Producing a graphic from Text

G

Guest

Hi,

I am just about to write a registration screen for a web based application.
I have seen and used registration screens that show the user a graphic
containing randon text that they are asked to type in a box below the
graphic. I believe this is to stop automaton's automatically creating
multiple accounts without any human interaction.

From memory I think this method is used when registering for a hotmail
account.

Does anybody know how I can do this, i.e. Produce a graphic from randomly
generated text, in .Net?, and in particular is there any .net code out there
(VB.Net ideally), or component that does this job?


Thanks, Mike.
 
V

V

I don't know if this is what you are looking for, but I would use
either of the two approaches below:

1. Use GDI+ classes, to draw a bitmap based on a text, and then show it
at the runtime.

2. Better yet, I would simply create a small database of images and
store them with their texts, and rotate them randomly for the website.

But if there are libraries or controls which server specifically this
purpose, I am not aware of that.

- Vaibhav
 
G

Guest

Thanks Vaibhav.

The 'small database of images' sounds like a good idea, and it would
probably be good enough.

I wonder if anybody else knows if this is how sites like msn do it, or is
there some cunning code out there that already does the job?


Cheers, Mike.
 
G

GhostInAK

Hello Mike,

The term you are looking for is CAPCHA (what a horrid name).. anyhow, look
it up on google.

-Boo
 
J

Jeffrey Tan[MSFT]

Hi Mike,

Thanks for your post!

The small database images solution is not perfect to achieve the really
random image. While the GDI+ dynamically generated image is more flexible
and it is very simple to implement. You just need to use
Graphics.DrawString method to write out the string to a Graphics object,
and then save it to the Response.OutputStream for displaying.

The article below shows you the full code snippet regarding doing this:
"How to Create Text Image on the fly with ASP.NET"
http://www.codeproject.com/aspnet/createTextImage.asp

The 2 articles below demonstrate more the power of GDI+ for dynamic image
generating:
"Create Snazzy Web Charts and Graphics On the Fly with the .NET Framework"
http://msdn.microsoft.com/msdnmag/issues/02/02/ASPDraw/default.aspx
"ASP.NET Controls to prevent automatic registrations from bots"
http://www.codeproject.com/aspnet/antiauto.asp

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top