从互联网下载图像损失透明度

时间:2012-10-12 01:09:02

标签: android

当我从互联网上下载图像并保存到SD卡时,当原始图像没有

时,图像会出现黑色背景
httpRequest = new HttpGet(fileUrl);
 HttpClient httpclient = new DefaultHttpClient();
 HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
 HttpEntity entity = response.getEntity();
 BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
 InputStream instream = bufHttpEntity.getContent();
 Bitmap    bm = BitmapFactory.decodeStream(instream);
 String file_path = Environment.getExternalStorageDirectory()+File.separator+"basquetMobile-  images";
 File dir = new File(file_path);     
 if(!dir.exists())
        dir.mkdirs();
 File file = new File(dir, tipoImagen+idEquipo+".jpg");
 FileOutputStream fOut = new FileOutputStream(file);
 bm.compress(Bitmap.CompressFormat.JPEG, 75, fOut);
 fOut.flush();
 fOut.close();

感谢您的帮助!!

>>>>>>>>>>>>>>>>>>>>>> [解决方案]<<<<<<<<<<<<<<<<<>>>>>

变化:

档案文件=新档案(dir,tipoImagen + idEquipo +“ .png ”);

bm.compress(Bitmap.CompressFormat.PNG,100,fOut);

>>>>>>>>>>>>>>>>>>>>>>感谢和LT;!<<<<<<<<<<<<<<<<>>>>>

1 个答案:

答案 0 :(得分:3)

变化:

文件档案=新档案(dir,tipoImagen + idEquipo +“。png”);

bm.compress(Bitmap.CompressFormat.PNG,100,fOut);