public class BitmapEncoder extends Object implements ResourceEncoder<Bitmap>
ResourceEncoder
that writes Bitmap
s
to OutputStream
s.
Bitmap
s that return true from
()
} are written using
Bitmap.CompressFormat.PNG
to preserve alpha and all other bitmaps are written using
Bitmap.CompressFormat.JPEG
.
Modifier and Type | Field and Description |
---|---|
static Option<Bitmap.CompressFormat> |
COMPRESSION_FORMAT
An
Bitmap.CompressFormat option used as the format to encode
the Bitmap . |
static Option<Integer> |
COMPRESSION_QUALITY
An integer option between 0 and 100 that is used as the compression quality.
|
Constructor and Description |
---|
BitmapEncoder()
Deprecated.
Use
BitmapEncoder(ArrayPool) instead. |
BitmapEncoder(ArrayPool arrayPool) |
Modifier and Type | Method and Description |
---|---|
boolean |
encode(Resource<Bitmap> resource,
File file,
Options options)
Writes the given data to the given output stream and returns True if the write completed
successfully and should be committed.
|
EncodeStrategy |
getEncodeStrategy(Options options) |
public static final Option<Integer> COMPRESSION_QUALITY
Defaults to 90.
public static final Option<Bitmap.CompressFormat> COMPRESSION_FORMAT
Bitmap.CompressFormat
option used as the format to encode
the Bitmap
.
Defaults to Bitmap.CompressFormat.JPEG
for images without alpha
and Bitmap.CompressFormat.PNG
for images with alpha.
@Deprecated public BitmapEncoder()
BitmapEncoder(ArrayPool)
instead.public boolean encode(@NonNull Resource<Bitmap> resource, @NonNull File file, @NonNull Options options)
Encoder
@NonNull public EncodeStrategy getEncodeStrategy(@NonNull Options options)
getEncodeStrategy
in interface ResourceEncoder<Bitmap>