二维码类库ThoughtWorks.QRCode.dll
ThoughtWorks.QRCode.Codec.QRCodeEncoder encoder = new QRCodeEncoder(); encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;//编码方法 encoder.QRCodeScale = 4;//大小 encoder.QRCodeVersion = 4;//版本 encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; String qrdata = "二维码信息"; System.Drawing.Bitmap bp = encoder.Encode(qrdata.ToString(), Encoding.GetEncoding("GB2312")); Image image = bp; Object oMissing = System.Reflection.Missing.Value; pictureBox1.Image = bp; 保存二维码图片: SaveFileDialog sf = new SaveFileDialog(); sf.Title = "选择保存文件位置"; sf.Filter = "保存图片(*.jpg) |*.jpg|所有文件(*.*) |*.*"; //设置默认文件类型显示顺序 sf.FilterIndex = 1; //保存对话框是否记忆上次打开的目录 sf.RestoreDirectory = true; if (sf.ShowDialog() == DialogResult.OK) { Image im = this.pictureBox1.Image; //获得文件路径 localFilePath = sf.FileName.ToString(); if (sf.FileName != "") { fileNameExt = localFilePath.Substring(localFilePath.LastIndexOf("\\") + 1);//获取文件名,不带路径 // newFileName = fileNameExt+DateTime.Now.ToString("yyyyMMdd") ;//给文件名后加上时间 FilePath = localFilePath.Substring(0, localFilePath.LastIndexOf(".")); //获取文件路径,带文件名,不带后缀 string fn = sf.FileName; pictureBox1.Image.Save(FilePath +"-"+ DateTime.Now.ToString("yyyyMMdd") + ".jpg"); } } //解析二维码信息 // QRCodeDecoder decoder = new QRCodeDecoder(); // String decodedString = decoder.decode(new QRCodeBitmapImage(new Bitmap(pictureBox1.Image))); //this.label3.Text = decodedString;