Merge branch 'master' of github.com:davemorrissey/subsampling-scale-image-view
diff --git a/library/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java b/library/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
index fce83c2..b2ba91c 100644
--- a/library/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
+++ b/library/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
@@ -166,6 +166,11 @@
// Minimum scale type
private int minimumScaleType = SCALE_TYPE_CENTER_INSIDE;
+ // overrides for the dimensions of the generated tiles
+ public static int TILE_SIZE_AUTO = Integer.MAX_VALUE;
+ private int maxTileWidth = TILE_SIZE_AUTO;
+ private int maxTileHeight = TILE_SIZE_AUTO;
+
// Whether to use the thread pool executor to load tiles
private boolean parallelLoadingEnabled;
@@ -1770,19 +1775,41 @@
}
/**
+ * By default the View automatically calculates the optimal tile size. Set this to override this, and force an upper limit to the dimensions of the generated tiles. Passing {@link TILE_SIZE_AUTO} will re-enable the default behaviour.
+ *
+ * @param maxPixels
+ */
+ public void setMaxTileSize(int maxPixels) {
+ this.maxTileWidth = maxPixels;
+ this.maxTileHeight = maxPixels;
+ }
+
+ /**
+ * By default the View automatically calculates the optimal tile size. Set this to override this, and force an upper limit to the dimensions of the generated tiles. Passing {@link TILE_SIZE_AUTO} will re-enable the default behaviour.
+ *
+ * @param maxPixelsX
+ * @param maxPixelsU
+ */
+ public void setMaxTileSize(int maxPixelsX, int maxPixelsY) {
+ this.maxTileWidth = maxPixelsX;
+ this.maxTileHeight = maxPixelsY;
+ }
+
+ /**
* In SDK 14 and above, use canvas max bitmap width and height instead of the default 2048, to avoid redundant tiling.
*/
private Point getMaxBitmapDimensions(Canvas canvas) {
+ int maxWidth = 2048;
+ int maxHeight = 2048;
if (VERSION.SDK_INT >= 14) {
try {
- int maxWidth = (Integer)Canvas.class.getMethod("getMaximumBitmapWidth").invoke(canvas);
- int maxHeight = (Integer)Canvas.class.getMethod("getMaximumBitmapHeight").invoke(canvas);
- return new Point(maxWidth, maxHeight);
+ maxWidth = (Integer)Canvas.class.getMethod("getMaximumBitmapWidth").invoke(canvas);
+ maxHeight = (Integer)Canvas.class.getMethod("getMaximumBitmapHeight").invoke(canvas);
} catch (Exception e) {
// Return default
}
}
- return new Point(2048, 2048);
+ return new Point(Math.min(maxWidth, maxTileWidth), Math.min(maxHeight, maxTileHeight));
}
/**