Writing text on the picture

xiaoxiao2021-03-06  19

In My Example, I Have A Picture of My Son! "" That My Boy! ". Also, To Show That You Can Combine Graphic Drawing and Text Toget The Word That I Just Put On The Picture.

In Order To Make this Sample Work, you need the folloading reasoning References:

Using system.drawing;

Using system.drawing.image;

Using system.drawing.drawing2d;

USING System.drawing.Text;

Also, you might need to play around with where you want your text and oval to go. Remember that both the placement of the text and graphic oval are based on X and Y coordinates. So, if you have to move the text / oval up . The value of the x parameter.

There Are Basically 6 Steps for My Sample:

Load your image: // load the Image to be Written on.

Bitmap bitmapImage = new

System.drawing.bitmap (Server.MAppath ("Dallen.jpg"));

Graphics graphicimage = graphics.FromImage (BitmapImage); set the graphics to be smooth. // smooth graphics is nice.

Graphicimage.smoothingmode = smoothingmode.antialias; Write Your text. Here is where you set your font. The new point. (100 = x, 250 = y). // Write your text.

GraphicImage.drawstring ("That's my boy!",

New font ("Arial", 12, FontStyle.Bold,

SystemBrushes.WindowText, new Point (100, 250)); Draw your oval around the text Note:. Play around with the numbers to make the oval to the correct size that you want // I am drawing a oval around my text..

GraphicImage.drawarc (New Pen (Color.red, 3), 90, 235, 150, 50, 0, 360); Set The Content Type To Jpg and Then Write Your Image To The Response Stream. // Set The Content TypeResponse. ContentType = "image / jpeg";

// save the new image to the response output stream.

BitmapImage.save (response.outputstream, Imageformat.jpeg); Clean Up. // Clean House.

GraphicImage.dispose ();

BitmapImage.dispose ();

转载请注明原文地址:https://www.9cbs.com/read-77198.html

New Post(0)