The image generator start part 1

Well so far so good. now we have to do the actual GDI+ stuff. Jumping right in:

  1. Create a new page (whatever you called in the previous page in the img tag)
  2. If you use Visual Studio, delete everything except the <%@ Page ... %> directive in the img_gen.aspx page
  3. 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...

You might also like...


About the author

Ruan Meyer

Ruan Meyer Saudi Arabia

erm, what can I say... not much, 'cept that I like music, nwn, dnd, programming (C, C++, C#, VB) etc. and Jack Daniels... ;) oh yes and girls...

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“My definition of an expert in any field is a person who knows enough about what's really going on to be scared.” - P. J. Plauger