Rgbscale() In Fenix


ruckage

Certified Guru
Joined
Oct 15, 2006
Messages
659
Hello,

Anybody have a clear understanding of how to use rgbscale() as it seems like it could be very useful but I'm struggling with it as there appears to be no info on it's usage.
So far I've figured out the basic usage which is:

rgbscale(library,map,r,g,b ) and that r,g and b need to be a value between 0-1

What I need to know now is if there is a way to reverse the effect. Any other info regarding its usage would also be greatly appreciated.
 
You know, Ruckage, you can always show your face in the #bilge sometimes, I'm sure they know.

Going to ask about it now... I assume you have checked the wiki and there is nothing on there?
 
Quiest said:
You know, Ruckage, you can always show your face in the #bilge sometimes, I'm sure they know.

Going to ask about it now... I assume you have checked the wiki and there is nothing on there?
Thanks, I did think of going to #bilge but I was in no real hurry for an answer to this and was busy with other stuff. I checked the wiki but no mention of it.
 
Last edited by a moderator:
rgbscale( int fileID , int graphID , float r , float g , float b )

This will convert the specified graph by using the specified colour as a reference. The converted graph will have only the specified colour and lighter/darker colours.

The exact formula is:
CODE

for every pixel:
c = 0.3 * oldpixel_r + 0.59 * oldpixel_g + 0.11 * oldpixel_b
newpixel_r = r * c;
newpixel_g = g * c;
newpixel_b = b * c;


where r,g,b are the specified r,g,b.

fileID,graphID - the graphic to be converted
r,g,b - The colour used as a reference.

See also
* greyscale
* blur
* filter
 
The following example came with documentation for Fenix 0.83b (I don't have the files that are loaded in the example):

CODE

Program Test_RGBSCALE;
Global
Float r,g,b;
rr,rg,rb;
Float rgb[]=0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0;
scale=0;
Begin
full_screen=false;
graph_mode=mode_16bits;
load_fpg("fpg2.fpg");
load_png("triangulo_16.png");
write(0,10,10,3,"Test RGBSCALE para Fenix...");
write(0,160,190,4,"Pulsa ESC para Salir...");
put_screen(0,1);
x=160; y=120; graph=map_clone(0,1000); size=200;
write(0,160,70,4,"Valores R G B:");
write_float(0,110,80,4,&r);
write_float(0,160,80,4,&g);
write_float(0,210,80,4,&b);
timer=0;
Repeat
If(timer>100 || !scale)
unload_map(0,graph);
graph=map_clone(0,1000);
rr=rand(0,10);
rg=rand(0,10);
rb=rand(0,10);
r=rgb[rr];
g=rgb[rg];
b=rgb[rb];
rgbscale(0,graph,r,g,b);
timer=0;
scale=1;
End
Frame;
Until(key(_esc))
End


Since they are constantly cloning the graphic before applying rgbscale(), the effect probably isn't reversible. If you don't want to clone your maps, you could try to mimic the effect of rgbscale() using blendops.
 
It's not reversible indeed. You can easily create the same effect with blendops, indeed - again. Well if you want it to be reversible you'd need to use blendop_assign() and not blendop_apply(), but using map_clone() is less hassle.
 
Thanks for the help everyone, that will come in very useful. Was going to ask if you wanted me to add this to the wiki but I see you already have. Thanks again.
 
Back
Top