public final class TransformationUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
PAINT_FLAGS |
Modifier and Type | Method and Description |
---|---|
static Bitmap |
centerCrop(BitmapPool pool,
Bitmap inBitmap,
int width,
int height)
A potentially expensive operation to crop the given Bitmap so that it fills the given
dimensions.
|
static Bitmap |
centerInside(BitmapPool pool,
Bitmap inBitmap,
int width,
int height)
If the Bitmap is smaller or equal to the Target it returns the original size, if not then
fitCenter(BitmapPool, Bitmap, int, int) is called instead. |
static Bitmap |
circleCrop(BitmapPool pool,
Bitmap inBitmap,
int destWidth,
int destHeight)
Crop the image to a circle and resize to the specified width/height.
|
static Bitmap |
fitCenter(BitmapPool pool,
Bitmap inBitmap,
int width,
int height)
An expensive operation to resize the given Bitmap down so that it fits within the given
dimensions maintain the original proportions.
|
static Lock |
getBitmapDrawableLock() |
static int |
getExifOrientationDegrees(int exifOrientation)
Get the # of degrees an image must be rotated to match the given exif orientation.
|
static Bitmap |
rotateImage(Bitmap imageToOrient,
int degreesToRotate)
This is an expensive operation that copies the image in place with the pixels rotated.
|
static Bitmap |
rotateImageExif(BitmapPool pool,
Bitmap inBitmap,
int exifOrientation)
Rotate and/or flip the image to match the given exif orientation.
|
static Bitmap |
roundedCorners(BitmapPool pool,
Bitmap inBitmap,
int width,
int height,
int roundingRadius)
Creates a bitmap from a source bitmap and rounds the corners.
|
static void |
setAlpha(Bitmap inBitmap,
Bitmap outBitmap)
Sets the alpha of the Bitmap we're going to re-use to the alpha of the Bitmap we're going to
transform.
|
public static final int PAINT_FLAGS
public static Lock getBitmapDrawableLock()
public static Bitmap centerCrop(@NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int width, int height)
pool
- The BitmapPool to obtain a bitmap from.inBitmap
- The Bitmap to resize.width
- The width in pixels of the final Bitmap.height
- The height in pixels of the final Bitmap.public static Bitmap fitCenter(@NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int width, int height)
pool
- The BitmapPool obtain a bitmap from.inBitmap
- The Bitmap to shrink.width
- The width in pixels the final image will fit within.height
- The height in pixels the final image will fit within.public static Bitmap centerInside(@NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int width, int height)
fitCenter(BitmapPool, Bitmap, int, int)
is called instead.pool
- The BitmapPool obtain a bitmap from.inBitmap
- The Bitmap to center.width
- The width in pixels of the target.height
- The height in pixels of the target.public static void setAlpha(Bitmap inBitmap, Bitmap outBitmap)
Bitmap.hasAlpha()
} consistent before and after
the transformation for transformations that don't add or remove transparent pixels.public static Bitmap rotateImage(@NonNull Bitmap imageToOrient, int degreesToRotate)
imageToOrient
- Image Bitmap to orient.degreesToRotate
- number of degrees to rotate the image by. If zero the original image is
returned unmodified.public static int getExifOrientationDegrees(int exifOrientation)
exifOrientation
- The exif orientation [1-8]public static Bitmap rotateImageExif(@NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int exifOrientation)
pool
- A pool that may or may not contain an image of the necessary
dimensions.inBitmap
- The bitmap to rotate/flip.exifOrientation
- the exif orientation [1-8].public static Bitmap circleCrop(@NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int destWidth, int destHeight)
pool
- The BitmapPool obtain a bitmap from.inBitmap
- The Bitmap to resize.destWidth
- The width in pixels of the final Bitmap.destHeight
- The height in pixels of the final Bitmap.public static Bitmap roundedCorners(@NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int width, int height, int roundingRadius)
inBitmap
- the source bitmap to use as a basis for the created bitmap.width
- the width of the generated bitmap.height
- the height of the generated bitmap.roundingRadius
- the corner radius to be applied (in device-specific pixels).Bitmap
similar to inBitmap but with rounded corners.IllegalArgumentException
- if roundingRadius, width or height is 0 or less.