Search in sources :

Example 16 with BitmapPool

use of com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool in project glide by bumptech.

the class CenterInsideTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    bitmapWidth = 100;
    bitmapHeight = 100;
    Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
    when(resource.get()).thenReturn(bitmap);
    context = RuntimeEnvironment.application;
    BitmapPool pool = new BitmapPoolAdapter();
    Glide.init(context, new GlideBuilder().setBitmapPool(pool));
    centerInside = new CenterInside();
}
Also used : Bitmap(android.graphics.Bitmap) GlideBuilder(com.bumptech.glide.GlideBuilder) BitmapPoolAdapter(com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter) BitmapPool(com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool) Before(org.junit.Before)

Example 17 with BitmapPool

use of com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool in project Rocket by mozilla-tw.

the class BitmapTransformation method transform.

@Override
public final Resource<Bitmap> transform(Context context, Resource<Bitmap> resource, int outWidth, int outHeight) {
    if (!Util.isValidDimensions(outWidth, outHeight)) {
        throw new IllegalArgumentException("Cannot apply transformation on width: " + outWidth + " or height: " + outHeight + " less than or equal to zero and not Target.SIZE_ORIGINAL");
    }
    BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
    Bitmap toTransform = resource.get();
    int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth;
    int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight;
    Bitmap transformed = transform(bitmapPool, toTransform, targetWidth, targetHeight);
    final Resource<Bitmap> result;
    if (toTransform.equals(transformed)) {
        result = resource;
    } else {
        result = BitmapResource.obtain(transformed, bitmapPool);
    }
    return result;
}
Also used : Bitmap(android.graphics.Bitmap) BitmapPool(com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool)

Aggregations

BitmapPool (com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool)17 Bitmap (android.graphics.Bitmap)15 BitmapDrawable (android.graphics.drawable.BitmapDrawable)7 Test (org.junit.Test)6 Drawable (android.graphics.drawable.Drawable)5 ColorDrawable (android.graphics.drawable.ColorDrawable)4 NonNull (android.support.annotation.NonNull)4 GlideBuilder (com.bumptech.glide.GlideBuilder)3 BitmapPoolAdapter (com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter)3 Before (org.junit.Before)2 Context (android.content.Context)1 Canvas (android.graphics.Canvas)1 Animatable (android.graphics.drawable.Animatable)1 Nullable (android.support.annotation.Nullable)1 DisplayMetrics (android.util.DisplayMetrics)1 NonNull (androidx.annotation.NonNull)1 ImageHeaderParser (com.bumptech.glide.load.ImageHeaderParser)1 ArrayPool (com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool)1 LruArrayPool (com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool)1 LruBitmapPool (com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool)1