FileDocCategorySizeDatePackage
LargeBitmap.javaAPI DocAndroid 5.1 API4321Thu Mar 12 22:22:30 GMT 2015android.graphics

LargeBitmap

public final class LargeBitmap extends Object
LargeBitmap can be used to decode a rectangle region from an image. LargeBimap is particularly useful when an original image is large and you only need parts of the image. To create a LargeBitmap, call BitmapFactory.createLargeBitmap(). Given a LargeBitmap, users can call decodeRegion() repeatedly to get a decoded Bitmap of the specified region.
hide

Fields Summary
private long
mNativeLargeBitmap
private boolean
mRecycled
Constructors Summary
private LargeBitmap(long nativeLbm)

        mNativeLargeBitmap = nativeLbm;
        mRecycled = false;
    
Methods Summary
private voidcheckRecycled(java.lang.String errorMessage)
Called by methods that want to throw an exception if the bitmap has already been recycled.

        if (mRecycled) {
            throw new IllegalStateException(errorMessage);
        }
    
public BitmapdecodeRegion(Rect rect, BitmapFactory.Options options)
Decodes a rectangle region in the image specified by rect.

param
rect The rectangle that specified the region to be decode.
param
opts null-ok; Options that control downsampling. inPurgeable is not supported.
return
The decoded bitmap, or null if the image data could not be decoded.

        checkRecycled("decodeRegion called on recycled large bitmap");
        if (rect.left < 0 || rect.top < 0 || rect.right > getWidth() || rect.bottom > getHeight())
            throw new IllegalArgumentException("rectangle is not inside the image");
        return nativeDecodeRegion(mNativeLargeBitmap, rect.left, rect.top,
                rect.right - rect.left, rect.bottom - rect.top, options);
    
protected voidfinalize()

        recycle();
    
public intgetHeight()
Returns the original image's height

        checkRecycled("getHeight called on recycled large bitmap");
        return nativeGetHeight(mNativeLargeBitmap);
    
public intgetWidth()
Returns the original image's width

        checkRecycled("getWidth called on recycled large bitmap");
        return nativeGetWidth(mNativeLargeBitmap);
    
public final booleanisRecycled()
Returns true if this large bitmap has been recycled. If so, then it is an error to try use its method.

return
true if the large bitmap has been recycled

        return mRecycled;
    
private static native voidnativeClean(long nativeLbm)

private static native BitmapnativeDecodeRegion(long nativeLbm, int start_x, int start_y, int width, int height, BitmapFactory.Options options)

private static native intnativeGetHeight(long nativeLbm)

private static native intnativeGetWidth(long nativeLbm)

public voidrecycle()
Frees up the memory associated with this large bitmap, and mark the large bitmap as "dead", meaning it will throw an exception if decodeRegion(), getWidth() or getHeight() is called. This operation cannot be reversed, so it should only be called if you are sure there are no further uses for the large bitmap. This is an advanced call, and normally need not be called, since the normal GC process will free up this memory when there are no more references to this bitmap.

        if (!mRecycled) {
            nativeClean(mNativeLargeBitmap);
            mRecycled = true;
        }