示例#1
0
        private void GenImage()
        {
            if (string.IsNullOrWhiteSpace(Value) || string.IsNullOrWhiteSpace(Format))
            {
                return;
            }
            try
            {
                System.Drawing.Bitmap imageData = ZXingUtil.CreateImage(this.Value1, this.Format, (int)this.Width, (int)this.Height, this.Value == "是" ? false : true, this.FontName, (int)this.FontSize);
                var bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(imageData.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight((int)imageData.Width, (int)imageData.Height));

                if (this.PreviewValue is Image == false)
                {
                    this.PreviewValue = new Image();
                }
                var image = this.PreviewValue as Image;
                image.Source = bs;
            }
            catch (Exception ex)
            {
                this.PreviewValue = "生成预览出错:" + ex.Message;
            }
        }
示例#2
0
 public object Format(PrintTemplate template, PrintTemplateItem item, OrderReturn or)
 {
     return(ZXingUtil.CreateImage(or.Id.ToString(), item.Format, (int)item.Width, (int)item.Height, item.Value1 == "是" ? false : true, item.FontName, (float)item.FontSize));
 }