Hi
My program gets a screen cap and displays that image on it's main dialog window. Then it lets the user to crop the image by drawing a square on the image. After the user releases the mouse after cropping, a child dialog window is opened to display the cropped image. Now i want to save this cropped image into the hard disk. i checked out the msdn article: Storing an Image and used the 2 functions found there to do this. Below is how i call those 2 function within the WM_LBUTTONUP msg handler of my main windows's dlgproc (the dlg that displays the uncropped screen cap).
Code:
case WM_LBUTTONUP:
//user releases the mouse ending the crop
if(bCrop)
{
//get ending mouse coords
iEndXPos = GET_X_LPARAM(lParam);
iEndYPos = GET_Y_LPARAM(lParam);
HWND hwndTempCap = CreateDialog(hInst,MAKEINTRESOURCE(IDD_TEMPCAP),NULL,DlgProcTempCap); //open the child dlg which should display the croped img
ShowWindow(hwndTempCap,SW_MAXIMIZE);
g_hTempMemDC = GetDC(hwndTempCap); //get the dc for the child dlg
BitBlt(g_hTempMemDC,0,0,iEndXPos-iStartXPos,iEndYPos-iStartYPos,
g_hMemDC,iStartXPos,iStartYPos,SRCCOPY); //copy the croped bitmap into the child dialogs' hdc
HBITMAP hbitmap = CreateCompatibleBitmap(g_hTempMemDC,200,200); // create a bmp for the child dlg
if(hbitmap==NULL)
PostQuitMessage(0);
PBITMAPINFO bmpinfo = CreateBitmapInfoStruct(hwnd, hbitmap); // msdn function - initialize members within a BITMAPINFOHEADER structure
CreateBMPFile(hwnd,"test.bmp",bmpinfo,hbitmap,g_hTempMemDC); // msdn function - save the croped img to disk
bCrop=FALSE;
}
break;
But after CreateBMPFile executes, what i get is a blank bitmap ("test.bmp") on the hard disk. CreateBitmapInfoStruct() and CreateBMPFile() cannot go wrong because i found them in msdn, so it's me somthing doing wrong. what's i'm doing wrong plase? Please help.
Thanks.