davemorrissey | b064b0b | 2013-08-26 09:45:26 -0700 | [diff] [blame] | 1 | subsampling-scale-image-view |
| 2 | ============================ |
| 3 | |
David Morrissey | 0e895c2 | 2013-08-26 20:07:35 +0100 | [diff] [blame] | 4 | A custom ImageView for Android with pinch to zoom and subsampled tiles to support large images. While zooming in, the |
David Morrissey | 260aec2 | 2013-08-29 23:31:20 +0100 | [diff] [blame] | 5 | low resolution, full size base layer is overlaid with smaller tiles in the best resolution for the current scale, and |
| 6 | tiles are loaded and discarded during panning to avoid holding too much bitmap data in memory. |
David Morrissey | 0e895c2 | 2013-08-26 20:07:35 +0100 | [diff] [blame] | 7 | |
David Morrissey | 260aec2 | 2013-08-29 23:31:20 +0100 | [diff] [blame] | 8 | Ideal for use in image gallery apps where the size of the images may be large enough to require subsampling, and where |
| 9 | pinch to zoom is required to view the high resolution detail. |
| 10 | |
| 11 | Tested with images up to 20000x13000px, but such large images are unusably slow to render. |
David Morrissey | 0e895c2 | 2013-08-26 20:07:35 +0100 | [diff] [blame] | 12 | |
| 13 | Supports: |
| 14 | * Display of images of any size |
David Morrissey | f065d6d | 2014-05-30 11:08:33 +0100 | [diff] [blame] | 15 | * Loading from assets or external files |
David Morrissey | 0e895c2 | 2013-08-26 20:07:35 +0100 | [diff] [blame] | 16 | * Pinch to zoom |
| 17 | * Panning while zooming |
| 18 | * One finger pan with momentum |
David Morrissey | 3276a50 | 2013-09-15 12:19:27 +0100 | [diff] [blame] | 19 | * Dynamically swapping image |
David Morrissey | 6543eaf | 2014-05-19 23:41:55 +0100 | [diff] [blame] | 20 | * Dynamically rotating image (0, 90, 180, 270) |
| 21 | * Optional automatic rotation of image based on EXIF |
David Morrissey | 0e895c2 | 2013-08-26 20:07:35 +0100 | [diff] [blame] | 22 | * Can be easily extended to add overlays |
David Morrissey | 8c91045 | 2014-05-21 08:22:45 +0100 | [diff] [blame] | 23 | * Compatible with OnClickListener and OnLongClickListener |
David Morrissey | f065d6d | 2014-05-30 11:08:33 +0100 | [diff] [blame] | 24 | * Works within a ViewPager to create a photo gallery |
David Morrissey | ae86219 | 2014-05-30 12:38:10 +0100 | [diff] [blame] | 25 | * Supports restoring scale, center and orientation after rotate |
David Morrissey | f065d6d | 2014-05-30 11:08:33 +0100 | [diff] [blame] | 26 | * Designed for extension |
| 27 | * Respects maximum bitmap size (in SDK14+ this is Canvas.getMaximumBitmapWidth/Height, for older versions 2048px) |
David Morrissey | 0e895c2 | 2013-08-26 20:07:35 +0100 | [diff] [blame] | 28 | |
| 29 | Limitations: |
| 30 | * Requires SDK 10 (Gingerbread). |
| 31 | * BitmapRegionDecoder does not support decoding an image from resources - the image file needs to be in assets or external storage. |
| 32 | * Very wide or tall images may still cause out of memory errors because each tile has same w:h ratio as the source image. Fixing this should be fairly easy if required. |
David Morrissey | 260aec2 | 2013-08-29 23:31:20 +0100 | [diff] [blame] | 33 | * This view does not extend ImageView so attributes including android:tint, android:scaleType and android:src are not supported. |
David Morrissey | 6543eaf | 2014-05-19 23:41:55 +0100 | [diff] [blame] | 34 | * Images stored in assets cannot be rotated based on EXIF. This shouldn't be a problem as you'll know the orientation of your files. |