二维码框架Zxing的使用
WPF 创建二维码 /** * 创建二维码图片 */ private ImageSource createQRCode(String content, int width, int height) { EncodingOptions options;//包含一些编码、大小等的设置 BarcodeWriter write = null;//用来生成二维码,对应的BarcodeReader用来解码 options = new QrCodeEncodingOptions { DisableECI = true, CharacterSet = “UTF-8”, Width = width, Height = height, Margin = }; write = new BarcodeWriter(); write.Format = BarcodeFormat.QR_CODE; write.Options = options; Bitmap bitmap = write.Write(content); IntPtr ip = bitmap.GetHbitmap(); BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( ip, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); DeleteObject(ip); return bitmapSource; }
继续阅读