java - 保存到存储时 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?
请任何帮助或建议...
解决方案
推荐阅读
- java - com.intellij.util.ReflectionUtil 对方法 java.util.ResourceBundle.setParent(java.util.ResourceBundle) 的非法反射访问
- firebase - 将 Firebase Firestore 设置为仅允许从单个 Unity 应用读取/写入
- javascript - 如何制作汇总模块,重新导出 ESM 模块的子模块的所有导出?
- javascript - Reactjs 函数“不是函数”
- java - 如何通过使用Java在powershell中获取进程名和id来区分系统和正常进程
- python - 如何将函数应用于 pandas DataFrame,但具有现有的 DataFrame 属性?
- python - 为什么当我改变其他对象的成员时对象成员会发生变化?
- c - zd vs lu 用于 sizeof
- react-native - 运行测试运行器时出现阴影错误
- r - R:图上的重叠点