ImageDotNet
A library for loading and saving images in .NET.
Goals
The goal of the library is to serve a purpose similar to stb_image and stb_image_write except written in C#. The goals include:
- Loading images.
- Writing images.
- Converting between different pixel formats.
Example
// Load image.png and ensure the pixel format is Rgba32.
var image = Image.LoadPng("image.png").To<Rgba32>();
// Get a pointer to the image data and pass it to glTexImage2D.
using (var data = image.GetDataPointer())
{
glTexImage2D(GL_TEXTURE_2D, 0, (int)GL_RGBA, image.Width, image.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void*)data.Pointer);
}
Credits
Thanks to:
- ImageSharp from Zulkir for helping me to understand some parts of PNG decoding.
- ImageSharp from Six Labors. I took the names for the pixel formats from there.