aboutsummaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorDavid Morrissey <davemorrissey@gmail.com>2017-11-09 19:24:58 +0000
committerDavid Morrissey <davemorrissey@gmail.com>2017-11-09 19:24:58 +0000
commit22fb5e3b36ebdf9c3a1ef963864c61ef82d48de0 (patch)
tree07a99d587790d332a216d680d2241ead02130240 /library
parent8a9f8f61893c20c9091cf50d3593abb85c38ab6c (diff)
downloadsubsampling-scale-image-view-22fb5e3b36ebdf9c3a1ef963864c61ef82d48de0.tar.gz
#273 #295 Support for setting minimum scale so image fills view and top left corner is shown first - SCALE_TYPE_START
Diffstat (limited to 'library')
-rw-r--r--library/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/library/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java b/library/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
index 177f092..8bf9153 100644
--- a/library/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
+++ b/library/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
@@ -122,8 +122,10 @@ public class SubsamplingScaleImageView extends View {
public static final int SCALE_TYPE_CENTER_CROP = 2;
/** Scale the image so that both dimensions of the image will be equal to or less than the maxScale and equal to or larger than minScale. The image is then centered in the view. */
public static final int SCALE_TYPE_CUSTOM = 3;
+ /** Scale the image so that both dimensions of the image will be equal to or larger than the corresponding dimension of the view. The top left is shown. */
+ public static final int SCALE_TYPE_START = 4;
- private static final List<Integer> VALID_SCALE_TYPES = Arrays.asList(SCALE_TYPE_CENTER_CROP, SCALE_TYPE_CENTER_INSIDE, SCALE_TYPE_CUSTOM);
+ private static final List<Integer> VALID_SCALE_TYPES = Arrays.asList(SCALE_TYPE_CENTER_CROP, SCALE_TYPE_CENTER_INSIDE, SCALE_TYPE_CUSTOM, SCALE_TYPE_START);
/** State change originated from animation. */
public static final int ORIGIN_ANIM = 1;
@@ -1441,7 +1443,7 @@ public class SubsamplingScaleImageView extends View {
fitToBounds(center, satTemp);
scale = satTemp.scale;
vTranslate.set(satTemp.vTranslate);
- if (init) {
+ if (init && minimumScaleType != SCALE_TYPE_START) {
vTranslate.set(vTranslateForSCenter(sWidth()/2, sHeight()/2, scale));
}
}
@@ -2195,7 +2197,7 @@ public class SubsamplingScaleImageView extends View {
private float minScale() {
int vPadding = getPaddingBottom() + getPaddingTop();
int hPadding = getPaddingLeft() + getPaddingRight();
- if (minimumScaleType == SCALE_TYPE_CENTER_CROP) {
+ if (minimumScaleType == SCALE_TYPE_CENTER_CROP || minimumScaleType == SCALE_TYPE_START) {
return Math.max((getWidth() - hPadding) / (float) sWidth(), (getHeight() - vPadding) / (float) sHeight());
} else if (minimumScaleType == SCALE_TYPE_CUSTOM && minScale > 0) {
return minScale;