1

I am trying to take screenshot of a view using getDrawingCache() method. When it gives bitmap that bitmap have not the same quality which i can see on the application. Below is the code which i am using :

view.buildDrawingCache();
Bitmap cacheBitmap = view.getDrawingCache();
ByteArrayOutputStream streamOut = new ByteArrayOutputStream();
cacheBitmap.compress(Bitmap.CompressFormat.PNG, 100, streamOut);
byte[] bitmapDataArry = streamOut.toByteArray();

I already tried few stuff which i got from google and SO. Like this improve quality of getdrawingcache and improve quality of image. But still not getting the pure image quality. Can anyone have any suggestion about this or any else method for taking screenshot without loosing quality.

Community
  • 1
  • 1
Ronak Joshi
  • 1,553
  • 2
  • 20
  • 43

1 Answers1

0

I guess your problem is that you taka a screenshot on a small screen device and there the drawing cache is smaller and therefore the screenshot itself is smaller but looks ok because of the phone screen which is also small. If you then upload this image that you've got from getDrawingCache to your server and then try to show it on another device with higher resolution screen the quality will be grainy and pixelated. If you are in this case then showing the original image or cropped version of it will help you maintain quality.

There is another case when your view might be getting the old cache. Here you can destroyDrawingCache() and then buildDrawingCache().

loshkin
  • 1,600
  • 2
  • 21
  • 38
  • So, what can i do for this. Because as we do not identify that which resolution's device user is using. Is there any way to take screenshot without depending on screen resolution? – Ronak Joshi Mar 16 '17 at 05:36