Ejemplo n.º 1
0
 //-----------------------------------------------------IntersectRectangles
 public void IntersectRectangles(RectI r1, RectI r2)
 {
     x1 = r1.x1;
     y1 = r1.y1;
     x2 = r1.x2;
     x2 = r1.y2;
     // First process m_x2,m_y2 because the other order
     // results in Internal Compiler Error under
     // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in
     // case of "Maximize Speed" optimization option.
     //-----------------
     if (x2 > r2.x2)
     {
         x2 = r2.x2;
     }
     if (y2 > r2.y2)
     {
         y2 = r2.y2;
     }
     if (x1 < r2.x1)
     {
         x1 = r2.x1;
     }
     if (y1 < r2.y1)
     {
         y1 = r2.y1;
     }
 }
Ejemplo n.º 2
0
 //--------------------------------------------------------------------
 public VectorClipper_DoClip()
 {
     m_clip_box = new RectI(0, 0, 0, 0);
     m_x1       = (0);
     m_y1       = (0);
     m_f1       = (0);
     m_clipping = (false);
 }
Ejemplo n.º 3
0
 //--------------------------------------------------------------------
 public VectorClipper_DoClip()
 {
     m_clip_box = new RectI(0,0,0,0);
     m_x1 = (0);
     m_y1 = (0);
     m_f1 = (0);
     m_clipping = (false);
 }
Ejemplo n.º 4
0
 public bool Clip(RectI 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(x1 <= x2 && y1 <= y2);
 }
Ejemplo n.º 5
0
 //---------------------------------------------------------UniteRectangles
 public void UniteRectangles(RectI r1, RectI r2)
 {
     x1 = r1.x1;
     y1 = r1.y1;
     x2 = r1.x2;
     x2 = r1.y2;
     if (x2 < r2.x2)
     {
         x2 = r2.x2;
     }
     if (y2 < r2.y2)
     {
         y2 = r2.y2;
     }
     if (x1 > r2.x1)
     {
         x1 = r2.x1;
     }
     if (y1 > r2.y1)
     {
         y1 = r2.y1;
     }
 }
Ejemplo n.º 6
0
 public override void Attach(IPixelFormat ren)
 {
     base.Attach(ren);
     m_clip_box = new RectI(0, 0, (int)ren.Width - 1, (int)ren.Height - 1);
 }
Ejemplo n.º 7
0
 //--------------------------------------------------------------------
 //public IPixelFormat ren() { return m_ren; }
 //--------------------------------------------------------------------
 public bool SetClippingBox(int x1, int y1, int x2, int y2)
 {
     RectI cb = new RectI(x1, y1, x2, y2);
     cb.Normalize();
     if (cb.Clip(new RectI(0, 0, (int)Width - 1, (int)Height - 1)))
     {
         m_clip_box = cb;
         return true;
     }
     m_clip_box.x1 = 1;
     m_clip_box.y1 = 1;
     m_clip_box.x2 = 0;
     m_clip_box.y2 = 0;
     return false;
 }
Ejemplo n.º 8
0
        public void CopyFrom(RasterBuffer src,
                       RectI rect_src_ptr,
                       int dx,
                       int dy)
        {
            RectI rsrc = new RectI(rect_src_ptr.x1, rect_src_ptr.y1, rect_src_ptr.x2 + 1, rect_src_ptr.y2 + 1);

            // Version with xdst, ydst (absolute positioning)
            //RectI rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1);

            // Version with dx, dy (relative positioning)
            RectI rdst = new RectI(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy);

            RectI rc = ClipRectangleArea(ref rdst, ref rsrc, (int)src.Width(), (int)src.Height());

            if(rc.x2 > 0)
            {
                int incy = 1;
                if(rdst.y1 > rsrc.y1)
                {
                    rsrc.y1 += rc.y2 - 1;
                    rdst.y1 += rc.y2 - 1;
                    incy = -1;
                }
                while(rc.y2 > 0)
                {
                    base.CopyFrom(src,
                                     rdst.x1, rdst.y1,
                                     rsrc.x1, rsrc.y1,
                                     (uint)rc.x2);
                    rdst.y1 += incy;
                    rsrc.y1 += incy;
                    --rc.y2;
                }
            }
        }
Ejemplo n.º 9
0
 //--------------------------------------------------------------------
 public FormatClippingProxy(IPixelFormat ren)
     : base(ren)
 {
     m_clip_box = new RectI(0, 0, (int)ren.Width - 1, (int)ren.Height - 1);
 }
Ejemplo n.º 10
0
        public RectI ClipRectangleArea(ref RectI dst, ref RectI src, int wsrc, int hsrc)
        {
            RectI rc = new RectI(0,0,0,0);
            RectI cb = ClipBox;
            ++cb.x2;
            ++cb.y2;

            if(src.x1 < 0)
            {
                dst.x1 -= src.x1;
                src.x1 = 0;
            }
            if(src.y1 < 0)
            {
                dst.y1 -= src.y1;
                src.y1 = 0;
            }

            if(src.x2 > wsrc) src.x2 = wsrc;
            if(src.y2 > hsrc) src.y2 = hsrc;

            if(dst.x1 < cb.x1)
            {
                src.x1 += cb.x1 - dst.x1;
                dst.x1 = cb.x1;
            }
            if(dst.y1 < cb.y1)
            {
                src.y1 += cb.y1 - dst.y1;
                dst.y1 = cb.y1;
            }

            if(dst.x2 > cb.x2) dst.x2 = cb.x2;
            if(dst.y2 > cb.y2) dst.y2 = cb.y2;

            rc.x2 = dst.x2 - dst.x1;
            rc.y2 = dst.y2 - dst.y1;

            if(rc.x2 > src.x2 - src.x1) rc.x2 = src.x2 - src.x1;
            if(rc.y2 > src.y2 - src.y1) rc.y2 = src.y2 - src.y1;
            return rc;
        }
Ejemplo n.º 11
0
 //--------------------------------------------------------------------
 public void ClipBox(int x1, int y1, int x2, int y2)
 {
     m_clip_box = new RectI(x1, y1, x2, y2);
     m_clip_box.Normalize();
     m_clipping = true;
 }
Ejemplo n.º 12
0
 //---------------------------------------------------------UniteRectangles
 public void UniteRectangles(RectI r1, RectI r2)
 {
     x1 = r1.x1;
     y1 = r1.y1;
     x2 = r1.x2;
     x2 = r1.y2;
     if (x2 < r2.x2) x2 = r2.x2;
     if (y2 < r2.y2) y2 = r2.y2;
     if (x1 > r2.x1) x1 = r2.x1;
     if (y1 > r2.y1) y1 = r2.y1;
 }
Ejemplo n.º 13
0
 //-----------------------------------------------------IntersectRectangles
 public void IntersectRectangles(RectI r1, RectI r2)
 {
     x1 = r1.x1;
     y1 = r1.y1;
     x2 = r1.x2;
     x2 = r1.y2;
     // First process m_x2,m_y2 because the other order
     // results in Internal Compiler Error under
     // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in
     // case of "Maximize Speed" optimization option.
     //-----------------
     if (x2 > r2.x2) x2 = r2.x2;
     if (y2 > r2.y2) y2 = r2.y2;
     if (x1 < r2.x1) x1 = r2.x1;
     if (y1 < r2.y1) y1 = r2.y1;
 }
Ejemplo n.º 14
0
 public bool Clip(RectI 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 x1 <= x2 && y1 <= y2;
 }
Ejemplo n.º 15
0
 //--------------------------------------------------------------------
 public void ClipBox(int x1, int y1, int x2, int y2)
 {
     m_clip_box = new RectI(x1, y1, x2, y2);
     m_clip_box.Normalize();
     m_clipping = true;
 }