Viewing source for Recipe2205vb.aspx

<%@ Page language="vb" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script runat="server">
Public Sub Page_Load(sender as object, e as System.EventArgs )
	' Initialize variables.
	Dim boxWidth As Integer = 100
	Dim boxHeight As Integer = 100
	Dim scale As Double = 0

	' Set the filename.
	Dim fileName As String
	fileName = Server.MapPath("aspalliance_logo.gif")

	
	' create a new bitmap image
	Dim InputBitmap As Bitmap = New Bitmap(fileName)
	
	
	' work out new sizes
	If(InputBitmap.Height < InputBitmap.Width) Then
		scale = (boxHeight)/InputBitmap.Width
	Else
		scale = (boxWidth)/InputBitmap.Height
	End If
		
	' Set new width and height.
	Dim newWidth As Integer = CInt(scale*InputBitmap.Width)
	Dim newHeight As Integer = CInt(scale*InputBitmap.Height)

	' create a new image from original
	Dim OutputBitmap As Bitmap = New Bitmap(InputBitmap, newWidth, newHeight)

	' set the mime type
	Response.Clear()
	Response.ContentType="image/Gif"

	' send the image to the viewer
	OutputBitmap.Save(Response.OutputStream, ImageFormat.Gif)

	' clean up
	OutputBitmap.Dispose()
	InputBitmap.Dispose()
End Sub
</script>