Suggestion: Getting pixel's RGB values

Started by Khris, Sat 29/04/2006 16:10:23

Previous topic - Next topic

Khris

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?

Wretched

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.

GarageGothic

#2
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.

Scorpiorus

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

SSH

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.
12

GarageGothic

#5
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).

SSH

#6
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
12

Pumaman

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 ;)


SMF spam blocked by CleanTalk