Java Code Examples for com.bumptech.glide.load.Transformation#transform()

The following examples show how to use com.bumptech.glide.load.Transformation#transform() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GifResourceEncoder.java    From giffun with Apache License 2.0 5 votes vote down vote up
private Resource<Bitmap> getTransformedFrame(Bitmap currentFrame, Transformation<Bitmap> transformation,
        GifDrawable drawable) {
    // TODO: what if current frame is null?
    Resource<Bitmap> bitmapResource = factory.buildFrameResource(currentFrame, bitmapPool);
    Resource<Bitmap> transformedResource = transformation.transform(bitmapResource,
            drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    if (!bitmapResource.equals(transformedResource)) {
        bitmapResource.recycle();
    }
    return transformedResource;
}
 
Example 2
Source File: TestFragment.java    From glide-support with The Unlicense 5 votes vote down vote up
private BitmapDrawable transformDrawable(Drawable drawable, Transformation<Bitmap> transform, int size) {
	// render original
	Bitmap bitmap = Bitmap.createBitmap(size, size, Config.ARGB_8888);
	Canvas canvas = new Canvas(bitmap);
	drawable.setBounds(0, 0, size, size);
	drawable.draw(canvas);
	// make rounded
	Resource<Bitmap> original = BitmapResource.obtain(bitmap, Glide.get(getContext()).getBitmapPool());
	Resource<Bitmap> rounded = transform.transform(original, size, size);
	if (!original.equals(rounded)) {
		original.recycle();
	}
	return new BitmapDrawable(getResources(), rounded.get());
}