public class BitmapUtils
extends java.lang.Object
| Constructor and Description |
|---|
BitmapUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Bitmap |
createBitmapFromView(View view)
Convert a view to a bitmap.
|
static boolean |
equals(Bitmap bitmap,
Bitmap other)
Validates if the bytes of a bitmap matches another
|
static Bitmap |
getBitmapFromDrawable(Drawable sourceDrawable)
Extract an underlying bitmap from a drawable
|
static byte[] |
getByteArrayFromDrawable(Drawable drawable)
Create a byte array out of drawable
|
static Drawable |
getDrawableFromByteArray(Context context,
byte[] array)
Decode byte array to drawable object
|
static Drawable |
getDrawableFromRes(Context context,
int drawableRes)
Get a drawable from a resource.
|
static Drawable |
getDrawableFromRes(Context context,
int drawableRes,
java.lang.Integer tintColor)
Get a tinted drawable from a resource.
|
static Bitmap |
mergeBitmap(Bitmap background,
Bitmap foreground)
Create a bitmap from a background and a foreground bitmap
|
static Bitmap |
mergeBitmap(Bitmap background,
Bitmap foreground,
float left,
float top)
Create a bitmap from a background and a foreground bitmap
|
public static Bitmap createBitmapFromView(@NonNull
View view)
view - the view to convertpublic static Bitmap mergeBitmap(@NonNull
Bitmap background,
@NonNull
Bitmap foreground)
background - The bitmap placed in the backgroundforeground - The bitmap placed in the foregroundpublic static Bitmap mergeBitmap(@NonNull
Bitmap background,
@NonNull
Bitmap foreground,
float left,
float top)
background - The bitmap placed in the backgroundforeground - The bitmap placed in the foregroundleft - position of the left side of the foreground bitmaptop - position of the top side of the foreground bitmap@Nullable
public static Bitmap getBitmapFromDrawable(@Nullable
Drawable sourceDrawable)
sourceDrawable - The source drawable@Nullable
public static byte[] getByteArrayFromDrawable(@Nullable
Drawable drawable)
drawable - The source drawable@Nullable
public static Drawable getDrawableFromByteArray(@NonNull
Context context,
@Nullable
byte[] array)
context - Context to obtain Resourcesarray - The source byte array@Nullable
public static Drawable getDrawableFromRes(@NonNull
Context context,
@DrawableRes
int drawableRes)
context - Context to obtain ResourcesdrawableRes - Drawable resource@Nullable
public static Drawable getDrawableFromRes(@NonNull
Context context,
@DrawableRes
int drawableRes,
@Nullable @ColorInt
java.lang.Integer tintColor)
context - Context to obtain ResourcesdrawableRes - Drawable resourcetintColor - Tint colorpublic static boolean equals(Bitmap bitmap,
Bitmap other)
bitmap - the bitmap to be compared againstother - the bitmap to compare with