https://github.com/tzinmein/xbrz-sharp
.NET 8 port of xBRZ 1.8 – high-quality 2D image upscaling library.
https://github.com/tzinmein/xbrz-sharp
2d dotnet image image-processing upscaling xbrz
Last synced: 2 months ago
JSON representation
.NET 8 port of xBRZ 1.8 – high-quality 2D image upscaling library.
- Host: GitHub
- URL: https://github.com/tzinmein/xbrz-sharp
- Owner: tzinmein
- License: other
- Created: 2025-10-01T12:51:01.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-11-08T15:27:24.000Z (8 months ago)
- Last Synced: 2026-03-02T21:51:31.376Z (4 months ago)
- Topics: 2d, dotnet, image, image-processing, upscaling, xbrz
- Language: C#
- Homepage:
- Size: 708 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# XbrzSharp

[](https://www.nuget.org/packages/XbrzSharp/)
[](LICENSE.md)

[xBRZ](https://sourceforge.net/projects/xbrz/): "Scale by rules" – high quality image upscaling filter by Zenju.
This is a .NET 8 port of xBRZ 1.8, based on the [Java port by Stanio](https://github.com/stanio/xbzr-java).
**Important:** This project is **distinct** from another .NET port [xBRZ.NET](https://github.com/Helion-Engine/xBRZ.NET) (namespace `xBRZNet`).
Right now it's a very straightforward port. Performance optimizations and more idiomatic .NET code may be added in the future.
Copyright (c) 2025 Ho Tzin Mein
## Projects
- **XbrzSharp** – Core xBRZ upscaling logic (library)
- **XbrzSharpTool** – Command-line tool for batch image upscaling
## Usage
### Command-Line Tool
```sh
dotnet run --project XbrzSharpTool -- [scaling_factor]
```
- ``: Path to the input image file or directory. If a directory is specified, all supported images in the directory will be upscaled.
- `[scaling_factor]`: Optional integer (default: 2). Must be between 2 and 6.
The output will be saved as `@x.png` in the same directory as the input file(s).
### Library API Example
You can use the `XbrzSharp` library in your own .NET projects for programmatic upscaling:
```csharp
using System.Drawing;
using System.Drawing.Imaging;
using Xbrz;
// Load your image as a Bitmap
using var bitmap = new Bitmap("input.png");
// Convert to ARGB int[] array
int width = bitmap.Width, height = bitmap.Height;
int[] srcPixels = new int[width * height];
var rect = new Rectangle(0, 0, width, height);
var data = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
System.Runtime.InteropServices.Marshal.Copy(data.Scan0, srcPixels, 0, srcPixels.Length);
bitmap.UnlockBits(data);
// Perform scaling
int factor = 3;
var scaler = new XbrzScaler(factor, withAlpha: true);
int[] scaledPixels = scaler.ScaleImage(srcPixels, null, width, height);
// Convert back to Bitmap
int scaledWidth = width * factor, scaledHeight = height * factor;
var scaledBitmap = new Bitmap(scaledWidth, scaledHeight, PixelFormat.Format32bppArgb);
var scaledRect = new Rectangle(0, 0, scaledWidth, scaledHeight);
var scaledData = scaledBitmap.LockBits(scaledRect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
System.Runtime.InteropServices.Marshal.Copy(scaledPixels, 0, scaledData.Scan0, scaledPixels.Length);
scaledBitmap.UnlockBits(scaledData);
// Save the result
scaledBitmap.Save("output@3x.png");
```
## Attribution for Test Assets
Test inputs and expected outputs are copied from the xBRZ Java port by Stanio.
## License
- **Core library (`xBrzNet`)**: [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html)
- **Other code (tools, tests, helpers, documentation)**: [BSD Zero Clause License](https://spdx.org/licenses/0BSD.html)
See [LICENSE](LICENSE.md) for full license texts.