Class TextureDownloader
- All Implemented Interfaces:
Proxy
GdkTextureDownloader
is 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.
-
Constructor Summary
ConstructorDescriptionTextureDownloader
(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.downloadBytes
(Out<Long> outStride) Downloads the given texture pixels into aGBytes
.void
downloadInto
(byte[] data, long stride) Downloads thetexture
into local memory.void
free()
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 Type
getType()
Get the GType of the TextureDownloader classvoid
setColorState
(ColorState colorState) Sets the color state the downloader will convert the data to.void
setFormat
(MemoryFormat format) Sets the format the downloader will download.void
setTexture
(Texture texture) Changes the texture the downloader will download.Methods inherited from class io.github.jwharm.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
-
-
Method Details
-
getType
-
copy
Creates a copy of the downloader.This function is meant for language bindings.
- Returns:
- A copy of the downloader
-
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.- Parameters:
outStride
- The stride of the resulting data in bytes- Returns:
- The downloaded pixels
-
downloadInto
public void downloadInto(byte[] data, long stride) Downloads thetexture
into local memory.- Parameters:
data
- pointer to enough memory to be filled with the downloaded data of the texturestride
- rowstride in bytes
-
free
public void free()Frees the given downloader and all its associated resources. -
getColorState
Gets the color state that the data will be downloaded in.- Returns:
- The color state of the download
-
getFormat
Gets the format that the data will be downloaded in.- Returns:
- The format of the download
-
getTexture
Gets the texture that the downloader will download.- Returns:
- The texture to download
-
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
-
setFormat
Sets the format the downloader will download.By default, GDK_MEMORY_DEFAULT is set.
- Parameters:
format
- the format to use
-
setTexture
Changes the texture the downloader will download.- Parameters:
texture
- the new texture to download
-