@Override
    public boolean encode(Resource<Bitmap> resource, OutputStream os) {
        final Bitmap bitmap = resource.get();

        long start = LogTime.getLogTime();
        Bitmap.CompressFormat format = getFormat(bitmap);
        bitmap.compress(format, quality, os);
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "Compressed with type: " + format + " of size " + Util.getBitmapByteSize(bitmap) + " in "
                    + LogTime.getElapsedMillis(start));
        }
        return true;
    }
An {@link ResourceEncoder} that writes {@link Bitmap}s to
{@link OutputStream}s.

<p>
    {@link Bitmap}s that return true from {@link Bitmap#hasAlpha()}} are written
    using {@link Bitmap.CompressFormat#PNG} to preserve alpha and all other bitmaps are written
    using {@link Bitmap.CompressFormat#JPEG}.
</p>

@see Bitmap#compress(Bitmap.CompressFormat, int, OutputStream)
core/src/main/java/com/bumptech/glide/load/resource/bitmap/BitmapEncoder.java