public final class EmfRectangle extends EmfDrawingRecordType
The EMR_RECTANGLE record draws a rectangle. The rectangle is outlined by using the current pen and filled by using the current brush.
The current position is neither used nor updated by Rectangle. If a PS_NULL pen is used, the dimensions of the rectangle are 1 pixel less in height and 1 pixel less in width.
EmfDrawingRecordType| Constructor and Description |
|---|
EmfRectangle()
Initializes a new instance of the
EmfRectangle class. |
EmfRectangle(EmfRecord source)
Initializes a new instance of the
EmfRectangle class. |
| Modifier and Type | Method and Description |
|---|---|
Rectangle |
getBox()
Gets or sets a 128-bit WMF RectL object, specified in [MS-WMF] section 2.2.2.19, which
specifies the inclusive-inclusive rectangle to draw.
|
void |
setBox(Rectangle value)
Gets or sets a 128-bit WMF RectL object, specified in [MS-WMF] section 2.2.2.19, which
specifies the inclusive-inclusive rectangle to draw.
|
public EmfRectangle(EmfRecord source)
Initializes a new instance of the EmfRectangle class.
source - The source.public EmfRectangle()
Initializes a new instance of the EmfRectangle class.
The following example shows how set the background color for EMF. It actually 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 {
private void addBackgroundRectangleEmf(com.aspose.imaging.fileformats.emf.EmfImage 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.emf.emf.records.EmfRectangle rectangle = new com.aspose.imaging.fileformats.emf.emf.records.EmfRectangle();
rectangle.setBox(image.getHeader().getEmfHeader().getBounds());
//Set Brush
com.aspose.imaging.fileformats.emf.emf.records.EmfCreateBrushIndirect brush = new com.aspose.imaging.fileformats.emf.emf.records.EmfCreateBrushIndirect();
brush.setLogBrush(new com.aspose.imaging.fileformats.emf.emf.objects.EmfLogBrushEx());
brush.getLogBrush().setArgb32ColorRef(color.toArgb());
brush.setIhBrush(1);
//Select brush
com.aspose.imaging.fileformats.emf.emf.records.EmfSelectObject selectObject = new com.aspose.imaging.fileformats.emf.emf.records.EmfSelectObject();
selectObject.setObjectHandle(1);
//Remove brush
com.aspose.imaging.fileformats.emf.emf.records.EmfDeleteObject deleteObject = new com.aspose.imaging.fileformats.emf.emf.records.EmfDeleteObject();
deleteObject.setObjectHandle(1);
//Add records
records.insertItem(1, brush);
records.insertItem(2, selectObject);
records.insertItem(3, rectangle);
records.insertItem(4, deleteObject);
}
}
// Here is the main example
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().addBackgroundRectangleEmf((com.aspose.imaging.fileformats.emf.EmfImage) image, com.aspose.imaging.Color.getBlue());
image.save(outputFile);
} finally {
image.close();
}
}
public Rectangle getBox()
Gets or sets a 128-bit WMF RectL object, specified in [MS-WMF] section 2.2.2.19, which specifies the inclusive-inclusive rectangle to draw.
public void setBox(Rectangle value)
Gets or sets a 128-bit WMF RectL object, specified in [MS-WMF] section 2.2.2.19, which specifies the inclusive-inclusive rectangle to draw.
Copyright (c) 2008-2022 Aspose Pty Ltd. All Rights Reserved.