Unity plugin for encoding & decoding QOI format images (https://qoiformat.org/qoi-specification.pdf).
Implementation is split into:
- a zero allocation pure C# (QOI)
ReadOnlySpan
/Span
based "namespace" static class; very much based on the reference C implementation (https://github.com/phoboslab/qoi) with two minor changes:- decoding has been separated into
DecodeHeader
andDecode
(so that we get a chance to create an appropriately sizedSpan
to decode into) flipVertically
has been added to both encoding & decoding since gfx texture resources are typically flipped vertically compared to raster image data
- decoding has been separated into
- a Unity layer QOIUnity that can decode into or encode from a Unity
Texture2D
- uses
NativeArrayUnsafeUtility
to work directly with the native pixel data (at the appropriate mip-level if required) - only
RGBA32
andRGB24
texture formats are supported - encoding does require the source
Texture2D
to be readable
- uses
The sample Unity project includes a test UGUI scene that loads, displays & saves the test images referenced in https://qoiformat.org/
Prerquisites:
- Tested with Unity 2021.3.16f1