I'm using below code for taking a view as parameter and create a bitmap from it:
public Bitmap screenShot(View view) {
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
view.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
return bitmap;
}
Now I'm using this code for taking screen shot from specific view and share it using Intent:
Bitmap captured = commons.screenShot(view);
String pathofBmp = Images.Media.insertImage(getContentResolver(), captured,"title", null);
Uri bmpUri = Uri.parse(pathofBmp);
Intent emailIntent1 = new Intent(android.content.Intent.ACTION_SEND);
emailIntent1.setType("image/jpeg");
emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri);
startActivity(Intent.createChooser(emailIntent1, "Share image using"));
It works perfect. But the result is a image with black background and low quality.
I've searched a lot, for example this way(Bad image quality after resizing/scaling bitmap), But problem still exists.
Any idea?
Thank in advanced.