VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Resize a bitmap high resolution Posted by chrldmp on 1 Feb 2013 at 2:43 AM
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
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,
Charlie



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.