🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectDraw - Find Pixel Value

Started by
5 comments, last by B4 24 years, 7 months ago
yes i do.
easy way:
HDC dc;
lpddsPrimary->GetDC(&dc);
color = GetPixel(dc,x,y);
lpddsPrimary->ReleaseDC(dc); //don't forget

otherwise, if you really dislike GDI, Lock the surface and read it directly. should be in the docs.

Advertisement
Someone told me to lock it and read it directly, would this method be faster if I wanted to know the value of many pixels? If so, this is the method I want to use.
If you want speed, then I would suggest that you *never* use GDI.

The best method would be to lock the surface, then do *ALL* of your pixel reading, then unlock the surface.

Locking and Unlocking are still pretty slow, so you want to use it as least as possible, so only and the begining and end.

William Reiach - Human Extrodinaire

Marlene and Me


Is there any sample code where it shows how to Lock, then retrieve the pixel value? I do not understand how to do that part, and I was unable to find a section in the SDK documentation.
You could check out :
http://www.gamedev.net/reference/programming/directx/article541.asp

this is how I learned. (and you don't even have to leave this website)

William Reiach - Human Extrodinaire

Marlene and Me


I am starting to use DirectX, and using DirectDraw to draw a bitmap on the screen. After I draw the bitmap, I want to be able to retrieve the RGB value of any pixel I want, but I was unable to do this because DirectX creates a surface so that GetPixel() did not work, does anyone know how I can retrieve pixel value?
Thanks.
Thank you very much, this is exactly what I needed.

This topic is closed to new replies.

Advertisement