java.lang.Object | |
↳ | com.pdftron.pdf.utils.ImageMemoryCache |
This class handles image memory caching to avoid allocating/de-allocating bitmaps by reusing them
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
addBitmapToCache(String key, BitmapDrawable bitmap)
Adds a new image to the memory and disk caches
| ||||||||||
void |
addBitmapToReusableSet(Bitmap bitmap)
Adds the specified bitmap to reusable set
| ||||||||||
void |
clearAll()
Clears all cached bitmaps including the reusable bitmap set.
| ||||||||||
void |
clearCache()
Clears caches (but still keeps the weak reference to the reusable bitmaps).
| ||||||||||
Bitmap |
decodeSampledBitmapFromDescriptor(FileDescriptor fileDescriptor, int reqWidth, int reqHeight)
Decode and sample down a bitmap from a file input stream to the requested width and height.
| ||||||||||
Bitmap |
decodeSampledBitmapFromFile(String filename, int reqWidth, int reqHeight)
Decode and sample down a bitmap from a file to the requested width and height.
| ||||||||||
Bitmap |
decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight)
Decode and sample down a bitmap from resources to the requested width and height.
| ||||||||||
Bitmap |
decodeSampledBitmapFromResource(Resources res, int resId, float downSampleFactor)
Decode and sample down a bitmap from resources to the requested width and height.
| ||||||||||
BitmapDrawable |
getBitmapFromCache(String key)
Returns bitmap having the specified key from cache
| ||||||||||
Bitmap |
getBitmapFromReusableSet(int width, int height, Bitmap.Config config)
Returns a bitmap with specified configuration from the reusable set
| ||||||||||
static ImageMemoryCache | getInstance() | ||||||||||
static void | setDebug(boolean debug) | ||||||||||
void |
setMemCacheSize(int memCacheSize)
Sets the memory cache size.
| ||||||||||
void |
setMemCacheSizePercent(float percent)
Sets the memory cache size based on a percentage of the max available VM memory.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Adds a new image to the memory and disk caches
key | The key used to store the image |
---|---|
bitmap | The bitmap to cache |
Adds the specified bitmap to reusable set
bitmap | The bitmap |
---|
Clears all cached bitmaps including the reusable bitmap set.
Clears caches (but still keeps the weak reference to the reusable bitmaps).
Decode and sample down a bitmap from a file input stream to the requested width and height.
fileDescriptor | The file descriptor to read from |
---|---|
reqWidth | The requested width of the resulting bitmap |
reqHeight | The requested height of the resulting bitmap |
Decode and sample down a bitmap from a file to the requested width and height.
filename | The full path of the file to decode |
---|---|
reqWidth | The requested width of the resulting bitmap, 0 for no down-sampling |
reqHeight | The requested height of the resulting bitmap, 0 for no down-sampling |
Decode and sample down a bitmap from resources to the requested width and height.
res | The resources object containing the image data |
---|---|
resId | The resource id of the image data |
reqWidth | The requested width of the resulting bitmap, 0 for no down-sampling |
reqHeight | The requested height of the resulting bitmap, 0 for no down-sampling |
Decode and sample down a bitmap from resources to the requested width and height.
res | The resources object containing the image data |
---|---|
resId | The resource id of the image data |
downSampleFactor | The down-sampling factor, 1.0 for no down-sampling |
Returns bitmap having the specified key from cache
key | The bitmap key |
---|
Returns a bitmap with specified configuration from the reusable set
width | The expected width |
---|---|
height | The expected height |
config | The bitmap configuration |
Sets the memory cache size.
memCacheSize | The memory cache size |
---|
Sets the memory cache size based on a percentage of the max available VM memory. Eg. setting percent to 0.2 would set the memory cache to one fifth of the available memory. Throws IllegalArgumentException if percent is < 0.01 or > .8. memory cache size is stored in kilobytes instead of bytes as this will eventually be passed to construct a LruCache which takes an int in its constructor.
percent | Percent of available app memory to use to size memory cache |
---|