summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2013-10-07 14:54:55 -0700
committerztenghui <ztenghui@google.com>2013-10-07 17:19:41 -0700
commit06578b59bf15c1ac35dbbffd979f40479b1cbda9 (patch)
treed5b5c1310f9aaf178238c5e3a26fddbf2b149c3c /src/com/android/camera
parent4de788063b51cc2d3f65122bdcc7f862170ba761 (diff)
downloadandroid_packages_apps_Snap-06578b59bf15c1ac35dbbffd979f40479b1cbda9.tar.gz
android_packages_apps_Snap-06578b59bf15c1ac35dbbffd979f40479b1cbda9.tar.bz2
android_packages_apps_Snap-06578b59bf15c1ac35dbbffd979f40479b1cbda9.zip
Keep the ImageData size info consistent with MediaStore and Exif
Basically, the width and hight in the ImageData will be pre-rotation. bug:11067085 Change-Id: I377caf2f1d49d26b4d6823d4e72168a055d80858
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/data/LocalMediaData.java17
-rw-r--r--src/com/android/camera/data/RotationTask.java12
-rw-r--r--src/com/android/camera/ui/FilmStripView.java37
3 files changed, 28 insertions, 38 deletions
diff --git a/src/com/android/camera/data/LocalMediaData.java b/src/com/android/camera/data/LocalMediaData.java
index 8e4b2f280..1f9c725d0 100644
--- a/src/com/android/camera/data/LocalMediaData.java
+++ b/src/com/android/camera/data/LocalMediaData.java
@@ -379,11 +379,7 @@ public abstract class LocalMediaData implements LocalData {
}
}
}
- if (orientation == 90 || orientation == 270) {
- int b = width;
- width = height;
- height = b;
- }
+
long sizeInBytes = c.getLong(COL_SIZE);
double latitude = c.getDouble(COL_LATITUDE);
double longitude = c.getDouble(COL_LONGITUDE);
@@ -519,18 +515,11 @@ public abstract class LocalMediaData implements LocalData {
decodedHeight = justBoundsOpts.outHeight;
}
- int viewWidth = decodedWidth;
- int viewHeight = decodedHeight;
- if (mOrientation == 90 || mOrientation == 270) {
- viewWidth = decodedHeight;
- viewHeight = decodedWidth;
- }
-
// If the width and height is valid and not matching the values
// from MediaStore, then update the MediaStore. This only
// happened when the MediaStore had been told a wrong data.
- if (viewWidth > 0 && viewHeight > 0 &&
- (viewWidth != mWidth || viewHeight != mHeight)) {
+ if (decodedWidth > 0 && decodedHeight > 0 &&
+ (decodedWidth != mWidth || decodedHeight != mHeight)) {
ContentValues values = new ContentValues();
values.put(Images.Media.WIDTH, decodedWidth);
values.put(Images.Media.HEIGHT, decodedHeight);
diff --git a/src/com/android/camera/data/RotationTask.java b/src/com/android/camera/data/RotationTask.java
index 950ae9371..558815a50 100644
--- a/src/com/android/camera/data/RotationTask.java
+++ b/src/com/android/camera/data/RotationTask.java
@@ -121,14 +121,6 @@ public class RotationTask extends AsyncTask<LocalData, Void, LocalData> {
PhotoData result = null;
if (success) {
- // Swap width and height after rotation. The new width and height
- // will be used to create the PhotoData, not used to update
- // MediaStore or Exif. Because we will re-calculate the width and
- // height based on the orientation info.
- int oldWidth = imageData.getWidth();
- int newWidth = imageData.getHeight();
- int newHeight = oldWidth;
-
// MediaStore using SQLite is thread safe.
values.put(Images.Media.ORIENTATION, finalRotationDegrees);
mContext.getContentResolver().update(imageData.getContentUri(),
@@ -143,8 +135,8 @@ public class RotationTask extends AsyncTask<LocalData, Void, LocalData> {
result = new PhotoData(data.getContentId(), data.getTitle(),
data.getMimeType(), data.getDateTaken(), data.getDateModified(),
- data.getPath(), newOrientation, newWidth, newHeight,
- data.getSizeInBytes(), latitude, longitude);
+ data.getPath(), newOrientation, imageData.getWidth(),
+ imageData.getHeight(), data.getSizeInBytes(), latitude, longitude);
}
return result;
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 26e6bbea8..21f2fc864 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -145,8 +145,9 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
public static final int SIZE_FULL = -2;
/**
- * Returns the width of the image. The final layout of the view returned
- * by {@link DataAdapter#getView(android.app.Activity, int)} will
+ * Returns the width of the image before orientation applied.
+ * The final layout of the view returned by
+ * {@link DataAdapter#getView(android.app.Activity, int)} will
* preserve the aspect ratio of
* {@link com.android.camera.ui.FilmStripView.ImageData#getWidth()} and
* {@link com.android.camera.ui.FilmStripView.ImageData#getHeight()}.
@@ -154,8 +155,9 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
public int getWidth();
/**
- * Returns the width of the image. The final layout of the view returned
- * by {@link DataAdapter#getView(android.app.Activity, int)} will
+ * Returns the height of the image before orientation applied.
+ * The final layout of the view returned by
+ * {@link DataAdapter#getView(android.app.Activity, int)} will
* preserve the aspect ratio of
* {@link com.android.camera.ui.FilmStripView.ImageData#getWidth()} and
* {@link com.android.camera.ui.FilmStripView.ImageData#getHeight()}.
@@ -708,9 +710,14 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
/** Returns [width, height] preserving image aspect ratio. */
private int[] calculateChildDimension(
- int imageWidth, int imageHeight,
+ int imageWidth, int imageHeight, int imageOrientation,
int boundWidth, int boundHeight) {
-
+ if (imageOrientation == 90 || imageOrientation == 270) {
+ // Swap width and height.
+ int savedWidth = imageWidth;
+ imageWidth = imageHeight;
+ imageHeight = savedWidth;
+ }
if (imageWidth == ImageData.SIZE_FULL
|| imageHeight == ImageData.SIZE_FULL) {
imageWidth = boundWidth;
@@ -732,10 +739,9 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
private void measureViewItem(ViewItem item, int boundWidth, int boundHeight) {
int id = item.getId();
- int[] dim = calculateChildDimension(
- mDataAdapter.getImageData(id).getWidth(),
- mDataAdapter.getImageData(id).getHeight(),
- boundWidth, boundHeight);
+ ImageData imageData = mDataAdapter.getImageData(id);
+ int[] dim = calculateChildDimension(imageData.getWidth(), imageData.getHeight(),
+ imageData.getOrientation(), boundWidth, boundHeight);
item.getView().measure(
MeasureSpec.makeMeasureSpec(
@@ -1528,7 +1534,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
final ImageData data = mDataAdapter.getImageData(dataID);
int[] dim = calculateChildDimension(
- data.getWidth(), data.getHeight(),
+ data.getWidth(), data.getHeight(), data.getOrientation(),
getMeasuredWidth(), getMeasuredHeight());
final int offsetX = dim[0] + mViewGap;
ViewItem viewItem = buildItemFromData(dataID);
@@ -1712,7 +1718,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
// If there is no scrolling at all, adjust mCenterX to place
// the current item at the center.
int[] dim = calculateChildDimension(
- data.getWidth(), data.getHeight(),
+ data.getWidth(), data.getHeight(), data.getOrientation(),
getMeasuredWidth(), getMeasuredHeight());
mCenterX = curr.getLeftPosition() + dim[0] / 2;
}
@@ -2133,8 +2139,11 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
.isUIActionSupported(ImageData.ACTION_ZOOM)) {
return FULL_SCREEN_SCALE;
}
- float imageWidth = (float) imageData.getWidth();
- return imageWidth / (float) curr.getWidth();
+ float imageWidth = imageData.getWidth();
+ if (imageData.getOrientation() == 90 || imageData.getOrientation() == 270) {
+ imageWidth = imageData.getHeight();
+ }
+ return imageWidth / curr.getWidth();
}
private void loadZoomedImage() {