2

if you want to save the image in PNG format you can use ImageFormat class of .Net. But this class doesn't implemented compression for PNG files. And for some reasons i can't save my file in JPEG format. After Some researched i know libpng is the official PNG reference library. But i can't find anything for using it in .net framework. Does anyone know about this library and using it in .NET?

About libpng

Thanks in Advanced.

3 Answers3

3

Another alternative: PngCs

But this class doesn't implemented compression for PNG files

What on earth does that mean? PNG is compressed by design.

leonbloy
  • 73,180
  • 20
  • 142
  • 190
2

ImageMagick is a very nice library that allows you (among other things) create PNG files. Magick.NET is the .Net wrapper for this library. Using this library, you can simply convert/create image formats. E.g. from their documentation:

using (MagickImage image = new MagickImage("Snakeware.gif"))
{
   image.Write("Snakeware.jpg");
}
dsfgsho
  • 2,731
  • 2
  • 22
  • 39
  • Thank you for your answer,what about compression? –  Jun 17 '13 at 22:27
  • Documentation on how to use the compression can be found here: http://www.imagemagick.org/Usage/formats/#png_quality. Note that you don't necessarily need to use the library: you can also simply do the conversion in the command line using processes. E.g. http://stackoverflow.com/questions/16028228/calling-image-magick-commands-from-net – dsfgsho Jun 17 '13 at 22:43
1

Since libpng it's written in C ( ANSI C, even better ) you can build a bridge between that library and your C# application -> Use a C library from C# code

There are also other options, such as freeimage and the port of ImageMagick to .net but in this case it's still unclear to me what kind of project is this one, I don't get if it's official or not, if it's already dead or alive, if you are interested you can search for that name.

In simple terms PNG it's a open standard where JPEG it's a world full of patents and royalties, for this reason some libraries do not offer jpeg features or they offer a limited set of jpeg related features/algorithms. PNG it's also a real imaging standard about a file format definition, jpeg it's more like a container.

Community
  • 1
  • 1
user2485710
  • 9,451
  • 13
  • 58
  • 102
  • Thank you for your reply.I look up for the method that i can compress png file.what's your suggestion? –  Jun 17 '13 at 22:26
  • 1
    JPEG isn't a "world full of patents and royalties". You might be confusing JPEG with JPEG2000. – Glenn Maynard May 05 '14 at 22:20