7 releases

Uses old Rust 2015

0.2.3 Sep 28, 2018
0.2.2 Sep 27, 2018
0.2.0 Dec 14, 2016
0.1.2 Dec 10, 2016

#563 in Images

Download history 8/week @ 2023-12-04 11/week @ 2023-12-11 9/week @ 2023-12-18 9/week @ 2023-12-25 3/week @ 2024-01-01 23/week @ 2024-01-08 13/week @ 2024-01-15 6/week @ 2024-01-22 8/week @ 2024-01-29 19/week @ 2024-02-05 21/week @ 2024-02-12 49/week @ 2024-02-19 29/week @ 2024-02-26 33/week @ 2024-03-04 38/week @ 2024-03-11 33/week @ 2024-03-18

135 downloads per month
Used in elma-lgr

WTFPL license

160KB
951 lines

Library for reading and writing PCX images for Rust

Add it to you dependencies:

[dependencies]
pcx = "0.2"

See API documentation for more info.

Released under WTFPL license.


lib.rs:

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]);
 }
 writer.finish().unwrap();

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.

Dependencies