首页 > 代码库 > 二维码

二维码

 

 Image _qRImg= GetQRCodeImage(要写入二维码的参数);
 PictureBox pb = new PictureBox();
pb.Size = _qRImg.Size;
pb.Image = _qRImg;
pb.Left = (int)(double.Parse(ds.Tables[0].Rows[i]["FieldX"].ToString()) * 0.5);
 pb.Top = (int)(double.Parse(ds.Tables[0].Rows[i]["FieldY"].ToString()) * 0.5);
  palMainPrew.Controls.Add(pb);

 

public Image GetQRCodeImage(string cqNum)
{
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
            qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeScale = 2;
            qrCodeEncoder.QRCodeVersion = 5;
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            return qrCodeEncoder.Encode(cqNum);
 }

二维码