summaryrefslogtreecommitdiff
path: root/src/com/android/bitmap/DecodeTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/bitmap/DecodeTask.java')
-rw-r--r--src/com/android/bitmap/DecodeTask.java34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/com/android/bitmap/DecodeTask.java b/src/com/android/bitmap/DecodeTask.java
index ac08c0b..0f12bae 100644
--- a/src/com/android/bitmap/DecodeTask.java
+++ b/src/com/android/bitmap/DecodeTask.java
@@ -323,8 +323,8 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> {
// if" the orientation has been corrected.
// Center the decode on the top 1/3.
BitmapUtils.calculateCroppedSrcRect(srcW, srcH, mDecodeOpts.destW,
- mDecodeOpts.destH,
- mDecodeOpts.destH, mOpts.inSampleSize, mDecodeOpts.verticalCenter,
+ mDecodeOpts.destH, mDecodeOpts.destH, mOpts.inSampleSize,
+ mDecodeOpts.horizontalCenter, mDecodeOpts.verticalCenter,
true /* absoluteFraction */,
1f, srcRect);
if (DEBUG) {
@@ -553,6 +553,12 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> {
public int destH;
/**
* If the destination dimensions are smaller than the source image provided by the request
+ * key, this will determine where horizontally the destination rect will be cropped from.
+ * Value from 0f for left-most crop to 1f for right-most crop.
+ */
+ public float horizontalCenter;
+ /**
+ * If the destination dimensions are smaller than the source image provided by the request
* key, this will determine where vertically the destination rect will be cropped from.
* Value from 0f for top-most crop to 1f for bottom-most crop.
*/
@@ -563,22 +569,40 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> {
public int sampleSizeStrategy;
public DecodeOptions(final int destW, final int destH) {
- this(destW, destH, 0.5f, STRATEGY_ROUND_NEAREST);
+ this(destW, destH, 0.5f, 0.5f, STRATEGY_ROUND_NEAREST);
+ }
+
+ /**
+ * Create new DecodeOptions with horizontally-centered cropping if applicable.
+ * @param destW The destination width to decode to.
+ * @param destH The destination height to decode to.
+ * @param verticalCenter If the destination dimensions are smaller than the source image
+ * provided by the request key, this will determine where vertically
+ * the destination rect will be cropped from.
+ * @param sampleSizeStrategy One of the STRATEGY constants.
+ */
+ public DecodeOptions(final int destW, final int destH,
+ final float verticalCenter, final int sampleSizeStrategy) {
+ this(destW, destH, 0.5f, verticalCenter, sampleSizeStrategy);
}
/**
* Create new DecodeOptions.
* @param destW The destination width to decode to.
* @param destH The destination height to decode to.
+ * @param horizontalCenter If the destination dimensions are smaller than the source image
+ * provided by the request key, this will determine where
+ * horizontally the destination rect will be cropped from.
* @param verticalCenter If the destination dimensions are smaller than the source image
* provided by the request key, this will determine where vertically
* the destination rect will be cropped from.
* @param sampleSizeStrategy One of the STRATEGY constants.
*/
- public DecodeOptions(final int destW, final int destH, final float verticalCenter,
- final int sampleSizeStrategy) {
+ public DecodeOptions(final int destW, final int destH, final float horizontalCenter,
+ final float verticalCenter, final int sampleSizeStrategy) {
this.destW = destW;
this.destH = destH;
+ this.horizontalCenter = horizontalCenter;
this.verticalCenter = verticalCenter;
this.sampleSizeStrategy = sampleSizeStrategy;
}