有没有办法以编程方式将文本添加到System.Drawing.Image? [英] Is there a way to programmatically add text to a System.Drawing.Image?

查看:115
本文介绍了有没有办法以编程方式将文本添加到System.Drawing.Image?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用System.Drawing.Graphics DrawImage函数显示的System.Drawing.Image.该图像是警车,我想在警车上画一个单位编号.是否有捷径可寻?

I have a System.Drawing.Image that I display with System.Drawing.Graphics DrawImage function. The image is a police car, and I would like to draw a unit number on top of the police car. Is there an easy way to do this?

推荐答案

您可以使用

You can use the DrawString method to write text out onto an image.

// Create string to draw.
String drawString = "Sample Text";

// Create font and brush.
Font drawFont = new Font("Arial", 16);
SolidBrush drawBrush = new SolidBrush(Color.Black);

// Create point for upper-left corner of drawing.
PointF drawPoint = new PointF(150.0F, 150.0F);

// Draw string to screen.
e.Graphics.DrawString(drawString, drawFont, drawBrush, drawPoint);

这篇关于有没有办法以编程方式将文本添加到System.Drawing.Image?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆