Package com.example.oblong
Class imageUtils
java.lang.Object
com.example.oblong.imageUtils
Utility class for encoding Bitmaps to Base64 strings and decoding Base64 strings back to Bitmaps.
for storage in Firebase since Base64 gets stored as a string
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic android.graphics.Bitmap
base64ToBitmap
(String base64String) Converts a Base64-encoded string back to a Bitmap image.static String
bitmapToBase64
(android.graphics.Bitmap bitmap) Converts a Bitmap image to a Base64-encoded string.static android.graphics.Bitmap
circularCrop
(android.graphics.Bitmap bitmap) Applies a circular crop to the provided Bitmap.static android.graphics.Bitmap
fastblur
(android.graphics.Bitmap sentBitmap, float scale, int radius) Stack Blur v1.0 from http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html Java Author: Mario Klingemann invalid input: '<'mario at quasimondo.com> http://incubator.quasimondo.com created Feburary 29, 2004 Android port : Yahel Bouaziz invalid input: '<'yahel at kayenko.com> http://www.kayenko.com ported april 5th, 2012 This is a compromise between Gaussian Blur and Box blur It creates much better looking blurs than Box Blur, but is 7x faster than my Gaussian Blur implementation.static String
getRealPathFromURI
(android.content.Context context, android.net.Uri uri) Get the real file path from a URI.static android.graphics.Bitmap
handleImageRotation
(String filePath, android.graphics.Bitmap bitmap) static boolean
isImageTooLarge
(android.graphics.Bitmap bitmap) Checks if the Bitmap is too large based on its memory size.
-
Constructor Details
-
imageUtils
public imageUtils()
-
-
Method Details
-
bitmapToBase64
Converts a Bitmap image to a Base64-encoded string.- Parameters:
bitmap
- The Bitmap image to encode.- Returns:
- A Base64-encoded string representing the image.
-
base64ToBitmap
Converts a Base64-encoded string back to a Bitmap image.- Parameters:
base64String
- The Base64-encoded string to decode.- Returns:
- A Bitmap image decoded from the Base64 string.
-
fastblur
public static android.graphics.Bitmap fastblur(android.graphics.Bitmap sentBitmap, float scale, int radius) Stack Blur v1.0 from http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html Java Author: Mario Klingemann invalid input: '<'mario at quasimondo.com> http://incubator.quasimondo.com created Feburary 29, 2004 Android port : Yahel Bouaziz invalid input: '<'yahel at kayenko.com> http://www.kayenko.com ported april 5th, 2012 This is a compromise between Gaussian Blur and Box blur It creates much better looking blurs than Box Blur, but is 7x faster than my Gaussian Blur implementation. I called it Stack Blur because this describes best how this filter works internally: it creates a kind of moving stack of colors whilst scanning through the image. Thereby it just has to add one new block of color to the right side of the stack and remove the leftmost color. The remaining colors on the topmost layer of the stack are either added on or reduced by one, depending on if they are on the right or on the left side of the stack. If you are using this algorithm in your code please add the following line: Stack Blur Algorithm by Mario Klingemann invalid input: '<'mario@quasimondo.com> -
handleImageRotation
public static android.graphics.Bitmap handleImageRotation(String filePath, android.graphics.Bitmap bitmap) -
circularCrop
public static android.graphics.Bitmap circularCrop(android.graphics.Bitmap bitmap) Applies a circular crop to the provided Bitmap.- Parameters:
bitmap
- The Bitmap to be cropped into a circular shape.- Returns:
- A circularly cropped Bitmap.
-
getRealPathFromURI
Get the real file path from a URI.- Parameters:
context
- The context.uri
- The URI to query.- Returns:
- The file path as a string, or null if not found.
-
isImageTooLarge
public static boolean isImageTooLarge(android.graphics.Bitmap bitmap) Checks if the Bitmap is too large based on its memory size.- Parameters:
bitmap
- The Bitmap to check.- Returns:
- True if the Bitmap is too large, false otherwise.
-