diff options
-rw-r--r-- | res/values/strings.xml | 8 | ||||
-rw-r--r-- | src/com/android/camera/data/LocalMediaData.java | 17 | ||||
-rw-r--r-- | src/com/android/camera/data/RotationTask.java | 12 | ||||
-rw-r--r-- | src/com/android/camera/ui/FilmStripView.java | 37 | ||||
-rw-r--r-- | src/com/android/camera/ui/ZoomView.java | 12 |
5 files changed, 43 insertions, 43 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 880da21c8..ae8ac0b05 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -112,7 +112,7 @@ <string name="height">Height</string> <!-- Text indicating the orientation of a media item in details window [CHAR LIMIT=14] --> <string name="orientation">Orientation</string> - <!-- Text indicating the duration of a video item in details window [CHAR LIMIT=14] --> + <!-- Text indicating the duration of a video item in details window [CHAR LIMIT=18] --> <string name="duration">Duration</string> <!-- Text indicating the mime type of a media item in details window [CHAR LIMIT=14] --> <string name="mimetype">MIME type</string> @@ -128,7 +128,7 @@ <string name="aperture">Aperture</string> <!-- Text indicating the focal length of a media item in details window [CHAR LIMIT=14] --> <string name="focal_length">Focal Length</string> - <!-- Text indicating the white balance of a media item in details window [CHAR LIMIT=14] --> + <!-- Text indicating the white balance of a media item in details window [CHAR LIMIT=18] --> <string name="white_balance">White balance</string> <!-- Text indicating the exposure time of a media item in details window [CHAR LIMIT=14] --> <string name="exposure_time">Exposure time</string> @@ -137,9 +137,9 @@ <!-- String indicating the time units in seconds. [CHAR LIMIT=8] --> <!-- String indicating the length units in milli-meters. [CHAR LIMIT=8] --> <string name="unit_mm">mm</string> - <!-- String indicating how camera shooting feature is used. [CHAR LIMIT=8] --> + <!-- String indicating how camera shooting feature is used. [CHAR LIMIT=12] --> <string name="manual">Manual</string> - <!-- String indicating how camera shooting feature is used. [CHAR LIMIT=8] --> + <!-- String indicating how camera shooting feature is used. [CHAR LIMIT=12 --> <string name="auto">Auto</string> <!-- String indicating camera flash is fired. [CHAR LIMIT=14] --> <string name="flash_on">Flash fired</string> 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() { diff --git a/src/com/android/camera/ui/ZoomView.java b/src/com/android/camera/ui/ZoomView.java index ca9747b0d..f7b645341 100644 --- a/src/com/android/camera/ui/ZoomView.java +++ b/src/com/android/camera/ui/ZoomView.java @@ -103,7 +103,17 @@ public class ZoomView extends ImageView { } BitmapFactory.Options options = new BitmapFactory.Options(); - options.inSampleSize = getSampleFactor(region.width(), region.height()); + + if ((mOrientation + 360) % 180 == 0) { + options.inSampleSize = getSampleFactor(region.width(), region.height()); + } else { + // The decoded region will be rotated 90/270 degrees before showing + // on screen. In other words, the width and height will be swapped. + // Therefore, sample factor should be calculated using swapped width + // and height. + options.inSampleSize = getSampleFactor(region.height(), region.width()); + } + if (mRegionDecoder == null) { InputStream is = getInputStream(); try { |