|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.herroworld.imagegrabber.ImageWorker
com.herroworld.imagegrabber.ImageResizer
public class ImageResizer
A simple subclass of ImageWorker
that resizes images from resources
given a target width and height. Useful for when the input images might be
too large to simply load directly into memory.
Constructor Summary | |
---|---|
ImageResizer(Context context,
int imageSize)
Initialize providing a single target image size (used for both width and height); |
|
ImageResizer(Context context,
int imageWidth,
int imageHeight)
Initialize providing a single target image size (used for both width and height); |
Method Summary | |
---|---|
static int |
calculateInSampleSize(BitmapFactory.Options options,
int reqWidth,
int reqHeight)
Calculate an inSampleSize for use in a BitmapFactory.Options
object when decoding bitmaps using the decode* methods from
BitmapFactory . |
static Bitmap |
decodeSampledBitmapFromFile(java.lang.String filename,
int reqWidth,
int reqHeight)
Decode and sample down a bitmap from a file to the requested width and height. |
static Bitmap |
decodeSampledBitmapFromResource(Resources res,
int resId,
int reqWidth,
int reqHeight)
Decode and sample down a bitmap from resources to the requested width and height. |
void |
setImageSize(int size)
Set the target image size (width and height will be the same). |
void |
setImageSize(int width,
int height)
Set the target image width and height. |
Methods inherited from class com.herroworld.imagegrabber.ImageWorker |
---|
cancelWork, getImageCache, loadImage, setAlwaysFetchFromServer, setExitTasksEarly, setFadeInTime, setImageCache, setImageFadeIn, setLoadingImage |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ImageResizer(Context context, int imageWidth, int imageHeight)
context
- imageWidth
- imageHeight
- public ImageResizer(Context context, int imageSize)
context
- imageSize
- Method Detail |
---|
public void setImageSize(int width, int height)
width
- height
- public void setImageSize(int size)
size
- public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight)
res
- The resources object containing the image dataresId
- The resource id of the image datareqWidth
- The requested width of the resulting bitmapreqHeight
- The requested height of the resulting bitmap
public static Bitmap decodeSampledBitmapFromFile(java.lang.String filename, int reqWidth, int reqHeight)
filename
- The full path of the file to decodereqWidth
- The requested width of the resulting bitmapreqHeight
- The requested height of the resulting bitmap
public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
BitmapFactory.Options
object when decoding bitmaps using the decode* methods from
BitmapFactory
. This implementation calculates the closest
inSampleSize that will result in the final decoded bitmap having a width
and height equal to or larger than the requested width and height. This
implementation does not ensure a power of 2 is returned for inSampleSize
which can be faster when decoding but results in a larger bitmap which
isn't as useful for caching purposes.
options
- An options object with out* params already populated (run
through a decode* method with inJustDecodeBounds==truereqWidth
- The requested width of the resulting bitmapreqHeight
- The requested height of the resulting bitmap
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |