Class TextureDownloader
- All Implemented Interfaces:
Proxy
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.
- Since:
- 4.10
-
Constructor Summary
ConstructorsConstructorDescriptionTextureDownloader(MemorySegment address) Create a TextureDownloader proxy instance for the provided memory address.TextureDownloader(Texture texture) Creates a new texture downloader fortexture. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a copy of the downloader.byte[]downloadBytes(Out<Long> outStride) Downloads the given texture pixels into aGBytes.byte[]downloadBytesWithPlanes(@Nullable Out<long[]> outOffsets, @Nullable Out<long[]> outStrides) Downloads the given texture pixels into aGBytes.voiddownloadInto(@org.jspecify.annotations.Nullable byte @Nullable [] data, long stride) Downloads thetextureinto local memory.voidfree()Frees the given downloader and all its associated resources.Gets the color state that the data will be downloaded in.Gets the format that the data will be downloaded in.Gets the texture that the downloader will download.static @Nullable TypegetType()Get the GType of the TextureDownloader classvoidsetColorState(ColorState colorState) Sets the color state the downloader will convert the data to.voidsetFormat(MemoryFormat format) Sets the format the downloader will download.voidsetTexture(Texture texture) Changes the texture the downloader will download.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
TextureDownloader
Create a TextureDownloader proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
TextureDownloader
Creates a new texture downloader fortexture.By default, the downloader will convert the data to the default memory format, and to the sRGB color state.
- Parameters:
texture- texture to download- Since:
- 4.10
-
-
Method Details
-
getType
Get the GType of the TextureDownloader class- Returns:
- the GType
-
copy
Creates a copy of the downloader.This function is meant for language bindings.
- Returns:
- A copy of the downloader
- Since:
- 4.10
-
downloadBytes
Downloads the given texture pixels into aGBytes. 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
downloadInto(byte[], long)once allocation succeeded.This function cannot be used with a multiplanar format. Use
downloadBytesWithPlanes(org.javagi.base.Out<long[]>, org.javagi.base.Out<long[]>)for that purpose.- Parameters:
outStride- The stride of the resulting data in bytes- Returns:
- The downloaded pixels
- Since:
- 4.10
-
downloadBytesWithPlanes
public byte[] downloadBytesWithPlanes(@Nullable Out<long[]> outOffsets, @Nullable Out<long[]> outStrides) Downloads the given texture pixels into aGBytes. 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.- Parameters:
outOffsets- The offsets of the resulting data planes in bytesoutStrides- The stride of the resulting data planes in bytes- Returns:
- The downloaded pixels
- Since:
- 4.20
-
downloadInto
public void downloadInto(@org.jspecify.annotations.Nullable byte @Nullable [] data, long stride) Downloads thetextureinto local memory.This function cannot be used with a multiplanar format.
- Parameters:
data- pointer to enough memory to be filled with the downloaded data of the texturestride- rowstride in bytes- Since:
- 4.10
-
free
public void free()Frees the given downloader and all its associated resources.- Since:
- 4.10
-
getColorState
Gets the color state that the data will be downloaded in.- Returns:
- The color state of the download
- Since:
- 4.16
-
getFormat
Gets the format that the data will be downloaded in.- Returns:
- The format of the download
- Since:
- 4.10
-
getTexture
Gets the texture that the downloader will download.- Returns:
- The texture to download
- Since:
- 4.10
-
setColorState
Sets the color state the downloader will convert the data to.By default, the sRGB colorstate returned by
ColorState.getSrgb()is used.- Parameters:
colorState- the color state to use- Since:
- 4.16
-
setFormat
Sets the format the downloader will download.By default, GDK_MEMORY_DEFAULT is set.
- Parameters:
format- the format to use- Since:
- 4.10
-
setTexture
Changes the texture the downloader will download.- Parameters:
texture- the new texture to download- Since:
- 4.10
-