LclrResource.Color
Contents
[
Hide
]LclrResource.Color property
Gets or sets the color of layer.
public SheetColorHighlightEnum Color { get; set; }
Property Value
The color.
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
- enum SheetColorHighlightEnum
- class LclrResource
- namespace Aspose.PSD.FileFormats.Psd.Layers.LayerResources
- assembly Aspose.PSD