I need to write this sample code so that the resulting image is the exact same as the original.
Dim a = New Bitmap( _
My.Application.Info.DirectoryPath & "\a.png")
Dim b As New Bitmap(a.Width, a.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb )
Dim g As Graphics = Graphics.FromImage(b)
g.DrawImage(a, b.GetBounds(GraphicsUnit.Pixel))
PictureBox1.Image = b
b.Save("b.png", System.Drawing.Imaging.ImageFormat.Png)
g.Dispose()
I don't understand what happens when I convert an image to graphics. Image.FromFile preserves all of the picture data, but graphics changes the picture size so that g.DrawImage(a, 0, 0) would be a larger picture, but cropped to the original's size. Graphics.FromImage resizes the picture and so some quality is lost.
Can this be rewritten so that the result is the same as the original (no resizing/loss of quality)?