Beispiel #1
0
        ///////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Decompress the document image data and all the layers' image data, in parallel.
        /// </summary>
        private void DecompressImages()
        {
            var imageLayers = Layers.Concat(new List <Layer>()
            {
                this.BaseLayer
            });

            foreach (var layer in imageLayers)
            {
                foreach (var channel in layer.Channels)
                {
                    var dcc          = new DecompressChannelContext(channel);
                    var waitCallback = new WaitCallback(dcc.DecompressChannel);
                    ThreadPool.QueueUserWorkItem(waitCallback);
                }
            }

            foreach (var layer in Layers)
            {
                foreach (var channel in layer.Channels)
                {
                    if (channel.ID == -2)
                    {
                        layer.Masks.LayerMask.ImageData = channel.ImageData;
                    }
                    else if (channel.ID == -3)
                    {
                        layer.Masks.UserMask.ImageData = channel.ImageData;
                    }
                }
            }
        }
Beispiel #2
0
        ///////////////////////////////////////////////////////////////////////////

        private void LoadLayers(BinaryReverseReader reader)
        {
            Debug.WriteLine("LoadLayers started at " + reader.BaseStream.Position.ToString());

            uint layersInfoSectionLength = reader.ReadUInt32();

            if (layersInfoSectionLength <= 0)
            {
                return;
            }

            long startPosition = reader.BaseStream.Position;

            short numberOfLayers = reader.ReadInt16();

            // If <0, then number of layers is absolute value,
            // and the first alpha channel contains the transparency data for
            // the merged result.
            if (numberOfLayers < 0)
            {
                AbsoluteAlpha  = true;
                numberOfLayers = Math.Abs(numberOfLayers);
            }

            m_layers.Clear();

            if (numberOfLayers == 0)
            {
                return;
            }

            for (int i = 0; i < numberOfLayers; i++)
            {
                m_layers.Add(new Layer(reader, this));
            }

            PrivateThreadPool threadPool = new PrivateThreadPool();

            foreach (Layer layer in m_layers)
            {
                foreach (Layer.Channel channel in layer.Channels)
                {
                    if (channel.ID != -2)
                    {
                        channel.LoadPixelData(reader);
                        DecompressChannelContext dcc          = new DecompressChannelContext(channel);
                        WaitCallback             waitCallback = new WaitCallback(dcc.DecompressChannel);
                        threadPool.QueueUserWorkItem(waitCallback);
                    }
                }

                layer.MaskData.LoadPixelData(reader);
            }

            threadPool.Drain();


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

            if (reader.BaseStream.Position % 2 == 1)
            {
                reader.ReadByte();
            }

            //-----------------------------------------------------------------------
            // make sure we are not on a wrong offset, so set the stream position
            // manually
            reader.BaseStream.Position = startPosition + layersInfoSectionLength;
        }
Beispiel #3
0
        ///////////////////////////////////////////////////////////////////////////
        private void LoadLayers(BinaryReverseReader reader)
        {
            Debug.WriteLine("LoadLayers started at " + reader.BaseStream.Position.ToString());

              uint layersInfoSectionLength = reader.ReadUInt32();

              if (layersInfoSectionLength <= 0)
            return;

              long startPosition = reader.BaseStream.Position;

              short numberOfLayers = reader.ReadInt16();

              // If <0, then number of layers is absolute value,
              // and the first alpha channel contains the transparency data for
              // the merged result.
              if (numberOfLayers < 0)
              {
            AbsoluteAlpha = true;
            numberOfLayers = Math.Abs(numberOfLayers);
              }

              m_layers.Clear();

              if (numberOfLayers == 0)
            return;

              for (int i = 0; i < numberOfLayers; i++)
              {
            m_layers.Add(new Layer(reader, this));
              }

              PrivateThreadPool threadPool = new PrivateThreadPool();

              foreach (Layer layer in m_layers)
              {
            foreach (Layer.Channel channel in layer.Channels)
            {
              if (channel.ID != -2)
              {
            channel.LoadPixelData(reader);
            DecompressChannelContext dcc = new DecompressChannelContext(channel);
            WaitCallback waitCallback = new WaitCallback(dcc.DecompressChannel);
            threadPool.QueueUserWorkItem(waitCallback);
              }
            }

            layer.MaskData.LoadPixelData(reader);
              }

              threadPool.Drain();

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

              if (reader.BaseStream.Position % 2 == 1)
            reader.ReadByte();

              //-----------------------------------------------------------------------
              // make sure we are not on a wrong offset, so set the stream position
              // manually
              reader.BaseStream.Position = startPosition + layersInfoSectionLength;
        }
        ///////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Decompress the document image data and all the layers' image data, in parallel.
        /// </summary>
        private void DecompressImages() {
            var imageLayers = Layers.Concat(new List<Layer>() { this.BaseLayer });
            foreach (var layer in imageLayers) {
                foreach (var channel in layer.Channels) {
                    var dcc = new DecompressChannelContext(channel);
                    var waitCallback = new WaitCallback(dcc.DecompressChannel);
                    ThreadPool.QueueUserWorkItem(waitCallback);
                }
            }

            foreach (var layer in Layers) {
                foreach (var channel in layer.Channels) {
                    if (channel.ID == -2)
                        layer.Masks.LayerMask.ImageData = channel.ImageData;
                    else if (channel.ID == -3)
                        layer.Masks.UserMask.ImageData = channel.ImageData;
                }
            }
        }