Struct image::dxt::DXTDecoder
source · pub struct DXTDecoder<R: Read> { /* private fields */ }
Expand description
DXT decoder
Implementations
sourceimpl<R: Read> DXTDecoder<R>
impl<R: Read> DXTDecoder<R>
sourcepub fn new(
r: R,
width: u32,
height: u32,
variant: DXTVariant
) -> Result<DXTDecoder<R>, ImageError>
pub fn new(
r: R,
width: u32,
height: u32,
variant: DXTVariant
) -> Result<DXTDecoder<R>, ImageError>
Create a new DXT decoder that decodes from the stream r
.
As DXT is often stored as raw buffers with the width/height
somewhere else the width and height of the image need
to be passed in width
and height
, as well as the
DXT variant in variant
.
width and height are required to be powers of 2 and at least 4.
otherwise an error will be returned
Trait Implementations
sourceimpl<R: Read> ImageDecoder for DXTDecoder<R>
impl<R: Read> ImageDecoder for DXTDecoder<R>
sourcefn dimensions(&self) -> (u64, u64)
fn dimensions(&self) -> (u64, u64)
Returns a tuple containing the width and height of the image
sourcefn scanline_bytes(&self) -> u64
fn scanline_bytes(&self) -> u64
Returns the minimum number of bytes that can be efficiently read from this decoder. This may
be as few as 1 or as many as
total_bytes()
. Read moresourcefn into_reader(self) -> ImageResult<Self::Reader>
fn into_reader(self) -> ImageResult<Self::Reader>
Returns a reader that can be used to obtain the bytes of the image. For the best
performance, always try to read at least
scanline_bytes
from the reader at a time. Reading
fewer bytes will cause the reader to perform internal buffering. Read moresourcefn read_image(self) -> ImageResult<Vec<u8>>
fn read_image(self) -> ImageResult<Vec<u8>>
Returns all the bytes in the image.
sourcefn row_bytes(&self) -> u64
fn row_bytes(&self) -> u64
Returns the number of bytes in a single row of the image. All decoders will pad image rows
to a byte boundary. Read more
sourcefn total_bytes(&self) -> u64
fn total_bytes(&self) -> u64
Returns the total number of bytes in the image.
sourcefn read_image_with_progress<F: Fn(Progress)>(
self,
progress_callback: F
) -> ImageResult<Vec<u8>>
fn read_image_with_progress<F: Fn(Progress)>(
self,
progress_callback: F
) -> ImageResult<Vec<u8>>
Same as
read_image
but periodically calls the provided callback to give updates on loading
progress. Read moresourceimpl<R: Read + Seek> ImageDecoderExt for DXTDecoder<R>
impl<R: Read + Seek> ImageDecoderExt for DXTDecoder<R>
sourcefn read_rect_with_progress<F: Fn(Progress)>(
&mut self,
x: u64,
y: u64,
width: u64,
height: u64,
buf: &mut [u8],
progress_callback: F
) -> ImageResult<()>
fn read_rect_with_progress<F: Fn(Progress)>(
&mut self,
x: u64,
y: u64,
width: u64,
height: u64,
buf: &mut [u8],
progress_callback: F
) -> ImageResult<()>
Read a rectangular section of the image, periodically reporting progress.
Auto Trait Implementations
impl<R> RefUnwindSafe for DXTDecoder<R>where
R: RefUnwindSafe,
impl<R> Send for DXTDecoder<R>where
R: Send,
impl<R> Sync for DXTDecoder<R>where
R: Sync,
impl<R> Unpin for DXTDecoder<R>where
R: Unpin,
impl<R> UnwindSafe for DXTDecoder<R>where
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more