Color + Alpha is killing me.... (Language Help)

by UglyMike ⌂ @, Brussels, Monday, February 04, 2013, 14:11 (2414 days ago)


I'm having great difficulty with the new color setup....

I use pixel(mousex,mousey) to get a color from the canvas.
This color is now returned as the value of a 4-byte construct, with the bytes denoting A,R,G and B

This 4-byte value has the most meaningfull byte (the Alpha) set to 255 (FF). Unfortnately, this also happens to turn the number negative.

I have a need to change the alpha of the returned color.
"COLOR RGB(R, G, B, A)" would allow me to play with the A(lpha) of the color, but only if I can extract the exact red, green, and blue components from the value returned by Pixel()

... therein lies the rub.

I've been trying for two days to write simple functions (getred, getgreen, getblue & getalpha) wich should return the correct color value (between 0 and 255). These work in a lot of cases, but not always. (like I already said, I'm not a coder.)

I went through the documentation. In the Color Documentation ( ) there are some errors. The formula used to get the value of of a ARGB set is of course not ((a*256+r)*256+b)*256+g (ARBG) but ((a*256+r)*256+g)*256+b (ARGB)
Also the white is said to be -460522 but should probably be -1 (-460522 almost full yellow) although I don't understand why (all binary ones, the first one is a minus but how do the others 31 bits turn into value 1? )

Anyone up to the task? I'll muddle on trying to get to grips with it but if someone already did something like this....

Complete thread:

 RSS Feed of thread

powered by my little forum