How to get pixel color w/ a LPDIRECTDRAWSURFACE
You can just lock the surface. And then access the surface byte to byte, then you can change or get the color of the pixel.
Thanks to the previous post. That lead me to the right direction. However, after spending 2 hours trying, I just couldn't figure out how to do it. However, I found in Andre Lamothe's game engine he has a locksurface function that worked for me.
--from the help----
IDirectDrawSurface7::GetPixelFormat
The IDirectDrawSurface7::GetPixelFormat method retrieves the color and pixel format of the surface.
HRESULT GetPixelFormat(
LPDDPIXELFORMAT lpDDPixelFormat
);
Parameters
lpDDPixelFormat
Address of the DDPIXELFORMAT structure to be filled with a detailed description of the current pixel and color space format of the surface.
This can range from extremely easy to extremely difficult. If your in 8-Bit (palletized) mode then you can simply lock it and look at the pixel value you need. The color is whatever is in the pallete at the value you found. If your in 16Bit mode this can be very difficult. You have to decode the value since there are many different 16Bit color formats.
--TheGoop
Yes, my bad. But as you said, after getting the pixel data, you need to know the format. GetPixelFormat will tell you just that.
Six
How do you find the pixel color at a particular point on a LPDIRECTDRAWSURFACE?
BYTE color = (BYTE) ddsd.lpSurface[y*ddsd.lPitch+x];