8 releases

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

#865 in Parser implementations

Download history 19/week @ 2024-07-17 31/week @ 2024-07-24 24/week @ 2024-07-31 29/week @ 2024-08-07 18/week @ 2024-08-14 16/week @ 2024-08-21 27/week @ 2024-08-28 13/week @ 2024-09-04 14/week @ 2024-09-11 33/week @ 2024-09-18 44/week @ 2024-09-25 16/week @ 2024-10-02 12/week @ 2024-10-09 13/week @ 2024-10-16 54/week @ 2024-10-23 149/week @ 2024-10-30

230 downloads per month
Used in elma-lgr

MIT OR Apache-2.0 OR WTFPL

57KB
1K SLoC

Library for reading and writing PCX images for Rust

Add it to you dependencies:

[dependencies]
pcx = "0.2"

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).


lib.rs:

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.

Dependencies

~115KB