Ejemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveGlobalLayerMask(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveGlobalLayerMask started at " + writer.BaseStream.Position.ToString());

            writer.Write((uint)GlobalLayerMaskData.Length);
            writer.Write(GlobalLayerMaskData);
        }
Ejemplo n.º 2
0
        private void SaveColorModeData(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveColorModeData started at " + writer.BaseStream.Position.ToString());

            writer.Write((uint)ColorModeData.Length);
            writer.Write(ColorModeData);
        }
Ejemplo n.º 3
0
            internal void SavePixelData(BinaryReverseWriter writer)
            {
                Debug.WriteLine("Channel SavePixelData started at " + writer.BaseStream.Position.ToString());

                writer.Write((short)m_imageCompression);
                writer.Write(m_data);
            }
Ejemplo n.º 4
0
            internal void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("Channel Save started at " + writer.BaseStream.Position.ToString());

                writer.Write(m_id);
                writer.Write(Data.Length + 2); // 2 bytes for the image compression tag
            }
Ejemplo n.º 5
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveLayers(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveLayers started at " + writer.BaseStream.Position);

            using (new LengthWriter(writer))
            {
                var numberOfLayers = (short)m_layers.Count;
                if (AbsoluteAlpha)
                {
                    numberOfLayers = (short)-numberOfLayers;
                }

                writer.Write(numberOfLayers);

                foreach (var layer in m_layers)
                {
                    layer.Save(writer);
                }

                foreach (var layer in m_layers)
                {
                    foreach (Layer.Channel channel in layer.Channels)
                    {
                        channel.SavePixelData(writer);
                    }
                }

                if (writer.BaseStream.Position % 2 == 1)
                {
                    writer.Write((byte)0);
                }
            }
        }
Ejemplo n.º 6
0
            ///////////////////////////////////////////////////////////////////////////

            public void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("Mask Save started at " + writer.BaseStream.Position.ToString());

                if (m_rect.IsEmpty)
                {
                    writer.Write((uint)0);
                    return;
                }

                using (new LengthWriter(writer))
                {
                    writer.Write(m_rect.Top);
                    writer.Write(m_rect.Left);
                    writer.Write(m_rect.Bottom);
                    writer.Write(m_rect.Right);

                    writer.Write(m_defaultColor);

                    writer.Write((byte)m_flags.Data);

                    // padding 2 bytes so that size is 20
                    writer.Write((int)0);
                }
            }
Ejemplo n.º 7
0
            ///////////////////////////////////////////////////////////////////////////

            public void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("BlendingRanges Save started at " + writer.BaseStream.Position.ToString());

                writer.Write((uint)m_data.Length);
                writer.Write(m_data);
            }
Ejemplo n.º 8
0
            public void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("AdjusmentLayerInfo Save started at " + writer.BaseStream.Position);

                writer.Write(LayerConstants.EightBimSignatureArray);
                writer.Write(m_key.ToCharArray());
                writer.Write((uint)m_data.Length);
                writer.Write(m_data);
            }
Ejemplo n.º 9
0
        public void Save(BinaryReverseWriter writer)
        {
            Debug.WriteLine("Layer Save started at " + writer.BaseStream.Position.ToString());

            writer.Write(m_rect.Top);
            writer.Write(m_rect.Left);
            writer.Write(m_rect.Bottom);
            writer.Write(m_rect.Right);

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

            writer.Write((short)m_channels.Count);
            foreach (Channel ch in m_channels)
            {
                ch.Save(writer);
            }

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

            string signature = "8BIM";

            writer.Write(signature.ToCharArray());
            writer.Write(m_blendModeKey.ToCharArray());
            writer.Write(m_opacity);
            writer.Write((byte)(m_clipping ? 1 : 0));

            writer.Write((byte)m_flags.Data);

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

            writer.Write((byte)0);

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

            using (new LengthWriter(writer))
            {
                m_maskData.Save(writer);
                m_blendingRangesData.Save(writer);

                long namePosition = writer.BaseStream.Position;

                writer.WritePascalString(m_name);

                int paddingBytes = (int)((writer.BaseStream.Position - namePosition) % 4);
                Debug.Print("Layer {0} write padding bytes after name", paddingBytes);

                for (int i = 0; i < paddingBytes; i++)
                {
                    writer.Write((byte)0);
                }

                foreach (AdjustmentLayerInfo info in m_adjustmentInfo)
                {
                    info.Save(writer);
                }
            }
        }
Ejemplo n.º 10
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveLayerAndMaskInfo(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveLayerAndMaskInfo started at " + writer.BaseStream.Position.ToString());

            using (new LengthWriter(writer))
            {
                SaveLayers(writer);
                SaveGlobalLayerMask(writer);
            }
        }
Ejemplo n.º 11
0
            public void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("AdjustmentLayerInfo Save started at " + writer.BaseStream.Position.ToString());

                string signature = "8BIM";

                writer.Write(signature.ToCharArray());
                writer.Write(m_key.ToCharArray());
                writer.Write((uint)m_data.Length);
                writer.Write(m_data);
            }
Ejemplo n.º 12
0
        public void Save(Stream stream)
        {
            BinaryReverseWriter writer = new BinaryReverseWriter(stream);

            writer.AutoFlush = true;

            SaveHeader(writer);
            SaveColorModeData(writer);
            SaveImageResources(writer);
            SaveLayerAndMaskInfo(writer);
            SaveImage(writer);
        }
Ejemplo n.º 13
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveImageResources(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveImageResources started at " + writer.BaseStream.Position.ToString());

            using (new LengthWriter(writer))
            {
                foreach (ImageResource imgRes in m_imageResources)
                {
                    imgRes.Save(writer);
                }
            }
        }
Ejemplo n.º 14
0
        private void SaveHeader(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveHeader started at " + writer.BaseStream.Position);

            writer.Write(ArrayEightBPS);
            writer.Write(Version);
            writer.Write(new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 });
            writer.Write(m_channels);
            writer.Write(m_rows);
            writer.Write(m_columns);
            writer.Write((short)m_depth);
            writer.Write((short)m_colorMode);
        }
Ejemplo n.º 15
0
        public LengthWriter(BinaryReverseWriter writer)
        {
            m_writer = writer;

            // we will write the correct length later, so remember
            // the position
            m_lengthPosition = m_writer.BaseStream.Position;
            m_writer.Write((uint)0xFEEDFEED);

            // remember the start  position for calculation Image
            // resources length
            m_startPosition = m_writer.BaseStream.Position;
        }
Ejemplo n.º 16
0
        public override ushort ReadUInt16()
        {
            ushort val = base.ReadUInt16();

#if true
            return(BinaryReverseWriter.SwapBytes(val));
#else
            unsafe
            {
                this.SwapBytes((byte *)&val, 2);
            }
            return(val);
#endif
        }
Ejemplo n.º 17
0
        public override long ReadInt64()
        {
            long val = base.ReadInt64();

#if true
            return(BinaryReverseWriter.SwapBytes(val));
#else
            unsafe
            {
                this.SwapBytes((byte *)&val, 8);
            }
            return(val);
#endif
        }
Ejemplo n.º 18
0
        public override int ReadInt32()
        {
            int val = base.ReadInt32();

#if true
            return(BinaryReverseWriter.SwapBytes(val));
#else
            unsafe
            {
                this.SwapBytes((byte *)&val, 4);
            }
            return(val);
#endif
        }
Ejemplo n.º 19
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveHeader(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveHeader started at " + writer.BaseStream.Position.ToString());

            string signature = "8BPS";

            writer.Write(signature.ToCharArray());
            writer.Write(Version);
            writer.Write(new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, });
            writer.Write(m_channels);
            writer.Write(m_rows);
            writer.Write(m_columns);
            writer.Write((short)m_depth);
            writer.Write((short)m_colorMode);
        }
Ejemplo n.º 20
0
        protected override void StoreData()
        {
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            BinaryReverseWriter    writer = new BinaryReverseWriter(stream);

            foreach (string name in m_channelNames)
            {
                writer.Write((byte)name.Length);
                writer.Write(name.ToCharArray());
            }

            writer.Close();
            stream.Close();

            Data = stream.ToArray();
        }
Ejemplo n.º 21
0
        protected override void StoreData()
        {
            var stream = new MemoryStream();
            var writer = new BinaryReverseWriter(stream);

            foreach (var name in m_channelNames)
            {
                writer.Write((byte) name.Length);
                writer.Write(name.ToCharArray());
            }

            writer.Close();
            stream.Close();

            Data = stream.ToArray();
        }
Ejemplo n.º 22
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveImage(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveImage started at " + writer.BaseStream.Position.ToString());

            writer.Write((short)m_imageCompression);

            if (m_imageCompression == ImageCompression.Rle)
            {
                SaveImageRLE(writer);
            }
            else
            {
                for (int ch = 0; ch < m_channels; ch++)
                {
                    writer.Write(m_imageData[ch]);
                }
            }
        }
Ejemplo n.º 23
0
        protected override void StoreData()
        {
            var stream = new MemoryStream();
            var writer = new BinaryReverseWriter(stream);

            writer.Write((Int16)m_hRes);
            writer.Write((Int32)m_hResUnit);
            writer.Write((Int16)m_widthUnit);

            writer.Write((Int16)m_vRes);
            writer.Write((Int32)m_vResUnit);
            writer.Write((Int16)m_heightUnit);

            writer.Close();
            stream.Close();

            Data = stream.ToArray();
        }
Ejemplo n.º 24
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveImageRLE(BinaryReverseWriter writer)
        {
            // we will write the correct lengths later, so remember
            // the position
            var lengthPosition = writer.BaseStream.Position;

            var rleRowLenghs = new int[m_rows * m_channels];

            if (m_imageCompression == ImageCompression.Rle)
            {
                for (int i = 0; i < rleRowLenghs.Length; i++)
                {
                    writer.Write((short)0x1234);
                }
            }

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

            for (int ch = 0; ch < m_channels; ch++)
            {
                var startIdx = ch * m_rows;

                for (int row = 0; row < m_rows; row++)
                {
                    rleRowLenghs[row + startIdx] = RleHelper.EncodedRow(writer.BaseStream, m_imageData[ch],
                                                                        row * m_columns, m_columns);
                }
            }

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

            long endPosition = writer.BaseStream.Position;

            writer.BaseStream.Position = lengthPosition;

            for (var i = 0; i < rleRowLenghs.Length; i++)
            {
                writer.Write((short)rleRowLenghs[i]);
            }

            writer.BaseStream.Position = endPosition;

            //---------------------------------------------------------------
        }
Ejemplo n.º 25
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveLayers(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveLayers started at " + writer.BaseStream.Position.ToString());

            using (new LengthWriter(writer))
            {
                short numberOfLayers = (short)m_layers.Count;
                if (AbsoluteAlpha)
                {
                    numberOfLayers = (short)-numberOfLayers;
                }

                writer.Write(numberOfLayers);

                // Finish compute-bound operations before embarking on the sequential save
                PrivateThreadPool threadPool = new PrivateThreadPool();
                foreach (Layer layer in m_layers)
                {
                    layer.PrepareSave(threadPool);
                }
                threadPool.Drain();

                foreach (Layer layer in m_layers)
                {
                    layer.Save(writer);
                }

                foreach (Layer layer in m_layers)
                {
                    foreach (Layer.Channel channel in layer.Channels)
                    {
                        channel.SavePixelData(writer);
                    }
                }

                if (writer.BaseStream.Position % 2 == 1)
                {
                    writer.Write((byte)0);
                }
            }
        }
Ejemplo n.º 26
0
        //////////////////////////////////////////////////////////////////

        public void Save(BinaryReverseWriter writer)
        {
            StoreData();

            if (m_osType == string.Empty)
            {
                m_osType = "8BIM";
            }

            writer.Write(m_osType.ToCharArray());
            writer.Write(m_id);

            writer.WritePascalString(m_name);

            writer.Write(m_data.Length);
            writer.Write(m_data);

            if (writer.BaseStream.Position % 2 == 1)
            {
                writer.Write((byte)0);
            }
        }
Ejemplo n.º 27
0
        ///////////////////////////////////////////////////////////////////////////
        private void SaveHeader(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveHeader started at " + writer.BaseStream.Position.ToString());

              string signature = "8BPS";
              writer.Write(signature.ToCharArray());
              writer.Write(Version);
              writer.Write(new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, });
              writer.Write(m_channels);
              writer.Write(m_rows);
              writer.Write(m_columns);
              writer.Write((short)m_depth);
              writer.Write((short)m_colorMode);
        }
Ejemplo n.º 28
0
            internal void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("Channel Save started at " + writer.BaseStream.Position);

                writer.Write(m_id);

                CompressImageData();

                writer.Write(Data.Length + 2); // 2 bytes for the image compression
            }
Ejemplo n.º 29
0
            public void CompressImageData()
            {
                if (m_imageCompression == ImageCompression.Rle)
                {
                    MemoryStream        dataStream = new MemoryStream();
                    BinaryReverseWriter writer     = new BinaryReverseWriter(dataStream);

                    // we will write the correct lengths later, so remember
                    // the position
                    long lengthPosition = writer.BaseStream.Position;

                    int[] rleRowLengths = new int[m_layer.m_rect.Height];
                    for (int i = 0; i < rleRowLengths.Length; i++)
                    {
                        writer.Write((short)0x1234);
                    }

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

                    int bytesPerRow = 0;

                    switch (m_layer.PsdFile.Depth)
                    {
                    case 1:
                        bytesPerRow = ImageDecoder.BytesFromBits(m_layer.m_rect.Width);
                        break;

                    case 8:
                        bytesPerRow = m_layer.m_rect.Width;
                        break;

                    case 16:
                        bytesPerRow = m_layer.m_rect.Width * 2;
                        break;
                    }

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

                    for (int row = 0; row < m_layer.m_rect.Height; row++)
                    {
                        int rowIndex = row * m_layer.m_rect.Width;
                        rleRowLengths[row] = RleHelper.EncodedRow(writer.BaseStream, m_imageData, rowIndex, bytesPerRow);
                    }

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

                    long endPosition = writer.BaseStream.Position;

                    writer.BaseStream.Position = lengthPosition;

                    for (int i = 0; i < rleRowLengths.Length; i++)
                    {
                        writer.Write((short)rleRowLengths[i]);
                    }

                    writer.BaseStream.Position = endPosition;

                    dataStream.Close();

                    m_data = dataStream.ToArray();

                    dataStream.Dispose();
                }
                else
                {
                    m_data = (byte[])m_imageData.Clone();
                }
            }
Ejemplo n.º 30
0
        ///////////////////////////////////////////////////////////////////////////
        private void SaveLayers(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveLayers started at " + writer.BaseStream.Position.ToString());

              using (new LengthWriter(writer))
              {
            short numberOfLayers = (short)m_layers.Count;
            if (AbsoluteAlpha)
              numberOfLayers = (short)-numberOfLayers;

            writer.Write(numberOfLayers);

            // Finish compute-bound operations before embarking on the sequential save
            PrivateThreadPool threadPool = new PrivateThreadPool();
            foreach (Layer layer in m_layers)
            {
              layer.PrepareSave(threadPool);
            }
            threadPool.Drain();

            foreach (Layer layer in m_layers)
            {
              layer.Save(writer);
            }

            foreach (Layer layer in m_layers)
            {
              foreach (Layer.Channel channel in layer.Channels)
              {
            channel.SavePixelData(writer);
              }
            }

            if (writer.BaseStream.Position % 2 == 1)
              writer.Write((byte)0);
              }
        }
Ejemplo n.º 31
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveImageResources(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveImageResources started at " + writer.BaseStream.Position);

            using (new LengthWriter(writer))
            {
                foreach (ImageResource imgRes in m_imageResources)
                    imgRes.Save(writer);
            }
        }
Ejemplo n.º 32
0
        private void SaveHeader(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveHeader started at " + writer.BaseStream.Position);

            writer.Write(ArrayEightBPS);
            writer.Write(Version);
            writer.Write(new byte[] {0x0, 0x0, 0x0, 0x0, 0x0, 0x0});
            writer.Write(m_channels);
            writer.Write(m_rows);
            writer.Write(m_columns);
            writer.Write((short) m_depth);
            writer.Write((short) m_colorMode);
        }
Ejemplo n.º 33
0
        protected override void StoreData()
        {
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
              BinaryReverseWriter writer = new BinaryReverseWriter(stream);

              writer.Write((Int16)m_hRes);
              writer.Write((Int32)m_hResUnit);
              writer.Write((Int16)m_widthUnit);

              writer.Write((Int16)m_vRes);
              writer.Write((Int32)m_vResUnit);
              writer.Write((Int16)m_heightUnit);

              writer.Close();
              stream.Close();

              Data = stream.ToArray();
        }
Ejemplo n.º 34
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveLayers(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveLayers started at " + writer.BaseStream.Position);

            using (new LengthWriter(writer))
            {
                var numberOfLayers = (short)m_layers.Count;
                if (AbsoluteAlpha)
                    numberOfLayers = (short) -numberOfLayers;

                writer.Write(numberOfLayers);

                foreach (var layer in m_layers)
                {
                    layer.Save(writer);
                }

                foreach (var layer in m_layers)
                {
                    foreach (Layer.Channel channel in layer.Channels)
                    {
                        channel.SavePixelData(writer);
                    }
                }

                if (writer.BaseStream.Position%2 == 1)
                    writer.Write((byte) 0);
            }
        }
Ejemplo n.º 35
0
        //////////////////////////////////////////////////////////////////

        public void Save(BinaryReverseWriter writer)
        {
            StoreData();

            if (m_osType == String.Empty)
                m_osType = "8BIM";

            writer.Write(m_osType.ToCharArray());
            writer.Write(m_id);

            writer.WritePascalString(m_name);

            writer.Write(m_data.Length);
            writer.Write(m_data);

            if (writer.BaseStream.Position%2 == 1)
                writer.Write((byte) 0);
        }
Ejemplo n.º 36
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveImage(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveImage started at " + writer.BaseStream.Position);

            writer.Write((short) m_imageCompression);

            if (m_imageCompression == ImageCompression.Rle)
            {
                SaveImageRLE(writer);
            }
            else
            {
                for (int ch = 0; ch < m_channels; ch++)
                {
                    writer.Write(m_imageData[ch]);
                }
            }
        }
Ejemplo n.º 37
0
        public LengthWriter(BinaryReverseWriter writer)
        {
            m_writer = writer;

              // we will write the correct length later, so remember
              // the position
              m_lengthPosition = m_writer.BaseStream.Position;
              m_writer.Write((uint)0xFEEDFEED);

              // remember the start  position for calculation Image
              // resources length
              m_startPosition = m_writer.BaseStream.Position;
        }
Ejemplo n.º 38
0
 internal void SavePixelData(BinaryReverseWriter writer)
 {
     //writer.Write(m_data);
 }
Ejemplo n.º 39
0
        ///////////////////////////////////////////////////////////////////////////

        public void Save(BinaryReverseWriter writer)
        {
            Debug.WriteLine("Layer Save started at " + writer.BaseStream.Position);

            writer.Write(m_rect.Top);
            writer.Write(m_rect.Left);
            writer.Write(m_rect.Bottom);
            writer.Write(m_rect.Right);

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

            writer.Write((short) m_channels.Count);
            foreach (Channel ch in m_channels)
                ch.Save(writer);

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

            writer.Write(LayerConstants.EightBimSignatureArray);
            writer.Write(m_blendModeKey.ToCharArray());
            writer.Write(m_opacity);
            writer.Write((byte) (m_clipping ? 1 : 0));

            writer.Write((byte) m_flags.Data);

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

            writer.Write((byte) 0);

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

            using (new LengthWriter(writer))
            {
                m_maskData.Save(writer);
                m_blendingRangesData.Save(writer);

                var namePosition = writer.BaseStream.Position;

                writer.WritePascalString(m_name);

                var paddingBytes = (int)((writer.BaseStream.Position - namePosition) % 4);
                Debug.Print("Layer {0} write padding bytes after name", paddingBytes);

                for (int i = 0; i < paddingBytes; i++)
                    writer.Write((byte) 0);

                foreach (AdjusmentLayerInfo info in m_adjustmentInfo)
                {
                    info.Save(writer);
                }
            }
        }
Ejemplo n.º 40
0
            private void CompressImageData()
            {
                if (m_imageCompression == ImageCompression.Rle)
                {
                    var dataStream = new MemoryStream();
                    var writer = new BinaryReverseWriter(dataStream);

                    // we will write the correct lengths later, so remember 
                    // the position
                    var lengthPosition = writer.BaseStream.Position;

                    var rleRowLenghs = new int[m_layer.m_rect.Height];

                    if (m_imageCompression == ImageCompression.Rle)
                    {
                        for (int i = 0; i < rleRowLenghs.Length; i++)
                        {
                            writer.Write((short) 0x1234);
                        }
                    }

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

                    int bytesPerRow = 0;

                    switch (m_layer.PsdFile.Depth)
                    {
                        case 1:
                            bytesPerRow = m_layer.m_rect.Width; //NOT Shure
                            break;
                        case 8:
                            bytesPerRow = m_layer.m_rect.Width;
                            break;
                        case 16:
                            bytesPerRow = m_layer.m_rect.Width*2;
                            break;
                    }

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

                    for (int row = 0; row < m_layer.m_rect.Height; row++)
                    {
                        int rowIndex = row*m_layer.m_rect.Width;
                        rleRowLenghs[row] = RleHelper.EncodedRow(writer.BaseStream, m_imageData, rowIndex, bytesPerRow);
                    }

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

                    long endPosition = writer.BaseStream.Position;

                    writer.BaseStream.Position = lengthPosition;

                    for (int i = 0; i < rleRowLenghs.Length; i++)
                    {
                        writer.Write((short) rleRowLenghs[i]);
                    }

                    writer.BaseStream.Position = endPosition;

                    dataStream.Close();

                    m_data = dataStream.ToArray();

                    dataStream.Dispose();
                }
                else
                {
                    m_data = (byte[]) m_imageData.Clone();
                }
            }
Ejemplo n.º 41
0
            internal void SavePixelData(BinaryReverseWriter writer)
            {
                Debug.WriteLine("Channel SavePixelData started at " + writer.BaseStream.Position);

                writer.Write((short) m_imageCompression);
                writer.Write(m_imageData);
            }
Ejemplo n.º 42
0
        public void Save(Stream stream)
        {
            var writer = new BinaryReverseWriter(stream)
            {
                AutoFlush = true
            };

            SaveHeader(writer);
            SaveColorModeData(writer);
            SaveImageResources(writer);
            SaveLayerAndMaskInfo(writer);
            SaveImage(writer);
        }
Ejemplo n.º 43
0
            ///////////////////////////////////////////////////////////////////////////

            public void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("Mask Save started at " + writer.BaseStream.Position);

                if (m_rect.IsEmpty)
                {
                    writer.Write((uint) 0);
                    return;
                }

                using (new LengthWriter(writer))
                {
                    writer.Write(m_rect.Top);
                    writer.Write(m_rect.Left);
                    writer.Write(m_rect.Bottom);
                    writer.Write(m_rect.Right);

                    writer.Write(m_defaultColor);

                    writer.Write((byte) m_flags.Data);

                    // padding 2 bytes so that size is 20
                    writer.Write((int) 0);
                }
            }
Ejemplo n.º 44
0
        private void SaveColorModeData(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveColorModeData started at " + writer.BaseStream.Position);

            writer.Write((uint) ColorModeData.Length);
            writer.Write(ColorModeData);
        }
Ejemplo n.º 45
0
 internal void SavePixelData(BinaryReverseWriter writer)
 {
     //writer.Write(m_data);
 }
Ejemplo n.º 46
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveLayerAndMaskInfo(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveLayerAndMaskInfo started at " + writer.BaseStream.Position);

            using (new LengthWriter(writer))
            {
                SaveLayers(writer);
                SaveGlobalLayerMask(writer);
            }
        }
Ejemplo n.º 47
0
            ///////////////////////////////////////////////////////////////////////////

            public void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("BlendingRanges Save started at " + writer.BaseStream.Position);

                writer.Write((uint) m_data.Length);
                writer.Write(m_data);
            }
Ejemplo n.º 48
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveGlobalLayerMask(BinaryReverseWriter writer)
        {
            Debug.WriteLine("SaveGlobalLayerMask started at " + writer.BaseStream.Position);

            writer.Write((uint) GlobalLayerMaskData.Length);
            writer.Write(GlobalLayerMaskData);
        }
Ejemplo n.º 49
0
            public void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("AdjusmentLayerInfo Save started at " + writer.BaseStream.Position);

                writer.Write(LayerConstants.EightBimSignatureArray);
                writer.Write(m_key.ToCharArray());
                writer.Write((uint) m_data.Length);
                writer.Write(m_data);
            }
Ejemplo n.º 50
0
        ///////////////////////////////////////////////////////////////////////////

        private void SaveImageRLE(BinaryReverseWriter writer)
        {
            // we will write the correct lengths later, so remember 
            // the position
            var lengthPosition = writer.BaseStream.Position;

            var rleRowLenghs = new int[m_rows * m_channels];

            if (m_imageCompression == ImageCompression.Rle)
            {
                for (int i = 0; i < rleRowLenghs.Length; i++)
                {
                    writer.Write((short) 0x1234);
                }
            }

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

            for (int ch = 0; ch < m_channels; ch++)
            {
                var startIdx = ch * m_rows;

                for (int row = 0; row < m_rows; row++)
                    rleRowLenghs[row + startIdx] = RleHelper.EncodedRow(writer.BaseStream, m_imageData[ch],
                        row*m_columns, m_columns);
            }

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

            long endPosition = writer.BaseStream.Position;

            writer.BaseStream.Position = lengthPosition;

            for (var i = 0; i < rleRowLenghs.Length; i++)
            {
                writer.Write((short) rleRowLenghs[i]);
            }

            writer.BaseStream.Position = endPosition;

            //---------------------------------------------------------------
        }
Ejemplo n.º 51
0
            public void Save(BinaryReverseWriter writer)
            {
                Debug.WriteLine("AdjustmentLayerInfo Save started at " + writer.BaseStream.Position.ToString());

                string signature = "8BIM";

                writer.Write(signature.ToCharArray());
                writer.Write(m_key.ToCharArray());
                writer.Write((uint)m_data.Length);
                writer.Write(m_data);
            }