Finding the color of a pixel

Started by
1 comment, last by GameDev.net 24 years, 6 months ago
where ddsd is a directdraw surface
x,y are you co-ordinates

((BYTE *) ddsd.lpSurface)[y * ddsd.lPitch + x]

Advertisement
Hey All,

I know that there has to be a way to determine the color of a pixel in 256 color mode, I'm just not sure what is is :-).

Can anyone help?

Thanks.

Ok,
here's some source code :

code:
UCHAR* buffer;DDSURFACEDESC2 ddsd;UCHAR TheEntry;PALETTEENTRY entry;int r, g, b;ZeroMemory(&ddsd, sizeof(ddsd));ddsd.dwSize = sizeof(ddsd);lpDDSWhatever->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);buffer = (UCHAR*)ddsd.lpSurface;TheEntry = buffer[x+(y*ddsd.lPitch)];lpDDSWhatever->Unlock(NULL);lpDDSWhatever->GetEntries(0, 0, 1, &entry[TheEntry]);r = entry.peRed;g = entry.peGreen;b = entry.peBlue;

This should work, I hope.

CU

------------------
Skullpture Entertainment
#40842461

[This message has been edited by NuFAN (edited October 24, 1999).]

Graphix Coding @Skullpture Entertainmenthttp://www.skullpture.de

This topic is closed to new replies.

Advertisement