use of com.bumptech.glide.load.resource.UnitTransformation in project glide by bumptech.
the class ReEncodingGifResourceEncoder method encode.
@Override
public boolean encode(Resource<GifDrawable> resource, File file, Options options) {
GifDrawable drawable = resource.get();
Transformation<Bitmap> transformation = drawable.getFrameTransformation();
boolean isTransformed = !(transformation instanceof UnitTransformation);
if (isTransformed && options.get(ENCODE_TRANSFORMATION)) {
return encodeTransformedToFile(drawable, file);
} else {
return writeDataDirect(drawable.getBuffer(), file);
}
}
use of com.bumptech.glide.load.resource.UnitTransformation in project glide by bumptech.
the class GifDrawableTransformationTest method testSetsTransformationAsFrameTransformation.
@Test
@SuppressWarnings("unchecked")
public void testSetsTransformationAsFrameTransformation() {
Resource<GifDrawable> resource = mockResource();
GifDrawable gifDrawable = mock(GifDrawable.class);
Transformation<Bitmap> unitTransformation = UnitTransformation.get();
when(gifDrawable.getFrameTransformation()).thenReturn(unitTransformation);
when(gifDrawable.getIntrinsicWidth()).thenReturn(500);
when(gifDrawable.getIntrinsicHeight()).thenReturn(500);
when(resource.get()).thenReturn(gifDrawable);
Bitmap firstFrame = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
when(gifDrawable.getFirstFrame()).thenReturn(firstFrame);
final int width = 123;
final int height = 456;
Bitmap expectedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Resource<Bitmap> expectedResource = mockResource();
when(expectedResource.get()).thenReturn(expectedBitmap);
when(wrapped.transform(Util.<Bitmap>anyResource(), anyInt(), anyInt())).thenReturn(expectedResource);
transformation.transform(resource, width, height);
verify(gifDrawable).setFrameTransformation(isA(Transformation.class), eq(expectedBitmap));
}
Aggregations