Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resizing an image file
I have a BMP file on disk which I need to load, resize to a fixed size
(by maintaining the aspect ratio), and then save it under a different name. I need to use VB.NET. I have tried several different things by using StretchBlt but it is not working. Does anyone have any sample code which does this? Thanks in advance. Giulio. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resizing an image file
Hi Giulio,
Thanks for posting in the community. First of all, I would like to confirm my understanding of your issue. From your description, I understand that you wants to resize an bitmap and keep the aspect ratio. Have I fully understood you? If there is anything I misunderstood, please feel free to let me know. Here is a sample, you may take a look. Private Sub btnScale_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnScale.Click ' Get the scale factor. Dim scale_factor As Single = Single.Parse(txtScale.Text) ' Get the source bitmap. Dim bm_source As New Bitmap(picSource.Image) ' Make a bitmap for the result. Dim bm_dest As New Bitmap( _ CInt(bm_source.Width * scale_factor), _ CInt(bm_source.Height * scale_factor)) ' Make a Graphics object for the result Bitmap. Dim gr_dest As Graphics = Graphics.FromImage(bm_dest) ' Copy the source image into the destination bitmap. gr_dest.DrawImage(bm_source, 0, 0, _ bm_dest.Width + 1, _ bm_dest.Height + 1) ' Display the result. picDest.Image = bm_dest End Sub You may try the code and let me know the result. Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resizing an image file
Hi Giulio,
Thanks for posting in the community. Did my reply about resize an bmp in vb.net help you? If you have any concern on this issue,please post here. Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resizing an image file
Guys,
Thank you very much for your help. Got it working now... Giulio. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Resizing File>Open box | Excel Discussion (Misc queries) | |||
Image Resizing and Shifting Excel 2007 | Excel Discussion (Misc queries) | |||
Resizing cells in a selection without resizing entire sheet | Excel Discussion (Misc queries) | |||
Image resizing DLL | Excel Programming | |||
resizing an image on a form | Excel Programming |