Class SkiaImageRegionDecoder
-
- All Implemented Interfaces:
-
ai.nexconn.chatui.picture.widget.longimage.ImageRegionDecoder
public class SkiaImageRegionDecoder implements ImageRegionDecoder
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.
-
-
Constructor Summary
Constructors Constructor Description SkiaImageRegionDecoder()
-
Method Summary
Modifier and Type Method Description Pointinit(Context context, Uri uri)Initialise the decoder. BitmapdecodeRegion(Rect sRect, int sampleSize)Decode a region of the image with the given sample size. booleanisReady()Status check. voidrecycle()This method will be called when the decoder is no longer required. -
-
Method Detail
-
init
Point init(Context context, Uri uri)
Initialise the decoder. When possible, initial setup work once in this method. This method must return the dimensions of the image. 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.uri- URI of the image.- Returns:
Dimensions of the image.
-
decodeRegion
Bitmap decodeRegion(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 an running in a single threaded executor, and while a synchronization lock is held on this object, so will never be called concurrently even if the decoder implementation supports it.
- 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.
-
-
-
-