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 |
| 15 | * Pinch to zoom |
| 16 | * Panning while zooming |
| 17 | * One finger pan with momentum |
| 18 | * Can be easily extended to add overlays |
| 19 | * Tiles over 2048px are avoided to support hardware acceleration |
| 20 | |
| 21 | Limitations: |
| 22 | * Requires SDK 10 (Gingerbread). |
| 23 | * BitmapRegionDecoder does not support decoding an image from resources - the image file needs to be in assets or external storage. |
| 24 | * 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. |
| 25 | * Does not support changing the image after one is loaded. This is another fairly simple change. |
David Morrissey | 260aec2 | 2013-08-29 23:31:20 +0100 | [diff] [blame^] | 26 | * This view does not extend ImageView so attributes including android:tint, android:scaleType and android:src are not supported. |