Loading src/com/android/contacts/quickcontact/WhitenessUtils.java +38 −35 Original line number Diff line number Diff line Loading @@ -39,9 +39,9 @@ public class WhitenessUtils { /** * An image with more than this amount white, is considered to be a whitish image. */ private static final float PROPORTION_WHITE_CUTOFF = 0.2f; private static final float PROPORTION_WHITE_CUTOFF = 0.1f; private static final float HALF = 0.5f; private static final float THIRD = 0.33f; /** * Colors with luma greater than this are considered close to white. This value is lower than Loading @@ -55,7 +55,7 @@ public class WhitenessUtils { */ public static boolean isBitmapWhiteAtTopOrBottom(Bitmap largeBitmap) { Trace.beginSection("isBitmapWhiteAtTopOrBottom"); try { final Bitmap smallBitmap = scaleBitmapDown(largeBitmap); final int[] rgbPixels = new int[smallBitmap.getWidth() * smallBitmap.getHeight()]; Loading @@ -65,7 +65,8 @@ public class WhitenessUtils { // look at top right corner of the bitmap int whiteCount = 0; for (int y = 0; y < smallBitmap.getHeight() * HEIGHT_PERCENT_ANALYZED; y++) { for (int x = (int) (smallBitmap.getWidth() * HALF); x < smallBitmap.getWidth(); x++) { for (int x = (int) (smallBitmap.getWidth() * (1 - THIRD)); x < smallBitmap.getWidth(); x++) { final int rgb = rgbPixels[y * smallBitmap.getWidth() + x]; if (isWhite(rgb)) { whiteCount ++; Loading @@ -73,7 +74,7 @@ public class WhitenessUtils { } } int totalPixels = (int) (smallBitmap.getHeight() * smallBitmap.getWidth() * HALF * HEIGHT_PERCENT_ANALYZED); * THIRD * HEIGHT_PERCENT_ANALYZED); if (whiteCount / (float) totalPixels > PROPORTION_WHITE_CUTOFF) { return true; } Loading @@ -93,8 +94,10 @@ public class WhitenessUtils { totalPixels = (int) (smallBitmap.getHeight() * smallBitmap.getWidth() * HEIGHT_PERCENT_ANALYZED); Trace.endSection(); return whiteCount / (float) totalPixels > PROPORTION_WHITE_CUTOFF; } finally { Trace.endSection(); } } private static boolean isWhite(int rgb) { Loading Loading
src/com/android/contacts/quickcontact/WhitenessUtils.java +38 −35 Original line number Diff line number Diff line Loading @@ -39,9 +39,9 @@ public class WhitenessUtils { /** * An image with more than this amount white, is considered to be a whitish image. */ private static final float PROPORTION_WHITE_CUTOFF = 0.2f; private static final float PROPORTION_WHITE_CUTOFF = 0.1f; private static final float HALF = 0.5f; private static final float THIRD = 0.33f; /** * Colors with luma greater than this are considered close to white. This value is lower than Loading @@ -55,7 +55,7 @@ public class WhitenessUtils { */ public static boolean isBitmapWhiteAtTopOrBottom(Bitmap largeBitmap) { Trace.beginSection("isBitmapWhiteAtTopOrBottom"); try { final Bitmap smallBitmap = scaleBitmapDown(largeBitmap); final int[] rgbPixels = new int[smallBitmap.getWidth() * smallBitmap.getHeight()]; Loading @@ -65,7 +65,8 @@ public class WhitenessUtils { // look at top right corner of the bitmap int whiteCount = 0; for (int y = 0; y < smallBitmap.getHeight() * HEIGHT_PERCENT_ANALYZED; y++) { for (int x = (int) (smallBitmap.getWidth() * HALF); x < smallBitmap.getWidth(); x++) { for (int x = (int) (smallBitmap.getWidth() * (1 - THIRD)); x < smallBitmap.getWidth(); x++) { final int rgb = rgbPixels[y * smallBitmap.getWidth() + x]; if (isWhite(rgb)) { whiteCount ++; Loading @@ -73,7 +74,7 @@ public class WhitenessUtils { } } int totalPixels = (int) (smallBitmap.getHeight() * smallBitmap.getWidth() * HALF * HEIGHT_PERCENT_ANALYZED); * THIRD * HEIGHT_PERCENT_ANALYZED); if (whiteCount / (float) totalPixels > PROPORTION_WHITE_CUTOFF) { return true; } Loading @@ -93,8 +94,10 @@ public class WhitenessUtils { totalPixels = (int) (smallBitmap.getHeight() * smallBitmap.getWidth() * HEIGHT_PERCENT_ANALYZED); Trace.endSection(); return whiteCount / (float) totalPixels > PROPORTION_WHITE_CUTOFF; } finally { Trace.endSection(); } } private static boolean isWhite(int rgb) { Loading