public class LclrResource extends LayerResource
Class LclrResource. This resource contains information about color of layer in layers' list is PS. It's only
LayerResource
An example of using Layer Sheet Color to visually highlight layers. For example you can update some layers in PSD and then highlight by color the layer which you want to attract attention.
class LocalScopeExtension { void checkSheetColorsAndRerverse(Short[] sheetColors, PsdImage psdImage) { int layersCount = psdImage.getLayers().length; for (int layerIndex = 0; layerIndex < layersCount; layerIndex++) { Layer layer = psdImage.getLayers()[layerIndex]; for (LayerResource layerResource : layer.getResources()) { if (!(layerResource instanceof LclrResource)) { continue; } // The lcrl resource always presents in psd file resource list. LclrResource resource = (LclrResource)layerResource; if (resource.getColor() != sheetColors[layerIndex]) { throw new Exception("Sheet Color has been read wrong"); } // Reverse of style sheet colors. Set up of Layer color highlight. resource.setColor(sheetColors[layersCount - layerIndex - 1]); break; } } } } LocalScopeExtension $ = new LocalScopeExtension(); String inPsdFilePath = "AllLclrResourceColors.psd"; String outPsdFilePath = "AllLclrResourceColorsReversed.psd"; // In the file colors of layers' highlighting are in this order Short[] sheetColors = new Short[] { SheetColorHighlightEnum.Red, SheetColorHighlightEnum.Orange, SheetColorHighlightEnum.Yellow, SheetColorHighlightEnum.Green, SheetColorHighlightEnum.Blue, SheetColorHighlightEnum.Violet, SheetColorHighlightEnum.Gray, SheetColorHighlightEnum.NoColor }; // Load a PSD file containing a predefined LclrResource PsdImage psdImage = (PsdImage)Image.load(inPsdFilePath); try { $.checkSheetColorsAndRerverse(sheetColors, psdImage); psdImage.save(outPsdFilePath, new PsdOptions()); } finally { psdImage.dispose(); } // Load a just saved PSD file PsdImage psdImage1 = (PsdImage)Image.load(outPsdFilePath); try { // Reverse colors List<Short> sheetColorList = Arrays.asList(sheetColors); Collections.reverse(sheetColorList); $.checkSheetColorsAndRerverse(sheetColorList.toArray(new Short[0]), psdImage1); } finally { psdImage1.dispose(); }
Modifier and Type | Field and Description |
---|---|
static int |
TypeToolKey
The type tool info key.
|
PsbResourceSignature, ResourceSignature
Constructor and Description |
---|
LclrResource()
Initializes a new instance of the
LclrResource class. |
LclrResource(byte[] data)
Initializes a new instance of the
LclrResource class. |
LclrResource(short color)
Initializes a new instance of the
LclrResource class. |
Modifier and Type | Method and Description |
---|---|
short |
getColor()
Gets or sets the color of layer.
|
int |
getKey()
Gets the layer resource key.
|
int |
getLength()
Gets the layer resource length in bytes.
|
int |
getPsdVersion()
Gets the psd version.
|
int |
getSignature()
Gets the signature.
|
void |
save(StreamContainer streamContainer,
int psdVersion)
Saves the resource to the specified stream container.
|
void |
setColor(short value)
Gets or sets the color of layer.
|
toString
public static final int TypeToolKey
The type tool info key.
public LclrResource()
Initializes a new instance of the LclrResource
class.
public LclrResource(short color)
Initializes a new instance of the LclrResource
class.
color
- The color.public LclrResource(byte[] data)
Initializes a new instance of the LclrResource
class.
data
- The resource data.PsdImageArgumentException
- Invalid Lclr Resource valuepublic final short getColor()
Gets or sets the color of layer.
Value: The color.public final void setColor(short value)
Gets or sets the color of layer.
Value: The color.public int getSignature()
Gets the signature.
getSignature
in class LayerResource
public int getKey()
Gets the layer resource key.
getKey
in class LayerResource
public int getLength()
Gets the layer resource length in bytes.
getLength
in class LayerResource
public int getPsdVersion()
Gets the psd version.
getPsdVersion
in class LayerResource
public void save(StreamContainer streamContainer, int psdVersion)
Saves the resource to the specified stream container.
save
in class LayerResource
streamContainer
- The stream container to save to.psdVersion
- The PSD version.