Hi.
I'm simulate rain in my game: http://www.miniracingonline.com
I convert to gray scale in TBakground to simulate gray day. ValueRain is for more or slow rain (slow or more color)
[pascal]
// DXImageList.Items[1] = Original color Background, not change
// DXImageList.Items[2] = Final Background (chage color)
// for eah pixel X,Y:
ColorPixel := DXImageList.Items[1].PatternSurfaces[0].Pixels[X,Y]; //original color image
R := GetRValue(ColorPixel);
G := GetGValue(ColorPixel);
B := GetBValue(ColorPixel);
ColorAver := (R + G + B) div 3;
if R < ColorAver then
R := Min(R+ValueRain ,ColorAver)
else
R := Max(R-ValueRain ,ColorAver);
if G < ColorAverthen
G := Min(G+ValueRain ,ColorAver)
else
G := Max(G-ValueRain ,ColorAver);
if B < ColorAverthen
B := Min(B+ValueRain ,ColorAver)
else
B := Max(B-ValueRain ,ColorAver);
// aply new color to background
DXImageList.Items[2].PatternSurfaces[0].Pixels[X,Y] := RGB(R,G,B);
[/pascal]
I paint 8 pixels by milisec but is MORE slow (100 fps to 20 fps :x ). Normally Background is 5000x3500 pixels :shock:
Another tecnique to change color faster ?
Thanks
Original color image:
Color of Full Rain:
Bookmarks