TimeBeanDithering 1.2.0
dotnet add package TimeBeanDithering --version 1.2.0
NuGet\Install-Package TimeBeanDithering -Version 1.2.0
<PackageReference Include="TimeBeanDithering" Version="1.2.0" />
<PackageVersion Include="TimeBeanDithering" Version="1.2.0" />
<PackageReference Include="TimeBeanDithering" />
paket add TimeBeanDithering --version 1.2.0
#r "nuget: TimeBeanDithering, 1.2.0"
#:package TimeBeanDithering@1.2.0
#addin nuget:?package=TimeBeanDithering&version=1.2.0
#tool nuget:?package=TimeBeanDithering&version=1.2.0
Dithering
.NET implementation of dithering
<p align="left"> <img src="https://github.com/TimeBean/Dithering/blob/main/Examples/Bayer4x4PalettePico8.png?raw=true" height="120"/> <img src="https://github.com/TimeBean/Dithering/blob/main/Examples/Bayer8x8PaletteObraDinnIBM.png?raw=true" height="120"/> <img src="https://github.com/TimeBean/Dithering/blob/main/Examples/StuckiLinear8x.png?raw=true" height="120"/> </p>
More examples can be found in Examples/
Usage
// load file
using var input = File.OpenRead(@"Examples/Mirana.png");
// get bitmap from file stream
using var originalBitmap = SKBitmap.Decode(input);
// stats
var width = originalBitmap.Width;
var height = originalBitmap.Height;
var rowBytes = originalBitmap.RowBytes;
var bytesPerPixel = originalBitmap.BytesPerPixel;
// pixelSpan that will be modified
var pixelSpan = originalBitmap.GetPixelSpan();
// reduces the number of colors to a fixed palette (e.g. 4 colors)
var quantizer = new LinearQuantizer(4);
// applies error diffusion dithering using Floyd–Steinberg
var processor = new FloydSteinbergProcessor(width, height, rowBytes, bytesPerPixel);
// dithring itself
var dithered = processor.Process(pixelSpan, quantizer);
// copy dithered span to original span
dithered.CopyTo(pixelSpan);
// save bitmap to file
var fileName = $"Out/dithered.png";
SaveBitmap(originalBitmap, fileName);
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- SkiaSharp (>= 3.119.3-preview.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.