Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnPaint(HWND hWnd,WPARAM wParam,LPARAM lParam, HDC hDC, PAINTSTRUCT* ps)
- {
- HDC hDCDoubleBuffer = CreateCompatibleDC(GetDC(hWnd));
- BITMAPINFO k;
- BITMAPINFOHEADER bitmapInfo;
- bitmapInfo.biSize = sizeof(BITMAPINFOHEADER);
- bitmapInfo.biWidth = 150;
- bitmapInfo.biHeight = 150;
- bitmapInfo.biPlanes = 1;
- bitmapInfo.biBitCount = 24;
- bitmapInfo.biCompression = BI_RGB;
- bitmapInfo.biSizeImage = 0;
- bitmapInfo.biXPelsPerMeter = 0;
- bitmapInfo.biYPelsPerMeter = 0;
- bitmapInfo.biClrUsed = 0;
- bitmapInfo.biClrImportant = 0;
- k.bmiHeader = bitmapInfo;
- HBITMAP bmp2= (HBITMAP)CreateCompatibleBitmap(GetDC(hWnd),bitmapInfo.biWidth,bitmapInfo.biHeight);
- HBITMAP oldBitmap;
- unsigned char a[1000000];
- unsigned char* data = a;
- int i,j,index,width,height;
- width = bitmapInfo.biWidth;
- height = bitmapInfo.biHeight;
- for(i = 0; i < height; i++)
- {
- for(j = 0; j < width; j++)
- {
- index = (width * i + j) * 3;
- data[index] = 255; //blue
- data[index + 1] = 0; //green
- data[index + 2] = 0; //red
- }
- }
- SetDIBits(hDCDoubleBuffer,bmp2,0, height, a, (BITMAPINFO*)&bitmapInfo, DIB_RGB_COLORS);
- oldBitmap = (HBITMAP)SelectObject(hDCDoubleBuffer,bmp2);
- BitBlt(hDC, 10, 10, bitmapInfo.biWidth, bitmapInfo.biHeight, hDCDoubleBuffer, 0, 0, SRCCOPY);
- SelectObject(hDCDoubleBuffer,oldBitmap);
- DeleteObject(bmp2);
- DeleteObject(oldBitmap);
- DeleteDC(hDCDoubleBuffer);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement