public void Save(BinaryReverseWriter writer) { Debug.WriteLine("BlendingRanges Save started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((UInt32)Data.Length); writer.Write(Data); }
internal void SavePixelData(BinaryReverseWriter writer) { Debug.WriteLine("Channel SavePixelData started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); writer.Write((short)ImageCompression); writer.Write(ImageData); }
public void Save(BinaryReverseWriter writer) { Debug.WriteLine("Mask Save started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); if (Rect.IsEmpty) { writer.Write((uint)0); return; } using (new LengthWriter(writer)) { writer.Write(Rect.Top); writer.Write(Rect.Left); writer.Write(Rect.Bottom); writer.Write(Rect.Right); writer.Write(DefaultColor); writer.Write((byte)_flags.Data); // padding 2 bytes so that size is 20 writer.Write(0); } }
internal void Save(BinaryReverseWriter reverseWriter) { Debug.WriteLine("Channel Save started at " + reverseWriter.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); reverseWriter.Write(ID); CompressImageData(); reverseWriter.Write(Data.Length + 2); // 2 bytes for the image compression }
public void Save(BinaryReverseWriter writer) { Debug.WriteLine("AdjusmentLayerInfo Save started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); const String signature = "8BIM"; writer.Write(signature.ToCharArray()); writer.Write(Key.ToCharArray()); writer.Write((UInt32)Data.Length); writer.Write(Data); }
protected override void StoreData() { var memoryStream = new MemoryStream(); var binaryReverseWriter = new BinaryReverseWriter(memoryStream); foreach (var text in ChannelNames) { binaryReverseWriter.Write((byte)text.Length); binaryReverseWriter.Write(text.ToCharArray()); } binaryReverseWriter.Close(); memoryStream.Close(); Data = memoryStream.ToArray(); }
protected override void StoreData() { var memoryStream = new MemoryStream(); var binaryReverseWriter = new BinaryReverseWriter(memoryStream); binaryReverseWriter.Write(HRes); binaryReverseWriter.Write((int)HResUnit); binaryReverseWriter.Write((short)WidthUnit); binaryReverseWriter.Write(VRes); binaryReverseWriter.Write((int)VResUnit); binaryReverseWriter.Write((short)HeightUnit); binaryReverseWriter.Close(); memoryStream.Close(); Data = memoryStream.ToArray(); }
protected override void StoreData() { MemoryStream memoryStream = new MemoryStream(); BinaryReverseWriter reverseWriter = new BinaryReverseWriter(memoryStream); foreach (String name in ChannelNames) { reverseWriter.Write((Byte)name.Length); reverseWriter.Write(name.ToCharArray()); } reverseWriter.Close(); memoryStream.Close(); Data = memoryStream.ToArray(); }
public void Save(BinaryReverseWriter reverseWriter) { Debug.WriteLine("Layer Save started at " + reverseWriter.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); reverseWriter.Write(Rect.Top); reverseWriter.Write(Rect.Left); reverseWriter.Write(Rect.Bottom); reverseWriter.Write(Rect.Right); reverseWriter.Write((Int16)Channels.Count); foreach (Channel ch in Channels) { ch.Save(reverseWriter); } const String signature = "8BIM"; reverseWriter.Write(signature.ToCharArray()); reverseWriter.Write(_blendModeKeyStr.ToCharArray()); reverseWriter.Write(Opacity); reverseWriter.Write((Byte)(Clipping ? 1 : 0)); reverseWriter.Write((Byte)_flags.Data); reverseWriter.Write((Byte)0); using (new LengthWriter(reverseWriter)) { MaskData.Save(reverseWriter); BlendingRangesData.Save(reverseWriter); Int64 namePosition = reverseWriter.BaseStream.Position; reverseWriter.WritePascalString(Name); Int32 paddingBytes = (int)((reverseWriter.BaseStream.Position - namePosition) % 4); Debug.Print("Layer {0} write padding bytes after name", paddingBytes); for (Int32 i = 0; i < paddingBytes; i++) { reverseWriter.Write((Byte)0); } foreach (AdjusmentLayerInfo info in AdjustmentInfo) { info.Save(reverseWriter); } } }
public void Save(BinaryReverseWriter reverseWriter) { StoreData(); if (OSType == string.Empty) { OSType = "8BIM"; } reverseWriter.Write(OSType.ToCharArray()); reverseWriter.Write(ID); reverseWriter.WritePascalString(Name); reverseWriter.Write(Data.Length); reverseWriter.Write(Data); if (reverseWriter.BaseStream.Position % 2L == 1L) { reverseWriter.Write(0); } }
protected override void StoreData() { MemoryStream memoryStream = new MemoryStream(); BinaryReverseWriter reverseWriter = new BinaryReverseWriter(memoryStream); reverseWriter.Write(HRes); reverseWriter.Write((Int32)HResUnit); reverseWriter.Write((Int16)WidthUnit); reverseWriter.Write(VRes); reverseWriter.Write((Int32)VResUnit); reverseWriter.Write((Int16)HeightUnit); reverseWriter.Close(); memoryStream.Close(); Data = memoryStream.ToArray(); }
private void CompressImageData() { if (ImageCompression == ImageCompression.Rle) { MemoryStream memoryStream = new MemoryStream(); BinaryReverseWriter reverseWriter = new BinaryReverseWriter(memoryStream); // we will write the correct lengths later, so remember // the position Int64 lengthPosition = reverseWriter.BaseStream.Position; Int32[] rleRowLenghs = new Int32[Layer.Rect.Height]; if (ImageCompression == ImageCompression.Rle) { for (Int32 i = 0; i < rleRowLenghs.Length; i++) { reverseWriter.Write((Int16)0x1234); } } Int32 bytesPerRow = 0; switch (Layer.PsdFile.Depth) { case 1: bytesPerRow = Layer.Rect.Width;//NOT Shure break; case 8: bytesPerRow = Layer.Rect.Width; break; case 16: bytesPerRow = Layer.Rect.Width * 2; break; } for (Int32 row = 0; row < Layer.Rect.Height; row++) { Int32 rowIndex = row * Layer.Rect.Width; rleRowLenghs[row] = RleHelper.EncodedRow(reverseWriter.BaseStream, ImageData, rowIndex, bytesPerRow); } Int64 endPosition = reverseWriter.BaseStream.Position; reverseWriter.BaseStream.Position = lengthPosition; foreach (Int32 length in rleRowLenghs) { reverseWriter.Write((Int16)length); } reverseWriter.BaseStream.Position = endPosition; memoryStream.Close(); Data = memoryStream.ToArray(); memoryStream.Dispose(); } else { Data = (byte[])ImageData.Clone(); } }
private void CompressImageData() { if (ImageCompression == ImageCompression.Rle) { MemoryStream memoryStream = new MemoryStream(); BinaryReverseWriter reverseWriter = new BinaryReverseWriter(memoryStream); // we will write the correct lengths later, so remember // the position Int64 lengthPosition = reverseWriter.BaseStream.Position; Int32[] rleRowLenghs = new Int32[Layer.Rect.Height]; if (ImageCompression == ImageCompression.Rle) { for (Int32 i = 0; i < rleRowLenghs.Length; i++) { reverseWriter.Write((Int16)0x1234); } } Int32 bytesPerRow = 0; switch (Layer.PsdFile.Depth) { case 1: bytesPerRow = Layer.Rect.Width; //NOT Shure break; case 8: bytesPerRow = Layer.Rect.Width; break; case 16: bytesPerRow = Layer.Rect.Width * 2; break; } for (Int32 row = 0; row < Layer.Rect.Height; row++) { Int32 rowIndex = row * Layer.Rect.Width; rleRowLenghs[row] = RleHelper.EncodedRow(reverseWriter.BaseStream, ImageData, rowIndex, bytesPerRow); } Int64 endPosition = reverseWriter.BaseStream.Position; reverseWriter.BaseStream.Position = lengthPosition; foreach (Int32 length in rleRowLenghs) { reverseWriter.Write((Int16)length); } reverseWriter.BaseStream.Position = endPosition; memoryStream.Close(); Data = memoryStream.ToArray(); memoryStream.Dispose(); } else { Data = (byte[])ImageData.Clone(); } }
public void Save(BinaryReverseWriter reverseWriter) { Debug.WriteLine("Layer Save started at " + reverseWriter.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); reverseWriter.Write(Rect.Top); reverseWriter.Write(Rect.Left); reverseWriter.Write(Rect.Bottom); reverseWriter.Write(Rect.Right); reverseWriter.Write((Int16)Channels.Count); foreach (Channel ch in Channels) ch.Save(reverseWriter); const String signature = "8BIM"; reverseWriter.Write(signature.ToCharArray()); reverseWriter.Write(_blendModeKeyStr.ToCharArray()); reverseWriter.Write(Opacity); reverseWriter.Write((Byte)(Clipping ? 1 : 0)); reverseWriter.Write((Byte)_flags.Data); reverseWriter.Write((Byte)0); using (new LengthWriter(reverseWriter)) { MaskData.Save(reverseWriter); BlendingRangesData.Save(reverseWriter); Int64 namePosition = reverseWriter.BaseStream.Position; reverseWriter.WritePascalString(Name); Int32 paddingBytes = (int)((reverseWriter.BaseStream.Position - namePosition) % 4); Debug.Print("Layer {0} write padding bytes after name", paddingBytes); for (Int32 i = 0; i < paddingBytes; i++) reverseWriter.Write((Byte)0); foreach (AdjusmentLayerInfo info in AdjustmentInfo) info.Save(reverseWriter); } }
internal void SavePixelData(BinaryReverseWriter writer) { //writer.Write(m_data); }
public void Save(BinaryReverseWriter reverseWriter) { StoreData(); if (OSType == String.Empty) OSType = "8BIM"; reverseWriter.Write(OSType.ToCharArray()); reverseWriter.Write(ID); reverseWriter.WritePascalString(Name); reverseWriter.Write(Data.Length); reverseWriter.Write(Data); if (reverseWriter.BaseStream.Position % 2 == 1) reverseWriter.Write((Byte)0); }