![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a GIF which its dimensions is 200x300 pixels and it is animating fine. But after i resize it to smaller dimensions (133x200 pixels), it doesn't animate anymore. Why is it not animating ? Thanks. |
#3
| |||
| |||
|
|
"Fong Lun" wrote: I have a GIF which its dimensions is 200x300 pixels and it is animating fine. But after i resize it to smaller dimensions (133x200 pixels), it doesn't animate anymore. Why is it not animating ? Thanks. I am doing this in ASP.NET to display any images (including png, jpg, gif...) in a <img> tag in a web page. I have put a size limit to the container to display the image (gif for this example). This is how i decide whether to resize the gif in my code. 1. The gif is in a table in SQL Server 2005 with image data type. 2. I retrieve the gif from the table using SELECT statement. 3. Below is my codes Dim b() As Byte = data(0) 'data(0) is the image which is retrieved from a SELECT statement Dim img As New Bitmap(New MemoryStream(b)) Dim imgformat As System.Drawing.Imaging.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif 'the original gif dimensions is 200x300pixels Dim h As Integer = img.Height Dim w As Integer = img.Width If h > 200 or w > 200 Then If h > w Then w = (200 / h) * w h = 200 Else h = (200 / w) * h w = 200 End If End If Dim bmp As New Bitmap(w, h) Dim gph As Graphics = Graphics.FromImage(bmp) gph.InterpolationMode = Drawing2D.InterpolationMode.High gph.DrawImage(img, 0, 0, w, h) Dim ms As New MemoryStream Dim picdata() As Byte bmp.Save(ms, imgformat) picdata = ms.GetBuffer gph.Dispose() bmp.Dispose() Response.Clear() Response.ClearHeaders() Response.ContentType = "image/gif" Response.BinaryWrite(picdata) |
#4
| |||
| |||
|
| "Fong Lun" wrote: I have a GIF which its dimensions is 200x300 pixels and it is animating fine. But after i resize it to smaller dimensions (133x200 pixels), it doesn't animate anymore. Why is it not animating ? Thanks. I am doing this in ASP.NET to display any images (including png, jpg, gif...) in a <img> tag in a web page. I have put a size limit to the container to display the image (gif for this example). This is how i decide whether to resize the gif in my code. 1. The gif is in a table in SQL Server 2005 with image data type. 2. I retrieve the gif from the table using SELECT statement. 3. Below is my codes Dim b() As Byte = data(0) 'data(0) is the image which is retrieved from a SELECT statement Dim img As New Bitmap(New MemoryStream(b)) Dim imgformat As System.Drawing.Imaging.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif 'the original gif dimensions is 200x300pixels Dim h As Integer = img.Height Dim w As Integer = img.Width If h > 200 or w > 200 Then If h > w Then w = (200 / h) * w h = 200 Else h = (200 / w) * h w = 200 End If End If Dim bmp As New Bitmap(w, h) Dim gph As Graphics = Graphics.FromImage(bmp) gph.InterpolationMode = Drawing2D.InterpolationMode.High gph.DrawImage(img, 0, 0, w, h) Dim ms As New MemoryStream Dim picdata() As Byte bmp.Save(ms, imgformat) picdata = ms.GetBuffer gph.Dispose() bmp.Dispose() Response.Clear() Response.ClearHeaders() Response.ContentType = "image/gif" Response.BinaryWrite(picdata) |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |