Struct pcx::Reader
[−]
[src]
pub struct Reader<R: Read> { pub header: Header, // some fields omitted }
PCX file reader.
Fields
header: Header
File header. All useful values are available via Reader
methods so you don't actually need it.
Methods
impl Reader<BufReader<File>>
[src]
fn new_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Start reading PCX file.
impl<R: Read> Reader<R>
[src]
fn new(stream: R) -> Result<Self>
Start reading PCX file.
fn size(&self) -> (u16, u16)
Get width and height of the image.
fn is_paletted(&self) -> bool
Whether this image is paletted or 24-bit RGB.
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.
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.
fn next_row_rgb(&mut self,
r: &mut [u8],
g: &mut [u8],
b: &mut [u8])
-> Result<()>
r: &mut [u8],
g: &mut [u8],
b: &mut [u8])
-> Result<()>
Read next row of the RGB image. 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.
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, ...