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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreate 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 TypeMethodDescriptionencode(android.content.Context context, android.graphics.Bitmap resource) Encodes the given bitmap to a file using the supplied format and quality settings.protected final 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 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:
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 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
-