diff --git a/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java b/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java index d46da9bf9..cdf3af682 100644 --- a/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java +++ b/core/src/test/java/com/google/zxing/BufferedImageLuminanceSource.java @@ -68,7 +68,9 @@ public final class BufferedImageLuminanceSource extends LuminanceSource { pixel = 0xFFFFFFFF; // = white } - // .229R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC) + // .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC), + // (306*R) >> 10 is approximately equal to R*0.299, and so on. + // 0x200 >> 10 is 0.5, it implements rounding. buffer[x] = (306 * ((pixel >> 16) & 0xFF) + 601 * ((pixel >> 8) & 0xFF) + diff --git a/javase/src/main/java/com/google/zxing/client/j2se/BufferedImageLuminanceSource.java b/javase/src/main/java/com/google/zxing/client/j2se/BufferedImageLuminanceSource.java index 66734563c..6fd5f38be 100644 --- a/javase/src/main/java/com/google/zxing/client/j2se/BufferedImageLuminanceSource.java +++ b/javase/src/main/java/com/google/zxing/client/j2se/BufferedImageLuminanceSource.java @@ -69,8 +69,10 @@ public final class BufferedImageLuminanceSource extends LuminanceSource { if ((pixel & 0xFF000000) == 0) { pixel = 0xFFFFFFFF; // = white } - - // .229R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC) + + // .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC), + // (306*R) >> 10 is approximately equal to R*0.299, and so on. + // 0x200 >> 10 is 0.5, it implements rounding. buffer[x] = (306 * ((pixel >> 16) & 0xFF) + 601 * ((pixel >> 8) & 0xFF) +