-
public class CropImageHelper to simplify crop image work like starting pick-image activity and handling camera/gallery intents.<br></br> The goal of the helper is to simplify the starting and most-common usage of image cropping and not all-purpose all possible scenario one-to-rule-them-all code base. So feel free to use it as is and as a wiki to make your own.<br></br> Added value you get out-of-the-box is some edge case handling that you may miss otherwise, like the stupid-ass Android camera result URI that may differ from version to version and from device to device.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classCropImage.ActivityResultResult data of Crop Image Activity.
public classCropImage.CancelledResult
-
Field Summary
Fields Modifier and Type Field Description private final StringCROP_IMAGE_EXTRA_SOURCEprivate final StringCROP_IMAGE_EXTRA_OPTIONSprivate final StringCROP_IMAGE_EXTRA_BUNDLEprivate final StringCROP_IMAGE_EXTRA_RESULTprivate final IntegerCROP_IMAGE_ACTIVITY_RESULT_ERROR_CODEpublic final static CropImageINSTANCE
-
Method Summary
Modifier and Type Method Description final BitmaptoOvalBitmap(Bitmap bitmap)Create a new bitmap that has all pixels beyond the oval shape transparent. final UrigetCaptureImageOutputUriContent(Context context)Get URI to image received from capture by camera. final StringgetCaptureImageOutputUriFilePath(Context context, Boolean uniqueName)Get File Path to image received from capture by camera. final static UrigetPickImageResultUriContent(Context context, Intent data)Get the URI of the selected image Will return the correct URI for camera and gallery image. final static StringgetPickImageResultUriFilePath(Context context, Intent data, Boolean uniqueName)Get the File Path of the selected imagecontext used to access Android APIs, like content resolve, it is your activity/fragment/widget. final StringgetCROP_IMAGE_EXTRA_SOURCE()The key used to pass crop image source URI to CropImageActivity. final StringgetCROP_IMAGE_EXTRA_OPTIONS()The key used to pass crop image options to CropImageActivity. final StringgetCROP_IMAGE_EXTRA_BUNDLE()The key used to pass crop image bundle data to CropImageActivity. final StringgetCROP_IMAGE_EXTRA_RESULT()The key used to pass crop image result data back from CropImageActivity. final IntegergetCROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE()The result code used to return error from CropImageActivity. -
-
Method Detail
-
toOvalBitmap
final Bitmap toOvalBitmap(Bitmap bitmap)
Create a new bitmap that has all pixels beyond the oval shape transparent. Old bitmap is recycled.
-
getCaptureImageOutputUriContent
@Deprecated(message = This will become obsolete. There will be no replacement. In case you need this, please raise an issue and explain your use case.) final Uri getCaptureImageOutputUriContent(Context context)
Get URI to image received from capture by camera.
This is not the File Path, for it please use getCaptureImageOutputUriFilePath
context used to access Android APIs, like content resolve, it is your activity/fragment/widget.
-
getCaptureImageOutputUriFilePath
@Deprecated(message = This will become obsolete. There will be no replacement. In case you need this, please raise an issue and explain your use case.) final String getCaptureImageOutputUriFilePath(Context context, Boolean uniqueName)
Get File Path to image received from capture by camera.
context used to access Android APIs, like content resolve, it is your activity/fragment/widget. uniqueName If true, make each image cropped have a different file name, this could cause memory issues, use wisely. Default: false
-
getPickImageResultUriContent
@Deprecated(message = This will become obsolete. There will be no replacement. In case you need this, please raise an issue and explain your use case.) final static Uri getPickImageResultUriContent(Context context, Intent data)
Get the URI of the selected image Will return the correct URI for camera and gallery image.
This is not the File Path, for it please use getPickImageResultUriFilePath
context used to access Android APIs, like content resolve, it is your activity/fragment/widget. data the returned data of the activity result
-
getPickImageResultUriFilePath
@Deprecated(message = This will become obsolete. There will be no replacement. In case you need this, please raise an issue and explain your use case.) final static String getPickImageResultUriFilePath(Context context, Intent data, Boolean uniqueName)
Get the File Path of the selected image
context used to access Android APIs, like content resolve, it is your activity/fragment/widget. data the returned data of the activity result uniqueName If true, make each image cropped have a different file name, this could cause memory issues, use wisely. Default: false
-
getCROP_IMAGE_EXTRA_SOURCE
final String getCROP_IMAGE_EXTRA_SOURCE()
The key used to pass crop image source URI to CropImageActivity.
-
getCROP_IMAGE_EXTRA_OPTIONS
final String getCROP_IMAGE_EXTRA_OPTIONS()
The key used to pass crop image options to CropImageActivity.
-
getCROP_IMAGE_EXTRA_BUNDLE
final String getCROP_IMAGE_EXTRA_BUNDLE()
The key used to pass crop image bundle data to CropImageActivity.
-
getCROP_IMAGE_EXTRA_RESULT
final String getCROP_IMAGE_EXTRA_RESULT()
The key used to pass crop image result data back from CropImageActivity.
-
getCROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE
final Integer getCROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE()
The result code used to return error from CropImageActivity.
-
-
-
-