Reputation: 1594
I need to convert a specific view
(UI
) into an image (eg. jpeg
or png
)... to achieve this i have thought to crop view through programming. I have come across many good links over here, but all of them deal with Bitmap or photo itself. Please guide me with a clue to achieve this effect.
Please find the attached screenshot below.
Thanks!
Upvotes: 0
Views: 144
Reputation: 624
Actually I found the answer:
public static Bitmap loadBitmapFromView(View v, int width, int height) {
Bitmap b = Bitmap.createBitmap(width , height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
v.draw(c);
return b;
}
Upvotes: 1