C#: Seeking PNG Compression algorithm/library [closed]

Unfortunately, .NET (and GDI+, which the .NET graphics libraries are built on) does not support any encoding parameters for PNG. In fact, if you call GetEncoderParameterList on your image with the PNG encoder Clsid, you’ll get a “Not implemented” exception.

Even more unfortunate is that both ImageFormat and ImageCodecInfo are sealed classes and you can’t just add new codecs to what .NET can natively access. Microsoft dropped the ball on this one.

This means your alternatives are, in decreasing order of masochism:
1) Implement a save function on your own in .NET that implements RFC 2083,
2) Implement a save function based off porting libpng to .NET,
3) Call unmanaged code that was built from libpng directly

libpng has great documentation and is free, both in availability and license permissiveness.

Leave a Comment