WmfRectangle
内容
[
隐藏
]WmfRectangle class
META_RECTANGLE 记录绘制一个矩形。矩形是使用笔勾勒出 并使用在 播放设备上下文中定义的画笔填充的。
public class WmfRectangle : WmfObject
构造函数
姓名 | 描述 |
---|---|
WmfRectangle() | 默认构造函数。 |
特性
姓名 | 描述 |
---|---|
Rectangle { get; set; } | 获取或设置矩形。 |
例子
以下示例显示了如何设置 WMF 的背景颜色。实际上它在绘制所有其他对象之前绘制了一个背景颜色的矩形。
[C#]
string dir = "c:\\aspose.imaging\\issues\\net\\3280\\";
string inputFilePath = dir + "image2.wmf";
string outputFilePath = dir + "ChangeBackground_" + "image2.wmf";
using (Aspose.Imaging.FileFormats.Emf.MetaImage image = (Aspose.Imaging.FileFormats.Emf.MetaImage)Aspose.Imaging.Image.Load(inputFilePath))
{
AddBackgroundRectangleWmf((Aspose.Imaging.FileFormats.Wmf.WmfImage)image, Aspose.Imaging.Color.Blue);
image.Save(outputFilePath);
}
/// <summary>
/// 改变 WMF 背景的辅助方法。
/// </summary>
public static void AddBackgroundRectangleWmf(Aspose.Imaging.FileFormats.Wmf.WmfImage image, Aspose.Imaging.Color color)
{
image.CacheData();
if (image.Records.Count < 1)
{
return;
}
//设置矩形
Aspose.Imaging.FileFormats.Wmf.Objects.WmfRectangle rectangle = new Aspose.Imaging.FileFormats.Wmf.Objects.WmfRectangle();
rectangle.Rectangle = image.FrameBounds;
//设置画笔
Aspose.Imaging.FileFormats.Wmf.Objects.WmfCreateBrushInDirect brush = new Aspose.Imaging.FileFormats.Wmf.Objects.WmfCreateBrushInDirect();
brush.LogBrush = new Aspose.Imaging.FileFormats.Emf.Emf.Objects.EmfLogBrushEx();
brush.LogBrush.Argb32ColorRef = color.ToArgb();
//选择画笔
Aspose.Imaging.FileFormats.Wmf.Objects.WmfSelectObject selectObject = new Aspose.Imaging.FileFormats.Wmf.Objects.WmfSelectObject(brush);
//删除画笔
Aspose.Imaging.FileFormats.Wmf.Objects.WmfDeleteObject deleteObject = new Aspose.Imaging.FileFormats.Wmf.Objects.WmfDeleteObject(brush);
//添加记录
image.Records.Insert(0, brush);
image.Records.Insert(1, selectObject);
image.Records.Insert(2, rectangle);
image.Records.Insert(3, deleteObject);
}