开发者

QRCode encoding and decoding problem

I want to split a file ( a docx file) and use the individual fragments of the file to encode a QRCode such that when the qrcodes are read in sequence, it reproduces the original file.

I was able to split the file and create a bunch of QRCodes but when attempted to recreate the file, the Decoder throws the following Error Message.

"Invalid number of finder pattern detected"

I am using http://www.codeproject.com/KB/cs/qrcode.aspx library.

My encoder code

private List Encode(String content, Encoding encoding, int System.Drawing.Color qrCodeBackgroundColor, QRCodeCapacity,System.Drawing.Color qrCodeBackgroundColor,System.Drawing.Color

qrCodeForegroundColor,int qrCodeScale, int NoOfQRcodes)

{

      List<Bitmap> _qrcodesImages = new List<Bitmap>();

      byte[] _filebytearray = encoding.GetBytes(content);

      for (int k = 0,l=0; k < NoOfQRcodes; k++)
      {
          byte[] _tempByteArray = _filebytearray.Skip(l).Take(QR开发者_如何学编程CodeCapacity).ToArray();
          bool[][] matrix = calQrcode(_tempByteArray);

          SolidBrush brush = new SolidBrush(qrCodeBackgroundColor);
          Bitmap image = new Bitmap((matrix.Length * qrCodeScale) + 1, (matrix.Length * qrCodeScale) + 1);
          Graphics g = Graphics.FromImage(image);
          g.FillRectangle(brush, new Rectangle(0, 0, image.Width, image.Height));
          brush.Color = qrCodeForegroundColor;
          for (int i = 0; i < matrix.Length; i++)
          {
              for (int j = 0; j < matrix.Length; j++)
              {
                  if (matrix[j][i])
                  {
                      g.FillRectangle(brush, j * qrCodeScale, i * qrCodeScale, qrCodeScale, qrCodeScale);
                  }
              }
          }
          _qrcodesImages.Add(image);
          l += QRCodeCapacity;
      }

      return _qrcodesImages;
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜