Xamarin: Anti-Aliasing doesnt work right {screenshot};

时间:2017-04-15 11:18:27

标签: android xamarin

so I am working on this app, that lets u pick a profile picture and then renders it into a circle to then show it back to the user. This is the result: Screenshot

所以,问题是圆圈的白色边框: 正如你所看到的那样,它并不是消除锯齿的,即使我们当然把抗锯齿放到了#34; true"。

你可以帮我们解决这个问题吗?我们找不到任何更好的方法来解决这个问题,但显然不应该这样......

非常感谢:)

编辑:

这是我们的代码

public static Bitmap DrawBorder(Bitmap bitmap)
{
    float ratio = 0.97f;
    int width = bitmap.Width;
    int height = bitmap.Height;
    Bitmap outputBitmap = Bitmap.CreateBitmap(width, height, Config.Argb8888);

    Path path = new Path();
    Canvas canvas = new Canvas(outputBitmap);

    //Draw Border
    Paint paint = new Paint();
    paint.AntiAlias = true;
    paint.SetStyle(Paint.Style.Fill);
    paint.SetXfermode(null);
    //   paint.SetStyle(Paint.Style.Stroke);
    paint.Color = Color.White;
    //   paint.StrokeWidth = 6;
    canvas.DrawCircle((float)width / 2, (float)height / 2, (float)Math.Min(width / 2, (height / 2)), paint);

    //Draw Picture 
    path.AddCircle(
              (float)(width / 2)
            , (float)(height / 2)
            , (float)Math.Min(width / 2, (height / 2)) * ratio
            , Path.Direction.Ccw);

    canvas.ClipPath(path);
    canvas.DrawBitmap(bitmap, 0, 0, paint);



    return outputBitmap;
}

0 个答案:

没有答案