Aspose.Imaging for Java发布了新的3.9版本

作者:控件中国网   出处:控件中国网   2016-10-08 14:26:44   阅读:11

Aspose.Imaging for Java图形图片处理控件是一款可以帮助开发人员进行各种图片处理和转换的Java类库,在新的3.9版本中主要作了如下的更新:
1、支持创建EMF元文件图片
public void penAndMixedArcTests()
{
// EmfRecorderGraphics2D class provides you the frame or canvas to draw shapes on it.
// Create an instance of EmfRecorderGraphics2D class. The constructor takes in 3 parameters:
// 1. Instance of Imaging Rectangle class
// 2. Instance of Imaging Size class
// 3. Instance of Imaging Size class
EmfRecorderGraphics2D graphics = new EmfRecorderGraphics2D(new Rectangle(0, 0, 1000, 1000), new Size(1000, 1000)
            , new Size(100, 100));
        {
 
            // Create an instance of Imaging Pen class and mention its color.
            Pen pen = new Pen(Color.getBisque().Clone());
 
            // Draw a line by calling DrawLine method and passing x,y coordinates of 1st point and same for 2nd point along with 
 
color info as Pen.
            graphics.drawLine(pen, 1, 1, 50, 50);
 
            // Reset the Pen color.
            pen = new Pen(Color.getBlueViolet().Clone(), 3);
 
            // specify the end style of the line.
            pen.setEndCap(LineCap.Round);
 
            // Draw a line by calling DrawLine method and passing x,y coordinates of 1st point and same for 2nd point along with 
 
color infor as Pen and end style of line.
            graphics.drawLine(pen, 15, 5, 50, 60);
 
            // specify the end style of the line.
            pen.setEndCap(LineCap.Square);
 
            // Draw a line by calling DrawLine method.
            graphics.drawLine(pen, 5, 10, 50, 10);
 
            // specify the end style of the line.
            pen.setEndCap(LineCap.Flat);
 
            // Draw a line by calling DrawLine method.
            graphics.drawLine(pen, new Point(5, 20), new Point(50, 20));
 
            // Create an instance of HatchBrush class to define rectanglurar brush with with different settings.
            HatchBrush hatchBrush = new com.Aspose.Imaging.brushes.HatchBrush();
            hatchBrush.setBackgroundColor(Color.getAliceBlue().Clone());
            hatchBrush.setForegroundColor(Color.getRed().Clone());
            hatchBrush.setHatchStyle(HatchStyle.Cross);
            pen = new Pen(hatchBrush, 7);
            graphics.drawRectangle(pen, 50, 50, 20, 30);
            graphics.setBackgroundMode(com.Aspose.Imaging.fileformats.emf.emf.consts.EmfBackgroundMode.OPAQUE);
            graphics.drawLine(pen, 80, 50, 80, 80);
 
            // Draw a line by calling DrawLine method and passing parameters.
            pen = new Pen(new SolidBrush(Color.getAqua().Clone()), 3);
            pen.setLineJoin(LineJoin.MiterClipped);
 
            // Draw a polygon by calling DrawPolygon method and passing parameters with line join setting/style.
            graphics.drawPolygon(pen, new Point[] { new Point(10, 20), new Point(12, 45), new Point(22, 48), new Point(48
                , 36), new Point(30, 55) });
            pen.setLineJoin(LineJoin.Bevel);
            graphics.drawRectangle(pen, 50, 10, 10, 5);
            pen.setLineJoin(LineJoin.Round);
            graphics.drawRectangle(pen, 65, 10, 10, 5);
            pen.setLineJoin(LineJoin.Miter);
            graphics.drawRectangle(pen, 80, 10, 10, 5);
 
            // Call EndRecording method to produce the final shape. EndRecording method will return the final shape as EmfImage.
            // So create an instance of EmfImage class and initialize it with EmfImage returned by EndRecording method.           
            final EmfImage image = graphics.endRecording();
 
            try /*JAVA: was using*/
            {
 
                test(image, "Pens.emf");
            }
            finally
            {
                if (image != null)
                    (image).dispose();
            }
        }
    }
}
 
private void test(EmfImage image, String fileName)
    {
        // Create an instance of PdfOptions class.
        PdfOptions options = new PdfOptions();
 
        // Create an instance of EmfRasterizationOptions class and define different settings.
        EmfRasterizationOptions rasterizationOptions = new EmfRasterizationOptions();
        options.setVectorRasterizationOptions(rasterizationOptions);
        rasterizationOptions.setPageSize(com.Aspose.Imaging.Size.to_SizeF(image.getSize()).Clone());
 
        String outPath = fileName + ".pdf";
 
// Call the save method to convert the EMF metafile image to PDF.
        image.save(outPath, options);
    }
2、支持转换EMF为SVG格式
String sourcePath = "input\\tiger.emf";
String destPath = "output\\tiger.svg";
 
    // Load an existing EMF file
    Image image = Image.load(sourcePath, new MetafileLoadOptions(true));
    try
    {
        // Create an instance of EmfRasterizationOptions class and set different options
EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions();
emfRasterizationOptions.setBackgroundColor(Color.getWhite());
emfRasterizationOptions.setPageWidth(image.getWidth());
emfRasterizationOptions.setPageHeight(image.getHeight());
 
        // call the save method and pass instance of SvgOptions class to convert it to SVG format.
image.save(destPath, new SvgOptions() {{ setVectorRasterizationOptions(emfRasterizationOptions); }});
    }
    finally
    {
        image.dispose();
    }
3.对更新PSD文本层的文本进行了增强
4.对处理提取TIFF框架进行了增强
5、对转换TIFF为JPEG进行了增强
6、对转换Djvu为PDF文件进行了增强
7、对光栅图片的旋转处理操作进行了增强
Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat