diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-10-09 01:15:42 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-10-09 01:15:42 +0200 |
commit | dab194f3763d1a13d6ea55f958314debca0cf2e6 (patch) | |
tree | 61d5aecd4dc6d89a2daa109c431ba8ac48c81481 /src/com/ruesga/android/wallpapers | |
parent | 51d2c34b2cfa2fd34b88e2c38f9429ce1d515dfb (diff) | |
download | android_packages_wallpapers_PhotoPhase-dab194f3763d1a13d6ea55f958314debca0cf2e6.tar.gz android_packages_wallpapers_PhotoPhase-dab194f3763d1a13d6ea55f958314debca0cf2e6.tar.bz2 android_packages_wallpapers_PhotoPhase-dab194f3763d1a13d6ea55f958314debca0cf2e6.zip |
Fix FC on disposition selection
Ensure that MER algorithm always returns a bound rectangle
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/com/ruesga/android/wallpapers')
-rw-r--r-- | src/com/ruesga/android/wallpapers/photophase/utils/MERAlgorithm.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/com/ruesga/android/wallpapers/photophase/utils/MERAlgorithm.java b/src/com/ruesga/android/wallpapers/photophase/utils/MERAlgorithm.java index c7009c3..43701e1 100644 --- a/src/com/ruesga/android/wallpapers/photophase/utils/MERAlgorithm.java +++ b/src/com/ruesga/android/wallpapers/photophase/utils/MERAlgorithm.java @@ -38,6 +38,7 @@ public final class MERAlgorithm { // Check matrix int rows = matrix.length; if (rows == 0) return null; + int cols = matrix[0].length; // Convert to histogram int[][] histogram = toHistogram(matrix); @@ -50,7 +51,21 @@ public final class MERAlgorithm { maxRect = rect; } } - return maxRect; + return ensureBounds(maxRect, cols, rows); + } + + /** + * Method that ensure the bounds of the max rectangle + * + * @param rect The rectangle to check + * @param cols The number of cols + * @param rows The number of rows + * @return Rect The rectangle checked + */ + private static Rect ensureBounds(Rect rect, int cols, int rows) { + if (rect.right - rect.left >= cols) rect.right = cols; + if (rect.bottom - rect.top >= rows) rect.bottom = rows; + return rect; } /** |