Returns the colour of the pixel corresponding a position in the surface.


GML Code Example

surface_getpixel(surface_id, x, y);

Argument Description
surface_id The ID of the surface.
x The x position on the surface from which to get the pixel.
y The y position on the surface from which to get the pixel.

Returns: Real


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. For further information see Surfaces.


GML Code 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".

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here