public MaskedSurface(Surface source, PdnGraphicsPath path)
        {
            RectangleF boundsF = path.GetBounds();
            Rectangle  bounds  = Utility.RoundRectangle(boundsF);

            Rectangle boundsClipped = Rectangle.Intersect(bounds, source.Bounds);
            Rectangle boundsRead;

            if (bounds != boundsClipped)
            {
                PdnRegion region = new PdnRegion(path);
                region.Intersect(source.Bounds);
                SetPathField(PdnGraphicsPath.FromRegion(region));
                this.region = region;
                boundsRead  = region.GetBoundsInt();
            }
            else
            {
                SetPathField(path.Clone());
                this.region = new PdnRegion(this.path);
                boundsRead  = boundsClipped;
            }

            if (boundsRead.Width > 0 && boundsRead.Height > 0)
            {
                this.surface = new Surface(boundsRead.Size);
                this.surface.CopySurface(source, boundsRead);
            }
            else
            {
                this.surface = null;
            }
        }
        private PdnGraphicsPath GetPath()
        {
            if (this.path == null)
            {
                SetPathField(PdnGraphicsPath.FromRegion(this.region));
            }

            return(this.shadowPath);
        }
        private PdnGraphicsPath GetPath()
        {
            if (this.path == null)
            {
                // TODO: FromRegion() is a VERY expensive call!
                PdnGraphicsPath newPath = PdnGraphicsPath.FromRegion(this.region);
                SetPathField(newPath);
            }

            return(this.shadowPath);
        }
Exemple #4
0
 public PdnGraphicsPath CreatePixelatedPath()
 {
     using (PdnGraphicsPath path = CreatePath())
     {
         using (PdnRegion region = new PdnRegion(path))
         {
             PdnGraphicsPath pixellatedPath = PdnGraphicsPath.FromRegion(region);
             return(pixellatedPath);
         }
     }
 }
        /// <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));
        }
Exemple #6
0
        /// <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.SurfaceReadOnly = new Surface(boundsClipped.Size);
            this.SurfaceReadOnly.Clear(ColorBgra.FromUInt32(0x00ffffff));

            Rectangle rect      = boundsClipped;
            Point     dstOffset = new Point(rect.X - boundsClipped.X, rect.Y - boundsClipped.Y);

            this.SurfaceReadOnly.CopySurface(source, dstOffset, rect);

            this.region = roiClipped;
            // TODO: FromRegion() is a VERY expensive call for what we are doing!
            PdnGraphicsPath newPath = PdnGraphicsPath.FromRegion(this.region);

            SetPathField(newPath);
        }