BABCropperView icon indicating copy to clipboard operation
BABCropperView copied to clipboard

more cropping behavior control

Open macness-pavelh opened this issue 6 years ago • 0 comments

This fixes #24 and more. Take it as a proposal how to extend this handy tool.

Motivation: for you service avatar you need an image of size 200x200 to 1000x1000 pixels. Currently it's only possible to set fixed cropped size - what will result to discarding some pixels if the selected image source rect is bigger then 200px.

The maximumCropOversize defines what is allowed ratio between requested cropSize and maximal cropped size if the source rectangle provided enough pixels. If we specify cropSize = (200, 200) and maximumCropOversize = 5.0 the cropped size will

a) never be less then 200x200 (imageRect <= 200x200) b) wil be in range 200..<1000 (imageRect > 200x200 AND imageRect <=1000x1000) c) will never exceed 1000x1000 (imageRect > 1000x1000)

In addition I added maximumImageUpscale defining amount the image can be stretched to fill wanted cropSize. Default is 0 - what will result to legacy behavior when the maxZoomScale for the scroll view is set to 4.0.

Non-zero value defines how much the image can be zoomed before cropping.

a) maximumImageUpscale = 1 image can be zoomed so that imageRect will never be smaller then cropSize b) maximumImageUpscale = 2 image can be zoomed up to a half size of wanted cropSize c) `maximumImageUpscale < 1.0 is not tested and possibly a bit undefined (and does not make much sense)

I hope you will find these changes useful. At least I tried to keep legacy behavior in all cases.

macness-pavelh avatar Mar 08 '18 13:03 macness-pavelh