summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/camera/PhotoModule.java14
-rwxr-xr-xsrc/com/android/camera/VideoModule.java13
-rw-r--r--src/com/android/camera/util/CameraUtil.java32
3 files changed, 59 insertions, 0 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index cefdeaea6..f7b2e4945 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -3102,6 +3102,20 @@ public class PhotoModule
}
Log.v(TAG, "Preview size is " + optimalSize.width + "x" + optimalSize.height);
+ size = mParameters.getPictureSize();
+
+ // Set jpegthumbnail size
+ // Set a jpegthumbnail size that is closest to the Picture height and has
+ // the right aspect ratio.
+ List<Size> supported = mParameters.getSupportedJpegThumbnailSizes();
+ optimalSize = CameraUtil.getOptimalJpegThumbnailSize(supported,
+ (double) size.width / size.height);
+ original = mParameters.getJpegThumbnailSize();
+ if (!original.equals(optimalSize)) {
+ mParameters.setJpegThumbnailSize(optimalSize.width, optimalSize.height);
+ }
+
+ Log.v(TAG, "Thumbnail size is " + optimalSize.width + "x" + optimalSize.height);
// Since changing scene mode may change supported values, set scene mode
// first. HDR is a scene mode. To promote it in UI, it is stored in a
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 651a3e3a6..eace13fa4 100755
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -2303,6 +2303,19 @@ public class VideoModule implements CameraModule,
Log.v(TAG, "Video snapshot size is " + optimalSize.width + "x" +
optimalSize.height);
+ // Set jpegthumbnail size
+ // Set a jpegthumbnail size that is closest to the Picture height and has
+ // the right aspect ratio.
+ Size size = mParameters.getPictureSize();
+ List<Size> sizes = mParameters.getSupportedJpegThumbnailSizes();
+ optimalSize = CameraUtil.getOptimalJpegThumbnailSize(sizes,
+ (double) size.width / size.height);
+ original = mParameters.getJpegThumbnailSize();
+ if (!original.equals(optimalSize)) {
+ mParameters.setJpegThumbnailSize(optimalSize.width, optimalSize.height);
+ }
+ Log.v(TAG, "Thumbnail size is " + optimalSize.width + "x" + optimalSize.height);
+
// Set JPEG quality.
int jpegQuality = CameraProfile.getJpegEncodingQualityParameter(mCameraId,
CameraProfile.QUALITY_HIGH);
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index cfddf957e..4cfc211bc 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -567,6 +567,38 @@ public class CameraUtil {
return optimalSize;
}
+
+ // Returns the largest thumbnail size which matches the given aspect ratio.
+ public static Size getOptimalJpegThumbnailSize(
+ List<Size> sizes, double targetRatio) {
+ // Use a very small tolerance because we want an exact match.
+ final double ASPECT_TOLERANCE = 0.001;
+ if (sizes == null) return null;
+
+ Size optimalSize = null;
+
+ // Try to find a size matches aspect ratio and has the largest width
+ for (Size size : sizes) {
+ double ratio = (double) size.width / size.height;
+ if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
+ if (optimalSize == null || size.width > optimalSize.width) {
+ optimalSize = size;
+ }
+ }
+
+ // Cannot find one that matches the aspect ratio. This should not happen.
+ // Ignore the requirement.
+ if (optimalSize == null) {
+ Log.w(TAG, "No thumbnail size match the aspect ratio");
+ for (Size size : sizes) {
+ if (optimalSize == null || size.width > optimalSize.width) {
+ optimalSize = size;
+ }
+ }
+ }
+ return optimalSize;
+ }
+
public static void dumpParameters(Parameters parameters) {
String flattened = parameters.flatten();
StringTokenizer tokenizer = new StringTokenizer(flattened, ";");