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


C# PaintDotNet.PdnRegion类代码示例

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


PdnRegion类属于PaintDotNet命名空间,在下文中一共展示了PdnRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EffectConfigDialog

 public EffectConfigDialog()
 {
     InitializeComponent();
     InitialInitToken();
     effectSelection = new PdnRegion();
     effectSelection.MakeInfinite();
 }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:7,代码来源:EffectConfigDialog.cs

示例2: GetRegionCache

        internal PdnRegion GetRegionCache()
        {
            if (regionCache == null)
            {
                regionCache = new PdnRegion(this.gdiPath);
            }

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

示例3: IrregularSurface

        /// <summary>
        /// Constructs an IrregularSurface by copying the given region-of-interest from an Image.
        /// </summary>
        /// <param name="source">The Surface to copy pixels from.</param>
        /// <param name="roi">Defines the Region from which to copy pixels from the Image.</param>
        public IrregularSurface(Surface source, PdnRegion roi)
        {
            PdnRegion roiClipped = (PdnRegion)roi.Clone();
            roiClipped.Intersect(source.Bounds);

            Rectangle[] rects = roiClipped.GetRegionScansReadOnlyInt();
            this.placedSurfaces = new ArrayList(rects.Length);

            foreach (Rectangle rect in rects)
            {
                this.placedSurfaces.Add(new PlacedSurface(source, rect));
            }

            this.region = roiClipped;
        }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:20,代码来源:IrregularSurface.cs

示例4: DrawGradient


//.........这里部分代码省略.........
                                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;
                    pen = (Pen)Pens.White.Clone();
                } 
                else 
                {
                    brush = Brushes.Black;
                    pen = (Pen)Pens.Gray.Clone();
                }

                g.SmoothingMode = SmoothingMode.AntiAlias;

                Point a1;
                Point b1;
开发者ID:metadeta96,项目名称:openpdn,代码行数:67,代码来源:ColorGradientControl.cs

示例5: OnDeserialization

        public void OnDeserialization(object sender)
        {
            region = PdnRegion.CreateEmpty();

            Rectangle[] rects = new Rectangle[placedSurfaces.Count];

            for (int i = 0; i < placedSurfaces.Count; ++i)
            {
                rects[i] = ((PlacedSurface)placedSurfaces[i]).Bounds;
            }

            region = Utility.RectanglesToRegion(rects);
        }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:13,代码来源:IrregularSurface.cs

示例6: UpdateHistogram

        public void UpdateHistogram(Surface surface, PdnRegion roi)
        {
            Clear();

            foreach (Rectangle rect in roi.GetRegionScansReadOnlyInt())
            {
                AddSurfaceRectangleToHistogram(surface, rect);
            }

            OnHistogramUpdated();
        }
开发者ID:nkaligin,项目名称:paint-mono,代码行数:11,代码来源:Histogram.cs

示例7: Invert

 public void Invert(PdnRegion region)
 {
     foreach (Rectangle rect in region.GetRegionScansReadOnlyInt())
     {
         Invert(rect);
     }
 }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:7,代码来源:BitVector2DSurfaceAdapter.cs

示例8: MaskedSurface

        /// <summary>
        /// Constructs a MaskSurface by copying the given region-of-interest from an Image.
        /// </summary>
        /// <param name="source">The Surface to copy pixels from.</param>
        /// <param name="roi">Defines the Region from which to copy pixels from the Image.</param>
        public MaskedSurface(Surface source, PdnRegion roi)
        {
            PdnRegion roiClipped = (PdnRegion)roi.Clone();
            roiClipped.Intersect(source.Bounds);

            Rectangle boundsClipped = roiClipped.GetBoundsInt();
            this.surface = new Surface(boundsClipped.Size);
            this.surface.Clear(ColorBgra.FromUInt32(0x00ffffff));

            Rectangle rect = boundsClipped;
            Point dstOffset = new Point(rect.X - boundsClipped.X, rect.Y - boundsClipped.Y);
            this.surface.CopySurface(source, dstOffset, rect);

            this.region = roiClipped;
            SetPathField(PdnGraphicsPath.FromRegion(this.region));
        }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:21,代码来源:MaskedSurface.cs

示例9: GetRegion

        private PdnRegion GetRegion()
        {
            if (this.region == null)
            {
                this.region = new PdnRegion(this.shadowPath);
            }

            return this.region;
        }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:9,代码来源:MaskedSurface.cs

示例10: Draw

        public unsafe void Draw(Surface dst, Matrix transform, ResamplingAlgorithm sampling)
        {
            if (this.disposed)
            {
                throw new ObjectDisposedException("MaskedSurface");
            }

            if (this.surface == null || !transform.IsInvertible)
            {
                return;
            }

            PdnRegion theRegion;
            Rectangle regionBounds;

            if (this.path == null)
            {
                theRegion = this.region.Clone();
                regionBounds = this.region.GetBoundsInt();
                theRegion.Transform(transform);
            }
            else
            {
                using (PdnGraphicsPath mPath = this.shadowPath.Clone())
                {
                    regionBounds = Rectangle.Truncate(mPath.GetBounds());
                    mPath.Transform(transform);
                    theRegion = new PdnRegion(mPath);
                }
            }

            DrawContext dc = new DrawContext();

            dc.boundsX = regionBounds.X;
            dc.boundsY = regionBounds.Y;

            Matrix inverse = transform.Clone();
            inverse.Invert();

            dc.inverses = new Matrix[Processor.LogicalCpuCount];
            for (int i = 0; i < dc.inverses.Length; ++i)
            {
                dc.inverses[i] = inverse.Clone();
            }

            // change in source-[X|Y] w.r.t. destination-[X|Y]
            PointF[] pts = new PointF[] {
                                            new PointF(1, 0),
                                            new PointF(0, 1)
                                        };

            inverse.TransformVectors(pts);
            inverse.Dispose();
            inverse = null;

            dc.dsxddx = pts[0].X;

            if (Math.Abs(dc.dsxddx) > fp_MaxValue)
            {
                dc.dsxddx = 0.0f;
            }

            dc.dsyddx = pts[0].Y;

            if (Math.Abs(dc.dsyddx) > fp_MaxValue)
            {
                dc.dsyddx = 0.0f;
            }

            dc.dsxddy = pts[1].X;

            if (Math.Abs(dc.dsxddy) > fp_MaxValue)
            {
                dc.dsxddy = 0.0f;
            }

            dc.dsyddy = pts[1].Y;

            if (Math.Abs(dc.dsyddy) > fp_MaxValue)
            {
                dc.dsyddy = 0.0f;
            }

            dc.fp_dsxddx = (int)(dc.dsxddx * fp_MultFactor);
            dc.fp_dsyddx = (int)(dc.dsyddx * fp_MultFactor);
            dc.fp_dsxddy = (int)(dc.dsxddy * fp_MultFactor);
            dc.fp_dsyddy = (int)(dc.dsyddy * fp_MultFactor);

            dc.dst = dst;
            dc.src = this.surface;
            Rectangle[] scans = theRegion.GetRegionScansReadOnlyInt();

            if (scans.Length == 1)
            {
                dc.dstScans = new Rectangle[Processor.LogicalCpuCount];
                Utility.SplitRectangle(scans[0], dc.dstScans);
            }
            else
            {
                dc.dstScans = scans;
//.........这里部分代码省略.........
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:101,代码来源:MaskedSurface.cs

示例11: Main


//.........这里部分代码省略.........
            benchmarks.Add(new CompositionBenchmark("Compositing three layers, Normal+Multiply+Overlay blending, 150+255+170 opacity (" + CompositionBenchmark.Iterations + "x)", doc1, surface,
                delegate(int layerIndex, Layer layer)
                {
                    if (layerIndex == 0)
                    {
                        layer.Visible = true;
                        layer.Opacity = 150;
                        ((BitmapLayer)layer).SetBlendOp(new UserBlendOps.NormalBlendOp());
                    }
                    else if (layerIndex == 1)
                    {
                        layer.Visible = true;
                        layer.Opacity = 255;
                        ((BitmapLayer)layer).SetBlendOp(new UserBlendOps.MultiplyBlendOp());
                    }
                    else if (layerIndex == 2)
                    {
                        layer.Visible = true;
                        layer.Opacity = 170;
                        ((BitmapLayer)layer).SetBlendOp(new UserBlendOps.OverlayBlendOp());
                    }
                    else
                    {
                        layer.Visible = false;
                    }
                }));
#endif

#if TRANSFORM
            // Transform benchmarks
            Matrix m = new Matrix();
            m.Reset();

            MaskedSurface msSimple = new MaskedSurface(surface, new PdnRegion(surface.Bounds)); // simple masked surface

            PdnRegion complexRegion = new PdnRegion(surface.Bounds);

            // cut 4 holes in region 1 to form a complex clipping surface
            for (int x = -1; x < 3; ++x)
            {
                for (int y = -1; y < 3; ++y)
                {
                    int left = (1 + (x * 3)) * (surface.Width / 6);
                    int top = (1 + (x * 3)) * (surface.Height / 6);
                    int right = (2 + (x * 3)) * (surface.Width / 6);
                    int bottom = (2 + (x * 3)) * (surface.Height / 6);

                    Rectangle rect = Rectangle.FromLTRB(left, top, right, bottom);
                    PdnGraphicsPath path = new PdnGraphicsPath();
                    path.AddEllipse(rect);
                    complexRegion.Exclude(path);
                }
            }

            MaskedSurface msComplex = new MaskedSurface(surface, complexRegion);

            benchmarks.Add(new TransformBenchmark("Transform simple surface, no transform, nearest neighbor resampling (" + TransformBenchmark.Iterations + "x)",
                surface,
                msSimple,
                m,
                false));

            benchmarks.Add(new TransformBenchmark("Transform complex surface, no transform, nearest neighbor resampling (" + TransformBenchmark.Iterations + "x)",
                surface,
                msSimple,
                m,
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:67,代码来源:Startup.cs

示例12: CreatePixelatedPath

 public PdnGraphicsPath CreatePixelatedPath()
 {
     using (PdnGraphicsPath path = CreatePath())
     //PdnGraphicsPath path = GetPathReadOnly();
     {
         using (PdnRegion region = new PdnRegion(path))
         {
             PdnGraphicsPath pixellatedPath = PdnGraphicsPath.FromRegion(region);
             return pixellatedPath;
         }
     }
 }
开发者ID:metadeta96,项目名称:openpdn,代码行数:12,代码来源:Selection.cs

示例13: Set

 public void Set(PdnRegion region, bool newValue)
 {
     foreach (Rectangle rect in region.GetRegionScansReadOnlyInt())
     {
         Set(rect, newValue);
     }
 }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:7,代码来源:BitVector2DSurfaceAdapter.cs

示例14: RenderedTileEventArgs

 public RenderedTileEventArgs(PdnRegion renderedRegion, int tileCount, int tileNumber)
 {
     this.renderedRegion = renderedRegion;
     this.tileCount = tileCount;
     this.tileNumber = tileNumber;
 }
开发者ID:metadeta96,项目名称:openpdn,代码行数:6,代码来源:RenderedTileEventArgs.cs

示例15: Changed

 private void Changed()
 {
     if (regionCache != null)
     {
         lock (regionCache.SyncRoot)
         {
             regionCache.Dispose();
             regionCache = null;
         }
     }
 }
开发者ID:herbqiao,项目名称:paint.net,代码行数:11,代码来源:PdnGraphicsPath.cs


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