我正在使用BitmapRegionDecoder.decodeRegion(…)来裁剪图像。但它不适用于android 2.3.1(api级别10)及以下版本。请告诉我有没有其他方法可以实现这一点。即使是android-support-v4.jar库也不包含此类。
您可以使用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
返回源位图或源位图的子集的副本它本身