Crate pcx[][src]

Library for reading and writing PCX image format.

PCX is quite old format, it is not recommended to use it for new applications.

PCX does not contain any color space information. Today one will usually interpret it as containing colors in sRGB color space.

Example for reading 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());
for y in 0..reader.height() {
    if reader.is_paletted() {
        // call reader.next_row_paletted(...) to read next row
    } else {
        // call reader.next_row_rgb(...) or reader.next_row_rgb_separate(...) to read next row

Example for writing 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]);

This library does not implement its own error type, instead it uses std::io::Error. In the case of invalid PCX file it will return error with .kind() == ErrorKind::InvalidData.



Low-level handling of PCX. You generally don't need to use this module.



PCX file reader.


Create paletted PCX image.


Create 24-bit RGB PCX image.