Image Manipulation

imggetpixel

Gets a pixel value at a particular position on the image.

The format string describes how you want to retrieve the data.

Syntax

imggetpixel(handle, x, y, "format")

Remarks

If x or y are out of bounds then the coordinates are wrapped (so (-1,-1) refers to the bottom right hand corner of the image).

Example

; Open the image:
img = imgopen("delete.png")

; Loop over each pixel in the image:
.for y = 0, y < imgheight(img), ++y
    .for x = 0, x < imgwidth(img), ++x
    
        ; Grab the luminosity of each pixel to two bits:
        l = imggetpixel(img, x, y, 'l2');
        
        ; Convert to an 'ASCII-art' brightness:
        c = choose(l + 1, ' ', '.', '+', '#');
        .echo c, c
        
    .loop
    .echoln
.loop

/*
          ....++++....
        ++++########++..
      ++######++++++##++..
    ++++##++++++++++++##++..
  ..++##++++++++++++++++##..
  ..##++++++++++++++++++++++..
  ++##++++############++++++..
  ++##++++############++++++..
  ..++++++++++++++++++++++++..
  ....##++++++++++++++++++..
    ..++++++++++++++++++++..
      ..++++++++++++++++..
        ....++++++++....
            ........
*/