Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual crop does not work everytime #100

Closed
plisiam opened this issue Apr 21, 2021 · 3 comments · Fixed by #102
Closed

Manual crop does not work everytime #100

plisiam opened this issue Apr 21, 2021 · 3 comments · Fixed by #102
Assignees
Labels
bug Something isn't working

Comments

@plisiam
Copy link

plisiam commented Apr 21, 2021

When an user crops an image, then sometimes the crop action is reverted or modified.

Steps to reproduce - option 1:

  1. Open the crop controller
  2. Tap and drag the LEFT-TOP corner and release
  3. -> the crop view returns to the original position
Screen.Recording.2021-04-21.at.16.31.42.mov

Steps to reproduce - option 2:

  1. Open the crop controller
  2. Tap and drag the TOP edge and release
  3. Tap and drag the LEFT edge and release
  4. -> the crop view is zoomed out
Screen.Recording.2021-04-21.at.16.33.17.mov

Notes

  • It is reproducible also when you move the left-bottom or the right-top corner/edge , but is is not reproducible when moving the right-bottom corner. Once you move the right-bottom corner, then it is not reproducible anymore even when moving other corners.
  • The problem is in the function ImageContainer.contains, which return false when is called from CropView.makeSureImageContainsCropOverlay in the function CropView.adjustUIForNewCrop
  • refBounds.contains(p2) returns false, because of the precision/tolerance which is used. Check the prints of values from the function
    • bounds (0.0, 0.0, 341.3333333333333, 512.0)
    • refBounds (-1e-06, -1e-06, 341.3333353333333, 512.000002)
    • p1 (5.87109375, 11.089843749999973)
    • p2 (341.20442708333326, 512.08984375)
  • The contains functions works correctly when called from updateCropBoxFrame

Suggested solution 1

  • change the tolerance to 1 or 0.5 or so
  • it could be a parameter in the ImageContainer.contains function and it would be changed only when calling from CropView.adjustUIForNewCrop

Suggested solution 2

  • Do not call makeSureImageContainsCropOverlay in the function CropView.adjustUIForNewCrop every time
  • I did not find, how the cropOverlay would end up out of bounds of the image just by dragging the corners.
  • Maybe we can call makeSureImageContainsCropOverlay in adjustUIForNewCrop only when adjustUIForNewCrop is called after setting the fixed ratio or after rotating
@guoyingtao guoyingtao self-assigned this Apr 21, 2021
@guoyingtao guoyingtao added the bug Something isn't working label Apr 21, 2021
@guoyingtao
Copy link
Owner

@plisiam Thanks for the report and suggestions!
I fixed it in a branch. Would you mind helping to check if it solve the issue by using the commit below? Thank you very much!

pod 'Mantis', :git => 'https://github.com/guoyingtao/Mantis.git', :commit => '92cbf5f408baf9132082499d8caae47c7d887b7a'

@plisiam
Copy link
Author

plisiam commented Apr 22, 2021

Hi, thanks for the quick fix.
0.25 is probably ok. I can't replicate it anymore.

@plisiam
Copy link
Author

plisiam commented Apr 22, 2021

Unfortunately I found one more bug with a similar symptoms, but probably different root cause. I'll enter it separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants