在ios Xamarin上绘制图像

时间:2014-01-21 15:36:09

标签: ios xamarin.ios xamarin

我正在为孩子们申请。在这个应用程序中,我想让孩子们画出他们想要的东西,或用一种颜色填充区域。对于绘图,我使用类似代码stackoverflow.com/questions/17219426/building-an-app-with-an-electronic-signature-feature-for-ios-possibly-using-mono

中的内容

现在我想用颜色填充区域

我发现这个代码用于android,我想将其转换为iOS(xamarin)

`     private void FloodFill(Bitmap bmp,Point pt,int targetColor,int replacementColor)     {

    Queue<Point> q = new LinkedList<Point>();
    q.add(pt);

    while (q.size() > 0) {
        Point n = q.poll();
        if (bmp.getPixel(n.x, n.y) != targetColor)
            continue;
        Point w = n, e = new Point(n.x + 1, n.y);

        while ((w.x > 0) && (bmp.getPixel(w.x, w.y) == targetColor)) 
        {
            bmp.setPixel(w.x, w.y, replacementColor);
            if ((w.y > 0) && (bmp.getPixel(w.x, w.y - 1) == targetColor))
                q.add(new Point(w.x, w.y - 1));
            if ((w.y < bmp.getHeight() - 1) && (bmp.getPixel(w.x, w.y + 1) == targeteColor))
                q.add(new Point(w.x, w.y + 1));
            w.x--;
        }

        while ((e.x < bmp.getWidth() - 1)&& (bmp.getPixel(e.x, e.y) == targetColor)) 
        {
            bmp.setPixel(e.x, e.y, replacementColor);
            if ((e.y > 0) && (bmp.getPixel(e.x, e.y - 1) == targetColor))
                q.add(new Point(e.x, e.y - 1));
            if ((e.y < bmp.getHeight() - 1) && (bmp.getPixel(e.x, e.y + 1) == targetColor))
                q.add(new Point(e.x, e.y + 1));
            e.x++;
        }
    }
}

`

欢迎任何帮助或评论

谢谢

0 个答案:

没有答案
相关问题