convert view to image in android
I'm trying to send a chart via email in android applicat开发者_JS百科ion, how can I attach that chart to email application?
Before attaching the graph to email we have to save the graph image into storage, For that you just enable the cache for that view by setting setDrawingCacheEnabled(true);
Then create the bitmap Bitmap.createBitmap(View.getDrawingCache());
.
we can convert the bitmap to desired image format as follows
bitmap.compress(CompressFormat.PNG, 100, new FileOutputStream(filename));
精彩评论