.NET canvas library for loading, saving, and cropping images
CanvasNet is a .NET library providing a mutable, span-based 32-bit RGBA pixel buffer along with
codecs for loading and saving images in common file formats. It's designed for fast, allocation-conscious
image operations using Span<T>, and supports independent-copy cropping for load/crop/save workflows.
- 🖼️ Pixel Buffer - Mutable 32-bit RGBA
Surfacewith span-based row access - ✂️ Cropping - Independent-copy cropping for load/crop/save workflows
- 📀 BMP Codec - Load and save 24-bit and 32-bit uncompressed Windows BMP files
- 🎨 PNG Codec - Load and save 8-bit Truecolor (RGB) and Truecolor-with-alpha (RGBA) PNG files
- 🖨️ TIFF Codec - Load and save 8-bit RGB/RGBA/Grayscale TIFF files with PackBits/LZW/Deflate
- 🗜️ JPEG Codec - Load baseline/progressive JPEG and save baseline 4:2:0 JPEG with quality control
- ⚡ Span-Based - Fast, allocation-conscious row and pixel access
- 🔄 Multi-Target - Supports .NET Standard 2.0, .NET 8, 9, and 10
- 📦 NuGet Ready - Easy integration via NuGet package
dotnet add package CanvasNetOr via Package Manager Console:
Install-Package CanvasNetusing CanvasNet.Canvas;
using CanvasNet.Codecs;
var surface = new Surface(4, 4);
surface[1, 1] = new Rgba32(255, 0, 0, 255); // set a red, opaque pixel
var cropped = surface.Crop(0, 0, 2, 2); // independent 2x2 copy
BmpCodec.Save(surface, "surface.bmp"); // save as a 32-bit BMP file
var reloaded = BmpCodec.Load("surface.bmp"); // load it back
PngCodec.Save(surface, "surface.png"); // save as an RGBA PNG file
var reloadedPng = PngCodec.Load("surface.png"); // load it back
TiffCodec.Save(surface, "surface.tiff"); // save as an RGBA TIFF file
var reloadedTiff = TiffCodec.Load("surface.tiff"); // load it back
JpegCodec.Save(surface, "surface.jpg", 90); // save as a baseline JPEG file
var reloadedJpeg = JpegCodec.Load("surface.jpg"); // load it backpwsh ./build.ps1Detailed API documentation for all public types and members is distributed in the api/ folder
of the NuGet package.
The CanvasNet User Guide is available on the CanvasNet releases page.
Contributions are welcome. See CONTRIBUTING.md for development setup, coding standards, and the pull request process.
Copyright (c) DEMA Consulting. Licensed under the MIT License. See LICENSE for details.
By contributing to this project, you agree that your contributions will be licensed under the MIT License.