Methods Summary |
---|
private void | checkRecycled(java.lang.String errorMessage)Called by methods that want to throw an exception if the region decoder
has already been recycled.
if (mRecycled) {
throw new IllegalStateException(errorMessage);
}
|
public Bitmap | decodeRegion(Rect rect, BitmapFactory.Options options)Decodes a rectangle region in the image specified by rect.
synchronized (mNativeLock) {
checkRecycled("decodeRegion called on recycled region decoder");
if (rect.right <= 0 || rect.bottom <= 0 || rect.left >= getWidth()
|| rect.top >= getHeight())
throw new IllegalArgumentException("rectangle is outside the image");
return nativeDecodeRegion(mNativeBitmapRegionDecoder, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top, options);
}
|
protected void | finalize()
try {
recycle();
} finally {
super.finalize();
}
|
public int | getHeight()Returns the original image's height
synchronized (mNativeLock) {
checkRecycled("getHeight called on recycled region decoder");
return nativeGetHeight(mNativeBitmapRegionDecoder);
}
|
public int | getWidth()Returns the original image's width
synchronized (mNativeLock) {
checkRecycled("getWidth called on recycled region decoder");
return nativeGetWidth(mNativeBitmapRegionDecoder);
}
|
public final boolean | isRecycled()Returns true if this region decoder has been recycled.
If so, then it is an error to try use its method.
return mRecycled;
|
private static native void | nativeClean(long lbm)
|
private static native Bitmap | nativeDecodeRegion(long lbm, int start_x, int start_y, int width, int height, BitmapFactory.Options options)
|
private static native int | nativeGetHeight(long lbm)
|
private static native int | nativeGetWidth(long lbm)
|
private static native android.graphics.BitmapRegionDecoder | nativeNewInstance(byte[] data, int offset, int length, boolean isShareable)
|
private static native android.graphics.BitmapRegionDecoder | nativeNewInstance(java.io.FileDescriptor fd, boolean isShareable)
|
private static native android.graphics.BitmapRegionDecoder | nativeNewInstance(java.io.InputStream is, byte[] storage, boolean isShareable)
|
private static native android.graphics.BitmapRegionDecoder | nativeNewInstance(long asset, boolean isShareable)
|
public static android.graphics.BitmapRegionDecoder | newInstance(byte[] data, int offset, int length, boolean isShareable)Create a BitmapRegionDecoder from the specified byte array.
Currently only the JPEG and PNG formats are supported.
if ((offset | length) < 0 || data.length < offset + length) {
throw new ArrayIndexOutOfBoundsException();
}
return nativeNewInstance(data, offset, length, isShareable);
|
public static android.graphics.BitmapRegionDecoder | newInstance(java.io.FileDescriptor fd, boolean isShareable)Create a BitmapRegionDecoder from the file descriptor.
The position within the descriptor will not be changed when
this returns, so the descriptor can be used again as is.
Currently only the JPEG and PNG formats are supported.
return nativeNewInstance(fd, isShareable);
|
public static android.graphics.BitmapRegionDecoder | newInstance(java.io.InputStream is, boolean isShareable)Create a BitmapRegionDecoder from an input stream.
The stream's position will be where ever it was after the encoded data
was read.
Currently only the JPEG and PNG formats are supported.
if (is instanceof AssetManager.AssetInputStream) {
return nativeNewInstance(
((AssetManager.AssetInputStream) is).getNativeAsset(),
isShareable);
} else {
// pass some temp storage down to the native code. 1024 is made up,
// but should be large enough to avoid too many small calls back
// into is.read(...).
byte [] tempStorage = new byte[16 * 1024];
return nativeNewInstance(is, tempStorage, isShareable);
}
|
public static android.graphics.BitmapRegionDecoder | newInstance(java.lang.String pathName, boolean isShareable)Create a BitmapRegionDecoder from a file path.
Currently only the JPEG and PNG formats are supported.
BitmapRegionDecoder decoder = null;
InputStream stream = null;
try {
stream = new FileInputStream(pathName);
decoder = newInstance(stream, isShareable);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
// do nothing here
}
}
}
return decoder;
|
public void | recycle()Frees up the memory associated with this region decoder, and mark the
region decoder 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 region decoder. 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 region decoder.
synchronized (mNativeLock) {
if (!mRecycled) {
nativeClean(mNativeBitmapRegionDecoder);
mRecycled = true;
}
}
|