Skip to main content

ImageModule

Description:

  Provides an interface to decode encoded image data.

newImageData

Type: Function.

Description:

  Creates a new ImageData object.

Signature:

newImageData: function(width: number, height: integer, format?: ImagePixelFormat, data?: string | FileData): ImageData

Parameters:

ParameterTypeDescription
widthnumberThe width of the ImageData.
heightintegerThe height of the ImageData.
formatImagePixelFormatThe pixel format of the ImageData. (Default: 'rgba8'.)
datastringFileData

Returns:

Return TypeDescription
ImageDataimageData — The new blank ImageData object. Each pixel's color values, (including the alpha values!) will be set to zero.

newImageData

Type: Function.

Description:

  Creates a new ImageData object.

Signature:

newImageData: function(filename: string): ImageData

Parameters:

ParameterTypeDescription
filenamestringThe filename of the image file.

Returns:

Return TypeDescription
ImageDataThe new ImageData object.

newImageData

Type: Function.

Description:

  Creates a new ImageData object.

Signature:

newImageData: function(data: FileData): ImageData

Parameters:

ParameterTypeDescription
dataFileDataThe data to load into the ImageData (RGBA bytes, left to right and top to bottom).

Returns:

Return TypeDescription
ImageDataThe new ImageData object.

newCompressedData

Type: Function.

Description:

  Create a new CompressedImageData object from a compressed image file. LÖVE supports several compressed texture formats, enumerated in the CompressedImageFormat page.

Signature:

newCompressedData: function(filename_or_data: string | FileData): CompressedImageData

Parameters:

ParameterTypeDescription
filename_or_datastring or FileDataThe filename of the compressed image file. Depending on the overload: A FileData containing a compressed image.

Returns:

Return TypeDescription
CompressedImageDataThe new CompressedImageData object.

isCompressed

Type: Function.

Description:

  Determines whether a file can be loaded as CompressedImageData.

Signature:

isCompressed: function(filename_or_data: string | FileData): boolean

Parameters:

ParameterTypeDescription
filename_or_datastring or FileDataThe filename of the potentially compressed image file. Depending on the overload: A FileData potentially containing a compressed image.

Returns:

Return TypeDescription
booleanWhether the file can be loaded as CompressedImageData or not. Depending on the overload: Whether the FileData can be loaded as CompressedImageData or not.