Response.Clear()
Response.ContentType = "image/jpg"
Dim imgBytes As Byte() = CType(Cache("ImageBytes"), Byte())
If imgBytes Is Nothing Then
Using img As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("TestImage.jpg"))
Dim ms As IO.MemoryStream = New IO.MemoryStream()
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
ms.Close()
imgBytes = ms.GetBuffer()
Cache("ImageBytes") = imgBytes
End Using
Response.OutputStream.Write(imgBytes, 0, imgBytes.Length)
Response.Flush()
Response.End()
No comments:
Post a Comment