docs/javadoc/com/davemorrissey/labs/subscaleview/decoder/SkiaImageRegionDecoder.html
com.davemorrissey.labs.subscaleview.decoder
All Implemented Interfaces:ImageRegionDecoder
public classSkiaImageRegionDecoderextends[Object](https://developer.android.com/reference/java/lang/Object.html?is-external=true "class or interface in java.lang")implements[ImageRegionDecoder](../../../../../com/davemorrissey/labs/subscaleview/decoder/ImageRegionDecoder.html "interface in com.davemorrissey.labs.subscaleview.decoder")
Default implementation of ImageRegionDecoder using Android's BitmapRegionDecoder, based on the Skia library. This works well in most circumstances and has reasonable performance due to the cached decoder instance, however it has some problems with grayscale, indexed and CMYK images. A ReadWriteLock is used to delegate responsibility for multi threading behaviour to the BitmapRegionDecoder instance on SDK >= 21, whilst allowing this class to block until no tiles are being loaded before recycling the decoder. In practice, BitmapRegionDecoder is synchronized internally so this has no real impact on performance.
Constructors | Constructor and Description |
| --- |
| SkiaImageRegionDecoder() |
| SkiaImageRegionDecoder(Bitmap.Config bitmapConfig) |
All Methods Instance Methods Concrete Methods | Modifier and Type | Method and Description |
| --- | --- |
| Bitmap | decodeRegion(Rect sRect, int sampleSize)
Decode a region of the image with the given sample size.
|
| Point | init(Context context, Uri uri)
Initialise the decoder.
|
| boolean | isReady()
Status check.
|
| void | recycle()
This method will be called when the decoder is no longer required.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public SkiaImageRegionDecoder()
-
public SkiaImageRegionDecoder([@Nullable](https://developer.android.com/reference/android/support.annotation.Nullable.html?is-external=true "class or interface in android")[Bitmap.Config](https://developer.android.com/reference/android/graphics/Bitmap.Config.html?is-external=true "class or interface in android.graphics")bitmapConfig)
-
[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public[Point](https://developer.android.com/reference/android/graphics/Point.html?is-external=true "class or interface in android.graphics")init([Context](https://developer.android.com/reference/android/content/Context.html?is-external=true "class or interface in android.content")context,[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")[Uri](https://developer.android.com/reference/android/net/Uri.html?is-external=true "class or interface in android.net")uri)
throws[Exception](https://developer.android.com/reference/java/lang/Exception.html?is-external=true "class or interface in java.lang")
Description copied from interface: ImageRegionDecoder
Initialise the decoder. When possible, perform initial setup work once in this method. The dimensions of the image must be returned. The URI can be in one of the following formats:
File: file:///scard/picture.jpg
Asset: file:///android_asset/picture.png
Resource: android.resource://com.example.app/drawable/picture
Specified by:init in interface ImageRegionDecoderParameters:context - Application context. A reference may be held, but must be cleared on recycle.uri - URI of the image.Returns:Dimensions of the image.Throws:Exception - if initialisation fails.
-
[@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")public[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html?is-external=true "class or interface in android.graphics")decodeRegion([@NonNull](https://developer.android.com/reference/android/support.annotation.NonNull.html?is-external=true "class or interface in android")[Rect](https://developer.android.com/reference/android/graphics/Rect.html?is-external=true "class or interface in android.graphics")sRect,
int sampleSize)
Description copied from interface: ImageRegionDecoder
Decode a region of the image with the given sample size. This method is called off the UI thread so it can safely load the image on the current thread. It is called from AsyncTasks running in an executor that may have multiple threads, so implementations must be thread safe. Adding synchronized to the method signature is the simplest way to achieve this, but bear in mind the ImageRegionDecoder.recycle() method can be called concurrently.
See SkiaImageRegionDecoder and SkiaPooledImageRegionDecoder for examples of internal locking and synchronization.
Specified by:decodeRegion in interface ImageRegionDecoderParameters:sRect - Source image rectangle to decode.sampleSize - Sample size.Returns:The decoded region. It is safe to return null if decoding fails.
-
public boolean isReady()
Description copied from interface: ImageRegionDecoder
Status check. Should return false before initialisation and after recycle.
Specified by:isReady in interface ImageRegionDecoderReturns:true if the decoder is ready to be used.
-
public void recycle()
Description copied from interface: ImageRegionDecoder
This method will be called when the decoder is no longer required. It should clean up any resources still in use.
Specified by:recycle in interface ImageRegionDecoder