Beispiel #1
0
        private static byte[] CreateEmfBytes(string contents, QREncodeMode mode, QRErrorLevel errorLevel)
        {
            var builder  = CreateQrBuilder(contents, mode, errorLevel);
            var emfImage = new MemoryStream();

            builder.SaveAsEmf(emfImage);
            return(emfImage.ToArray());
        }
Beispiel #2
0
        private static Bitmap CreateBitmapImage(string contents, int?resolution, QREncodeMode mode, QRErrorLevel errorLevel)
        {
            var builder = CreateQrBuilder(contents, mode, errorLevel);

            if (resolution.HasValue)
            {
                return(builder.GetCustomSizeBarCodeImage(new Size(resolution.Value, resolution.Value), false));
            }

            return(builder.GetOnlyBarCodeImage());
        }
Beispiel #3
0
        /// <summary> Allowed <paramref name="resolution"/> are  </summary>
        private static Bitmap CreateBitmap(string contents
                                           , int?resolution          = null, QREncodeMode mode = DefaultQrEncodeMode
                                           , QRErrorLevel errorLevel = DefaultQrErrorLevel)
        {
            Bitmap bitmap = CreateBitmapImage(contents, resolution, mode, errorLevel);

            return(bitmap);

            /*using (var ms = new MemoryStream())
             * {
             *  bitmap.Save(ms, ImageFormat.Png);
             *  var content = ms.ToArray();
             *  return CreateImage(content);
             *  //return new Image(content, "QR.png");
             * }*/
        }
Beispiel #4
0
        private static BarCodeBuilder CreateQrBuilder(string contents, QREncodeMode mode, QRErrorLevel errorLevel)
        {
            if (mode == QREncodeMode.Binary)
            {
                var bytes = Encoding.UTF8.GetBytes(contents);
                contents = ISO_8859_1.GetString(bytes);
            }

            BarCodeBuilder builder = new BarCodeBuilder(contents, Symbology.QR)
            {
                QRErrorLevel = errorLevel,
                QREncodeMode = mode,
                EnableEscape = true,
                CaptionAbove = new Caption {
                    Visible = false
                },
                CaptionBelow = new Caption {
                    Visible = false
                }
            };

            return(builder);
        }
Beispiel #5
0
 public static Image CreateEmf(string contents, QREncodeMode mode, QRErrorLevel errorLevel)
 => CreateImage(CreateEmfBytes(contents, mode, errorLevel));
Beispiel #6
0
 public static Bitmap Create(string contents, int resolution, QREncodeMode mode, QRErrorLevel errorLevel)
 => CreateBitmap(contents, resolution, mode, errorLevel);
Beispiel #7
0
 public static Bitmap Create(string contents, int resolution, QREncodeMode mode) => CreateBitmap(contents, resolution, mode);
Beispiel #8
0
 public static Bitmap Create(string contents, QREncodeMode mode, QRErrorLevel errorLevel) => CreateBitmap(contents, mode: mode, errorLevel: errorLevel);
Beispiel #9
0
 public static Bitmap Create(string contents, QREncodeMode mode) => CreateBitmap(contents, mode: mode);