Struct libktx_rs::texture::Texture [−][src]
pub struct Texture<'a> { /* fields omitted */ }
Expand description
A KTX (1 or 2) texture.
This wraps both a sys::ktxTexture
handle, and the TextureSource
it was created from.
Implementations
Attempts to create a new texture, consuming the given TextureSource
.
Attempts to write the texture (in its native format, either KTX1 or KTX2) to sink
.
Returns the pointer to the (C-allocated) underlying sys::ktxTexture
.
SAFETY: Pointers are harmless. Dereferencing them is not!
Returns the pitch (in bytes) of an image row at the specified image level.
This is rounded up to 1 if needed.
Returns the size (in bytes) of an element of the image.
Attempts to return the offset (in bytes) into Self::data
for the image
at the given mip level, array layer, and slice.
slice
is either a cubemap’s face or a 3D texture’s depth slice.
Attempts to return the size (in bytes) of the uncompressed image data.
Attempts to return the size (in bytes) of a certain mip level.
Attempts to [re]load this image’s data to its internal buffer.
Also see Self::data()
.
Creating the image with [enums::TextureCreateFlags::LOAD_IMAGE_DATA
] performs this step automatically on load.
Attempts to iterate all mip levels of the image, and all faces of cubemaps. This calls
callback(miplevel: i32, face: i32, width: i32, height: i32, depth: i32, pixel_data: &[u8]) -> Result<(), KtxError>
for each level/face. The image data passed to the callback is immutable.
Note that image data should already have been loaded (see Self::load_image_data()
).
Attempts to iterate all mip levels of the image, and all faces of cubemaps. This calls
callback(miplevel: i32, face: i32, width: i32, height: i32, depth: i32, pixel_data: &mut [u8]) -> Result<(), KtxError>
for each level/face. The image data passed to the callback is mutable.
Note that image data should already have been loaded (see Self::load_image_data()
).
If this Texture
really is a KTX1, returns KTX1-specific functionalities for it.