Skip to content

image_tools

YYBartT edited this page Sep 11, 2024 · 1 revision

Image Tools

This module provides interaction with images on the device.

Functions

These are the functions in this module:



Back To Top

MobileUtils_Image_Crop

This function crops the image at the given file path to the given dimensions.


Syntax:

MobileUtils_Image_Crop(path, w, h, x, y)
Argument Type Description
path String The path to the image
w Real The width of the zone to crop
h Real The height of the zone to crop
x Real The x offset of the zone to crop
y Real The y offset of the zone to crop



Returns:

N/A


Example:

if(async_load[?"type"] == "MobileUtils_Gallery_Open")
{
    var _path = async_load[?"path"];
    if(MobileUtils_Image_Width(_path) != 300 or MobileUtils_Image_Height(_path) != 300)
    {
        MobileUtils_Image_Resize(_path, 300, 300);
        MobileUtils_Image_Crop(_path, 100, 100, 100, 100);
        MobileUtils_Image_Resize(_path, 300, 300);
    }
    Obj_MobileUtils_Gallery_Picture.sprite = sprite_add(_path, 0, 0, 0, 0, 0);
}

The code above was extracted from the MobileUtils_Gallery_Open sample and shows an example on how to crop an image (for a complete example please refer to the respective function).




Back To Top

MobileUtils_Image_Height

This function returns the height of an image.


Syntax:

MobileUtils_Image_Height(path)
Argument Type Description
path String The path to the image



Returns:

Real


Example:

if(async_load[?"type"] == "MobileUtils_Gallery_Open")
{
    var _path = async_load[?"path"];
    if(MobileUtils_Image_Width(_path) != 300 or MobileUtils_Image_Height(_path) != 300)
    {
        MobileUtils_Image_Resize(_path, 300, 300);
        MobileUtils_Image_Crop(_path, 100, 100, 100, 100);
        MobileUtils_Image_Resize(_path, 300, 300);
    }
    Obj_MobileUtils_Gallery_Picture.sprite = sprite_add(_path, 0, 0, 0, 0, 0);
}

The code above was extracted from the MobileUtils_Gallery_Open sample and shows an example on how to get the height of an image (for a complete example please refer to the respective function).




Back To Top

MobileUtils_Image_Resize

This function resizes an image.


Syntax:

MobileUtils_Image_Resize(path, width, height)
Argument Type Description
path String The path to the image
width Real The width of the zone to crop
height Real The height of the zone to crop



Returns:

N/A


Example:

if(async_load[?"type"] == "MobileUtils_Gallery_Open")
{
    var _path = async_load[?"path"];
    if(MobileUtils_Image_Width(_path) != 300 or MobileUtils_Image_Height(_path) != 300)
    {
        MobileUtils_Image_Resize(_path, 300, 300);
        MobileUtils_Image_Crop(_path, 100, 100, 100, 100);
        MobileUtils_Image_Resize(_path, 300, 300);
    }
    Obj_MobileUtils_Gallery_Picture.sprite = sprite_add(_path, 0, 0, 0, 0, 0);
}

The code above was extracted from the MobileUtils_Gallery_Open sample and shows an example on how to resize an image (for a complete example please refer to the respective function).




Back To Top

MobileUtils_Image_Width

This function returns the width of an image.


Syntax:

MobileUtils_Image_Width(path)
Argument Type Description
path String The path to the image



Returns:

Real


Example:

if(async_load[?"type"] == "MobileUtils_Gallery_Open")
{
    var _path = async_load[?"path"];
    if(MobileUtils_Image_Width(_path) != 300 or MobileUtils_Image_Height(_path) != 300)
    {
        MobileUtils_Image_Resize(_path, 300, 300);
        MobileUtils_Image_Crop(_path, 100, 100, 100, 100);
        MobileUtils_Image_Resize(_path, 300, 300);
    }
    Obj_MobileUtils_Gallery_Picture.sprite = sprite_add(_path, 0, 0, 0, 0, 0);
}

The code above was extracted from the MobileUtils_Gallery_Open sample and shows an example on how to get the width of an image (for a complete example please refer to the respective function).