I am trying to create bitmap of all view.but I am not able to create bitmap of all view,please help me to resolve this problem.
Asked
Active
Viewed 103 times
0
-
1Please post your code – PriyankaChauhan Sep 30 '16 at 06:03
-
Possible duplicate of [Converting a view to Bitmap without displaying it in Android?](http://stackoverflow.com/questions/2801116/converting-a-view-to-bitmap-without-displaying-it-in-android) – Anjali Sep 30 '16 at 06:12
1 Answers
0
public Bitmap overlay(FrameLayout frame_layout){
frame_layout.setDrawingCacheEnabled(true);
frame_layout.buildDrawingCache();
return frame_layout.getDrawingCache();
}
public void saveImage(){
Bitmap bitmap=overlay(print_layout);
try{
String path = Environment.getExternalStorageDirectory().toString()+ File.separator+"bitmap";
File path_file=new File(path);
path_file.mkdirs();
OutputStream fOut = null;
File file = new File(path+ File.separator+"print.png"); // the File to save to
fOut = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate
fOut.flush();
fOut.close();
Log.d("sun","saved");
}
catch (Exception e){
Log.d("sun",e.toString());
}
}

Shubham Sahil
- 11
- 3