Esempio n. 1
0
        protected override void OnExecute()
        {
            FitSurfaceContext fsc = new FitSurfaceContext(Dest, Source, Rects, ResamplingAlgorithm.Bicubic);

            for (int i = 0; i < Rects.Length; ++i)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(fsc.FitSurface), i);
            }

            ThreadPool.Drain();
        }
Esempio n. 2
0
        protected override void OnExecute()
        {
            FitSurfaceContext fsc = new FitSurfaceContext(this.dst, this.src, rects, ResamplingAlgorithm.Bicubic);

            for (int i = 0; i < this.rects.Length; ++i)
            {
                this.threadPool.QueueUserWorkItem(new WaitCallback(fsc.FitSurface), (object)i);
            }

            this.threadPool.Drain();
        }
Esempio n. 3
0
		protected override void OnExecute()
		{
            FitSurfaceContext fsc = new FitSurfaceContext(this.dst, this.src, rects, ResamplingAlgorithm.Bicubic);
            for (int i = 0; i < this.rects.Length; ++i)
            {
                this.threadPool.QueueUserWorkItem(new WaitCallback(fsc.FitSurface), (object)i);
            }

            this.threadPool.Drain();
		}
Esempio n. 4
0
        private static BitmapLayer ResizeLayer(BitmapLayer layer, int width, int height, ResamplingAlgorithm algorithm,
            int tileCount, Procedure progressCallback, ref bool pleaseStopMonitor)
        {
            Surface surface = new Surface(width, height);
            surface.Clear(ColorBgra.FromBgra(255, 255, 255, 0));

            PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool();
            int rectCount;

            if (tileCount == 0)
            {
                rectCount = Processor.LogicalCpuCount;
            }
            else
            {
                rectCount = tileCount;
            }

            Rectangle[] rects = new Rectangle[rectCount];
            Utility.SplitRectangle(surface.Bounds, rects);

            FitSurfaceContext fsc = new FitSurfaceContext(surface, layer.Surface, rects, algorithm);

            if (progressCallback != null)
            {
                fsc.RenderedRect += progressCallback;
            }

            WaitCallback callback = new WaitCallback(fsc.FitSurface);

            for (int i = 0; i < rects.Length; ++i)
            {
                if (pleaseStopMonitor)
                {
                    break;
                }
                else
                {
                    threadPool.QueueUserWorkItem(callback, BoxedConstants.GetInt32(i));
                }
            }

            threadPool.Drain();
            threadPool.DrainExceptions();

            if (pleaseStopMonitor)
            {
                surface.Dispose();
                surface = null;
            }

            BitmapLayer newLayer;

            if (surface == null)
            {
                newLayer = null;
            }
            else
            {
                newLayer = new BitmapLayer(surface, true);
                newLayer.LoadProperties(layer.SaveProperties());
            }

            if (progressCallback != null)
            {
                fsc.RenderedRect -= progressCallback;
            }

            return newLayer;
        }
Esempio n. 5
0
        private static BitmapLayer ResizeLayer(BitmapLayer layer, int width, int height, ResamplingAlgorithm algorithm,
                                               int tileCount, Procedure progressCallback, ref bool pleaseStopMonitor)
        {
            Surface surface = new Surface(width, height);

            surface.Clear(ColorBgra.FromBgra(255, 255, 255, 0));

            PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool();
            int rectCount;

            if (tileCount == 0)
            {
                rectCount = Processor.LogicalCpuCount;
            }
            else
            {
                rectCount = tileCount;
            }

            Rectangle[] rects = new Rectangle[rectCount];
            Utility.SplitRectangle(surface.Bounds, rects);

            FitSurfaceContext fsc = new FitSurfaceContext(surface, layer.Surface, rects, algorithm);

            if (progressCallback != null)
            {
                fsc.RenderedRect += progressCallback;
            }

            WaitCallback callback = new WaitCallback(fsc.FitSurface);

            for (int i = 0; i < rects.Length; ++i)
            {
                if (pleaseStopMonitor)
                {
                    break;
                }
                else
                {
                    threadPool.QueueUserWorkItem(callback, BoxedConstants.GetInt32(i));
                }
            }

            threadPool.Drain();
            threadPool.DrainExceptions();

            if (pleaseStopMonitor)
            {
                surface.Dispose();
                surface = null;
            }

            BitmapLayer newLayer;

            if (surface == null)
            {
                newLayer = null;
            }
            else
            {
                newLayer = new BitmapLayer(surface, true);
                newLayer.LoadProperties(layer.SaveProperties());
            }

            if (progressCallback != null)
            {
                fsc.RenderedRect -= progressCallback;
            }

            return(newLayer);
        }