Android – how do I get bitmap bytes at API level 11?

There has been a useful method bitmap. Getbytecount () since API level 12, but how do you get the same value in API 11?

resolvent:

It is best to use only support libraries:

int bitmapByteCount=BitmapCompat.getAllocationByteCount(bitmap)

Or, if you want to do it yourself:

public static int getBitmapByteCount(Bitmap bitmap) {
    if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB_MR1)
        return bitmap.getRowBytes() * bitmap.getHeight();
    if (VERSION.SDK_INT < VERSION_CODES.KITKAT)
        return bitmap.getByteCount();
    return bitmap.getAllocationByteCount();
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>