首页 > 解决方案 > 保存到存储时 PNG 文件大小会增加

问题描述

我的 android 项目中有一个可绘制的 png,大小为36.98kb,我将这张图片保存到缓存目录中的用户设备中。

这是我的代码

File wmImg = new File(getExternalCacheDir(), "WmImg.png");
            if (!wmImg.exists()) {
                fos = new FileOutputStream(wmImg);
                Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.watermark);
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
            } 

文件保存成功,但图像大小增加到264kb。原始图像和保存的图像之间存在巨大差异。为什么会这样?

如何在不增加大小的情况下将png文件保存到android?

请任何帮助或建议...

标签: javaandroid-studiopngfilesize

解决方案


推荐阅读