Q:

Bitmap PNG save without modifications

I am attempting to load a PNG image into a Bitmap and save it without modifications.
I tried something along these lines:
var png = Bitmap.FromFile("t_02.png");
png.Save("t_02_out.png", ImageFormat.Png);

I also tried:
var png = Bitmap.FromFile("t_02.png");
png.Save("t_02_out.png");

In either case, the original 233kb file procuded a 356kb image. What am I doing wrong?

A:

The image in question is stored with the grey-scale color type. The specification describes:
http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html
A pixel is then be stored as a single byte. .NET saves a PNG file as 32-bit regardless of pixel format.
The closest I got is using AForge grayscale filter and storing, which turns it into a palette storage.
The result is then much closer to the original, but due to the palet it is often still larger.
Conclusion: .NET image format support is terrible. I used ImageMagic to solve .NET incompetence.

