简体   繁体   English

在相机胶卷中保存png

[英]save png in camera roll

Is it possible to save images in camera roll as .PNG file ? 是否可以将相机胶卷中的图像保存为.PNG文件?

As far as I understand when we are using Mediastore class all files are saving as JPEG format. 据我所知,当我们使用Mediastore类时,所有文件都保存为JPEG格式。

The problem came when downloading transparent file and saved it to camera roll which is transparent png file and in camera roll it shows black jpeg. 下载透明文件并将其保存到透明png文件的相机胶卷时出现问题,在相机胶卷中显示黑色jpeg。

I think you can do that in a second step with Bitmap.compress 我认为你可以在Bitmap.compress的第二步中做到这一点

boolean compress(Bitmap.CompressFormat format, int quality, OutputStream stream)

By passing an output stream for example a FileOutputStream: 通过传递输出流,例如FileOutputStream:

FileOutputStream out = new FileOutputStream(filename);
bmp.compress(Bitmap.CompressFormat.PNG, your_quality_from_1_to_100, out);

and then 接着

MediaStore.Images.Media.insertImage(context.getContentResolver(), absoluteFilepath, fileName, fileDescription);

For more information give a look to https://developer.android.com/reference/android/graphics/Bitmap.html 有关更多信息,请访问https://developer.android.com/reference/android/graphics/Bitmap.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM