日期:2014-05-17  浏览次数:20886 次

用Google二维码识别程序库zxing开发的识别程序,为什么有的能识别,有的识别不了
如题。
从GOOLE、百度图片上下载下来的一些二维码图片,有的是打了网站水印的,拿手机“我查查”软件能识别出相关包含的信息。但是用zxing开发的程序识别不了(其他的标准的大部分都能识别),这是为什么?谢谢,在线等。

代码如下:
using System;
using System.Drawing;
using System.Windows.Forms;
using com.google.zxing;
using COMMON = com.google.zxing.common;

private void button1_Click(object sender, EventArgs e)
  {
     if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Image img = Image.FromFile(this.openFileDialog1.FileName);
            Bitmap bmap;
            try
            {
                bmap = new Bitmap(img);
            }
            catch (System.IO.IOException ioe)
            {
                MessageBox.Show(ioe.ToString());
                return;
            }
            if (bmap == null)
            {
                MessageBox.Show("Could not decode image");
                return;
            }           
            LuminanceSource source = new RGBLuminanceSource(bmap, bmap.Width, bmap.Height);
            com.google.zxing.BinaryBitmap bitmap = new com.google.zxing.BinaryBitmap(new COMMON.HybridBinarizer(source));
            Result result;
            try
            {
                result = new MultiFormatReader().decode(bitmap); 
            }
            catch (ReaderException re)
            {
                MessageBox.Show(re.ToString());
                return;
 &nbs