BitmapFactory

1、加载网络流

HttpURLConnection connection  = (HttpURLConnection) url.openConnection(); InputStream is = connection.getInputStream();

BitmapFactory.decodeStream(is);

2、加载文件中的图片

stream = new FileInputStream(new File(path+"test.jpg"));
    BitmapFactory.Options opts = new BitmapFactory.Options(); 
    opts.inSampleSize = 8;
    Bitmap bitmap = BitmapFactory.decodeStream(stream , null, opts); 
    iv.setImageBitmap(bitmap);

 3、通过resource加载

BitmapFactory.decodeResource(getResource(),R.drawable.pic);
 

你可能感兴趣的:(bitmapfactory)