CanHub / Android-Image-Cropper

Image Cropping Library for Android, optimised for Camera / Gallery.
https://canhub.github.io/
Apache License 2.0
1.17k stars 240 forks source link

How to use CropImageView in Compose? #596

Open phongbm opened 8 months ago

phongbm commented 8 months ago

I want to use CropImageView in Compose project, how to do that?

Pantsoffski commented 6 months ago

Like this:

val cropImage = rememberLauncherForActivityResult(CropImageContract()) { result -> if (result.isSuccessful) { // Use the returned uri. val uriContent = result.uriContent val uriFilePath = result.getUriFilePath(context) // optional usage } else { // An error occurred. val exception = result.error } }

and start with e.g. this:

cropImage.launch( CropImageContractOptions( uri = null, cropImageOptions = CropImageOptions( imageSourceIncludeGallery = true, imageSourceIncludeCamera = false, fixAspectRatio = true // aspectRatioX = 1, // aspectRatioY = 1, ) ) )

hoangchungk53qx1 commented 1 month ago

https://gist.github.com/hoangchungk53qx1/b17356cc82515666058b3d53781bf5d5