Bitmap bmp(100, 100, PixelFormat32bppARGB);
void Example_LockBits2() { UINT* pixels; // Lock a 50xs30 rectangular portion of the bitmap for writing. BitmapData bitmapData; Rect rect(20, 10, 50, 30); bmp.LockBits( &rect, ImageLockModeWrite, PixelFormat32bppARGB, &bitmapData); // Write to the temporary buffer provided by LockBits. pixels = (UINT*)bitmapData.Scan0; for (UINT row = 0; row < 30; ++row) { for (UINT col = 0; col < 50; ++col) { pixels[row * bitmapData.Stride / 4 + col] = 0xff00ff00; } } // Commit the changes, and unlock the 50x30 portion of the bitmap. bmp.UnlockBits(&bitmapData); }
case WM_PAINT: { Example_LockBits2(); Graphics grap(GetDC(hwnd)); grap.DrawImage(&bmp, 150, 100); break; }
Example_LockBits2
DrawImage
Graphics myGraphics(GetDC(hWnd));PointF point(0., 0.);Image* image = new Image(L"BACK12.BMP");myGraphics.DrawImage(image, point);
BitmapData bitmapData = bmp.LockBits( &rect, ImageLockModeWrite, PixelFormat32bppARGB, &bitmapData);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)