Class LclrResource
LclrResource class
Class LclrResource. This resource contains information about color of layer in layers’ list is PS. It’s only
public class LclrResource : LayerResource
Constructors
Name | Description |
---|
LclrResource() | Initializes a new instance of the LclrResource class. |
LclrResource(byte[]) | Initializes a new instance of the LclrResource class. |
LclrResource(SheetColorHighlightEnum) | Initializes a new instance of the LclrResource class. |
Properties
Name | Description |
---|
Color { get; set; } | Gets or sets the color of layer. |
Key { get; } | Gets the layer resource key. |
override Length { get; } | Gets the layer resource length in bytes. |
PsdVersion { get; } | Gets the minimal psd version required for layer resource. 0 indicates no restrictions. |
virtual Signature { get; } | Gets the signature. |
Methods
Name | Description |
---|
override Save(StreamContainer, int) | Saves the resource to the specified stream container. |
override ToString() | Returns a String that represents this instance. |
Fields
Name | Description |
---|
const TypeToolKey | The type tool info key. |
Examples
The following example demonstrates how you can change Sheet Color Highlight In Aspose.PSD (Sheet color setting)
[C#]
string sourceFilePath = "AllLclrResourceColors.psd";
string outputFilePath = "AllLclrResourceColorsReversed.psd";
// In the file colors of layers' highlighting are in this order
SheetColorHighlightEnum[] sheetColorsArr = new SheetColorHighlightEnum[] {
SheetColorHighlightEnum.Red,
SheetColorHighlightEnum.Orange,
SheetColorHighlightEnum.Yellow,
SheetColorHighlightEnum.Green,
SheetColorHighlightEnum.Blue,
SheetColorHighlightEnum.Violet,
SheetColorHighlightEnum.Gray,
SheetColorHighlightEnum.NoColor
};
// Layer Sheet Color is used 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.
using (PsdImage img = (PsdImage)Image.Load(sourceFilePath))
{
CheckSheetColorsAndRerverse(sheetColorsArr, img);
img.Save(outputFilePath, new PsdOptions());
}
using (PsdImage img = (PsdImage)Image.Load(outputFilePath))
{
// Colors should be reversed
Array.Reverse(sheetColorsArr);
CheckSheetColorsAndRerverse(sheetColorsArr, img);
}
void CheckSheetColorsAndRerverse(SheetColorHighlightEnum[] sheetColors, PsdImage img)
{
int layersCount = img.Layers.Length;
for (int layerIndex = 0; layerIndex < layersCount; layerIndex++)
{
Layer layer = img.Layers[layerIndex];
LayerResource[] resources = layer.Resources;
foreach (LayerResource layerResource in resources)
{
// The lcrl resource always presents in psd file resource list.
LclrResource resource = layerResource as LclrResource;
if (resource != null)
{
if (resource.Color != sheetColors[layerIndex])
{
throw new Exception("Sheet Color has been read wrong");
}
// Reverse of style sheet colors. Set up of Layer color highlight.
resource.Color = sheetColors[layersCount - layerIndex - 1];
break;
}
}
}
}
See Also