Class SoCoResource
SoCoResource class
Class SoCoResource. This resource contains information about Color Fill Layers
public class SoCoResource : FillLayerResource
Constructors
Name | Description |
---|
SoCoResource() | Initializes a new instance of the SoCoResource class. |
Properties
Name | Description |
---|
Color { get; set; } | Gets the RGB color . |
override Key { get; } | Gets the layer resource key. |
override Length { get; } | Gets the layer resource length in bytes. |
override PsdVersion { get; } | Gets the minimal psd version required for layer resource. 0 indicates no restrictions. |
override Signature { get; } | Gets the layer resource 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 edit SoCoResource (Layer Resource for Color Fill Layer)
[C#]
string sourceFile = "ColorFillLayer.psd";
string outputFile = "SoCoResource_Edited.psd";
// Load an existing image into an instance of PsdImage class
var im = (PsdImage)Image.Load(sourceFile);
using (im)
{
foreach (var layer in im.Layers)
{
// Finding of FillLayer
if (layer is FillLayer)
{
var fillLayer = (FillLayer)layer;
foreach (var resource in fillLayer.Resources)
{
// Finding of SoCoResource in Layer Resource List
if (resource is SoCoResource)
{
var socoResource = (SoCoResource)resource;
var expectedColor = Color.FromArgb(63, 83, 141);
if ((expectedColor.R != socoResource.Color.R) ||
(expectedColor.G != socoResource.Color.G) ||
(expectedColor.B != socoResource.Color.B) ||
(expectedColor.A != socoResource.Color.A))
{
throw new Exception("Unexpected color");
}
// Setting the SoCoResource Color property
socoResource.Color = Color.Red;
break;
}
}
break;
}
im.Save(outputFile);
}
}
See Also