From 34b8dc315380c13a55c00e623cc8d9c8a844a248 Mon Sep 17 00:00:00 2001 From: seyedalireza Date: Sat, 15 May 2021 23:11:33 +0430 Subject: [PATCH] Feature: add flip function #105 --- .../simplecropview/CropImageView.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/simplecropview/src/main/java/com/isseiaoki/simplecropview/CropImageView.java b/simplecropview/src/main/java/com/isseiaoki/simplecropview/CropImageView.java index b515aa7..233c15d 100644 --- a/simplecropview/src/main/java/com/isseiaoki/simplecropview/CropImageView.java +++ b/simplecropview/src/main/java/com/isseiaoki/simplecropview/CropImageView.java @@ -1398,6 +1398,24 @@ private void resetImageInfo() { mAngle = mExifRotation; } + /** + * Flip Image. + * @param flipMode type of flip operation. + */ + public void flipImage(FlipMode flipMode) { + switch (flipMode) { + case HORIZONTAL: + mMatrix.postScale(-1, 1); + break; + case VERTICAL: + mMatrix.postScale(1, -1); + break; + default: + throw new IllegalStateException("Unexpected value: " + flipMode); + } + updateLayout(); + } + /** * Load image from Uri. * This method is deprecated. Use loadAsync(Uri, LoadCallback) instead. @@ -2356,6 +2374,10 @@ public int getId() { } } + public enum FlipMode { + HORIZONTAL, VERTICAL + } + public enum ShowMode { SHOW_ALWAYS(1), SHOW_ON_TOUCH(2), NOT_SHOW(3); private final int ID;