我想从网上下载一些gif格式的图片,现在已经可以得到它的Bitmap对象(bmp),要把它保存到SD卡中(file),发现有下面的方法:
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
bmp.compress(Bitmap.CompressFormat.JPEG, 80, bos);但是好像compress()方法只能保存jpg格式或者png格式,因此我想问一下,如何才能保存为gif格式呢?
谢谢!
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
bmp.compress(Bitmap.CompressFormat.JPEG, 80, bos);但是好像compress()方法只能保存jpg格式或者png格式,因此我想问一下,如何才能保存为gif格式呢?
谢谢!
解决方案 »
- 如何判断new ComponentName是否成功
- Android,桌面快捷方式toast屏蔽问题?急急急!!!!在线等!!!!
- Android 模拟器
- 哪位高手能帮我编写一下在 Android 模拟器上实现这个页面的程序呢???
- android 怎样在状态栏添加选项卡
- (急急急)进入应用,开启飞行模式然后 关闭然后在进应用就会卡39秒。
- 这里有开发android游戏的同志吗?
- 如何将PopupWindow遮住的控件点击到!然后让这个控件响应点击事件??
- 求opencv V手势分类器
- Android调试崩溃问题,求各位大哥支招
- Activity Intent.ACTION_CALL_BUTTON的关闭问题
- 有谁知道android官方开发论坛在哪?
public void getImage(String path, String saveName) throws Exception {
URL url = new URL(path);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setConnectTimeout(1000 * 6);
if (con.getResponseCode() == 200) {
InputStream inputStream = con.getInputStream();
byte[] b = getByte(inputStream);
File file = new File(saveName);
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(b);
fileOutputStream.close(); }
} private byte[] getByte(InputStream inputStream) throws Exception {
byte[] b = new byte[1024];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int len = -1;
while ((len = inputStream.read(b)) != -1) {
byteArrayOutputStream.write(b, 0, len);
}
byteArrayOutputStream.close();
inputStream.close();
return byteArrayOutputStream.toByteArray();
}