Resize a bitmap high resolution - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Resize a bitmap high resolution

chrldmpchrldmp Posts: 2Member
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)
Return bm_dest
End Function[/color]


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,
Charlie
Sign In or Register to comment.