Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Image

Inherits: Resource < RefCounted < Object

Image datatype.

Description

Native image datatype. Contains image data which can be converted to an ImageTexture and provides commonly used image processing methods. The maximum width and height for an Image are MAX_WIDTH and MAX_HEIGHT.

An Image cannot be assigned to a texture property of an object directly (such as Sprite2D.texture), and has to be converted manually to an ImageTexture first.

Note: The maximum image size is 16384×16384 pixels due to graphics hardware limitations. Larger images may fail to import.

Tutorials

Properties

Dictionary

data

{ "data": PackedByteArray(), "format": "Lum8", "height": 0, "mipmaps": false, "width": 0 }

Methods

void

adjust_bcs ( float brightness, float contrast, float saturation )

void

blend_rect ( Image src, Rect2i src_rect, Vector2i dst )

void

blend_rect_mask ( Image src, Image mask, Rect2i src_rect, Vector2i dst )

void

blit_rect ( Image src, Rect2i src_rect, Vector2i dst )

void

blit_rect_mask ( Image src, Image mask, Rect2i src_rect, Vector2i dst )

void

bump_map_to_normal_map ( float bump_scale=1.0 )

void

clear_mipmaps ( )

Error

compress ( CompressMode mode, CompressSource source=0, ASTCFormat astc_format=0 )

Error

compress_from_channels ( CompressMode mode, UsedChannels channels, ASTCFormat astc_format=0 )

Dictionary

compute_image_metrics ( Image compared_image, bool use_luma )

void

convert ( Format format )

void

copy_from ( Image src )

Image

create ( int width, int height, bool use_mipmaps, Format format ) static

Image

create_from_data ( int width, int height, bool use_mipmaps, Format format, PackedByteArray data ) static

void

crop ( int width, int height )

Error

decompress ( )

AlphaMode

detect_alpha ( ) const

UsedChannels

detect_used_channels ( CompressSource source=0 ) const

void

fill ( Color color )

void

fill_rect ( Rect2i rect, Color color )

void

fix_alpha_edges ( )

void

flip_x ( )

void

flip_y ( )

Error

generate_mipmaps ( bool renormalize=false )

PackedByteArray

get_data ( ) const

Format

get_format ( ) const

int

get_height ( ) const

int

get_mipmap_count ( ) const

int

get_mipmap_offset ( int mipmap ) const

Color

get_pixel ( int x, int y ) const

Color

get_pixelv ( Vector2i point ) const

Image

get_region ( Rect2i region ) const

Vector2i

get_size ( ) const

Rect2i

get_used_rect ( ) const

int

get_width ( ) const

bool

has_mipmaps ( ) const

bool

is_compressed ( ) const

bool

is_empty ( ) const

bool

is_invisible ( ) const

Error

load ( String path )

Error

load_bmp_from_buffer ( PackedByteArray buffer )

Image

load_from_file ( String path ) static

Error

load_jpg_from_buffer ( PackedByteArray buffer )

Error

load_ktx_from_buffer ( PackedByteArray buffer )

Error

load_png_from_buffer ( PackedByteArray buffer )

Error

load_svg_from_buffer ( PackedByteArray buffer, float scale=1.0 )

Error

load_svg_from_string ( String svg_str, float scale=1.0 )

Error

load_tga_from_buffer ( PackedByteArray buffer )

Error

load_webp_from_buffer ( PackedByteArray buffer )

void

normal_map_to_xy ( )

void

premultiply_alpha ( )

void

resize ( int width, int height, Interpolation interpolation=1 )

void

resize_to_po2 ( bool square=false, Interpolation interpolation=1 )

Image

rgbe_to_srgb ( )

void

rotate_90 ( ClockDirection direction )

void

rotate_180 ( )

Error

save_exr ( String path, bool grayscale=false ) const

PackedByteArray

save_exr_to_buffer ( bool grayscale=false ) const

Error

save_jpg ( String path, float quality=0.75 ) const

PackedByteArray

save_jpg_to_buffer ( float quality=0.75 ) const

Error

save_png ( String path ) const

PackedByteArray

save_png_to_buffer ( ) const

Error

save_webp ( String path, bool lossy=false, float quality=0.75 ) const

PackedByteArray

save_webp_to_buffer ( bool lossy=false, float quality=0.75 ) const

void

set_data ( int width, int height, bool use_mipmaps, Format format, PackedByteArray data )

void

set_p