By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

Image resize with Smoothing (anti alias)

P: n/a
Jay
Hi guys, trying to fix a problem with an image resize routine. The code
posted below uploads and resizes a jpeg, probablem is, the outlook can look
a bit bitty becuase of teh samller size...is there a way I can anti alias /
smooth the resized image before saving?
If myThumb.ContentLength > 0 Then
Dim myThumbData(myThumb.ContentLength) As Byte

myThumb.InputStream.Read(myThumbData, 0, myThumb.ContentLength)

Dim FileStream As New System.IO.FileStream(strTempSavePath &
"rawupload-thumb.jpg", IO.FileMode.Create)

FileStream.Write(myThumbData, 0, myThumb.ContentLength)

FileStream.Close()

' Create New image and bitmap objects. Load the image file and put into a
resized bitmap.

Dim g As System.Drawing.Image =
System.Drawing.Image.FromFile(strTempSavePath & "rawupload-thumb.jpg")

Dim thisFormat = g.RawFormat

Dim intThumbSize As New Size

intThumbSize = NewImageSize(g.Width, g.Height, 90, 90)

' Create bimap in memory to manipulate image.

Dim imgOutput As New Bitmap(g, intThumbSize.Width, intThumbSize.Height)

Response.ContentType = "image/jpeg"

' Resize done, now save the file back to the temp directory.

imgOutput.Save(strTempSavePath & "upload-thumb.jpg", thisFormat)

' Tidy up the objects

g.Dispose()

imgOutput.Dispose()

' Set URL for uploaded image to be previwed on page where this control is
included.

imgThumb.ImageUrl = "/catalogue/images/tmp/upload-thumb.jpg"

imgThumb.Visible = True

End If
Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.