Image datatype.
Native image datatype. Contains image data, which can be converted to a [Texture], and several functions to interact with it. The maximum width and height for an [code]Image[/code] is 16384 pixels.
Alpha-blends [code]src_rect[/code] from [code]src[/code] image to this image at coordinates [code]dest[/code].
Alpha-blends [code]src_rect[/code] from [code]src[/code] image to this image using [code]mask[/code] image at coordinates [code]dst[/code]. Alpha channels are required for both [code]src[/code] and [code]mask[/code]. [code]dst[/code] pixels and [code]src[/code] pixels will blend if the corresponding mask pixel's alpha value is not 0. [code]src[/code] image and [code]mask[/code] image [b]must[/b] have the same size (width and height) but they can have different formats.
Copies [code]src_rect[/code] from [code]src[/code] image to this image at coordinates [code]dst[/code].
Blits [code]src_rect[/code] area from [code]src[/code] image to this image at the coordinates given by [code]dst[/code]. [code]src[/code] pixel is copied onto [code]dst[/code] if the corresponding [code]mask[/code] pixel's alpha value is not 0. [code]src[/code] image and [code]mask[/code] image [b]must[/b] have the same size (width and height) but they can have different formats.
Removes the image's mipmaps.
Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available. See [code]COMPRESS_*[/code] constants.
Converts the image's format. See [code]FORMAT_*[/code] constants.
Copies [code]src[/code] image to this image.
Creates an empty image of given size and format. See [code]FORMAT_*[/code] constants. If [code]use_mipmaps[/code] is true then generate mipmaps for this image. See the [code]generate_mipmaps[/code] method.
Creates a new image of given size and format. See [code]FORMAT_*[/code] constants. Fills the image with the given raw data. If [code]use_mipmaps[/code] is true then generate mipmaps for this image. See the [code]generate_mipmaps[/code] method.
Crops the image to the given [code]width[/code] and [code]height[/code]. If the specified size is larger than the current size, the extra area is filled with black pixels.
Decompresses the image if it is compressed. Returns an error if decompress function is not available.
Returns ALPHA_BLEND if the image has data for alpha values. Returns ALPHA_BIT if all the alpha values are below a certain threshold or the maximum value. Returns ALPHA_NONE if no data for alpha values is found.
Stretches the image and enlarges it by a factor of 2. No interpolation is done.
Fills the image with a given [Color].
Blends low-alpha pixels with nearby pixels.
Flips the image horizontally.
Flips the image vertically.
Generates mipmaps for the image. Mipmaps are pre-calculated and lower resolution copies of the image. Mipmaps are automatically used if the image needs to be scaled down when rendered. This improves image quality and the performance of the rendering. Returns an error if the image is compressed, in a custom format or if the image's width/height is 0.
Returns the image's raw data.
Returns the image’s format. See [code]FORMAT_*[/code] constants.
Returns the image's height.
Returns the offset where the image's mipmap with index [code]mipmap[/code] is stored in the [code]data[/code] dictionary.
Returns the color of the pixel at [code](x, y)[/code] if the image is locked. If the image is unlocked it always returns a [Color] with the value [code](0, 0, 0, 1.0)[/code].
Returns a new image that is a copy of the image's area specified with [code]rect[/code].
Returns the image's size (width and height).
Returns a [Rect2] enclosing the visible portion of the image.
Returns the image's width.
Returns [code]true[/code] if the image has generated mipmaps.
Returns [code]true[/code] if the image is compressed.
Returns [code]true[/code] if the image has no data.
Returns [code]true[/code] if all the image's pixels have an alpha value of 0. Returns [code]false[/code] if any pixel has an alpha value higher than 0.
Loads an image from file [code]path[/code].
Locks the data for writing access.
Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normalmap. A normalmap can add lots of detail to a 3D surface without increasing the polygon count.
Multiplies color values with alpha values. Resulting color values for a pixel are [code](color * alpha)/256[/code].
Resizes the image to the given [code]width[/code] and [code]height[/code]. New pixels are calculated using [code]interpolation[/code]. See [code]interpolation[/code] constants.
Resizes the image to the nearest power of 2 for the width and height. If [code]square[/code] is [code]true[/code] then set width and height to be the same.
Saves the image as a PNG file to [code]path[/code].
Sets the [Color] of the pixel at [code](x, y)[/code] if the image is locked. Example:
[codeblock]
var img = Image.new()
img.create(img_width, img_height, false, Image.FORMAT_RGBA8)
img.lock()
img.set_pixel(x, y, color) # Works
img.unlock()
img.set_pixel(x, y, color) # Does not have an effect
[/codeblock]
Shrinks the image by a factor of 2.
Converts the raw data from the sRGB colorspace to a linear scale.
Unlocks the data and prevents changes.
Holds all of the image's color data in a given format. See [code]FORMAT_*[/code] constants.
OpenGL texture format RED with a single component and a bitdepth of 8.
OpenGL texture format RG with two components and a bitdepth of 8 for each.
OpenGL texture format RGB with three components, each with a bitdepth of 8. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
OpenGL texture format RGBA with four components, each with a bitdepth of 8. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
OpenGL texture format RGBA with four components, each with a bitdepth of 4.
OpenGL texture format GL_RGB5_A1 where 5 bits of depth for each component of RGB and one bit for alpha.
OpenGL texture format GL_R32F where there's one component, a 32-bit floating-point value.
OpenGL texture format GL_RG32F where there are two components, each a 32-bit floating-point values.
OpenGL texture format GL_RGB32F where there are three components, each a 32-bit floating-point values.
OpenGL texture format GL_RGBA32F where there are four components, each a 32-bit floating-point values.
OpenGL texture format GL_R32F where there's one component, a 16-bit "half-precision" floating-point value.
OpenGL texture format GL_RG32F where there's two components, each a 16-bit "half-precision" floating-point value.
OpenGL texture format GL_RGB32F where there's three components, each a 16-bit "half-precision" floating-point value.
OpenGL texture format GL_RGBA32F where there's four components, each a 16-bit "half-precision" floating-point value.
A special OpenGL texture format where the three color components have 9 bits of precision and all three share a single exponent.
The S3TC texture format that uses Block Compression 1, and is the smallest variation of S3TC, only providing 1 bit of alpha and color data being premultiplied with alpha. More information can be found at https://www.khronos.org/opengl/wiki/S3_Texture_Compression. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
The S3TC texture format that uses Block Compression 2, and color data is interpreted as not having been premultiplied by alpha. Well suited for images with sharp alpha transitions between translucent and opaque areas. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
The S3TC texture format also known as Block Compression 3 or BC3 that contains 64 bits of alpha channel data followed by 64 bits of DXT1-encoded color data. Color data is not premultiplied by alpha, same as DXT3. DXT5 generally produces superior results for transparency gradients than DXT3. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
Texture format that uses Red Green Texture Compression, normalizing the red channel data using the same compression algorithm that DXT5 uses for the alpha channel. More information can be found here https://www.khronos.org/opengl/wiki/Red_Green_Texture_Compression.
Texture format that uses Red Green Texture Compression, normalizing the red and green channel data using the same compression algorithm that DXT5 uses for the alpha channel.
Texture format that uses BPTC compression with unsigned normalized RGBA components. More information can be found at https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
Texture format that uses BPTC compression with signed floating-point RGB components.
Texture format that uses BPTC compression with unsigned floating-point RGB components.
Texture format used on PowerVR-supported mobile platforms, uses 2 bit color depth with no alpha. More information on PVRTC can be found here https://en.wikipedia.org/wiki/PVRTC. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
Same as PVRTC2, but with an alpha component.
Similar to PVRTC2, but with 4 bit color depth and no alpha.
Same as PVRTC4, but with an alpha component.
Ericsson Texture Compression format, also referred to as 'ETC1', and is part of the OpenGL ES graphics standard. An overview of the format is given at https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC1.
Ericsson Texture Compression format 2 variant R11_EAC, which provides one channel of unsigned data.
Ericsson Texture Compression format 2 variant SIGNED_R11_EAC, which provides one channel of signed data.
Ericsson Texture Compression format 2 variant RG11_EAC, which provides two channels of unsigned data.
Ericsson Texture Compression format 2 variant SIGNED_RG11_EAC, which provides two channels of signed data.
Ericsson Texture Compression format 2 variant RGB8, which is a followup of ETC1 and compresses RGB888 data. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
Ericsson Texture Compression format 2 variant RGBA8, which compresses RGBA8888 data with full alpha support. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.
Ericsson Texture Compression format 2 variant RGB8_PUNCHTHROUGH_ALPHA1, which compresses RGBA data to make alpha either fully transparent or fully opaque. Note that when creating an [ImageTexture], an sRGB to linear color space conversion is performed.