Class 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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected android.graphics.Bitmap bitmapFromPayload​(android.content.Context context, com.cloudinary.android.payload.Payload payload, int width, int height)  
      android.graphics.Bitmap decode​(android.content.Context context, com.cloudinary.android.payload.Payload payload)
      Decodes a bitmap from the given payload.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 width
        height - Required height
    • Method Detail

      • 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.PayloadDecodeException
        Decodes 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 to width and height. For exact resizing combine this decoder with Limit processing step, or use ImagePreprocessChain.limitDimensionsChain(int, int).
        Specified by:
        decode in interface com.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 found
        com.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.PayloadNotFoundException
        com.cloudinary.android.preprocess.PayloadDecodeException