tags:

views:

200

answers:

2

I have an array of RGB values, whose size I can guarantee to match the client area of a window on screen.

Using the Win32 API, what are the easiest and fastest ways to get the contents of my array on the screen in response to a WM_PAINT message?

If it makes it simpler/faster, we can assume it's a 32-bit display and each element of the array is 32 bits.

A: 

Use BitBlt

Paul Betts
I suppose I'm really asking how to get a DC I can blit from my array, since BitBlt needs a source DC
James Hopkin
Prefer SetDIBitsToDevice(), but you use "HDC hdc = GetDC(hwnd); HDC hdcBitmap = CreateCompatableDC(hdc); ReleaseDC(hdc); DeleteObject(SelectObject(hdcBitmap, hBitmap));" in your init. DeleteObject() releases the 1x1@1bpp default bitmap.
Simon Buchan
+1  A: 

If you have complete control over your backing format, use a DIB format and a dummy BITMAPINFO structure. Then use SetDIBitsToDevice to copy to the DC.

Be aware of the peculiarities of the DIB format - every line has to be extended to a multiple of 4 bytes, the first line of the buffer is the bottom line of the image, and the byte order is Blue,Green,Red.

Mark Ransom