Question Shrink a bitmpap with high resolution


New member
Feb 1, 2013
Programming Experience
Hi to all,
I have written this code to resize (shrink) a bitmap:

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)
Return bm_dest
Catch ex As Exception
Return bm_source
End Try
End Function

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,
Top Bottom