Older Newer
Thu, 28 Oct 2021 07:23:54 . . . . SyneRyder [Add details of set_edge_mode behavior on src]


Changes by last author:

Added:
= src =

== Syntax ==

:int src(int x, int y, int z)

== Arguments ==

:x

::The x coordinate of the pixel to be retrieved.

:y

::The y coordinate of the pixel to be retrieved.

:z

::The channel number to be retrieved for the pixel

== Return ==

:The integer value of the specified pixel for the specified channel.

== Description ==

:This function retrieves the value of a specified channel 'z' from the image pixel at position (x,y). The x and y coordinates should usually be within the image, i.e., 0 <= x < X and 0 <= y < Y, while the channel number z should be in the range 0 to Z - 1, where Z is the maximum number of channels in the image. For an image in the usual RGB color mode, channel z=0 is the red channel, z=1 is the green channel, and z=2 is the blue channel. If the RGB image has an alpha (transparency) channel, this is z=3. For images in different color modes (e.g., CMYK) the channels will be different. Note that use of the src() function in the ForEveryTile handler forces FilterMeister to handle the image as a single (and possibly large) tile.

:If the specified coordinates lie outside the image dimensions, src will follow the edge-mirroring behavior defined by set_edge_mode. By default (ie edgeMode == 0), x and y will be clamped into the ranges 0 <= x < X and 0 <= y < Y. If edgeMode == 1, getArray will return a zero value, while edgeMode == 2 will wrap negative co-ordinate values to the other side of the image.

== Example ==

<code>

// A very simple slight blur!

%ffp

R,G,B: (src(x - 1, y, z) + src(x + 1, y, z)) / 2

A: a

</code>

== See Also ==

:pget, tget, t2get, pset, tset, t2set, set_edge_mode

== Comments ==

:How is pget different from src? src gets the pixel from the original image, while pget gets the pixel from the output buffer. Before your filter algorithm runs, the output buffer (i.e., the final output image) hasn't changed, which is why pget may seem identical to src at times. src is useful for times when you have modified the output, but still need data from the original image.