csharp: QR Code Barcode

來源:互聯網
上載者:User

標籤: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;            }        }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.