com.davemorrissey.labs.subscaleview.decoder

## Interface ImageRegionDecoder

All Known Implementing Classes:
  SkiaImageRegionDecoder, SkiaPooledImageRegionDecoder

    public interface ImageRegionDecoder

Interface for image decoding classes, allowing the default `BitmapRegionDecoder` based on the Skia library to be replaced with a custom class.

### Method Summary

All Methods Instance Methods Abstract Methods
`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.

### Method Detail

#### init

    @NonNull
    Point init(Context context,
                        @NonNull
                        Uri uri)
                 throws Exception

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`

Parameters:
  `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.

#### decodeRegion

    @NonNull
    Bitmap decodeRegion(@NonNull
                                 Rect sRect,
                                 int sampleSize)

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 `AsyncTask`s 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 `recycle()` method can be called concurrently.

See `SkiaImageRegionDecoder` and `SkiaPooledImageRegionDecoder` for examples of internal locking and synchronization.

Parameters:
  `sRect` - Source image rectangle to decode.
  `sampleSize` - Sample size.
Returns:
  The decoded region. It is safe to return null if decoding fails.

#### isReady

    boolean isReady()

Status check. Should return false before initialisation and after recycle.

Returns:
  true if the decoder is ready to be used.

#### recycle

    void recycle()

This method will be called when the decoder is no longer required. It should clean up any resources still in use.