public class BitmapEncoder extends Object implements ResourceEncoder<Bitmap>
ResourceEncoder that writes Bitmaps to
OutputStreams.
Bitmaps that return true from Bitmap.hasAlpha()} are written
using Bitmap.CompressFormat.PNG to preserve alpha and all other bitmaps are written
using Bitmap.CompressFormat.JPEG.
| Constructor and Description |
|---|
BitmapEncoder() |
BitmapEncoder(Bitmap.CompressFormat compressFormat,
int quality) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
encode(Resource<Bitmap> resource,
OutputStream os)
Writes the given data to the given output stream and returns True if the write completed successfully and
should be committed.
|
String |
getId()
Returns an ID identifying any transformation this encoder may apply to the given data that will be mixed in to
the cache key.
|
public BitmapEncoder()
public BitmapEncoder(Bitmap.CompressFormat compressFormat, int quality)
public boolean encode(Resource<Bitmap> resource, OutputStream os)
Encoderpublic String getId()
EncoderIf the encoder does not transform the data in a way that significantly affects the cached result (ie performs no unusual compression or downsampling) an empty string is an appropriate id.