Merging two Gdiplus::Bitmap into one c++

  • Thread starter Thread starter Yozer2333
  • Start date Start date
Y

Yozer2333

Guest
Im trying to merge two Gdiplus::Bitmap and save result to disk.


pbmBitmap - is Gdiplus::Bitmap



At start i was trying to copy one bitmap into another and save copied bitmap to disk. Here is my code:


HBITMAP bitmapSource;
pbmBitmap->GetHBITMAP(Color::White, &bitmapSource); //create HBITMAP from Gdiplus::Bitmap

HDC dcDestination = CreateCompatibleDC(NULL); //create device contex for our destination bitmap
HBITMAP HBitmapDestination = CreateCompatibleBitmap(dcDestination, pbmBitmap->GetWidth(), pbmBitmap->GetHeight()); //create HBITMAP with correct size
SelectObject(dcDestination, dcDestination); //select created hbitmap on our destination dc

HDC dcSource = CreateCompatibleDC(NULL); //create device contex for our source bitmap
SelectObject(dcSource, bitmapSource); //select source bitmap on our source dc

BitBlt(dcDestination, 0, 0, pbmBitmap->GetWidth(), pbmBitmap->GetHeight(), dcSource, 0, 0, SRCCOPY); //copy piece of bitmap with correct size

SaveBitmap(dcDestination, HBitmapDestination, "OMG.bmp"); //not working i get 24kb bitmap
//SaveBitmap(dcSource, bitmapSource, "OMG.bmp"); //works like a boss, so its problem with SaveBitmap function



It should work, but i get 24kb black bitmap.
SaveBitmap is my custom function, it works when i try save source bitmap.
Why i cant copy one bitmap to another??

Continue reading...
 
Back
Top