GDI+ Resizing image problem

J

James A Taber

Problem resizing image.(JPG)

If i try to resize an img with horisontal=150 and vertical resolution=150
The quality of the target image is dramatically reduced. Source code is
provided below.

How can i solve this? What am i doing wrong?

Thanx in advance
-James A Taber

Public Sub ResizeImage(ByVal sSourcePath As String, ByVal sTargetPath As
String)
Dim fs As FileStream
Dim gImageIn As Image
Dim gImageInFormat As Object

Try
fs = New FileStream(sSourcePath, FileMode.Open, FileAccess.Read)
gImageIn = Image.FromStream(fs)

gImageInFormat = gImageIn.RawFormat
Dim gImageOut As New System.Drawing.Bitmap(gImageIn, 350, 262)

gImageOut.Save(sTargetPath, gImageInFormat)

Catch
Throw
Finally
fs.Close()
gImageIn.Dispose()
End Try

End Sub
 
N

Natty Gur

Hi,

use :
oGrapic.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear
oGrapic.DrawImage(oBmp, New Rectangle(0, 0, oTxtBmp.Width,
oTxtBmp.Height), _
0, _
0, _
oBmp.Width, _
oBmp.Height, _
GraphicsUnit.Pixel)

you can also refer to this sample[1] that create dynamic buttons by the
button text length.

[1] http://www.developersdex.com/gurus/code/599.asp

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
J

James A Taber

I have tried to figue it out ... But have until now not been able to do
that. Could you provide me some sample code?

I would be greatful for any help.

Thanx

James A Taber
 
J

James A Taber

Tank you, This is absolutely perfect!
Thanks for all you help and time.

:)
James A Taber
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top