Connecting Tech Pros Worldwide Forums | Help | Site Map

Resize an Image and saving it to Disk

Gustavo De la Espriella
Guest
 
Posts: n/a
#1: Nov 19 '05
Hi,
I'm having trouble resizing images while mantaining resolution.
I used the following code to save a jpeg file to disk, but with the
GetThumbImage it loses resolution.
----------------------------------------------
MyImage = System.Drawing.Image.FromFile(Request.PhysicalAppl icationPath &
"images\TempExterno.jpg")
MyImage.GetThumbnailImage(600, (MyImage.Size.Height * (600 /
MyImage.Size.Width)), myCallback,
IntPtr.Zero).Save(Request.PhysicalApplicationPath & "images\" &
strIDProducto & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
----------------------------------------------
How can I create a file from another picture file with a different size
(mantaining a decent quality)?

Thanks;

Gustavo Antonio De la Espriella



Herfried K. Wagner
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Resize an Image and saving it to Disk


Hello,

"Gustavo De la Espriella" <qq@qqq.qq.qq> schrieb:[color=blue]
> How can I create a file from another picture file with a
> different size (mantaining a decent quality)?[/color]

\\\
Dim bmp As New Bitmap( _
"C:\Lagoon1024x768.bmp" _
)
Dim bmp2 As New Bitmap( _
bmp.Width * 0.1, _
bmp.Height * 0.1, _
Imaging.PixelFormat.Format24bppRgb _
)
Dim g As Graphics = Graphics.FromImage(bmp2)

' Select/change interpolation mode here.
g.InterpolationMode = _
Drawing.Drawing2D.InterpolationMode.HighQualityBic ubic

' Draw image using specified interpolation mode.
g.DrawImage(bmp, 0, 0, bmp2.Width, bmp2.Height)
Me.PictureBox1.Image = bmp2
bmp2.Save("C:\foo.bmp")
///

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


NNM.RU
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Resize an Image and saving it to Disk


Use PNG files, they are in a way compressed BMPs. They give same quality at
a much smaller size.


).Save(Request.PhysicalApplicationPath & "images\" &
strIDProducto & ".png", System.Drawing.Imaging.ImageFormat.PNG)




"Herfried K. Wagner" <aon.912666908.N.O.S.P.@.M.aon.at> wrote in message
news:e$g46dmRDHA.2084@TK2MSFTNGP11.phx.gbl...[color=blue]
> Hello,
>
> "Gustavo De la Espriella" <qq@qqq.qq.qq> schrieb:[color=green]
> > How can I create a file from another picture file with a
> > different size (mantaining a decent quality)?[/color]
>
> \\\
> Dim bmp As New Bitmap( _
> "C:\Lagoon1024x768.bmp" _
> )
> Dim bmp2 As New Bitmap( _
> bmp.Width * 0.1, _
> bmp.Height * 0.1, _
> Imaging.PixelFormat.Format24bppRgb _
> )
> Dim g As Graphics = Graphics.FromImage(bmp2)
>
> ' Select/change interpolation mode here.
> g.InterpolationMode = _
> Drawing.Drawing2D.InterpolationMode.HighQualityBic ubic
>
> ' Draw image using specified interpolation mode.
> g.DrawImage(bmp, 0, 0, bmp2.Width, bmp2.Height)
> Me.PictureBox1.Image = bmp2
> bmp2.Save("C:\foo.bmp")
> ///
>
> Regards,
> Herfried K. Wagner
> --
> MVP · VB Classic, VB .NET
> http://www.mvps.org/dotnet
>
>[/color]


Closed Thread