public void Save(PsdBinaryWriter writer, bool globalLayerInfo, bool isLargeDocument) { Util.DebugMessage(writer.BaseStream, $"Save, Begin, LayerInfo, {Signature}, {Key}"); writer.WriteAsciiChars(Signature); writer.WriteAsciiChars(Key); var startPosition = writer.BaseStream.Position; using (var lengthWriter = new PsdBlockLengthWriter(writer, LayerInfoUtil.HasLongLength(Signature, Key, isLargeDocument))) { // Depending on the key, the length may be unpadded, 2-padded, or // 4-padded. Thus, it is up to each implementation of WriteData to // pad the length correctly. WriteData(writer); } // Data for global layer info is always padded to a multiple of 4, // even if this causes the stated length to be incorrect. if (globalLayerInfo) { writer.WritePadding(startPosition, 4); } Util.DebugMessage(writer.BaseStream, $"Save, End, LayerInfo, {Signature}, {Key}"); }
public void Save(PsdBinaryWriter writer) { Debug.WriteLine("LayerInfo.Save started at " + writer.BaseStream.Position); writer.WriteAsciiChars("8BIM"); writer.WriteAsciiChars(Key); var startPosition = writer.BaseStream.Position; using (var lengthWriter = new PsdBlockLengthWriter(writer)) { // Depending on the key, the length may be unpadded, 2-padded, or // 4-padded. Thus, it is up to each implementation of WriteData to // pad the length correctly. WriteData(writer); } // Regardless of how the length is padded, the data is always padded to // a multiple of 4. writer.WritePadding(startPosition, 4); }