surface_getpixel

This function can be used to get the colour of a specific pixel from a surface, using the local coordinates of the surface where (0,0) is the top left corner. This function should not be used very often as it is extremely slow and may cause a pause in your game.

NOTE: When working with surfaces there is the possibility that they can cease to exist at any time due to them being stored in texture memory. You should ALWAYS check that a surface exists using surface_exists() before referencing them directly.

 

Syntax:

surface_getpixel(surface_id, x, y);

ArgumentType Description
surface_idSurface The ID of the surface.
xReal The x position on the surface from which to get the pixel.
yReal The y position on the surface from which to get the pixel.

 

Returns:

Colour

 

Example:

col = surface_getpixel(surf, 56, 78 );

This will return the colour of the pixel at coordinates (56,78) of the surface indexed in the variable "surf".