Search in sources :

Example 1 with BytesResource

use of com.bumptech.glide.load.resource.bytes.BytesResource in project glide by bumptech.

the class BitmapBytesTranscoder method transcode.

@Override
public Resource<byte[]> transcode(Resource<Bitmap> toTranscode) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    toTranscode.get().compress(compressFormat, quality, os);
    toTranscode.recycle();
    return new BytesResource(os.toByteArray());
}
Also used : BytesResource(com.bumptech.glide.load.resource.bytes.BytesResource) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 2 with BytesResource

use of com.bumptech.glide.load.resource.bytes.BytesResource in project glide by bumptech.

the class GifDrawableBytesTranscoder method transcode.

@Override
public Resource<byte[]> transcode(Resource<GifDrawable> toTranscode) {
    GifDrawable gifData = toTranscode.get();
    ByteBuffer byteBuffer = gifData.getBuffer();
    return new BytesResource(ByteBufferUtil.toBytes(byteBuffer));
}
Also used : BytesResource(com.bumptech.glide.load.resource.bytes.BytesResource) GifDrawable(com.bumptech.glide.load.resource.gif.GifDrawable) ByteBuffer(java.nio.ByteBuffer)

Aggregations

BytesResource (com.bumptech.glide.load.resource.bytes.BytesResource)2 GifDrawable (com.bumptech.glide.load.resource.gif.GifDrawable)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ByteBuffer (java.nio.ByteBuffer)1