i have reduce the image by passing two parameter to this function
but it shows : parameter is not valid.
Public Shared Function ResizeImage_default(ByVal imageFile() As Byte, ByVal targetSize As Integer) As Byte()
Using oldImage As System.Drawing.Image = System.Drawing.Image.FromStream(New MemoryStream(imageFile)) ---
ERR:Throw Exception in thisLine
Dim newSize As Size = CalculateDimensions(oldImage.Size, targetSize)
newSize.Height = 777
newSize.Width = 574
Using newImage As Bitmap = New Bitmap(newSize.Width, newSize.Height, PixelFormat.Format24bppRgb)
Using canvas As Graphics = Graphics.FromImage(newImage)
canvas.SmoothingMode = SmoothingMode.HighQuality
canvas.InterpolationMode = InterpolationMode.HighQualityBicubic
canvas.PixelOffsetMode = PixelOffsetMode.HighQuality
canvas.DrawImage(oldImage, New Rectangle(New Point(0, 0), newSize))
Dim m As New MemoryStream
newImage.Save(m, ImageFormat.Jpeg)
Return m.GetBuffer
End Using
End Using
End Using
End Function
venkatu2005
All-Star
32487 Points
6742 Posts
I have err in this thumbnail function ...?
Sep 13, 2008 07:12 AM|LINK
Hi
i have reduce the image by passing two parameter to this function
but it shows : parameter is not valid.
Public Shared Function ResizeImage_default(ByVal imageFile() As Byte, ByVal targetSize As Integer) As Byte()
Using oldImage As System.Drawing.Image = System.Drawing.Image.FromStream(New MemoryStream(imageFile)) --- ERR:Throw Exception in thisLine
Dim newSize As Size = CalculateDimensions(oldImage.Size, targetSize)
newSize.Height = 777
newSize.Width = 574
Using newImage As Bitmap = New Bitmap(newSize.Width, newSize.Height, PixelFormat.Format24bppRgb)
Using canvas As Graphics = Graphics.FromImage(newImage)
canvas.SmoothingMode = SmoothingMode.HighQuality
canvas.InterpolationMode = InterpolationMode.HighQualityBicubic
canvas.PixelOffsetMode = PixelOffsetMode.HighQuality
canvas.DrawImage(oldImage, New Rectangle(New Point(0, 0), newSize))
Dim m As New MemoryStream
newImage.Save(m, ImageFormat.Jpeg)
Return m.GetBuffer
End Using
End Using
End Using
End Function
Let me know the reason ?
can anyone give solution for this..?
Thanks.
Coool
Contributor
4393 Points
687 Posts
Re: I have err in this thumbnail function ...?
Sep 13, 2008 10:15 AM|LINK
http://www.glennjones.net/Post/799/Highqualitydynamicallyresizedimageswithnet.htm
Parth Patel
Software Engineer
venkatu2005
All-Star
32487 Points
6742 Posts
Re: I have err in this thumbnail function ...?
Sep 18, 2008 05:31 AM|LINK
Hi
Anyone tell what's the error in the above function..
or else let anyone give the code for resize the image in vb.net ,
here i have passed the byte array...
Thanks.