how can I convert an OpenCV image to an Microsoft Foundation Classes (MFC) CBitmap
object?
I tried the following, which failed,
cv::Mat tmp;
(Load opencv image ...)
cv::Size size = tmp.size();
CBitmap bitmap;
// 3 colors (RGB), 24bits (8bits*3channels)
if (!bitmap.CreateBitmap(128, 128, 1, 24, (void *)tmp.data)) {
TRACE0("Failed to create bitmap for image display\n");
return;
}
this results in a black image..
This post shares the method of converting an
IplImage
toCBitmap
:Based on this, you can achieve your goal by calling it as follows: