surface_save_part

This function saves part of a surface to disc using the given filename.

The surface must be saved as a *.png format file, and the (x, y) position must be given as local coordinates to the surface, bearing in mind that the top left corner of the surface is always (0, 0).

NOTE This function will only work with surfaces that use the surface_rgba8unorm (default) surface format.

 

Syntax:

surface_save_part(surface_id, fname, x, y, width, height);

ArgumentTypeDescription
surface_idSurfaceThe surface to set as the drawing target.
fnameStringThe name of the saved image file.
xRealThe starting x position within the surface.
yRealThe starting y position within the surface.
widthRealThe width of the part to save.
heightRealThe height of the part to save.

 

Returns:

N/A

 

Example:

if (keyboard_check_pressed(ord("S")))
{
    surface_save_part(surf, "test.png", 0, 0, 100, 100);
}

The above code will check to see if the user presses the "S" key on the keyboard and if they do it will save a part of the surface indexed in the variable surf to disc.