android studio for android learning (二十四 )bitmap and bitmapFactory
来源:互联网 发布:淘宝客机器人软件下载 编辑:程序博客网 时间:2024/06/06 11:48
1.Bitmap实现在android.graphics包中。但是Bitmap类的构造函数是私有的,外面并不能实例化,只能是通过JNI实例化。这必然是 某个辅助类提供了创建Bitmap的接口,而这个类的实现通过JNI接口来实例化Bitmap的,这个类就是BitmapFactory。
2.
a. 比如SD卡中的图片可以使用decodeFile方法,
b. 网络上的图片可以使用decodeStream方法,
c. 资源文件中的图片可以使用decodeResource方法.
除此之外,还有些不是很常见的方法,decodeByteArray(byte[] data, int offset, int length)从指定的字节数组里开始将长度为length的字节数据解析成bitmap对象。decodeFileDescriptor(FileDescriptor fd),用于从FileDescriptor对应的文件中解析创建bitmap对象。
3.注意:这些方法会尝试为已经构建的bitmap分配内存,这时就会很容易导致OOM(Out of Memory)出现。为此每一种解析方法都提供了一个可选的BitmapFactory.Options参数,将这个参数的inJustDecodeBounds属性设置为true就可以让解析方法禁止为bitmap分配内存,返回值也不再是一个Bitmap对象,而是null。
0 0
- android studio for android learning (二十四 )bitmap and bitmapFactory
- 初学Android,图形图像之使用Bitmap和BitmapFactory(二十四)
- 初学Android,图形图像之使用Bitmap和BitmapFactory(二十四)
- (转)初学Android,图形图像之使用Bitmap和BitmapFactory(二十四)
- android studio for android learning (二)
- android studio for android learning (二十八) android基础知识
- android studio for android learning (十四) android的数据的存储sharedPreferences
- android BitmapFactory的OutOfMemoryError: bitmap ...
- Android图片之Bitmap、BitmapFactory
- android studio for android learning (一)
- android studio for android learning (四) 兼容性问题
- android下载网络图片,BitmapFactory创建bitmap
- Android graphics学习笔记(4) - Bitmap&BitmapFactory
- Android图形图像处理之Bitmap和BitmapFactory
- android BitmapFactory.Options 优化bitmap图像
- android graphics--AvoidXfermode/Bitmap/BitmapFactory译
- Android绘图-Paint、Canvas、Bitmap、BitmapFactory
- Android入门——Bitmap和BitmapFactory
- 代理模式
- Lucas定理C递归实现
- C++中的static关键字的总结
- static与final关键字
- php 设计模式
- android studio for android learning (二十四 )bitmap and bitmapFactory
- immutable.js
- springMVC
- 类和对象(三角形)
- scrollView常用属性
- mybatis简介
- 视频录制
- OSPF协议
- 坚持#第8天~此生遇你 死亦足矣