Packages

 

com.aspose.imaging.fileformats.wmf.objects

Class WmfSelectObject

  • All Implemented Interfaces:
    Cloneable


    public class WmfSelectObject
    extends WmfObject

    The select object.

    • Constructor Detail

      • WmfSelectObject

        public WmfSelectObject(WmfGraphicObject wmfObject)

        Initializes a new instance of the WmfSelectObject class.

        Parameters:
        wmfObject - The WMF object.
      • WmfSelectObject

        public WmfSelectObject()

        Initializes a new instance of the WmfSelectObject class.

        Code example:

        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();
            }
        }
        

    • Method Detail

      • getObjectIndex

        public int getObjectIndex()

        Gets or sets the index of the object.

        Value: The index of the object.
      • setObjectIndex

        public void setObjectIndex(int value)

        Gets or sets the index of the object.

        Value: The index of the object.