コード例 #1
0
ファイル: KwQRCodeWriter.cs プロジェクト: xxdoc/BCTest
 public void encodeAndSaveWithEC(string text, string path, QR_CORRECT_LEV correctLev)
 {
     try
     {
         this.filePath = path;
         textToQRImage(text, (QR_CORRECT_LEV)correctLev).Save(path, ImageFormat.Bmp);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #2
0
ファイル: KwQRCodeWriter.cs プロジェクト: xxdoc/BCTest
        static public Bitmap textToQRImage(string text, QR_CORRECT_LEV correctLev)
        {
            try
            {
                if (writer == null)
                {
                    writer = new QRCodeWriter();
                }
                Hashtable hints = new Hashtable();
                switch (correctLev)
                {
                case QR_CORRECT_LEV.L:
                    hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.L;
                    break;

                case QR_CORRECT_LEV.M:
                    hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.M;
                    break;

                case QR_CORRECT_LEV.Q:
                    hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.Q;
                    break;

                case QR_CORRECT_LEV.H:
                    hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.H;
                    break;

                default:
                    hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.L;
                    break;
                }
                ByteMatrix byteMatrix = writer.encode(
                    text,
                    BarcodeFormat.QR_CODE,
                    size,
                    size,
                    hints);

                return(byteMatrix.ToBitmap());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
コード例 #3
0
ファイル: KwQRCodeWriter.cs プロジェクト: siterious/BCTest
 public void encodeAndSaveWithEC(string text, string path, QR_CORRECT_LEV correctLev)
 {
     try
     {
         this.filePath = path;
         textToQRImage(text, (QR_CORRECT_LEV)correctLev).Save(path, ImageFormat.Bmp);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #4
0
ファイル: KwQRCodeWriter.cs プロジェクト: siterious/BCTest
        public static Bitmap textToQRImage(string text, QR_CORRECT_LEV correctLev)
        {
            try
            {
                if (writer == null) writer = new QRCodeWriter();
                Hashtable hints = new Hashtable();
                switch (correctLev)
                {
                    case QR_CORRECT_LEV.L:
                        hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.L;
                        break;
                    case QR_CORRECT_LEV.M:
                        hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.M;
                        break;
                    case QR_CORRECT_LEV.Q:
                        hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.Q;
                        break;
                    case QR_CORRECT_LEV.H:
                        hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.H;
                        break;
                    default:
                        hints[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.L;
                        break;
                }
                ByteMatrix byteMatrix = writer.encode(
                        text,
                        BarcodeFormat.QR_CODE,
                        size,
                        size,
                        hints);

                return byteMatrix.ToBitmap();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
        }