#image-data #data-transfer #data-format #color-palette #section #reader #ilda

ilda-idtf

A complete implementation of the ILDA Image Data Transfer Format Specification, Revision 011, 2014-11-16

1 unstable release

0.1.0 Apr 29, 2020

#2595 in Parser implementations

Download history 290/week @ 2023-11-20 87/week @ 2023-11-27 5/week @ 2023-12-04 1/week @ 2023-12-11 164/week @ 2023-12-18 518/week @ 2023-12-25 7/week @ 2024-01-01 80/week @ 2024-01-08 1491/week @ 2024-01-15 219/week @ 2024-01-22 492/week @ 2024-01-29 290/week @ 2024-02-05 898/week @ 2024-02-12 459/week @ 2024-02-19 553/week @ 2024-02-26 168/week @ 2024-03-04

2,096 downloads per month
Used in nannou_laser

MIT/Apache

31KB
702 lines

ilda-idtf Actions Status Crates.io Crates.io docs.rs

A complete implementation of the ILDA Image Data Transfer Format Specification, Revision 011, 2014-11-16.

This library provides efficient reading and writing of IDTF. The reader implementation uses a zero-copy approach where structures are mapped directly to the memory from which they are read.

Usage

The SectionReader type can be used to read IDTF sections from any type implementing std::io::Read. This allows for efficiently reading the format from any byte source (e.g. file, memory, socket, etc).

let mut reader = ilda_idtf::SectionReader::new(reader);

The open function is provided as a convenience for opening a buffered IDTF SectionReader for the file at the given path.

let mut reader = ilda_idtf::open(path).unwrap();

The SectionReader::read_next method allows for iteration over the sections contained within.

while let Ok(Some(section)) = reader.read_next() {
    // ...
}

Each yielded Section provides access to the Header and the inner reader. The exact reader kind is determined via the Format specified within the header. The user must pattern match on the section's reader field in order to retrieve an instance of the correct subsection reader type. The user may then read the associated subsection data.

match section.reader {
    ilda_idtf::SubsectionReaderKind::Coords3dIndexedColor(mut r) => {
        while let Some(point) = r.read_next().unwrap() {
            // ...
        }
    }
    ilda_idtf::SubsectionReaderKind::Coords2dIndexedColor(mut r) => {
        while let Some(point) = r.read_next().unwrap() {
            // ...
        }
    }
    ilda_idtf::SubsectionReaderKind::ColorPalette(mut r) => {
        while let Some(palette) = r.read_next().unwrap() {
            // ...
        }
    }
    ilda_idtf::SubsectionReaderKind::Coords3dTrueColor(mut r) => {
        while let Some(point) = r.read_next().unwrap() {
            // ...
        }
    }
    ilda_idtf::SubsectionReaderKind::Coords2dTrueColor(mut r) => {
        while let Some(point) = r.read_next().unwrap() {
            // ...
        }
    }
}

In order to interpret the indexed color data formats, a color palette must be used. A color palette is an ordered list of RGB colors. While the palette should be specified by a preceding Section, this is not always the case. The ILDA IDTF specification recommends a default palette. This palette is provided via the DEFAULT_PALETTE constant.

License

Licensed under either of

at your option.

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Test Files

The files within the test_files directory have been retrieved from the following site:

http://www.laserfx.com/Backstage.LaserFX.com/Archives/DownloadIndex.html

These files are not included under the license mentioned above. Each test_files/ subdirectory is provided from a different group of laserists. Please see the ReadMe.txt in each for more information on their origins and conditions of use.

Dependencies

~2.5MB
~48K SLoC