0

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.

Community
  • 1
  • 1
Sirwan Afifi
  • 10,654
  • 14
  • 63
  • 110
  • If insertImage() lowers the quality of the picture then why not save the bitmap to file yourself? Further i would like to know what you consider to be the result in 'the result is an image..'. Where does one see the result? – greenapps Oct 22 '14 at 20:43
  • 1
    Actually, I don't want to save file, I just need to create bitmap on the fly. – Sirwan Afifi Oct 22 '14 at 20:45

0 Answers0