4

当我从互联网下载图像并保存到 sdcard 时,当原始图像没有时,图像具有黑色背景

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();

谢谢您的帮助!!

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

改变:

文件 file = new File(dir, tipoImagen+idEquipo+" .png ");

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

>>>>>>>>>>>>>>>>>>>>>>谢谢!<<<<<<<<<<<<<<<<<>>>>>

4

1 回答 1

3

改变:

文件 file = new File(dir, tipoImagen+idEquipo+".png");

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

于 2012-10-12T02:00:08.730 回答