For info on setting up and running Gecko's frontend Vue application, see the /frontend README
Lightweight, bitonal image compression static C++ library that was designed with WASM-compatibility in mind. Built for The Gecko Project.
Gecko requires the following to build:
- CMake version 3.16 or above
- A compiler which supports C++ 20 features
First, clone the reposity. Gecko can be built and configured for a variety of different environments and build systems. To configure and build a x64 Release for Visual Studio 2022, run:
cmake -B out/build -S . -G "Visual Studio 17 2022" -A x64 && cmake --build out/build --config ReleaseSubsequent builds that don't require reconfiguring cmake can be simplified:
cmake --build out/build --config ReleaseGecko uses GoogleTest framework, and integrates with ctest to run tests in a configuration-agnostic way. To execute all tests for a Release build, run:
ctest --test-dir build -C ReleaseIf you've configured your project for Visual Studio, the tests can alternatively be discovered and run via the Test Explorer.
For now, Gecko's compression library currently only supports encoding from / to 3-channel bitmaps. More specifically, it only supports encoding to uncompressed, positive-height, 24bpp .bmp files that follow the BITMAPINFOHEADER header format. Indexed-color bitmaps (with color palettes) are not supported.
Although these limitations may seem overly strict, Gecko is only really designed to be used by, well, Gecko.
#include <optional>
#include <cstddef>
#include <vector>
#include "CompressedBitonal.h"
#include "UncompressedBitonal.h"
using namespace Gecko::Compression;
...
std::vector<uint8_t> bmpBytes{}; // Load uncompressed bytes
std::optional<UncompressedBitonal> uncompressed;
std::optional<CompressedBitonal> compressed;
std::optional<std::vector<uint8_t>> compressedBytes;
uncompressed = UncompressedBitonal::TryReadFromBuffer(bmpBytes, UncompressedBitonal::StorageFormat::BMPStrict24);
if (uncompressed)
compressed = Encoder::TryCompressBitonal(*uncompressed);
if (compressed)
compressedBytes = CompressedBitonal::TryWriteToBuffer(*compressed, CompressedBitonal::StorageFormat::BDC);
if (compressedBytes)
; // Save compressed bytes