当前位置: 首页>>代码示例>>C#>>正文


C# Surface.Dispose方法代码示例

本文整理汇总了C#中PaintDotNet.Surface.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.Dispose方法的具体用法?C# Surface.Dispose怎么用?C# Surface.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PaintDotNet.Surface的用法示例。


在下文中一共展示了Surface.Dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderThumbnail

        public override Surface RenderThumbnail(int maxEdgeLength)
        {
            Size thumbSize = Utility.ComputeThumbnailSize(this.Size, maxEdgeLength);
            Surface thumb = new Surface(thumbSize);

            thumb.SuperSamplingFitSurface(this.surface);

            Surface thumb2 = new Surface(thumbSize);
            thumb2.ClearWithCheckboardPattern();
            UserBlendOps.NormalBlendOp nbop = new UserBlendOps.NormalBlendOp();
            nbop.Apply(thumb2, thumb);

            thumb.Dispose();
            thumb = null;

            return thumb2;
        }
开发者ID:herbqiao,项目名称:paint.net,代码行数:17,代码来源:BitmapLayer.cs

示例2: DrawGradient


//.........这里部分代码省略.........

                            int ap = Utility.Clamp((int)Math.Round(at * 255.0), 0, 255);
                            int rp = Utility.Clamp((int)Math.Round(rt * 255.0), 0, 255);
                            int gp = Utility.Clamp((int)Math.Round(gt * 255.0), 0, 255);
                            int bp = Utility.Clamp((int)Math.Round(bt * 255.0), 0, 255);

                            for (int y = 0; y < gradientSurface.Height; ++y)
                            {
                                ColorBgra src = gradientSurface[x, y];

                                // we are assuming that src.A = 255

                                int rd = ((rp * ap) + (src.R * (255 - ap))) / 255;
                                int gd = ((gp * ap) + (src.G * (255 - ap))) / 255;
                                int bd = ((bp * ap) + (src.B * (255 - ap))) / 255;

                                // TODO: proper alpha blending!
                                gradientSurface[x, y] = ColorBgra.FromBgra((byte)bd, (byte)gd, (byte)rd, 255);
                            }
                        }

                        g.DrawImage(ra.Bitmap, gradientRect, ra.Bounds, GraphicsUnit.Pixel);
                    }
                    else if (Orientation == Orientation.Vertical)
                    {
                        // TODO
                    }
                    else
                    {
                        throw new InvalidEnumArgumentException();
                    }
                }

                gradientSurface.Dispose();
            }
            else
            {
                using (LinearGradientBrush lgb = new LinearGradientBrush(this.ClientRectangle,
                           maxColor, minColor, gradientAngle, false))
                {
                    g.FillRectangle(lgb, gradientRect);
                }
            }

            // fill background
            using (PdnRegion nonGradientRegion = new PdnRegion())
            {
                nonGradientRegion.MakeInfinite();
                nonGradientRegion.Exclude(gradientRect);

                using (SolidBrush sb = new SolidBrush(this.BackColor))
                {
                    g.FillRegion(sb, nonGradientRegion.GetRegionReadOnly());
                }
            }

            // draw value triangles
            for (int i = 0; i < this.vals.Length; i++)
            {
                int pos = ValueToPosition(vals[i]);
                Brush brush;
                Pen pen;

                if (i == highlight) 
                {
                    brush = Brushes.Blue;
开发者ID:metadeta96,项目名称:openpdn,代码行数:67,代码来源:ColorGradientControl.cs

示例3: RenderCompositionTo

        protected void RenderCompositionTo(Surface dst, bool highQuality, bool forceUpToDate)
        {
            if (forceUpToDate)
            {
                UpdateComposition(false);
            }

            if (dst.Width == this.compositionSurface.Width && 
                dst.Height == this.compositionSurface.Height)
            {
                dst.ClearWithCheckboardPattern();
                new UserBlendOps.NormalBlendOp().Apply(dst, this.compositionSurface);
            }
            else if (highQuality)
            {
                Surface thumb = new Surface(dst.Size);
                thumb.SuperSamplingFitSurface(this.compositionSurface);

                dst.ClearWithCheckboardPattern();

                new UserBlendOps.NormalBlendOp().Apply(dst, thumb);

                thumb.Dispose();
            }
            else
            {
                this.surfaceBox.RenderTo(dst);
            }
        }
开发者ID:herbqiao,项目名称:paint.net,代码行数:29,代码来源:DocumentView.cs

示例4: ResizeDocument

            private void ResizeDocument()
            {
                this.pleaseStop = false;

                // This is only sort of a hack: we must try and allocate enough for 2 extra layer-sized buffers
                // Then we free them immediately. This is just so that if we don't have enough memory that we'll
                // fail sooner rather than later.
                Surface s1 = new Surface(this.newSize);
                Surface s2 = new Surface(this.newSize);

                try
                {
                    foreach (Layer layer in src.Layers)
                    {
                        if (this.pleaseStop)
                        {
                            this.returnVal = false;
                            return;
                        }

                        if (layer is BitmapLayer)
                        {
                            Layer newLayer = ResizeLayer((BitmapLayer)layer, this.newSize.Width, this.newSize.Height, this.algorithm,
                                this.tilesPerLayer, new Procedure(RenderedRectHandler), ref this.pleaseStop);

                            if (newLayer == null)
                            {
                                this.returnVal = false;
                                return;
                            }

                            dst.Layers.Add(newLayer);
                        }
                        else
                        {
                            throw new InvalidOperationException("Resize does not support Layers that are not BitmapLayers");
                        }
                    }
                }

                finally
                {
                    s1.Dispose();
                    s2.Dispose();
                }

                this.returnVal = true;
            }
开发者ID:metadeta96,项目名称:openpdn,代码行数:48,代码来源:ResizeAction.cs

示例5: ResizeLayer

        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;
        }
开发者ID:metadeta96,项目名称:openpdn,代码行数:70,代码来源:ResizeAction.cs

示例6: OnPreRenderComplete

        protected virtual void OnPreRenderComplete(RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Rectangle[] rois;
            Surface surfaceCopy;
            RenderArgs args;
            RenderArgs currentSourceArgs;
            RenderArgs currentDestinationArgs;
            Rectangle boundingTile;

            if (FullImageSelected(srcArgs.Bounds))
            {
                boundingTile = dstArgs.Bounds;
            }
            else
            {
                boundingTile = this.EnvironmentParameters.GetSelection(dstArgs.Bounds).GetBoundsInt();
                boundingTile.Inflate(base.ApronSize, base.ApronSize);
                boundingTile.Intersect(dstArgs.Bounds);
            }

            rois = base.SliceRectangles(new Rectangle[] { boundingTile });

            surfaceCopy = new Surface(dstArgs.Width, dstArgs.Height, SurfaceCreationFlags.DoNotZeroFillHint); //dstArgs.Surface.Clone();
            args = new RenderArgs(surfaceCopy);

            currentSourceArgs = srcArgs;
            currentDestinationArgs = args;

            this.pass = 1;
            OnBeginPass(this.pass, currentDestinationArgs, currentSourceArgs);
            OnRenderRegion(rois, currentDestinationArgs, currentSourceArgs);

            if (Passes == 1)
            {
                CopyRois(this.EnvironmentParameters.GetSelection(dstArgs.Bounds).GetRegionScansInt(),
                    dstArgs.Surface,
                    surfaceCopy);
                surfaceCopy.Dispose();
            }
            else
            {
                if (base.tmr != null)
                {
                    base.tmr = new System.Diagnostics.Stopwatch();
                    base.tmr.Start();
                }

                this.pass = 2;
                if (FullImageSelected(srcArgs.Bounds))
                {
                    currentSourceArgs = args;
                    currentDestinationArgs = dstArgs;

                    OnBeginPass(this.pass, currentDestinationArgs, currentSourceArgs);
                    OnRenderRegion(rois, currentDestinationArgs, currentSourceArgs);
                    surfaceCopy.Dispose();
                }
                else
                {
                    Surface surfaceCopy2;
                    RenderArgs args2;
                    surfaceCopy2 = new Surface(dstArgs.Width, dstArgs.Height, SurfaceCreationFlags.DoNotZeroFillHint);
                    args2 = new RenderArgs(surfaceCopy2);

                    currentSourceArgs = args;
                    currentDestinationArgs = args2;

                    OnBeginPass(this.pass, currentDestinationArgs, currentSourceArgs);
                    OnRenderRegion(rois, currentDestinationArgs, currentSourceArgs);
                    surfaceCopy.Dispose();

                    CopyRois(this.EnvironmentParameters.GetSelection(dstArgs.Bounds).GetRegionScansInt(),
                        dstArgs.Surface,
                        surfaceCopy2);

                    surfaceCopy2.Dispose();
                }
            }
        }
开发者ID:bbowyersmyth,项目名称:ComputeShaderEffects,代码行数:79,代码来源:DualPassComputeShaderBase.cs


注:本文中的PaintDotNet.Surface.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。