C#.net如何在GDI+绘图过程中添加文字?样子就像windows自带的画图软件那样
展开全部
//下面这两个文件位置根据你的需求,修改成你机子上的绝对位置。
//程序运行完后,会在newFile位置生成一个新文件。
string oldFile = Environment.CurrentDirectory + "\\test.jpg";
string newFile = Environment.CurrentDirectory + "\\test1.jpg";
Image image = Image.FromFile(oldFile);
Graphics graphic = Graphics.FromImage(image);
graphic.DrawString("绘画时间:2010年11月24日11:31:10", new Font("幼圆", 24f, FontStyle.Regular), new SolidBrush(Color.Black), 100f, 100f);
image.Save(newFile);
image.Dispose();
graphic.Dispose();
//程序运行完后,会在newFile位置生成一个新文件。
string oldFile = Environment.CurrentDirectory + "\\test.jpg";
string newFile = Environment.CurrentDirectory + "\\test1.jpg";
Image image = Image.FromFile(oldFile);
Graphics graphic = Graphics.FromImage(image);
graphic.DrawString("绘画时间:2010年11月24日11:31:10", new Font("幼圆", 24f, FontStyle.Regular), new SolidBrush(Color.Black), 100f, 100f);
image.Save(newFile);
image.Dispose();
graphic.Dispose();
展开全部
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Paint += P;
}
private void P(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
g.DrawString("This is the test text.", this.Font, new SolidBrush(Color.Black), new PointF(0, 0));
g.Dispose();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Paint += P;
}
private void P(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
g.DrawString("This is the test text.", this.Font, new SolidBrush(Color.Black), new PointF(0, 0));
g.Dispose();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询