Ejemplo n.º 1
0
 public RoundedRect(RectangleD bounds, double r)
     : this(bounds.x1, bounds.y1, bounds.x2, bounds.y2, r)
 {
 }
Ejemplo n.º 2
0
        // Generic routine to create the intersection between
        // two rectangles.
        //
        public static RectangleD Intersect(RectangleD left, RectangleD right)
        {
            double x1 = Math.Max(left.x1, right.x1);
            double x2 = Math.Min(left.x2, right.x2);
            double y1 = Math.Max(left.y1, right.y1);
            double y2 = Math.Min(left.y2, right.y2);

            if (x2 >= x1 && y2 >= y1)
            {
                return new RectangleD(x1, y1, x2, y2);
            }

            return RectangleD.Empty;
        }
Ejemplo n.º 3
0
        public static RectangleD Union(RectangleD left, RectangleD right)
        {
            double x1 = Math.Min(left.Left, right.Left);
            double x2 = Math.Max(left.Right, right.Right);
            double y1 = Math.Min(left.Bottom, right.Bottom);
            double y2 = Math.Max(left.Top, right.Top);

            return new RectangleD(x1, y1, x2, y2);
        }
Ejemplo n.º 4
0
 // Change the shape of this rectangle by intersecting
 // it with another one.
 public void Intersect(RectangleD rect)
 {
     RectangleD result = RectangleD.Intersect(rect, this);
     this.x1 = result.Left;
     this.y1 = result.Bottom;
     this.x2 = result.x2;
     this.y2 = result.y2;
 }
Ejemplo n.º 5
0
        public bool Clip(RectangleD r)
        {
            if (x2 > r.x2) x2 = r.x2;
            if (y2 > r.y2) y2 = r.y2;
            if (x1 < r.x1) x1 = r.x1;
            if (y1 < r.y1) y1 = r.y1;

            return IsValid();
        }
Ejemplo n.º 6
0
 public abstract void SetClippingRect(RectangleD rect_d);
Ejemplo n.º 7
0
        void DrawImage(IImage sourceImage,
            double DestX, double DestY,
            double HotspotOffsetX, double HotspotOffsetY,
            double ScaleX, double ScaleY,
            double AngleRad,
            RGBA_Bytes Color32,
            ref RectangleD pFinalBlitBounds,
            bool doDrawing,
            bool oneMinusSourceAlphaOne)
        {
            Affine destRectTransform = Affine.NewIdentity();

            if (HotspotOffsetX != 0.0f || HotspotOffsetY != 0.0f)
            {
                destRectTransform *= Affine.NewTranslation(-HotspotOffsetX, -HotspotOffsetY);
            }

            if (ScaleX != 1 || ScaleY != 1)
            {
                destRectTransform *= Affine.NewScaling(ScaleX, ScaleY);
            }

            if (AngleRad != 0)
            {
                destRectTransform *= Affine.NewRotation(AngleRad);
            }

            if (DestX != 0 || DestY != 0)
            {
                destRectTransform *= Affine.NewTranslation(DestX, DestY);
            }

            int SourceBufferWidth = (int)sourceImage.Width();
            int SourceBufferHeight = (int)sourceImage.Height();

            RectPath.Clear();

            RectPath.MoveTo(0, 0);
            RectPath.LineTo(SourceBufferWidth, 0);
            RectPath.LineTo(SourceBufferWidth, SourceBufferHeight);
            RectPath.LineTo(0, SourceBufferHeight);
            RectPath.ClosePolygon();


            // Calculate the bounds. LBB [10/5/2004]
            const int ERROR_ADD = 0;
            double BoundXDouble, BoundYDouble;
            BoundXDouble = 0; BoundYDouble = 0;
            destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble);
            double BoundX = (double)BoundXDouble;
            double BoundY = (double)BoundYDouble;

            pFinalBlitBounds.Left = Math.Floor(BoundX - ERROR_ADD);
            pFinalBlitBounds.Right = Math.Ceiling(BoundX + ERROR_ADD);
            pFinalBlitBounds.Top = Math.Floor(BoundY - ERROR_ADD);
            pFinalBlitBounds.Bottom = Math.Ceiling(BoundY + ERROR_ADD);

            BoundXDouble = SourceBufferWidth; BoundYDouble = 0;
            destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble);
            BoundX = (double)BoundXDouble;
            BoundY = (double)BoundYDouble;
            pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left);
            pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right);
            pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top);
            pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom);

            BoundXDouble = SourceBufferWidth; BoundYDouble = SourceBufferHeight;
            destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble);
            BoundX = (double)BoundXDouble;
            BoundY = (double)BoundYDouble;
            pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left);
            pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right);
            pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top);
            pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom);

            BoundXDouble = 0; BoundYDouble = SourceBufferHeight;
            destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble);
            BoundX = (double)BoundXDouble;
            BoundY = (double)BoundYDouble;
            pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left);
            pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right);
            pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top);
            pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom);

            if (!doDrawing)
            {
                return;
            }

            if (m_DestImage.OriginOffset.x != 0 || m_DestImage.OriginOffset.y != 0)
            {
                destRectTransform *= Affine.NewTranslation(-m_DestImage.OriginOffset.x, -m_DestImage.OriginOffset.y);
            }

            Affine sourceRectTransform = new Affine(destRectTransform);
            // We invert it because it is the transform to make the image go to the same position as the polygon. LBB [2/24/2004]
            sourceRectTransform.Invert();

            span_allocator spanAllocator = new span_allocator();

            span_interpolator_linear interpolator = new span_interpolator_linear(sourceRectTransform);

            ImageBuffer sourceImageWithBlender = (ImageBuffer)sourceImage;// new ImageBuffer(sourceImage, new BlenderBGRA());

            span_image_filter_rgba_bilinear_clip spanImageFilter;
            ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImageWithBlender, RGBA_Doubles.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes());
            spanImageFilter = new span_image_filter_rgba_bilinear_clip(source, RGBA_Doubles.rgba_pre(0, 0, 0, 0), interpolator);

            rasterizer_scanline_aa rasterizer = new rasterizer_scanline_aa();
            rasterizer.SetVectorClipBox(0, 0, m_DestImage.Width(), m_DestImage.Height());
            scanline_packed_8 scanlineCache = new scanline_packed_8();
            //scanline_unpacked_8 scanlineCache = new scanline_unpacked_8();

            conv_transform transfromedRect = new conv_transform(RectPath, destRectTransform);
            rasterizer.add_path(transfromedRect);
#if false
	        bool HighQualityFilter = (BlitXParams.m_OptionalFlags & CBlitXParams::BlitHighQualityFilter) != 0
		        && (BlitXParams.m_OptionalFlags & CBlitXParams::RenderOneMinusScrAlpha_One) == 0;
	        if (HighQualityFilter)
	        {
Ejemplo n.º 8
0
 public override void SetClippingRect(RectangleD clippingRect)
 {
     Rasterizer.SetVectorClipBox(clippingRect);
 }