public class PictureHelper
extends java.lang.Object
| Constructor and Description |
|---|
PictureHelper() |
| Modifier and Type | Method and Description |
|---|---|
static int |
calculateInSampleSize(android.graphics.BitmapFactory.Options options,
int reqWidth,
int reqHeight)
Calculate an inSampleSize for use in a
BitmapFactory.Options object
when decoding bitmaps using the decode* methods from BitmapFactory. |
static android.graphics.Bitmap |
compressBitmap(android.graphics.Bitmap original,
int compressRatio) |
static java.io.File |
createImageFile() |
static java.lang.String |
createRandomImageFilename() |
static android.graphics.Bitmap |
createYotiPatternMaskSquares(android.graphics.Bitmap foreground,
android.graphics.RectF[] rects) |
static android.graphics.Bitmap |
decodeBase64(java.lang.String input) |
static android.graphics.Bitmap |
decodeBase64ToBitmap(java.lang.String input) |
static android.graphics.Bitmap |
decodeSampledBitmapFromFile(java.lang.String filename,
int reqWidth,
int reqHeight) |
static android.graphics.Bitmap |
decodeSampledBitmapFromResource(android.content.res.Resources res,
int resId,
int reqWidth,
int reqHeight) |
static java.lang.String |
encodeBitmapFileTobase64(java.lang.String filePath) |
static java.lang.String |
encodeBitmapTobase64(android.graphics.Bitmap image) |
static java.lang.String |
encodeJpegFileTobase64(java.lang.String filePath) |
static java.lang.String |
encodeTobase64(android.graphics.Bitmap image) |
static java.lang.ref.WeakReference<android.graphics.Bitmap> |
flipMirroredBitmap(java.lang.ref.WeakReference<android.graphics.Bitmap> mFaceBitmap,
int width,
int height) |
static java.lang.String |
getDocumentFilePathInInternalStorage(android.content.Context context) |
static java.lang.String |
getTemporalPathForBitmapWithFileName(java.lang.String fileName) |
static byte[] |
loadAndRotateBitmapFromFileToByteArray(java.lang.String filePath,
float angle,
int newWidth,
int newHeight,
int compression,
boolean useJpeg)
Load a bitmap from a file, rotate it and scale it while keepung the aspect ratio
|
static byte[] |
loadBitmapFromFileToByteArray(java.lang.String filePath)
Read bitmap file to bytes, doesn't do any checking for valid bitmap
|
static android.graphics.Bitmap |
loadBitmapFromView(android.view.View v) |
static byte[] |
loadImageInByteArrayFormat(java.lang.String filePath) |
static android.graphics.Bitmap |
punchAHoleInABitmap(android.graphics.Bitmap foreground,
float holeRadius,
float yRatio) |
static android.graphics.Bitmap |
readBitmapFromFile(java.lang.String filePath) |
static java.lang.String |
rotateAndEncodeBitmapFileTobase64(java.lang.String filePath,
float angle,
int newWidth,
int newHeight,
int compression,
boolean useJpeg) |
static void |
saveBitmapToFile(android.graphics.Bitmap bitmap) |
static boolean |
saveBitmapToFile(android.graphics.Bitmap bitmap,
java.lang.String filename) |
static boolean |
saveBitmapToFile(android.graphics.Bitmap bitmap,
java.lang.String filename,
android.graphics.Bitmap.CompressFormat format,
int compressionRatio) |
static java.lang.String |
saveBitmapToInternalStorage(android.content.Context context,
android.graphics.Bitmap bitmap,
java.lang.String filename,
android.graphics.Bitmap.CompressFormat format,
int compressionRatio) |
static boolean |
saveBitmapToPNGFile(android.graphics.Bitmap bitmap,
java.lang.String filename) |
static boolean |
saveByteArrayToFile(byte[] bytes,
java.lang.String filename) |
static java.lang.ref.WeakReference<android.graphics.Bitmap> |
scaleBitmapFromFile(java.lang.String imageFilePath,
int percentage) |
static java.lang.ref.WeakReference<android.graphics.Bitmap> |
scaleBitmapKeepingAspectRatio(java.lang.ref.WeakReference<android.graphics.Bitmap> bitmapOrg,
int width,
int height) |
static android.graphics.Bitmap |
YuvToBitmap(android.content.Context ctx,
byte[] yuvData,
int width,
int height)
Renderscript based YUV converter.
|
static android.graphics.Bitmap |
YuvToBitmapCompat(byte[] yuvData,
int width,
int height) |
static android.graphics.Bitmap |
YuvToBitmapViaRgb(byte[] yuvData,
int width,
int height) |
static int[] |
YuvToRGB(byte[] yuvData,
int width,
int height) |
public static boolean saveBitmapToFile(android.graphics.Bitmap bitmap,
java.lang.String filename,
android.graphics.Bitmap.CompressFormat format,
int compressionRatio)
public static java.lang.String saveBitmapToInternalStorage(android.content.Context context,
android.graphics.Bitmap bitmap,
java.lang.String filename,
android.graphics.Bitmap.CompressFormat format,
int compressionRatio)
public static boolean saveBitmapToFile(android.graphics.Bitmap bitmap,
java.lang.String filename)
@Nullable public static byte[] loadBitmapFromFileToByteArray(java.lang.String filePath)
filePath - path on disk to loadpublic static byte[] loadAndRotateBitmapFromFileToByteArray(java.lang.String filePath,
float angle,
int newWidth,
int newHeight,
int compression,
boolean useJpeg)
filePath - where to load the bitmapangle - the rotation angle, can be negativenewWidth - the new width, can 0 or negative if which case it will be ignorednewHeight - the new height, can 0 or negative if which case it will be ignoredcompression - compress the picture to the expected ratiouseJpeg - true the pivture will a JPEG false default encoding : PNGpublic static java.lang.String encodeBitmapFileTobase64(java.lang.String filePath)
public static java.lang.String rotateAndEncodeBitmapFileTobase64(java.lang.String filePath,
float angle,
int newWidth,
int newHeight,
int compression,
boolean useJpeg)
public static java.lang.String encodeBitmapTobase64(android.graphics.Bitmap image)
public static android.graphics.Bitmap decodeBase64ToBitmap(java.lang.String input)
public static java.lang.ref.WeakReference<android.graphics.Bitmap> flipMirroredBitmap(java.lang.ref.WeakReference<android.graphics.Bitmap> mFaceBitmap,
int width,
int height)
public static java.lang.ref.WeakReference<android.graphics.Bitmap> scaleBitmapKeepingAspectRatio(java.lang.ref.WeakReference<android.graphics.Bitmap> bitmapOrg,
int width,
int height)
public static java.lang.ref.WeakReference<android.graphics.Bitmap> scaleBitmapFromFile(java.lang.String imageFilePath,
int percentage)
public static byte[] loadImageInByteArrayFormat(java.lang.String filePath)
public static android.graphics.Bitmap punchAHoleInABitmap(android.graphics.Bitmap foreground,
float holeRadius,
float yRatio)
@Nullable public static android.graphics.Bitmap loadBitmapFromView(android.view.View v)
v - - the view from which the bitmap should be createpublic static android.graphics.Bitmap decodeSampledBitmapFromFile(java.lang.String filename,
int reqWidth,
int reqHeight)
public static int calculateInSampleSize(android.graphics.BitmapFactory.Options options,
int reqWidth,
int reqHeight)
BitmapFactory.Options object
when decoding bitmaps using the decode* methods from BitmapFactory.
This implementation calculates the closest inSampleSize that is a power of 2 and will result
in the final decoded bitmap having a width and height equal to or larger than the requested
width and height.options - An options object with out* params already populated (run through a decode*
method with inJustDecodeBounds==truereqWidth - The requested width of the resulting bitmapreqHeight - The requested height of the resulting bitmappublic static java.lang.String createRandomImageFilename()
public static java.lang.String getDocumentFilePathInInternalStorage(android.content.Context context)
public static java.io.File createImageFile()
throws java.io.IOException
java.io.IOExceptionpublic static boolean saveBitmapToPNGFile(android.graphics.Bitmap bitmap,
java.lang.String filename)
public static boolean saveByteArrayToFile(byte[] bytes,
java.lang.String filename)
public static android.graphics.Bitmap compressBitmap(android.graphics.Bitmap original,
int compressRatio)
public static java.lang.String encodeJpegFileTobase64(java.lang.String filePath)
public static java.lang.String encodeTobase64(android.graphics.Bitmap image)
public static android.graphics.Bitmap decodeBase64(java.lang.String input)
public static java.lang.String getTemporalPathForBitmapWithFileName(java.lang.String fileName)
@Nullable
public static android.graphics.Bitmap YuvToBitmapCompat(byte[] yuvData,
int width,
int height)
public static int[] YuvToRGB(byte[] yuvData,
int width,
int height)
public static android.graphics.Bitmap YuvToBitmapViaRgb(byte[] yuvData,
int width,
int height)
@Nullable
public static android.graphics.Bitmap YuvToBitmap(android.content.Context ctx,
byte[] yuvData,
int width,
int height)
public static void saveBitmapToFile(android.graphics.Bitmap bitmap)
public static android.graphics.Bitmap createYotiPatternMaskSquares(android.graphics.Bitmap foreground,
android.graphics.RectF[] rects)
public static android.graphics.Bitmap decodeSampledBitmapFromResource(android.content.res.Resources res,
int resId,
int reqWidth,
int reqHeight)
public static android.graphics.Bitmap readBitmapFromFile(java.lang.String filePath)