diff --git a/Examples/.gitignore b/Examples/.gitignore
index a6f89c2..69d07b8 100644
--- a/Examples/.gitignore
+++ b/Examples/.gitignore
@@ -1 +1,3 @@
-/target/
\ No newline at end of file
+.idea
+/target/
+*.iml
\ No newline at end of file
diff --git a/Examples/pom.xml b/Examples/pom.xml
index 7e63627..9a5cc59 100644
--- a/Examples/pom.xml
+++ b/Examples/pom.xml
@@ -17,14 +17,14 @@
com.aspose
aspose-psd
- 20.5
+ 20.9
javadoc
com.aspose
aspose-psd
- 20.5
+ 20.9
jdk16
diff --git a/Examples/src/main/java/com/aspose/psd/examples/Conversion/SettingForReplacingMissingFonts.java b/Examples/src/main/java/com/aspose/psd/examples/Conversion/SettingForReplacingMissingFonts.java
index 3ea1154..0642c6a 100644
--- a/Examples/src/main/java/com/aspose/psd/examples/Conversion/SettingForReplacingMissingFonts.java
+++ b/Examples/src/main/java/com/aspose/psd/examples/Conversion/SettingForReplacingMissingFonts.java
@@ -27,16 +27,16 @@ public static void main(String[] args)
String destName = dataDir + "result.png";
PsdLoadOptions loadOptions = new PsdLoadOptions();
- loadOptions.setDefaultReplacementFont("Arial");
// load PSD image and replace the non found fonts.
Image image = Image.load(sourceFile,loadOptions);
PsdImage psdImage = (PsdImage)image;
- PngOptions Options = new PngOptions();
- Options.setColorType(PngColorType.TruecolorWithAlpha);
- psdImage.save(destName, Options);
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
+ pngOptions.setDefaultReplacementFont("Arial");
+ psdImage.save(destName, pngOptions);
//ExEnd:SettingForReplacingMissingFonts
diff --git a/Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/FontReplacement.java b/Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/FontReplacement.java
index bd288c5..9087ae3 100644
--- a/Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/FontReplacement.java
+++ b/Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/FontReplacement.java
@@ -13,24 +13,24 @@
/**
*
- *
*/
-public class FontReplacement {
- public static void main(String[] args)
+public class FontReplacement
+{
+ public static void main(String[] args)
{
- //ExStart:FontReplacement
- String dataDir = Utils.getDataDir(FontReplacement.class) + "DrawingAndFormattingImages/";
-
- // Load an image in an instance of image and setting default replacement font.
- PsdLoadOptions psdLoadOptions = new PsdLoadOptions();
- psdLoadOptions.setDefaultReplacementFont("Arial");
+ //ExStart:FontReplacement
+ String dataDir = Utils.getDataDir(FontReplacement.class) + "DrawingAndFormattingImages/";
- PsdImage psdImage = (PsdImage)Image.load(dataDir +"Cloud_AzPlat_Banner3A_SB_EN_US_160x600_chinese_font.psd", psdLoadOptions);
-
- PngOptions pngOptions = new PngOptions();
- psdImage.save(dataDir + "replaced_font.png", pngOptions);
-
+ // Load an image in an instance of image and setting default replacement font.
+ PsdLoadOptions psdLoadOptions = new PsdLoadOptions();
- //ExEnd:FontReplacement
+ PsdImage psdImage = (PsdImage)Image.load(dataDir + "Cloud_AzPlat_Banner3A_SB_EN_US_160x600_chinese_font.psd", psdLoadOptions);
+
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setDefaultReplacementFont("Arial");
+ psdImage.save(dataDir + "replaced_font.png", pngOptions);
+
+
+ //ExEnd:FontReplacement
}
}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/AddStrokeEffectAtRuntime.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/AddStrokeEffectAtRuntime.java
new file mode 100644
index 0000000..63f0ee4
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/AddStrokeEffectAtRuntime.java
@@ -0,0 +1,115 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.Color;
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.fillsettings.FillType;
+import com.aspose.psd.fileformats.psd.layers.fillsettings.IColorFillSettings;
+import com.aspose.psd.fileformats.psd.layers.fillsettings.IGradientFillSettings;
+import com.aspose.psd.fileformats.psd.layers.fillsettings.IPatternFillSettings;
+import com.aspose.psd.fileformats.psd.layers.layereffects.StrokeEffect;
+import com.aspose.psd.fileformats.psd.layers.layereffects.StrokePosition;
+import com.aspose.psd.imageloadoptions.PsdLoadOptions;
+import com.aspose.psd.imageoptions.PngOptions;
+
+/**
+ * This example shows how to add a stroke effect (border) to existing layers of PSD file in Java. There are three types
+ * of the stroke: color, gradient and pattern. Each of the type has three ways (positions) in which the stroke is
+ * rendered: inside, center and outside. This example demonstrates usage of all these cases.
+ */
+public class AddStrokeEffectAtRuntime
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.getDataDir(AddStrokeEffectAtRuntime.class) + "ModifyingAndConvertingImages/PSD/AddStrokeEffectAtRuntime/";
+ String outputDir = Utils.GetDataDir_Output();
+ //ExStart:AddStrokeEffectAtRuntime
+ String srcPsdPath = dataDir + "StrokeEffectsSource.psd";
+ String dstPngPath = outputDir + "output.png";
+
+ PsdLoadOptions psdLoadOptions = new PsdLoadOptions();
+ psdLoadOptions.setLoadEffectsResource(true);
+ PsdImage psdImage = (PsdImage)Image.load(srcPsdPath, psdLoadOptions);
+ try
+ {
+ StrokeEffect strokeEffect;
+ IColorFillSettings colorFillSettings;
+ IGradientFillSettings gradientFillSettings;
+ IPatternFillSettings patternFillSettings;
+
+ // 1. Adds Color fill, at position Inside
+ strokeEffect = psdImage.getLayers()[1].getBlendingOptions().addStroke(FillType.Color);
+ strokeEffect.setSize(7);
+ strokeEffect.setPosition(StrokePosition.Inside);
+ colorFillSettings = (IColorFillSettings)strokeEffect.getFillSettings();
+ colorFillSettings.setColor(Color.getGreen());
+
+ // 2. Adds Color fill, at position Outside
+ strokeEffect = psdImage.getLayers()[2].getBlendingOptions().addStroke(FillType.Color);
+ strokeEffect.setSize(7);
+ strokeEffect.setPosition(StrokePosition.Outside);
+ colorFillSettings = (IColorFillSettings)strokeEffect.getFillSettings();
+ colorFillSettings.setColor(Color.getGreen());
+
+ // 3. Adds Color fill, at position Center
+ strokeEffect = psdImage.getLayers()[3].getBlendingOptions().addStroke(FillType.Color);
+ strokeEffect.setSize(7);
+ strokeEffect.setPosition(StrokePosition.Center);
+ colorFillSettings = (IColorFillSettings)strokeEffect.getFillSettings();
+ colorFillSettings.setColor(Color.getGreen());
+
+ // 4. Adds Gradient fill, at position Inside
+ strokeEffect = psdImage.getLayers()[4].getBlendingOptions().addStroke(FillType.Gradient);
+ strokeEffect.setSize(5);
+ strokeEffect.setPosition(StrokePosition.Inside);
+ gradientFillSettings = (IGradientFillSettings)strokeEffect.getFillSettings();
+ gradientFillSettings.setAlignWithLayer(false);
+ gradientFillSettings.setAngle(90);
+
+ // 5. Adds Gradient fill, at position Outside
+ strokeEffect = psdImage.getLayers()[5].getBlendingOptions().addStroke(FillType.Gradient);
+ strokeEffect.setSize(5);
+ strokeEffect.setPosition(StrokePosition.Outside);
+ gradientFillSettings = (IGradientFillSettings)strokeEffect.getFillSettings();
+ gradientFillSettings.setAlignWithLayer(true);
+ gradientFillSettings.setAngle(90);
+
+ // 6. Adds Gradient fill, at position Center
+ strokeEffect = psdImage.getLayers()[6].getBlendingOptions().addStroke(FillType.Gradient);
+ strokeEffect.setSize(5);
+ strokeEffect.setPosition(StrokePosition.Center);
+ gradientFillSettings = (IGradientFillSettings)strokeEffect.getFillSettings();
+ gradientFillSettings.setAlignWithLayer(true);
+ gradientFillSettings.setAngle(0);
+
+ // 7. Adds Pattern fill, at position Inside
+ strokeEffect = psdImage.getLayers()[7].getBlendingOptions().addStroke(FillType.Pattern);
+ strokeEffect.setSize(5);
+ strokeEffect.setPosition(StrokePosition.Inside);
+ patternFillSettings = (IPatternFillSettings)strokeEffect.getFillSettings();
+ patternFillSettings.setScale(200);
+
+ // 8. Adds Pattern fill, at position Outside
+ strokeEffect = psdImage.getLayers()[8].getBlendingOptions().addStroke(FillType.Pattern);
+ strokeEffect.setSize(10);
+ strokeEffect.setPosition(StrokePosition.Outside);
+ patternFillSettings = (IPatternFillSettings)strokeEffect.getFillSettings();
+ patternFillSettings.setScale(100);
+
+ // 9. Adds Pattern fill, at position Center
+ strokeEffect = psdImage.getLayers()[9].getBlendingOptions().addStroke(FillType.Pattern);
+ strokeEffect.setSize(10);
+ strokeEffect.setPosition(StrokePosition.Center);
+ patternFillSettings = (IPatternFillSettings)strokeEffect.getFillSettings();
+ patternFillSettings.setScale(75);
+
+ psdImage.save(dstPngPath, new PngOptions());
+ }
+ finally
+ {
+ psdImage.dispose();
+ }
+ //ExEnd:AddStrokeEffectAtRuntime
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont.java
new file mode 100644
index 0000000..2736f86
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont.java
@@ -0,0 +1,52 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.tiff.enums.TiffExpectedFormat;
+import com.aspose.psd.imageoptions.JpegOptions;
+import com.aspose.psd.imageoptions.PngOptions;
+import com.aspose.psd.imageoptions.TiffOptions;
+
+/**
+ * This example demonstrates how to set a Default Replacement Font during saving the image. The program applies
+ * different default font replacements for different output files.
+ */
+public class SetDefaultReplacementFont
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.getResourcesDir() + "/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/";
+ String outputDir = Utils.GetDataDir_Output();
+ //ExStart:SetDefaultReplacementFont
+ // Please, don't install Konstanting Font, because this test should replace font that is not installed
+ String srcPsdPath = dataDir + "sample_konstanting.psd";
+ String[] dstPaths = new String[]
+ {
+ "replacedfont0.tiff",
+ "replacedfont1.png",
+ "replacedfont2.jpg"
+ };
+
+ // Load a PSD that require a font that is not installed
+ PsdImage image = (PsdImage)Image.load(srcPsdPath);
+ try
+ {
+ // This way you can use different fonts for different outputs
+ image.save(outputDir + dstPaths[0], new TiffOptions(TiffExpectedFormat.TiffJpegRgb));
+
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setDefaultReplacementFont("Verdana");
+ image.save(outputDir + dstPaths[1], pngOptions);
+
+ JpegOptions jpegOptions = new JpegOptions();
+ jpegOptions.setDefaultReplacementFont("Times New Roman");
+ image.save(outputDir + dstPaths[2], jpegOptions);
+ }
+ finally
+ {
+ image.dispose();
+ }
+ //ExEnd:SetDefaultReplacementFont
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportBritResource.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportBritResource.java
new file mode 100644
index 0000000..4d86c99
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportBritResource.java
@@ -0,0 +1,71 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.Layer;
+import com.aspose.psd.fileformats.psd.layers.LayerResource;
+import com.aspose.psd.fileformats.psd.layers.adjustmentlayers.BrightnessContrastLayer;
+import com.aspose.psd.fileformats.psd.layers.layerresources.BritResource;
+import com.aspose.psd.imageoptions.PsdOptions;
+
+/**
+ * This Example demonstrates how you can programmatically change the PSD Image Brightness/Contrast Layer Resource -
+ * BritResource. This is a Low-Level Aspose.PSD API. You can use Brightness/Contrast Layer through its API, which will
+ * be much easier, but direct PhotoShop resource editing gives you more control over the PSD file content.
+ */
+public class SupportBritResource
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.getResourcesDir() + "/ModifyingAndConvertingImages/PSD/SupportBritResource/";
+ String outputDir = Utils.GetDataDir_Output();
+ //ExStart:SupportBritResource
+ String srcPath = dataDir + "BrightnessContrastPS6.psd";
+ String dstPath = outputDir + "BrightnessContrastPS6_output.psd";
+
+ // Load a Photoshop document containing a Brightness / Contrast adjustment layer
+ PsdImage psdImage = (PsdImage)Image.load(srcPath);
+ try
+ {
+ // Search for BritResource
+ for (Layer layer : psdImage.getLayers())
+ {
+ if (layer instanceof BrightnessContrastLayer)
+ {
+ for (LayerResource layerResource : layer.getResources())
+ {
+ if (layerResource instanceof BritResource)
+ {
+ BritResource resource = (BritResource)layerResource;
+
+ // Verify resource properties
+ if (resource.getBrightness() != -40 ||
+ resource.getContrast() != 10 ||
+ resource.getLabColor() ||
+ resource.getMeanValueForBrightnessAndContrast() != 127)
+ {
+ throw new RuntimeException("BritResource was read wrong");
+ }
+
+ // Update resource properties
+ resource.setBrightness((short)25);
+ resource.setContrast((short)-14);
+ resource.setLabColor(true);
+ resource.setMeanValueForBrightnessAndContrast((short)200);
+
+ // Save a copy of the updated PSD
+ psdImage.save(dstPath, new PsdOptions());
+ break;
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ psdImage.dispose();
+ }
+ //ExEnd:SupportBritResource
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportEmbeddedSmartObjects.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportEmbeddedSmartObjects.java
new file mode 100644
index 0000000..f116db8
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportEmbeddedSmartObjects.java
@@ -0,0 +1,125 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.FileFormat;
+import com.aspose.psd.Image;
+import com.aspose.psd.RasterImage;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.png.PngColorType;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.smartobjects.SmartObjectLayer;
+import com.aspose.psd.imageoptions.PngOptions;
+import com.aspose.psd.imageoptions.PsdOptions;
+import com.aspose.psd.internal.Exceptions.FormatException;
+import com.aspose.psd.system.Enum;
+
+/**
+ * This example demonstrates how to change the smart object layer in the PSD file and export /
+ * update smart object original embedded contents.
+ */
+public class SupportEmbeddedSmartObjects
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.GetDataDir_PSD();
+ String outputDir = Utils.GetDataDir_Output();
+
+ //ExStart:SupportEmbeddedSmartObjects
+ class LocalScopeExtension
+ {
+ void assertAreEqual(Object actual, Object expected)
+ {
+ if (actual != null && !actual.equals(expected))
+ {
+ throw new FormatException(String.format("Actual value %s are not equal to expected %s.", actual, expected));
+ }
+ }
+ }
+ LocalScopeExtension $ = new LocalScopeExtension();
+
+ final int left = 0;
+ final int top = 0;
+ final int right = 0xb;
+ final int bottom = 0x10;
+ long[] formats = new long[]
+ {
+ FileFormat.Png, FileFormat.Psd, FileFormat.Bmp, FileFormat.Jpeg, FileFormat.Gif, FileFormat.Tiff, FileFormat.Jpeg2000
+ };
+
+ for (long format : formats)
+ {
+ // Resolve suitable text representation of the file format extension
+ String sFileFormat = Enum.getName(FileFormat.class, format).toLowerCase();
+ String fileFormatExt = format == FileFormat.Jpeg2000 ? "jpf" : sFileFormat;
+
+ // Build paths
+ String filename = "r-embedded-" + sFileFormat;
+ String srcPsdPath = dataDir + filename + ".psd";
+ String dstPngPath = outputDir + filename + "_output.png";
+ String dstPsdPath = outputDir + filename + "_output.psd";
+ String dstPngPath1 = outputDir + filename + "_updated.png";
+ String dstPsdPath1 = outputDir + filename + "_updated.psd";
+ String exportPath = outputDir + filename + "_export." + fileFormatExt;
+
+ // Load a predefined PSD file containing a smart object
+ PsdImage image = (PsdImage)Image.load(srcPsdPath);
+ try
+ {
+ // Find a smart object layer
+ SmartObjectLayer smartObjectLayer = (SmartObjectLayer)image.getLayers()[0];
+
+ // Verify its position
+ $.assertAreEqual(left, smartObjectLayer.getContentsBounds().getLeft());
+ $.assertAreEqual(top, smartObjectLayer.getContentsBounds().getTop());
+ $.assertAreEqual(right, smartObjectLayer.getContentsBounds().getRight());
+ $.assertAreEqual(bottom, smartObjectLayer.getContentsBounds().getBottom());
+
+ // Export the embedded smart object image into appropriate file format
+ smartObjectLayer.exportContents(exportPath);
+
+ // Check if the original image is saved correctly
+ image.save(dstPsdPath, new PsdOptions(image));
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
+ image.save(dstPngPath, pngOptions);
+
+ // Load smart object as a raster image
+ RasterImage innerImage = (RasterImage)smartObjectLayer.loadContents(null);
+ try
+ {
+ $.assertAreEqual(format, innerImage.getFileFormat());
+
+ // Load raster image pixels and invert them
+ int[] pixels = innerImage.loadArgb32Pixels(innerImage.getBounds());
+ for (int i = 0; i < pixels.length; i++)
+ {
+ int pixel = pixels[i];
+ int alpha = (int)(pixel & 0xff000000);
+ pixels[i] = (~(pixel & 0x00ffffff)) | alpha;
+ }
+
+ // Replace original pixels with inverted ones
+ innerImage.saveArgb32Pixels(innerImage.getBounds(), pixels);
+
+ // Replace the original smart object image with inverted one
+ smartObjectLayer.replaceContents(innerImage);
+ }
+ finally
+ {
+ innerImage.dispose();
+ }
+
+ // Check if the updated image is saved correctly
+ image.save(dstPsdPath1, new PsdOptions(image));
+ PngOptions pngOptions1 = new PngOptions();
+ pngOptions1.setColorType(PngColorType.TruecolorWithAlpha);
+ image.save(dstPngPath1, pngOptions1);
+
+ }
+ finally
+ {
+ image.dispose();
+ }
+ //ExEnd:SupportEmbeddedSmartObjects
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportLinkedSmartObjects.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportLinkedSmartObjects.java
new file mode 100644
index 0000000..408fd42
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportLinkedSmartObjects.java
@@ -0,0 +1,419 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.FileFormat;
+import com.aspose.psd.Image;
+import com.aspose.psd.LoadOptions;
+import com.aspose.psd.RasterImage;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.png.PngColorType;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.Layer;
+import com.aspose.psd.fileformats.psd.layers.smartobjects.SmartObjectLayer;
+import com.aspose.psd.fileformats.psd.layers.smartobjects.SmartObjectType;
+import com.aspose.psd.imageoptions.PngOptions;
+import com.aspose.psd.imageoptions.PsdOptions;
+import com.aspose.psd.internal.Exceptions.FormatException;
+import com.aspose.psd.system.Enum;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Array;
+
+/**
+ * This is a complex example because it contains a few sub-examples. All these sub-examples
+ * demonstrate usage of linked smart objects and their APIs.
+ */
+public class SupportLinkedSmartObjects
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.GetDataDir_PSD();
+ String outputDir = Utils.GetDataDir_Output();
+
+ //ExStart:SupportLinkedSmartObjects
+ class LocalScopeExtension
+ {
+ boolean equals(Object a, Object b)
+ {
+ return (a == b) || (a != null && a.equals(b));
+ }
+
+ void assertAreEqual(Object actual, Object expected)
+ {
+ boolean areEqual = equals(actual, expected);
+ // Compare arrays if any
+ if (!areEqual &&
+ (actual != null && actual.getClass().isArray()) &&
+ (expected != null && expected.getClass().isArray()))
+ {
+ int length;
+ // Use Reflection for accessing arrays to support arrays of primitives
+ if ((length = Array.getLength(actual)) == Array.getLength(expected))
+ {
+ for (int i = 0; i < length; i++)
+ {
+ if (!equals(Array.get(actual, i), Array.get(expected, i)))
+ {
+ break;
+ }
+ }
+
+ areEqual = true;
+ }
+ }
+
+ if (!areEqual)
+ {
+ throw new FormatException(
+ String.format("Actual value %s are not equal to expected %s.", actual, expected));
+ }
+ }
+
+ void exampleOfUpdatingSmartObjectLayer(
+ String filePath,
+ int contentsLength,
+ int left,
+ int top,
+ int right,
+ int bottom,
+ long format)
+ {
+ // This example demonstrates how to change the smart object layer in the PSD file and export / update its contents.
+ filePath = dataDir + filePath;
+ final String fileName = getFileNameWithoutExtension(filePath);
+ String pngOutputPath = outputDir + fileName + "_modified.png";
+ String png2OutputPath = outputDir + fileName + "_updated_modified.png";
+ String psd2OutputPath = outputDir + fileName + "_updated_modified.psd";
+ String exportPath = outputDir + fileName + "_exported." + getFormatExt(format);
+
+ PsdImage image = (PsdImage)Image.load(filePath);
+ try
+ {
+ SmartObjectLayer smartObjectLayer = (SmartObjectLayer)image.getLayers()[0];
+
+ // Verify the content length and the layer bounds
+ assertAreEqual(contentsLength, smartObjectLayer.getContents().length);
+ assertAreEqual(left, smartObjectLayer.getContentsBounds().getLeft());
+ assertAreEqual(top, smartObjectLayer.getContentsBounds().getTop());
+ assertAreEqual(right, smartObjectLayer.getContentsBounds().getRight());
+ assertAreEqual(bottom, smartObjectLayer.getContentsBounds().getBottom());
+
+ int contentType = smartObjectLayer.getContentType();
+ if (contentType == SmartObjectType.AvailableLinked)
+ {
+ // Let's export the external smart object image from the PSD smart object layer to a new location
+ // because we are going to modify it.
+ smartObjectLayer.exportContents(exportPath);
+ smartObjectLayer.relinkToFile(exportPath);
+
+ }
+
+ // Let's invert the content of the smart object: inner (not cached) image
+ RasterImage innerImage = (RasterImage)smartObjectLayer.loadContents(new LoadOptions());
+ try
+ {
+ invertImage(innerImage);
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ try
+ {
+ innerImage.save(stream);
+ smartObjectLayer.setContents(stream.toByteArray());
+ }
+ finally
+ {
+ try
+ {
+ stream.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ finally
+ {
+ innerImage.dispose();
+ }
+
+ // Let's check whether the modified content does not affect rendering yet.
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
+ image.save(pngOutputPath, pngOptions);
+
+ smartObjectLayer.updateModifiedContent();
+
+ // Let's check whether the updated content affects rendering and the psd image is saved correctly
+ image.save(psd2OutputPath, new PsdOptions(image));
+ PngOptions pngOptions1 = new PngOptions();
+ pngOptions1.setColorType(PngColorType.TruecolorWithAlpha);
+ image.save(png2OutputPath, pngOptions1);
+
+ }
+ finally
+ {
+ image.dispose();
+ }
+ }
+
+ void exampleOfEmbeddedSmartObjectLayerToLinkedConversion(
+ String filePath,
+ int contentsLength,
+ int left,
+ int top,
+ int right,
+ int bottom,
+ long format)
+ {
+ // This demonstrates how to convert an embedded smart object layer in the PSD file to external one.
+ filePath = dataDir + filePath;
+ String formatExt = getFormatExt(format);
+ String fileName = getFileNameWithoutExtension(filePath);
+ String pngOutputPath = outputDir + fileName + "_to_external.png";
+ String psdOutputPath = outputDir + fileName + "_to_external.psd";
+ String externalPath = outputDir + fileName + "_external." + formatExt;
+
+ PsdImage image = (PsdImage)Image.load(filePath);
+ try
+ {
+ SmartObjectLayer smartObjectLayer = (SmartObjectLayer)image.getLayers()[0];
+ smartObjectLayer.convertToLinked(externalPath);
+
+ assertAreEqual(contentsLength, smartObjectLayer.getContents().length);
+ assertAreEqual(left, smartObjectLayer.getContentsBounds().getLeft());
+ assertAreEqual(top, smartObjectLayer.getContentsBounds().getTop());
+ assertAreEqual(right, smartObjectLayer.getContentsBounds().getRight());
+ assertAreEqual(bottom, smartObjectLayer.getContentsBounds().getBottom());
+ assertAreEqual(SmartObjectType.AvailableLinked, smartObjectLayer.getContentType());
+
+ // Let's check if the converted image is saved correctly
+ image.save(psdOutputPath, new PsdOptions(image));
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
+ image.save(pngOutputPath, pngOptions);
+
+ }
+ finally
+ {
+ image.dispose();
+ }
+
+ PsdImage image1 = (PsdImage)Image.load(psdOutputPath);
+ try
+ {
+ SmartObjectLayer smartObjectLayer = (SmartObjectLayer)image1.getLayers()[0];
+ assertAreEqual(contentsLength, smartObjectLayer.getContents().length);
+ assertAreEqual(left, smartObjectLayer.getContentsBounds().getLeft());
+ assertAreEqual(top, smartObjectLayer.getContentsBounds().getTop());
+ assertAreEqual(right, smartObjectLayer.getContentsBounds().getRight());
+ assertAreEqual(bottom, smartObjectLayer.getContentsBounds().getBottom());
+ assertAreEqual(SmartObjectType.AvailableLinked, smartObjectLayer.getContentType());
+ }
+ finally
+ {
+ image1.dispose();
+ }
+ }
+
+ void exampleOfLinkedSmartObjectLayerToEmbeddedConversion(
+ String filePath,
+ int contentsLength,
+ int left,
+ int top,
+ int right,
+ int bottom,
+ long format)
+ {
+ filePath = dataDir + filePath;
+ String fileName = getFileNameWithoutExtension(filePath);
+ String pngOutputPath = outputDir + fileName + "_to_embedded.png";
+ String psdOutputPath = outputDir + fileName + "_to_embedded.psd";
+
+ PsdImage image = (PsdImage)Image.load(filePath);
+ try
+ {
+ SmartObjectLayer smartObjectLayer0 = (SmartObjectLayer)image.getLayers()[0];
+ smartObjectLayer0.embedLinked();
+ assertAreEqual(contentsLength, smartObjectLayer0.getContents().length);
+ assertAreEqual(left, smartObjectLayer0.getContentsBounds().getLeft());
+ assertAreEqual(top, smartObjectLayer0.getContentsBounds().getTop());
+ assertAreEqual(right, smartObjectLayer0.getContentsBounds().getRight());
+ assertAreEqual(bottom, smartObjectLayer0.getContentsBounds().getBottom());
+ if (image.getLayers().length >= 2)
+ {
+ SmartObjectLayer smartObjectLayer1 = (SmartObjectLayer)image.getLayers()[1];
+ assertAreEqual(SmartObjectType.Embedded, smartObjectLayer0.getContentType());
+ assertAreEqual(SmartObjectType.AvailableLinked, smartObjectLayer1.getContentType());
+
+ image.getSmartObjectProvider().embedAllLinked();
+ for (Layer layer : image.getLayers())
+ {
+ SmartObjectLayer smartLayer = (SmartObjectLayer)layer;
+ if (smartLayer != null)
+ {
+ assertAreEqual(SmartObjectType.Embedded, smartLayer.getContentType());
+ }
+ }
+ }
+
+ // Let's check if the converted image is saved correctly
+ image.save(psdOutputPath, new PsdOptions(image));
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
+ image.save(pngOutputPath, pngOptions);
+
+ }
+ finally
+ {
+ image.dispose();
+ }
+
+ PsdImage image1 = (PsdImage)Image.load(psdOutputPath);
+ try
+ {
+ SmartObjectLayer smartObjectLayer = (SmartObjectLayer)image1.getLayers()[0];
+ assertAreEqual(contentsLength, smartObjectLayer.getContents().length);
+ assertAreEqual(left, smartObjectLayer.getContentsBounds().getLeft());
+ assertAreEqual(top, smartObjectLayer.getContentsBounds().getTop());
+ assertAreEqual(right, smartObjectLayer.getContentsBounds().getRight());
+ assertAreEqual(bottom, smartObjectLayer.getContentsBounds().getBottom());
+ assertAreEqual(SmartObjectType.Embedded, smartObjectLayer.getContentType());
+ }
+ finally
+ {
+ image1.dispose();
+ }
+ }
+
+ void exampleOfExternalSmartObjectLayerSupport(String filePath, int contentsLength, int left, int top, int right, int bottom, long format)
+ {
+ filePath = dataDir + filePath;
+ String formatExt = getFormatExt(format);
+ String fileName = getFileNameWithoutExtension(filePath);
+ String pngOutputPath = outputDir + fileName + ".png";
+ String psdOutputPath = outputDir + fileName + ".psd";
+ String linkOutputPath = outputDir + fileName + "_inverted." + formatExt;
+ String png2OutputPath = outputDir + fileName + "_updated.png";
+ String psd2OutputPath = outputDir + fileName + "_updated.psd";
+ String exportPath = outputDir + fileName + "_export." + formatExt;
+
+ PsdImage image = (PsdImage)Image.load(filePath);
+ try
+ {
+ SmartObjectLayer smartObjectLayer = (SmartObjectLayer)image.getLayers()[image.getLayers().length - 1];
+ assertAreEqual(left, smartObjectLayer.getContentsBounds().getLeft());
+ assertAreEqual(top, smartObjectLayer.getContentsBounds().getTop());
+ assertAreEqual(right, smartObjectLayer.getContentsBounds().getRight());
+ assertAreEqual(bottom, smartObjectLayer.getContentsBounds().getBottom());
+ assertAreEqual(contentsLength, smartObjectLayer.getContents().length);
+ assertAreEqual(SmartObjectType.AvailableLinked, smartObjectLayer.getContentType());
+
+ // Let's export the linked smart object image from the PSD smart object layer
+ smartObjectLayer.exportContents(exportPath);
+
+ // Let's check if the original image is saved correctly
+ image.save(psdOutputPath, new PsdOptions(image));
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
+ image.save(pngOutputPath, pngOptions);
+
+ RasterImage innerImage = (RasterImage)smartObjectLayer.loadContents(null);
+ try
+ {
+ assertAreEqual(format, innerImage.getFileFormat());
+
+ // Let's invert the linked smart object image
+ invertImage(innerImage);
+ innerImage.save(linkOutputPath);
+
+ // Let's replace the linked smart object image in the PSD layer
+ smartObjectLayer.replaceContents(linkOutputPath);
+ }
+ finally
+ {
+ innerImage.dispose();
+ }
+
+ // Let's check if the updated image is saved correctly
+ image.save(psd2OutputPath, new PsdOptions(image));
+ PngOptions pngOptions1 = new PngOptions();
+ pngOptions1.setColorType(PngColorType.TruecolorWithAlpha);
+ image.save(png2OutputPath, pngOptions1);
+
+ }
+ finally
+ {
+ image.dispose();
+ }
+ }
+
+ // Inverts the image.
+ void invertImage(RasterImage innerImage)
+ {
+ if (innerImage instanceof PsdImage)
+ {
+ PsdImage innerPsdImage = (PsdImage)innerImage;
+ invertRasterImage(innerPsdImage.getLayers()[0]);
+ }
+ else
+ {
+ invertRasterImage(innerImage);
+ }
+ }
+
+ // Inverts the raster image.
+ void invertRasterImage(RasterImage innerImage)
+ {
+ int[] pixels = innerImage.loadArgb32Pixels(innerImage.getBounds());
+ for (int i = 0; i < pixels.length; i++)
+ {
+ int pixel = pixels[i];
+ int alpha = (int)(pixel & 0xff000000);
+ pixels[i] = (~(pixel & 0x00ffffff)) | alpha;
+ }
+
+ innerImage.saveArgb32Pixels(innerImage.getBounds(), pixels);
+ }
+
+ // Gets the format extension.
+ String getFormatExt(long format)
+ {
+ String formatExt = format == FileFormat.Jpeg2000 ? "jpf" : Enum.getName(FileFormat.class, format).toLowerCase();
+ return formatExt;
+ }
+
+ String getFileNameWithoutExtension(String filePath)
+ {
+ return new File(filePath).getName().split("\\.")[0];
+ }
+ }
+ LocalScopeExtension $ = new LocalScopeExtension();
+
+ // This example demonstrates how to update the external or embedded smart object layer using these methods:
+ // RelinkToFile, UpdateModifiedContent, ExportContents
+ $.exampleOfUpdatingSmartObjectLayer("rgb8_2x2_linked2.psd", 0x53, 0, 0, 2, 2, FileFormat.Png);
+ $.exampleOfUpdatingSmartObjectLayer("r-embedded-png.psd", 0x207, 0, 0, 0xb, 0x10, FileFormat.Png);
+
+ // This example demonstrates how to convert the embedded smart object to external linked contents using the ConvertToLinked method.
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("new_panama-papers-4.psd", 0x10caa, 0, 0, 0x280, 0x169, FileFormat.Jpeg);
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("r3-embedded.psd", 0x207, 0, 0, 0xb, 0x10, FileFormat.Png);
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("r-embedded-tiff.psd", 0xca94, 0, 0, 0xb, 0x10, FileFormat.Tiff);
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("r-embedded-bmp.psd", 0x278, 0, 0, 0xb, 0x10, FileFormat.Bmp);
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("r-embedded-gif.psd", 0x3ec, 0, 0, 0xb, 0x10, FileFormat.Gif);
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("r-embedded-jpeg.psd", 0x327, 0, 0, 0xb, 0x10, FileFormat.Jpeg);
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("r-embedded-jpeg2000.psd", 0x519f, 0, 0, 0xb, 0x10, FileFormat.Jpeg2000);
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("r-embedded-psd.psd", 0xc074, 0, 0, 0xb, 0x10, FileFormat.Psd);
+ $.exampleOfEmbeddedSmartObjectLayerToLinkedConversion("r-embedded-png.psd", 0x207, 0, 0, 0xb, 0x10, FileFormat.Png);
+
+ // This example demonstrates how to embed one external smart object layer or all linked layers in the PSD file using the EmbedLinked method.
+ $.exampleOfLinkedSmartObjectLayerToEmbeddedConversion("rgb8_2x2_linked.psd", 0x53, 0, 0, 2, 2, FileFormat.Png);
+ $.exampleOfLinkedSmartObjectLayerToEmbeddedConversion("rgb8_2x2_linked2.psd", 0x53, 0, 0, 2, 2, FileFormat.Png);
+
+ // This example demonstrates how to change the Adobe® Photoshop® external smart object layer and export / update its contents
+ // using the ExportContents and ReplaceContents methods.
+ $.exampleOfExternalSmartObjectLayerSupport("rgb8_2x2_linked.psd", 0x53, 0, 0, 2, 2, FileFormat.Png);
+ $.exampleOfExternalSmartObjectLayerSupport("rgb8_2x2_linked2.psd", 0x4aea, 0, 0, 10, 10, FileFormat.Psd);
+ //ExEnd:SupportLinkedSmartObjects
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportLnkeResource.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportLnkeResource.java
new file mode 100644
index 0000000..8e1ae50
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportLnkeResource.java
@@ -0,0 +1,203 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.png.PngColorType;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.LayerResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LinkDataSourceType;
+import com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LnkeResource;
+import com.aspose.psd.imageoptions.PngOptions;
+import com.aspose.psd.imageoptions.PsdOptions;
+import com.aspose.psd.internal.Exceptions.FormatException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ * An example of linking different types of assets (raster images, CC libraries) to PSD. Also API of LnkeResource is
+ * considered.
+ */
+public class SupportLnkeResource
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.getResourcesDir() + "/ModifyingAndConvertingImages/PSD/SupportLnkeResource/";
+ String outputDir = Utils.GetDataDir_Output();
+ //ExStart:SupportLnkeResource
+ // A class that keeps methods in the local scope
+ class LocalScopeExtension
+ {
+ void assertIsTrue(boolean condition)
+ {
+ if (!condition)
+ {
+ throw new FormatException("ExampleOfLnkEResourceSupport works incorrectly.");
+ }
+ }
+
+ void assertAreEqual(Object actual, Object expected)
+ {
+ assertIsTrue(actual != null && actual.equals(expected));
+ }
+
+ // This example demonstrates how to get and set properties of the Photoshop Psd LnkE
+ // Resource that contains information about an external linked file.
+ void exampleOfLnkEResourceSupport(
+ String fileName,
+ int length,
+ int length2,
+ int length3,
+ int length4,
+ String fullPath,
+ String date,
+ double assetModTime,
+ String childDocId,
+ boolean locked,
+ String uid,
+ String name,
+ String originalFileName,
+ String fileType,
+ long size)
+ {
+ String srcPsdPath = dataDir + fileName;
+ String dstPsdPath = outputDir + "out_" + fileName;
+ String dstPngPath = dstPsdPath.replace(".psd", ".png");
+
+ // Load a predefined PSD
+ PsdImage image = (PsdImage)Image.load(srcPsdPath);
+ try
+ {
+ // Search LnkeResource among global resources
+ LnkeResource lnkeResource = null;
+ for (LayerResource resource : image.getGlobalLayerResources())
+ {
+ if (resource instanceof LnkeResource)
+ {
+ lnkeResource = (LnkeResource)resource;
+
+ // Verify LnkeResource properties
+ assertAreEqual(lnkeResource.getLength(), length);
+ assertAreEqual(lnkeResource.get_Item(0).getUniqueId(), UUID.fromString(uid));
+ assertAreEqual(lnkeResource.get_Item(0).getFullPath(), fullPath);
+ assertAreEqual(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(lnkeResource.get_Item(0).getDate()), date);
+ assertAreEqual(lnkeResource.get_Item(0).getAssetModTime(), assetModTime);
+ assertAreEqual(lnkeResource.get_Item(0).getAssetLockedState(), locked);
+ assertAreEqual(lnkeResource.get_Item(0).getFileName(), name);
+ assertAreEqual(lnkeResource.get_Item(0).getFileSize(), size);
+ assertAreEqual(lnkeResource.get_Item(0).getChildDocId(), childDocId);
+ assertAreEqual(lnkeResource.get_Item(0).getVersion(), 7);
+ assertAreEqual(lnkeResource.get_Item(0).getFileType().trim(), fileType);
+ assertAreEqual(lnkeResource.get_Item(0).getFileCreator().trim(), "");
+ assertAreEqual(lnkeResource.get_Item(0).getOriginalFileName(), originalFileName);
+ assertAreEqual(lnkeResource.get_Item(0).getCompId(), -1);
+ assertAreEqual(lnkeResource.get_Item(0).getOriginalCompId(), -1);
+ assertIsTrue(lnkeResource.get_Item(0).hasFileOpenDescriptor());
+ assertIsTrue(!lnkeResource.isEmpty());
+ assertIsTrue(lnkeResource.get_Item(0).getType() == LinkDataSourceType.liFE);
+
+ // Update LnkeResource properties
+ lnkeResource.get_Item(0).setFullPath("file:///C:/Aspose/net/Aspose.Psd/test/testdata/Images/Psd/SmartObjects/rgb8_2x2.png");
+ assertAreEqual(lnkeResource.getLength(), length2);
+ lnkeResource.get_Item(0).setFileName("rgb8_2x23.png");
+ assertAreEqual(lnkeResource.getLength(), length3);
+ lnkeResource.get_Item(0).setChildDocId(UUID.randomUUID().toString());
+ assertAreEqual(lnkeResource.getLength(), length4);
+ lnkeResource.get_Item(0).setDate(new Date());
+ lnkeResource.get_Item(0).setAssetModTime(Double.MAX_VALUE);
+ lnkeResource.get_Item(0).setFileSize(Long.MAX_VALUE);
+ lnkeResource.get_Item(0).setFileType("test");
+ lnkeResource.get_Item(0).setFileCreator("file");
+ lnkeResource.get_Item(0).setCompId(Integer.MAX_VALUE);
+ break;
+ }
+ }
+
+ // Make sure LnkeResource is supported
+ assertIsTrue(lnkeResource != null);
+
+ // Save a copy of the loaded PSD
+ image.save(dstPsdPath, new PsdOptions(image));
+ }
+ finally
+ {
+ image.dispose();
+ }
+
+ // Load the saved copy
+ PsdImage image1 = (PsdImage)Image.load(dstPsdPath);
+ try
+ {
+ // Convert PSD to PNG file format (with alpha channel for transparency)
+ PngOptions pngOptions = new PngOptions();
+ pngOptions.setColorType(PngColorType.TruecolorWithAlpha);
+ image1.save(dstPngPath, pngOptions);
+ }
+ finally
+ {
+ image1.dispose();
+ }
+
+ }
+ }
+ LocalScopeExtension $ = new LocalScopeExtension();
+
+ // This example demonstrates how to get and set properties of the Psd LnkE Resource that
+ // contains information about external linked JPEG file.
+ $.exampleOfLnkEResourceSupport(
+ "photooverlay_5_new.psd",
+ 0x21c,
+ 0x26c,
+ 0x274,
+ 0x27c,
+ "file:///C:/Users/cvallejo/Desktop/photo.jpg",
+ "05/09/2017 22:24:51",
+ 0,
+ "F062B9DB73E8D124167A4186E54664B0",
+ false,
+ "02df245c-36a2-11e7-a9d8-fdb2b61f07a7",
+ "photo.jpg",
+ "photo.jpg",
+ "JPEG",
+ 0x1520d);
+
+ // This example demonstrates how to get and set properties of the PSD LnkE Resource that
+ // contains information about an external linked PNG file.
+ $.exampleOfLnkEResourceSupport(
+ "rgb8_2x2_linked.psd",
+ 0x284,
+ 0x290,
+ 0x294,
+ 0x2dc,
+ "file:///C:/Aspose/net/Aspose.Psd/test/testdata/Issues/PSDNET-491/rgb8_2x2.png",
+ "04/14/2020 14:23:44",
+ 0,
+ "",
+ false,
+ "5867318f-3174-9f41-abca-22f56a75247e",
+ "rgb8_2x2.png",
+ "rgb8_2x2.png",
+ "png",
+ 0x53);
+
+ // This example demonstrates how to get and set properties of the Photoshop Psd LnkE Resource
+ // that contains information about an external linked CC Libraries Asset.
+ $.exampleOfLnkEResourceSupport(
+ "rgb8_2x2_asset_linked.psd",
+ 0x398,
+ 0x38c,
+ 0x388,
+ 0x3d0,
+ "CC Libraries Asset “rgb8_2x2_linked/rgb8_2x2” (Feature is available in Photoshop CC 2015)",
+ "01/01/0001 00:00:00",
+ 1588890915488.0d,
+ "",
+ false,
+ "ec15f0a8-7f13-a640-b928-7d29c6e9859c",
+ "rgb8_2x2_linked",
+ "rgb8_2x2.png",
+ "png",
+ 0);
+ //ExEnd:SupportLnkeResource
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportNestedLayerGroups.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportNestedLayerGroups.java
new file mode 100644
index 0000000..2639933
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportNestedLayerGroups.java
@@ -0,0 +1,41 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.LayerGroup;
+
+/**
+ * This example demonstrates how to add a nested layer group to PSD programmatically.
+ */
+public class SupportNestedLayerGroups
+{
+ public static void main(String[] args)
+ {
+ String outputDir = Utils.GetDataDir_Output();
+ //ExStart:SupportNestedLayerGroups
+ String dstPsdPath = outputDir + "output.psd";
+
+ // Create an image with the size of 1x1 pixels to work with
+ PsdImage psdImage = new PsdImage(1, 1);
+ try
+ {
+ // Add a parent layer group ("true" means to open the layer group on start)
+ LayerGroup group1 = psdImage.addLayerGroup("Group 1", 0, true);
+ // Add a nested layer group
+ LayerGroup group2 = group1.addLayerGroup("Group 2", 0);
+
+ if (group1.getLayers().length != 2)
+ {
+ throw new RuntimeException("Group 1 must contain two layers of Group 2.");
+ }
+
+ // Verify that there are no exceptions on saving just created layer groups
+ psdImage.save(dstPsdPath);
+ }
+ finally
+ {
+ psdImage.dispose();
+ }
+ //ExEnd:SupportNestedLayerGroups
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportObjectArrayAndUnitArrayStructures.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportObjectArrayAndUnitArrayStructures.java
new file mode 100644
index 0000000..2b334dd
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportObjectArrayAndUnitArrayStructures.java
@@ -0,0 +1,93 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.Layer;
+import com.aspose.psd.fileformats.psd.layers.LayerResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.OSTypeStructure;
+import com.aspose.psd.fileformats.psd.layers.layerresources.smartobjectresources.PlLdResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.typetoolinfostructures.DescriptorStructure;
+import com.aspose.psd.fileformats.psd.layers.layerresources.typetoolinfostructures.ObjectArrayStructure;
+import com.aspose.psd.fileformats.psd.layers.layerresources.typetoolinfostructures.UnitArrayStructure;
+import com.aspose.psd.fileformats.psd.layers.layerresources.typetoolinfostructures.UnitTypes;
+import com.aspose.psd.internal.Exceptions.FormatException;
+
+/**
+ * This example proves that ObjectArrayStructure and UnitArrayStructure are supported by the library
+ * so that we can read and write them. The program walks through the hierarchy of resource
+ * structures in search of the valid UnitArrayStructure.
+ */
+public class SupportObjectArrayAndUnitArrayStructures
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.GetDataDir_PSD();
+
+ //ExStart:SupportObjectArrayAndUnitArrayStructures
+ // Define a local class just to keep reusable code (methods)
+ class LocalScopeExtension
+ {
+ void assertAreEqual(Object actual, Object expected)
+ {
+ if (!((actual == expected) || (actual != null && actual.equals(expected))))
+ {
+ throw new FormatException(String.format(
+ "Actual value %s are not equal to expected %s.", actual, expected));
+ }
+ }
+ }
+ LocalScopeExtension $ = new LocalScopeExtension();
+
+ String srcPsdPath = dataDir + "LayeredSmartObjects8bit2.psd";
+
+ // Load a predefine PSD file containing a smart object with PlLdResource
+ PsdImage image = (PsdImage)Image.load(srcPsdPath);
+ try
+ {
+ // Walk through the hierarchy of structures in search of UnitArrayStructure
+ UnitArrayStructure verticalStructure = null;
+ for (Layer imageLayer : image.getLayers())
+ {
+ for (LayerResource imageResource : imageLayer.getResources())
+ {
+ PlLdResource resource;
+ if (imageResource instanceof PlLdResource &&
+ (resource = (PlLdResource)imageResource).isCustom())
+ {
+ for (OSTypeStructure structure : resource.getItems())
+ {
+ if (structure.getKeyName().getClassName().equals("customEnvelopeWarp"))
+ {
+ // Make sure that the loaded file is what we expect
+ $.assertAreEqual(DescriptorStructure.class, structure.getClass());
+ DescriptorStructure custom = (DescriptorStructure)structure;
+ $.assertAreEqual(custom.getStructures().length, 1);
+ OSTypeStructure mesh = custom.getStructures()[0];
+ $.assertAreEqual(ObjectArrayStructure.class, mesh.getClass());
+ ObjectArrayStructure meshObjectArray = (ObjectArrayStructure)mesh;
+ $.assertAreEqual(meshObjectArray.getStructures().length, 2);
+ OSTypeStructure vertical = meshObjectArray.getStructures()[1];
+
+ // Finally verify and assign the found UnitArrayStructure
+ $.assertAreEqual(UnitArrayStructure.class, vertical.getClass());
+ verticalStructure = (UnitArrayStructure)vertical;
+ $.assertAreEqual(verticalStructure.getUnitType(), UnitTypes.Pixels);
+ $.assertAreEqual(verticalStructure.getValueCount(), 16);
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ $.assertAreEqual(true, verticalStructure != null);
+ }
+ finally
+ {
+ image.dispose();
+ }
+ //ExEnd:SupportObjectArrayAndUnitArrayStructures
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportPlLdResource.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportPlLdResource.java
new file mode 100644
index 0000000..4c61091
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportPlLdResource.java
@@ -0,0 +1,243 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.Layer;
+import com.aspose.psd.fileformats.psd.layers.LayerResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.smartobjectresources.PlLdResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.smartobjectresources.PlacedLayerType;
+import com.aspose.psd.fileformats.psd.layers.layerresources.typetoolinfostructures.UnitTypes;
+import com.aspose.psd.imageoptions.PsdOptions;
+import com.aspose.psd.internal.Exceptions.FormatException;
+
+import java.lang.reflect.Array;
+import java.util.UUID;
+
+/**
+ * This example shows how to get or set the Placed layer resource properties of the PSD file.
+ */
+public class SupportPlLdResource
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.GetDataDir_PSD();
+ String outputDir = Utils.GetDataDir_Output();
+
+ //ExStart:SupportPlLdResource
+ // Define a local class just to keep reusable code (methods)
+ class LocalScopeExtension
+ {
+ boolean equals(Object a, Object b)
+ {
+ return (a == b) || (a != null && a.equals(b));
+ }
+
+ void assertAreEqual(Object actual, Object expected)
+ {
+ boolean areEqual = equals(actual, expected);
+ // Compare arrays if any
+ if (!areEqual &&
+ (actual != null && actual.getClass().isArray()) &&
+ (expected != null && expected.getClass().isArray()))
+ {
+ int length;
+ // Use Reflection for accessing arrays to support arrays of primitives
+ if ((length = Array.getLength(actual)) == Array.getLength(expected))
+ {
+ for (int i = 0; i < length; i++)
+ {
+ if (!equals(Array.get(actual, i), Array.get(expected, i)))
+ {
+ break;
+ }
+ }
+
+ areEqual = true;
+ }
+ }
+
+ if (!areEqual)
+ {
+ throw new FormatException(
+ String.format("Actual value %s are not equal to expected %s.", actual, expected));
+ }
+ }
+ }
+ LocalScopeExtension $ = new LocalScopeExtension();
+
+ String srcPsdPath = dataDir + "LayeredSmartObjects8bit2.psd";
+ String dstPsdPath = outputDir + "LayeredSmartObjects8bit2_output.psd";
+ Object[][] expectedValues = new Object[][]
+ {
+ new Object[]
+ {
+ true,
+ "76f05a3b-7523-5e42-a1bb-27f4735bffa0",
+ 1,
+ 1,
+ 0x10,
+ PlacedLayerType.Raster,
+ new double[]
+ {
+ 29.937922786050663,
+ 95.419959734187131,
+ 126.85445817782261,
+ 1.0540625423957124,
+ 172.20861031651307,
+ 47.634102808208553,
+ 75.292074924741144,
+ 142
+ },
+ 0d,
+ 0d,
+ 0d,
+ 0d,
+ 0d,
+ 149d,
+ 310d,
+ 4,
+ 4,
+ UnitTypes.Pixels,
+ new double[]
+ {
+ 0.0d, 103.33333333333333d, 206.66666666666666d, 310.0d,
+ 0.0d, 103.33333333333333d, 206.66666666666666d, 310.0d,
+ 0.0d, 103.33333333333333d, 206.66666666666666d, 310.0d,
+ 0.0d, 103.33333333333333d, 206.66666666666666d, 310.0d
+ },
+ UnitTypes.Pixels,
+ new double[]
+ {
+ 0.0d, 0.0d, 0.0d, 0.0d,
+ 49.666666666666664d, 49.666666666666664d, 49.666666666666664d, 49.666666666666664d,
+ 99.333333333333329d, 99.333333333333329d, 99.333333333333329d, 99.333333333333329d,
+ 149, 149, 149, 149,
+ },
+ },
+ new Object[]
+ {
+ true,
+ "cf0477a8-8f92-ac4f-9462-f78e26234851",
+ 1,
+ 1,
+ 0x10,
+ PlacedLayerType.Raster,
+ new double[]
+ {
+ 37.900314592235681,
+ -0.32118219433001371,
+ 185.94210608826535,
+ 57.7076819802063,
+ 153.32047433609358,
+ 140.9311755779743,
+ 5.2786828400639294,
+ 82.902311403437977,
+ },
+ 0d,
+ 0d,
+ 0d,
+ 0d,
+ 0d,
+ 721d,
+ 1280d,
+ 4,
+ 4,
+ UnitTypes.Pixels,
+ new double[]
+ {
+ 0.0, 426.66666666666663, 853.33333333333326, 1280,
+ 0.0, 426.66666666666663, 853.33333333333326, 1280,
+ 0.0, 426.66666666666663, 853.33333333333326, 1280,
+ 0.0, 426.66666666666663, 853.33333333333326, 1280,
+ },
+ UnitTypes.Pixels,
+ new double[]
+ {
+ 0.0, 0.0, 0.0, 0.0,
+ 240.33333333333331, 240.33333333333331, 240.33333333333331, 240.33333333333331,
+ 480.66666666666663, 480.66666666666663, 480.66666666666663, 480.66666666666663,
+ 721, 721, 721, 721,
+ },
+ 0,
+ 0
+ }
+ };
+
+ // Load a predefined PSD file containing PlLdResource
+ PsdImage image = (PsdImage)Image.load(srcPsdPath);
+ try
+ {
+ PlLdResource resource = null;
+ int index = 0;
+ for (Layer imageLayer : image.getLayers())
+ {
+ for (LayerResource imageResource : imageLayer.getResources())
+ {
+ if (imageResource instanceof PlLdResource)
+ {
+ // Make sure the loaded resource is what we expect at the same time
+ // demonstrate API usage of PlLdResource
+ resource = (PlLdResource)imageResource;
+ Object[] expectedValue = expectedValues[index++];
+ $.assertAreEqual(expectedValue[0], resource.isCustom());
+ $.assertAreEqual(expectedValue[1], resource.getUniqueId().toString());
+ $.assertAreEqual(expectedValue[2], resource.getPageNumber());
+ $.assertAreEqual(expectedValue[3], resource.getTotalPages());
+ $.assertAreEqual(expectedValue[4], resource.getAntiAliasPolicy());
+ $.assertAreEqual(expectedValue[5], resource.getPlacedLayerType());
+ $.assertAreEqual(8, resource.getTransformMatrix().length);
+ $.assertAreEqual(expectedValue[6], resource.getTransformMatrix());
+ $.assertAreEqual(expectedValue[7], resource.getValue());
+ $.assertAreEqual(expectedValue[8], resource.getPerspective());
+ $.assertAreEqual(expectedValue[9], resource.getPerspectiveOther());
+ $.assertAreEqual(expectedValue[10], resource.getTop());
+ $.assertAreEqual(expectedValue[11], resource.getLeft());
+ $.assertAreEqual(expectedValue[12], resource.getBottom());
+ $.assertAreEqual(expectedValue[13], resource.getRight());
+ $.assertAreEqual(expectedValue[14], resource.getUOrder());
+ $.assertAreEqual(expectedValue[15], resource.getVOrder());
+ if (resource.isCustom())
+ {
+ $.assertAreEqual(expectedValue[16], resource.getHorizontalMeshPointUnit());
+ $.assertAreEqual(expectedValue[17], resource.getHorizontalMeshPoints());
+ $.assertAreEqual(expectedValue[18], resource.getVerticalMeshPointUnit());
+ $.assertAreEqual(expectedValue[19], resource.getVerticalMeshPoints());
+ double[] temp = resource.getVerticalMeshPoints();
+ resource.setVerticalMeshPoints(resource.getHorizontalMeshPoints());
+ resource.setHorizontalMeshPoints(temp);
+ }
+
+ // This values should be changed they are given just for an example,
+ // to demonstrate API usage of PlLdResource
+ resource.setUniqueId(UUID.randomUUID());
+ resource.setPageNumber(2);
+ resource.setTotalPages(3);
+ resource.setAntiAliasPolicy(30);
+ resource.setPlacedLayerType(PlacedLayerType.Vector);
+ resource.setValue(1.23456789);
+ resource.setPerspective(0.123456789);
+ resource.setPerspectiveOther(0.987654321);
+ resource.setTop(-126);
+ resource.setLeft(-215);
+ resource.setBottom(248);
+ resource.setRight(145);
+ resource.setUOrder(6);
+ resource.setVOrder(9);
+
+ break;
+ }
+ }
+ }
+
+ // Make sure the resource were found
+ $.assertAreEqual(true, resource != null);
+ image.save(dstPsdPath, new PsdOptions(image));
+ }
+ finally
+ {
+ image.dispose();
+ }
+ //ExEnd:SupportPlLdResource
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources.java
new file mode 100644
index 0000000..cfb4e49
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources.java
@@ -0,0 +1,244 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.FileStreamContainer;
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.LayerResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LiFdDataSource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.LinkDataSourceType;
+import com.aspose.psd.fileformats.psd.layers.layerresources.linkresources.Lnk2Resource;
+import com.aspose.psd.imageoptions.PsdOptions;
+import com.aspose.psd.internal.Exceptions.FormatException;
+import java.util.UUID;
+
+/**
+ * This example demonstrates how to work with smart object resources (basically Lnk2Resource). The program loads several
+ * Photoshop documents and exports their smart objects to raster file formats. Also the code demonstrates usage of
+ * public methods of Lnk2Resource.
+ */
+public class SupportSmartObjectResources
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.getDataDir(SupportSmartObjectResources.class) + "ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/";
+ String outputDir = Utils.GetDataDir_Output();
+ //ExStart:SupportSmartObjectResources
+ class LocalScopeExtension
+ {
+ void assertAreEqual(Object expected, Object actual)
+ {
+ if (!actual.equals(expected))
+ {
+ throw new FormatException(String.format("Actual value %s are not equal to expected %s.", actual, expected));
+ }
+ }
+
+ // Saves the data of a smart object into PSD file
+ void saveSmartObjectData(String filePath, byte[] data)
+ {
+ FileStreamContainer container = FileStreamContainer.createFileStream(filePath, false);
+ try
+ {
+ container.write(data);
+ }
+ finally
+ {
+ container.dispose();
+ }
+
+ }
+
+ // Loads the new data for a smart object from a file
+ byte[] loadNewData(String filePath)
+ {
+
+ FileStreamContainer container = FileStreamContainer.openFileStream(filePath);
+ try
+ {
+ return container.toBytes();
+ }
+ finally
+ {
+ container.dispose();
+ }
+ }
+
+ // Gets and sets properties of the PSD Lnk2 / Lnk3 Resource and its liFD data sources in PSD image
+ void exampleOfLnk2ResourceSupport(
+ String fileName,
+ int dataSourceCount,
+ int length,
+ int newLength,
+ Object[] dataSourceExpectedValues)
+ {
+ String srcPsdPath = dataDir + fileName;
+ String dstPsdPath = outputDir + "out_" + fileName;
+
+ PsdImage image = (PsdImage)Image.load(srcPsdPath);
+ try
+ {
+ // Search for Lnk2Resource
+ Lnk2Resource lnk2Resource = null;
+ for (LayerResource resource : image.getGlobalLayerResources())
+ {
+ if (resource instanceof Lnk2Resource)
+ {
+ lnk2Resource = (Lnk2Resource)resource;
+
+ // Verify properties of Lnk2Resource
+ assertAreEqual(lnk2Resource.getDataSourceCount(), dataSourceCount);
+ assertAreEqual(lnk2Resource.getLength(), length);
+ assertAreEqual(lnk2Resource.isEmpty(), false);
+
+ for (int i = 0; i < lnk2Resource.getDataSourceCount(); i++)
+ {
+ // Verify and change properties of LiFdDataSource
+ LiFdDataSource lifdSource = lnk2Resource.get_Item(i);
+ Object[] expected = (Object[])dataSourceExpectedValues[i];
+ assertAreEqual(LinkDataSourceType.liFD, lifdSource.getType());
+ assertAreEqual(expected[0], lifdSource.getUniqueId().toString());
+ assertAreEqual(expected[1], lifdSource.getOriginalFileName());
+ assertAreEqual(expected[2], lifdSource.getFileType().trim());
+ assertAreEqual(expected[3], lifdSource.getFileCreator().trim());
+ assertAreEqual(expected[4], lifdSource.getData().length);
+ assertAreEqual(expected[5], lifdSource.getAssetModTime());
+ assertAreEqual(expected[6], lifdSource.getChildDocId());
+ assertAreEqual(expected[7], lifdSource.getVersion());
+ assertAreEqual(expected[8], lifdSource.hasFileOpenDescriptor());
+ assertAreEqual(expected[9], lifdSource.getLength());
+
+ if (lifdSource.hasFileOpenDescriptor())
+ {
+ assertAreEqual(-1, lifdSource.getCompId());
+ assertAreEqual(-1, lifdSource.getOriginalCompId());
+ lifdSource.setCompId(Integer.MAX_VALUE);
+ }
+
+ saveSmartObjectData(
+ outputDir + fileName + "_" + lifdSource.getOriginalFileName(),
+ lifdSource.getData());
+ lifdSource.setData(loadNewData(dataDir + "new_" + lifdSource.getOriginalFileName()));
+ assertAreEqual(expected[10], lifdSource.getLength());
+
+ lifdSource.setChildDocId(UUID.randomUUID().toString());
+ lifdSource.setAssetModTime(Double.MAX_VALUE);
+ lifdSource.setFileType("test");
+ lifdSource.setFileCreator("me");
+ }
+
+ assertAreEqual(newLength, lnk2Resource.getLength());
+ break;
+ }
+ }
+
+ // Make sure that Lnk2Resource was found
+ assertAreEqual(true, lnk2Resource != null);
+
+ // Make a copy of the loaded PSD
+ if (image.getBitsPerChannel() < 32) // 32 bit per channel saving is not supported yet
+ {
+ image.save(dstPsdPath, new PsdOptions(image));
+ }
+ }
+ finally
+ {
+ image.dispose();
+ }
+ }
+ }
+ LocalScopeExtension $ = new LocalScopeExtension();
+
+ Object[] Lnk2ResourceSupportCases = new Object[]
+ {
+ new Object[]
+ {
+ "00af34a0-a90b-674d-a821-73ee508c5479",
+ "rgb8_2x2.png",
+ "png",
+ "",
+ 0x53,
+ 0d,
+ "",
+ 7,
+ true,
+ 0x124L,
+ 0x74cL
+ }
+ };
+
+ Object[] LayeredLnk2ResourceSupportCases = new Object[]
+ {
+ new Object[]
+ {
+ "69ac1c0d-1b74-fd49-9c7e-34a7aa6299ef",
+ "huset.jpg",
+ "JPEG",
+ "",
+ 0x9d46,
+ 0d,
+ "xmp.did:0F94B342065B11E395B1FD506DED6B07",
+ 7,
+ true,
+ 0x9E60L,
+ 0xc60cL
+ },
+ new Object[]
+ {
+ "5a7d1965-0eae-b24e-a82f-98c7646424c2",
+ "panama-papers.jpg",
+ "JPEG",
+ "",
+ 0xF56B,
+ 0d,
+ "xmp.did:BDE940CBF51B11E59D759CDA690663E3",
+ 7,
+ true,
+ 0xF694L,
+ 0x10dd4L
+ },
+ };
+
+ Object[] LayeredLnk3ResourceSupportCases = new Object[]
+ {
+ new Object[]
+ {
+ "2fd7ba52-0221-de4c-bdc4-1210580c6caa",
+ "panama-papers.jpg",
+ "JPEG",
+ "",
+ 0xF56B,
+ 0d,
+ "xmp.did:BDE940CBF51B11E59D759CDA690663E3",
+ 7,
+ true,
+ 0xF694l,
+ 0x10dd4L
+ },
+ new Object[]
+ {
+ "372d52eb-5825-8743-81a7-b6f32d51323d",
+ "huset.jpg",
+ "JPEG",
+ "",
+ 0x9d46,
+ 0d,
+ "xmp.did:0F94B342065B11E395B1FD506DED6B07",
+ 7,
+ true,
+ 0x9E60L,
+ 0xc60cL
+ },
+ };
+
+ // This example demonstrates how to get and set properties of the PSD Lnk2 Resource and its liFD data sources for 8 bit per channel.
+ $.exampleOfLnk2ResourceSupport("rgb8_2x2_embedded_png.psd", 1, 0x12C, 0x0000079c, Lnk2ResourceSupportCases);
+
+ // This example demonstrates how to get and set properties of the PSD Lnk3 Resource and its liFD data sources for 32 bit per channel.
+ $.exampleOfLnk2ResourceSupport("Layered PSD file smart objects.psd", 2, 0x19504, 0x0001d3e0, LayeredLnk3ResourceSupportCases);
+
+ // This example demonstrates how to get and set properties of the PSD Lnk2 Resource and its liFD data sources for 16 bit per channel.
+ $.exampleOfLnk2ResourceSupport("LayeredSmartObjects16bit.psd", 2, 0x19504, 0x0001d3e0, LayeredLnk2ResourceSupportCases);
+ //ExEnd:SupportSmartObjectResources
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSoLEResource.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSoLEResource.java
new file mode 100644
index 0000000..f9dc454
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSoLEResource.java
@@ -0,0 +1,363 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.Layer;
+import com.aspose.psd.fileformats.psd.layers.LayerResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.smartobjectresources.PlacedLayerType;
+import com.aspose.psd.fileformats.psd.layers.layerresources.smartobjectresources.SmartObjectResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.smartobjectresources.SoLeResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.typetoolinfostructures.UnitTypes;
+import com.aspose.psd.imageoptions.PsdOptions;
+import com.aspose.psd.internal.Exceptions.FormatException;
+
+import java.lang.reflect.Array;
+import java.util.UUID;
+
+/**
+ * This example demonstrates API usage of SoLEResource and proves that reading and writing
+ * SoLEResources works as expected so the resource is supported.
+ */
+public class SupportSoLEResource
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.GetDataDir_PSD();
+ String outputDir = Utils.GetDataDir_Output();
+
+ //ExStart:SupportSoLEResource
+ class LocalScopeExtension
+ {
+ void assertIsTrue(boolean condition)
+ {
+ if (!condition)
+ {
+ throw new FormatException("Expected true");
+ }
+ }
+
+ boolean equals(Object a, Object b)
+ {
+ return (a == b) || (a != null && a.equals(b));
+ }
+
+ void assertAreEqual(Object actual, Object expected)
+ {
+ boolean areEqual = equals(actual, expected);
+ // Compare arrays if any
+ if (!areEqual &&
+ (actual != null && actual.getClass().isArray()) &&
+ (expected != null && expected.getClass().isArray()))
+ {
+ int length;
+ // Use Reflection for accessing arrays to support arrays of primitives
+ if ((length = Array.getLength(actual)) == Array.getLength(expected))
+ {
+ for (int i = 0; i < length; i++)
+ {
+ if (!equals(Array.get(actual, i), Array.get(expected, i)))
+ {
+ break;
+ }
+ }
+
+ areEqual = true;
+ }
+ }
+
+ if (!areEqual)
+ {
+ throw new FormatException(
+ String.format("Actual value %s are not equal to expected %s.", actual, expected));
+ }
+ }
+
+ void checkSmartObjectResourceValues(Object[] expectedValue, SmartObjectResource resource)
+ {
+ assertAreEqual(expectedValue[0], resource.isCustom());
+ assertAreEqual(expectedValue[2], resource.getPageNumber());
+ assertAreEqual(expectedValue[3], resource.getTotalPages());
+ assertAreEqual(expectedValue[4], resource.getAntiAliasPolicy());
+ assertAreEqual(expectedValue[5], resource.getPlacedLayerType());
+ assertAreEqual(8, resource.getTransformMatrix().length);
+ assertAreEqual(expectedValue[6], resource.getTransformMatrix());
+ assertAreEqual(expectedValue[7], resource.getValue());
+ assertAreEqual(expectedValue[8], resource.getPerspective());
+ assertAreEqual(expectedValue[9], resource.getPerspectiveOther());
+ assertAreEqual(expectedValue[10], resource.getTop());
+ assertAreEqual(expectedValue[11], resource.getLeft());
+ assertAreEqual(expectedValue[12], resource.getBottom());
+ assertAreEqual(expectedValue[13], resource.getRight());
+ assertAreEqual(expectedValue[14], resource.getUOrder());
+ assertAreEqual(expectedValue[15], resource.getVOrder());
+
+ assertAreEqual(expectedValue[16], resource.getCrop());
+ assertAreEqual(expectedValue[17], resource.getFrameStepNumerator());
+ assertAreEqual(expectedValue[18], resource.getFrameStepDenominator());
+ assertAreEqual(expectedValue[19], resource.getDurationNumerator());
+ assertAreEqual(expectedValue[20], resource.getDurationDenominator());
+ assertAreEqual(expectedValue[21], resource.getFrameCount());
+ assertAreEqual(expectedValue[22], resource.getWidth());
+ assertAreEqual(expectedValue[23], resource.getHeight());
+ assertAreEqual(expectedValue[24], resource.getResolution());
+ assertAreEqual(expectedValue[25], resource.getResolutionUnit());
+ assertAreEqual(expectedValue[26], resource.getComp());
+ assertAreEqual(expectedValue[27], resource.getCompId());
+ assertAreEqual(expectedValue[28], resource.getOriginalCompId());
+ assertAreEqual(expectedValue[29], resource.getPlacedId().toString());
+ assertAreEqual(expectedValue[30], resource.getNonAffineTransformMatrix());
+ if (resource.isCustom())
+ {
+ assertAreEqual(expectedValue[31], resource.getHorizontalMeshPointUnit());
+ assertAreEqual(expectedValue[32], resource.getHorizontalMeshPoints());
+ assertAreEqual(expectedValue[33], resource.getVerticalMeshPointUnit());
+ assertAreEqual(expectedValue[34], resource.getVerticalMeshPoints());
+ }
+ }
+
+ void setNewSmartValues(SmartObjectResource resource, Object[] newValues)
+ {
+ // This values we do not change in resource
+ newValues[0] = resource.isCustom();
+ newValues[1] = resource.getUniqueId().toString();
+ newValues[5] = resource.getPlacedLayerType();
+ newValues[14] = resource.getUOrder();
+ newValues[15] = resource.getVOrder();
+ newValues[28] = resource.getOriginalCompId();
+
+ // This values should be changed in the PlLdResource (with the specified UniqueId) as well
+ // and some of them must be in accord with the underlining smart object in the LinkDataSource
+ resource.setPageNumber((Integer)newValues[2]); // 2;
+ resource.setTotalPages((Integer)newValues[3]); // 3;
+ resource.setAntiAliasPolicy((Integer)newValues[4]); // 0;
+ resource.setTransformMatrix((double[])newValues[6]);
+ resource.setValue((Double)newValues[7]); // 1.23456789;
+ resource.setPerspective((Double)newValues[8]); // 0.123456789;
+ resource.setPerspectiveOther((Double)newValues[9]); // 0.987654321;
+ resource.setTop((Double)newValues[10]); // -126;
+ resource.setLeft((Double)newValues[11]); // -215;
+ resource.setBottom((Double)newValues[12]); // 248;
+ resource.setRight((Double)newValues[13]); // 145;
+ resource.setCrop((Integer)newValues[16]); // 5;
+ resource.setFrameStepNumerator((Integer)newValues[17]); // 1;
+ resource.setFrameStepDenominator((Integer)newValues[18]); // 601;
+ resource.setDurationNumerator((Integer)newValues[19]); // 2;
+ resource.setDurationDenominator((Integer)newValues[20]); // 602;
+ resource.setFrameCount((Integer)newValues[21]); // 11;
+ resource.setWidth((Double)newValues[22]); // 541;
+ resource.setHeight((Double)newValues[23]); // 249;
+ resource.setResolution((Double)newValues[24]); // 144;
+ resource.setResolutionUnit((Integer)newValues[25]);
+ resource.setComp((Integer)newValues[26]); // 21;
+ resource.setCompId((Integer)newValues[27]); // 22;
+ resource.setNonAffineTransformMatrix((double[])newValues[30]);
+
+ // This unique Id should be changed in references if any
+ resource.setPlacedId(UUID.fromString((String)newValues[29])); // "12345678-9abc-def0-9876-54321fecba98");
+ if (resource.isCustom())
+ {
+ resource.setHorizontalMeshPointUnit((Integer)newValues[31]);
+ resource.setHorizontalMeshPoints((double[])newValues[32]);
+ resource.setVerticalMeshPointUnit((Integer)newValues[33]);
+ resource.setVerticalMeshPoints((double[])newValues[34]);
+ }
+
+ // Be careful with some parameters: the saved image may become unreadable by Adobe® Photoshop®
+ //resource.setUOrder(6);
+ //resource.setVOrder(9);
+
+ // Do no change this otherwise you won't be able to use free transform
+ // or change the underlining smart object to the vector type
+ //resource.setPlacedLayerType(PlacedLayerType.Vector);
+
+ // There should be valid PlLdResource with this unique Id
+ //resource.setUniqueId(UUID.fromString("98765432-10fe-cba0-1234-56789abcdef0"));
+ }
+ }
+ LocalScopeExtension $ = new LocalScopeExtension();
+
+ Object[] newSmartValues = new Object[]
+ {
+ true,
+ null,
+ 2,
+ 3,
+ 0,
+ PlacedLayerType.ImageStack,
+ new double[]
+ {
+ 12.937922786050663,
+ 19.419959734187131,
+ 2.85445817782261,
+ 1.0540625423957124,
+ 7.20861031651307,
+ 14.634102808208553,
+ 17.292074924741144,
+ 4
+ },
+ 1.23456789,
+ 0.123456789,
+ 0.987654321,
+ -126d,
+ -215d,
+ 248d,
+ 145d,
+ 4,
+ 4,
+ 5,
+ 1,
+ 601,
+ 2,
+ 602,
+ 11,
+ 541d,
+ 249d,
+ 144d,
+ UnitTypes.Percent,
+ 21,
+ 22,
+ 23,
+ "12345678-9abc-def0-9876-54321fecba98",
+ new double[]
+ {
+ 129.937922786050663,
+ 195.419959734187131,
+ 26.85445817782261,
+ 12.0540625423957124,
+ 72.20861031651307,
+ 147.634102808208553,
+ 175.292074924741144,
+ 42
+ },
+ UnitTypes.Points,
+ new double[]
+ {
+ 0.01d, 103.33333333333433d, 206.66686666666666d, 310.02d,
+ 0.20d, 103.33333333333533d, 206.69666666666666d, 310.03d,
+ 30.06d, 103.33333333336333d, 206.66660666666666d, 310.04d,
+ 04.05d, 103.33333333373333d, 206.66666166666666d, 310.05d
+ },
+ UnitTypes.Distance,
+ new double[]
+ {
+ 0.06d, 0.07d, 0.08d, 0.09d,
+ 49.066666666666664d, 49.266666666666664d, 49.566666666666664d, 49.766666666666664d,
+ 99.133333333333329d, 99.433333333333329d, 99.633333333333329d, 99.833333333333329d,
+ 140, 141, 142, 143,
+ },
+ };
+
+ Object[] expectedValues = new Object[]
+ {
+ new Object[]
+ {
+ false,
+ "5867318f-3174-9f41-abca-22f56a75247e",
+ 1,
+ 1,
+ 0x10,
+ PlacedLayerType.Raster,
+ new double[]
+ {
+ 0, 0, 2, 0, 2, 2, 0, 2
+ },
+ 0d,
+ 0d,
+ 0d,
+ 0d,
+ 0d,
+ 2d,
+ 2d,
+ 4,
+ 4,
+ 1,
+ 0,
+ 600,
+ 0,
+ 600,
+ 1,
+ 2d,
+ 2d,
+ 72d,
+ UnitTypes.Density,
+ -1,
+ -1,
+ -1,
+ "64b3997c-06e0-be40-a349-41acf397c897",
+ new double[]
+ {
+ 0, 0, 2, 0, 2, 2, 0, 2
+ },
+ }
+ };
+
+ String srcPsdPath = dataDir + "rgb8_2x2_linked.psd";
+ String dstPsdPath = outputDir + "rgb8_2x2_linked_output.psd";
+
+ PsdImage image = (PsdImage)Image.load(srcPsdPath);
+ try
+ {
+ SoLeResource soleResource = null;
+ int index = 0;
+
+ // Find SoLeResource
+ for (Layer imageLayer : image.getLayers())
+ {
+ for (LayerResource imageResource : imageLayer.getResources())
+ {
+
+ if (imageResource instanceof SoLeResource)
+ {
+ soleResource = (SoLeResource)imageResource;
+ Object[] expectedValue = (Object[])expectedValues[index++];
+ $.assertAreEqual(expectedValue[1], soleResource.getUniqueId().toString());
+ $.checkSmartObjectResourceValues(expectedValue, soleResource);
+ $.setNewSmartValues(soleResource, newSmartValues);
+
+ break;
+ }
+ }
+ }
+
+ $.assertIsTrue(soleResource != null);
+ soleResource = null; // clear the value to reuse the variable a bit later
+
+ // Save the changes to a PSD file for further verification
+ image.save(dstPsdPath, new PsdOptions(image));
+
+ // Load just saved PSD file
+ PsdImage savedImage = (PsdImage)Image.load(dstPsdPath);
+ try
+ {
+ // Find SoLeResource
+ for (Layer imageLayer : image.getLayers())
+ {
+ for (LayerResource imageResource : imageLayer.getResources())
+ {
+ if (imageResource instanceof SoLeResource)
+ {
+ soleResource = (SoLeResource)imageResource;
+
+ // Make sure that the resource was saved correctly
+ $.checkSmartObjectResourceValues(newSmartValues, soleResource);
+
+ break;
+ }
+ }
+ }
+ }
+ finally
+ {
+ savedImage.dispose();
+ }
+
+ $.assertIsTrue(soleResource != null);
+ }
+ finally
+ {
+ image.dispose();
+ }
+ //ExEnd:SupportSoLEResource
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSoLdResource.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSoLdResource.java
new file mode 100644
index 0000000..e5fc3b2
--- /dev/null
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/SupportSoLdResource.java
@@ -0,0 +1,352 @@
+package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD;
+
+import com.aspose.psd.Image;
+import com.aspose.psd.examples.Utils.Utils;
+import com.aspose.psd.fileformats.psd.PsdImage;
+import com.aspose.psd.fileformats.psd.layers.Layer;
+import com.aspose.psd.fileformats.psd.layers.LayerResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.smartobjectresources.PlacedLayerType;
+import com.aspose.psd.fileformats.psd.layers.layerresources.smartobjectresources.SoLdResource;
+import com.aspose.psd.fileformats.psd.layers.layerresources.typetoolinfostructures.UnitTypes;
+import com.aspose.psd.imageoptions.PsdOptions;
+import com.aspose.psd.internal.Exceptions.FormatException;
+
+import java.lang.reflect.Array;
+import java.util.UUID;
+
+/**
+ * This example shows how to get or set the smart object layer data properties of the PSD file.
+ */
+public class SupportSoLdResource
+{
+ public static void main(String[] args)
+ {
+ String dataDir = Utils.GetDataDir_PSD();
+ String outputDir = Utils.GetDataDir_Output();
+
+ //ExStart:SupportSoLdResource
+ // Define a local class just to keep reusable code (methods)
+ class LocalScopeExtension
+ {
+ boolean equals(Object a, Object b)
+ {
+ return (a == b) || (a != null && a.equals(b));
+ }
+
+ void assertAreEqual(Object actual, Object expected)
+ {
+ boolean areEqual = equals(actual, expected);
+ // Compare arrays if any
+ if (!areEqual &&
+ (actual != null && actual.getClass().isArray()) &&
+ (expected != null && expected.getClass().isArray()))
+ {
+ int length;
+ // Use Reflection for accessing arrays to support arrays of primitives
+ if ((length = Array.getLength(actual)) == Array.getLength(expected))
+ {
+ for (int i = 0; i < length; i++)
+ {
+ if (!equals(Array.get(actual, i), Array.get(expected, i)))
+ {
+ break;
+ }
+ }
+
+ areEqual = true;
+ }
+ }
+
+ if (!areEqual)
+ {
+ throw new FormatException(
+ String.format("Actual value %s are not equal to expected %s.", actual, expected));
+ }
+ }
+ }
+ LocalScopeExtension $ = new LocalScopeExtension();
+
+ String srcPsdPath = dataDir + "LayeredSmartObjects8bit2.psd";
+ String dstPsdPath = outputDir + "LayeredSmartObjects8bit2_output.psd";
+
+ Object[][] expectedValues = new Object[][]
+ {
+ new Object[]
+ {
+ true,
+ "76f05a3b-7523-5e42-a1bb-27f4735bffa0",
+ 1,
+ 1,
+ 0x10,
+ PlacedLayerType.Raster,
+ new double[]
+ {
+ 29.937922786050663,
+ 95.419959734187131,
+ 126.85445817782261,
+ 1.0540625423957124,
+ 172.20861031651307,
+ 47.634102808208553,
+ 75.292074924741144,
+ 142
+ },
+ 0.0,
+ 0.0,
+ 0.0,
+ 0d,
+ 0d,
+ 149d,
+ 310d,
+ 4,
+ 4,
+ 1,
+ 0,
+ 600,
+ 0,
+ 600,
+ 1,
+ 310d,
+ 149d,
+ 72d,
+ UnitTypes.Density,
+ -1,
+ -1,
+ -1,
+ "d3388655-19e4-9742-82f2-f553bb01046a",
+ new double[]
+ {
+ 29.937922786050663,
+ 95.419959734187131,
+ 126.85445817782261,
+ 1.0540625423957124,
+ 172.20861031651307,
+ 47.634102808208553,
+ 75.292074924741144,
+ 142
+ },
+ UnitTypes.Pixels,
+ new double[]
+ {
+ 0.0d, 103.33333333333333d, 206.66666666666666d, 310.0d,
+ 0.0d, 103.33333333333333d, 206.66666666666666d, 310.0d,
+ 0.0d, 103.33333333333333d, 206.66666666666666d, 310.0d,
+ 0.0d, 103.33333333333333d, 206.66666666666666d, 310.0d
+ },
+ UnitTypes.Pixels,
+ new double[]
+ {
+ 0.0d, 0.0d, 0.0d, 0.0d,
+ 49.666666666666664d, 49.666666666666664d, 49.666666666666664d, 49.666666666666664d,
+ 99.333333333333329d, 99.333333333333329d, 99.333333333333329d, 99.333333333333329d,
+ 149, 149, 149, 149,
+ },
+ },
+ new Object[]
+ {
+ true,
+ "cf0477a8-8f92-ac4f-9462-f78e26234851",
+ 1,
+ 1,
+ 0x10,
+ PlacedLayerType.Raster,
+ new double[]
+ {
+ 37.900314592235681,
+ -0.32118219433001371,
+ 185.94210608826535,
+ 57.7076819802063,
+ 153.32047433609358,
+ 140.9311755779743,
+ 5.2786828400639294,
+ 82.902311403437977,
+ },
+ 0.0,
+ 0.0,
+ 0.0,
+ 0d,
+ 0d,
+ 721d,
+ 1280d,
+ 4,
+ 4,
+ 1,
+ 0,
+ 600,
+ 0,
+ 600,
+ 1,
+ 1280d,
+ 721d,
+ 72d,
+ UnitTypes.Density,
+ -1,
+ -1,
+ -1,
+ "625cc4b9-2c5f-344f-8636-03caf2bd3489",
+ new double[]
+ {
+ 37.900314592235681,
+ -0.32118219433001371,
+ 185.94210608826535,
+ 57.7076819802063,
+ 153.32047433609358,
+ 140.9311755779743,
+ 5.2786828400639294,
+ 82.902311403437977,
+ },
+ UnitTypes.Pixels,
+ new double[]
+ {
+ 0.0, 426.66666666666663, 853.33333333333326, 1280,
+ 0.0, 426.66666666666663, 853.33333333333326, 1280,
+ 0.0, 426.66666666666663, 853.33333333333326, 1280,
+ 0.0, 426.66666666666663, 853.33333333333326, 1280,
+ },
+ UnitTypes.Pixels,
+ new double[]
+ {
+ 0.0, 0.0, 0.0, 0.0,
+ 240.33333333333331, 240.33333333333331, 240.33333333333331, 240.33333333333331,
+ 480.66666666666663, 480.66666666666663, 480.66666666666663, 480.66666666666663,
+ 721, 721, 721, 721,
+ },
+ 0,
+ 0
+ }
+ };
+
+ // Load a predefined PSD file containing SoLdResource
+ PsdImage image = (PsdImage)Image.load(srcPsdPath);
+ try
+ {
+ SoLdResource resource = null;
+ int index = 0;
+ for (Layer imageLayer : image.getLayers())
+ {
+ for (LayerResource imageResource : imageLayer.getResources())
+ {
+ if (imageResource instanceof SoLdResource)
+ {
+ // Make sure the loaded resource is what we expect at the same time
+ // demonstrate API usage of SoLdResource
+ resource = (SoLdResource)imageResource;
+ Object[] expectedValue = expectedValues[index++];
+ $.assertAreEqual(expectedValue[0], resource.isCustom());
+ $.assertAreEqual(expectedValue[1], resource.getUniqueId().toString());
+ $.assertAreEqual(expectedValue[2], resource.getPageNumber());
+ $.assertAreEqual(expectedValue[3], resource.getTotalPages());
+ $.assertAreEqual(expectedValue[4], resource.getAntiAliasPolicy());
+ $.assertAreEqual(expectedValue[5], resource.getPlacedLayerType());
+ $.assertAreEqual(8, resource.getTransformMatrix().length);
+ $.assertAreEqual(expectedValue[6], resource.getTransformMatrix());
+ $.assertAreEqual(expectedValue[7], resource.getValue());
+ $.assertAreEqual(expectedValue[8], resource.getPerspective());
+ $.assertAreEqual(expectedValue[9], resource.getPerspectiveOther());
+ $.assertAreEqual(expectedValue[10], resource.getTop());
+ $.assertAreEqual(expectedValue[11], resource.getLeft());
+ $.assertAreEqual(expectedValue[12], resource.getBottom());
+ $.assertAreEqual(expectedValue[13], resource.getRight());
+ $.assertAreEqual(expectedValue[14], resource.getUOrder());
+ $.assertAreEqual(expectedValue[15], resource.getVOrder());
+
+ $.assertAreEqual(expectedValue[16], resource.getCrop());
+ $.assertAreEqual(expectedValue[17], resource.getFrameStepNumerator());
+ $.assertAreEqual(expectedValue[18], resource.getFrameStepDenominator());
+ $.assertAreEqual(expectedValue[19], resource.getDurationNumerator());
+ $.assertAreEqual(expectedValue[20], resource.getDurationDenominator());
+ $.assertAreEqual(expectedValue[21], resource.getFrameCount());
+ $.assertAreEqual(expectedValue[22], resource.getWidth());
+ $.assertAreEqual(expectedValue[23], resource.getHeight());
+ $.assertAreEqual(expectedValue[24], resource.getResolution());
+ $.assertAreEqual(expectedValue[25], resource.getResolutionUnit());
+ $.assertAreEqual(expectedValue[26], resource.getComp());
+ $.assertAreEqual(expectedValue[27], resource.getCompId());
+ $.assertAreEqual(expectedValue[28], resource.getOriginalCompId());
+ $.assertAreEqual(expectedValue[29], resource.getPlacedId().toString());
+ $.assertAreEqual(expectedValue[30], resource.getNonAffineTransformMatrix());
+ if (resource.isCustom())
+ {
+ $.assertAreEqual(expectedValue[31], resource.getHorizontalMeshPointUnit());
+ $.assertAreEqual(expectedValue[32], resource.getHorizontalMeshPoints());
+ $.assertAreEqual(expectedValue[33], resource.getVerticalMeshPointUnit());
+ $.assertAreEqual(expectedValue[34], resource.getVerticalMeshPoints());
+ double[] temp = resource.getVerticalMeshPoints();
+ resource.setVerticalMeshPoints(resource.getHorizontalMeshPoints());
+ resource.setHorizontalMeshPoints(temp);
+ }
+
+ // This values should be changed in the PlLdResource (with the specified UniqueId) as well
+ // and some of them must be in accord with the underlining smart object in the LinkDataSource
+ resource.setPageNumber(2);
+ resource.setTotalPages(3);
+ resource.setAntiAliasPolicy(0);
+ resource.setValue(1.23456789);
+ resource.setPerspective(0.123456789);
+ resource.setPerspectiveOther(0.987654321);
+ resource.setTop(-126);
+ resource.setLeft(-215);
+ resource.setBottom(248);
+ resource.setRight(145);
+ resource.setCrop(4);
+ resource.setFrameStepNumerator(1);
+ resource.setFrameStepDenominator(601);
+ resource.setDurationNumerator(2);
+ resource.setDurationDenominator(602);
+ resource.setFrameCount(11);
+ resource.setWidth(541);
+ resource.setHeight(249);
+ resource.setResolution(144);
+ resource.setComp(21);
+ resource.setCompId(22);
+ resource.setTransformMatrix(new double[]
+ {
+ 12.937922786050663,
+ 19.419959734187131,
+ 2.85445817782261,
+ 1.0540625423957124,
+ 7.20861031651307,
+ 14.634102808208553,
+ 17.292074924741144,
+ 4
+ });
+ resource.setNonAffineTransformMatrix(new double[]
+ {
+ 129.937922786050663,
+ 195.419959734187131,
+ 26.85445817782261,
+ 12.0540625423957124,
+ 72.20861031651307,
+ 147.634102808208553,
+ 175.292074924741144,
+ 42
+ });
+
+ // This unique Id should be changed in references if any
+ resource.setPlacedId(UUID.fromString("12345678-9abc-def0-9876-54321fecba98"));
+
+ // Be careful with some parameters: image may became unreadable by Adobe® Photoshop®
+ ////resource.UOrder = 6;
+ ////resource.VOrder = 9;
+
+ // Do no change this otherwise you won't be able to use free transform
+ // or change the underlining smart object to the vector type
+ ////resource.PlacedLayerType = PlacedLayerType.Vector;
+
+ // There should be valid PlLdResource with this unique Id
+ ////resource.UniqueId = new Guid("98765432-10fe-cba0-1234-56789abcdef0");
+
+ break;
+ }
+ }
+ }
+
+ $.assertAreEqual(true, resource != null);
+ image.save(dstPsdPath, new PsdOptions(image));
+ }
+ finally
+ {
+ image.dispose();
+ }
+ //ExEnd:SupportSoLdResource
+ }
+}
diff --git a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/TextLayerBoundBox.java b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/TextLayerBoundBox.java
index e04da1d..4898d44 100644
--- a/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/TextLayerBoundBox.java
+++ b/Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/TextLayerBoundBox.java
@@ -34,7 +34,7 @@ public static void main(String[] args)
// TextBoundBox is the maximum layer size for Text Layer.
// In this area PS will try to fit your text
- Size boundBox = textLayer.getTextBoundBox();
+ Size boundBox = textLayer.getTextBoundBox().getSize().toSize();
Assert.areEqual(correctBoundBox, boundBox);
//ExEnd:TextLayerBoundBox
}
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/AddStrokeEffectAtRuntime/StrokeEffectsSource.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/AddStrokeEffectAtRuntime/StrokeEffectsSource.psd
new file mode 100644
index 0000000..cc50a99
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/AddStrokeEffectAtRuntime/StrokeEffectsSource.psd differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont0.tiff b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont0.tiff
new file mode 100644
index 0000000..c28c955
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont0.tiff differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont1.png b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont1.png
new file mode 100644
index 0000000..f885c19
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont1.png differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont2.jpg b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont2.jpg
new file mode 100644
index 0000000..1ef81b9
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/replacedfont2.jpg differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/sample_konstanting.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/sample_konstanting.psd
new file mode 100644
index 0000000..f79e581
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SetDefaultReplacementFont/sample_konstanting.psd differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportBritResource/BrightnessContrastPS6.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportBritResource/BrightnessContrastPS6.psd
new file mode 100644
index 0000000..b3bf12c
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportBritResource/BrightnessContrastPS6.psd differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/photooverlay_5_new.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/photooverlay_5_new.psd
new file mode 100644
index 0000000..6bb919f
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/photooverlay_5_new.psd differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2.png b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2.png
new file mode 100644
index 0000000..524f844
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2.png differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2_asset_linked.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2_asset_linked.psd
new file mode 100644
index 0000000..45be7f3
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2_asset_linked.psd differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2_linked.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2_linked.psd
new file mode 100644
index 0000000..d2f822e
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportLnkeResource/rgb8_2x2_linked.psd differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/Layered PSD file smart objects.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/Layered PSD file smart objects.psd
new file mode 100644
index 0000000..76e8382
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/Layered PSD file smart objects.psd differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/LayeredSmartObjects16bit.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/LayeredSmartObjects16bit.psd
new file mode 100644
index 0000000..4e684ee
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/LayeredSmartObjects16bit.psd differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_huset.jpg b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_huset.jpg
new file mode 100644
index 0000000..734a5e2
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_huset.jpg differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_panama-papers.jpg b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_panama-papers.jpg
new file mode 100644
index 0000000..dab834d
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_panama-papers.jpg differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_rgb8_2x2.png b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_rgb8_2x2.png
new file mode 100644
index 0000000..a53a950
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/new_rgb8_2x2.png differ
diff --git a/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/rgb8_2x2_embedded_png.psd b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/rgb8_2x2_embedded_png.psd
new file mode 100644
index 0000000..95600ec
Binary files /dev/null and b/Examples/src/main/resources/ModifyingAndConvertingImages/PSD/SupportSmartObjectResources/rgb8_2x2_embedded_png.psd differ
diff --git a/Examples/src/main/resources/PSD/AddColorBalanceAdjustmentLayer.psd b/Examples/src/main/resources/PSD/AddColorBalanceAdjustmentLayer.psd
new file mode 100644
index 0000000..ae66949
Binary files /dev/null and b/Examples/src/main/resources/PSD/AddColorBalanceAdjustmentLayer.psd differ
diff --git a/Examples/src/main/resources/PSD/LayeredSmartObjects8bit2.psd b/Examples/src/main/resources/PSD/LayeredSmartObjects8bit2.psd
new file mode 100644
index 0000000..621be35
Binary files /dev/null and b/Examples/src/main/resources/PSD/LayeredSmartObjects8bit2.psd differ
diff --git a/Examples/src/main/resources/PSD/new_panama-papers-4.psd b/Examples/src/main/resources/PSD/new_panama-papers-4.psd
new file mode 100644
index 0000000..3b41d34
Binary files /dev/null and b/Examples/src/main/resources/PSD/new_panama-papers-4.psd differ
diff --git a/Examples/src/main/resources/PSD/r-embedded-bmp.psd b/Examples/src/main/resources/PSD/r-embedded-bmp.psd
new file mode 100644
index 0000000..fe5e426
Binary files /dev/null and b/Examples/src/main/resources/PSD/r-embedded-bmp.psd differ
diff --git a/Examples/src/main/resources/PSD/r-embedded-gif.psd b/Examples/src/main/resources/PSD/r-embedded-gif.psd
new file mode 100644
index 0000000..02cfc27
Binary files /dev/null and b/Examples/src/main/resources/PSD/r-embedded-gif.psd differ
diff --git a/Examples/src/main/resources/PSD/r-embedded-jpeg.psd b/Examples/src/main/resources/PSD/r-embedded-jpeg.psd
new file mode 100644
index 0000000..49a7ffa
Binary files /dev/null and b/Examples/src/main/resources/PSD/r-embedded-jpeg.psd differ
diff --git a/Examples/src/main/resources/PSD/r-embedded-jpeg2000.psd b/Examples/src/main/resources/PSD/r-embedded-jpeg2000.psd
new file mode 100644
index 0000000..a27c43b
Binary files /dev/null and b/Examples/src/main/resources/PSD/r-embedded-jpeg2000.psd differ
diff --git a/Examples/src/main/resources/PSD/r-embedded-png.psd b/Examples/src/main/resources/PSD/r-embedded-png.psd
new file mode 100644
index 0000000..402649b
Binary files /dev/null and b/Examples/src/main/resources/PSD/r-embedded-png.psd differ
diff --git a/Examples/src/main/resources/PSD/r-embedded-psd.psd b/Examples/src/main/resources/PSD/r-embedded-psd.psd
new file mode 100644
index 0000000..70eff0a
Binary files /dev/null and b/Examples/src/main/resources/PSD/r-embedded-psd.psd differ
diff --git a/Examples/src/main/resources/PSD/r-embedded-tiff.psd b/Examples/src/main/resources/PSD/r-embedded-tiff.psd
new file mode 100644
index 0000000..76e1a6f
Binary files /dev/null and b/Examples/src/main/resources/PSD/r-embedded-tiff.psd differ
diff --git a/Examples/src/main/resources/PSD/r3-embedded.psd b/Examples/src/main/resources/PSD/r3-embedded.psd
new file mode 100644
index 0000000..6377915
Binary files /dev/null and b/Examples/src/main/resources/PSD/r3-embedded.psd differ
diff --git a/Examples/src/main/resources/PSD/rgb8_2x2.png b/Examples/src/main/resources/PSD/rgb8_2x2.png
new file mode 100644
index 0000000..524f844
Binary files /dev/null and b/Examples/src/main/resources/PSD/rgb8_2x2.png differ
diff --git a/Examples/src/main/resources/PSD/rgb8_2x2_linked.psd b/Examples/src/main/resources/PSD/rgb8_2x2_linked.psd
new file mode 100644
index 0000000..d2f822e
Binary files /dev/null and b/Examples/src/main/resources/PSD/rgb8_2x2_linked.psd differ
diff --git a/Examples/src/main/resources/PSD/rgb8_2x2_linked2.psd b/Examples/src/main/resources/PSD/rgb8_2x2_linked2.psd
new file mode 100644
index 0000000..ceee9da
Binary files /dev/null and b/Examples/src/main/resources/PSD/rgb8_2x2_linked2.psd differ