将其上传到服务器后如何保持图像质量?

时间:2014-12-19 10:23:35

标签: android bitmapimage

代码工作正常,但生成的图像失去了很多质量。使用的压缩格式是PNG。还有如何将图像保存为.png而不是.file。

public static void writeBitmapToDisk(String filename, Bitmap paramBitmap,
        Context paramContext, Bitmap.CompressFormat paramCompressFormat) {

    Log.e("CL", "paramBitmap.getByteCount()" + paramBitmap.getByteCount());

    String str = constructFileName(filename);
    if (paramBitmap != null) {
        try {
            FileOutputStream localFileOutputStream = paramContext
                    .openFileOutput(str, 0);
            Log.e("CL", "localFileOutputStream" + localFileOutputStream);
            paramBitmap.compress(paramCompressFormat, 100,
                    localFileOutputStream);
            localFileOutputStream.close();
            return;
        } catch (FileNotFoundException localFileNotFoundException) {
            localFileNotFoundException.printStackTrace();
            return;
        } catch (IOException localIOException) {
            localIOException.printStackTrace();
        }
    }
}

0 个答案:

没有答案