RotSpriteSharp.SkiaSharpExtensions 1.0.1-beta.13

This is a prerelease version of RotSpriteSharp.SkiaSharpExtensions.
There is a newer version of this package available.
See the version list below for details.
dotnet add package RotSpriteSharp.SkiaSharpExtensions --version 1.0.1-beta.13
                    
NuGet\Install-Package RotSpriteSharp.SkiaSharpExtensions -Version 1.0.1-beta.13
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RotSpriteSharp.SkiaSharpExtensions" Version="1.0.1-beta.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RotSpriteSharp.SkiaSharpExtensions" Version="1.0.1-beta.13" />
                    
Directory.Packages.props
<PackageReference Include="RotSpriteSharp.SkiaSharpExtensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RotSpriteSharp.SkiaSharpExtensions --version 1.0.1-beta.13
                    
#r "nuget: RotSpriteSharp.SkiaSharpExtensions, 1.0.1-beta.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RotSpriteSharp.SkiaSharpExtensions@1.0.1-beta.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RotSpriteSharp.SkiaSharpExtensions&version=1.0.1-beta.13&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=RotSpriteSharp.SkiaSharpExtensions&version=1.0.1-beta.13&prerelease
                    
Install as a Cake Tool

Build & Publish NuGet NuGet Version License: AGPL-3.0-or-later

RotSpriteSharp (.NET port)

This is a port of the rotsprite-rs Rust library, which implements the RotSprite algorithm for high-quality pixel art rotation. The port aims to faithfully reproduce the original algorithm and provide a demo for batch rotation and comparison. It supports all currently supported .NET LTS versions.

RotSpriteSharp is a stable library. Future updates will mainly address dependency upgrades, support for new .NET LTS releases, and occasional new extensions. The core algorithm is complete and production-ready.

.NET LTS Support Timetable

Version Release Date End of Support
.NET 8 Nov 2023 Nov 2026
.NET 10 Nov 2025 Nov 2028

For more details, see the official .NET support policy.

About RotSpriteSharp

RotSpriteSharp is a pixel art rotation algorithm that preserves sharpness and detail, outperforming standard aliased rotation methods for sprites and pixel art. It works by:

  1. Pixel-Guessing Enlargement: Scales the input image up by 8x using a custom algorithm inspired by Scale2x, checking for pixel similarity rather than equality.
  2. Optimal Rotation Offset: Searches for the best rotation offset by iterating over a small grid, rotating the enlarged image, and choosing the offset with minimal color difference.
  3. Aliased Rotation & Downscaling: Rotates and scales the image back to the original size using nearest-neighbor methods.
  4. Single-Pixel Detail Correction: Optionally post-processes the output to fix overlooked single-pixel details.

This approach uses pixel-level heuristics to approximate high-quality rotation, resulting in visually pleasing, sharp, and smooth rotated sprites.

Usage

You can run the demo project (RotCon) with command-line parameters:

RotCon.exe <inputPath> [outputDir] [angles]
  • inputPath: Path to the input image (default: threeforms.png)
  • outputDir: Optional output directory for results (default: current directory)
  • angles: Optional comma-separated list of rotation angles (default: 0,45,90,135,180,225,270,315)

Example:

RotCon.exe threeforms.png out 0,90,180,270

This will output rotated images using the RotSpriteSharp algorithm, saving them in the out directory as threeforms_rot0.png, threeforms_rot90.png, etc.

Library API Example

The core rotation API is provided by the RotSpriteSharp class:

using RotSpriteSharp;
using SixLabors.ImageSharp.PixelFormats;

// Load your pixel buffer (e.g., from ImageSharp)
Rgba32[] pixels = ...;
int width = ...;
double angle = 45.0;
Rgba32 emptyColor = new Rgba32(0, 0, 0, 0);

// Rotate the image
var rotated = RotSpriteSharp.Rotate(pixels, emptyColor, width, angle);

// rotated.Pixels, rotated.Width, rotated.Height
  • For angles divisible by 90, the algorithm uses a fast path (no upscaling).
  • For other angles, the image is upscaled by 8x, rotated, and downscaled for high-quality results.

Extension Projects & Usage

RotSpriteSharp provides extension libraries for popular graphics APIs:

SkiaSharp Extensions

Add a reference to RotSpriteSharp.SkiaSharpExtensions and use:

using RotSpriteSharp.SkiaSharpExtensions;
using SkiaSharp;

// Rotate a SKBitmap
SKBitmap bitmap = ...;
SKBitmap rotated = bitmap.RotateWithRotSprite(45);

// Rotate a SKColor[] pixel buffer
SKColor[] pixels = ...;
int width = ...;
SKColor[] rotatedPixels = pixels.RotateWithRotSprite(width, 45);

System.Drawing Extensions

Add a reference to RotSpriteSharp.SystemDrawingExtensions and use (Windows only):

using RotSpriteSharp.SystemDrawingExtensions;
using System.Drawing;

// Rotate a Bitmap
Bitmap bitmap = ...;
Bitmap rotated = bitmap.RotateWithRotSprite(45);

// Rotate a Color[] pixel buffer
Color[] pixels = ...;
int width = ...;
Color[] rotatedPixels = pixels.RotateWithRotSprite(width, 45);

Note: System.Drawing.Common is only supported on Windows. The extension methods will throw PlatformNotSupportedException on other platforms.

Projects

  • RotSpriteSharp: Core library implementing the algorithm (no external dependencies).
  • RotCon: Console demo for batch rotation and comparison (uses SkiaSharp for image loading and saving).

Requirements

  • All currently supported .NET LTS versions
  • SkiaSharp (only required for the RotCon demo application)

Attribution & Credits

This .NET port is based on the Rust implementation and strives to maintain algorithmic fidelity with the original RotSprite algorithm. For more details on the algorithm, see the RotSprite Wikipedia page and the Rust implementation.

License

See LICENSE file for details. This project is licensed under the AGPL-3.0-or-later, following the original Rust implementation.


Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 215 11/9/2025
1.0.1-beta.13 171 11/9/2025
1.0.0 160 11/8/2025