This will find the pixel in this image, located at x/y, and then yield it's attributes into the associated block.
Red, green and blue are each a value from 0 to 255, whilst alpha is a value from 0.0 to 1.0.
Note that no yielding is done if the pixel is located outside of the block.
ship = new Image( 'ship.png' )
ship.getPixel( x, y, ) do |red, green, blue, alpha|
// do work here
getPixel can also be used without an attached block. This version will pack the values up into an ARGB integer, and return the value. If the value is not found, then null is returned.
To get each value out you can use bit-shifting. Note that all values, including the alpha component, are each a value from 0 to 255.
pixel = image.getPixel( x, y )
alpha = (pixel >> 24) & 0xff
red = (pixel >> 16) & 0xff
green = (pixel >> 8) & 0xff
blue = pixel & 0xff