Class BitmapEncoder

  • All Implemented Interfaces:
    com.cloudinary.android.preprocess.ResourceEncoder<android.graphics.Bitmap>

    public class BitmapEncoder
    extends java.lang.Object
    implements com.cloudinary.android.preprocess.ResourceEncoder<android.graphics.Bitmap>
    Encodes the bitmap to a file. Allows configuration of quality and format.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  BitmapEncoder.Format  
    • Constructor Summary

      Constructors 
      Constructor Description
      BitmapEncoder()
      Create a new bitmap encoder with the default specifications.
      BitmapEncoder​(BitmapEncoder.Format format, int quality)
      Create a new bitmap encoder with the given specifications.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String encode​(android.content.Context context, android.graphics.Bitmap resource)
      Encodes the given bitmap to a file using the supplied format and quality settings.
      protected java.lang.String saveFile​(android.content.Context context, android.graphics.Bitmap resource, int quality, BitmapEncoder.Format format)  
      • Methods inherited from class java.lang.Object

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

      • BitmapEncoder

        public BitmapEncoder()
        Create a new bitmap encoder with the default specifications.
      • BitmapEncoder

        public BitmapEncoder​(BitmapEncoder.Format format,
                             int quality)
        Create a new bitmap encoder with the given specifications.
        Parameters:
        format - The format to encode the bitmap
        quality - The quality to use when encoding the bitmap
    • Method Detail

      • encode

        public java.lang.String encode​(android.content.Context context,
                                       android.graphics.Bitmap resource)
                                throws com.cloudinary.android.preprocess.ResourceCreationException
        Encodes the given bitmap to a file using the supplied format and quality settings. If no configuration is supplied, default settings will be used.
        Specified by:
        encode in interface com.cloudinary.android.preprocess.ResourceEncoder<android.graphics.Bitmap>
        Parameters:
        context - Android context
        resource - The resource (after processing) to save to file.
        Returns:
        Throws:
        com.cloudinary.android.preprocess.ResourceCreationException - if the resource cannot be saved to a file
      • saveFile

        protected final java.lang.String saveFile​(android.content.Context context,
                                                  android.graphics.Bitmap resource,
                                                  int quality,
                                                  BitmapEncoder.Format format)
                                           throws com.cloudinary.android.preprocess.ResourceCreationException
        Throws:
        com.cloudinary.android.preprocess.ResourceCreationException