On the window, I created a rectangle and filled it with a brush, now I want to save it in HBTIMAP and display it again on window
so, first I created a rectangle
Code:HDC hdc,bmp_hdc; HBITMAP hPicture; ..... hdc = BeginPaint(hwnd, &ps); hBrush = CreateSolidBrush(RGB(230,230,230)); // Creating brush for background SelectObject(hdc, hBrush); Rectangle(hdc, 19, 49, 196, 194); // Drawing rectange that is 1 pixel larger than picture in every dimension DeleteObject(hBrush); /*The rectangle was created and filled with color, secondly, created a BITMAPINFO structure;*/ BITMAPINFO bmp_info; ZeroMemory( &bmp_info.bmiHeader, sizeof(BITMAPINFOHEADER) ); bmp_info.bmiHeader.biWidth = 16;//10;//4;//176; // width should be divided by 4 bmp_info.bmiHeader.biHeight = 16; // should be maybe minus mark to make it right bmp_info.bmiHeader.biPlanes = 1; bmp_info.bmiHeader.biBitCount = 8; // 24bit colors bmp_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmp_info.bmiHeader.biSizeImage = 0; bmp_info.bmiHeader.biCompression = BI_RGB; // No compression bmp_info.bmiHeader.biClrUsed = 0; // When set to 0, colors used is counted on biBitCount bmp_info.bmiHeader.biClrImportant= 0; /*rest of the codes, I did like this:*/ bmp_hdc = CreateCompatibleDC(hdc); hPicture = CreateDIBSection(hdc, &bmp_info, DIB_RGB_COLORS,NULL,NULL,0); SelectObject(bmp_hdc,hPicture); //now I copy size 16X16 from that rectangle to hPicture BitBlt(bmp_hdc,0,0,16,16,hdc,19,49,SRCCOPY); 16, NULL, (BITMAPINFO*)&bmp_info, DIB_RGB_COLORS); //again, show the hPicture in position (20,30) back in hdc BitBlt(hdc,20,30,16,16,bmp_hdc,0,0,SRCCOPY);
but I could not display what I had copied from that rectangle, what's wrong with my code, thanks!!!!
Sorry for un-clear codes!!