【问题标题】:Save image in internal storage without compressing将图像保存在内部存储中而不压缩
【发布时间】:2013-10-24 13:03:03
【问题描述】:

我正在将图像保存在存储器中,但图像质量因压缩而丢失。那么如何在不压缩的情况下保存图像。 我正在使用以下代码

//Creating bitmap from Resource id
Bitmap bitmap=BitmapFactory.decodeResource(getResources(), BitmapId);
    String extStorage=Environment.getExternalStorageDirectory().toString();

    File file = new File(extStorage, "name.png");
    if(file.exists())
        file.delete();
    try {
        outStream = new FileOutputStream(file);
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
.....
}

请告诉我如何保存图像而不损失其质量..

【问题讨论】:

    标签: android storage


    【解决方案1】:

    你提供的第二个参数100其实并不影响你的图像质量,但是如果你想压缩更多你可以将值减小到10,你会得到一个低质量的图像,只对内存问题,

    但我认为值 100 不会影响你的质量,这只是一个猜测

    【讨论】:

    • 我想保存原始图像,而不是压缩后的图像。对于 PNG 压缩,质量参数会被忽略,但即使保存的图像也会被压缩,因此其质量会受到影响。我应该怎么做才能保留原始图像
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-28
    • 1970-01-01
    • 2013-10-28
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多