-
- All Implemented Interfaces:
-
com.mobwith.imgmodule.load.ResourceDecoder
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP) public final class ParcelFileDescriptorBitmapDecoder implements ResourceDecoder<ParcelFileDescriptor, Bitmap>
Decodes Bitmaps from ParcelFileDescriptors.
-
-
Constructor Summary
Constructors Constructor Description ParcelFileDescriptorBitmapDecoder(Downsampler downsampler)
-
Method Summary
Modifier and Type Method Description booleanhandles(@NonNull() ParcelFileDescriptor source, @NonNull() Options options)Returns {@code true}if this decoder is capable of decoding the given source with the givenoptions, and{@code false}otherwise.Resource<Bitmap>decode(@NonNull() ParcelFileDescriptor source, int width, int height, @NonNull() Options options)Returns a decoded resource from the given data or null if no resource could be decoded. -
-
Constructor Detail
-
ParcelFileDescriptorBitmapDecoder
ParcelFileDescriptorBitmapDecoder(Downsampler downsampler)
-
-
Method Detail
-
handles
boolean handles(@NonNull() ParcelFileDescriptor source, @NonNull() Options options)
Returns
{@code true}if this decoder is capable of decoding the given source with the givenoptions, and{@code false}otherwise.Decoders should make a best effort attempt to quickly determine if they are likely to beable to decode data, but should not attempt to completely read the given data. A typicalimplementation would check the file headers verify they match content the decoder expects tohandle (i.e. a GIF decoder should verify that the image contains the GIF header block.
Decoders that return
{@code true}from{@code handles}may still return{@code null}from decode if the data is partial or formatted incorrectly.
-
decode
@Nullable() Resource<Bitmap> decode(@NonNull() ParcelFileDescriptor source, int width, int height, @NonNull() Options options)
Returns a decoded resource from the given data or null if no resource could be decoded.
The
{@code source}is managed by the caller, there's no need to close it. The returned Resource will be released when the engine sees fit.Note - The
{@code width}and{@code height}arguments are hints only, there is norequirement that the decoded resource exactly match the given dimensions. A typical use casewould be to use the target dimensions to determine how much to downsample Bitmaps by to avoidoverly large allocations.- Parameters:
source- The data the resource should be decoded from.width- The ideal width in pixels of the decoded resource, or to indicate the original resourcewidth.height- The ideal height in pixels of the decoded resource, or to indicate the original resourceheight.options- A map of string keys to objects that may or may not contain options available tothis particular implementation.
-
-
-
-