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.
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.