Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Drawing.Imaging
Imports System.IO

Namespace PlexityHide.GTP.WEB
	''' <summary>
	''' Summary description for GTPImg.
	''' </summary>
	Public Class GTPImg : Inherits System.Web.UI.Page
		Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
		  Dim filename As String=Request.QueryString.Get("filename")

	  Dim ms2 As MemoryStream=CType(Page.Cache.Get(filename), MemoryStream)
	  If Not ms2 Is Nothing Then
		Response.ContentType="image/png"
		ms2.WriteTo(Response.OutputStream)
	  Else
		' this is the normal case in design time
		Dim b As System.Drawing.Image=Nothing
		If System.IO.File.Exists(filename) Then
		  b=System.Drawing.Image.FromFile(filename)

		  Try
			Response.ContentType="image/png"
			Dim ms As MemoryStream = New MemoryStream()
			b.Save(ms,ImageFormat.Png)
			ms.WriteTo(Response.OutputStream)

			'b.Save(Response.OutputStream,ImageFormat.Jpeg);
			b.Dispose()
			System.IO.File.Delete(filename)
		  Catch ee As Exception
			If ee.Message<>"" Then
			End If
		  End Try
		End If

	  End If
		End Sub

		#Region "Web Form Designer generated code"
		Overrides Protected Sub OnInit(ByVal e As EventArgs)
			'
			' CODEGEN: This call is required by the ASP.NET Web Form Designer.
			'
			InitializeComponent()
			MyBase.OnInit(e)
		End Sub

		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()
'	  Me.Load += New System.EventHandler(Me.Page_Load);

		End Sub
		#End Region
	End Class
End Namespace
