Skip to content

v0.16.0: Bilinear filtering and faster scaling

Latest

Choose a tag to compare

@Darky-Lucera Darky-Lucera released this 16 Oct 19:08

This release adds per-window selection of nearest-neighbor or bilinear filtering at run time, and makes CPU scaling faster.

Heads up. Two build defaults change:

  • 64-bit x86: builds now target x86-64-v2. On older processors, mfb_open_ex fails. Set MINIFB_USE_X86_64_V2=OFF to support them.
  • Web: Emscripten builds now enable WebAssembly SIMD. Set MINIFB_USE_WASM_SIMD=OFF to support browsers without it.

New

  • mfb_set_stretch_mode(window, mode) selects MFB_STRETCH_NEAREST or MFB_STRETCH_BILINEAR independently for each window. Both filters are always available, and new windows use nearest.
  • MINIFB_USE_X86_64_V2 and MINIFB_USE_X86_64_V3 select the CPU level for the whole library. The v3 option is off by default.
  • MINIFB_USE_WASM_SIMD lets the compiler vectorize buffer operations in Emscripten builds.
  • Tests for both scaling filters, cache reuse, independent window settings and Web canvas reopening.
  • docs/scaling_algorithms.md explains how the CPU scaler works and how much faster it is.

Changes

  • The CPU scaler, used by X11 without OpenGL, Wayland, Android, DOS, and GDI and Cocoa in bilinear mode, caches its column tables and reuses rows. It uses SSE2 and AVX2 on x86, and NEON on ARM, where available. In the documented benchmarks, nearest-neighbor scaling is up to 7.7 times faster than before.
  • CPU nearest-neighbor scaling now samples at pixel centers, so some scaled images change slightly.
  • In input_events, B selects bilinear and N selects nearest.
  • The Android examples have separate application ids, so both can be installed on the same device.

Fixes

  • Windows with GDI: a window smaller than its buffer could show wrong colors.
  • macOS without Metal: nearest-neighbor scaling could smooth the image.
  • Scaling: images with a dimension of 65,536 pixels or more could be drawn incorrectly.
  • Web: optimized examples and tests could abort at startup.
  • Android: native2026 could crash at startup on API 28 and 29.
  • X11/OpenGL: the OpenGL context is now released before it is destroyed and before the X display is closed.
  • Examples: improved allocation failure handling and corrected viewport and input coordinate calculations.

Thanks to @fruediger for the clang-cl warning fixes in #147.

See the CHANGELOG for the details.