Skip to content

About

Pixel-art scaling algorithms and filters for .NET 10: a dependency-free library plus a command-line tool that uses it.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

SharpScaler

Pixel-art scaling algorithms and filters for .NET 10: a dependency-free library plus a command-line tool that uses it.

Algorithms

Scalers (id → scale factors):

id algorithm factors package
nearest Nearest Neighbor any integer ≥ 1 core
scale2x, scale3x, scale4x Scale2x / Scale3x / Scale4x (4x = 2x twice) 2 / 3 / 4 core
mmpx, mmpx4x MMPX (4x = 2x twice) 2 / 4 core
scalefx, scalefx9x ScaleFX (9x = 3x twice) 3 / 9 core
depixel Depixelizing Pixel Art (Kopf/Lischinski) any integer ≥ 1 core
hq2x, hq3x, hq4x hqx 2 / 3 / 4 SharpScaler.Hqx
xbrz2x … xbrz6x xBRZ 2 … 6 SharpScaler.Xbrz

Filters (--filter id[:key=value,...]):

id options (default)
scanlines period (2), strength (0.5)
crt bleed (0.25), mask (0.4), scanline (0.35), period (2), gain (automatic brightness compensation, 1 = off)
dither levels (2..256, default 2), method (bayer2, bayer4, bayer8, floyd-steinberg; default bayer4)

Algorithm specifications and provenance: docs/references/.

Command-line tool

sharpscaler list
sharpscaler scale <input> <output> [-a|--algo <id>] [-f|--factor <n>] [--filter <spec>]... [--show]
  • Input: PNG or BMP, detected by file content. Output: .png or .bmp, chosen by extension.
  • Defaults: --algo nearest, --factor 2. Filters run after scaling, in the given order.
  • --show also prints the result as Sixel graphics (needs a Sixel-capable terminal and a build with SharpSixel).
  • Exit codes: 0 ok, 1 runtime error (I/O, unsupported or corrupt image), 2 usage error.
sharpscaler scale sprite.png out.png -a scale2x -f 2
sharpscaler scale sprite.png out.png -a nearest -f 4 --filter crt:period=4 --filter dither:levels=16

Two CLI flavors are built: Mit (core algorithms only) and Full (adds hqx and xBRZ; binary under GPL-3.0-only).

Library

using SharpScaler;
using SharpScaler.Imaging;

PixelImage input = PngCodec.Decode(File.ReadAllBytes("sprite.png"));
AlgorithmRegistry registry = AlgorithmRegistry.CreateDefault();
// hqx / xBRZ (optional packages): HqxScalers.Register(registry); XbrzScalers.Register(registry);

PixelImage output = new ImagePipeline()
    .Scale(registry.GetScaler("scale2x"), 2)
    .Filter(registry.GetFilter("scanlines"))
    .Run(input);
File.WriteAllBytes("out.png", PngCodec.Encode(output));

Pixel format: RGBA8888, straight alpha, row-major. Output is deterministic. BMP and PNG codecs are built in; further formats via the optional SharpScaler.Skia adapter (SkiaSharp).

Build, test, release

dotnet build
dotnet test                              # Skia-free main suite
dotnet test tests/SharpScaler.Skia.Tests # optional Skia adapter
sh tools/release.sh                      # nupkgs, self-contained CLI (Mit/Full × win-x64/linux-x64) and archives (.zip Windows, .tar.gz Linux) into artifacts/, deliverables copied to release/<version>/

Test helpers: tools/test-all.ps1 (Windows, runs every scaler/filter on one input), tools/test-formats.py (Linux, input-format matrix).

Note on the use of AI (voluntary)

Parts of this project (source code, tests and documentation) were created with the assistance of the AI language model Claude by Anthropic (Claude Sonnet 5.5; only this one model version was used).

Licenses

Per project, with SPDX-License-Identifier headers in every source file:

project license
SharpScaler (core), SharpScaler.Cli, SharpScaler.Skia MIT
SharpScaler.Hqx LGPL-2.1-or-later
SharpScaler.Xbrz GPL-3.0-only
SharpScaler.All (meta package: core + Hqx + Xbrz) GPL-3.0-only

Both variants are published in parallel: all-in-one SharpScaler.All, or the MIT core SharpScaler plus the optional SharpScaler.Hqx / SharpScaler.Xbrz. Anything that includes xBRZ is a GPL-3.0-only combined work; the MIT packages carry no copyleft. Full texts: LICENSES/; overview: LICENSE; third-party notices: THIRD-PARTY-NOTICES.md (also inside every package and CLI folder).

Copyright © 2026 Alexander Feuster, https://github.com/feuster/SharpScaler

About

Pixel-art scaling algorithms and filters for .NET 10: a dependency-free library plus a command-line tool that uses it.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages