Exemplo n.º 1
0
        public void Save(PsdBinaryWriter writer, Boolean globalLayerInfo,
                         Boolean isLargeDocument)
        {
            Util.DebugMessage(writer.BaseStream, "Save, Begin, LayerInfo, {0}, {1}",
                              Signature, Key);

            writer.WriteAsciiChars(Signature);
            writer.WriteAsciiChars(Key);

            var startPosition = writer.BaseStream.Position;

            using (var lengthWriter = new PsdBlockLengthWriter(writer,
                                                               LayerInfoUtil.HasLongLength(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, {0}, {1}",
                              Signature, Key);
        }
Exemplo n.º 2
0
 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);
         }
     }
 }
Exemplo n.º 3
0
        public void Save(PsdBinaryWriter writer)
        {
            Util.DebugMessage(writer.BaseStream, "Save, Begin, Layer");

            writer.Write(Rect);

            //-----------------------------------------------------------------------

            writer.Write((Int16)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,
                              globalLayerInfo: false,
                              isLargeDocument: PsdFile.IsLargeDocument);
                }
            }

            Util.DebugMessage(writer.BaseStream, "Save, End, Layer, {0}", Name);
        }
Exemplo n.º 4
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveHeader(PsdBinaryWriter writer)
        {
            Util.DebugMessage(writer.BaseStream, "Save, Begin, File header");

            string signature = "8BPS";

            writer.WriteAsciiChars(signature);
            writer.Write((Int16)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);

            Util.DebugMessage(writer.BaseStream, "Save, End, File header");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Write out the image resource block: header and data.
        /// </summary>
        public void Save(PsdBinaryWriter writer)
        {
            Util.DebugMessage(writer.BaseStream, "Save, Begin, ImageResource");

            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);

            Util.DebugMessage(writer.BaseStream, "Save, End, ImageResource, {0}", ID);
        }