Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CanvasNet

GitHub forks GitHub stars GitHub contributors License Build Quality Gate Security NuGet

.NET canvas library for loading, saving, and cropping images

Overview

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.

Features

  • 🖼️ Pixel Buffer - Mutable 32-bit RGBA Surface with 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

Installation

dotnet add package CanvasNet

Or via Package Manager Console:

Install-Package CanvasNet

Usage

using 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 back

Building

pwsh ./build.ps1

API Documentation

Detailed API documentation for all public types and members is distributed in the api/ folder of the NuGet package.

User Guide

The CanvasNet User Guide is available on the CanvasNet releases page.

Contributing

Contributions are welcome. See CONTRIBUTING.md for development setup, coding standards, and the pull request process.

License

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.

Support

About

Pure DotNet Canvas Library

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages