protected override void WriteData(PsdBinaryWriter writer) { var startPosition = writer.BaseStream.Position; writer.WriteUnicodeString(Name); writer.WritePadding(startPosition, 4); }
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}"); }
protected override void WriteData(PsdBinaryWriter writer) { var startPosition = writer.BaseStream.Position; writer.WriteUnicodeString(Name); writer.WritePadding(startPosition, 4); }
/// <summary> /// Write out the image resource block: header and data. /// </summary> public void Save(PsdBinaryWriter writer) { 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); }
/////////////////////////////////////////////////////////////////////////// private void SaveLayerAndMaskInfo(PsdBinaryWriter writer) { using (new PsdBlockLengthWriter(writer)) { var startPosition = writer.BaseStream.Position; SaveLayers(writer); SaveGlobalLayerMask(writer); foreach (var info in AdditionalInfo) { info.Save(writer); } writer.WritePadding(startPosition, 2); } }
/////////////////////////////////////////////////////////////////////////// private void SaveLayerAndMaskInfo(PsdBinaryWriter writer) { Debug.WriteLine("SaveLayerAndMaskInfo started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); using (new PsdBlockLengthWriter(writer)) { var startPosition = writer.BaseStream.Position; SaveLayers(writer); SaveGlobalLayerMask(writer); foreach (var info in AdditionalInfo) { info.Save(writer); } writer.WritePadding(startPosition, 2); } }
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); }
private void SaveLayers(PsdBinaryWriter writer) { Debug.WriteLine("SaveLayers started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); using (new PsdBlockLengthWriter(writer)) { var numLayers = (Int16)Layers.Count; if (AbsoluteAlpha) { numLayers = (Int16)(-numLayers); } // Layers section must be empty if the color mode doesn't allow layers. // Photoshop will refuse to load indexed and multichannel images if // there is a nonempty layers section with a layer count of 0. if (numLayers == 0) { return; } var startPosition = writer.BaseStream.Position; writer.Write(numLayers); foreach (var layer in Layers) { layer.Save(writer); } foreach (var layer in Layers) { foreach (var channel in layer.Channels) { channel.SavePixelData(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); } }
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); }
private void SaveLayers(PsdBinaryWriter writer) { using (new PsdBlockLengthWriter(writer)) { var numLayers = (Int16)Layers.Count; if (AbsoluteAlpha) numLayers = (Int16)(-numLayers); // Layers section must be empty if the color mode doesn't allow layers. // Photoshop will refuse to load indexed and multichannel images if // there is a nonempty layers section with a layer count of 0. if (numLayers == 0) return; var startPosition = writer.BaseStream.Position; writer.Write(numLayers); foreach (var layer in Layers) { layer.Save(writer); } foreach (var layer in Layers) { foreach (var channel in layer.Channels) { channel.SavePixelData(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); } }
/////////////////////////////////////////////////////////////////////////// private void SaveLayerAndMaskInfo(PsdBinaryWriter writer) { using (new PsdBlockLengthWriter(writer)) { var startPosition = writer.BaseStream.Position; SaveLayers(writer); SaveGlobalLayerMask(writer); foreach (var info in AdditionalInfo) info.Save(writer); writer.WritePadding(startPosition, 2); } }
/////////////////////////////////////////////////////////////////////////// private void SaveLayerAndMaskInfo(PsdBinaryWriter writer) { Debug.WriteLine("SaveLayerAndMaskInfo started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); using (new PsdBlockLengthWriter(writer)) { var startPosition = writer.BaseStream.Position; SaveLayers(writer); SaveGlobalLayerMask(writer); foreach (var info in AdditionalInfo) info.Save(writer); writer.WritePadding(startPosition, 2); } }