All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
asp.net把输入文字转化成图片_[Asp.Net教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/1/30 1:21:51 Browse times: 316 Comment times: 0

asp.net把输入文字转化成图片_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

asp.net把输入文字转化成图片_[Asp.Net教程]

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;

public class Drawing
{
public void CreateImage(string name,string filePath)
{
int wid=300;
int high=200;
Font font=new Font("Arial",48,FontStyle.Bold);
//字的颜色
SolidBrush brush=new SolidBrush(Color.Black);

Bitmap image=new Bitmap(wid,high);
Graphics g=Graphics.FromImage(image);
g.Clear(ColorTranslator.FromHtml("#f0f0f0"));
RectangleF rect=new RectangleF(5,2,wid,high);
//绘制图片
g.DrawString(name,font,brush,rect);
//保存
image.Save(filePath,ImageFormat.Jpeg);
//释放对象
g.Dispose();
image.Dispose();
}
}
public class Program
{
public static void Main()
{
Drawing dh=new Drawing();
Console.WriteLine("输入文字:");
string name=Console.ReadLine();
dh.CreateImage(name,@"e:\test\c#\advanced\Name.jpg");
}
}





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.