【问题标题】:MediaStore.Images.Media lowers the quality of the image stored to galleryMediaStore.Images.Media 降低存储到画廊的图像质量
【发布时间】:2013-07-23 04:40:43
【问题描述】:

我正在通过 -

将应用的屏幕截图保存到图库
//screenshot
private void screenshot()
{
    Uri photo = lomography();
    String photopath = photo.getPath();
    try {
        MediaStore.Images.Media.insertImage(getContentResolver(), photopath, "name" , "desc");
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

存储在光路中的图像质量很高:

但是当我导航到图库并打开同一张照片时,这是低 JPEG 版本,带有几个压缩伪像:

为什么当原始文件是 PNG 时,图库图像是 JPEG 版本? 如何将高分辨率版本保存到图库?

read here 的诀窍在于“使用 ContentResolver::insert 注册图像”。

但我正在使用 getContentResolver。

【问题讨论】:

    标签: android jpeg mediastore


    【解决方案1】:

    要解决此问题,请打开“MediaStore.Images.Media.insertImage”方法的声明,将您需要的代码复制并粘贴到您自己的类中,然后将图像压缩为 50% 的地方将其更改为 100% .

    【讨论】:

      【解决方案2】:

      这就是答案。 我的意思是“this”是代码中缺少的部分。

      而不是“MediaStore.Images.Media.insertImage(getContentResolver()”。 我应该使用 MediaStore.Images.Media.insertImage(this.getContentResolver()

      问题解决了。

      【讨论】:

      • 两者是相同的,默认情况下,在this实例中调用。
      • @xmenW.K.图像质量显着降低,就像 vga 相机一样。
      • 标记的答案不是解决方案,您调用的是相同的方法,无论是否使用this
      • @xmenW.K.添加“this”出人意料地解决了这个问题。我想这与上下文有关。没有这个,它会创建一个缩略图质量的屏幕截图。
      • MediaStore.insertImage 源代码显示图像确实被大幅压缩:github.com/android/platform_frameworks_base/blob/master/core/… -- 50% 质量!
      猜你喜欢
      • 2016-02-09
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 2019-08-23
      • 2017-08-03
      • 1970-01-01
      • 1970-01-01
      • 2016-06-06
      相关资源
      最近更新 更多