hqx
High-quality pixel-art magnification by 2x, 3x, and 4x. The filter keeps sharp edges sharp and smooths diagonal edges, which suits sprites and tiles far better than bilinear scaling.
How it works
For each source pixel the filter reads a 3x3 neighborhood, classifies the eight neighbors as close or distant in an approximate YUV space, and fills the output block from a 256-entry rule table. Border pixels replicate their nearest in-image neighbor.
Pixel format
Each pixel is a u32 read as 0xAARRGGBB. Alpha sits in the top byte and rides
through interpolation. Color comparison ignores alpha. Byte order in memory is
the caller's concern.
Usage
// A 2x2 image of four colors, scaled 2x to 4x4.
let src = ;
let mut dst = vec!;
hq2x;
assert_eq!;
The destination must hold scale * scale * width * height pixels. A short
destination panics up front before any write. The _rb variants take explicit
row strides in pixels for padded buffers.
Installation
[]
= "0.1"
License
Distributed under the GNU Lesser General Public License version 2.1 or later. See LICENSE and NOTICE.