Class BitmapEncoder
- java.lang.Object
-
- com.bumptech.glide.load.resource.bitmap.BitmapEncoder
-
- All Implemented Interfaces:
Encoder<Resource<android.graphics.Bitmap>>,ResourceEncoder<android.graphics.Bitmap>
public class BitmapEncoder extends java.lang.Object implements ResourceEncoder<android.graphics.Bitmap>
AnResourceEncoderthat writesBitmaps toOutputStreams.Bitmaps that return true from()} are written usingBitmap.CompressFormat.PNGto preserve alpha and all other bitmaps are written usingBitmap.CompressFormat.JPEG.- See Also:
Bitmap.compress(android.graphics.Bitmap.CompressFormat, int, java.io.OutputStream)
-
-
Field Summary
Fields Modifier and Type Field Description static Option<android.graphics.Bitmap.CompressFormat>COMPRESSION_FORMATAnBitmap.CompressFormatoption used as the format to encode theBitmap.static Option<java.lang.Integer>COMPRESSION_QUALITYAn integer option between 0 and 100 that is used as the compression quality.
-
Constructor Summary
Constructors Constructor Description BitmapEncoder()Deprecated.UseBitmapEncoder(ArrayPool)instead.BitmapEncoder(ArrayPool arrayPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanencode(Resource<android.graphics.Bitmap> resource, java.io.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.EncodeStrategygetEncodeStrategy(Options options)
-
-
-
Field Detail
-
COMPRESSION_QUALITY
public static final Option<java.lang.Integer> COMPRESSION_QUALITY
An integer option between 0 and 100 that is used as the compression quality.Defaults to 90.
-
COMPRESSION_FORMAT
public static final Option<android.graphics.Bitmap.CompressFormat> COMPRESSION_FORMAT
AnBitmap.CompressFormatoption used as the format to encode theBitmap.Defaults to
Bitmap.CompressFormat.JPEGfor images without alpha andBitmap.CompressFormat.PNGfor images with alpha.
-
-
Constructor Detail
-
BitmapEncoder
public BitmapEncoder(@NonNull ArrayPool arrayPool)
-
BitmapEncoder
@Deprecated public BitmapEncoder()
Deprecated.UseBitmapEncoder(ArrayPool)instead.
-
-
Method Detail
-
encode
public boolean encode(@NonNull Resource<android.graphics.Bitmap> resource, @NonNull java.io.File file, @NonNull Options options)Description copied from interface:EncoderWrites the given data to the given output stream and returns True if the write completed successfully and should be committed.
-
getEncodeStrategy
@NonNull public EncodeStrategy getEncodeStrategy(@NonNull Options options)
- Specified by:
getEncodeStrategyin interfaceResourceEncoder<android.graphics.Bitmap>
-
-