Ejemplo n.º 1
0
        public static Bitmap AsBitmap(this Android.Views.View view, Context context, int width, int height)
        {
            DisplayMetrics displayMetrics = new DisplayMetrics();

            view.Measure(displayMetrics.WidthPixels, displayMetrics.HeightPixels);
            view.Layout(0, 0, displayMetrics.WidthPixels, displayMetrics.HeightPixels);

            view.BuildDrawingCache();
            Bitmap bitmap = Bitmap.CreateBitmap(displayMetrics, width, height, Bitmap.Config.Argb8888);

            Canvas canvas = new Canvas(bitmap);

            view.Draw(canvas);

            return(bitmap);
        }