Click here to Skip to main content
15,886,258 members
Articles / Web Development / ASP.NET
Article

Text2Image

Rate me:
Please Sign up or sign in to vote.
1.42/5 (11 votes)
1 Apr 20032 min read 65.3K   1.2K   37   5
An ASP.NET example in VB.NET that converts text to an image.

Introduction

This project illustrates one of powerful graphics features offered by .NET. It demonstrates how a string, whether ASCII or Unicode, can be converted to an Image. For example, for reasons of security, certain sites use this technique in their registration system, so as to make the user type a randomly selected string of characters that is displayed in an image into a confirmation textbox. To build this project, I've used ASP.NET with VB.NET. Also all the object names declared and GUI strings are in Hindi. This is to demonstrate the Unicode capability of .NET. Objects like Graphics are declared in Hindi! The project is saved as type Unicode.

Background

If you've been working on globalization of your projects to make them world ready then this project is easy to understand. If you've designed older ASP sites that are multilingual, then this Text2Image project would be an extension to it. However, an important aspect to be noticed is the flexibility that VS.NET offers in terms of declaring names to classes and objects. But of course, typing in English is easier compared to Hindi.

Using the Code

Since this project uses ASP.NET, I assume that you have Visual Studio .NET installed on your system, or at least have the .NET Framework installed with IIS setup to run .aspx files. Unzip the given ZIP file into a new directory on your disk and create a virtual directory name in your IIS, and map it to the new directory. I've used the "Arial MS Unicode", version 1.00, font to get the Hindi (devnagari) characters from the Windows Character Map. Any font version older than that won't work.

This project uses System.Drawing, System.Drawing.Graphics and System.IO Namespaces. Bitmap, Graphics, Color, Font and Brush are used primarily.

Points of Interest

There's one interesting aspect that I learnt during the development of Text2Image. Try pressing the help key after placing the cursor on the Graphics or Bitmap objects declared in Hindi. I expected the help to do nothing fancy, but it took me straight to the definition of the object. I learned that the help system does not consider the keyword, but the context of the underlying object.

As mentioned previously, the font used to build Text2Image was "Arial Unicode MS Ver 1.00". The app won't work if the version of the font is anything below that. The project works well on a windows XP machine with office XP installed (since the latest version of the font is already present). Also the code that I've written is for single machine running IIS with .NET Framework installed and not for intranet users (for which the code needs to be modified slightly).

Distribution

Feel free to take the code and reuse it or modify and make it better.

Thank you,
Vijay Kanth
Wipro Technologies, Bangalore.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
Over 8 years of IT Experience. I've been using Microsoft Technologies for almost that long. With ASP and VB Background, I've strengthened my skillset with .NET, especially ASP.NET and VB.NET. I also have a passion for XML and XSLT. Have designed quite a few sites for MNC's.

Comments and Discussions

 
GeneralUnusable Pin
Henrique Cruz1-Dec-07 12:16
Henrique Cruz1-Dec-07 12:16 
GeneralReadability low... Pin
gmagana4-Apr-03 13:02
gmagana4-Apr-03 13:02 
GeneralRe: Readability low... Pin
Vijay Kanth6-Apr-03 17:45
Vijay Kanth6-Apr-03 17:45 
GeneralRe: Readability low... Pin
Mike Whitenton22-Jul-03 21:59
Mike Whitenton22-Jul-03 21:59 
GeneralRe: Readability low... Pin
YardenST18-May-04 9:26
YardenST18-May-04 9:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.