Well so far so good. now we have to do the actual GDI+ stuff. Jumping right in:
- Create a new page (whatever you called in the previous page in the img tag)
- If you use Visual Studio, delete everything except the
<%@ Page ... %>
directive in theimg_gen.aspx
page - It the
Page_Load
procedure add the following:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'# Get the word to be displayed
Dim m_sWord as String
m_sWord = Request("w")
'# Create and initialize the color variables (can be anything you like)
'# I use two colors to create a gradient.
Dim FontColor1 As System.Drawing.Color = Color.SlateGray
Dim FontColor2 As System.Drawing.Color = Color.Blue
'# Create and initialize the background colors same as the fonts
'# If you create the function as I have, to get a solid color, just make color1 the same as color2
Dim BackColor1 As System.Drawing.Color = Color.Transparent
Dim BackColor2 As System.Drawing.Color = Color.Red
'# Declare the font variables
Dim FontSize As Integer = 24
Dim FontName As String = "Arial" '# Can be any font installed on the machine
'# Create the rectangle you want to draw to and init the coordinates
'# For this tutorial, we're going to draw a 200x50 image
Dim m_Rect As System.Drawing.Rectangle
m_Rect.X = 0
m_Rect.Y = 0
m_Rect.Width = 200
m_Rect.Height = 50
'# Call the drawing function
DrawTextToScreen(m_Point, m_sWord, FontName, FontSize, FontColor1, FontColor2, _
BackColor1, BackColor2)
End Sub
Now here comes the interesting bit, the actual drawing...
Comments