【发布时间】:2015-10-05 00:23:36
【问题描述】:
从远程 url 保存位图图像的典型方法(基于研究)是:
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。 我知道我必须降低压缩参数才能获得更小的尺寸,但远程图像经过优化且效率更高。
有没有一种方法可以在不压缩的情况下将远程图像保存在移动存储中?
===== 回答我的问题 =====
首先我为误导性内容道歉;我想要的只是保存可能是 png|jpeg|gif|等的图像。可能我误导了你们,我试图保存的图像是 BMP 格式,但事实并非如此。
不过,对于那些想要保存图像而不压缩的人,看看这个answer
【问题讨论】: