Retrieving RGB values

Started by Chrille, Tue 13/07/2010 18:20:12

Previous topic - Next topic

Chrille

Is it possible to retrieve a color value from the screen? Like, what's the value of Red, Green or Blue at X & Y?
GASPOP software
http://www.gaspop.com

Calin Leafshade

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

Chrille

Thanks! I'll have a look at it
GASPOP software
http://www.gaspop.com

Dualnames

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
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

#4
This should work:

Code: ags
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

Chrille

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!
GASPOP software
http://www.gaspop.com

Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk