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()); }
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()); }
/// <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"); * }*/ }
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); }
public static Image CreateEmf(string contents, QREncodeMode mode, QRErrorLevel errorLevel) => CreateImage(CreateEmfBytes(contents, mode, errorLevel));
public static Bitmap Create(string contents, int resolution, QREncodeMode mode, QRErrorLevel errorLevel) => CreateBitmap(contents, resolution, mode, errorLevel);
public static Bitmap Create(string contents, int resolution, QREncodeMode mode) => CreateBitmap(contents, resolution, mode);
public static Bitmap Create(string contents, QREncodeMode mode, QRErrorLevel errorLevel) => CreateBitmap(contents, mode: mode, errorLevel: errorLevel);
public static Bitmap Create(string contents, QREncodeMode mode) => CreateBitmap(contents, mode: mode);