com.bumptech.glide.load.resource.bitmap
Class BitmapEncoder

java.lang.Object
  extended by com.bumptech.glide.load.resource.bitmap.BitmapEncoder
All Implemented Interfaces:
Encoder<Resource<Bitmap>>, ResourceEncoder<Bitmap>

public class BitmapEncoder
extends Object
implements ResourceEncoder<Bitmap>

An 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.

See Also:
Bitmap.compress(android.graphics.Bitmap.CompressFormat, int, java.io.OutputStream)

Constructor Summary
BitmapEncoder()
           
BitmapEncoder(Bitmap.CompressFormat compressFormat, int quality)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitmapEncoder

public BitmapEncoder()

BitmapEncoder

public BitmapEncoder(Bitmap.CompressFormat compressFormat,
                     int quality)
Method Detail

encode

public boolean encode(Resource<Bitmap> resource,
                      OutputStream os)
Description copied from interface: Encoder
Writes the given data to the given output stream and returns True if the write completed successfully and should be committed.

Specified by:
encode in interface Encoder<Resource<Bitmap>>
Parameters:
resource - The data to write.
os - The OutputStream to write the data to.

getId

public String getId()
Description copied from interface: Encoder
Returns an ID identifying any transformation this encoder may apply to the given data that will be mixed in to the cache key.

If 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.

Specified by:
getId in interface Encoder<Resource<Bitmap>>