Expand description
Library for reading and writing PCX images.
Example of reading a PCX image:
let mut reader = pcx::Reader::from_file("test-data/marbles.pcx").unwrap();
println!("width = {}, height = {}, paletted = {}", reader.width(), reader.height(), reader.is_paletted());
let mut buffer = vec![0; reader.width() as usize * reader.height() as usize * 3];
reader.read_rgb_pixels(&mut buffer).unwrap();
Example of writing a PCX image:
// Create 5x5 RGB file.
let mut writer = pcx::WriterRgb::create_file("test.pcx", (5, 5), (300, 300)).unwrap();
for y in 0..5 {
// Write 5 green pixels.
writer.write_row(&[0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0]);
}
writer.finish().unwrap();
This library does not implement its own error type, instead it uses std::io::Error
. In the case of an invalid
PCX file it will return an error with .kind() == ErrorKind::InvalidData
.
Modules§
- Low-level handling of PCX. You generally don’t need to use this module.
Structs§
- PCX file reader.
- Create paletted PCX image.
- Create 24-bit RGB PCX image.