Convert Bitmap to Mat

前端 未结 1 450
遥遥无期
遥遥无期 2021-01-17 00:16

I need to convert Gdiplus::Bitmap to cv::Map format. I\'m using this code to do this:

Gdiplus::Bitmap* enhanced = ...; // some Bitmap
Gdiplus::BitmapData bmp         


        
相关标签:
1条回答
  • 2021-01-17 00:50

    if you're constructing a cv::Mat from your Bitmap, you will have to use

    cv::imshow("w", imageMap);
    

    to draw it.

    again, the address of a cv::Mat is not the same as an IplImage* required by cvShowImage();

    (btw, you should get rid of all other deprecated c-api calls, too.)

    also, be a bit careful, a Mat constructed the way you do, has a borrowed pointer to the pixels.

    i don't know anything about gdi+, but if that pointer goes out of scope or gets invalid when you call enhanced->UnlockRect (or what it was called), you will need to do

    Mat safeImg = imageMap.clone();
    

    to achieve a 'deep' copy.

    0 讨论(0)
提交回复
热议问题