I am trying to get screenshot of the view as follows. I am getting Bitmap and I need to convert it to to Image to add into PDF generator.
using (var screensh
You can use this method:
public Bitmap getScreenshotBmp() {
FileOutputStream fileOutputStream = null;
File path = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
String uniqueID = UUID.randomUUID().toString();
File file = new File(path, uniqueID + ".jpg");
try {
fileOutputStream = new FileOutputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
screenshot.compress(Bitmap.CompressFormat.JPEG, 30, fileOutputStream);
try {
fileOutputStream.flush();
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return screenshot;
}
Bitmap bm = BitmapFactory.DecodeFile (path);
MemoryStream stream = new MemoryStream ();
bm.Compress (Bitmap.CompressFormat.Jpeg, 100, stream);
Image img = Image.FromArray (stream.ToArray());