码迷,mamicode.com
首页 > 其他好文 > 详细

csharp: QR Code Barcode

时间:2014-07-09 20:16:16      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:des   blog   http   color   width   os   

/// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                int scale = 4;
                qrCodeEncoder.QRCodeScale = scale;
                int version = 7;
                qrCodeEncoder.QRCodeVersion = version;
                qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                System.Drawing.Image image;
                String data = Request.Url.AbsoluteUri;// "http://www.dusystem.com/  涂聚文";
                image = qrCodeEncoder.Encode(data);
                //picEncode.Image = image;

                string filename = "geovinduQrcode.jpg";
                string file = Server.MapPath(filename);
                image.Save(file);
                this.Image1.ImageUrl = filename;

            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            QRCodeEncoder encoder = new QRCodeEncoder();
            encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H; // 30%
            encoder.QRCodeScale = 10;
            System.Drawing.Image img = encoder.Encode("www.dusystem.com");
            string filename = "geovinduQrcodeVi.jpg";
            string file = Server.MapPath(filename);
            string log = Server.MapPath("nasa.bmp");

            System.Drawing.Image logo = System.Drawing.Image.FromFile(log);
            int left = (img.Width / 2) - (logo.Width / 2);
            int top = (img.Height / 2) - (logo.Height / 2);
            Graphics g = Graphics.FromImage(img);
            g.DrawImage(logo, new Point(left, top));
            string filename1 = "QrcodeVi.jpg";
            img.Save(Server.MapPath(filename1));
            this.Image2.ImageUrl = filename1;
        }
 /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                System.Drawing.Image img;
                Bitmap temp = new Bitmap(1, 1);
                temp.SetPixel(0, 0, Color.Black);
                img = (System.Drawing.Image)temp;
                int W = 300;
                int H = 150;
                b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
                b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
                BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
                type = BarcodeLib.TYPE.CODE128;
                b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;
                b.IncludeLabel = true;
                b.RotateFlipType = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), "RotateNoneFlipNone", true);

                img = b.Encode(type, "00800900000011", Color.Black, Color.White, W, H);
                string filename = "geovindu.jpg";
                string file = Server.MapPath(filename);
                img.Save(file);
                this.Image1.ImageUrl = filename;
            }
        }

 

csharp: QR Code Barcode,布布扣,bubuko.com

csharp: QR Code Barcode

标签:des   blog   http   color   width   os   

原文地址:http://www.cnblogs.com/geovindu/p/3831505.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!