LclrResource Class
Class LclrResource. This resource contains information about color of layer in layers' list is PS. It's only
Inheritance Hierarchy
SystemObject
  Aspose.PSD.FileFormats.Psd.LayersLayerResource
    Aspose.PSD.FileFormats.Psd.Layers.LayerResourcesLclrResource

Namespace: Aspose.PSD.FileFormats.Psd.Layers.LayerResources
Assembly: Aspose.PSD (in Aspose.PSD.dll) Version: 21.12
Syntax
public class LclrResource : LayerResource

The LclrResource type exposes the following members.

Constructors
  NameDescription
Public methodLclrResource
Initializes a new instance of the LclrResource class.
Public methodLclrResource(Byte)
Initializes a new instance of the LclrResource class.
Public methodLclrResource(SheetColorHighlightEnum)
Initializes a new instance of the LclrResource class.
Properties
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodSave
Saves the resource to the specified stream container.
(Overrides LayerResourceSave(StreamContainer, Int32).)
Protected methodSaveResourceHeader
Saves the resource header.
(Inherited from LayerResource.)
Public methodToString
Returns a String that represents this instance.
(Inherited from LayerResource.)
Fields
  NameDescription
Public fieldStatic memberTypeToolKey
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