示例#1
0
        // returns true for out of range
        public static bool SetPixel(object sessionObj, int x1, int y1, int x2, int y2, int r, int g, int b, int a)
        {
            Wax.Util.Images.UniversalBitmap.DrawingSession session = (Wax.Util.Images.UniversalBitmap.DrawingSession)sessionObj;
            if (x1 < 0 || y1 < 0 || x1 >= session.Parent.Width || y1 >= session.Parent.Height)
            {
                return(true);
            }
            if (x2 < 0 || y2 < 0 || x2 >= session.Parent.Width || y2 >= session.Parent.Height)
            {
                return(true);
            }

            if (x1 == x2 && y1 == y2)
            {
                session.SetPixel(x1, y1, r, g, b, a);
            }
            else
            {
                int    xdiff = x2 - x1;
                int    ydiff = y2 - y1;
                double progress;
                int    step, xEnd, yEnd, x, y;
                if (Math.Abs(xdiff) > Math.Abs(ydiff))
                {
                    // draw horizontally
                    step = xdiff > 0 ? 1 : -1;
                    xEnd = x2 + step;
                    for (x = x1; x != xEnd; x += step)
                    {
                        progress = 1.0 * (x - x1) / (x2 - x1);
                        y        = (int)(progress * ydiff + .5) + y1;
                        session.SetPixel(x, y, r, g, b, a);
                    }
                }
                else
                {
                    // draw vertically
                    step = ydiff > 0 ? 1 : -1;
                    yEnd = y2 + step;
                    for (y = y1; y != yEnd; y += step)
                    {
                        progress = 1.0 * (y - y1) / (y2 - y1);
                        x        = (int)(progress * xdiff + .5) + x1;
                        session.SetPixel(x, y, r, g, b, a);
                    }
                }
            }
            return(false);
        }
示例#2
0
 public static void EndEditSession(object sessionObj, object bmpObj)
 {
     Wax.Util.Images.UniversalBitmap.DrawingSession session = (Wax.Util.Images.UniversalBitmap.DrawingSession)sessionObj;
     session.Flush();
 }
示例#3
0
 public static void Blit(object targetObj, object srcObj, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th)
 {
     Wax.Util.Images.UniversalBitmap.DrawingSession target = (Wax.Util.Images.UniversalBitmap.DrawingSession)targetObj;
     Wax.Util.Images.UniversalBitmap src = (Wax.Util.Images.UniversalBitmap)srcObj;
     target.Draw(src, tx, ty, sx, sy, tw, th, sw, sh);
 }
示例#4
0
 public static object StartEditSession(object bmpObj)
 {
     Wax.Util.Images.UniversalBitmap bmp = (Wax.Util.Images.UniversalBitmap)bmpObj;
     Wax.Util.Images.UniversalBitmap.DrawingSession session = bmp.CreateNewDrawingSession();
     return(session);
 }