【问题标题】:Any alternative way to achieve BitmapRegionDecoder.decodeRegion(...) android 2.2 and below?实现 BitmapRegionDecoder.decodeRegion(...) android 2.2 及以下版本的任何替代方法?
【发布时间】:2012-08-29 20:34:22
【问题描述】:

我正在使用 BitmapRegionDecoder.decodeRegion(...) 来裁剪图像。但它不适用于 android 2.3.1 (api level 10 ) 及更低版本。请让我知道是否有任何替代方法可以实现这一目标。甚至 android-support-v4.jar 库也不包含这个类。

【问题讨论】:

标签: android bitmap crop region decoder


【解决方案1】:

您可以使用Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height) 裁剪图像。它一直存在,因此为旧 API 提供了替代方案。

文档非常不言自明:

从源的指定子集中返回不可变位图 位图。新的位图可能与源是同一个对象,也可能是一个副本 已经做出来了。它被初始化为与 原始位图。

参数

source    The bitmap we are subsetting
x         The x coordinate of the first pixel in source
y         The y coordinate of the first pixel in source
width     The number of pixels in each row
height    The number of rows

返回源位图或源位图子集的副本 自己。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多