B4A Library [Library] RSCrop - Crop images with gallery

Hey everyone,

For an app i'm developing, I needed to let the user crop a piece of a bitmap to use in my app.
I stumbled on this thread: http://www.b4x.com/forum/basic4android-updates-questions/19550-resize-crop.html
but it lacked some features like pinching, rectangular cropping, resizing, zoom and panning and more.

After some googling, i figured out that you could send an intent to the default media gallery to let it crop your images.

It opens your gallery where you select your image and then the cropping activity opens. After the cropping is done, an event is raised with the Path and a success boolean.
3 Functions are needed to get you going:

B4X:
Sub mnuCrop_Click
Dim CropImage As RSCrop
CropImage.Initialize("CropImage", "image.jpg")
CropImage.CropImage2(True, False, False, False)
End Sub

Sub CropImage_Cropped (Success As Boolean, Pathname As String)
   If Success = True Then
      ToastMessageShow("Successfully cropped!", True)
      ToastMessageShow("Path: " & Pathname, True)
   Else
      ToastMessageShow(Pathname, False)
   End If
End Sub


After the cropping is done, the image is saved to your file.dirExternal and the filename is the one you specified in your initialize method.

Regards,
Tomas

Edit: If people would like to test:
I would like to know on which devices this work: API level (android version) and phone
Preferably I need Galaxy Note support
 

Attachments

  • RSCrop.zip
    4.8 KB · Views: 1,225
Last edited:

Luiz Fernando Orlandini

Active Member
Licensed User
Longtime User
Hello folks.

I'm trying to use this lib with B4A 6.0 and getting the attached exception which crash my App, when I try to open a new Activity.
 

Attachments

  • Screen Shot 2016-07-04 at 12.40.37 AM.png
    152.7 KB · Views: 216

Mashiane

Expert
Licensed User
Longtime User
THis is
This is so perferct!!
 

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Guys

The last parameter in this line shows CircleCrop

B4X:
CropImage.CropImage2(True, True, False, True)

Did anyone get it to work as circleCrop

Thanks in advance
 

ykucuk

Well-Known Member
Licensed User
Longtime User
I tried with Samsung Galaxy S5 and Samsung Note 5.

The application asks me 2 times for select image and shows dialog after the second select.

Note5 never shows me crop dialog and Galaxy 5 show.

Any help?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…