UCG (Universal Compressed Graphics) is a file format for storing bitmaps as compact as possible, but still relatively fast to decompress.
Concept
The format uses a combination of Huffman Code & Run-Length encoding. Basically, it Huffman encodes both the colors (the 16 main colors + 1 transparent "color") and the run-lengths, and writes the results to a file.
Performance & Results
A 213pixels high and 320pixels wide UCG image file takes about 0.4 seconds to decode in ComputerCraft redux, which is pretty good considering the complexity of Huffman Code reading and the low computing speed of ComputerCraft computers. But while the original paintutils file is about 65kilobytes in size, the UCG file only takes up 25kilobytes.
Generally, an UCG file is about 10%-40% the size of the same image stored in paintutils format.
Advantages over paintutils images
- UCG files are much smaller than paintutils files
- the width & height of the image are stored at the start of the image, you don't have to read the whole image to find out the image size
You can find a detailed description and specification here: https://github.com/a.../Images/UCG1.md
The CraftOS-Standards Github repository where I proposed the standard: https://github.com/o...aftOS-Standards
And the discussion about the specification: https://github.com/o...andards/pull/34
Implementations
Here are 2 APIs for handling UCGs. They're not publicly released yet, so there's only little documentation about how to use them.
libucg: https://github.com/ardera/libucg/
xaif: https://github.com/ardera/xaif
Edited by ardera, 30 July 2017 - 09:24 PM.












