Catatan Rilis Aspose.PSD untuk Java 24.4
Contents
 [
      
        Hide
      ]
    
Halaman ini berisi catatan rilis untuk Aspose.PSD untuk Java 24.4
| Kunci | Ringkasan | Kategori | 
|---|---|---|
| PSDJAVA-610 | Penetapan Lisensi untuk Aspose.PSD untuk Java menyebabkan pengecualian jika dilakukan lebih dari satu kali | Bug | 
| PSDJAVA-611 | [Format AI] Tambah penanganan sumber daya XObjectForm | Fitur | 
| PSDJAVA-612 | Tambah Konstruktor untuk ShapeLayer | Fitur | 
| PSDJAVA-613 | Perbaikan konversi file Psd dari RGB ke CMYK | Bug | 
| PSDJAVA-614 | File PSD tertentu tidak dapat diekspor menggunakan Aspose.PSD | Bug | 
Perubahan API Publik
API Ditambahkan:
- M:com.aspose.psd.fileformats.psd.PsdImage.addShapeLayer
API Dihapus:
- Tidak ada
Contoh Penggunaan:
PSDJAVA-610. Penetapan Lisensi untuk Aspose.PSD untuk Java menyebabkan pengecualian jika dilakukan lebih dari satu kali
        License license = new License();
        String liccorrectJava = "Aspose.PSD.Java.lic";
        license.setLicense(liccorrectJava);
        license.setLicense(liccorrectJava);PSDJAVA-611. [Format AI] Tambah penanganan sumber daya XObjectForm
        String sourceFile = "src/main/resources/example.ai";
        String outputFilePath = "src/main/resources/example.png";
        try (AiImage image = (AiImage) Image.load(sourceFile)) {
            image.save(outputFilePath, new PngOptions());
        }PSDJAVA-612. Tambah Konstruktor untuk ShapeLayer
    private static final int IMG_TO_PSD_RATIO = 256 * 65535;
    public static void main(String[] args) {
        String outputFile = "src/main/resources/AddShapeLayer_output.psd";
        try (PsdImage newPsd = new PsdImage(600, 400)) {
            ShapeLayer layer = newPsd.addShapeLayer();
            PathShape newShape = generateNewShape(newPsd.getSize());
            List<IPathShape> newShapes = new List<>();
            newShapes.add(newShape);
            layer.getPath().setItems(newShapes.toArray(new IPathShape[0]));
            layer.update();
            newPsd.save(outputFile);
        }
        try (PsdImage image = (PsdImage) Image.load(outputFile)) {
            assertAreEqual(2, image.getLayers().length);
            ShapeLayer shapeLayer = (ShapeLayer) image.getLayers()[1];
            ColorFillSettings internalFill = (ColorFillSettings) shapeLayer.getFill();
            IStrokeSettings strokeSettings = shapeLayer.getStroke();
            ColorFillSettings strokeFill = (ColorFillSettings) strokeSettings.getFill();
            assertAreEqual(1, shapeLayer.getPath().getItems().length); // 1 Shape
            assertAreEqual(3, shapeLayer.getPath().getItems()[0].getItems().length); // 3 knots in a shape
            assertAreEqual(-16127182, internalFill.getColor().toArgb()); // ff09eb32
            assertAreEqual(7.41, strokeSettings.getSize());
            assertAreEqual(false, strokeSettings.getEnabled());
            assertAreEqual(StrokePosition.Center, strokeSettings.getLineAlignment());
            assertAreEqual(LineCapType.ButtCap, strokeSettings.getLineCap());
            assertAreEqual(LineJoinType.MiterJoin, strokeSettings.getLineJoin());
            assertAreEqual(-16777216, strokeFill.getColor().toArgb()); // ff000000
        }
    }
    static PathShape generateNewShape(Size imageSize) {
        PathShape newShape = new PathShape();
        PointF point1 = new PointF(20, 100);
        PointF point2 = new PointF(200, 100);
        PointF point3 = new PointF(300, 10);
        BezierKnotRecord firstBezierKnotRecord = new BezierKnotRecord();
        firstBezierKnotRecord.setLinked(true);
        firstBezierKnotRecord.setPoints(new Point[]{
                pointFToResourcePoint(point1, imageSize),
                pointFToResourcePoint(point1, imageSize),
                pointFToResourcePoint(point1, imageSize)
        });
        BezierKnotRecord secondBezierKnotRecord = new BezierKnotRecord();
        secondBezierKnotRecord.setLinked(true);
        secondBezierKnotRecord.setPoints(new Point[]{
                pointFToResourcePoint(point2, imageSize),
                pointFToResourcePoint(point2, imageSize),
                pointFToResourcePoint(point2, imageSize)
        });
        BezierKnotRecord thirdBezierKnotRecord = new BezierKnotRecord();
        thirdBezierKnotRecord.setLinked(true);
        thirdBezierKnotRecord.setPoints(new Point[]{
                pointFToResourcePoint(point3, imageSize),
                pointFToResourcePoint(point3, imageSize),
                pointFToResourcePoint(point3, imageSize)
        });
        BezierKnotRecord[] bezierKnots = new BezierKnotRecord[]{
                firstBezierKnotRecord,
                secondBezierKnotRecord,
                thirdBezierKnotRecord
        };
        newShape.setItems(bezierKnots);
        return newShape;
    }
    static Point pointFToResourcePoint(PointF point, Size imageSize) {
        return new Point(
                Math.round(point.getY() * (IMG_TO_PSD_RATIO / imageSize.getHeight())),
                Math.round(point.getX() * (IMG_TO_PSD_RATIO / imageSize.getWidth())));
    }
    static void assertAreEqual(Object expected, Object actual) {
        assertAreEqual(expected, actual, "Objects are not equal.");
    }
    static void assertAreEqual(Object expected, Object actual, String message) {
        if (!expected.equals(actual)) {
            throw new IllegalArgumentException(message);
        }
    }PSDJAVA-613. Perbaikan konversi file Psd dari RGB ke CMYK
    public static void main(String[] args) {
        // Periksa bahwa file psd yang dikonversi ke CMYK + RLE 4 saluran dari file psd dalam RGB + RLE 4 saluran, benar-benar memiliki 4 saluran
        // dan HasTransparencyData == false.
        String sourceFile = "src/main/resources/frog_nosymb.psd";
        String outputFile = "src/main/resources/frog_nosymb_output.psd";
        try (PsdImage psdImage = (PsdImage) Image.load(sourceFile)) {
            psdImage.setTransparencyData(false);
            PsdOptions psdOptions = new PsdOptions(psdImage);
            psdOptions.setColorMode(ColorModes.Cmyk);
            psdOptions.setCompressionMethod(CompressionMethod.RLE);
            psdOptions.setChannelsCount((short) 4);
            psdImage.save(outputFile, psdOptions);
        }
        try (PsdImage psdImage = (PsdImage) Image.load(outputFile)) {
            assertAreEqual(false, psdImage.hasTransparencyData());
            assertAreEqual(4, psdImage.getLayers()[0].getChannelsCount());
        }
    }
    static void assertAreEqual(Object expected, Object actual) {
        assertAreEqual(expected, actual, "Objects are not equal.");
    }
    static void assertAreEqual(Object expected, Object actual, String message) {
        if (!expected.equals(actual)) {
            throw new IllegalArgumentException(message);
        }
    }PSDJAVA-614. File PSD tertentu tidak dapat diekspor menggunakan Aspose.PSD
        String sourceFile = "src/main/resources/1966source.psd";
        String outputPng = "src/main/resources/output.png";
        PsdLoadOptions psdLoadOptions = new PsdLoadOptions();
        psdLoadOptions.setLoadEffectsResource(true);
        try (PsdImage psdImage = (PsdImage) Image.load(sourceFile, psdLoadOptions)) {
            psdImage.save(outputPng, new PngOptions());
        }