From b5e9cffeba47a5bdd4fe78a661cbc4b664b067c6 Mon Sep 17 00:00:00 2001 From: wood Date: Thu, 1 Oct 2015 12:30:15 +0800 Subject: [PATCH] fix a little error RGB to gray, the weight of R is 0.299, not 0.229. The comment have a little error. And why add 0x200 ? It may be a error. 306/1024 = 0.2988. 601/1024=0.5869 and 117/1027 = 0.1143. --- .../zxing/client/j2se/BufferedImageLuminanceSource.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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..f5d55abda 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 @@ -70,12 +70,12 @@ 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) buffer[x] = (306 * ((pixel >> 16) & 0xFF) + 601 * ((pixel >> 8) & 0xFF) + - 117 * (pixel & 0xFF) + - 0x200) >> 10; + 117 * (pixel & 0xFF) + ) >> 10; } raster.setPixels(left, y, width, 1, buffer); }