Android-在不压缩的情况下将位图图像保存在移动存储中 [英] Android - Save Bitmap Image on Mobile Storage without Compressing
问题描述
(基于研究)从远程URL保存位图图像的典型方式是:
The typical way (based on research) for saving bitmap images from a remote url is:
Bitmap bmImage = null;
InputStream in = new java.net.URL(imageUrl).openStream();
bmImage = BitmapFactory.decodeStream(in);
File file = new File(myPath);
FileOutputStream outputStream;
outputStream = new FileOutputStream(file);
bmImage.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
outputStream.close();
除非将位图压缩,否则无法保存(位图始终未压缩). 远程映像大小为32KB,压缩后为110KB. 我知道我必须降低压缩参数才能减小尺寸,但是远程图像是经过优化的并且效率更高.
I cannot save bitmap unless it is compressed (Bitmap is always uncompressed). The remote image size is 32KB, after compression it gets 110KB. I know I have to lower compression parameter to get smaller size, but the remote image is optimize and much more efficient.
有没有一种方法可以将远程映像保存到移动存储中而不进行压缩?
Is there a way I can save the remote image on mobile storage without compressing it?
===== 回答我的问题 =====
===== ANSWER TO MY PROBLEM =====
首先,我对误导性内容深表歉意;我只想保存可能是png | jpeg | gif |等的图像.可能我误导了你们我要保存的图像是BMP格式,但是不是.
First I apologize for misleading content; all I wanted is to save images that could be png|jpeg|gif|etc.. Probably I mislead you guys that the image I am trying to save is in BMP format, but it is not.
尽管如此,对于那些想在不进行压缩的情况下保存图像的人,请查看此 answer
Nevertheless, for those who want to save images WITHOUT compressing, have a look to this answer
推荐答案
Use AndroidBmpUtil as shown in the code below:
new AndroidBmpUtil().save(bmImage, file);
这篇关于Android-在不压缩的情况下将位图图像保存在移动存储中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!