BigGustave 1.0.0

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package BigGustave --version 1.0.0
NuGet\Install-Package BigGustave -Version 1.0.0
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="BigGustave" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BigGustave --version 1.0.0
#r "nuget: BigGustave, 1.0.0"
#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.
// Install BigGustave as a Cake Addin
#addin nuget:?package=BigGustave&version=1.0.0

// Install BigGustave as a Cake Tool
#tool nuget:?package=BigGustave&version=1.0.0

Big Gustave

Build status

Open, read and create PNG images in fully managed C#.

Usage

To open a PNG image from file and get some pixel values:

using (var stream = File.OpenRead(@"C:\my\file\path\file.png"))
{
    Png image = Png.Open(stream);

    Pixel pixel = image.GetPixel(image.Width - 1, image.Height - 1);

    int pixelRedAverage = 0;

    pixelRedAverage += pixel.R;

    pixel = image.GetPixel(0, 0);

    pixelRedAverage += pixel.R;

    Console.WriteLine(pixelRedAverage / 2.0);       
    
}

The PNG object has methods to inspect the header and get the pixel values. The header has properties for:

png.Header.Width
png.Header.Height
png.Header.BitDepth
png.Header.ColorType
png.Header.CompressionMethod
png.Header.FilterMethod
png.Header.InterlaceMethod

The PNG also has width and height as convenience properties from the header information:

png.Width == png.Header.Width
png.Height == png.Header.Height

And a property that indicates if the image uses transparency:

png.HasAlphaChannel

To get a pixel use:

Pixel pixel = png.GetPixel(0, 7);

Where the first argument is x (column) and the second is y (row). The Pixel is used for all image types, e.g. Grayscale, Colour, with/without transparency.

Creation

Because of some issues with ZLib compatibility the created images work with most, but not all image viewers. Of the viewers tested the images work with all browsers, Paint, Gimp, Paint3D etc.

To create a PNG use:

var builder = PngBuilder.Create(2, 2, false);

var red = new Pixel(255, 0, 12, 255, false);
var black = new Pixel(0, 0, 0, 255, false);

builder.SetPixel(new Pixel(255, 0, 12, 255, false), 0, 0);
builder.SetPixel(new Pixel(255, 0, 12, 255, false), 1, 1);

using (var memory = new MemoryStream())
{
    builder.Save(memory);
    
    return memory.ToArray();
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BigGustave:

Package Downloads
WolvenKit.Modkit

Modding tools for Cyberpunk 2077.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 12,402 5/1/2021
1.0.5 246 4/22/2021
1.0.3 622 12/31/2020
1.0.2 338 11/8/2020
1.0.1 533 12/17/2019
1.0.0 515 5/19/2019