msla_format

Library for encoding and decoding common masked stereolithography (MSLA) file formats. This crate is a collection of format implementation extracted from my mslicer project, an open source slicer for MSLA printers.
Supported Formats
Run Length Encoding
Because resin printers often have very high resolution displays/masks it would be impractical to store layer data uncompressed, for this reason all the supported formats make use of some form of run length encoding (RLE). This is why the interface for all the layer encoders lets you add runs of values.
It is important to note that you must define a value for every pixel (although there is no check for this). This is because (on my printer at least) the buffer that each layer is decoded into is initially uninitialized. So if the last run doesn’t fill the buffer, the printer will just print whatever was in the buffer before which just makes a huge mess (theoretically of course).
Examples
For some real world examples, check out the following links to my mslicer project source code:
- CLI .ctb/.goo inspector
- Slicing a triangular mesh into a layer
- Decoding a sliced file for a layer preview
Decode
Decode a .ctb file from disk and saves all of its layers as PNGs (using the built-in RLE optimized PNG encoder).
use fs;
use ;
let bytes = read.unwrap;
let mut des = new;
let file = deserialize.unwrap;
println!;
for in file.layers.iter.enumerate
Encode
Encode a blank layer with default settings to a .goo file.
use File;
use ;
let config = default;
let pixels = config.platform_resolution.x * config.platform_resolution.y;
let mut layer = new;
layer.add_run;
let layer = finish;
let file = from_slice_result;
let mut ser = new;
file.serialize;