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 4 3253
ahh...I have a method at work to create quality thumbnails, but I am at
home...
here is a discussion to help you get started...it's where i did... http://www.dotnet247.com/247referenc...25/128742.aspx
"James A Taber" <ic*******@hotmail.com> wrote in message
news:eB**************@tk2msftngp13.phx.gbl... 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
Hi,
use :
oGrapic.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.HighQua lityBilinear
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
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
"PJ" <pj*********@hotmail.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl... ahh...I have a method at work to create quality thumbnails, but I am at home...
here is a discussion to help you get started...it's where i did... http://www.dotnet247.com/247referenc...25/128742.aspx
"James A Taber" <ic*******@hotmail.com> wrote in message news:eB**************@tk2msftngp13.phx.gbl... 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
Tank you, This is absolutely perfect!
Thanks for all you help and time.
:-)
James A Taber
"PJ" <pj***@hotmail.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl... here's a method i use...sorry it's VB...i'm forced to code in this god
awful syntax right now...
Private Shared Function ScaleFile(ByVal img As Image, ByVal newSize As
Size) As Byte()
Dim newImg As Image = New Bitmap(newSize.Width, newSize.Height, img.PixelFormat) Dim graphic As Graphics = Graphics.FromImage(newImg) graphic.CompositingQuality() = Drawing.Drawing2D.CompositingQuality.HighQuality graphic.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality graphic.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBic ubic Dim rect As New Rectangle(0, 0, newSize.Width, newSize.Height) graphic.DrawImage(img, rect) Dim ms As New MemoryStream() newImg.Save(ms, img.RawFormat) Dim bytes As Byte() = ms.ToArray() ms.Close() Return bytes
End Function
"James A Taber" <ic*******@hotmail.com> wrote in message news:uE**************@TK2MSFTNGP11.phx.gbl... 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 "PJ" <pj*********@hotmail.com> wrote in message news:O3**************@TK2MSFTNGP10.phx.gbl... ahh...I have a method at work to create quality thumbnails, but I am
at home...
here is a discussion to help you get started...it's where i did... http://www.dotnet247.com/247referenc...25/128742.aspx
"James A Taber" <ic*******@hotmail.com> wrote in message news:eB**************@tk2msftngp13.phx.gbl... > 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 > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alex Hopson |
last post by:
I'm using the code below to loop through some images and resize each image
twice, once to create a thumbnail and once to create a small image.
The page stops loading around the 38th image out of...
|
by: Michael Kennedy [UB] |
last post by:
Hi Everyone,
I have this multithreaded C# windows forms application which does a lot of
image processing. Occasionally, I get the following error:
A generic error occurred in GDI+....
|
by: anonymous |
last post by:
I'm writing a program that deals extensively with the printer. For the most
part my application runs fine, but occasionally I run into some Exceptions.
The most common exceptions I run into are...
|
by: news |
last post by:
This may be a stupid question, but if I don't ask I'll never know ;)
Ok, here it goes.... I am writing an application that renders an image in
one picturebox and a graph in another.
The image...
|
by: Alphonse Giambrone |
last post by:
I am currently reading 'Programming The Web with Visual Basic .NET' and
have so far found it to be excellent. Downloaded all the code from Apress
and working in chapter 4, I get the error shown...
|
by: Karl Hungus |
last post by:
Im looking for a barebones example of dynamic image creation using GDI+ and
asp.net using c#.
My hosting provider supports asp.net, but I have a fairly basic account and
cannot install any...
|
by: lgbjr |
last post by:
Hello All,
I have some pictureboxes on a VB.NET form that are linked to an AccessDB. If
the user wishes to open or edit an image, I need to save the image in the
picturebox to a temp file, then...
|
by: David Lozzi |
last post by:
Howdy,
I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders!
Now I am making a public function that will take the...
|
by: mishrarajesh44 |
last post by:
hii all,
I am facing a problem currently..
i have a script for image uploading and resizing..
the image uploading takes place properly for every size images..
but, the resizing works for...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |