这个类比较简单、通过不同来源创建位图 差不多11个方法,
- decodeByteArray(byte[] data, int offset, int length,BitmapFactory.Options opts)
从一个data字节数组中解析图片,从offset下标开始, - decodeByteArray(byte[] data, int offset, int length)
同上,无opts参数 decodeFile(String pathName)
从一个pathName路径解析图片decodeFile(String pathName, BitmapFactory.Options opts)
同上,包含optsdecodeFileDescriptor(FileDescriptor fd)
- decodeFileDescriptor(FileDescriptor fd, Rect outPadding,BitmapFactory.Options opts)
decodeResource(Resources res, int id, BitmapFactory.Options opts)
从android资源文件夹解析图片decodeResource(Resources res, int id)
同上,不包含opts参数decodeResourceStream(Resources res, TypedValue value, InputStream is,
Rect pad, BitmapFactory.Options opts)decodeStream(InputStream is)
从is流中解析图片decodeStream(InputStream is, Rect outPadding, BitmapFactory.Options opts)
同上
如上生成位图的方法decodeResource..(…)这种不建议使用,因为种方生成位图时会在java层做一些操作,这样内存消耗更多,而decodeFile(。。。)方法直接操作底层内存消耗更少,防止OOM这个是非常关键的一步。使用时注意查看源码非常清楚二者的使用区别