IO.Github.Hcoona.Pngcs
1.2.1
dotnet add package IO.Github.Hcoona.Pngcs --version 1.2.1
NuGet\Install-Package IO.Github.Hcoona.Pngcs -Version 1.2.1
<PackageReference Include="IO.Github.Hcoona.Pngcs" Version="1.2.1" />
<PackageVersion Include="IO.Github.Hcoona.Pngcs" Version="1.2.1" />
<PackageReference Include="IO.Github.Hcoona.Pngcs" />
paket add IO.Github.Hcoona.Pngcs --version 1.2.1
#r "nuget: IO.Github.Hcoona.Pngcs, 1.2.1"
#:package IO.Github.Hcoona.Pngcs@1.2.1
#addin nuget:?package=IO.Github.Hcoona.Pngcs&version=1.2.1
#tool nuget:?package=IO.Github.Hcoona.Pngcs&version=1.2.1
PNGCS
A small library to read/write huge PNG files in C#.
Overview
PngCs is a C# library to read/write PNG images.
It provides a simple API for progressive (sequential line-oriented) reading and writing. It's specially suitable for huge images, which one does not want to load fully in memory.
Installation
Install the NuGet package:
dotnet add package IO.Github.Hcoona.Pngcs
Or via Package Manager Console:
Install-Package IO.Github.Hcoona.Pngcs
Features
- Modern .NET support: Multi-targeting for
netstandard2.0
,netstandard2.1
,net8.0
, andnet9.0
- Native AOT compatibility: Full support for Native Ahead-of-Time compilation
- Supports all PNG spec color models and bitdepths:
- RGB8/RGB16/RGBA8/RGBA16
- G8/4/2/1
- GA8/4/2/1
- PAL8/4/2/1
- All filters/compression settings
- Support for Chunks (metadata)
- API Compatibility: API aligned with
Hjg.Pngcs
v1.1.4. SeeCompatibilitySuppressions.xml
for details. - Note: Does not support interlaced images
Origin
This is a port of the PngJ library (Java). The API, documentation and samples from PNGJ apply also to this PngCs library: http://code.google.com/p/pngj/wiki/Overview
History
See ChangeLog.md
Authors
- Hernan J Gonzalez - hgonzalez@gmail.com - Stack Overflow Profile - The original author.
- Shuai Zhang - zhangshuai.ustc@gmail.com - Current maintainer.
License
This project is licensed under the GNU General Public License v3.0 or later (GPL v3+). See LICENSE.GPL.txt
for details.
Portions of the code are derived from an open source project originally licensed under the Apache License, Version 2.0 by Hernán J. González. The original copyright and license notice are preserved in accordance with the Apache License.
For more information, see the files:
LICENSE.GPL.txt
(GPL v3+)LICENSE.APACHE.txt
(Apache 2.0)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 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 is compatible. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.2.1 | 60 | 7/27/2025 |
1.2.0-beta.14 | 194 | 7/26/2025 |
1.2.0-beta.11 | 194 | 7/26/2025 |
1.2.0-beta.2 | 208 | 7/26/2025 |
# PngCs Changelog
A C# port of the PNG Java library.
## Version History on GitHub
Change logs for <https://github.com/hcoona/pngcs>.
### Version 1.2.1 (July 27, 2025)
- **Modern .NET support**: Multi-targeting for `netstandard2.0`, `netstandard2.1`, `net8.0`, and `net9.0`
- **Native AOT compatibility**: Full support for Native Ahead-of-Time compilation
- **NuGet package availability**: Official NuGet package with assembly name `Hjg.Pngcs`
- **Enhanced compression support**: Improved ZLib stream implementation
- Native `ZLibStream` support for .NET 8.0+ targets
- Unified compression stream architecture
- **Performance improvements**:
- Enhanced string operations with ordinal comparison
- Optimized dictionary lookups with `TryGetValue()` patterns
- Eliminated unnecessary array allocations
- **Bug fixes**:
- Fixed `PngChunkTIME.GetAsString()` format string issues
- Improved stream disposal to prevent resource leaks
- Fixed ThreadStatic field initialization problems
- **Breaking changes**:
- Assembly renamed from `pngcs` to `Hjg.Pngcs`
- Consolidated ZLib stream implementations (removed separate `ZlibInputStreamMs` and `ZlibOutputStreamMs` classes)
- Updated to GPL-3.0+ licensing
## Version History on Google Code
Change logs for <http://code.google.com/p/pngcs/>.
### Version 1.1.4 (December 15, 2012)
- **Dual targeting support**: .NET 4.5 with CLR `DeflateStream` (with custom Zlib wrapper) and older versions with SharpZipLib (requires additional DLL)
- New `Zlib` namespace/folder structure
- Decoupled compression implementation from SharpZipLib/.NET CLR
- Custom implementations of CRC32 and Adler checksums
- **Bug fixes**:
- Fixed bad namespace in internal `PngInterlacer`
- Replaced CRC test in `PngReader` with Adler32
### Version 1.1.3 (December 8, 2012)
- **Interlaced PNG support**: Full reading support for interlaced images
- **Enhanced sample storage**: Read/write operations now support both `INT` and `BYTE` for sample storage
- `ImageLine` includes `sampleType` with dual buffers: `Scanline` (integer) and `ScanlineB` (byte)
- New type-specific methods: `ReadRowInt`/`ReadRowByte`, `WriteRowInt`/`WriteRowByte`
- **Packed format support**: Bit depths 1-2-4 can be unpacked on-the-fly during read/write operations (see `PngReader.SetUnpackedMode()`)
- **Improved PngReader**:
- `ReadRow` can skip rows efficiently (`getRow` is now deprecated)
- More efficient decoding (only processes necessary data)
- New batch operations: `ReadRows`/`WriteRows` returning `ImageLines` object
- `PngReader.ReadSkippingAllRows` allows efficient pixel data skipping
- **Enhanced testing framework**:
- Added `crctest` and `PngReaderTest` for improved internal testing
- `PngSuiteTest` performs double-mirror comparison with original images (including interlaced)
- **API improvements**:
- `ImageLineHelper.Pal2rgb` (renamed, corrected, supports alpha with TRNS)
- Added `getMetadata().GetPalette()` and `getMetadata().CreateNewPalette()`
- Fixed textual chunk issues (null bytes, empty texts) with comprehensive testing
- **Code organization**: Extensive polishing and reorganization of test/sample code into unified project
### Version 1.0.96 (October 21, 2012)
- **API enhancement**: `SetMaxXXX()` methods now accept zero for unlimited operation (e.g., `PngReader.setMaxTotalBytesRead(0)`)
- **New sample**: Added `SampleCustomChunk` demonstrating custom chunk registration for read/write operations
- **Bug fixes**:
- Fixed `PNGChunkTIME` output format issues
- Fixed `PngWriter.init()` not being called internally when row number not provided
### Version 1.0.95 (August 14, 2012)
- **Enhanced security**: Defensive limits and tuning for `PngReader`
- New limits: `MaxTotalBytesRead` (200MB), `MaxBytesMetadata` (5MB), `SkipChunkMaxSize` (2MB)
- Added `SkipChunkIds` for "fdAT" chunks
- `PngChunkSkipped`: Truly skipped chunks (never loaded into memory)
- All skipped chunks represented as `PngChunkSkipped` in `ChunksLists`
- **Code improvements**:
- Removed `ParseChunkAndAddToList()`, added `ReadChunk()` method
- Added 'offset' property to chunks (informational)
- Updated `PngReader` offset to `long` type (supports >2GB files) with `MaxTotalBytesRead` validation
### Version 1.0.93 (June 23, 2012)
- **Non-sequential reading**: `PngReader.GetRow()` supports non-sequential access (useful for line skipping)
- **API update**: `PngReader.End()` no longer deprecated, now recommended
- **Bug fix**: Fixed `ImageLine.Pack()`/`ImageLine.Unpack()` buffer length requirements
- **New feature**: Added `PngWriter.ComputeCompressionRatio()`
### Version 1.0.92 (June 15, 2012)
- **License change**: Now released under Apache License
- **Standalone assembly**: Replaced external SharpZipLib with embedded `ICSharpCode.SharpZipLib.dll`
- **C# conventions**: Extensive refactoring to follow C# best practices
- **Breaking changes**: Signature modifications (especially casing) break backward compatibility
- Removed unnecessary LINQ imports and .NET 4.0 dependencies (now targets .NET 2.0)
- **Documentation**: Complete XML documentation for all classes and methods (`Pngcs.xml`)
- **Samples**: Reorganized and added new sample projects (e.g., `SampleCreateOrangeGradient`)
- **Documentation**: Added Doxygen documentation generation
### Version 1.0.91 (June 10, 2012)
- **Major reorganization**: Synchronized with Java port PngJ v0.91
- Complete chunk implementation and full PNG Test Suite support
- Public methods/properties now follow C# naming conventions
### Early Development
**September 22, 2011**: Feature parity achieved with current PngJ implementation. Testing, optimization, and validation pending.
**September 21, 2011**: Integrated SharpZipLib classes. Basic reading and writing functionality operational.
**January 2011**: Initial port from Java, assisted by j2cstranslator.sourceforge.net
---
## Credits
**Author**: Hernan J. Gonzalez
**Email**: <hgonzalez@gmail.com>
**Website**: <http://hjg.com.ar/>