TextureDownloader#
Added in version 4.10.
- class TextureDownloader(**kwargs)#
Used to download the contents of a Texture.
It is intended to be created as a short-term object for a single download, but can be used for multiple downloads of different textures or with different settings.
GdkTextureDownloader can be used to convert data between different formats.
Create a GdkTexture for the existing format and then download it in a
different format.
Constructors#
- class TextureDownloader
- classmethod new(texture: Texture) TextureDownloader#
Creates a new texture downloader for
texture.By default, the downloader will convert the data to the default memory format, and to the sRGB color state.
Added in version 4.10.
- Parameters:
texture – texture to download
Methods#
- class TextureDownloader
- download_bytes() tuple[Bytes, int]#
Downloads the given texture pixels into a
GBytes. The rowstride will be stored in the stride value.This function will abort if it tries to download a large texture and fails to allocate memory. If you think that may happen, you should handle memory allocation yourself and use
download_intoonce allocation succeeded.This function cannot be used with a multiplanar format. Use
download_bytes_with_planesfor that purpose.Added in version 4.10.
- download_bytes_with_planes() tuple[Bytes, list[int], list[int]]#
Downloads the given texture pixels into a
GBytes. The offsets and strides of the resulting buffer will be stored in the respective values.If the format does have less than 4 planes, the remaining offsets and strides will be set to
0.Added in version 4.20.
- download_into(data: list[int], stride: int) None#
Downloads the
textureinto local memory.This function cannot be used with a multiplanar format.
Added in version 4.10.
- Parameters:
data – pointer to enough memory to be filled with the downloaded data of the texture
stride – rowstride in bytes
- get_color_state() ColorState#
Gets the color state that the data will be downloaded in.
Added in version 4.16.
- get_format() MemoryFormat#
Gets the format that the data will be downloaded in.
Added in version 4.10.
- set_color_state(color_state: ColorState) None#
Sets the color state the downloader will convert the data to.
By default, the sRGB colorstate returned by
get_srgbis used.Added in version 4.16.
- Parameters:
color_state – the color state to use
- set_format(format: MemoryFormat) None#
Sets the format the downloader will download.
By default, GDK_MEMORY_DEFAULT is set.
Added in version 4.10.
- Parameters:
format – the format to use