Link to home
Start Free TrialLog in
Avatar of Starr Duskk
Starr DuskkFlag for United States of America

asked on

Writing text on an image

How can I write text on a displayed image?

1) temporarily just as it displays?
2) permanently?

I know I can do it with stylesheets, but I mean if they right click to download, the text will remain on the image.

thanks.
ASKER CERTIFIED SOLUTION
Avatar of Juan_Barrera
Juan_Barrera
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Learned
Relevant code enhanced (not an answer, so no points please):


            Random Rand = new Random();
            int number = Rand.Next(10000, 99999);
            Bitmap Bmp = new Bitmap(90, 50);
 
            using (Graphics g = Graphics.FromImage(Bmp))
            {
                Font Fnt = new Font("Verdana", 12, FontStyle.Bold);
 
                g.DrawString(number.ToString(), Fnt, Brushes.Yellow, 15, 15);
 
                // Create random numbers for the first line 
                int y1 = Rand.Next(0, 50);
                int y2 = Rand.Next(0, 50);
 
                // Draw the first line 
                g.DrawLine(Pens.Yellow, 0, y1, 90, y2);
 
                // Create random numbers for the second line
                y1 = Rand.Next(0, 50);
                y2 = Rand.Next(0, 50);
 
                // Draw the second line
 
                g.DrawLine(Pens.Yellow, 0, y1, 90, y2);
 
                Bmp.Save(Response.OutputStream, ImageFormat.Gif);
            }

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Starr Duskk

ASKER

Sorry I wasn't clear.
I meant, I have an existing photo image. I want to write the text URL to the bottom left corner of the image.
 
 
That was a GDI+ example for writing on a Bitmap or Image, so if you only have an image at a URL, then you need to do something else.  Are you looking to write over the image, or below it?
Yes, but you can create a bitmap from an existing image:

 Drawing.Bitmap.FromFile("path")

Use it instead of creating a blank BitMap
Over the image on the left bottom corner.
thanks.
 
If the image is at the URL that is on your site, than Bitmap.FromFile will need Server.MapPath, but other than that, you should be good to go.
thanks for the VB version!