|
<%@ WebHandler Language="VB" Class="ScribbleImage" %>
Imports System
Imports System.Web
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Public Class ScribbleImage : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "image/png"
context.Response.Cache.SetNoStore()
context.Response.Cache.SetCacheability(HttpCacheability.NoCache)
context.Response.Cache.SetExpires(DateTime.Now)
context.Response.Cache.SetValidUntilExpires(False)
Dim bmp As Bitmap = CType(context.Session.Item("Image"), Bitmap)
SyncLock (bmp)
Using ms As MemoryStream = New MemoryStream()
bmp.Save(ms, ImageFormat.Png)
ms.Flush()
context.Response.BinaryWrite(ms.GetBuffer())
End Using
End SyncLock
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.