Made the RGB to luminance approximation/optimization a little faster -- one less...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 31 Mar 2008 19:04:38 +0000 (19:04 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 31 Mar 2008 19:04:38 +0000 (19:04 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@327 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android-m3/src/com/google/zxing/client/android/RGBMonochromeBitmapSource.java
android/src/com/google/zxing/client/android/RGBMonochromeBitmapSource.java
javame/src/com/google/zxing/client/j2me/LCDUIImageMonochromeBitmapSource.java

index 6d3f2bd..100a9d4 100755 (executable)
@@ -140,9 +140,9 @@ final class RGBMonochromeBitmapSource implements MonochromeBitmapSource {
     // corrupts the conversion. Not significant for our purposes.
     //
     // But we can get even cleverer and eliminate a few shifts:
-    return (((pixel & 0x00FF0000) >> 8)  +
-            ((pixel & 0x0000FF00) << 1) +
-            ((pixel & 0x000000FF) << 8)) >> 10;
+    return (((pixel & 0x00FF0000) >> 16)  +
+            ((pixel & 0x0000FF00) >>  7) +
+            ( pixel & 0x000000FF       )) >> 2;
   }
 
 }
\ No newline at end of file
index 6d3f2bd..100a9d4 100755 (executable)
@@ -140,9 +140,9 @@ final class RGBMonochromeBitmapSource implements MonochromeBitmapSource {
     // corrupts the conversion. Not significant for our purposes.
     //
     // But we can get even cleverer and eliminate a few shifts:
-    return (((pixel & 0x00FF0000) >> 8)  +
-            ((pixel & 0x0000FF00) << 1) +
-            ((pixel & 0x000000FF) << 8)) >> 10;
+    return (((pixel & 0x00FF0000) >> 16)  +
+            ((pixel & 0x0000FF00) >>  7) +
+            ( pixel & 0x000000FF       )) >> 2;
   }
 
 }
\ No newline at end of file
index e567edd..cadb815 100644 (file)
@@ -134,9 +134,9 @@ public final class LCDUIImageMonochromeBitmapSource implements MonochromeBitmapS
     // corrupts the conversion. Not significant for our purposes.
     //
     // But we can get even cleverer and eliminate a few shifts:
-    return (((pixel & 0x00FF0000) >> 8)  +
-            ((pixel & 0x0000FF00) << 1) +
-            ((pixel & 0x000000FF) << 8)) >> 10;
+    return (((pixel & 0x00FF0000) >> 16)  +
+            ((pixel & 0x0000FF00) >>  7) +
+            ( pixel & 0x000000FF       )) >> 2;
   }
 
 }
\ No newline at end of file