Graphics.DrawString
DrawString(string, Font, Brush, float, float)
在指定位置用指定的字符绘制指定的文本字符串Brush和Font对象.
public void DrawString(string s, Font font, Brush brush, float x, float y)
| 范围 | 类型 | 描述 |
|---|
| s | String | 要绘制的字符串。 |
| font | Font | Font定义字符串的文本格式。 |
| brush | Brush | Brush确定绘制文本的颜色和纹理。 |
| x | Single | 绘制文本左上角的 x 坐标。 |
| y | Single | 绘制文本左上角的 y 坐标。 |
例外
| 例外 | (健康)状况 |
|---|
| ArgumentNullException | brush为空。 -或- s一片空白。 |
也可以看看
DrawString(string, Font, Brush, PointF)
在指定位置用指定的字符绘制指定的文本字符串Brush和Font对象.
public void DrawString(string s, Font font, Brush brush, PointF point)
| 范围 | 类型 | 描述 |
|---|
| s | String | 要绘制的字符串。 |
| font | Font | Font定义字符串的文本格式。 |
| brush | Brush | Brush确定绘制文本的颜色和纹理。 |
| point | PointF | PointF指定绘制文本左上角的结构。 |
例外
| 例外 | (健康)状况 |
|---|
| ArgumentNullException | brush为空。 -或- s一片空白。 |
例子
此示例演示了使用 Font 和 SolidBrush 类在 Image 表面上绘制字符串。该示例创建一个新图像并使用 Figures 和 GraphicsPath 绘制形状
[C#]
//创建图像实例
using (Aspose.PSD.Image image = new Aspose.PSD.FileFormats.Psd.PsdImage(500, 500))
{
//创建并初始化Graphics类的实例
Aspose.PSD.Graphics graphics = new Aspose.PSD.Graphics(image);
//清除图形表面
graphics.Clear(Color.Wheat);
//创建字体实例
Aspose.PSD.Font font = new Aspose.PSD.Font("Times New Roman", 16);
//创建一个具有红色的 SolidBrush 实例
Aspose.PSD.Brushes.SolidBrush brush = new Aspose.PSD.Brushes.SolidBrush(Color.Red);
//画一个字符串
graphics.DrawString("Created by Aspose.PSD for .Net", font, brush, new PointF(100, 100));
// 创建导出选项。
Aspose.PSD.ImageOptions.GifOptions options = new Aspose.PSD.ImageOptions.GifOptions();
// 保存所有更改
image.Save("C:\\temp\\output.gif", options);
}
也可以看看
DrawString(string, Font, Brush, float, float, StringFormat)
在指定位置用指定的字符绘制指定的文本字符串Brush和Font使用指定格式属性的对象StringFormat .
public void DrawString(string s, Font font, Brush brush, float x, float y, StringFormat format)
| 范围 | 类型 | 描述 |
|---|
| s | String | 要绘制的字符串。 |
| font | Font | Font定义字符串的文本格式。 |
| brush | Brush | Brush确定绘制文本的颜色和纹理。 |
| x | Single | 绘制文本左上角的 x 坐标。 |
| y | Single | 绘制文本左上角的 y 坐标。 |
| format | StringFormat | StringFormat指定应用于绘制文本的格式属性,例如行间距和对齐方式。 |
例外
| 例外 | (健康)状况 |
|---|
| ArgumentNullException | brush为空。 -或- s一片空白。 |
也可以看看
DrawString(string, Font, Brush, PointF, StringFormat)
在指定位置用指定的字符绘制指定的文本字符串Brush和Font使用指定格式属性的对象StringFormat .
public void DrawString(string s, Font font, Brush brush, PointF point, StringFormat format)
| 范围 | 类型 | 描述 |
|---|
| s | String | 要绘制的字符串。 |
| font | Font | Font定义字符串的文本格式。 |
| brush | Brush | Brush确定绘制文本的颜色和纹理。 |
| point | PointF | PointF指定绘制文本左上角的结构。 |
| format | StringFormat | StringFormat指定应用于绘制文本的格式属性,例如行间距和对齐方式。 |
例外
| 例外 | (健康)状况 |
|---|
| ArgumentNullException | brush为空。 -或- s一片空白。 |
也可以看看
DrawString(string, Font, Brush, RectangleF)
在指定矩形内绘制指定文本字符串Brush和Font对象.
public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle)
| 范围 | 类型 | 描述 |
|---|
| s | String | 要绘制的字符串。 |
| font | Font | Font定义字符串的文本格式。 |
| brush | Brush | Brush确定绘制文本的颜色和纹理。 |
| layoutRectangle | RectangleF | RectangleF指定绘制文本位置的结构。 |
例外
| 例外 | (健康)状况 |
|---|
| ArgumentNullException | brush为空。 -或- s一片空白。 |
也可以看看
DrawString(string, Font, Brush, RectangleF, StringFormat)
在指定矩形内绘制指定文本字符串Brush和Font使用指定格式属性的对象StringFormat .
public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle,
StringFormat format)
| 范围 | 类型 | 描述 |
|---|
| s | String | 要绘制的字符串。 |
| font | Font | Font定义字符串的文本格式。 |
| brush | Brush | Brush确定绘制文本的颜色和纹理。 |
| layoutRectangle | RectangleF | RectangleF指定绘制文本位置的结构。 |
| format | StringFormat | StringFormat指定应用于绘制文本的格式属性,例如行间距和对齐方式。 |
例外
| 例外 | (健康)状况 |
|---|
| ArgumentNullException | brush为空。 -或- s为空。 -或- brush一片空白。 |
也可以看看