java.lang.Object | |
↳ | android.graphics.BitmapRegionDecoder |
BitmapRegionDecoder can be used to decode a rectangle region from an image. BitmapRegionDecoder is particularly useful when an original image is large and you only need parts of the image.
To create a BitmapRegionDecoder, call newInstance(...). Given a BitmapRegionDecoder, users can call decodeRegion() repeatedly to get a decoded Bitmap of the specified region.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Decodes a rectangle region in the image specified by rect.
| |||||||||||
Returns the original image's height
| |||||||||||
Returns the original image's width
| |||||||||||
Returns true if this region decoder has been recycled.
| |||||||||||
Create a BitmapRegionDecoder from a file path.
| |||||||||||
Create a BitmapRegionDecoder from an input stream.
| |||||||||||
Create a BitmapRegionDecoder from the file descriptor.
| |||||||||||
Create a BitmapRegionDecoder from the specified byte array.
| |||||||||||
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.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Called before the object's memory is reclaimed by the VM.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Decodes a rectangle region in the image specified by rect.
rect | The rectangle that specified the region to be decode. |
---|---|
options | null-ok; Options that control downsampling. inPurgeable is not supported. |
Returns true if this region decoder has been recycled. If so, then it is an error to try use its method.
Create a BitmapRegionDecoder from a file path. Currently only the JPEG and PNG formats are supported.
pathName | complete path name for the file to be decoded. |
---|---|
isShareable | If this is true, then the BitmapRegionDecoder may keep a shallow reference to the input. If this is false, then the BitmapRegionDecoder will explicitly make a copy of the input data, and keep that. Even if sharing is allowed, the implementation may still decide to make a deep copy of the input data. If an image is progressively encoded, allowing sharing may degrade the decoding speed. |
IOException | if the image format is not supported or can not be decoded. |
---|
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.
is | The input stream that holds the raw data to be decoded into a BitmapRegionDecoder. |
---|---|
isShareable | If this is true, then the BitmapRegionDecoder may keep a shallow reference to the input. If this is false, then the BitmapRegionDecoder will explicitly make a copy of the input data, and keep that. Even if sharing is allowed, the implementation may still decide to make a deep copy of the input data. If an image is progressively encoded, allowing sharing may degrade the decoding speed. |
IOException | if the image format is not supported or can not be decoded. |
---|
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.
fd | The file descriptor containing the data to decode |
---|---|
isShareable | If this is true, then the BitmapRegionDecoder may keep a shallow reference to the input. If this is false, then the BitmapRegionDecoder will explicitly make a copy of the input data, and keep that. Even if sharing is allowed, the implementation may still decide to make a deep copy of the input data. If an image is progressively encoded, allowing sharing may degrade the decoding speed. |
IOException | if the image format is not supported or can not be decoded. |
---|
Create a BitmapRegionDecoder from the specified byte array. Currently only the JPEG and PNG formats are supported.
data | byte array of compressed image data. |
---|---|
offset | offset into data for where the decoder should begin parsing. |
length | the number of bytes, beginning at offset, to parse |
isShareable | If this is true, then the BitmapRegionDecoder may keep a shallow reference to the input. If this is false, then the BitmapRegionDecoder will explicitly make a copy of the input data, and keep that. Even if sharing is allowed, the implementation may still decide to make a deep copy of the input data. If an image is progressively encoded, allowing sharing may degrade the decoding speed. |
IOException | if the image format is not supported or can not be decoded. |
---|
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.
Called before the object's memory is reclaimed by the VM. This can only happen once the garbage collector has detected that the object is no longer reachable by any thread of the running application.
The method can be used to free system resources or perform other cleanup
before the object is garbage collected. The default implementation of the
method is empty, which is also expected by the VM, but subclasses can
override finalize()
as required. Uncaught exceptions which are
thrown during the execution of this method cause it to terminate
immediately but are otherwise ignored.
Note that the VM does guarantee that finalize()
is called at most
once for any object, but it doesn't guarantee when (if at all) finalize()
will be called. For example, object B's finalize()
can delay the execution of object A's finalize()
method and
therefore it can delay the reclamation of A's memory. To be safe, use a
ReferenceQueue
, because it provides more control
over the way the VM deals with references during garbage collection.
Throwable |
---|