3 registered members (Akow, TipmyPip, tomaslolo),
788
guests, and 11
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Merging colors
#317842
04/02/10 23:42
04/02/10 23:42
|
Joined: Mar 2010
Posts: 75
YellowAfterlife
OP
Junior Member
|
OP
Junior Member
Joined: Mar 2010
Posts: 75
|
This isn't just for LC, this is about to be used in midlet programming too. Intruduction. A variable type 'pixel' presents, which consists of: .red (byte,0-255) .green (byte,0-255) .blue (byte,0-255) .alpha (byte,0-255) Device screen is represented by array of 'pixel's, to allow free image manipulations. So. Drawing a RGB pixel is simpliest thing, R2 = R1, G2 = G1, B2 = B1. Drawing a ARGB pixel onto a RGB needs better math, R2 = R0 + R1 * A1 / 255 G2 = G0 + G1 * A1 / 255 B2 = B0 + B1 * A1 / 255 But still obviously easy. But how to draw a ARGB pixel onto another ARGB pixel? The effect that I am searching for, produces the following output (ARGB): (255,0,0,128) + (0,0,255,128) = (85,0,170,192) What color & alpha manipulations need to be done to achieve that?
Unfortunately, I've not worked with 3dGS for a while now, but it was fun
|
|
|
Re: Merging colors
[Re: YellowAfterlife]
#317843
04/03/10 00:18
04/03/10 00:18
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
The effect that I am searching for, produces the following output (ARGB): (255,0,0,128) + (0,0,255,128) = (85,0,170,192) Which component is the alpha value, the last or the first one? In the latter case, you add an invisible (alpha = 0) pixel? Where did you get the end result from?
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Merging colors
[Re: Superku]
#317847
04/03/10 00:38
04/03/10 00:38
|
Joined: Jul 2004
Posts: 1,710
MMike
Serious User
|
Serious User
Joined: Jul 2004
Posts: 1,710
|
ok thats addictive, so .. it would be.... yello + yello = yelloe right :S HEHE well. i think you have to work with hue channel numbers or maybe not, like, a cicle is 360º degrees right.. on your circle the max is 255.. now you have to know that 255+ 10 wont be 265 but 005 in a color channel i think :S and 255 + 10 should be 255 again, because thats the max of the variable of color ... But anyway follow my tip! you to a 260 or 360 to be your 255 of red for right to you have to write a function for that... but that aint work. CHECK THIS SOURCE! with CODE examples.. (i think it might be handy...) : HERE
Last edited by MMike; 04/03/10 00:52.
|
|
|
Re: Merging colors
[Re: MMike]
#317866
04/03/10 08:55
04/03/10 08:55
|
Joined: Mar 2010
Posts: 75
YellowAfterlife
OP
Junior Member
|
OP
Junior Member
Joined: Mar 2010
Posts: 75
|
Ah well. Google helps a bit. Final function looks like the following:
procedure px(x,y,red,green,blue,alpha: integer);
var s_red,s_green,s_blue,s_alpha,t_red,t_green,t_blue,t_alpha: integer;
var t1,t2,t3: real;
begin
s_red := ord(scrr[x,y]);
s_green := ord(scrg[x,y]);
s_blue := ord(scrb[x,y]);
s_alpha := ord(scra[x,y]);
t1 := s_alpha * alpha;
t_alpha := alpha + s_alpha - trunc(t1 / 255);
t1 := 255 - alpha;
t2 := red * alpha;
t3 := s_red * s_alpha * t1;
t_red := trunc(t2 / 255 + (t3 / 255) / 255);
t2 := green * alpha;
t3 := s_green * s_alpha * t1;
t_green := trunc(t2 / 255 + (t3 / 255) / 255);
t2 := blue * alpha;
t3 := s_blue * s_alpha * t1;
t_blue := trunc(t2 / 255 + (t3 / 255) / 255);
scrr[x,y] := chr(t_red);
scrg[x,y] := chr(t_green);
scrb[x,y] := chr(t_blue);
scra[x,y] := chr(t_alpha);
end;
scrr,srcg,srcb,sra = screen-sized buffer of Char(0-255). Thanks for trying to help, though.
Unfortunately, I've not worked with 3dGS for a while now, but it was fun
|
|
|
|