Baker76.Imaging 1.0.30

dotnet add package Baker76.Imaging --version 1.0.30
                    
NuGet\Install-Package Baker76.Imaging -Version 1.0.30
                    
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="Baker76.Imaging" Version="1.0.30" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Baker76.Imaging" Version="1.0.30" />
                    
Directory.Packages.props
<PackageReference Include="Baker76.Imaging" />
                    
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 Baker76.Imaging --version 1.0.30
                    
#r "nuget: Baker76.Imaging, 1.0.30"
                    
#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 Baker76.Imaging@1.0.30
                    
#: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=Baker76.Imaging&version=1.0.30
                    
Install as a Cake Addin
#tool nuget:?package=Baker76.Imaging&version=1.0.30
                    
Install as a Cake Tool

Baker76.Imaging

A library for creating and manipulating images with basic support for reading and writing image file formats.

Main reason for writing this imaging library is System.Common.Drawing for .NET 6 only supports Windows platform and SixLabors.ImageSharp reads indexed images, but translates palette into RGB.

This makes it difficult to create and manipulate indexed images with a palettes for cross-platform usage.

Features:

  • Create and manipulate images.
  • Read and write bitmap images.

Usage

Creating images

Create new image with dimension 2 * 2 and 8 bits per pixel:

var image = new Image(2, 2, 8);

Create new image with dimension 2 * 2 and 8 bits per pixel with black color as transparency:

var image = new Image(2, 2, 8, true, new Color(0, 0, 0));

Black color is added as first color in palette and set as transparent color.

Create new image with dimension 2 * 2 and 32 bits per pixel:

var image = new Image(2, 2, 32);

Using palette

Add red color to palette:

image.Palette.AddColor(new Color(255, 0, 0));

Set 3rd color as transparency color:

image.Palette.TransparentColor = 2;

Get and set pixels

Get pixel at coordinate x = 2 and y = 2:

var pixel = image.GetPixel(1, 1);

Set pixel at coordinate x = 2 and y = 2 to palette's 3rd color:

image.SetPixel(1, 1, 2);

Setting pixels to palette colors are only supported for 1, 2, 4 and 8 bits per pixel images.

Set pixel at coordinate x = 2 and y = 2 to red color using color instance:

image.SetPixel(1, 1, new Color(255, 0, 0));

Set pixel at coordinate x = 2 and y = 2 to red color using RGB values:

image.SetPixel(1, 1, 255, 0, 0);

Setting pixels to color instance or RGBA values are only supported for 24 and 32 bits per pixel images.

Directly manipulate image with dimension 2 * 2, 8 bits per pixel image pixel data and set pixel at coordinate x = 2 and y = 2 to 2nd palette color:

var pixelOffset = (1 * 2 + 1) * 1; // y * width + x * 1 byte per pixel
image.PixelData[pixelOffset] = 1; // 2nd palette color

Directly manipulate image with dimension 2 * 2, 24 bits per pixel image pixel data and set pixel at coordinate x = 2 and y = 2 to red color using RGB values:

var pixelOffset = (1 * 2 + 1) * 3; // y * width + x * 3 bytes per pixel
image.PixelData[pixelOffset] = 255; // red channel
image.PixelData[pixelOffset + 1] = 0; // green channel
image.PixelData[pixelOffset + 2] = 0; // blue channel

Reading and writing png images

Png reader and writer supports 2, 4, 8, 24 and 32 bits per pixel images.

Reading a png image:

await using var stream = File.OpenRead("test.png");
var image = PngReader.Read(stream);

Writing a png image:

await using var stream = File.OpenWrite("test.png");
PngWriter.Write(stream, image);

Reading and writing bitmap images

Bitmap reader and writer supports 1, 4, 8, 24 and 32 bits per pixel images.

Only 32 bits per pixel bitmaps support transparency.

Reading a .bmp image:

await using var stream = File.OpenRead("test.bmp");
var image = BmpReader.Read(stream);

Writing a .bmp image:

await using var stream = File.OpenWrite("test.bmp");
BmpWriter.Write(stream, image);
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 was computed.  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 (3)

Showing the top 3 NuGet packages that depend on Baker76.Imaging:

Package Downloads
Baker76.Atlas

Tools for generating and parsing Crunch texture atlas format.

Baker76.TileMap

Tools for generating and parsing Tiled tile map format.

Baker76.ColorQuant

A color quantizer based on Xiaolin Wu's Color Quantizer.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.30 55 8/1/2025
1.0.29 49 8/1/2025
1.0.28 86 7/27/2025
1.0.27 135 6/27/2025
1.0.26 128 6/27/2025
1.0.25 164 6/26/2025
1.0.24 141 6/26/2025
1.0.23 137 6/26/2025