예제 #1
0
        ///////////////////////////////////////////////////////////////////////////

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

            //var channels = layersAndComposite.SelectMany(x => x.Channels);
            //Parallel.ForEach(channels, channel =>
            //{
            //  channel.DecodeImageData();
            //});
            foreach (var lac in layersAndComposite)
            {
                foreach (var c in lac.Channels)
                {
                    c.DecodeImageData();
                }
            }

            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;
                    }
                }
            }
        }
예제 #2
0
        ///////////////////////////////////////////////////////////////////////////

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

            Parallel.ForEach(imageLayers, layer =>
            {
                Parallel.ForEach(layer.Channels, channel =>
                {
                    channel.DecompressImageData();
                });
            });


            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;
                    }
                }
            }
        }
예제 #3
0
        ///////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Decompress the document image data and all the layers' image data, in parallel.
        /// </summary>
        private void DecompressImages()
        {
            var layersAndComposite = Layers.Concat(new[] { BaseLayer });
            var channels           = layersAndComposite.SelectMany(x => x.Channels);
            LinkedList <Task> list = new LinkedList <Task>();

            foreach (var chanel in channels)
            {
                list.AddLast(Task.Run(() => chanel.DecodeImageData()));
            }
            foreach (var task in list)
            {
                task.Wait();
            }

            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;
                    }
                }
            }
        }
예제 #4
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;
                    }
                }
            }
        }
예제 #5
0
        ///////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Decompress the document image data and all the layers' image data, in parallel.
        /// </summary>
        private void DecompressImages()
        {
            var layersAndComposite = Layers.Concat(new[] { BaseLayer });
            var channels           = layersAndComposite.SelectMany(x => x.Channels);

            foreach (var channel in channels)
            {
                channel.DecodeImageData();
            }

            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;
                    }
                }
            }
        }
예제 #6
0
        ///////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Cleanup
        /// </summary>
        public void Cleanup()
        {
            var layersAndComposite = Layers.Concat(new[] { BaseLayer });

            foreach (var lac in layersAndComposite)
            {
                foreach (var c in lac.Channels)
                {
                    c.Cleanup();
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Check the validity of the PSD file and generate necessary data.
        /// </summary>
        public void PrepareSave()
        {
            var imageLayers = Layers.Concat(new List <Layer>()
            {
                this.BaseLayer
            }).ToList();

            foreach (var layer in imageLayers)
            {
                layer.PrepareSave();
            }

            SetVersionInfo();
            VerifyLayerSections();
        }
예제 #8
0
        /// <summary>
        /// Check the validity of the PSD file and generate necessary data.
        /// </summary>
        public void PrepareSave()
        {
            CheckDimension(ColumnCount);
            CheckDimension(RowCount);
            VerifyInfoLayers();
            VerifyLayerSections();

            var imageLayers = Layers.Concat(new List <Layer>()
            {
                this.BaseLayer
            }).ToList();

            foreach (var layer in imageLayers)
            {
                layer.PrepareSave();
            }

            SetVersionInfo();
        }