Class AnimatedDataSectionStructure

AnimatedDataSectionStructure class

アニメーションデータのあるセクション.

public class AnimatedDataSectionStructure : OSTypeStructure

プロパティ

名前説明
Items { get; }アニメーション データ セクション構造を取得または設定します。
override Key { get; }構造キーを取得します。
KeyName { get; set; }キー名を取得または設定します。
override Length { get; }を取得しますOSTypeStructureバイト単位の長さ.

メソッド

名前説明
virtual GetHeaderLength()ヘッダー長を取得します。
Save(StreamContainer)指定したストリーム コンテナーに構造体を保存します。
SaveWithoutKeyName(StreamContainer)指定したストリーム コンテナーに構造体を保存します。

田畑

名前説明
const StructureKeyAnDs. の構造キーを識別します。

次のコードは、アニメーション データのタイムライン フレームで遅延時間を設定/更新する方法を示しています。

[C#]

string sourceFile = "3_animated.psd";
string outputPsd = "output_3_animated.psd";

T FindStructure<T>(IEnumerable<OSTypeStructure> structures, string keyName) where T : OSTypeStructure
{
    foreach (var structure in structures)
    {
        if (structure.KeyName.ClassName == keyName)
        {
            return structure as T;
        }
    }

    return null;
}

OSTypeStructure[] AddOrReplaceStructure(IEnumerable<OSTypeStructure> structures, OSTypeStructure newStructure)
{
    List<OSTypeStructure> listOfStructures = new List<OSTypeStructure>(structures);

    for (int i = 0; i < listOfStructures.Count; i++)
    {
        OSTypeStructure structure = listOfStructures[i];
        if (structure.KeyName.ClassName == newStructure.KeyName.ClassName)
        {
            listOfStructures.RemoveAt(i);
            break;
        }
    }

    listOfStructures.Add(newStructure);

    return listOfStructures.ToArray();
}

using (PsdImage image = (PsdImage)Image.Load(sourceFile))
{
    foreach (var imageResource in image.ImageResources)
    {
        if (imageResource is AnimatedDataSectionResource)
        {
            var animatedData =
                (AnimatedDataSectionStructure) (imageResource as AnimatedDataSectionResource).AnimatedDataSection;
            var framesList = FindStructure<ListStructure>(animatedData.Items, "FrIn");

            var frame1 = (DescriptorStructure)framesList.Types[1];

            // 1 秒に等しい値 100 センチ秒のフレーム遅延レコードを作成します。
            var frameDelay = new IntegerStructure(new ClassID("FrDl"));
            frameDelay.Value = 100; // 時間をセンチ秒単位で設定します。

            frame1.Structures = AddOrReplaceStructure(frame1.Structures, frameDelay);

            break;
        }
    }

    image.Save(outputPsd);
}

関連項目