public class GradientOverlayEffect extends Object implements ILayerEffect
Gradient Layer effect
An example of applying the gradient overlay effect for an image layer.
String inPsdFilePath = "psdnet256.psd"; String outPsdFilePath = "psdnet256.psd_output.psd"; // Support layer effects, if any PsdLoadOptions psdLoadOptions = new PsdLoadOptions(); psdLoadOptions.setLoadEffectsResource(true); // Load a PSD file containing an image PsdImage psdImage = (PsdImage)Image.load(inPsdFilePath, psdLoadOptions); try { BlendingOptions layerBlendOptions = psdImage.getLayers()[1].getBlendingOptions(); // Search GradientOverlayEffect in a layer GradientOverlayEffect gradientOverlayEffect = null; for (ILayerEffect effect : layerBlendOptions.getEffects()) { gradientOverlayEffect = (GradientOverlayEffect)effect; if (gradientOverlayEffect != null) { break; } } if (gradientOverlayEffect == null) { // Create a new GradientOverlayEffect if it not exists gradientOverlayEffect = layerBlendOptions.addGradientOverlay(); } // Add a bit of transparency to the effect gradientOverlayEffect.setOpacity((byte)200); // Change the blend mode of gradient effect gradientOverlayEffect.setBlendMode(BlendMode.Hue); // Get GradientFillSettings object to configure gradient overlay settings GradientFillSettings settings = gradientOverlayEffect.getSettings(); // Set a new gradient with two colors settings.setColorPoints(new IGradientColorPoint[] { new GradientColorPoint(Color.getGreenYellow(), 0, 50), new GradientColorPoint(Color.getBlueViolet(), 4096, 50), }); // Set an inclination of the gradient at an angle of 80 degrees settings.setAngle(80); // Scale gradient effect up to 150% settings.setScale(150); // Set type of gradient settings.setGradientType(GradientType.Linear); // Make the gradient opaque by setting the opacity to 100% at each transparency point settings.getTransparencyPoints()[0].setOpacity(100); settings.getTransparencyPoints()[1].setOpacity(100); psdImage.save(outPsdFilePath); } finally { psdImage.dispose(); }
Modifier and Type | Method and Description |
---|---|
long |
getBlendMode()
Gets or sets the blend mode.
|
byte |
getOpacity()
Gets or sets the opacity.
|
GradientFillSettings |
getSettings()
Gets or sets the settings.
|
boolean |
isVisible()
Gets or sets a value indicating whether this instance is visible.
|
void |
setBlendMode(long value)
Gets or sets the blend mode.
|
void |
setOpacity(byte value)
Gets or sets the opacity.
|
void |
setSettings(GradientFillSettings value)
Gets or sets the settings.
|
void |
setVisible(boolean value)
Gets or sets a value indicating whether this instance is visible.
|
public final GradientFillSettings getSettings()
Gets or sets the settings.
Value: The settings.public final void setSettings(GradientFillSettings value)
Gets or sets the settings.
Value: The settings.public final long getBlendMode()
Gets or sets the blend mode.
Value: The blend mode.getBlendMode
in interface ILayerEffect
public final void setBlendMode(long value)
Gets or sets the blend mode.
Value: The blend mode.setBlendMode
in interface ILayerEffect
An example of changing the blending mode for a gradient overlay effect.
String inPsdFilePath = "psdnet585.psd"; String outPsdFilePath = "out_psdnet585.psd"; // Load a PSD file containing an image layer PsdImage psdImage = (PsdImage)Image.load(inPsdFilePath); try { GradientOverlayEffect gradientOverlayEffect = psdImage.getLayers()[1].getBlendingOptions().addGradientOverlay(); // Change the blend mode for the gradient overlay effect gradientOverlayEffect.setBlendMode(BlendMode.Subtract); // Save a modified copy of loaded PSD file on the path psdImage.save(outPsdFilePath); } finally { psdImage.dispose(); }
public final boolean isVisible()
Gets or sets a value indicating whether this instance is visible.
Value:true
if this instance is visible; otherwise, false
.isVisible
in interface ILayerEffect
public final void setVisible(boolean value)
Gets or sets a value indicating whether this instance is visible.
Value:true
if this instance is visible; otherwise, false
.setVisible
in interface ILayerEffect
public final byte getOpacity()
Gets or sets the opacity.
Value: The opacity.getOpacity
in interface ILayerEffect
public final void setOpacity(byte value)
Gets or sets the opacity.
Value: The opacity.setOpacity
in interface ILayerEffect
Copyright (c) 2008-2020 Aspose Pty Ltd. All Rights Reserved.