surface_getpixel_ext

This function gets the full abgr 32-bit value of any pixel of a (previously created) surface.

If the surface uses a floating point format, an array will be returned instead, similar to surface_getpixel(). However, as opposed to that function (which only gives you RGB), this function will give you 4 elements in the array (RGBA).

NOTE This function will have a huge performance hit and so should only be used when absolutely necessary.

 

Syntax:

surface_getpixel_ext(surface_id, x, y);

ArgumentTypeDescription
surface_idSurfaceThe surface to use.
xRealThe x coordinate of the pixel to check
yRealThe y coordinate of the pixel to check

 

Returns:

Real or Array

 

Example:

col = surface_getpixel_ext(mouse_x, mouse_y);
alpha = (col >> 24) & 255;
blue = (col >> 16) & 255;
green = (col >> 8) & 255;
red = col & 255;

The above code will get the 32-bit colour value at the position of the mouse and then split it into its component values, storing them in variables.