Older Newer
Fri, 27 Dec 2019 10:14:31 . . . . SyneRyder [Reformat example code for eBook screens]


Changes by last author:

Added:
= rgb2iuv =

== Syntax ==

int rgb2iuv(int r, int g, int b, int z)

== Arguments ==

:r

::Red value

:g

::Green value

:b

::Blue value

:z

::Determines which value is returned. z=0 for i, z=1 for u, z=2 for v

== Return ==

Returns the i, u or v value depending on the value of z

== Description ==

Lets you convert RGB values to YUV values.

== Example ==

<code>

%ffp

ctl(0): "Y Adjust",range=(-255,255),val=0

ctl(1): "U Adjust",range=(-255,255),val=0

ctl(2): "V Adjust",range=(-255,255),val=0

ForEveryTile:

{

int r,g,b,i,u,v;

for (y = y_start; y &lt; y_end; y++) {

updateProgress(y,y_end);

for (x = x_start; x &lt; x_end; x++) {

r=src(x,y,0);

g=src(x,y,1);

b=src(x,y,2);

i=rgb2iuv(r,g,b,0) + ctl(0);

u=rgb2iuv(r,g,b,1) + ctl(1);

v=rgb2iuv(r,g,b,2) + ctl(2);

r=iuv2rgb(i,u,v,0);

g=iuv2rgb(i,u,v,1);

b=iuv2rgb(i,u,v,2);

pset(x, y, 0, r);

pset(x, y, 1, g);

pset(x, y, 2, b);

}

}

return true;

}

</code>

== See Also ==

iuv2rgb

== Comments ==

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.