TYoshimura.PNGReadWrite
5.0.0
dotnet add package TYoshimura.PNGReadWrite --version 5.0.0
NuGet\Install-Package TYoshimura.PNGReadWrite -Version 5.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="TYoshimura.PNGReadWrite" Version="5.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TYoshimura.PNGReadWrite" Version="5.0.0" />
<PackageReference Include="TYoshimura.PNGReadWrite" />
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 TYoshimura.PNGReadWrite --version 5.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TYoshimura.PNGReadWrite, 5.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.
#:package TYoshimura.PNGReadWrite@5.0.0
#: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=TYoshimura.PNGReadWrite&version=5.0.0
#tool nuget:?package=TYoshimura.PNGReadWrite&version=5.0.0
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 8.0 - 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 = PNGPixelArray.Read(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 = PNGPixelArray.Read(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 | 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.
-
net8.0
- System.Drawing.Common (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
fix: read