Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: zabnat on Fri 08/08/2008 16:02:57

Title: GetPixel behaviour?
Post by: zabnat on Fri 08/08/2008 16:02:57
Does this function only work on 256-color mode?
I have 16-bit mode and it does return values consistently, but the values are different than I would expect.
For example:

DrawingSurface *background = Room.GetDrawingSurfaceForBackground();
background.Clear(1);
background.DrawingColor = 20;
background.DrawRectangle(0, 0, 320, 100);
int color1 = background.GetPixel(160,50);
int color2 = background.GetPixel(160,150);

and now color1 == 16904 and color2 == 20 but I would have expected that color1 == 20 and color2 == 1.

EDIT:
Well, I was able to find the solution. Have I really been able to dodge this in the manual or is it not in there?  ???
Anyway: the first 32 (0-32) colors seem to be special so I can't set them as DrawingColor and use the GetPixel to get the same number back again. So solution is to use color numbers starting from 32.

ps. I did it again. Wrestle with something for many hours/days and right after posting about it find the solution for it.
Title: Re: GetPixel behaviour?
Post by: Pumaman on Fri 08/08/2008 19:34:45
That's a good point, I'll update the docs for GetPixel to mention it.