Png compression

F

Franz

I want to ask about the png compression for Bitmap.Save
Here are the case :

Jpg (768 x 576 , 301KB) => Jpg (384 x 288, 22KB)
Jpg (768 x 576 , 301KB) => Png (384 x 288, 311KB)

Is the compression of png worst than that of jpg?

Here are the code :

Image image = Bitmap.FromFile(filePath);

int newWidth = (int)(percentage * image.Width);
int newHeight = (int)(percentage * image.Height);

Rectangle rectDest = new Rectangle(0, 0, newWidth, newHeight);
Bitmap bitmap = new Bitmap(rectDest.Width, rectDest.Height);
Graphics g = Graphics.FromImage(bitmap);
g.DrawImage(image, rectDest, 0, 0, image.Width, image.Height,
GraphicsUnit.Pixel);
image.Dispose();

bitmap.Save(filePath, format);
bitmap.Dispose();
 
D

Daniel O'Connell [C# MVP]

If memory serves, png is a lossless compression model. Because its lossless
it will almost always result in files that are larger than the equivilent
jpeg, which is a lossy compression system(that is, it throws data you don't
need away).

So, the compression is different and each format has a different purpose. If
you are looking into lossless compression for images go with png, if you are
looking for best quality\size ratio, jpeg will probably do you well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top