Hi there,
I have some code for an ASP.Net page that produces an image of an e-mail
address to prevent those programs that spider the net for e-mail
addresses on pages grabbing it.
The code is as follows (but on my version it gets the e-mail address
from a database rather than QueryString).
How can I crop the image to the exact size of the text as if the e-mail
address is short there is excess whitespace and if it is long it
over-runs the image.
Any help would be great!
[color=blue]
> // Set Content Type to GIF
> Response.Conten tType = "image/gif";
>
> // Create Image
> const int width = 250, height = 20;
> Bitmap objBitmap = new Bitmap(width, height);
> Graphics objGraphics = Graphics.FromIm age(objBitmap);
> objGraphics.Fil lRectangle(new SolidBrush(Colo r.White), 0, 0, width, height);
>
> // Create Font and String Format
> Font fontDesc = new Font("Verdana", 8, FontStyle.Under line);
> StringFormat stringFormat = new StringFormat();
> stringFormat.Al ignment = StringAlignment .Near;
> stringFormat.Li neAlignment = StringAlignment .Center;
>
> // Draw the String
> objGraphics.Dra wString(Request .QueryString["email"], fontDesc, new SolidBrush(Colo r.Blue), new Rectangle(0, 0, width, height), stringFormat);
>
> // Save the Image to the OutputStream
> objBitmap.Save( Response.Output Stream, ImageFormat.Gif );
>
> // Clean Up
> objGraphics.Dis pose();[/color]
--
Mark (Sparky) Keats
+-+-+-+-+-+-+-+-+-+
e: mark@sparky4646 .co.uk
web: http://www.sparky4646.co.uk
---------------------------------------------------------------------
"Computer games don't affect kids, I mean if Pac Man affected us
as kids, we'd all run around in a darkened room munching pills
and listening to repetitive music..."
- Kristian Wilson, CEO, Nintendo Gaming Corporation, Inc, 1989
---------------------------------------------------------------------
I have some code for an ASP.Net page that produces an image of an e-mail
address to prevent those programs that spider the net for e-mail
addresses on pages grabbing it.
The code is as follows (but on my version it gets the e-mail address
from a database rather than QueryString).
How can I crop the image to the exact size of the text as if the e-mail
address is short there is excess whitespace and if it is long it
over-runs the image.
Any help would be great!
[color=blue]
> // Set Content Type to GIF
> Response.Conten tType = "image/gif";
>
> // Create Image
> const int width = 250, height = 20;
> Bitmap objBitmap = new Bitmap(width, height);
> Graphics objGraphics = Graphics.FromIm age(objBitmap);
> objGraphics.Fil lRectangle(new SolidBrush(Colo r.White), 0, 0, width, height);
>
> // Create Font and String Format
> Font fontDesc = new Font("Verdana", 8, FontStyle.Under line);
> StringFormat stringFormat = new StringFormat();
> stringFormat.Al ignment = StringAlignment .Near;
> stringFormat.Li neAlignment = StringAlignment .Center;
>
> // Draw the String
> objGraphics.Dra wString(Request .QueryString["email"], fontDesc, new SolidBrush(Colo r.Blue), new Rectangle(0, 0, width, height), stringFormat);
>
> // Save the Image to the OutputStream
> objBitmap.Save( Response.Output Stream, ImageFormat.Gif );
>
> // Clean Up
> objGraphics.Dis pose();[/color]
--
Mark (Sparky) Keats
+-+-+-+-+-+-+-+-+-+
e: mark@sparky4646 .co.uk
web: http://www.sparky4646.co.uk
---------------------------------------------------------------------
"Computer games don't affect kids, I mean if Pac Man affected us
as kids, we'd all run around in a darkened room munching pills
and listening to repetitive music..."
- Kristian Wilson, CEO, Nintendo Gaming Corporation, Inc, 1989
---------------------------------------------------------------------