android - BitmapRegionDecoder 翻译



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 需要编译的指定矩形区域
optionsnull-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进程将释放内存,




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值