surface_save_part

This function will save a 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).

 

Syntax:

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

ArgumentType Description
surface_idSurface The ID of the surface to set as the drawing target.
fnameString The name of the saved image file.
xReal The starting x position within the surface.
yReal The starting y position within the surface.
widthReal The width of the part to save.
heightReal The 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.