Skip to content

setbe/stb

 
 

Repository files navigation

stb (freestanding C++ fork)

This repository is a freestanding-friendly C++ rewrite/fork of selected stb single-header libraries.

Main goals:

  • Freestanding-first builds (optional CRT-free integration).
  • Cleaner C++ structure instead of macro-heavy C internals.
  • Header-first workflow with deterministic, testable behavior.
  • Byte-diff tests against original stb where practical.

Repository status

  • stb_truetype/ - Implemented based on stb_truetype.h.
  • stb_truetype_stream/ - Stream-oriented atlas pipeline (SDF, MSDF, MTSDF), no allocations inside the library path.
  • stb_image_write/ - Partially implemented (bmp, tga only).
  • stb_image/ - Implemented.
  • stb_image_resize2/ - NOT implemented.
  • 3rd_party/stb/ - upstream stb git submodule used for reference/byte-diff tests.
  • test/ - Catch2 tests and small Windows examples.

stb_image

  • Supported through the C++ API: PNG, BMP, GIF, PSD, PIC, JPEG, PNM, HDR, TGA.
  • Two-pass usage is available:
    • Pass 1: Plan* computes dimensions/channels/output byte size.
    • Pass 2: Decode* writes into caller-provided memory.
  • Batch planning helpers are available to compute max/sum memory across many images.
  • Byte-diff tests are present against original stb_image.h.

Build (CMake)

Example configure:

cmake -S . -B build -G "Visual Studio 17 2022" -A Win32

Example build:

cmake --build build --config ReleaseMiniNoConsole

Common MSVC configs:

  • Debug
  • Release
  • ReleaseMini
  • ReleaseNoConsole
  • ReleaseMiniNoConsole

Security note

As with original stb-family libraries, do not treat these parsers as hardened against hostile input without additional sandboxing and validation.

License

MIT (see LICENSE). Original stb code is by Sean Barrett and contributors.

About

stb header-only libraries for C++

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 99.0%
  • CMake 1.0%