Friday, March 06, 2009

prelude to a screen cap

<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%
' Declare Vars
Dim objBMP As System.Drawing.Bitmap
Dim objGraphics As System.Drawing.Graphics
Dim objFont As System.Drawing.Font

' Create new image - bitmap
objBMP = New Bitmap(100, 30)

' Create a graphics object to work with from the BMP
objGraphics = System.Drawing.Graphics.FromImage(objBMP)

' Fill the image with background color
objGraphics.Clear(Color.Green)

' Set anti-aliasing for text to make it better looking
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias

' Configure font to use for text
objFont = New Font("Arial", 16, FontStyle.Bold)

' Write out the text
objGraphics.DrawString("ASP 101", objFont, Brushes.White, 3, 3)


' Set the content type and return the image
Response.ContentType = "image/GIF"
objBMP.Save(Response.OutputStream, ImageFormat.Gif)

' Kill our objects
objFont.Dispose()
objGraphics.Dispose()
objBMP.Dispose()
%>



as c#

<%@ Page Language="C#" AutoEventWireup="true"  %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%
//' Declare Vars
System.Drawing.Bitmap objBMP;
System.Drawing.Graphics objGraphics;
System.Drawing.Font objFont;

//' Create new image - bitmap
objBMP = new Bitmap(100, 30);

//' Create a graphics object to work with from the BMP
objGraphics = System.Drawing.Graphics.FromImage(objBMP);

//' Fill the image with background color
objGraphics.Clear(Color.Green);

//' Set anti-aliasing for text to make it better looking
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;

//' Configure font to use for text
objFont = new Font("Arial", 16, FontStyle.Bold);

//' Write out the text
objGraphics.DrawString("ASP C#", objFont, Brushes.White, 3, 3);


//' Set the content type and return the image
Response.ContentType = "image/GIF";
objBMP.Save(Response.OutputStream, ImageFormat.Gif);

//' Kill our objects
objFont.Dispose();
objGraphics.Dispose();
objBMP.Dispose();
%>


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?