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=400;
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,@"D:\test\c#\advanced\Name.jpg");
}
}
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
public class Drawing
{
public void CreateImage(string name,string filePath)
{
int wid=400;
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,@"D:\test\c#\advanced\Name.jpg");
}
}