Class BitmapUtils


  • public class BitmapUtils
    extends java.lang.Object
    A utility class providing functions about bitmap.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static android.graphics.Bitmap copyMutable​(android.graphics.Bitmap bitmap)
      If the bitmap is mutable, it will return it.
      static int getAllocationByteCount​(android.graphics.Bitmap bitmap)
      Returns the size of the allocated memory used to store this bitmap's pixels in a backwards compatible way.
      static boolean hasMipMap​(android.graphics.Bitmap bitmap)  
      static void recycle​(android.graphics.Bitmap bitmap)
      Recycle bitmap.
      static void recycle​(android.graphics.Bitmap... bitmaps)
      Recycle bitmap.
      static void setHasMipMap​(android.graphics.Bitmap bitmap, boolean hasMipmap)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • recycle

        public static void recycle​(@Nullable
                                   android.graphics.Bitmap bitmap)
        Recycle bitmap.
        Parameters:
        bitmap - bitmap to recycle
      • recycle

        public static void recycle​(@Nullable
                                   android.graphics.Bitmap... bitmaps)
        Recycle bitmap.
        Parameters:
        bitmaps - bitmaps to recycle
        See Also:
        recycle(Bitmap)
      • copyMutable

        @NonNull
        public static android.graphics.Bitmap copyMutable​(@NonNull
                                                          android.graphics.Bitmap bitmap)
        If the bitmap is mutable, it will return it. Otherwise, it returns the bitmap's mutable copy and recycle it.
        Parameters:
        bitmap - the bitmap in which to return its mutable copy and recycle
        Returns:
        the mutable copy of the bitmap.
      • hasMipMap

        public static boolean hasMipMap​(@NonNull
                                        android.graphics.Bitmap bitmap)
      • setHasMipMap

        public static void setHasMipMap​(@NonNull
                                        android.graphics.Bitmap bitmap,
                                        boolean hasMipmap)
      • getAllocationByteCount

        public static int getAllocationByteCount​(@NonNull
                                                 android.graphics.Bitmap bitmap)
        Returns the size of the allocated memory used to store this bitmap's pixels in a backwards compatible way.
        Parameters:
        bitmap - the bitmap in which to return its allocation size
        Returns:
        the allocation size in bytes