예제 #1
0
			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);
			}
예제 #2
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
			}
예제 #3
0
			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);
			}
예제 #4
0
		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();
		}
예제 #5
0
		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);
		}
예제 #6
0
			internal void SavePixelData(BinaryReverseWriter writer)
			{
				Debug.WriteLine("Channel SavePixelData started at " + writer.BaseStream.Position.ToString(CultureInfo.InvariantCulture));

				writer.Write((short)ImageCompression);
				writer.Write(ImageData);
			}
예제 #7
0
			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();
				}
			}
예제 #8
0
파일: Layer.cs 프로젝트: HaKDMoDz/eStd
		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);
			}
		}