zxing中的qxing QRCode编码和解码 [英] zxing QRCode Encoding and Decoding in c#

查看:125
本文介绍了zxing中的qxing QRCode编码和解码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在我的Windows应用程序(C#)中实现QRCode编码和解码。

为此我开始使用zxing库。

它有一些内部功能;但我不知道如何使用它。

请你分享一些解决方案,我可以通过设置一些参数来编码和解码,例如Errorcorrectionlevel,版本,大小等。



任何帮助都会很棒。

提前致谢



-Vivek Deshmukh

Hi ,
I need to implement QRCode encoding and decoding in my Windows application(C#).
For this I started using zxing library.
It has some inbuild functions; but I don't know how to use it.
Could you please share some solution where in I can able to encode and decode by setting some parameters such as Errorcorrectionlevel,version, size etc.

Any help would be greatful.
Thanks in advance

-Vivek Deshmukh

推荐答案

试试这个



http://windowqr.codeplex.com/SourceControl/list/changesets [ ZXING示例项目]



解码



Try this

http://windowqr.codeplex.com/SourceControl/list/changesets[ZXING Sample Project]

Decoding

using com.google.zxing.qrcode;
using com.google.zxing;
using com.google.zxing.common;

public string Process(Bitmap bitmap)
{
  try
  {
    com.google.zxing.LuminanceSource source = new RGBLuminanceSource(bitmap, bitmap.Width, bitmap.Height);
    var binarizer = new HybridBinarizer(source);
    var binBitmap = new BinaryBitmap(binarizer);
    return reader.decode(binBitmap).Text;
  }
  catch
  {
    return string.Empty;
  }
}







编码




Encoding

QRCodeWriter writer = new QRCodeWriter();
Hashtable hints = new Hashtable();
            
            hints.Add(EncodeHintType.ERROR_CORRECTION, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel.M);
            hints.Add("Version", "7");
            ByteMatrix byteIMGNew = writer.encode("Hello", BarcodeFormat.QR_CODE, 350, 350, hints);
            sbyte[][] imgNew = byteIMGNew.Array;
            Bitmap bmp1 = new Bitmap(byteIMGNew.Width, byteIMGNew.Height);
            Graphics g1 = Graphics.FromImage(bmp1);
            g1.Clear(Color.White);
            for (int i = 0; i <= imgNew.Length - 1; i++)
            {
                for (int j = 0; j <= imgNew[i].Length - 1; j++)
                {
                    if (imgNew[j][i] == 0)
                    {
                        g1.FillRectangle(Brushes.Black, i, j, 1, 1);
                    }
                    else
                    {
                        g1.FillRectangle(Brushes.White, i, j, 1, 1);
                    }
                }
            }
            bmp1.Save("D:\\QREncode.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);


首先,你需要整合一个< a style =text-decoration:none; color:#000000href =http://www.keepdynamic.com/csharp-barcode-generator/qr-code.shtmltarget =_ self> QR Code encoder 和 c#.net 中的QR码解码器,您可以在vb.net中编码和解码QR码。

这样做的最佳方法是利用兼容的现有QR码库使用.net框架。快速搜索揭示了一个开源项目QRCode库。该库支持编码和解码qr代码。这应该满足您为模型编号和产品编号生成qr代码然后阅读它们的条件。
First,you need to integrate a QR Code encoder and QR Code decoder in c#.net,just then you can encode and decode QR Code in vb.net.
The best method for doing this is to leverage an existing QR code library compatible with the .net framework. A quick search reveals an open source project QRCode Library. The library supports both encoding and decoding qr codes. This should satisfy your condition of generating qr codes for Model Numbers and Product Numbers and then reading them.


这篇关于zxing中的qxing QRCode编码和解码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆