-
Bitmap saving problem
Hi all!
i'm trying to load an image into a dialog window, shrink it, then save that shrinked image back to the disk. i shrink it like this:
Code:
StretchBlt(g_hMemDC, 0, 0, SCREENWIDTH, SCREENHEIGHT,hdcDesk,0,0,SCREENWIDTH*2,SCREENHEIGHT*2,SRCCOPY);
Problem is that the dlg area which dosen't occupy the shrinked image becomes black, and when i save the image the black part is also saved as the bmp. Howto save only the shrinked image, without the black area?
Thanx for any help.
-
I guess you need to resize (create another one?) your g_hMemDC?
--
Mats
-
Create another bitmap in memory with CreateBitmap() or whatever it is, with the new shrunk dimensions, fill it with your HDC, then save it to disk.
-
thx that worked.
Code:
::StretchBlt(g_hMemDC, 0, 0, SCREENWIDTH, SCREENHEIGHT,hdcDesk,0,0,SCREENWIDTH*2,SCREENHEIGHT*2,SRCCOPY);
HBITMAP hbmpshrnk = CreateCompatibleBitmap(g_hMemDC, SCREENWIDTH/2, SCREENHEIGHT/2);
...
PBITMAPINFO bmpinfo = CreateBitmapInfoStruct(hwndgl, hbmpshrnk);
CreateBMPFile(hwndgl,"desktoptemp.bmp",bmpinfo,g_hDeskBmp,g_hMemDC);