pub struct Reader<R: Read> {
pub header: Header,
/* private fields */
}Expand description
PCX file reader.
Fields§
§header: HeaderFile header. All useful values are available via Reader methods so you don’t actually need it.
Implementations§
Source§impl<R: Read> Reader<R>
impl<R: Read> Reader<R>
Sourcepub fn dimensions(&self) -> (u16, u16)
pub fn dimensions(&self) -> (u16, u16)
Get width and height of the image.
Sourcepub fn is_paletted(&self) -> bool
pub fn is_paletted(&self) -> bool
Whether this image is paletted or 24-bit RGB.
Sourcepub fn palette_length(&self) -> Option<u16>
pub fn palette_length(&self) -> Option<u16>
Get number of colors in the palette if this image is paletted. Number of colors is either 2, 4, 8, 16 or 256.
Sourcepub fn next_row_paletted(&mut self, buffer: &mut [u8]) -> Result<()>
pub fn next_row_paletted(&mut self, buffer: &mut [u8]) -> Result<()>
Read next row of the paletted image. Check that is_paletted() is true before calling this function.
buffer length must be equal to the image width.
Order of rows is from top to bottom, order of pixels is from left to right.
Sourcepub fn next_row_rgb_separate(
&mut self,
r: &mut [u8],
g: &mut [u8],
b: &mut [u8],
) -> Result<()>
pub fn next_row_rgb_separate( &mut self, r: &mut [u8], g: &mut [u8], b: &mut [u8], ) -> Result<()>
Read next row of the RGB image to separate R, G and B buffers. Check that is_paletted() is false before calling this function.
r, g, b buffer lengths must be equal to the image width.
Order of rows is from top to bottom, order of pixels is from left to right.
Sourcepub fn next_row_rgb(&mut self, rgb: &mut [u8]) -> Result<()>
pub fn next_row_rgb(&mut self, rgb: &mut [u8]) -> Result<()>
Read next row of the RGB image to one buffer with interleaved RGB values. Check that is_paletted() is false before calling this function.
rgb buffer length must be equal to the image width multiplied by 3.
Order of rows is from top to bottom, order of pixels is from left to right.
Sourcepub fn read_palette(self, buffer: &mut [u8]) -> Result<usize>
pub fn read_palette(self, buffer: &mut [u8]) -> Result<usize>
Read color palette.
If palette contains 256-colors then it is stored at the end of file and this function will read the file to the end.
Returns number of colors in palette or zero if there is no palette. The actual number of bytes written to the output buffer is equal to the returned value multiplied by 3. Format of the output buffer is R, G, B, R, G, B, …
Consider using get_palette instead.
Source§impl<R: Seek + Read> Reader<R>
impl<R: Seek + Read> Reader<R>
Sourcepub fn read_rgb_pixels(&mut self, rgb: &mut [u8]) -> Result<()>
pub fn read_rgb_pixels(&mut self, rgb: &mut [u8]) -> Result<()>
Read the entire RGB image, converting from paletted to RGB if necessarry.
rgb buffer length must be equal to width*height*3.
Order of rows is from top to bottom, order of pixels is from left to right. Format of the output buffer is R, G, B, R, G, B, …
Sourcepub fn get_palette(&mut self, buffer: &mut [u8]) -> Result<usize>
pub fn get_palette(&mut self, buffer: &mut [u8]) -> Result<usize>
Get color palette.
Returns number of colors in palette or zero if there is no palette. The actual number of bytes written to the output buffer is equal to the returned value multiplied by 3. Format of the output buffer is R, G, B, R, G, B, …