Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Chrille on Tue 13/07/2010 18:20:12

Title: Retrieving RGB values
Post by: Chrille on Tue 13/07/2010 18:20:12
Is it possible to retrieve a color value from the screen? Like, what's the value of Red, Green or Blue at X & Y?
Title: Re: Retrieving RGB values
Post by: Calin Leafshade on Tue 13/07/2010 18:22:31
Yea the latest version of my utility module contains functions to convert AGS colour values to RGB and HSL and back again but its not uploaded at the moment..

in the mean time GG posted a routine in my sprite deformation thread in the Tech forum which does it
Title: Re: Retrieving RGB values
Post by: Chrille on Tue 13/07/2010 18:36:09
Thanks! I'll have a look at it
Title: Re: Retrieving RGB values
Post by: Dualnames on Tue 13/07/2010 18:47:02
Or you can additionally go and SEARCH the forums Chrille and find it being already there. (from May 2006!)

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26432.0

And since the link doesn't work. Shame.
Oh, dawg, I have that one too.

http://www.xenogiagames.com/dngames/RawGetRGB.rar
Title: Re: Retrieving RGB values
Post by: Khris on Tue 13/07/2010 18:50:54
This should work:

int R, G, B;

void ColorToRGB(int c) {
 B = c % 32;
 c -= B;
 B = B * 8;
 G = c % 2048;
 c -= G;
 G = G / 8;
 R = c / 256;
}

void GetPixel(int x, int y) {
 DynamicSprite*d =  DynamicSprite.CreateFromScreenShot();
 DrawingSurface*ds = d.GetDrawingSurface();
 ColorToRGB(ds.GetPixel(x, y));
  ds.Release();
  d.Delete();
}


EDIT: added tidying up
Title: Re: Retrieving RGB values
Post by: Chrille on Tue 13/07/2010 20:09:05
That's perfect, Khris. Saves me using a module too. I'll try that right away.

I actually tried searching first, Dualnames. Problem was I didn't think of searching for RGB. When searching for RGB just now, among the results I was surprised and happy to find a thread on my crummy old game Pleurghburg (mispelled pleurgburg, how rude!).

Thanks again!
Title: Re: Retrieving RGB values
Post by: Dualnames on Tue 13/07/2010 22:36:57
I'm not teaching you, that'd be blasphemy.  :D

I'm just pointing out my coolness in front of you. So enjoy my coolness factor.