goo
Library for encoding and decoding Elegoo's .goo file format.
This is a stand alone version of this crate taken from my mslicer project, its an open source slicer for masked stereolithography printers.
If you want to learn more about the goo format, make sure you read the official format spec. Some things aren't mentioned in the spec like how everything is big-endian, the checksum is just the negated sum of all bytes in the payload, and the image data encoding specification is hard to follow, so look at my implementation. Also, if you use ImHex, I have created a pattern file (goo.hexpat) that may be helpful.
Examples
For some real world examples, check out the following links to my mslicer project source code:
Encoding an Image
Because thousands of very high resolution images take many tens of gigabytes to store, goo files use a run length encoding mechanism as a simple form of compression. In order to encode an image into a goo layer, you therefore must separate it into runs first. In this example ill just add alternating rows of white and black.
It is important to note that you must define a value for every pixel. This is because on my printer at least the buffer that each layer is decoded into is uninitialized memory. 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.
use ;
let size = ;
let mut out = new;
for y in 0..size.1
let = out.finish;
let decoder = new;
assert_eq!;
for run in decoder
Decoding to Images
This example is a simplified version of the included example to inspect sliced goo files. Note that setting each pixel individually is not very fast, but it was enough for a debugging tool.
use fs;
use ;
use RgbImage;
let raw_goo = read?;
let goo = deserialize?;
println!;
for in goo.layers.iter.enumerate