• Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Finding the color of a pixel

This topic is 6663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

where ddsd is a directdraw surface
x,y are you co-ordinates

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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).]

Share this post


Link to post
Share on other sites

  • Advertisement