Android中BitmapFactory.Options学习
来源:互联网 发布:白金数据 原著 编辑:程序博客网 时间:2024/05/01 16:08
首先BitmapFactory的作用是:Creates Bitmap objects from various sources, including files, streams, and byte-arrays。
BitmapFactory.Options用于解码Bitmap时对各种参数的控制,详细参数介绍如下:
1)inJustDecodeBounds
如果将这个值置为true,那么在解码的时候将不会返回bitmap,只会返回这个bitmap的尺寸。这个属性的目的是,如果你只想知道一个bitmap的尺寸,但又不想将其加载到内存时。这是一个非常有用的属性。
这个值是一个int,当它小于1的时候,将会被当做1处理,如果大于1,那么就会按照比例(1 / inSampleSize)缩小bitmap的宽和高、
降低分辨率,大于1时这个值将会被处置为2的倍数。
例如,width=100,height=100,inSampleSize=2,那么就会将bitmap处理为,width=50,height=50,宽高降为1 / 2,像素数降为1 / 4。
3)inDither:
这个值和抖动解码有关,默认值为false,表示不采用抖动解码。
表示这个bitmap的像素密度(对应的是DisplayMetrics中的densityDpi,不是density)。
请参看我另一篇文章:http://blog.csdn.net/haozipi/article/details/47185535
4)inTargetDensity:
表示要被画出来时的目标像素密度(对应的是DisplayMetrics中的densityDpi,不是density)。
5)inScreenDensity:
表示实际设备的像素密度(对应的是DisplayMetrics中的densityDpi,不是density)。
6)inScaled:
设置这个Bitmap是否可以被缩放,默认值是true,表示可以被缩放。
ps:inDensity,inTargetDensity,inScreenDensity三个值的具体关系请参看我的另一篇文章:http://blog.csdn.net/haozipi/article/details/47185917
7)inPurgeable和inInputShareable:
这两个值一般是一起使用,设置为true时,前者表示空间不够是否可以被释放,后者表示是否可以共享引用。这两个值在Android5.0后被弃用。
8)inPreferQualityOverSpeed:
这个值表示是否在解码时图片有更高的品质,仅用于JPEG格式。如果设置为true,则图片会有更高的品质,但是会解码速度会很慢。
9)outWidth和outHeight:
表示这个Bitmap的宽和高,一般和inJustDecodeBounds一起使用来获得Bitmap的宽高,但是不加载到内存。
- Android中BitmapFactory.Options学习
- Android中BitmapFactory.Options详解
- Android中BitmapFactory.Options详解
- Android中BitmapFactory.Options详解
- Android中BitmapFactory.Options详解
- Android中BitmapFactory.Options详解
- Android中BitmapFactory.Options详解
- Android中BitmapFactory.Options详解
- android BitmapFactory.Options
- android BitmapFactory.Options
- android BitmapFactory.Options
- android BitmapFactory.Options
- android BitmapFactory.Options
- Android:BitmapFactory.Options
- Android Bitmapfactory.Options
- Android中自定义布局中加载图片BitmapFactory.options详解
- android BitmapFactory.Options(总结网络中出现的一些)
- Android——Bitmapfactory.options
- math.h 三角函数
- 理解java web项目中的路径问题
- 处理:/var/redis/run/redis_6379.pid exists, process is already running or crashed
- POJ1083 Moving Tables
- A1078. 逆序对个数
- Android中BitmapFactory.Options学习
- 1.21
- Android下拉刷新与轮播图冲突解决方案
- Android 弹性ScrollView
- 简易电子钟
- 六、浅记java面向对象
- 通信协议——Http、TCP、UDP
- 你一定没见过这么有意思的电路板
- hdu 1828 Picture 线段树+扫描线