X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=javase%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fclient%2Fj2se%2FGUIRunner.java;h=78e7732d358f63d602c5a3c237c94377d6698ee0;hb=608fe313d82bb79f0f5a96856697bdfb4a6305d3;hp=e37b68b8e966334445c0ee4f9e95e454408bb16a;hpb=adcb498790b50fa7fa9a76b7c823d9bdb64ff322;p=zxing.git diff --git a/javase/src/com/google/zxing/client/j2se/GUIRunner.java b/javase/src/com/google/zxing/client/j2se/GUIRunner.java index e37b68b8..78e7732d 100644 --- a/javase/src/com/google/zxing/client/j2se/GUIRunner.java +++ b/javase/src/com/google/zxing/client/j2se/GUIRunner.java @@ -16,10 +16,20 @@ package com.google.zxing.client.j2se; -import com.google.zxing.MonochromeBitmapSource; +import com.google.zxing.BinaryBitmap; +import com.google.zxing.LuminanceSource; import com.google.zxing.MultiFormatReader; import com.google.zxing.ReaderException; import com.google.zxing.Result; +import com.google.zxing.common.HybridBinarizer; + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; import javax.imageio.ImageIO; import javax.swing.Icon; @@ -29,19 +39,12 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; /** *

Simple GUI frontend to the library. Right now, only decodes a local file. * This definitely needs some improvement. Just throwing something down to start.

* - * @author srowen@google.com (Sean Owen) + * @author Sean Owen */ public final class GUIRunner extends JFrame { @@ -91,14 +94,15 @@ public final class GUIRunner extends JFrame { if (image == null) { return "Could not decode image"; } - MonochromeBitmapSource source = new BufferedImageMonochromeBitmapSource(image); + LuminanceSource source = new BufferedImageLuminanceSource(image); + BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); Result result; try { - result = new MultiFormatReader().decode(source); + result = new MultiFormatReader().decode(bitmap); } catch (ReaderException re) { return re.toString(); } return result.getText(); } -} \ No newline at end of file +}