public LengthWriter(BinaryReverseWriter writer) { _reverseWriter = writer; _lengthPosition = _reverseWriter.BaseStream.Position; _reverseWriter.Write(4277010157u); _startPosition = _reverseWriter.BaseStream.Position; }
public LengthWriter(BinaryReverseWriter writer) { _reverseWriter = writer; // we will write the correct length later, so remember // the position _lengthPosition = _reverseWriter.BaseStream.Position; _reverseWriter.Write(0xFEEDFEED); // remember the start position for calculation Image // resources length _startPosition = _reverseWriter.BaseStream.Position; }
public LengthWriter(BinaryReverseWriter writer) { _reverseWriter = writer; // we will write the correct length later, so remember // the position _lengthPosition = _reverseWriter.BaseStream.Position; _reverseWriter.Write(0xFEEDFEED); // remember the start position for calculation Image // resources length _startPosition = _reverseWriter.BaseStream.Position; }
public void Write() { if (m_lengthPosition != long.MinValue) { long endPosition = m_writer.BaseStream.Position; m_writer.BaseStream.Position = m_lengthPosition; long length = endPosition - m_startPosition; m_writer.Write((uint)length); m_writer.BaseStream.Position = endPosition; m_lengthPosition = long.MinValue; } }
public void Write() { if (_lengthPosition == long.MinValue) { return; } long endPosition = _reverseWriter.BaseStream.Position; _reverseWriter.BaseStream.Position = _lengthPosition; long length = endPosition - _startPosition; _reverseWriter.Write((uint)length); _reverseWriter.BaseStream.Position = endPosition; _lengthPosition = long.MinValue; }
static private void UpdatePsd(FileInfo fileInfo, Dictionary <string, Color> convertMap) { Console.Out.WriteLine("Start Convert " + fileInfo.FullName); var fileStream = new FileStream(fileInfo.FullName, FileMode.Open); if (fileStream == null) { Console.Out.WriteLine("Paramter Error, Skip"); return; } var psdFile = new PsdFile(fileStream, new LoadContext()); fileStream.Close(); foreach (Layer layr in psdFile.Layers) { var layName = layr.Name.ToUpper(); try { var findKey = convertMap.Single(x => layName.Contains(x.Key)); var color = findKey.Value; var vscg = layr.AdditionalInfo.SingleOrDefault(x => x.Key == "vscg"); var solidColor = layr.AdditionalInfo.SingleOrDefault(x => x.Key == "SoCo"); //var tysh = layr.AdditionalInfo.SingleOrDefault(x => x.Key == "TySh"); if (solidColor == null /*&& tysh == null*/ && vscg == null) { ConsoleColor oldColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine("Convert Error : " + fileInfo.FullName); Console.ForegroundColor = oldColor; return; } if (vscg != null) { solidColor = vscg; } if (solidColor != null) { PhotoshopFile.PsdDescriptor eff = new PhotoshopFile.PsdDescriptor(CreateReadStream(solidColor)); double red = color.R; double green = color.G; double blue = color.B; byte[] redBuffer, greenBuffer, blueBuffer; unsafe { BinaryReverseReader.SwapBytes((byte *)&red, 8); redBuffer = ConvertDoubleToByteArray(red); BinaryReverseReader.SwapBytes((byte *)&green, 8); greenBuffer = ConvertDoubleToByteArray(green); BinaryReverseReader.SwapBytes((byte *)&blue, 8); blueBuffer = ConvertDoubleToByteArray(blue); } long redOffset = 0, greenOffset = 0, blueOffset = 0; GetPSDColorOffset(eff, ref redOffset, ref greenOffset, ref blueOffset); BinaryReverseWriter writer = CreateWriteStream(solidColor); writer.Seek((int)redOffset, SeekOrigin.Begin); writer.Write(redBuffer); writer.Seek((int)greenOffset, SeekOrigin.Begin); writer.Write(greenBuffer); writer.Seek((int)blueOffset, SeekOrigin.Begin); writer.Write(blueBuffer); } //else if (tysh != null) //{ // PhotoshopFile.LayerResources.TypeToolTyShPH6 txt = new PhotoshopFile.LayerResources.TypeToolTyShPH6(CreateReadStream(tysh)); // Dictionary<string, object> d = txt.StylesheetReader.GetStylesheetDataFromLongestRun(); // BinaryReverseWriter writer = CreateWriteStream(tysh); // //writer.Seek((int)redOffset, SeekOrigin.Begin); // //writer.Write(redBuffer); // //writer.Seek((int)greenOffset, SeekOrigin.Begin); // //writer.Write(greenBuffer); // //writer.Seek((int)blueOffset, SeekOrigin.Begin); // //writer.Write(blueBuffer); //} } catch { } } psdFile.Save(fileInfo.DirectoryName + "\\_" + fileInfo.Name, Encoding.Default); Console.Out.WriteLine("Convert Finished, Save to " + fileInfo.DirectoryName + "\\_" + fileInfo.Name, Encoding.Default); }
protected override void StoreData() { var stream = new MemoryStream(); var writer = new BinaryReverseWriter(stream); foreach (string name in _channelNames) { writer.Write((byte)name.Length); writer.Write(name.ToCharArray()); } writer.Close(); stream.Close(); Data = stream.ToArray(); }
protected override void StoreData() { var stream = new MemoryStream(); var writer = new BinaryReverseWriter(stream); writer.Write(HRes); writer.Write((Int32)HResUnit); writer.Write((Int16)WidthUnit); writer.Write(VRes); writer.Write((Int32)VResUnit); writer.Write((Int16)HeightUnit); writer.Close(); stream.Close(); Data = stream.ToArray(); }