com.bumptech.glide.load.resource.bitmap
Class CenterCrop
java.lang.Object
com.bumptech.glide.load.resource.bitmap.BitmapTransformation
com.bumptech.glide.load.resource.bitmap.CenterCrop
- All Implemented Interfaces:
- Transformation<Bitmap>
public class CenterCrop
- extends BitmapTransformation
Scale the image so that either the width of the image matches the given width and the height of the image is
greater than the given height or vice versa, and then crop the larger dimension to match the given dimension.
Does not maintain the image's aspect ratio
Method Summary |
String |
getId()
A method to get a unique identifier for this particular transformation that can be used as part of a cache key. |
protected Bitmap |
transform(BitmapPool pool,
Bitmap toTransform,
int outWidth,
int outHeight)
Transforms the given Bitmap based on the given dimensions and returns the transformed
result. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CenterCrop
public CenterCrop(Context context)
CenterCrop
public CenterCrop(BitmapPool bitmapPool)
transform
protected Bitmap transform(BitmapPool pool,
Bitmap toTransform,
int outWidth,
int outHeight)
- Description copied from class:
BitmapTransformation
- Transforms the given
Bitmap
based on the given dimensions and returns the transformed
result.
Note - As with all Transformation
s, this method must be idempotent. Given
bitmap A, and bitmap B == transform(A). transform(B) must always equal B.
- Specified by:
transform
in class BitmapTransformation
- Parameters:
pool
- A BitmapPool
that can be used to obtain and
return intermediate Bitmap
s used in this transformation. For every
Bitmap
obtained from the pool during this transformation, a
Bitmap
must also be returned.toTransform
- The Bitmap
to transform.outWidth
- The ideal width of the transformed bitmap (does not need to match exactly).outHeight
- The ideal height of the transformed bitmap (does not need to match exactly).
getId
public String getId()
- Description copied from interface:
Transformation
- A method to get a unique identifier for this particular transformation that can be used as part of a cache key.
The fully qualified class name for this class is appropriate if written out, but getClass().getName() is not
because the name may be changed by proguard.
If this transformation does not affect the data that will be stored in cache, returning an empty string here
is acceptable.
- Returns:
- A string that uniquely identifies this transformation.