import android.content.ContentResolver;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import com.adobe.xmp.XMPException;
import com.adobe.xmp.XMPMeta;
+import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.exif.ExifInterface;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
* @param uri URI of image to open.
* @param context context whose ContentResolver to use.
* @param maxSideLength max side length of returned bitmap.
- * @param originalBounds set to the actual bounds of the stored bitmap.
+ * @param originalBounds If not null, set to the actual bounds of the stored bitmap.
+ * @param useMin use min or max side of the original image
* @return downsampled bitmap or null if this operation failed.
*/
public static Bitmap loadConstrainedBitmap(Uri uri, Context context, int maxSideLength,
- Rect originalBounds) {
- if (maxSideLength <= 0 || originalBounds == null || uri == null || context == null) {
+ Rect originalBounds, boolean useMin) {
+ if (maxSideLength <= 0 || uri == null || context == null) {
throw new IllegalArgumentException("bad argument to getScaledBitmap");
}
// Get width and height of stored bitmap
Rect storedBounds = loadBitmapBounds(context, uri);
- originalBounds.set(storedBounds);
+ if (originalBounds != null) {
+ originalBounds.set(storedBounds);
+ }
int w = storedBounds.width();
int h = storedBounds.height();
}
// Find best downsampling size
- int imageSide = Math.max(w, h);
+ int imageSide = 0;
+ if (useMin) {
+ imageSide = Math.min(w, h);
+ } else {
+ imageSide = Math.max(w, h);
+ }
int sampleSize = 1;
while (imageSide > maxSideLength) {
imageSide >>>= 1;
*/
public static Bitmap loadOrientedConstrainedBitmap(Uri uri, Context context, int maxSideLength,
int orientation, Rect originalBounds) {
- Bitmap bmap = loadConstrainedBitmap(uri, context, maxSideLength, originalBounds);
+ Bitmap bmap = loadConstrainedBitmap(uri, context, maxSideLength, originalBounds, false);
if (bmap != null) {
bmap = orientBitmap(bmap, orientation);
}