QRClass.cs 881 B

123456789101112131415161718192021222324252627
  1. using QRCoder;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Interop;
  8. using System.Windows.Media.Imaging;
  9. using System.Windows;
  10. using System.Drawing;
  11. namespace WpfApp1
  12. {
  13. internal class QRClass
  14. {
  15. public static BitmapSource QR()
  16. {
  17. string text = "http://gogs.ngknn.ru:3000/Alexey/PP_Minin";
  18. QRCodeGenerator qr = new QRCodeGenerator();
  19. QRCodeData data = qr.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
  20. QRCode code = new QRCode(data);
  21. Bitmap bitmap = code.GetGraphic(100);
  22. BitmapSource bitmapImage = (BitmapSource)Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
  23. return bitmapImage;
  24. }
  25. }
  26. }