#image #paintbrush

pcx

Library for reading & writing PCX images

9 releases

new 0.2.5 Feb 2, 2026
0.2.4 Nov 6, 2024
0.2.3 Sep 28, 2018
0.2.0 Dec 14, 2016
0.1.2 Dec 10, 2016

#221 in Images

Download history 155/week @ 2025-10-15 279/week @ 2025-10-22 188/week @ 2025-10-29 372/week @ 2025-11-05 188/week @ 2025-11-12 149/week @ 2025-11-19 191/week @ 2025-11-26 30/week @ 2025-12-10 12/week @ 2025-12-17 18/week @ 2025-12-24 25/week @ 2025-12-31 4/week @ 2026-01-07 20/week @ 2026-01-14 15/week @ 2026-01-21 32/week @ 2026-01-28

74 downloads per month
Used in 2 crates

MIT OR Apache-2.0 OR WTFPL

57KB
1K SLoC

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.


Library for reading and writing PCX images in Rust

Example usage:

let mut reader = pcx::Reader::from_file("test-data/marbles.pcx").unwrap();
println!("width = {}, height = {}", reader.width(), reader.height());

let mut buffer = vec![0; reader.width() as usize * reader.height() as usize * 3];
reader.read_rgb_pixels(&mut buffer).unwrap();

See API documentation for more info.

License

This project is licensed under either of

at your option.

Note that these licenses do not cover the test images (test-data folder).

Dependencies

~125KB