protected override void WriteData(PsdBinaryWriter writer) { var startPosition = writer.BaseStream.Position; writer.WriteUnicodeString(Name); writer.WritePadding(startPosition, 4); }
public void Save(PsdBinaryWriter writer, Boolean globalLayerInfo, Boolean isLargeDocument) { Util.DebugMessage(writer.BaseStream, "Save, Begin, LayerInfo, {0}, {1}", Signature, Key); writer.WriteAsciiChars(Signature); writer.WriteAsciiChars(Key); var startPosition = writer.BaseStream.Position; using (var lengthWriter = new PsdBlockLengthWriter(writer, LayerInfoUtil.HasLongLength(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, {0}, {1}", Signature, Key); }
/// <summary> /// Write out the image resource block: header and data. /// </summary> public void Save(PsdBinaryWriter writer) { Util.DebugMessage(writer.BaseStream, "Save, Begin, ImageResource"); writer.WriteAsciiChars(Signature); writer.Write((UInt16)ID); writer.WritePascalString(Name, 2); // Length is unpadded, but data is even-padded var startPosition = writer.BaseStream.Position; using (new PsdBlockLengthWriter(writer)) { WriteData(writer); } writer.WritePadding(startPosition, 2); Util.DebugMessage(writer.BaseStream, "Save, End, ImageResource, {0}", ID); }
/////////////////////////////////////////////////////////////////////////// private void SaveLayerAndMaskInfo(PsdBinaryWriter writer) { Util.DebugMessage(writer.BaseStream, "Save, Begin, Layer and mask info"); using (new PsdBlockLengthWriter(writer, IsLargeDocument)) { var startPosition = writer.BaseStream.Position; SaveLayers(writer); SaveGlobalLayerMask(writer); foreach (var info in AdditionalInfo) { info.Save(writer, globalLayerInfo: true, isLargeDocument: IsLargeDocument); } writer.WritePadding(startPosition, 2); } Util.DebugMessage(writer.BaseStream, "Save, End, Layer and mask info"); }
/// <summary> /// Saves the Layers Info section, including headers and padding. /// </summary> /// <param name="writer">The PSD writer.</param> internal void SaveLayers(PsdBinaryWriter writer) { Util.DebugMessage(writer.BaseStream, "Save, Begin, Layers Info section"); using (new PsdBlockLengthWriter(writer, IsLargeDocument)) { var startPosition = writer.BaseStream.Position; // Only one set of Layers can exist in the file. If layers will be // written to the Additional Info section, then the Layers section // must be empty to avoid conflict. var hasInfoLayers = AdditionalInfo.Exists(x => x is InfoLayers); if (!hasInfoLayers) { SaveLayersData(writer); } // Documentation states that the Layers Info section is even-padded, // but it is actually padded to a multiple of 4. writer.WritePadding(startPosition, 4); } Util.DebugMessage(writer.BaseStream, "Save, End, Layers Info section"); }