PC Review


Reply
Thread Tools Rate Thread

C# method need for converting text to graphics

 
 
Stratum
Guest
Posts: n/a
 
      13th Dec 2007
I'm looking for some method, possibly in a .Net class that I don't
about, for converting a text image to an image file in GIF or
JPEG format. The application is a form (could be a Web form
or a Windows form on an Internet-connected computer) where
the user types the contents of a randomly generated string
which is displayed in the form of an image.

You would encounter such a form, for instance, when
registering a software product, or submitting some kind
of information on a form that you don't want submitted
by an automated mass mailer... in other words, a spammer.
The string on the image must be manually typed
in order to submit the form.

Generating the string is no problem. Rasterizing it to
an image is the big deal.

Anyone know of a method, preferably in C#?

 
Reply With Quote
 
 
 
 
Chris Mullins [MVP - C#]
Guest
Posts: n/a
 
      13th Dec 2007
It's called "DrawString".

http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.drawstring(VS.71).aspx

--
Chris Mullins


"Stratum" <(E-Mail Removed)> wrote in message
news:b91da067-3520-41af-b354-(E-Mail Removed)...
> I'm looking for some method, possibly in a .Net class that I don't
> about, for converting a text image to an image file in GIF or
> JPEG format. The application is a form (could be a Web form
> or a Windows form on an Internet-connected computer) where
> the user types the contents of a randomly generated string
> which is displayed in the form of an image.
>
> You would encounter such a form, for instance, when
> registering a software product, or submitting some kind
> of information on a form that you don't want submitted
> by an automated mass mailer... in other words, a spammer.
> The string on the image must be manually typed
> in order to submit the form.
>
> Generating the string is no problem. Rasterizing it to
> an image is the big deal.
>
> Anyone know of a method, preferably in C#?
>



 
Reply With Quote
 
 
 
 
Peter Duniho
Guest
Posts: n/a
 
      13th Dec 2007
On Wed, 12 Dec 2007 16:23:57 -0800, Stratum <(E-Mail Removed)> wrote:

> I'm looking for some method, possibly in a .Net class that I don't
> about, for converting a text image to an image file in GIF or
> JPEG format. The application is a form (could be a Web form
> or a Windows form on an Internet-connected computer) where
> the user types the contents of a randomly generated string
> which is displayed in the form of an image.
>
> [...]
> Generating the string is no problem. Rasterizing it to
> an image is the big deal.
>
> Anyone know of a method, preferably in C#?


Do you want a captcha? Or just a bitmap with some text? If the latter,
it's not hard at all in .NET. Just create a Bitmap instance the size you
want, use Graphics.FromImage() to get a Graphics instance that will draw
into the Bitmap, and call Graphics.DrawString() to draw the text
graphically into your Bitmap instance. Finally, use the Image.Save()
method on the Bitmap instance to save the image out in whatever format you
want (but if you're using this for an online application, it may be that
you can just send the Bitmap back to the client directly without saving it
to a file).

If you want a captcha, you need to do all of the above, plus whatever
obfuscation of the text you want. I recommend Google for learning more
about specific captcha implementations. I'm not aware of any .NET support
for that specifically.

Pete
 
Reply With Quote
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      13th Dec 2007
As Peter D. indicated, it sounds like you are looking for a CAPTCHA control.
If you search on "ASP.NET CAPTCHA CONTROL" you'll find plenty of sample code.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"Stratum" wrote:

> I'm looking for some method, possibly in a .Net class that I don't
> about, for converting a text image to an image file in GIF or
> JPEG format. The application is a form (could be a Web form
> or a Windows form on an Internet-connected computer) where
> the user types the contents of a randomly generated string
> which is displayed in the form of an image.
>
> You would encounter such a form, for instance, when
> registering a software product, or submitting some kind
> of information on a form that you don't want submitted
> by an automated mass mailer... in other words, a spammer.
> The string on the image must be manually typed
> in order to submit the form.
>
> Generating the string is no problem. Rasterizing it to
> an image is the big deal.
>
> Anyone know of a method, preferably in C#?
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting a date to a text field w/o converting it to a julian da LynnMinn Microsoft Excel Worksheet Functions 2 6th Mar 2008 04:43 PM
Graphics.FillRectangle vs Graphics.FillPath speed Mark Ingram Microsoft C# .NET 2 23rd May 2006 03:13 PM
What's better? Graphics.FromHwnd or Graphics.FromHdc Benny Raymond Microsoft C# .NET 1 2nd Dec 2005 04:30 PM
User defined Graphics in PowerPoint Graphics module Doris Edwards Microsoft Powerpoint 2 22nd Sep 2003 11:28 PM
Graphics in IE only appearing as an "X in a blank box -- NO graphics" Craig E Windows XP Internet Explorer 0 1st Jul 2003 02:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:51 AM.