I'm taking screenshot of my Layout with this code:
View u = findViewById(R.id.mainL);
u.setDrawingCacheEnabled(true);
LinearLayout z = (LinearLayout) findViewById(R.id.mainL);
int totalHeight = z.getHeight();
int totalWidth = z.getWidth();
u.layout(0, 0, totalWidth, totalHeight);
u.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(u.getDrawingCache());
u.setDrawingCacheEnabled(false);
obviously I'm not doing anything on quality but the result bitmap (that is a jpeg image) has a very bad quality.
what am I doing wrong? I thing I should change it to a PNG Image somehow for better quality but I don't know how. thanks.
Edit:
for those who ask where am I saving the bitmap I have to say that I'm not saving it at all. I just share it with this code:
String pathofBmp = MediaStore.Images.Media.insertImage(getContentResolver(), b , "title", null);
Uri bmpUri = Uri.parse(pathofBmp);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpeg");
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(shareIntent, "Share"));