Class DynamicBitmapUtils
- java.lang.Object
-
- com.pranavpandey.android.dynamic.util.DynamicBitmapUtils
-
public class DynamicBitmapUtils extends java.lang.ObjectHelper class to performBitmapoperations.
-
-
Constructor Summary
Constructors Constructor Description DynamicBitmapUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static android.graphics.BitmapapplyColorFilter(android.graphics.Bitmap bitmap, int color)Apply monochrome color filter on the supplied bitmap.static android.graphics.BitmapapplyColorFilter(android.graphics.Bitmap bitmap, android.graphics.ColorFilter colorFilter)Apply color filter on the supplied bitmap.static android.graphics.BitmapcreateBitmap(android.view.View view)Creates a bitmap from the supplied view.static android.graphics.BitmapcreateBitmap(android.view.View view, int width, int height)Creates a bitmap from the supplied view.static android.graphics.BitmapcropBitmap(android.graphics.Bitmap bitmap, int newWidth, int newHeight)Crop bitmap to the new width and height.static android.graphics.BitmapgetBitmap(android.content.Context context, android.net.Uri uri)Retrieve the bitmap from the supplied URI.static android.graphics.BitmapgetBitmap(android.graphics.drawable.Drawable drawable)Get bitmap from the supplied drawable.static android.graphics.BitmapgetBitmap(android.graphics.drawable.Drawable drawable, boolean compress, int quality)Get bitmap from the supplied drawable.static android.graphics.BitmapgetBitmap(android.graphics.drawable.Drawable drawable, int width, int height, boolean compress, int quality)Get bitmap from the supplied drawable.static intgetDominantColor(android.graphics.Bitmap bitmap)Extract the dominant color from the supplied bitmap.static android.graphics.BitmapresizeBitmap(android.graphics.Bitmap bitmap, int newWidth, int newHeight)Resize bitmap to the new width and height.
-
-
-
Method Detail
-
getBitmap
@Nullable public static android.graphics.Bitmap getBitmap(@Nullable android.content.Context context, @Nullable android.net.Uri uri)Retrieve the bitmap from the supplied URI.- Parameters:
context- The context to get the content resolver.uri- The URI to retrieve the bitmap.- Returns:
- The bitmap from the supplied URI.
- See Also:
Context.getContentResolver()
-
getBitmap
@Nullable public static android.graphics.Bitmap getBitmap(@Nullable android.graphics.drawable.Drawable drawable, int width, int height, boolean compress, int quality)Get bitmap from the supplied drawable.- Parameters:
drawable- The drawable to get the bitmap.width- The width in dip for the bitmap.height- The height in dip for the bitmap.compress-trueto compress the bitmap.quality- The quality of the compressed bitmap.- Returns:
- The bitmap from the supplied drawable.
-
getBitmap
@Nullable public static android.graphics.Bitmap getBitmap(@Nullable android.graphics.drawable.Drawable drawable, boolean compress, int quality)Get bitmap from the supplied drawable.- Parameters:
drawable- The drawable to get the bitmap.compress-trueto compress the bitmap.quality- The quality of the compressed bitmap.- Returns:
- The bitmap from the supplied drawable.
-
getBitmap
@Nullable public static android.graphics.Bitmap getBitmap(@Nullable android.graphics.drawable.Drawable drawable)Get bitmap from the supplied drawable.- Parameters:
drawable- The drawable to get the bitmap.- Returns:
- The bitmap from the supplied drawable.
-
resizeBitmap
@Nullable public static android.graphics.Bitmap resizeBitmap(@Nullable android.graphics.Bitmap bitmap, int newWidth, int newHeight)Resize bitmap to the new width and height.- Parameters:
bitmap- The bitmap to resize.newWidth- The new width for the bitmap.newHeight- The new height for the bitmap.- Returns:
- The resized bitmap with new width and height.
-
cropBitmap
@Nullable public static android.graphics.Bitmap cropBitmap(@Nullable android.graphics.Bitmap bitmap, int newWidth, int newHeight)Crop bitmap to the new width and height.- Parameters:
bitmap- The bitmap to crop.newWidth- The new width for the bitmap.newHeight- The new height for the bitmap.- Returns:
- The cropped bitmap with new width and height.
-
applyColorFilter
@Nullable public static android.graphics.Bitmap applyColorFilter(@Nullable android.graphics.Bitmap bitmap, @NonNull android.graphics.ColorFilter colorFilter)Apply color filter on the supplied bitmap.- Parameters:
bitmap- The bitmap to apply color filter.colorFilter- The color filter to be applied on the bitmap.- Returns:
- The new bitmap with applied color filter.
-
applyColorFilter
@Nullable public static android.graphics.Bitmap applyColorFilter(@Nullable android.graphics.Bitmap bitmap, @ColorInt int color)Apply monochrome color filter on the supplied bitmap.- Parameters:
bitmap- The bitmap to apply color filter.color- The color to generate color filter.- Returns:
- The new bitmap with applied color filter.
-
getDominantColor
@ColorInt public static int getDominantColor(@NonNull android.graphics.Bitmap bitmap)Extract the dominant color from the supplied bitmap.- Parameters:
bitmap- The bitmap to extract the dominant color.- Returns:
- The dominant color extracted from the bitmap.
-
createBitmap
@Nullable public static android.graphics.Bitmap createBitmap(@Nullable android.view.View view, int width, int height)Creates a bitmap from the supplied view.- Parameters:
view- The view to get the bitmap.width- The width for the bitmap.height- The height for the bitmap.- Returns:
- The bitmap from the supplied drawable.
-
createBitmap
@Nullable public static android.graphics.Bitmap createBitmap(@Nullable android.view.View view)Creates a bitmap from the supplied view.- Parameters:
view- The view to get the bitmap.- Returns:
- The bitmap from the supplied drawable.
-
-