andriod.graphics.BitmapFactory类详解

Bitmap实现在android.graphics包中。但是Bitmap类的构造函数是私有的,外面并不能实例化,只能是通过JNI实例化。这必然是 某个辅助类提供了创建Bitmap的接口,而这个类的实现通过JNI接口来实例化Bitmap的,这个类就是BitmapFactory

public class

BitmapFactory

extends  Object
java.lang.Object
   ↳ android.graphics.BitmapFactory
Public Constructors
BitmapFactory()
Public Methods
static  Bitmap decodeByteArray(byte[] data, int offset, int length,  BitmapFactory.Options opts)
Decode an immutable bitmap from the specified byte array.
static  Bitmap decodeByteArray(byte[] data, int offset, int length) 从字节数组中解码出Bitmap
Decode an immutable bitmap from the specified byte array.
static  Bitmap decodeFile( String pathName) 从文件路径解码出Bitmap
Decode a file path into a bitmap.
static  Bitmap decodeFile( String pathName,  BitmapFactory.Options opts) BitmapFactory.Options为解码参数
Decode a file path into a bitmap.
static  Bitmap decodeFileDescriptor( FileDescriptor fd) 从一个文件描述符解码出Bitmap
Decode a bitmap from the file descriptor.
static  Bitmap decodeFileDescriptor( FileDescriptor fd,  Rect outPadding,  BitmapFactory.Options opts) 从一个文件描述符解码出Bitmap,以矩阵outPadding为大小,
BitmapFactory.Options为解码参数
Decode a bitmap from the file descriptor.
static  Bitmap decodeResource( Resources res, int id,  BitmapFactory.Options opts)
static  Bitmap decodeResource( Resources res, int id)
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pic180);
static  Bitmap decodeResourceStream( Resources res,  TypedValue value,  InputStream is,  Rect pad,  BitmapFactory.Options opts)
Decode a new Bitmap from an InputStream.
static  Bitmap decodeStream( InputStream is)
Decode an input stream into a bitmap.
static  Bitmap decodeStream( InputStream is,  Rect outPadding,  BitmapFactory.Options opts) 从inputStream中解码出Bitmap,以矩阵outPadding为大小,
BitmapFactory.Options为解码参数
Decode an input stream into a bitmap.

BitmapFactory.Options

public Bitmap inBitmap
public int inDensity
public boolean inDither
public boolean inInputShareable
public boolean inJustDecodeBounds  如果设置为true,并不会把图像的数据完全解码,亦即decodeXyz()返回值为null,但是Options的outAbc中解出了图像的基本信息。
public boolean inMutable
public boolean inPreferQualityOverSpeed
public Bitmap.Config inPreferredConfig    指定decode到内存中,手机中所采用的编码,可选值定义在Bitmap.Config中。缺省值是ARGB_8888。
public boolean inPurgeable
public int inSampleSize  设置decode时的缩放比例
public boolean inScaled
public int inScreenDensity
public int inTargetDensity
public byte[] inTempStorage
public boolean mCancel 
public int outHeight 指定解码出来的高度
public String outMimeType  指定解码出来的MimeType
public int outWidth  指定解码出来的宽度


2、Bitmap bitmap=bitmapDrawable.getBitmap();


二、// 转换为BitmapDrawable对象    
1、BitmapDrawable bmpDraw=new BitmapDrawable(bitmap); 
2、BitmapDrawable bitmapDrawable=new BitmapDrawable(InputStream);
3、BitmapDrawable bmpDraw=(BitmapDrawable)getResources().getDrawable(R.drawable.pic180);







  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值