Class BitmapUtils

java.lang.Object
com.trimblemaps.mapsdk.utils.BitmapUtils

public class BitmapUtils extends Object
Utility class for creating bitmaps
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static android.graphics.Bitmap
    createBitmapFromView(android.view.View view)
    Convert a view to a bitmap.
    static boolean
    equals(android.graphics.Bitmap bitmap, android.graphics.Bitmap other)
    Validates if the bytes of a bitmap matches another
    static android.graphics.Bitmap
    getBitmapFromDrawable(android.graphics.drawable.Drawable sourceDrawable)
    Extract an underlying bitmap from a drawable
    static byte[]
    getByteArrayFromDrawable(android.graphics.drawable.Drawable drawable)
    Create a byte array out of drawable
    static android.graphics.drawable.Drawable
    getDrawableFromByteArray(android.content.Context context, byte[] array)
    Decode byte array to drawable object
    static android.graphics.drawable.Drawable
    getDrawableFromRes(android.content.Context context, int drawableRes)
    Get a drawable from a resource.
    static android.graphics.drawable.Drawable
    getDrawableFromRes(android.content.Context context, int drawableRes, Integer tintColor)
    Get a tinted drawable from a resource.
    static android.graphics.Bitmap
    mergeBitmap(android.graphics.Bitmap background, 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.
    static android.graphics.Bitmap
    mergeBitmap(android.graphics.Bitmap background, android.graphics.Bitmap foreground, float left, float top)
    Create a bitmap from a background and a foreground bitmap
    static android.graphics.Bitmap
    mergeBitmaps(android.graphics.Bitmap background, android.graphics.Bitmap foreground)
    Create a bitmap from a background and a foreground bitmap.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 background
      foreground - 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 background
      foreground - 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 background
      foreground - The bitmap placed in the foreground
      left - position of the left side of the foreground bitmap
      top - 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 obtain Resources
      array - 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 obtain Resources
      drawableRes - 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 obtain Resources
      drawableRes - Drawable resource
      tintColor - 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 against
      other - the bitmap to compare with
      Returns:
      true if equal