summaryrefslogtreecommitdiffstats
path: root/gallerycommon
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-02-11 07:19:47 +0800
committerChih-Chung Chang <chihchung@google.com>2012-02-11 10:21:58 +0800
commitc20bc57295c1b4b73ea65701a94efaf519955351 (patch)
tree20f474a001e08d8f2dc9b14229bbf16692d0cdcb /gallerycommon
parentfa0c5fdbb402442fe8a39ecacb994a8be2750d68 (diff)
downloadandroid_packages_apps_Snap-c20bc57295c1b4b73ea65701a94efaf519955351.tar.gz
android_packages_apps_Snap-c20bc57295c1b4b73ea65701a94efaf519955351.tar.bz2
android_packages_apps_Snap-c20bc57295c1b4b73ea65701a94efaf519955351.zip
Use FloatMath instead of Math.
Change-Id: I41661b231f6c034dbca6af26d5950eda6c5fc7da
Diffstat (limited to 'gallerycommon')
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
index 2192cf8ec..67aa6d77b 100644
--- a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
+++ b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
@@ -23,6 +23,7 @@ import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Build;
+import android.util.FloatMath;
import android.util.Log;
import java.io.ByteArrayOutputStream;
@@ -71,7 +72,7 @@ public class BitmapUtils {
&& minSideLength == UNCONSTRAINED) return 1;
int lowerBound = (maxNumOfPixels == UNCONSTRAINED) ? 1 :
- (int) Math.ceil(Math.sqrt((double) (w * h) / maxNumOfPixels));
+ (int) FloatMath.ceil(FloatMath.sqrt((float) (w * h) / maxNumOfPixels));
if (minSideLength == UNCONSTRAINED) {
return lowerBound;
@@ -95,7 +96,7 @@ public class BitmapUtils {
// Fin the min x that 1 / x <= scale
public static int computeSampleSizeLarger(float scale) {
- int initialSize = (int) Math.floor(1f / scale);
+ int initialSize = (int) FloatMath.floor(1f / scale);
if (initialSize <= 1) return 1;
return initialSize <= 8
@@ -106,7 +107,7 @@ public class BitmapUtils {
// Find the max x that 1 / x >= scale.
public static int computeSampleSize(float scale) {
Utils.assertTrue(scale > 0);
- int initialSize = Math.max(1, (int) Math.ceil(1 / scale));
+ int initialSize = Math.max(1, (int) FloatMath.ceil(1 / scale));
return initialSize <= 8
? Utils.nextPowerOf2(initialSize)
: (initialSize + 7) / 8 * 8;
@@ -116,8 +117,7 @@ public class BitmapUtils {
Bitmap bitmap, int targetPixels, boolean recycle) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
- float scale = (float) Math.sqrt(
- (double) targetPixels / (width * height));
+ float scale = FloatMath.sqrt((float) targetPixels / (width * height));
if (scale >= 1.0f) return bitmap;
return resizeBitmapByScale(bitmap, scale, recycle);
}