How to make Android screenshots saved as .jpg?

时光怂恿深爱的人放手 提交于 2019-12-13 08:05:41

问题


I am using ExifInterface to save information for image description. But because screenshots are save .png and ExifInterface doesn't work on .png, I cannot save image description for screenshots.

I have two options:

  1. Every time I need to save EXIF image description, I need to first convert the screenshots to .jpg format, and then edit its EXIF data.
  2. Or I can just set the phone to save all screenshots as .jpg files. So whenever I save a screenshot (by pressing the volume down key+power button), the screenshot is saved right there and then as .jpg. No hassle trying to convert it later.

回答1:


You can take advantage of a View's drawing cache.

myView.setDrawingCacheEnabled(true);
Bitmap b = view.getDrawingCache();
b.compress(CompressFormat.JPEG, 95, new FileOutputStream("/some/location/image.jpg"))

Where view is your View. The 95 is the quality of the JPG compression. And the file output stream is just that.



来源:https://stackoverflow.com/questions/51617172/how-to-make-android-screenshots-saved-as-jpg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!