BitmapRegionDecoder can be used to decode a rectangle region from an image. BitmapRegionDecoder is particularly useful when an original image is large and you only need parts of the image.

To create a BitmapRegionDecoder, call newInstance(...). Given a BitmapRegionDecoder, users can call decodeRegion() repeatedly to get a decoded Bitmap of the specified region.


BitmapRegionDecoder 类可以用来从一个图片中解码矩形区域。 当你的的原图片很大并只需要图片中的一小部分时BitmapRegionDecoder 类特别有效益。

创建一个BitmapRegionDecoder类,并条用newInstance()可以得到一个BitmapRegionDecoder对象,用户可以调用decodeRegion()方法去重复获取指定区域的图片。


public Bitmap decodeRegion (Rect rect, BitmapFactory.Options options)

根据指定的矩形,编译图片中指定区域

rect 需要编译的指定矩形区域
options null-ok; Options that control downsampling. inPurgeable is not supported.
  • 返回位图,或当图片数据不能被编译时返回null;

public int getHeight ()

Returns the original image's height 返回原始图片的高

public int getWidth ()

Returns the original image's width 返回原始图片的宽

public final boolean isRecycled ()

如果编译区域已经被回收返回true。


public void recycle ()

Free up the memory associated with this region decoder, and mark the region decoder as "dead", meaning it will throw an excepion if decodeRegion(),getWidth() of getHeight() is called.

This operation cannot be reversed, so it should only be called if you are sure there are no further uses the region decoder. This is an advanced call, and normally need not be called, since the normal GC process wiill free up this memory when there are no more references to this region decoder.


释放与解码区域相关的内存,并记录该区域为“dead“,如果decodeRegion(),getWidth() 或者getHeight()被调用,将抛出异常。

这个操作是不可逆的,所以这个方法应该在你确定编码区域不会有进一步的使用时才被调用。这是一个高级调用,正常情况下不会被调用,因为当没有再使用该区域的解码器时,正常情况下GC进程将释放内存,




更多相关文章

  1. android:定制checkbox 图片
  2. android图片缩放手势检测类--ScaleGestureDetector
  3. android图片压缩方法
  4. android ListView SimpleAdapter 带图片
  5. Android之OnGestureListener实现图片的左右滑动
  6. Android之圆角矩形
  7. 图片压缩保存读取操作
  8. Android 圆角图片,基于Glide4.9 的 BitmapTransformation,可任意设
  9. 【原创】Android 4.4前后版本读取图库图片方式的变化

随机推荐

  1. Android短信会话(查看会话记录以及会话详
  2. greenhand起步之Android音乐播放器最终版
  3. Android中后台线程如何与UI线程交互
  4. 10个提高Android(安卓)App性能的建议
  5. Evenbus思想解决切换网络高级处理(高级篇
  6. Android(安卓)4.0按键事件以及系统流程分
  7. Android学习路线(十四)Activity生命周期—
  8. android 将对象存储于本地(内存)
  9. Android(安卓)系统拍照及打开系统相册 完
  10. Android(安卓)OpenCV(三十四):直线拟合