B4A Library CropImageView V1.0

DonManfred

Expert
Licensed User
Longtime User
if i do load another image after cropping one with
B4X:
    Dim b As Bitmap
    b.Initialize(File.DirAssets,"mycats.jpg")
    civ.ImageBitmap = b

the image is shown in crop-tool...
When i crop again i get a cropped image of the new loaded image.

So. It is working for me

Also, some images won't display but will still crop - memory?
maybe you can see additional information in the (unfiltered) log
 

MaFu

Well-Known Member
Licensed User
Longtime User
Great Lib!
One question. Why I cant access all parts of the image (there is some margin and then inside is crop panel). Because maybe I want to crop part of the image that is in some corner.

Thanks

Damn. It seems my message gone lost on server change.

The next version of my MFLib contains a "Cropper" view. This view looks like CropImageView but it's a complete rewrite from scratch for B4A (and not a wrapper). It hasn't the margin problem and a few extras (no resources needed, visible feedback of dragged corner, adjustable colors).
Due to my spare time at the moment (i'm busy with other projects) the new lib will not ready before january.
 

DavideV

Active Member
Licensed User
Longtime User
Hi DonManfred, really great lib.
It could be my mistake but i can't get FixedAspectRatio and SetAspectRatio to work, the first (FixedAspectRatio=true) displays a vertical, fixed crop area non-adjustable and this could be right.
Then i apply the second, say civ.setAspectRatio(50,50), and does nothing.
Also with FixedAspectRatio=false the crop area doesn't change with SetaspectRatio.
Could you please check or post a little example?

My goal is to get a square cropped image

Thx in advance

DavideV
 

kreativa

Member
Licensed User
Longtime User
Hi everybody,
Just a question. Is there a way to define the position and the dimensions of the initial rect, used to crop the image?

Thanks!
 

schalkgreyling

Member
Licensed User
Longtime User
I have the same issue, have you been able to solve it?

Kind Regards

Hi DavideV,

I have the same issue, have you been able to solve it?

Kind Regards
 

schalkgreyling

Member
Licensed User
Longtime User
I
Hi schalkgreyling,
unfortunately not

Bye

I do the following after choosing an image from library:

B4X:
        Dim b As Bitmap
        b.Initialize("",file_loc)
        CropImageView1.setAspectRatio(5,5)
        CropImageView1.FixedAspectRatio = True
        CropImageView1.ImageBitmap = b

The crop aspect ratio is a tall almost 20x1 shape, but Surprisingly when I select a picture again, it goes to the (a X a) block shape and locks it. It would seem like something initialises after the image was loaded. I have tried applying the crop at different stages that the CropImageView loads, but the only thing that works seems to be a second image selection. I'll let you know if I find a solution.
 

DavideV

Active Member
Licensed User
Longtime User


Nice, good to know
 

schalkgreyling

Member
Licensed User
Longtime User
Nice, good to know
Interesting Solution:
B4X:
Activity.LoadLayout("image_upload")
Dim c As Bitmap
c.Initialize(File.DirAssets,"images.png")
CropImageView1.ImageBitmap = c
CropImageView1.setAspectRatio(5,5)
CropImageView1.FixedAspectRatio = True
CropImageView1.Visible = False


Sub chooser_Result(Success As Boolean, Dir As String, FileName As String)
    If Success Then
Dim file_loc As String
file_loc = GetPathFromContentResult(FileName)
Dim b As Bitmap
b.Initialize("",file_loc)
CropImageView1.setAspectRatio(5,5)
CropImageView1.FixedAspectRatio = True
CropImageView1.ImageBitmap = b

I load a blank image into the CropImageView1 as the layout is loaded and set the visibility to false. Then when I select an image from the gallery and set visibility to true, the crop works perfectly.
 

Luiz Fernando Orlandini

Active Member
Licensed User
Longtime User
Hi there!

After I started using this library with B4A 6.0 my APP starts to crash.

Attached the exception.

Any thoughts?

Thanks.
 

Attachments

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

DonManfred

Expert
Licensed User
Longtime User
Any thoughts?
- we dont see any code
- Based on error yor ar missing a ressource. Forget to add #additionalres?
- Sou should post the error from the logwindow instead of a screenshot. Rightclick copy all
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
After I started using this library with B4A 6.0 my APP starts to crash.
I tried the sample with b4a 6 and it works fine here!

I checked the Resourcesfolder. It is available here. It is present in the ExampleZIP too.

If you add the lib to your project then you need to add the #additionalres directive for this lib too to match the folder where the resources are placed.

Make sure you added
B4X:
#AdditionalRes: ..\resources
pointing to the correct path of the resourcefolde of this lib.
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
Curious,

Why when I load in some images, there is a dark tinted sub area that is smaller then the image size, but the crop window will only move around in this dark tinted area and I cant get the crop square to move to places on the image outside of the dark tinted area.

Anybody know why?
 

artsoft

Active Member
Licensed User
Longtime User
Hi all!

The same issue as other developers here:
I have to crop an image with fix square ratio. The width and the height have to be equal. So I try all solutions but no success until today.

See the screenshot below!

This is my code:

B4X:
Dim b2 as Bitmap
b2 = LoadBitmap(pwdinput.ez_path, pwdinput.ez_file)
crop.Visible = False
crop.ImageBitmap = b2
crop.rotateImage(90)
crop.setAspectRatio(5, 5)
crop.FixedAspectRatio = True
crop.Visible = True

And there is currently no way to crop square sections from the loaded image.

So, what could be the problem here?

Thx in advance to all helpers.

Regards
ARTsoft
 

Attachments

  • cropTest.png
    98.8 KB · Views: 295

MaFu

Well-Known Member
Licensed User
Longtime User
Responsive to some questions and problems in this thread:
The ImageCropper of my MFLib 2 ...
... can get and set crop position/dimension programmatically
... has no border area, the crop rectangle can moved/sized to the outmost bounds
... has working aspect ratio
 

scsjc

Well-Known Member
Licensed User
Longtime User
Hello Don Manfred,
i dont know where are my mistake.... some images can't select all image only center....

 

scsjc

Well-Known Member
Licensed User
Longtime User
What is the question? I did not understand

I dont know why cant select all image only the center.... in this image can see the Zone-Select is only in the midle and can't move to select left corner, right corner ...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…