Jump to content

  • Log In with Google      Sign In   
  • Create Account

Finding the color of a pixel


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 24 October 1999 - 02:46 AM

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.


Sponsor:

#2 jamesmcc   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 October 1999 - 03:16 PM

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

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


#3 NuFAN   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 October 1999 - 02:46 AM

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).]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS