public abstract class DownsampleStrategy extends Object
| Modifier and Type | Class and Description | 
|---|---|
| static class  | DownsampleStrategy.SampleSizeRoundingIndicates whether to prefer to prefer downsampling or scaling to prefer lower memory usage
 or higher quality. | 
| Modifier and Type | Field and Description | 
|---|---|
| static DownsampleStrategy | AT_LEASTDownsamples so the image's smallest dimension is between the given dimensions and 2x the given
 dimensions, with no size restrictions on the image's largest dimension. | 
| static DownsampleStrategy | AT_MOSTDownsamples so the image's largest dimension is between 1/2 the given dimensions and the given
 dimensions, with no restrictions on the image's smallest dimension. | 
| static DownsampleStrategy | CENTER_INSIDEReturns the original image if it is smaller than the target, otherwise it will be downscaled
 maintaining its original aspect ratio, so that one of the image's dimensions is exactly equal
 to the requested size and the other is less or equal than the requested size. | 
| static DownsampleStrategy | CENTER_OUTSIDEScales, maintaining the original aspect ratio, so that one of the image's dimensions is
 exactly equal to the requested size and the other dimension is greater than or equal to
 the requested size. | 
| static DownsampleStrategy | DEFAULTDefault strategy, currently  CENTER_OUTSIDE. | 
| static DownsampleStrategy | FIT_CENTERScales, maintaining the original aspect ratio, so that one of the image's dimensions is
 exactly equal to the requested size and the other dimension is less than or equal to the
 requested size. | 
| static DownsampleStrategy | NONEPerforms no downsampling or scaling. | 
| Constructor and Description | 
|---|
| DownsampleStrategy() | 
| Modifier and Type | Method and Description | 
|---|---|
| abstract DownsampleStrategy.SampleSizeRounding | getSampleSizeRounding(int sourceWidth,
                     int sourceHeight,
                     int requestedWidth,
                     int requestedHeight)Returns a non-null  DownsampleStrategy.SampleSizeRoundingto use to resolve rounding errors and conflicts
 between scaling for the width and the height of the image. | 
| abstract float | getScaleFactor(int sourceWidth,
              int sourceHeight,
              int requestedWidth,
              int requestedHeight)Returns a float (0, +infinity) indicating a scale factor to apply to the source
 width and height when displayed in the requested width and height. | 
public static final DownsampleStrategy FIT_CENTER
This method will upscale if the requested width and height are greater than the source width
 and height. To avoid upscaling, use AT_LEAST, AT_MOST or
 CENTER_INSIDE.
 
On pre-KitKat devices, this is equivalent to AT_MOST because only power of
 two downsampling can be used.
public static final DownsampleStrategy CENTER_OUTSIDE
This method will upscale if the requested width and height are greater than the source width
 and height. To avoid upscaling, use AT_LEAST, AT_MOST,
 or CENTER_INSIDE.
 
On pre-KitKat devices, this is equivalent to AT_LEAST because only power of
 two downsampling can be used.
public static final DownsampleStrategy AT_LEAST
public static final DownsampleStrategy AT_MOST
public static final DownsampleStrategy CENTER_INSIDE
This method will not upscale.
public static final DownsampleStrategy NONE
public static final DownsampleStrategy DEFAULT
CENTER_OUTSIDE.public abstract float getScaleFactor(int sourceWidth,
                                     int sourceHeight,
                                     int requestedWidth,
                                     int requestedHeight)
The returned scale factor will be split into a power of two sample size applied via
 BitmapFactory.Options.inSampleSize and a float scale factor applied
 after downsampling via BitmapFactory.Options.inTargetDensity and
 BitmapFactory.Options.inDensity. Because of rounding errors the scale
 factor may not be applied precisely.
 
The float scaling factor will only be applied on KitKat+. Prior to KitKat, only the power of two downsampling will be applied.
sourceWidth - The width in pixels of the image to be downsampled.sourceHeight - The height in pixels of the image to be downsampled.requestedWidth - The width in pixels of the view/target the image will be displayed in.requestedHeight - The height in pixels of the view/target the image will be displayed in.public abstract DownsampleStrategy.SampleSizeRounding getSampleSizeRounding(int sourceWidth, int sourceHeight, int requestedWidth, int requestedHeight)
DownsampleStrategy.SampleSizeRounding to use to resolve rounding errors and conflicts
 between scaling for the width and the height of the image.sourceWidth - The width in pixels of the image to be downsampled.sourceHeight - The height in pixels of the image to be downsampled.requestedWidth - The width in pixels of the view/target the image will be displayed in.requestedHeight - The height in pixels of the view/target the image will be displayed in.