Packages

 

com.aspose.imaging.imageoptions

Class SvgRasterizationOptions

    • Constructor Detail

      • SvgRasterizationOptions

        public SvgRasterizationOptions()

        Initializes a new instance of the SvgRasterizationOptions class.

    • Method Detail

      • getScaleX

        public float getScaleX()

        Gets or sets the scale x.

        Returns:
        The scale x.
      • setScaleX

        public void setScaleX(float value)

        Gets or sets the scale x.

        Parameters:
        value - The scale x.
        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();
        }
        

      • getScaleY

        public float getScaleY()

        Gets or sets the scale y.

        Returns:
        The scale y.
      • setScaleY

        public void setScaleY(float value)

        Gets or sets the scale y.

        Parameters:
        value - The scale y.
        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();
        }