Exemplo n.º 1
0
		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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 7
0
 protected abstract Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg);
Exemplo n.º 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());
 }
Exemplo n.º 9
0
 protected virtual Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg)
 {
     return(new MemoryStream(writer.Write(cfg.BarCode).ToByteArray()));
 }
Exemplo n.º 10
0
 protected abstract Stream ToImageStream(BarcodeWriter writer, BarCodeCreateConfiguration cfg);
Exemplo n.º 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();
 }