TYoshimura.PNGReadWrite
4.1.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package TYoshimura.PNGReadWrite --version 4.1.1
NuGet\Install-Package TYoshimura.PNGReadWrite -Version 4.1.1
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="TYoshimura.PNGReadWrite" Version="4.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TYoshimura.PNGReadWrite --version 4.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TYoshimura.PNGReadWrite, 4.1.1"
#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 TYoshimura.PNGReadWrite as a Cake Addin #addin nuget:?package=TYoshimura.PNGReadWrite&version=4.1.1 // Install TYoshimura.PNGReadWrite as a Cake Tool #tool nuget:?package=TYoshimura.PNGReadWrite&version=4.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PNGReadWrite
PNG file IO - Deep color compatible
PNG Suite passed
Requirement
.NET 6 - windows
Install
- Nuget include: System.Drawing.Common
- Enable WPF (*.csproj)
<PropertyGroup>
<UseWPF>true</UseWPF>
</PropertyGroup>
Usage
Create
const int width = 255, height = 128;
PNGPixel[,] arr = new PNGPixel[width, height];
for (int x, y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
arr[x, y] = new PNGPixel((ushort)(x * 257), (ushort)(y * 257), 0);
}
}
PNGPixelArray png = new(arr);
PNGPixelArray png_copy = png[10..^20, 20..^30];
png_copy.Write(dirpath + "pngcopy_regionclip.png");
Open
PNGPixelArray png = new();
png.Read(filepath);
PNGPixelArray png = new(filepath);
GDI+(Bitmap) <-> PNGPixelArray
Bitmap bitmap = new(32, 32);
using (Graphics g = Graphics.FromImage(bitmap)) {
using Pen pen = new(new SolidBrush(Color.Black));
g.Clear(Color.Gray);
g.DrawLine(pen, new Point(0, 0), new Point(31, 31));
}
PNGPixelArray png_black = bitmap;
png_black.Write(dirpath + "gdi_test.png");
PNGPixelArray png_read = new(dirpath + "gdi_test.png");
bitmap = (Bitmap)png_read;
using (Graphics g = Graphics.FromImage(bitmap)) {
using Pen pen = new(new SolidBrush(Color.White));
g.DrawLine(pen, new Point(0, 31), new Point(31, 0));
}
PNGPixelArray png_cross = bitmap;
png_cross.Write(dirpath + "gdi_test2.png");
Assert.AreEqual(PNGPixel.Black, png_cross[0, 0]);
Assert.AreEqual(PNGPixel.Black, png_cross[^1, ^1]);
Assert.AreEqual(PNGPixel.White, png_cross[0, ^1]);
Assert.AreEqual(PNGPixel.White, png_cross[^1, 0]);
WPF(BitmapSource) <-> PNGPixelArray
WriteableBitmap bitmapsource = new(32, 32, 96d, 96d, PixelFormats.Rgba64, null);
PNGPixelArray png = bitmapsource;
png.Write(dirpath + "wic_test.png");
png.Metadata.Dpi = (32, 32);
bitmapsource = new WriteableBitmap((BitmapSource)png);
Assert.AreEqual(32, bitmapsource.DpiX);
See also: Tests
Licence
Author
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- System.Drawing.Common (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
refactor