I need to make a copy of an PNG image on my disk. In fact I need more complicated think, but this is a part of it. So,
I'm doing this:
Bitmap oldbmp = new Bitmap( filename );
Bitmap newbmp = new Bitmap(oldbmp.Size.Width, oldbmp.Size.Height, oldbmp.PixelFormat);
// if I don't do this, destination image looks bigger and clipped
newbmp1.SetResolution(oldbmp.HorizontalResolution, oldbmp.VerticalResolution);
Graphics graphics = Graphics.FromImage(newbmp);
graphics.DrawImageUnscaled(oldbmp,0,0);
newbmp.Save( filename2 );
What I have is the second file has different filesize (sometimes more, sometimes less then the first one).
I guess something wrong with encoding, but cannot understand what exactly. What must I change or add?
P.S. Bitmap.Clone( ... ) doesn't do what I need.
Update:
Ok, my actual task is:
Cut file to several smaller parts.
Save parts to disk.
Read parts from disk.
Assemble parts back to full image.
Save full image to disk.
First file is PNG, last file is PNG, they must be of equall size if parts haven't been changed.
Different size matters, because some files a really large and difference can be more than 2 MBs!
UPDATE2:
The first image. After executing the code the size of file grows.