示例#1
0
        private void btnDecode_Click(object sender, EventArgs e)
        {
            try
            {
                QRCodeDecoder decoder = new QRCodeDecoder();
                /*
                sbyte[] data = decoder.decodeBytes(new QRCodeBitmapImage(new Bitmap(picDecode.Image)));
                byte[] byteData = new byte[data.Length];

                Buffer.BlockCopy(data, 0, byteData, 0, byteData.Length);
                if (QRCodeUtility.IsUniCode(byteData))
                {
                    MessageBox.Show("Unicode");
                }
                else
                {
                    MessageBox.Show("Not unicode");
                }
                 */
                //QRCodeDecoder.Canvas = new ConsoleCanvas();
                String decodedString = decoder.decode(new QRCodeBitmapImage(new Bitmap(picDecode.Image)));
                txtDecodedData.Text = decodedString;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public DecodeResult(QRCodeDecoder enclosingInstance, sbyte[] decodedBytes, int numErrors, bool correctionSucceeded)
 {
     InitBlock(enclosingInstance);
     this.decodedBytes = decodedBytes;
     this.numCorrections = numErrors;
     this.correctionSucceeded = correctionSucceeded;
 }
 public DecodeResult(QRCodeDecoder enclosingInstance, sbyte[] decodedBytes, int numErrors, bool correctionSucceeded)
 {
     InitBlock(enclosingInstance);
     this.decodedBytes        = decodedBytes;
     this.numCorrections      = numErrors;
     this.correctionSucceeded = correctionSucceeded;
 }
示例#4
0
        private void btnDecode_Click(object sender, EventArgs e)
        {
            QRCodeDecoder decoder = new QRCodeDecoder();

            String decodedString = decoder.decode(new QRCodeBitmapImage(new Bitmap(pb_view.Image)));

            txtEncodeData.Text = decodedString;
        }
示例#5
0
 /// <summary>
 /// 二维码解码
 /// </summary>
 /// <param name="filePath">图片路径</param>
 /// <returns></returns>
 public string CodeDecoder(string filePath)
 {
     if (!System.IO.File.Exists(filePath))
         return null;
     Bitmap myBitmap = new Bitmap(Image.FromFile(filePath));
     QRCodeDecoder decoder = new QRCodeDecoder();
     string decodedString = decoder.decode(new QRCodeBitmapImage(myBitmap));
     return decodedString;
 }
        /*  二维码名片格式
         * 
            BEGIN:VCARD 
            VERSION:3.0 
            N:易网天成 
            EMAIL:[email protected] 
            TEL:010-56955550 
            TEL;CELL:13000000000 
            ADR:北京 
            ORG:北京易网天成
            TITLE:技术部 
            URL:http://www.ewtch.com 
            NOTE:企业信息化服务第一品牌 
            END:VCARD
         * 
         * 
         */

        public String Decode()
        {
            Bitmap bm = new Bitmap(@"F:\Ahoo\Ahoo.Demo\Ahoo.Demo.Web\test.png");

            QRCodeDecoder decoder = new QRCodeDecoder();

            QRCodeBitmapImage qcImg = new QRCodeBitmapImage(bm);

            string img_text = decoder.decode(qcImg, System.Text.Encoding.UTF8);

            return img_text;
        }
示例#7
0
 private void btnDecode_Click_1(object sender, EventArgs e)
 {
     try
     {
         QRCodeDecoder decoder = new QRCodeDecoder();
         //QRCodeDecoder.Canvas = new ConsoleCanvas();
         String decodedString = decoder.decode(new QRCodeBitmapImage(new Bitmap(picDecode.Image)));
         txtDecodedData.Text = decodedString;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#8
0
文件: Form1.cs 项目: Makk24/QR-Code
 /// <summary>
 /// 解码
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button2_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     Bitmap b = this.pictureBox1.Image as Bitmap;
     try
     {
         QRCodeDecoder decoder = new QRCodeDecoder();
         //解码
         String decodedString = decoder.decode(new QRCodeBitmapImage(b),Encoding.UTF8);
         //显示解码信息
         this.lbl解码信息.Text += decodedString ;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     Cursor.Current = Cursors.Default;
 }
        //
        // GET: /QRCode/

        public FileResult Index()
        {
            QRCodeEncoder encoder = new QRCodeEncoder();

            string strCoder = "http://wx.ahoo.me/";

            Bitmap bm = encoder.Encode(strCoder, System.Text.Encoding.UTF8);

            MemoryStream stream = new MemoryStream();

            bm.Save(stream, System.Drawing.Imaging.ImageFormat.Png);

            QRCodeDecoder decoder = new QRCodeDecoder();

            QRCodeBitmapImage qcImg = new QRCodeBitmapImage(bm);

            string img_text = decoder.decode(qcImg, System.Text.Encoding.UTF8);

            return File(stream.GetBuffer(), "image/png");
        }
示例#10
0
 private void btnDecode_Click(object sender, EventArgs e)
 {
     try
     {
         if(picDecode.Image == null)
         {
             MessageBox.Show("请选择图片");
         }
         else
         {
             //创建二维码解析对象
             QRCodeDecoder qrCoderDecoder = new QRCodeDecoder();
             //解析二维码图片
             string decoderString = qrCoderDecoder.decode(new QRCodeBitmapImage(new Bitmap( picDecode.Image)));
             txtDecodedData.Text = decoderString;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("这张图片有问题", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#11
0
文件: Form1.cs 项目: kinpauln/QRCode
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         QRCodeDecoder decoder = new QRCodeDecoder();
         string str = "";
         if (this.comboBox5.SelectedIndex == 0)
         {
             str = decoder.decode(new QRCodeBitmapImage(new Bitmap(this.pictureBox2.Image)), Encoding.GetEncoding("gb2312"));
         }
         if (this.comboBox5.SelectedIndex == 1)
         {
             str = decoder.decode(new QRCodeBitmapImage(new Bitmap(this.pictureBox2.Image)), Encoding.UTF8);
         }
         if (this.comboBox5.SelectedIndex == 2)
         {
             str = decoder.decode(new QRCodeBitmapImage(new Bitmap(this.pictureBox2.Image)), Encoding.Unicode);
         }
         this.richTextBox2.Text = str;
     }
     catch
     {
         MessageBox.Show("无法识别,建议采用手机扫描识别!");
     }
 }
 /// <summary>
 /// 解析二维码
 /// </summary>
 public void DecodeQRCode()
 {
     if (bimg == null)
     {
         MessageBox.Show("请先打开一张二维码图片!", "系统提示");
         return;
     }
     QRCodeDecoder qrDecoder = new QRCodeDecoder();
     QRCodeImage qrImage = new QRCodeBitmapImage(bimg);
     tbDecodeResult.Text = qrDecoder.decode(qrImage, Encoding.UTF8);
 }
示例#13
0
 private void InitBlock(QRCodeDecoder enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
示例#14
0
 static void Main(string[] args)
 {
     QRCodeDecoder decoder = new QRCodeDecoder();  
 }
示例#15
0
 public DecodeResult(QRCodeDecoder enclosingInstance, sbyte[] decodedBytes, int numCorrectionFailures)
 {
     InitBlock(enclosingInstance);
     this.decodedBytes          = decodedBytes;
     this.numCorrectionFailures = numCorrectionFailures;
 }
示例#16
0
        private void btnDecodeQR_Click(object sender, EventArgs e)
        {
            if (picBox3.Image == null)
            {
                MessageBox.Show("请选择要解析的二维码图片", "系统提示");
            }
            else
            {
                //获取出错 Exception
                try
                {
                    QRCodeDecoder qrDecode = new QRCodeDecoder();
                    //qrDecode.decode()
                    Bitmap decodeimage = DecodeImage as Bitmap;
                    Bitmap bmp = new Bitmap(decodeimage, picBox3.Width, picBox3.Height);
                    ThoughtWorks.QRCode.Codec.Data.QRCodeImage qrimage = new ThoughtWorks.QRCode.Codec.Data.QRCodeBitmapImage(bmp);
                    lbQRDecodeOutput.Text = qrDecode.decode(qrimage, Encoding.UTF8);
                }
                catch (ThoughtWorks.QRCode.ExceptionHandler.DecodingFailedException dfE)
                {
                    MessageBox.Show(dfE.Message); //显示解析二维码出错的原因
                }

            }
        }
示例#17
0
文件: QRCode.cs 项目: sndnvaps/Blog
        /// <summary>
        /// 识别二维码
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static string Recognition(string _path)
        {
            var _result = string.Empty;
            var fullpath = string.Empty;
            if (System.Web.HttpContext.Current.Request.Files.Count > 0)
            {
                for (int j = 0; j < System.Web.HttpContext.Current.Request.Files.Count; j++)
                {
                    var filename = Guid.NewGuid().ToString() + "_tmp.png";
                    _path = (_path.IndexOf("~") > -1) ?
                        System.Web.HttpContext.Current.Server.MapPath(@"~\QRCode\upload") + "\\" : _path;
                    var filepath = _path;
                    if (!Directory.Exists(filename))
                    {
                        Directory.CreateDirectory(filepath);
                    }
                    fullpath = filepath + filename.Replace("_tmp", "");
                    string qrdecode = string.Empty;
                    System.Web.HttpPostedFile uploadFile = System.Web.HttpContext.Current.Request.Files[j];
                    uploadFile.SaveAs(fullpath);

                    QRCodeDecoder decoder = new QRCodeDecoder();
                    Bitmap bm = new Bitmap(fullpath);
                    qrdecode = decoder.decode(new QRCodeBitmapImage(bm));
                    bm.Dispose();

                    _result = "[{\"count\":1,\"list\":[{\"imgurl\":\"" + fullpath + "\",\"qrtext\":\"" + qrdecode + "\"}]}]";
                }
            }
            else
            {
                _result = "[{\"count\":0,\"list\":[{\"error\":\"" + "没有选择二维码文件".ChinessConvertToUnicodeString() + "\"}]}]";
            }
            //删除缓存图片
            File.Delete(fullpath);
            return _result;
        }
示例#18
0
 /// <summary>
 /// 读取图片,解析二维码
 /// </summary>
 /// <param name="bmap">二维码图片</param>
 /// <returns>二维码内容</returns>
 public static string decoderQRCode(System.Drawing.Image bmap)
 {
     QRCodeDecoder decoder = new QRCodeDecoder();
     string decodedString = decoder.decode(new QRCodeBitmapImage(new Bitmap(bmap)));
     return decodedString;
 }
示例#19
0
        /// <summary>
        /// 解析二维码,根据二维码图片路径
        /// </summary>
        /// <param name="path">二维码图片路径</param>
        /// <returns>二维码内容</returns>
        public static string decoderQRCode(string path)
        {
            QRCodeDecoder decoder = new QRCodeDecoder();
            string decodeString = decoder.decode(new QRCodeBitmapImage(new Bitmap(path)), System.Text.Encoding.UTF8);
            return decodeString;

            #region 已注释,方式二
            //sbyte[] bytes=decoder.decodeBytes(new QRCodeBitmapImage(new Bitmap(path)));
            ////bytes[] 转换成  byte[]
            //byte[] temp =new byte[bytes.Length];
            //Buffer.BlockCopy(bytes, 0, temp, 0, bytes.Length);

            //string decodeString =System.Text.Encoding.UTF8.GetString(temp);
            //return decodeString;
            #endregion
        }
 private void  InitBlock(QRCodeDecoder enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
示例#21
0
 /// <summary>
 /// 解析二维码,根据输入流
 /// </summary>
 /// <param name="input">二维码输入流</param>
 /// <returns>二维码内容</returns>
 public static string decoderQRCode(Stream input)
 {
     QRCodeDecoder decoder = new QRCodeDecoder();
     sbyte[] bytes = decoder.decodeBytes(new QRCodeBitmapImage(new Bitmap(input)));
     //bytes[] 转换成  byte[]
     byte[] temp = bytes.Cast<byte>().ToArray();
     string decodeString = System.Text.Encoding.UTF8.GetString(temp);
     return decodeString;
 }
示例#22
0
文件: QRCode.cs 项目: sndnvaps/Blog
        /// <summary>
        /// 识别二维码
        /// </summary>
        /// <returns></returns>
        public static string Recognition()
        {
            var _result = string.Empty;
            var fullpath = string.Empty;
            if (System.Web.HttpContext.Current.Request.Files.Count > 0)
            {
                for (int j = 0; j < System.Web.HttpContext.Current.Request.Files.Count; j++)
                {
                    var filename = Guid.NewGuid().ToString() + "_tmp.png";
                    var filepath = System.Web.HttpContext.Current.Server.MapPath(@"~\Utilty\QRCode\upload") + "\\";
                    if (!Directory.Exists(filename))
                    {
                        Directory.CreateDirectory(filepath);
                    }
                    fullpath = filepath + filename;
                    if (string.IsNullOrEmpty(fullpath))
                        return "请上传二维码文件".ChinessConvertToUnicodeString();
                    string qrdecode = string.Empty;
                    System.Web.HttpPostedFile uploadFile = System.Web.HttpContext.Current.Request.Files[j];
                    uploadFile.SaveAs(fullpath);

                    QRCodeDecoder decoder = new QRCodeDecoder();
                    Bitmap bm = new Bitmap(fullpath);
                    try
                    {
                        qrdecode = decoder.decode(new QRCodeBitmapImage(bm));
                    }
                    catch
                    {
                        _result = "[{\"status\":0,\"count\":1,\"content\":\"" + "大小设置出错".ChinessConvertToUnicodeString() + "\"}]";
                        return _result;
                    }
                    bm.Dispose();

                    _result = "[{\"count\":1,\"list\":[{\"imgurl\":\"" + fullpath + "\",\"qrtext\":\"" + qrdecode + "\"}]}]";
                }
            }
            else
            {
                _result = "[{\"count\":0,\"list\":[{\"error\":\"" + "没有上传文件".ChinessConvertToUnicodeString() + "\"}]}]";
            }
            //删除缓存图片
            File.Delete(fullpath);
            return _result;
        }
示例#23
0
 /// <summary>
 /// 解析二维码
 /// </summary>
 /// <param name="bitmap">要解析的二维码位图</param>
 /// <returns>解析后的字符串</returns>
 public static string QRCodeDeCoderUtil(Bitmap bitmap)
 {
     QRCodeDecoder decoder = new QRCodeDecoder();
     string decodedString = decoder.decode(new QRCodeBitmapImage(bitmap), Encoding.UTF8);//指定UTF8编码,支持中文
     return decodedString;
 }