Class PsdLayer
One layer record of a PSD file, read as metadata: the layer's pixels are not loaded.
public sealed record PsdLayer : IEquatable<PsdLayer>
- Inheritance
-
PsdLayer
- Implements
- Inherited Members
Examples
// Layer records come as metadata, bottom to top as the file lists them; their pixels are not loaded.
using Raster image = Raster.Load("layered.psd");
foreach (PsdLayer layer in ((PsdDetails)image.Metadata.FormatDetails!).Layers)
{
if (layer.Kind == PsdLayerKind.GroupEnd)
{
continue;
}
string kind = layer.Kind == PsdLayerKind.Layer ? "layer" : "group";
Console.WriteLine($"{new string(' ', 2 * layer.Level)}{layer.Name} ({kind}, {layer.BlendModeKey}, opacity {layer.Opacity:P0}{(layer.IsVisible ? "" : ", hidden")})");
}
Constructors
PsdLayer(string, Rect, float, string, BlendMode?, bool, bool, PsdLayerKind, int)
One layer record of a PSD file, read as metadata: the layer's pixels are not loaded.
public PsdLayer(string Name, Rect Bounds, float Opacity, string BlendModeKey, BlendMode? BlendMode, bool IsVisible, bool IsClipped, PsdLayerKind Kind, int Level)
Parameters
NamestringThe layer's name: its Unicode name when the file has one, else its Pascal name.
BoundsRectWhere the layer's pixels lie in the image; empty for groups and layers without pixels.
OpacityfloatThe opacity, 0 (transparent) to 1, as DrawImage takes it; the file stores it in 256 steps.
BlendModeKeystringThe blend mode as Photoshop names it, such as "norm", "mul " or "pass" (pass through, for groups).
BlendModeBlendMode?The same blend mode in Egami's terms, or null when Egami has none like it.
IsVisibleboolWhether the layer is shown.
IsClippedboolWhether the layer is clipped to the layer below it (a clipping mask).
KindPsdLayerKindWhether the record is a layer or one end of a group.
LevelintHow many groups the record is inside; a group's own records are at the level outside it.
Examples
// Layer records come as metadata, bottom to top as the file lists them; their pixels are not loaded.
using Raster image = Raster.Load("layered.psd");
foreach (PsdLayer layer in ((PsdDetails)image.Metadata.FormatDetails!).Layers)
{
if (layer.Kind == PsdLayerKind.GroupEnd)
{
continue;
}
string kind = layer.Kind == PsdLayerKind.Layer ? "layer" : "group";
Console.WriteLine($"{new string(' ', 2 * layer.Level)}{layer.Name} ({kind}, {layer.BlendModeKey}, opacity {layer.Opacity:P0}{(layer.IsVisible ? "" : ", hidden")})");
}
Properties
BlendMode
The same blend mode in Egami's terms, or null when Egami has none like it.
public BlendMode? BlendMode { get; init; }
Property Value
BlendModeKey
The blend mode as Photoshop names it, such as "norm", "mul " or "pass" (pass through, for groups).
public string BlendModeKey { get; init; }
Property Value
Bounds
Where the layer's pixels lie in the image; empty for groups and layers without pixels.
public Rect Bounds { get; init; }
Property Value
FillOpacity
Gets the fill opacity, 0 to 1: like Opacity, but it leaves layer effects alone. 1 when the file names none; the file stores it in 256 steps.
public float FillOpacity { get; init; }
Property Value
IsClipped
Whether the layer is clipped to the layer below it (a clipping mask).
public bool IsClipped { get; init; }
Property Value
IsVisible
Whether the layer is shown.
public bool IsVisible { get; init; }
Property Value
Kind
Whether the record is a layer or one end of a group.
public PsdLayerKind Kind { get; init; }
Property Value
LayerType
Gets what the layer holds: pixels, text, a shape, a smart object, a fill, an adjustment, or a group.
public PsdLayerType LayerType { get; init; }
Property Value
Level
How many groups the record is inside; a group's own records are at the level outside it.
public int Level { get; init; }
Property Value
Name
The layer's name: its Unicode name when the file has one, else its Pascal name.
public string Name { get; init; }
Property Value
Opacity
The opacity, 0 (transparent) to 1, as DrawImage takes it; the file stores it in 256 steps.
public float Opacity { get; init; }