summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/Util.java
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2010-12-20 18:10:02 +0800
committerChia-chi Yeh <chiachi@android.com>2010-12-20 18:10:02 +0800
commit6bca5289166b1444f4b98538343a24d35f46dda5 (patch)
tree2877ab9e4e4e0606b7de8906881dbd34347f5b1b /src/com/android/camera/Util.java
parent5f039073a239fc8ebf94238c3dce24dc1cce865b (diff)
downloadLegacyCamera-6bca5289166b1444f4b98538343a24d35f46dda5.zip
LegacyCamera-6bca5289166b1444f4b98538343a24d35f46dda5.tar.gz
LegacyCamera-6bca5289166b1444f4b98538343a24d35f46dda5.tar.bz2
Cleanup: Make Util get rid of IImage.
Change-Id: I1628bcae4daa4768186f08df0d328f7c5a5380df
Diffstat (limited to 'src/com/android/camera/Util.java')
-rw-r--r--src/com/android/camera/Util.java35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index 6017d45..66c301b 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -16,8 +16,6 @@
package com.android.camera;
-import com.android.camera.gallery.IImage;
-
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
@@ -104,10 +102,10 @@ public class Util {
* tolerable in terms of memory usage.
*
* The function returns a sample size based on the constraints.
- * Both size and minSideLength can be passed in as IImage.UNCONSTRAINED,
+ * Both size and minSideLength can be passed in as -1
* which indicates no care of the corresponding constraint.
* The functions prefers returning a sample size that
- * generates a smaller bitmap, unless minSideLength = IImage.UNCONSTRAINED.
+ * generates a smaller bitmap, unless minSideLength = -1.
*
* Also, the function rounds up the sample size to a power of 2 or multiple
* of 8 because BitmapFactory only honors sample size this way.
@@ -137,9 +135,9 @@ public class Util {
double w = options.outWidth;
double h = options.outHeight;
- int lowerBound = (maxNumOfPixels == IImage.UNCONSTRAINED) ? 1 :
+ int lowerBound = (maxNumOfPixels < 0) ? 1 :
(int) Math.ceil(Math.sqrt(w * h / maxNumOfPixels));
- int upperBound = (minSideLength == IImage.UNCONSTRAINED) ? 128 :
+ int upperBound = (minSideLength < 0) ? 128 :
(int) Math.min(Math.floor(w / minSideLength),
Math.floor(h / minSideLength));
@@ -148,25 +146,15 @@ public class Util {
return lowerBound;
}
- if ((maxNumOfPixels == IImage.UNCONSTRAINED) &&
- (minSideLength == IImage.UNCONSTRAINED)) {
+ if (maxNumOfPixels < 0 && minSideLength < 0) {
return 1;
- } else if (minSideLength == IImage.UNCONSTRAINED) {
+ } else if (minSideLength < 0) {
return lowerBound;
} else {
return upperBound;
}
}
- public static void closeSilently(Closeable c) {
- if (c == null) return;
- try {
- c.close();
- } catch (Throwable t) {
- // do nothing
- }
- }
-
public static Bitmap makeBitmap(byte[] jpegData, int maxNumOfPixels) {
try {
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -178,7 +166,7 @@ public class Util {
return null;
}
options.inSampleSize = computeSampleSize(
- options, IImage.UNCONSTRAINED, maxNumOfPixels);
+ options, -1, maxNumOfPixels);
options.inJustDecodeBounds = false;
options.inDither = false;
@@ -191,6 +179,15 @@ public class Util {
}
}
+ public static void closeSilently(Closeable c) {
+ if (c == null) return;
+ try {
+ c.close();
+ } catch (Throwable t) {
+ // do nothing
+ }
+ }
+
public static void Assert(boolean cond) {
if (!cond) {
throw new AssertionError();