public class WmfCreateBrushInDirect extends WmfGraphicObject
The Create brush in direct
| Constructor and Description |
|---|
WmfCreateBrushInDirect()
Initializes a new instance of the
WmfCreateBrushInDirect class. |
| Modifier and Type | Method and Description |
|---|---|
EmfLogBrushEx |
getLogBrush()
Gets or sets the log brush.
|
void |
setLogBrush(EmfLogBrushEx value)
Gets or sets the log brush.
|
getIndex, setIndexpublic WmfCreateBrushInDirect()
Initializes a new instance of the WmfCreateBrushInDirect class.
The following example shows how set the background color for WMF. Actually it draws a rectangle of the background color before drawing all other objects.
String baseFolder = "c:\\temp\\";
// This is a helper class which does all real work.
class Util {
public void addBackgroundRectangleWmf(com.aspose.imaging.fileformats.wmf.WmfImage image, com.aspose.imaging.Color color) {
image.cacheData();
com.aspose.imaging.fileformats.emf.MetaObjectList records = image.getRecords();
if (records.size() < 1) {
return;
}
//Set Rectangle
com.aspose.imaging.fileformats.wmf.objects.WmfRectangle rectangle = new com.aspose.imaging.fileformats.wmf.objects.WmfRectangle();
rectangle.setRectangle(image.getFrameBounds());
//Set Brush
com.aspose.imaging.fileformats.wmf.objects.WmfCreateBrushInDirect brush = new com.aspose.imaging.fileformats.wmf.objects.WmfCreateBrushInDirect();
brush.setLogBrush(new com.aspose.imaging.fileformats.emf.emf.objects.EmfLogBrushEx());
brush.getLogBrush().setArgb32ColorRef(color.toArgb());
//Select brush
com.aspose.imaging.fileformats.wmf.objects.WmfSelectObject selectObject = new com.aspose.imaging.fileformats.wmf.objects.WmfSelectObject(brush);
//Remove brush
com.aspose.imaging.fileformats.wmf.objects.WmfDeleteObject deleteObject = new com.aspose.imaging.fileformats.wmf.objects.WmfDeleteObject(brush);
//Add records
records.insertItem(0, brush);
records.insertItem(1, selectObject);
records.insertItem(2, rectangle);
records.insertItem(3, deleteObject);
}
}
String[] files = new String[]{"image1.emf", "image2.wmf"};
for (String fileName : files) {
String inputFile = baseFolder + fileName;
String outputFile = baseFolder + "Background_" + fileName;
com.aspose.imaging.fileformats.emf.MetaImage image = (com.aspose.imaging.fileformats.emf.MetaImage) com.aspose.imaging.Image.load(inputFile);
try {
new Util().addBackgroundRectangleWmf((com.aspose.imaging.fileformats.wmf.WmfImage) image, com.aspose.imaging.Color.getBlue());
image.save(outputFile);
} finally {
image.close();
}
}
public EmfLogBrushEx getLogBrush()
Gets or sets the log brush.
Value: The log brush.public void setLogBrush(EmfLogBrushEx value)
Gets or sets the log brush.
Value: The log brush.Copyright (c) 2008-2022 Aspose Pty Ltd. All Rights Reserved.