M
Mark Keats
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!
--
Mark (Sparky) Keats
+-+-+-+-+-+-+-+-+-+
e: (e-mail address removed)
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!
// Set Content Type to GIF
Response.ContentType = "image/gif";
// Create Image
const int width = 250, height = 20;
Bitmap objBitmap = new Bitmap(width, height);
Graphics objGraphics = Graphics.FromImage(objBitmap);
objGraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
// Create Font and String Format
Font fontDesc = new Font("Verdana", 8, FontStyle.Underline);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Near;
stringFormat.LineAlignment = StringAlignment.Center;
// Draw the String
objGraphics.DrawString(Request.QueryString["email"], fontDesc, new SolidBrush(Color.Blue), new Rectangle(0, 0, width, height), stringFormat);
// Save the Image to the OutputStream
objBitmap.Save(Response.OutputStream, ImageFormat.Gif);
// Clean Up
objGraphics.Dispose();
--
Mark (Sparky) Keats
+-+-+-+-+-+-+-+-+-+
e: (e-mail address removed)
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
---------------------------------------------------------------------