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 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 classBitmapEncoder.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
Modifier and Type Method Description java.lang.Stringencode(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.StringsaveFile(android.content.Context context, android.graphics.Bitmap resource, int quality, BitmapEncoder.Format format)
-
Constructor Details
-
BitmapEncoder
public BitmapEncoder()Create a new bitmap encoder with the default specifications. -
BitmapEncoder
Create a new bitmap encoder with the given specifications.- Parameters:
format- The format to encode the bitmapquality- The quality to use when encoding the bitmap
-
-
Method Details
-
encode
public java.lang.String encode(android.content.Context context, android.graphics.Bitmap resource) throws com.cloudinary.android.preprocess.ResourceCreationExceptionEncodes 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:
encodein interfacecom.cloudinary.android.preprocess.ResourceEncoder<android.graphics.Bitmap>- Parameters:
context- Android contextresource- 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
-