Maskerings toepassen

Ondersteuning van maskeringslaag

Dit artikel laat zien hoe je een maskeringslaag kunt ondersteunen voor PSD-afbeeldingen en vervolgens die afbeeldingen kunt opslaan. De code snippet is hieronder verstrekt.

String dataDir = Utils.getDataDir(SupportOfLayerMask.class) + "PSD/";
// Export of the psd with complex mask
String sourceFileName = dataDir + "MaskComplex.psd";
String exportPath = dataDir + "MaskComplex.png";
try (PsdImage im = (PsdImage) Image.load(sourceFileName)) {
// Export to PNG
PngOptions saveOptions = new PngOptions();
saveOptions.setColorType(PngColorType.TruecolorWithAlpha);
im.save(exportPath, saveOptions);
}

Ondersteuning van uitsnijmasker

Dit artikel laat zien hoe je een uitsnijmasker kunt ondersteunen in een PSD-bestand met Aspose.PSD. De code snippet is hieronder verstrekt.

String dataDir = Utils.getDataDir(SupportOfClippingMask.class) + "PSD/";
// Exposure layer editing
// Export of the psd with complex clipping mask
String sourceFileName = dataDir + "ClippingMaskComplex.psd";
String exportPath = dataDir + "ClippingMaskComplex.png";
try (PsdImage im = (PsdImage) Image.load(sourceFileName)) {
// Export to PNG
PngOptions saveOptions = new PngOptions();
saveOptions.setColorType(PngColorType.TruecolorWithAlpha);
im.save(exportPath, saveOptions);
}