In the following article:
Finding a Bitmap contained inside another Bitmap
There is GDI+ method to load bitmap before use of LockBits funtion. We ant to use only PixelFormat24bppRGB because then we want LockBits to determine pixels of bitmap. It works pretty well, when we use .bmp image as source. But when I try to use another format, this is not working at all.
I tried to load .jpg with GDI+ and then to make a clone with only PixelFormat24bppRGB.
With no success.
Gdiplus::Bitmap* bm = new Bitmap(L"test.jpg");
Gdiplus::Bitmap* bigBmp = bm->Clone(0, 0, bm->GetWidth(), bm->GetHeight(), PixelFormat24bppRGB);
Gdiplus::BitmapData* bigbitmapData = new BitmapData;
Gdiplus::Rect bigRect(0, 0, bigBmp->GetWidth(), bigBmp->GetHeight());
bigBmp->LockBits(&bigRect, ImageLockModeRead, PixelFormat24bppRGB, bigbitmapData);
the bitmap from jpg is loaded correctly because I got correct width and height.
When I use in the above code:
Gdiplus::Bitmap* bm = new Bitmap(L"test.bmp");
(where .bmp I tested both 24-bits colors and 16 and 8-bits) everything is working fine.
I guess the problem is becasue of colors number in .jpg
How to fix .jpg for PixelFormat24bppRGB? Any idea? please.