1 package com.bumptech.glide.load.resource.bitmap;
2 
3 import android.graphics.Bitmap;
4 
5 import com.bumptech.glide.load.DecodeFormat;
6 import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
7 
8 /**
9  * A bitmap decoder for a given resource type.
10  *
11  * @param <T> The type of resource this decoder can decode a {@link Bitmap} from.
12  */
13 public interface BitmapDecoder<T> {
14     /**
15      * Returns a decoded bitmap for a given resource and target dimensions.
16      *
17      * @param resource The resource to decode, managed by the caller, no need to clean it up.
18      * @param bitmapPool A bitmap pool that can be used to reuse bitmaps during the load. Any bitmaps created or
19      *                   obtained from the pool other than the bitmap returned by this method should be returned to the
20      *                   pool.
21      * @param outWidth The target width for the returned bitmap (need not match exactly).
22      * @param outHeight The target height for the returned bitmap (need not match exactly).
23      * @param decodeFormat The desired configuration for the returned bitmap.
24      */
decode(T resource, BitmapPool bitmapPool, int outWidth, int outHeight, DecodeFormat decodeFormat)25     Bitmap decode(T resource, BitmapPool bitmapPool, int outWidth, int outHeight, DecodeFormat decodeFormat)
26             throws Exception;
27 
28     /**
29      * Returns some unique String id that distinguishes this decoder from any other decoder.
30      *
31      * <p>
32      *     This method can return the empty string if for all practical purposes it applies no transformations to the
33      *     data while loading the resource. For {@link android.graphics.Bitmap}s this would mean at a minimum doing no
34      *     downsampling and also probably always producing {@link android.graphics.Bitmap}s with
35      *     {@link android.graphics.Bitmap.Config#ARGB_8888} as their config.
36      * </p>
37      */
getId()38     String getId();
39 }
40