getPixel

Syntax

int getPixel(int x, int y)

Arguments

x
X-coordinate (in pixels) of the relative position (originating top-left at 0, 0) in the control where you want to retrieve a pixel color from.
y
Y-coordinate (in pixels) of the relative position (originating top-left at 0, 0) in the control where you want to retrieve a pixel color from.

Returns

The 8-bit RGB color value of the pixel at the given co-ordinates as a single 32-bit integer.

Description

Call getPixel to retrieve an individual pixel color from an OWNERDRAW control. First call startSetPixel, then use getPixel, setPixel and any of the other Control drawing functions to draw to the control. Finish with a call to endSetPixel. This function is not for getting pixels from the preview / final image; use src or pget for that instead.

Example

%fml
ctl[0]: OWNERDRAW, Color=RGB(0,0,0), Size=(100,100)

OnFilterStart: {

  // Get the size of the canvas
  int width, height;
  startSetPixel(0);
  width = getSetPixelWidth();
  height = getSetPixelHeight();

  // Draw purple line at y = 100
  for (int xp = 0; xp < width; xp++) {
    setPixel(xp, 100, RGB(192,0,255));
  }

  // Duplicate at y = 200 line at y = 100
  for (int xp = 0; xp < width; xp++) {
    setPixel(xp, 200, getPixel(xp, 100));
  }
  endSetPixel(0);

  return false;
}

See Also

startSetPixel, setPixel, endSetPixel

Comments

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