Timeline.SwitchActiveFrame

Timeline.SwitchActiveFrame method

Switches the active frame to targeted.

public void SwitchActiveFrame(int targetActiveFrameIndex)
ParameterTypeDescription
targetActiveFrameIndexInt32The target frame index.

Exceptions

exceptioncondition
IndexOutOfRangeExceptionThe new index of the active frame should be in the frame count range.

Examples

The following code demonstrates a new approach to work with the Timeline.

[C#]

string sourceFile = "4_animated.psd";
string outputFile = "output_edited.psd";

using (var psdImage = (PsdImage)Image.Load(sourceFile))
{
    Timeline timeline = psdImage.Timeline;
    
    // Add one more frame
    List<Frame> frames = new List<Frame>(timeline.Frames);
    frames.Add(new Frame());
    timeline.Frames = frames.ToArray();

    timeline.SwitchActiveFrame(4);

    psdImage.Save(outputFile);
}

See Also