Love2D APIImageDataOn this pageImageData Description: Raw (decoded) image data. release Type: Function. Description: Destroys the object's Lua reference. The object will be completely deleted if it's not referenced by any other LÖVE object or thread. This method can be used to immediately clean up resources without waiting for Lua's garbage collector. Signature: release: function(self: ImageData): boolean Returns: Return TypeDescriptionbooleanTrue if the object was released by this call, false if it had been previously released. type Type: Function. Description: Gets the type of the object as a string. Signature: type: function(self: ImageData): string Returns: Return TypeDescriptionstringThe type as a string. Of Type: Function. Description: Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true. Signature: typeOf: function(self: ImageData, type_name: string): boolean Parameters: ParameterTypeDescriptiontype_namestringThe name of the type to check for. Returns: Return TypeDescriptionbooleanTrue if the object is of the specified type, false otherwise. getString Type: Function. Description: Gets the full Data as a string. Signature: getString: function(self: ImageData): string Returns: Return TypeDescriptionstringThe raw data. getSize Type: Function. Description: Gets the Data's size in bytes. Signature: getSize: function(self: ImageData): integer Returns: Return TypeDescriptionintegerThe size of the Data in bytes. getPointer Type: Function. Description: Gets a pointer to the Data. Can be used with libraries such as LuaJIT's FFI. Signature: getPointer: function(self: ImageData): any Returns: Return TypeDescriptionanyA raw pointer to the Data. getFFIPointer Type: Function. Description: Gets an FFI pointer to the Data. This function should be preferred instead of Data:getPointer because the latter uses light userdata which can't store more all possible memory addresses on some new ARM64 architectures, when LuaJIT is used. Signature: getFFIPointer: function(self: ImageData): nil Returns: Return TypeDescriptionnilA raw void* pointer to the Data, or nil if FFI is unavailable. clone Type: Function. Description: Creates a new copy of the Data object. Signature: clone: function(self: ImageData): ImageData Returns: Return TypeDescriptionImageDataThe new copy. getWidth Type: Function. Description: Gets the width of the ImageData in pixels. Signature: getWidth: function(self: ImageData): integer Returns: Return TypeDescriptionintegerThe width of the ImageData in pixels. getHeight Type: Function. Description: Gets the height of the ImageData in pixels. Signature: getHeight: function(self: ImageData): integer Returns: Return TypeDescriptionintegerThe height of the ImageData in pixels. getDimensions Type: Function. Description: Gets the width and height of the ImageData in pixels. Signature: getDimensions: function(self: ImageData): integer, integer Returns: Return TypeDescriptionintegerThe width of the ImageData in pixels.integerThe height of the ImageData in pixels. getFormat Type: Function. Description: Gets the pixel format of the ImageData. Signature: getFormat: function(self: ImageData): string Returns: Return TypeDescriptionstringThe pixel format the ImageData was created with. getPixel Type: Function. Description: Gets the color of a pixel at a specific position in the image. Valid x and y values start at 0 and go up to image width and height minus 1. Non-integer values are floored. In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. Signature: getPixel: function(self: ImageData, x: integer, y: integer): number, number, number, number Parameters: ParameterTypeDescriptionxintegerThe position of the pixel on the x-axis.yintegerThe position of the pixel on the y-axis. Returns: Return TypeDescriptionnumberThe red component (0-1).numberThe green component (0-1).numberThe blue component (0-1).numberThe alpha component (0-1). setPixel Type: Function. Description: Sets the color of a pixel at a specific position in the image. Valid x and y values start at 0 and go up to image width and height minus 1. In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. Signature: setPixel: function(self: ImageData, x: integer, y: integer, red: number, green: number, blue: number, alpha?: number) Parameters: ParameterTypeDescriptionxintegerThe position of the pixel on the x-axis.yintegerThe position of the pixel on the y-axis.rednumberThe red component (0-1).greennumberThe green component (0-1).bluenumberThe blue component (0-1).alphanumberThe alpha component (0-1). mapPixel Type: Function. Description: Transform an image by applying a function to every pixel. This function is a higher-order function. It takes another function as a parameter, and calls it once for each pixel in the ImageData. The passed function is called with six parameters for each pixel in turn. The parameters are numbers that represent the x and y coordinates of the pixel and its red, green, blue and alpha values. The function should return the new red, green, blue, and alpha values for that pixel. function pixelFunction(x, y, r, g, b, a) -- template for defining your own pixel mapping function -- perform computations giving the new values for r, g, b and a -- ... return r, g, b, a end In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. Signature: mapPixel: function(self: ImageData, mapper: function(x: integer, y: integer, red: number, green: number, blue: number, alpha: number): (number, number, number, number), x?: integer, y?: integer, width?: integer, height?: integer) Parameters: ParameterTypeDescriptionmapperfunctionFunction to apply to every pixel.xintegerThe x-axis of the top-left corner of the area within the ImageData to apply the function to. (Default: 0.)yintegerThe y-axis of the top-left corner of the area within the ImageData to apply the function to. (Default: 0.)widthintegerThe width of the area within the ImageData to apply the function to. (Default: ImageData:getWidth().)heightintegerThe height of the area within the ImageData to apply the function to. (Default: ImageData:getHeight().) paste Type: Function. Description: Paste into ImageData from another source ImageData. Overload details: Note that this function just replaces the contents in the destination rectangle; it does not do any alpha blending. Signature: paste: function(self: ImageData, source: ImageData, destination_x: integer, destination_y: integer, source_x?: integer, source_y?: integer, source_width?: integer, source_height?: integer) Parameters: ParameterTypeDescriptionsourceImageDataSource ImageData from which to copy.destination_xintegerDestination top-left position on x-axis.destination_yintegerDestination top-left position on y-axis.source_xintegerSource top-left position on x-axis.source_yintegerSource top-left position on y-axis.source_widthintegerSource width.source_heightintegerSource height. encode Type: Function. Description: Encodes the ImageData and optionally writes it to the save directory. Signature: encode: function(self: ImageData, format: string, filename?: string): FileData Parameters: ParameterTypeDescriptionformatstringThe format to encode the image as. Depending on the overload: The format to encode the image in.filenamestringThe filename to write the file to. If nil, no file will be written but the FileData will still be returned. (Default: nil.) Returns: Return TypeDescriptionFileDataThe encoded image as a new FileData object.