Class BitmapDecoder
java.lang.Object
com.cloudinary.android.preprocess.BitmapDecoder
- All Implemented Interfaces:
com.cloudinary.android.preprocess.ResourceDecoder<android.graphics.Bitmap>
public class BitmapDecoder
extends java.lang.Object
implements com.cloudinary.android.preprocess.ResourceDecoder<android.graphics.Bitmap>
Decodes a bitmap from a payload. If given width and height the decoding process will take them
into account to decode the bitmap efficiently but will not necessarily resize the bitmap.
-
Constructor Summary
Constructors Constructor Description BitmapDecoder()Create a new decoder.BitmapDecoder(int width, int height)Create a new decoder taking the required width and height into account to decode the bitmap efficiently. -
Method Summary
Modifier and Type Method Description protected android.graphics.BitmapbitmapFromPayload(android.content.Context context, com.cloudinary.android.payload.Payload payload, int width, int height)android.graphics.Bitmapdecode(android.content.Context context, com.cloudinary.android.payload.Payload payload)Decodes a bitmap from the given payload.
-
Constructor Details
-
BitmapDecoder
public BitmapDecoder()Create a new decoder. -
BitmapDecoder
public BitmapDecoder(int width, int height)Create a new decoder taking the required width and height into account to decode the bitmap efficiently.- Parameters:
width- Required widthheight- Required height
-
-
Method Details
-
decode
public android.graphics.Bitmap decode(android.content.Context context, com.cloudinary.android.payload.Payload payload) throws com.cloudinary.android.payload.PayloadNotFoundException, com.cloudinary.android.preprocess.PayloadDecodeExceptionDecodes a bitmap from the given payload. If the bitmap is at least two times larger than the required dimensions it will decode a version scaled down by a factor. Note: The dimensions of the decoded bitmap will not necessarily be equal towidthandheight. For exact resizing combine this decoder withLimitprocessing step, or useImagePreprocessChain.limitDimensionsChain(int, int).- Specified by:
decodein interfacecom.cloudinary.android.preprocess.ResourceDecoder<android.graphics.Bitmap>- Parameters:
context- Android context.payload- Payload to extract the bitmap from- Returns:
- The decoded bitmap
- Throws:
com.cloudinary.android.payload.PayloadNotFoundException- if the payload is not foundcom.cloudinary.android.preprocess.PayloadDecodeException- if the payload exists but cannot be decoded
-
bitmapFromPayload
protected final android.graphics.Bitmap bitmapFromPayload(android.content.Context context, com.cloudinary.android.payload.Payload payload, int width, int height) throws com.cloudinary.android.payload.PayloadNotFoundException, com.cloudinary.android.preprocess.PayloadDecodeException- Throws:
com.cloudinary.android.payload.PayloadNotFoundExceptioncom.cloudinary.android.preprocess.PayloadDecodeException
-