GetThumbnailImage Question

R

rhungund

Hi all. I'm using a simple thumbnail generating script in VB.NET/GDI.
It uses the GetThumbnailImage method.

It works great when resizing gifs. But when I resize a jpeg the
quality looks terrible. Here's a code snippet. Thanks.


Dim fullSizeImg as System.Drawing.Image
fullSizeImg =
System.Drawing.Image.FromFile(Server.MapPath(imageUrl))
width = fullSizeImg.width
height = fullSizeImg.height
imageHeight = height * (imageWidth/width)

'Do we need to create a thumbnail?
Response.ContentType = "image/jpeg"
If imageHeight > 0 and imageWidth > 0 then
Dim dummyCallBack as System.Drawing.Image.GetThumbNailImageAbort
dummyCallBack = New _
System.Drawing.Image.GetThumbnailImageAbort(AddressOf
ThumbnailCallback)

Dim thumbNailImg as System.Drawing.Image
thumbNailImg = fullSizeImg.GetThumbnailImage(imageWidth,
imageHeight, _
dummyCallBack,
IntPtr.Zero)

thumbNailImg.Save(Response.OutputStream, ImageFormat.jpeg)
Else
fullSizeImg.Save(Response.OutputStream, ImageFormat.jpeg)
End If
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top