public virtual Stream Create(BarCodeCreateConfiguration cfg) { #if __ANDROID__ var writer = new ZXing.BarcodeWriter { Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), cfg.Format.ToString()), Encoder = new MultiFormatWriter(), Options = new EncodingOptions { Height = cfg.Height, Margin = cfg.Margin, Width = cfg.Height, PureBarcode = cfg.PureBarcode } }; #endif #if __IOS__ var writer = new ZXing.Mobile.BarcodeWriter { Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), cfg.Format.ToString()), Encoder = new MultiFormatWriter(), Options = new EncodingOptions { Height = cfg.Height, Margin = cfg.Margin, Width = cfg.Height, PureBarcode = cfg.PureBarcode } }; #endif return this.ToImageStream(writer, cfg); }
protected override Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg) { var ms = new MemoryStream(); Deployment.Current.Dispatcher.BeginInvoke(() => { var bitmap = writer.Write(cfg.BarCode); bitmap.SaveJpeg(ms, cfg.Width, cfg.Height, 0, 100); ms.Seek(0, SeekOrigin.Begin); }); return ms; }
protected override Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg) { var ms = new MemoryStream(); Deployment.Current.Dispatcher.BeginInvoke(() => { var bitmap = writer.Write(cfg.BarCode); bitmap.SaveJpeg(ms, cfg.Width, cfg.Height, 0, 100); ms.Seek(0, SeekOrigin.Begin); }); return(ms); }
protected override Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg) { var stream = new MemoryStream(); var cf = cfg.ImageType == ImageType.Png ? Bitmap.CompressFormat.Png : Bitmap.CompressFormat.Jpeg; using (var bitmap = writer.Write(cfg.BarCode)) bitmap.Compress(cf, 0, stream); stream.Position = 0; return stream; }
protected virtual Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg) { var stream = new MemoryStream(); var cf = cfg.ImageType == ImageType.Png ? Bitmap.CompressFormat.Png : Bitmap.CompressFormat.Jpeg; using (var bitmap = writer.Write(cfg.BarCode)) bitmap.Compress(cf, 0, stream); stream.Position = 0; return(stream); }
public virtual Stream Create(BarCodeCreateConfiguration cfg) { var writer = new BarcodeWriter { Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), cfg.Format.ToString()), Encoder = new MultiFormatWriter(), Options = new EncodingOptions { Height = cfg.Height, Margin = cfg.Margin, Width = cfg.Height, PureBarcode = cfg.PureBarcode } }; return(this.ToImageStream(writer, cfg)); }
protected abstract Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg);
protected virtual Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg) { return((cfg.ImageType == ImageType.Png) ? writer.Write(cfg.BarCode).AsPNG().AsStream() : writer.Write(cfg.BarCode).AsJPEG().AsStream()); }
protected virtual Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg) { return(new MemoryStream(writer.Write(cfg.BarCode).ToByteArray())); }
protected abstract Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg);
protected override Stream ToImageStream(ZXing.Mobile.BarcodeWriter writer, BarCodeCreateConfiguration cfg) { return (cfg.ImageType == ImageType.Png) ? writer.Write(cfg.BarCode).AsPNG().AsStream() : writer.Write(cfg.BarCode).AsJPEG().AsStream(); }