Class LayerState

LayerState class

The options of time line layer state.

public sealed class LayerState

Constructors

NameDescription
LayerState()The default constructor.

Properties

NameDescription
BlendMode { get; set; }Gets or sets the blending mode.
Enabled { get; set; }Gets or sets the enabled state.
FillOpacity { get; set; }Gets or sets the fill opacity value.
HorizontalFXRf { get; set; }Gets or sets the HorizontalFXRf value.
Id { get; set; }Gets or sets the layer id.
Opacity { get; set; }Gets or sets the opacity value.
PositionOffset { get; set; }Gets or sets the layer position offset related to the actual layer position.
StateEffects { get; }Gets the layer state effects.
VerticalFXRf { get; set; }Gets or sets the VerticalFXRf value.

Examples

The Timeline class gives a high-level ability to manipulate the timeline of PsdImage, like changing frame delay or editing layer state on a specific frame.

[C#]

string sourceFile = "image1219.psd";
string outputPsd = "output_image800.psd";

using (PsdImage psdImage = (PsdImage)Image.Load(sourceFile))
{
    Timeline timeline = psdImage.Timeline;

    // Change dispose method of frame 1
    timeline.Frames[0].DisposalMethod = FrameDisposalMethod.DoNotDispose;

    // Change delay of frame 2
    timeline.Frames[1].Delay = 15;

    // Change opacity of 'Layer 1' on frame 2
    LayerState layerState11 = timeline.Frames[1].LayerStates[1];
    layerState11.Opacity = 50;

    // move 'Layer 1' to left-bottom corner on frame 3
    LayerState layerState21 = timeline.Frames[2].LayerStates[1];
    layerState21.PositionOffset = new Point(-50, 230);

    // Adds new frame
    List<Frame> frames = new List<Frame>(timeline.Frames);
    frames.Add(new Frame());
    timeline.Frames = frames.ToArray();

    // Change blendMode of 'Layer 1' on frame 4
    LayerState layerState31 = timeline.Frames[3].LayerStates[1];
    layerState31.BlendMode = BlendMode.Dissolve;

    // Apply changes back to PsdImage instance
    psdImage.Save(outputPsd);
}

See Also