tags:

views:

33

answers:

1
+1  Q: 

GetPixel in GDI

Using GetPixel, Is that right that you retrieve the pixel information that HDC temporarily store after you draw on each WM_PAINT call?

A: 

It will get the x,y pixel value of whatever bitmap is selected within the HDC.

http://msdn.microsoft.com/en-us/library/dd144909%28VS.85%29.aspx

GetPixel is quite slow, if I recall correctly. Depending on what you want to do, it will probably be a lot faster to access the raw bitmap data directly.

James
But when you do that, I'm not certain whether GDI will flush all operations directly to your raw bitmap (i.e. _during_ the WM_PAINT, between `BeginPaint()` and `EndPaint()` your bitmap may be out of sync.) Raymond Chen recently wrote on this topic: http://blogs.msdn.com/b/oldnewthing/archive/2010/09/23/10066473.aspx. You could of course "fix" that by calling `GdiFlush`, like `GetPixel` does. But that probably just makes direct access equally slow as calling GetPixel in the first place.
MSalters