private void SaveColorModeData(PsdBinaryWriter writer) { Debug.WriteLine("SaveColorModeData started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((UInt32)ColorModeData.Length); writer.Write(ColorModeData); }
internal void Save(PsdBinaryWriter writer) { Debug.WriteLine("Channel Save started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write(ID); writer.Write(Length); }
/////////////////////////////////////////////////////////////////////////// public void Save(PsdBinaryWriter writer) { Debug.WriteLine("BlendingRanges Save started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((UInt32)Data.Length); writer.Write(Data); }
/////////////////////////////////////////////////////////////////////////// public void Save(PsdBinaryWriter writer) { Debug.WriteLine("BlendingRanges Save started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((UInt32)Data.Length); writer.Write(Data); }
/////////////////////////////////////////////////////////////////////////// private void SaveGlobalLayerMask(PsdBinaryWriter writer) { Debug.WriteLine("SaveGlobalLayerMask started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((UInt32)GlobalLayerMaskData.Length); writer.Write(GlobalLayerMaskData); }
public override void WriteData(PsdBinaryWriter writer) { if (!string.IsNullOrEmpty(Key)) { writer.WriteAsciiChars(Key); } writer.WriteUnicodeString(ClassIDName); if (ClassID.Length != 4) { writer.Write(ClassID.Length); } else { writer.Write(0); } writer.WriteAsciiChars(ClassID); writer.Write(Descriptor.Count); foreach (var pair in Descriptor) { writer.Write(pair.Key.Length == 4 ? 0 : pair.Key.Length); writer.WriteAsciiChars(pair.Key); pair.Value.WriteData(writer); } }
protected override void WriteData(PsdBinaryWriter writer) { writer.Write(Version); writer.Write(HasRealMergedData); writer.WriteUnicodeString(ReaderName); writer.WriteUnicodeString(WriterName); writer.Write(FileVersion); }
public override void WriteData(PsdBinaryWriter writer) { writer.WriteAsciiChars(Key); writer.WriteUnicodeString(NameFromClassID); writer.Write(ClassID.Length == 4 ? 0 : ClassID.Length); writer.WriteAsciiChars(ClassID); writer.Write(Offset); }
protected override void WriteData(PsdBinaryWriter writer) { writer.Write(Version); writer.Write(HasRealMergedData); writer.WriteUnicodeString(ReaderName); writer.WriteUnicodeString(WriterName); writer.Write(FileVersion); }
public override void WriteData(PsdBinaryWriter writer) { writer.WriteAsciiChars(Key); writer.Write(Type.Length == 4 ? 0 : Type.Length); writer.WriteAsciiChars(Type); writer.Write(Enum.Length == 4 ? 0 : Enum.Length); writer.WriteAsciiChars(Enum); }
protected override void WriteData(PsdBinaryWriter writer) { writer.Write((Int32)SectionType); if (BlendModeKey != null) { writer.WriteAsciiChars("8BIM"); writer.WriteAsciiChars(BlendModeKey); if (subtype != null) { writer.Write((Int32)Subtype); } } }
/////////////////////////////////////////////////////////////////////////// public void Save(PsdBinaryWriter writer) { Debug.WriteLine("MaskInfo Save started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); if (LayerMask == null) { writer.Write((UInt32)0); return; } using (new PsdBlockLengthWriter(writer)) { writer.Write(LayerMask.Rect); writer.Write(LayerMask.BackgroundColor); writer.Write((byte)LayerMask.Flags.Data); if (UserMask == null) { // Pad by 2 bytes to make the block length 20 writer.Write((UInt16)0); } else { writer.Write((byte)UserMask.Flags.Data); writer.Write(UserMask.BackgroundColor); writer.Write(UserMask.Rect); } } }
internal void SavePixelData(PsdBinaryWriter writer) { writer.Write((short)ImageCompression); if (ImageDataRaw == null) { return; } if (ImageCompression == PhotoshopFile.ImageCompression.Rle) { RleRowLengths.Write(writer); } writer.Write(ImageDataRaw); }
/////////////////////////////////////////////////////////////////////////// public void Save(PsdBinaryWriter writer) { if (LayerMask == null) { writer.Write((UInt32)0); return; } using (new PsdBlockLengthWriter(writer)) { writer.Write(LayerMask.Rect); writer.Write(LayerMask.BackgroundColor); writer.Write((byte)LayerMask.Flags.Data); if (UserMask == null) { // Pad by 2 bytes to make the block length 20 writer.Write((UInt16)0); } else { writer.Write((byte)UserMask.Flags.Data); writer.Write(UserMask.BackgroundColor); writer.Write(UserMask.Rect); } } }
/////////////////////////////////////////////////////////////////////////// private void SaveImage(PsdBinaryWriter writer) { writer.Write((short)this.ImageCompression); if (this.ImageCompression == PhotoshopFile.ImageCompression.Rle) { foreach (var channel in this.BaseLayer.Channels) { channel.RleRowLengths.Write(writer); } } foreach (var channel in this.BaseLayer.Channels) { writer.Write(channel.ImageDataRaw); } }
/////////////////////////////////////////////////////////////////////////// public void Save(PsdBinaryWriter writer) { Util.DebugMessage(writer.BaseStream, "Save, Begin, BlendingRanges"); if (Data == null) { writer.Write((UInt32)0); return; } writer.Write((UInt32)Data.Length); writer.Write(Data); Util.DebugMessage(writer.BaseStream, "Save, End, BlendingRanges"); }
internal void Save(PsdBinaryWriter writer) { Util.DebugMessage(writer.BaseStream, "Save, Begin, Channel"); writer.Write(ID); if (Layer.PsdFile.IsLargeDocument) { writer.Write(Length); } else { writer.Write((Int32)Length); } Util.DebugMessage(writer.BaseStream, $"Save, End, Channel, {ID}"); }
public void Write(PsdBinaryWriter writer) { for (int i = 0; i < Values.Length; i++) { writer.Write((UInt16)Values[i]); } }
public void Write(PsdBinaryWriter writer) { for (int i = 0; i < Values.Length; i++) { writer.Write((UInt16)Values[i]); } }
internal void SavePixelData(PsdBinaryWriter writer) { Debug.WriteLine("Channel SavePixelData started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((short)ImageCompression); if (Data == null) { return; } if (ImageCompression == PhotoshopFile.ImageCompression.Rle) { writer.Write(this.RleHeader); } writer.Write(Data); }
/////////////////////////////////////////////////////////////////////////// private void SaveImage(PsdBinaryWriter writer) { Debug.WriteLine("SaveImage started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((short)this.ImageCompression); if (this.ImageCompression == PhotoshopFile.ImageCompression.Rle) { foreach (var channel in this.BaseLayer.Channels) { writer.Write(channel.RleHeader); } } foreach (var channel in this.BaseLayer.Channels) { writer.Write(channel.Data); } }
public override void WriteData(PsdBinaryWriter writer) { writer.WriteAsciiChars(Key); writer.Write(References.Length); for (int i = 0; i < References.Length; ++i) { References [i].WriteData(writer); } }
public override void WriteData(PsdBinaryWriter writer) { writer.WriteAsciiChars(Key); writer.Write(List.Length); for (int i = 0; i < List.Length; ++i) { List [i].WriteData(writer); } }
internal void SavePixelData(PsdBinaryWriter writer) { Util.DebugMessage(writer.BaseStream, "Save, Begin, Channel image"); writer.Write((short)ImageCompression); if (ImageDataRaw == null) { return; } if (ImageCompression == PhotoshopFile.ImageCompression.Rle) { RleRowLengths.Write(writer, Layer.PsdFile.IsLargeDocument); } writer.Write(ImageDataRaw); Util.DebugMessage(writer.BaseStream, $"Save, End, Channel image, {ID}"); }
public void Write() { var endPosition = writer.BaseStream.Position; writer.BaseStream.Position = lengthPosition; long length = endPosition - startPosition; if (hasLongLength) { writer.Write(length); } else { writer.Write((UInt32)length); } writer.BaseStream.Position = endPosition; }
public PsdBlockLengthWriter(PsdBinaryWriter writer, bool hasLongLength) { this.writer = writer; this.hasLongLength = hasLongLength; // Store position so that we can return to it when the length is known. lengthPosition = writer.BaseStream.Position; // Write a sentinel value as a placeholder for the length. writer.Write((UInt32)0xFEEDFEED); if (hasLongLength) { writer.Write((UInt32)0xFEEDFEED); } // Store the start position of the data block so that we can calculate // its length when we're done writing. startPosition = writer.BaseStream.Position; }
protected override void WriteData(PsdBinaryWriter writer) { writer.Write(HDpi.Integer); writer.Write(HDpi.Fraction); writer.Write((Int16)HResDisplayUnit); writer.Write((Int16)WidthDisplayUnit); writer.Write(VDpi.Integer); writer.Write(VDpi.Fraction); writer.Write((Int16)VResDisplayUnit); writer.Write((Int16)HeightDisplayUnit); }
public void Write() { var endPosition = writer.BaseStream.Position; writer.BaseStream.Position = lengthPosition; long length = endPosition - startPosition; writer.Write((UInt32)length); writer.BaseStream.Position = endPosition; }
public void CompressImageData() { // Can be called implicitly by Layer.PrepareSave or explicitly by the // consumer of this library. Since image data compression can take // some time, explicit calling makes more accurate progress available. if (imageDataCompressed) { return; } if (ImageCompression == ImageCompression.Rle) { var dataStream = new MemoryStream(); var headerStream = new MemoryStream(); var rleWriter = new RleWriter(dataStream); var headerWriter = new PsdBinaryWriter(headerStream, Encoding.ASCII); //--------------------------------------------------------------- var rleRowLengths = new UInt16[Layer.Rect.Height]; var bytesPerRow = Util.BytesPerRow(Layer.Rect, Layer.PsdFile.BitDepth); for (int row = 0; row < Layer.Rect.Height; row++) { int rowIndex = row * Layer.Rect.Width; rleRowLengths[row] = (UInt16)rleWriter.Write(ImageData, rowIndex, bytesPerRow); } // Write RLE row lengths and save for (int i = 0; i < rleRowLengths.Length; i++) { headerWriter.Write(rleRowLengths[i]); } headerStream.Flush(); this.RleHeader = headerStream.ToArray(); headerStream.Close(); // Save compressed data dataStream.Flush(); data = dataStream.ToArray(); dataStream.Close(); Length = 2 + RleHeader.Length + Data.Length; } else { data = ImageData; this.Length = 2 + Data.Length; } imageDataCompressed = true; }
public PsdBlockLengthWriter(PsdBinaryWriter writer) { this.writer = writer; // Store position so that we can return to it when the length is known. lengthPosition = writer.BaseStream.Position; // Write a sentinel value as a placeholder for the length. writer.Write((UInt32)0xFEEDFEED); // Store the start position of the data block so that we can calculate // its length when we're done writing. startPosition = writer.BaseStream.Position; }
/////////////////////////////////////////////////////////////////////////// private void SaveHeader(PsdBinaryWriter writer) { string signature = "8BPS"; writer.WriteAsciiChars(signature); writer.Write(Version); writer.Write(new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }); writer.Write(ChannelCount); writer.Write(RowCount); writer.Write(ColumnCount); writer.Write((Int16)BitDepth); writer.Write((Int16)ColorMode); }
/// <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 SaveHeader(PsdBinaryWriter writer) { Debug.WriteLine("SaveHeader started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); string signature = "8BPS"; writer.WriteAsciiChars(signature); writer.Write(Version); writer.Write(new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }); writer.Write(ChannelCount); writer.Write(RowCount); writer.Write(ColumnCount); writer.Write((Int16)BitDepth); writer.Write((Int16)ColorMode); }
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); } }
protected override void WriteData(PsdBinaryWriter writer) { writer.Write(Data); }
/////////////////////////////////////////////////////////////////////////// public void Save(PsdBinaryWriter writer) { Debug.WriteLine("MaskInfo Save started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); if (LayerMask == null) { writer.Write((UInt32)0); return; } using (new PsdBlockLengthWriter(writer)) { writer.Write(LayerMask.Rect); writer.Write(LayerMask.BackgroundColor); writer.Write((byte)LayerMask.Flags.Data); if (UserMask == null) { // Pad by 2 bytes to make the block length 20 writer.Write((UInt16)0); } else { writer.Write((byte)UserMask.Flags.Data); writer.Write(UserMask.BackgroundColor); writer.Write(UserMask.Rect); } } }
/////////////////////////////////////////////////////////////////////////// private void SaveGlobalLayerMask(PsdBinaryWriter writer) { Debug.WriteLine("SaveGlobalLayerMask started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((UInt32)GlobalLayerMaskData.Length); writer.Write(GlobalLayerMaskData); }
/////////////////////////////////////////////////////////////////////////// private void SaveHeader(PsdBinaryWriter writer) { Debug.WriteLine("SaveHeader started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); string signature = "8BPS"; writer.WriteAsciiChars(signature); writer.Write(Version); writer.Write(new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }); writer.Write(ChannelCount); writer.Write(RowCount); writer.Write(ColumnCount); writer.Write((Int16)BitDepth); writer.Write((Int16)ColorMode); }
/////////////////////////////////////////////////////////////////////////// private void SaveImage(PsdBinaryWriter writer) { Debug.WriteLine("SaveImage started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((short)this.ImageCompression); if (this.ImageCompression == PhotoshopFile.ImageCompression.Rle) { foreach (var channel in this.BaseLayer.Channels) writer.Write(channel.RleHeader); } foreach (var channel in this.BaseLayer.Channels) { writer.Write(channel.Data); } }
public void Save(PsdBinaryWriter writer) { writer.Write(Rect); //----------------------------------------------------------------------- writer.Write((short)Channels.Count); foreach (var ch in Channels) ch.Save(writer); //----------------------------------------------------------------------- writer.WriteAsciiChars("8BIM"); writer.WriteAsciiChars(BlendModeKey); writer.Write(Opacity); writer.Write(Clipping); writer.Write((byte)flags.Data); //----------------------------------------------------------------------- writer.Write((byte)0); //----------------------------------------------------------------------- using (new PsdBlockLengthWriter(writer)) { Masks.Save(writer); BlendingRangesData.Save(writer); var namePosition = writer.BaseStream.Position; // Legacy layer name is limited to 31 bytes. Unicode layer name // can be much longer. writer.WritePascalString(Name, 4, 31); foreach (LayerInfo info in AdditionalInfo) { info.Save(writer); } } }
protected override void WriteData(PsdBinaryWriter writer) { writer.Write((Int32)SectionType); if (BlendModeKey != null) { writer.WriteAsciiChars("8BIM"); writer.WriteAsciiChars(BlendModeKey); if (subtype != null) writer.Write((Int32)Subtype); } }
/////////////////////////////////////////////////////////////////////////// private void SaveHeader(PsdBinaryWriter writer) { string signature = "8BPS"; writer.WriteAsciiChars(signature); writer.Write(Version); writer.Write(new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }); writer.Write(ChannelCount); writer.Write(RowCount); writer.Write(ColumnCount); writer.Write((Int16)BitDepth); writer.Write((Int16)ColorMode); }
/////////////////////////////////////////////////////////////////////////// private void SaveImage(PsdBinaryWriter writer) { writer.Write((short)this.ImageCompression); if (this.ImageCompression == PhotoshopFile.ImageCompression.Rle) { foreach (var channel in this.BaseLayer.Channels) channel.RleRowLengths.Write(writer); } foreach (var channel in this.BaseLayer.Channels) { writer.Write(channel.ImageDataRaw); } }
private void SaveColorModeData(PsdBinaryWriter writer) { writer.Write((UInt32)ColorModeData.Length); writer.Write(ColorModeData); }
/////////////////////////////////////////////////////////////////////////// public void Save(PsdBinaryWriter writer) { if (LayerMask == null) { writer.Write((UInt32)0); return; } using (new PsdBlockLengthWriter(writer)) { writer.Write(LayerMask.Rect); writer.Write(LayerMask.BackgroundColor); writer.Write((byte)LayerMask.Flags.Data); if (UserMask == null) { // Pad by 2 bytes to make the block length 20 writer.Write((UInt16)0); } else { writer.Write((byte)UserMask.Flags.Data); writer.Write(UserMask.BackgroundColor); writer.Write(UserMask.Rect); } } }
private void SaveColorModeData(PsdBinaryWriter writer) { Debug.WriteLine("SaveColorModeData started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((UInt32)ColorModeData.Length); writer.Write(ColorModeData); }
protected override void WriteData(PsdBinaryWriter writer) { writer.Write(HDpi.Integer); writer.Write(HDpi.Fraction); writer.Write((Int16)HResDisplayUnit); writer.Write((Int16)WidthDisplayUnit); writer.Write(VDpi.Integer); writer.Write(VDpi.Fraction); writer.Write((Int16)VResDisplayUnit); writer.Write((Int16)HeightDisplayUnit); }
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 SaveGlobalLayerMask(PsdBinaryWriter writer) { writer.Write((UInt32)GlobalLayerMaskData.Length); writer.Write(GlobalLayerMaskData); }