Table of Contents

Class PsdLayerImage

Namespace
Egami.Formats.Psd
Assembly
Egami.dll

One layer or group of a PsdDocument, with its pixels and mask.

public sealed class PsdLayerImage : IDisposable
Inheritance
PsdLayerImage
Implements
Inherited Members

Examples

// ReadLayers gives every layer with its pixels, bottom to top; a group comes after its contents.
using PsdDocument document = PsdImage.ReadLayers("layered.psd");
foreach (PsdLayerImage layer in document.Layers)
{
    if (layer.Pixels is Raster pixels)
    {
        // Each layer at its own size, in the natural type with alpha (Rgba8 here); X and Y place it on the canvas.
        pixels.Save($"layer-{layer.Index}.png");
        Console.WriteLine($"{layer.Info.Name}: {pixels.Width}×{pixels.Height} at ({layer.X}, {layer.Y}), in group {layer.ParentIndex}");
    }
}

Properties

Index

Gets the layer's position in Layers.

public int Index { get; }

Property Value

int

Info

Gets or sets the layer's record: name, opacity, blend mode, visibility and the rest. Set a changed copy (with with) to flatten the document differently, for example with a layer hidden.

public PsdLayer Info { get; set; }

Property Value

PsdLayer

Exceptions

ArgumentNullException

The value is null.

Ink

Gets a CMYK layer's pixels as ink, the planes premultiplied by its alpha; null for other modes.

public InkRaster? Ink { get; }

Property Value

InkRaster

Mask

Gets the layer's pixel mask, or null.

public PsdMask? Mask { get; }

Property Value

PsdMask

ParentIndex

Gets the position in Layers of the group the layer is in, or −1 at the top level.

public int ParentIndex { get; }

Property Value

int

Pixels

Gets the layer's pixels at its own size, with straight alpha, or null for a group, a layer without pixels (an adjustment, an empty layer) and a CMYK layer, whose pixels are in Ink.

public Raster? Pixels { get; }

Property Value

Raster

X

Gets the left edge of the layer on the canvas; it can be negative or reach past the canvas.

public int X { get; }

Property Value

int

Y

Gets the top edge of the layer on the canvas.

public int Y { get; }

Property Value

int

Methods

Dispose()

Disposes the pixels and the mask.

public void Dispose()