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);
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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));
        }
Beispiel #7
0
 protected abstract Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg);
Beispiel #8
0
 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());
 }
Beispiel #9
0
 protected virtual Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg)
 {
     return(new MemoryStream(writer.Write(cfg.BarCode).ToByteArray()));
 }
 protected abstract Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg);
Beispiel #11
0
 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();
 }