Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When you specify
CropImageOptions.allowCounterRotation = true
, thecrop_image_menu_rotate_left
MenuItem
is shown. When it is selected, the coderotateImage(-mOptions.rotationDegrees);
is executed. Yet therotateImage
method expected a value between 0 and 360. This creates unexpected behavior when one rotates an image counter-clockwise and the image's crop rectangle is not a square, or whenCropImageOptions.rotationDegrees
is set to an unusual value, such as 450 or -90.I've fixed the
CropImageView.rotateImage(int)
method. At the beginning of the method, I ensure that thedegrees
parameter be in the range [0, 360]. Now, becausedegrees
is always non-negative, I can simplify the computation that changesmDegreesRotated
. Additionally, the computation forflipAxes
was missing parentheses, so I fixed that as well.It should be noted that the forcing of the degrees to a non-zero value in the range
[0,360)
can be simplified to just:I left the more verbose
if
statement to make it more obvious what the code was doing.Collectively, these changes ensure that the image is correctly rotated, even if the value passed in is outside of the range [0, 360]. This is particularly important for counter-clockwise rotations.