Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Khris on Sat 29/04/2006 16:10:23

Title: Suggestion: Getting pixel's RGB values
Post by: Khris on Sat 29/04/2006 16:10:23
I'd find it useful to be able to read a pixel's color information off the current screen or a (dynamic) sprite.

Maybe a DynamicSprite.GetRGB(int x, int y) command or something like that.

If that was possible, I wouldn't have to use a map to, say, draw a 3D-texture.
Or is there a way to achieve this that I'm not aware of?
Title: Re: Suggestion: Getting pixel's RGB values
Post by: Wretched on Sat 29/04/2006 16:43:50
Yeah, I've often missed a RawGetColourAt(), function or something, I can only suggest you load in your own data file with the sprites texture in and reference that.
Title: Re: Suggestion: Getting pixel's RGB values
Post by: GarageGothic on Sat 29/04/2006 18:08:44
Yes, that would be very helpful indeed. I would also like a way to copy the alpha channel of one sprite onto another sprite of the same dimension.

Edit: not necessarily alpha channel, since that indicates 32 bit sprites. I rather meant transparency aka pink pixels. For non-antialiased sprites it would be possible to script a workaround if the above suggestion was implemented.
Title: Re: Suggestion: Getting pixel's RGB values
Post by: Scorpiorus on Sat 29/04/2006 22:12:31
Yeah, I have come across this where I needed to read pixels.

It's especially important for high/true-color games that doesn't use palette.

Many graphic effects could then be done via scripting, such as: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26274.0
Title: Re: Suggestion: Getting pixel's RGB values
Post by: SSH on Sun 30/04/2006 00:13:52
Quote from: GarageGothic on Sat 29/04/2006 18:08:44
Edit: not necessarily alpha channel, since that indicates 32 bit sprites. I rather meant transparency aka pink pixels. For non-antialiased sprites it would be possible to script a workaround if the above suggestion was implemented.

You can have transparency in user-made dynamic sprites. You just need to make the BG the right colour. I use this in SpriteFonts.
Title: Re: Suggestion: Getting pixel's RGB values
Post by: GarageGothic on Sun 30/04/2006 01:47:06
SSH, perhaps I didn't explain myself properly. I'm aware you can use (255, 0, 255) as a masking color. That's not the issue. What I meant was acquiring that transparency of an existing sprite, say a character, and applying the transparency to a DynamicSprite of the same dimensions. (Or simply the ability to RawDraw the pink pixels, visibly, from a sprite, but not the rest of the sprite - the reverse of how RawDrawing usually works).
Title: Re: Suggestion: Getting pixel's RGB values
Post by: SSH on Thu 04/05/2006 17:19:03
By the way, I just thought of a horrible way to do a RawGetRGB... grab the pixle as a 1x1 dynamic sprite, save as a BMP, load the BMP via the file interface and using the info in: http://www.daubnet.com/formats/BMP.html
http://web.uccs.edu/wbahn/ECE1021/STATIC/REFERENCES/bmpfileformat.htm
etc.
we find that at offset 10, there is a long giving the offset of the pixel data. Then we go to there and read the blue, green and red values. It would probably take some teaking to get right and be slow, but if it is required only every now and then, it shouldn't be a problem...

And here it is: RawGetRGB module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26432.0)
Title: Re: Suggestion: Getting pixel's RGB values
Post by: Pumaman on Mon 08/05/2006 20:23:44
Dynamicsprite.GetRGB/SetRGB functions sound useful to me, certainly worthy of tracker entry.

SSH, I think you win Most Hideous Hack award 2006, well done ;)
Title: Re: Suggestion: Getting pixel's RGB values
Post by: strazer on Sun 14/05/2006 13:59:56
Tracker'd: http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=569