ASP.net in C # implementation picture with Stroke font example

Source: Internet
Author: User

The effect is as follows

The code is as follows

Private Image Loadfont (string pa)
{
Image Bmap;
Bmap = Image.FromFile (PA);

Graphics g = graphics.fromimage (BMAP);//Create Graphics object on Image Object

G.smoothingmode = Smoothingmode.antialias;
G.smoothingmode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
GraphicsPath MyPath = new GraphicsPath ();

String stringtext = This.textBox1.Text.Trim ();
string font = "";//font
This.comboBox1.Invoke (New EventHandler (delegate
{
Font = This.comboBox1.Text;
}));
FontFamily family = new FontFamily (Font);
int fontstyle = (int) fontstyle.bold;
int emsize = (int) numericupdown3.value;//font size
Point origin = new Point (10, 10);
StringFormat format = Stringformat.genericdefault;
Brush bru = new SolidBrush (Color.FromArgb (241, 027, 039));
Mypath.addstring (Stringtext,
Family
FontStyle,
Emsize,
Origin
format);

G.fillpath (Bru, MyPath);
G.drawpath (New Pen (Color.White, (float) numericupdown1.value), MyPath);
Bmap. Save (@ "d:/test.jpg");//saves image picture to local
return bmap;
}

Get all the fonts on the system

Installedfontcollection myfont = new Installedfontcollection ();
fontfamily[] myfontfamilies = myfont.families;
int Count = myfontfamilies.length;
for (int i = 0; i < Count; i++)
{
    this.comboBox1.Items.Add (Myfontfamilies[i]. Name);
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.