當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。