欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

asp.net如何使用QRCode生成圖片中心加Logo或圖像的二維碼-創(chuàng)新互聯(lián)

這篇文章給大家分享的是有關(guān)asp.net如何使用QRCode生成圖片中心加Logo或圖像的二維碼的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡(jiǎn)單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名申請(qǐng)、虛擬空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、錫林浩特網(wǎng)站維護(hù)、網(wǎng)站推廣。

具體如下:

<%@ WebHandler Language="C#" Class="GetQRCode" %>
using System;
using System.Web;
using ThoughtWorks.QRCode.Codec;
using ThoughtWorks.QRCode.Codec.Data;
using ThoughtWorks.QRCode.Codec.Util;
using System.IO;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
public class GetQRCode : IHttpHandler
{
  public void ProcessRequest(HttpContext context)
  {
    String data = context.Request["CodeText"];
    if (!string.IsNullOrEmpty(data))
    {
      QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
      qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
      qrCodeEncoder.QRCodeScale = 4;
      qrCodeEncoder.QRCodeVersion = 8;
      qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
      System.Drawing.Image image = qrCodeEncoder.Encode(data);
      System.IO.MemoryStream MStream = new System.IO.MemoryStream();
      image.Save(MStream, System.Drawing.Imaging.ImageFormat.Png);
      System.IO.MemoryStream MStream1 = new System.IO.MemoryStream();
      CombinImage(image, context.Server.MapPath("~/images/201292891051540.jpg")).Save(MStream1, System.Drawing.Imaging.ImageFormat.Png);
      context.Response.ClearContent();
      context.Response.ContentType = "image/png";
      context.Response.BinaryWrite(MStream1.ToArray());
      //image.Dispose();
      MStream.Dispose();
      MStream1.Dispose();
    }
    context.Response.Flush();
    context.Response.End();
  }
  /// <summary>
  /// 調(diào)用此函數(shù)后使此兩種圖片合并,類似相冊(cè),有個(gè)
  /// 背景圖,中間貼自己的目標(biāo)圖片
  /// </summary>
  /// <param name="imgBack">粘貼的源圖片</param>
  /// <param name="destImg">粘貼的目標(biāo)圖片</param>
  public static Image CombinImage(Image imgBack, string destImg)
  {
    Image img = Image.FromFile(destImg);    //照片圖片
    if (img.Height != 65 || img.Width != 65)
    {
      img = KiResizeImage(img, 65, 65, 0);
    }
    Graphics g = Graphics.FromImage(imgBack);
    g.DrawImage(imgBack, 0, 0, imgBack.Width, imgBack.Height);   //g.DrawImage(imgBack, 0, 0, 相框?qū)? 相框高);
    //g.FillRectangle(System.Drawing.Brushes.White, imgBack.Width / 2 - img.Width / 2 - 1, imgBack.Width / 2 - img.Width / 2 - 1,1,1);//相片四周刷一層黑色邊框
    //g.DrawImage(img, 照片與相框的左邊距, 照片與相框的上邊距, 照片寬, 照片高);
    g.DrawImage(img, imgBack.Width / 2 - img.Width / 2, imgBack.Width / 2 - img.Width / 2, img.Width, img.Height);
    GC.Collect();
    return imgBack;
  }
  /// <summary>
  /// Resize圖片
  /// </summary>
  /// <param name="bmp">原始Bitmap</param>
  /// <param name="newW">新的寬度</param>
  /// <param name="newH">新的高度</param>
  /// <param name="Mode">保留著,暫時(shí)未用</param>
  /// <returns>處理以后的圖片</returns>
  public static Image KiResizeImage(Image bmp, int newW, int newH, int Mode)
  {
    try
    {
      Image b = new Bitmap(newW, newH);
      Graphics g = Graphics.FromImage(b);
      // 插值算法的質(zhì)量
      g.InterpolationMode = InterpolationMode.HighQualityBicubic;
      g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
      g.Dispose();
      return b;
    }
    catch
    {
      return null;
    }
  }
  public bool IsReusable
  {
    get
    {
      return false;
    }
  }
}

感謝各位的閱讀!關(guān)于“asp.net如何使用QRCode生成圖片中心加Logo或圖像的二維碼”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

本文標(biāo)題:asp.net如何使用QRCode生成圖片中心加Logo或圖像的二維碼-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://chinadenli.net/article34/ddihse.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、定制開發(fā)、網(wǎng)站排名、網(wǎng)站建設(shè)、虛擬主機(jī)、網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)