Class BitmapEncoder

java.lang.Object
com.cloudinary.android.preprocess.BitmapEncoder
All Implemented Interfaces:
com.cloudinary.android.preprocess.ResourceEncoder<android.graphics.Bitmap>

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

    • 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 Details

    • encode

      public 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 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