Package com.trimblemaps.mapsdk.utils
Class BitmapUtils
java.lang.Object
com.trimblemaps.mapsdk.utils.BitmapUtils
Utility class for creating bitmaps
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic android.graphics.BitmapcreateBitmapFromView(android.view.View view) Convert a view to a bitmap.static booleanequals(android.graphics.Bitmap bitmap, android.graphics.Bitmap other) Validates if the bytes of a bitmap matches anotherstatic android.graphics.BitmapgetBitmapFromDrawable(android.graphics.drawable.Drawable sourceDrawable) Extract an underlying bitmap from a drawablestatic byte[]getByteArrayFromDrawable(android.graphics.drawable.Drawable drawable) Create a byte array out of drawablestatic android.graphics.drawable.DrawablegetDrawableFromByteArray(android.content.Context context, byte[] array) Decode byte array to drawable objectstatic android.graphics.drawable.DrawablegetDrawableFromRes(android.content.Context context, int drawableRes) Get a drawable from a resource.static android.graphics.drawable.DrawablegetDrawableFromRes(android.content.Context context, int drawableRes, Integer tintColor) Get a tinted drawable from a resource.static android.graphics.BitmapmergeBitmap(android.graphics.Bitmap background, android.graphics.Bitmap foreground) Deprecated.static android.graphics.BitmapmergeBitmap(android.graphics.Bitmap background, android.graphics.Bitmap foreground, float left, float top) Create a bitmap from a background and a foreground bitmapstatic android.graphics.BitmapmergeBitmaps(android.graphics.Bitmap background, android.graphics.Bitmap foreground) Create a bitmap from a background and a foreground bitmap.
-
Constructor Details
-
BitmapUtils
public BitmapUtils()
-
-
Method Details
-
createBitmapFromView
public static android.graphics.Bitmap createBitmapFromView(@NonNull android.view.View view) Convert a view to a bitmap.- Parameters:
view- the view to convert- Returns:
- the converted bitmap
-
mergeBitmap
@Deprecated public static android.graphics.Bitmap mergeBitmap(@NonNull android.graphics.Bitmap background, @NonNull android.graphics.Bitmap foreground) Deprecated.mergeBitmaps(Bitmap, Bitmap)should be used instead, as it does not shift the input by 10px to the right and bottom.Create a bitmap from a background and a foreground bitmap. The foreground bitmap will be shifted 10px to the right and 10px to the bottom relative to the background.- Parameters:
background- The bitmap placed in the backgroundforeground- The bitmap placed in the foreground- Returns:
- the merged bitmap
-
mergeBitmaps
public static android.graphics.Bitmap mergeBitmaps(@NonNull android.graphics.Bitmap background, @NonNull android.graphics.Bitmap foreground) Create a bitmap from a background and a foreground bitmap.- Parameters:
background- The bitmap placed in the backgroundforeground- The bitmap placed in the foreground- Returns:
- the merged bitmap
-
mergeBitmap
public static android.graphics.Bitmap mergeBitmap(@NonNull android.graphics.Bitmap background, @NonNull android.graphics.Bitmap foreground, float left, float top) Create a bitmap from a background and a foreground bitmap- Parameters:
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- Returns:
- the merged bitmap
-
getBitmapFromDrawable
@Nullable public static android.graphics.Bitmap getBitmapFromDrawable(@Nullable android.graphics.drawable.Drawable sourceDrawable) Extract an underlying bitmap from a drawable- Parameters:
sourceDrawable- The source drawable- Returns:
- The underlying bitmap
-
getByteArrayFromDrawable
@Nullable public static byte[] getByteArrayFromDrawable(@Nullable android.graphics.drawable.Drawable drawable) Create a byte array out of drawable- Parameters:
drawable- The source drawable- Returns:
- The byte array of source drawable
-
getDrawableFromByteArray
@Nullable public static android.graphics.drawable.Drawable getDrawableFromByteArray(@NonNull android.content.Context context, @Nullable byte[] array) Decode byte array to drawable object- Parameters:
context- Context to obtainResourcesarray- The source byte array- Returns:
- The drawable created from source byte array
-
getDrawableFromRes
@Nullable public static android.graphics.drawable.Drawable getDrawableFromRes(@NonNull android.content.Context context, @DrawableRes int drawableRes) Get a drawable from a resource.- Parameters:
context- Context to obtainResourcesdrawableRes- Drawable resource- Returns:
- The drawable created from the resource
-
getDrawableFromRes
@Nullable public static android.graphics.drawable.Drawable getDrawableFromRes(@NonNull android.content.Context context, @DrawableRes int drawableRes, @Nullable @ColorInt Integer tintColor) Get a tinted drawable from a resource.- Parameters:
context- Context to obtainResourcesdrawableRes- Drawable resourcetintColor- Tint color- Returns:
- The drawable created from the resource
-
equals
@VisibleForTesting public static boolean equals(android.graphics.Bitmap bitmap, android.graphics.Bitmap other) Validates if the bytes of a bitmap matches another- Parameters:
bitmap- the bitmap to be compared againstother- the bitmap to compare with- Returns:
- true if equal
-
mergeBitmaps(Bitmap, Bitmap)should be used instead, as it does not shift the input by 10px to the right and bottom.