MyException - 我的异常网
当前位置: 我的异常网 » 移动开发 » Bit地图Factory

Bit地图Factory

www.MyException.Cn,网友分享于:2012-06-30   浏览:5次
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);
 
软件开发程序错误异常Exception Copyright © 2009-2015 MyException 版权所有