Packages

 

com.aspose.imaging.imageoptions

Class VectorRasterizationOptions

    • Constructor Detail

      • VectorRasterizationOptions

        public VectorRasterizationOptions()
    • Method Detail

      • getSmoothingMode

        public final int getSmoothingMode()

        Gets the smoothing mode.

        Returns:
        the smoothing mode.
      • setSmoothingMode

        public final void setSmoothingMode(int value)

        Sets the smoothing mode.

        Parameters:
        value - the smoothing mode.
        Code example:

        This example shows how to load an SVG image from a file and rasterize it to PNG using various options.


        String dir = "c:\\temp\\";
        
        // Using Aspose.Imaging.Image.Load is a unified way to load image.
        com.aspose.imaging.fileformats.svg.SvgImage svgImage = (com.aspose.imaging.fileformats.svg.SvgImage) com.aspose.imaging.Image.load(dir + "test.svg");
        try {
            // In order to rasterize SVG we need to specify rasterization options.
            com.aspose.imaging.imageoptions.SvgRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.SvgRasterizationOptions();
        
            // Set default color of a background for an image. Default value is white.
            rasterizationOptions.setBackgroundColor(com.aspose.imaging.Color.getGray());
        
            // Set the page size
            rasterizationOptions.setPageSize(new com.aspose.imaging.SizeF(svgImage.getWidth(), svgImage.getHeight()));
        
            // Antialiasing is applied to lines and curves and the edges of filled areas.
            rasterizationOptions.setSmoothingMode(com.aspose.imaging.SmoothingMode.AntiAlias);
        
            // Each character is drawn using its antialiased glyph bitmap without hinting.
            rasterizationOptions.setTextRenderingHint(com.aspose.imaging.TextRenderingHint.AntiAlias);
        
            // Reduce the image size 10 times, i.e. the output size will be 10% of the original size.
            rasterizationOptions.setScaleX(0.1f);
            rasterizationOptions.setScaleY(0.1f);
        
            com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions();
            saveOptions.setVectorRasterizationOptions(rasterizationOptions);
        
            // Save to a PNG file
            svgImage.save(dir + "test.output.png", saveOptions);
        } finally {
            svgImage.dispose();
        }
        

      • getBorderX

        public float getBorderX()

        Gets or sets the border X.

        Returns:
        The border X.
      • setBorderX

        public void setBorderX(float value)

        Gets or sets the border X.

        Parameters:
        value - The border X.
      • getBorderY

        public float getBorderY()

        Gets or sets the border Y.

        Returns:
        The border Y.
      • setBorderY

        public void setBorderY(float value)

        Gets or sets the border Y.

        Parameters:
        value - The border Y.
      • getCenterDrawing

        public boolean getCenterDrawing()

        Gets a value indicating whether center drawing.

        Returns:
        a value indicating whether center drawing.
      • setCenterDrawing

        public void setCenterDrawing(boolean value)

        Sets a value indicating whether center drawing.

        Parameters:
        value - a value indicating whether center drawing.
      • getPageHeight

        public float getPageHeight()

        Gets the page height.

        Returns:
        the page height.
      • setPageHeight

        public void setPageHeight(float value)

        Sets the page height.

        Parameters:
        value - the page height.
      • getPageSize

        public SizeF getPageSize()

        Gets the page size.

        Returns:
        the page size.
      • setPageSize

        public void setPageSize(SizeF value)

        Sets the page size.

        Parameters:
        value - the page size.
        Code example:

        This example shows how to load a EMF image from a file and convert it to SVG using EmfRasterizationOptions.


        String dir = "c:\\temp\\";
        
        // Using Aspose.Imaging.Image.Load is a unified way to load all types of images including EMF.
        com.aspose.imaging.fileformats.emf.EmfImage emfImage = (com.aspose.imaging.fileformats.emf.EmfImage) com.aspose.imaging.Image.load(dir + "test.emf");
        try {
            com.aspose.imaging.imageoptions.SvgOptions saveOptions = new com.aspose.imaging.imageoptions.SvgOptions();
        
            // Text will be converted to shapes.
            saveOptions.setTextAsShapes(true);
        
            com.aspose.imaging.imageoptions.EmfRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.EmfRasterizationOptions();
        
            // The background color of the drawing surface.
            rasterizationOptions.setBackgroundColor(com.aspose.imaging.Color.getWhiteSmoke());
        
            // The page size.
            rasterizationOptions.setPageSize(new com.aspose.imaging.SizeF(emfImage.getWidth(), emfImage.getHeight()));
        
            // If embedded emf exists, then render emf; otherwise render wmf.
            rasterizationOptions.setRenderMode(com.aspose.imaging.fileformats.emf.EmfRenderMode.Auto);
        
            // Set the horizontal margin
            rasterizationOptions.setBorderX(50);
        
            // Set the vertical margin
            rasterizationOptions.setBorderY(50);
        
            saveOptions.setVectorRasterizationOptions(rasterizationOptions);
        
            emfImage.save(dir + "test.output.svg", saveOptions);
        } finally {
            emfImage.dispose();
        }
        

      • getPageWidth

        public float getPageWidth()

        Gets the page width.

        Returns:
        the page width.
      • setPageWidth

        public void setPageWidth(float value)

        Sets the page width.

        Parameters:
        value - the page width.
      • getBackgroundColor

        public Color getBackgroundColor()

        Gets a background color.

        Returns:
        a background color.
      • setBackgroundColor

        public void setBackgroundColor(Color value)

        Sets a background color.

        Parameters:
        value - a background color.
        Code example:

        This example shows how to load a EMF image from a file and convert it to SVG using EmfRasterizationOptions.


        String dir = "c:\\temp\\";
        
        // Using Aspose.Imaging.Image.Load is a unified way to load all types of images including EMF.
        com.aspose.imaging.fileformats.emf.EmfImage emfImage = (com.aspose.imaging.fileformats.emf.EmfImage) com.aspose.imaging.Image.load(dir + "test.emf");
        try {
            com.aspose.imaging.imageoptions.SvgOptions saveOptions = new com.aspose.imaging.imageoptions.SvgOptions();
        
            // Text will be converted to shapes.
            saveOptions.setTextAsShapes(true);
        
            com.aspose.imaging.imageoptions.EmfRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.EmfRasterizationOptions();
        
            // The background color of the drawing surface.
            rasterizationOptions.setBackgroundColor(com.aspose.imaging.Color.getWhiteSmoke());
        
            // The page size.
            rasterizationOptions.setPageSize(new com.aspose.imaging.SizeF(emfImage.getWidth(), emfImage.getHeight()));
        
            // If embedded emf exists, then render emf; otherwise render wmf.
            rasterizationOptions.setRenderMode(com.aspose.imaging.fileformats.emf.EmfRenderMode.Auto);
        
            // Set the horizontal margin
            rasterizationOptions.setBorderX(50);
        
            // Set the vertical margin
            rasterizationOptions.setBorderY(50);
        
            saveOptions.setVectorRasterizationOptions(rasterizationOptions);
        
            emfImage.save(dir + "test.output.svg", saveOptions);
        } finally {
            emfImage.dispose();
        }
        

      • getDrawColor

        public Color getDrawColor()

        Gets a foreground color.

        Returns:
        a foreground color.
      • setDrawColor

        public void setDrawColor(Color value)

        Sets a foreground color.

        Parameters:
        value - a foreground color.
      • getTextRenderingHint

        public final int getTextRenderingHint()

        Gets the text rendering hint.

        Value: The text rendering hint.
        Returns:
        the text rendering hint.
      • setTextRenderingHint

        public final void setTextRenderingHint(int value)

        Sets the text rendering hint.

        Value: The text rendering hint.
        Parameters:
        value - the text rendering hint.
        Code example:

        This example shows how to load an SVG image from a file and rasterize it to PNG using various options.


        String dir = "c:\\temp\\";
        
        // Using Aspose.Imaging.Image.Load is a unified way to load image.
        com.aspose.imaging.fileformats.svg.SvgImage svgImage = (com.aspose.imaging.fileformats.svg.SvgImage) com.aspose.imaging.Image.load(dir + "test.svg");
        try {
            // In order to rasterize SVG we need to specify rasterization options.
            com.aspose.imaging.imageoptions.SvgRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.SvgRasterizationOptions();
        
            // Set default color of a background for an image. Default value is white.
            rasterizationOptions.setBackgroundColor(com.aspose.imaging.Color.getGray());
        
            // Set the page size
            rasterizationOptions.setPageSize(new com.aspose.imaging.SizeF(svgImage.getWidth(), svgImage.getHeight()));
        
            // Antialiasing is applied to lines and curves and the edges of filled areas.
            rasterizationOptions.setSmoothingMode(com.aspose.imaging.SmoothingMode.AntiAlias);
        
            // Each character is drawn using its antialiased glyph bitmap without hinting.
            rasterizationOptions.setTextRenderingHint(com.aspose.imaging.TextRenderingHint.AntiAlias);
        
            // Reduce the image size 10 times, i.e. the output size will be 10% of the original size.
            rasterizationOptions.setScaleX(0.1f);
            rasterizationOptions.setScaleY(0.1f);
        
            com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions();
            saveOptions.setVectorRasterizationOptions(rasterizationOptions);
        
            // Save to a PNG file
            svgImage.save(dir + "test.output.png", saveOptions);
        } finally {
            svgImage.dispose();
        }
        

      • getPositioning

        public final int getPositioning()

        Gets the positioning.

        Value: The positioning.
        Returns:
        the positioning.
        See Also:
        PositioningTypes
      • setPositioning

        public final void setPositioning(int value)

        Sets the positioning.

        Value: The positioning.
        Parameters:
        value - the positioning.
        See Also:
        PositioningTypes
      • copyTo

        public final void copyTo(VectorRasterizationOptions vectorRasterizationOptions)

        Copies to.

        Parameters:
        vectorRasterizationOptions - The vector rasterization options.