Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Resize a bitmap high resolution
Hi to all,
I have written this code to resize (shrink) a bitmap:
[color=Blue] Public Function ResizeBitmap(bm_source As Bitmap, scale_factor As Double) As Bitmap
Dim bm_dest As New Bitmap(CInt(bm_source.Width * scale_factor), CInt(bm_source.Height * scale_factor))
Dim g As Graphics = Graphics.FromImage(bm_dest)
g.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1)
Now I do the following:
- Load a bitmap in my code, copy it to clipboard (Clipboard.SetImage(bmp)), paste it in Excel and manually resize it to half the size
- Then in my code use the above function to resize the bitmap to half the size, and then copy it in Excel
As expected, the bitmaps are exactly th same size, so the resizing works fine. But the bitmap that I resized manually in Excel has a much better resolution! How can I get the same resolution through code?
Thanks for your help,