Exemple #1
0
        public static Bitmap getRoundedShape(Bitmap scaleBitmapImage,int targetint)
        {
            int targetWidth = targetint;
            int targetHeight = targetint;
            Bitmap targetBitmap = Bitmap.CreateBitmap(targetWidth,
                targetHeight,Bitmap.Config.Argb8888);

            Canvas canvas = new Canvas(targetBitmap);
            global::Android.Graphics.Path path = new global::Android.Graphics.Path();
            path.AddCircle(((float) targetWidth - 1) / 2,
                ((float) targetHeight - 1) / 2,
                (Math.Min(((float) targetWidth),
                    ((float) targetHeight)) / 2),
                global::Android.Graphics.Path.Direction.Ccw);

            canvas.ClipPath(path);
            Bitmap sourceBitmap = scaleBitmapImage;
            canvas.DrawBitmap(sourceBitmap,
                new Rect(0, 0, sourceBitmap.Width,
                    sourceBitmap.Height),
                new Rect(0, 0, targetWidth, targetHeight), null);
            return targetBitmap;
        }