欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門(mén)教程網(wǎng)!

C#教程

當(dāng)前位置:主頁(yè) > 軟件編程 > C#教程 >

C#如何消除驗(yàn)證碼圖片的鋸齒效果

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C#教程|點(diǎn)擊: 次

引言 

      基于生成圖片實(shí)現(xiàn)了一個(gè)手機(jī)號(hào)轉(zhuǎn)圖片的需求。 內(nèi)容也很簡(jiǎn)單,直接用手機(jī)號(hào)生成一個(gè)png圖片。就是為了背景透明以便其他地方調(diào)用。 有無(wú)鋸齒主要依靠一句代碼:g.TextRenderingHint= TextRenderingHint.AntiAlias; 

生成圖片  

1、有鋸齒 


2、無(wú)鋸齒

生成方法

string color = "#ff6633"; 

    System.Drawing.Bitmap image = new System.Drawing.Bitmap(170, 35);
    Graphics g = Graphics.FromImage(image);
    try
    {
      g.TextRenderingHint= TextRenderingHint.AntiAlias; //消除鋸齒
      

      //生成隨機(jī)生成器
      Random random = new Random();
     //清空?qǐng)D片背景色
      //g.Clear(Color.Transparent);
      //畫(huà)圖片的背景噪音線

      /*for (int i = 0; i < 2; i++)

      {
        int x1 = random.Next(image.Width);
        int x2 = random.Next(image.Width);
        int y1 = random.Next(image.Height);
        int y2 = random.Next(image.Height);
        g.DrawLine(new Pen(Color.Black), x1, y1, x2, y2);

      }

      */

      System.Drawing.ColorConverter colConvert = new System.Drawing.ColorConverter();
      Color fontColor =(System.Drawing.Color)colConvert.ConvertFromString(color);
      Font font = new System.Drawing.Font("Arial", 18, System.Drawing.FontStyle.Bold);
      LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), fontColor, fontColor,LinearGradientMode.Horizontal);
      g.DrawString(phone, font, brush, 2, 2);
      //畫(huà)圖片的前景噪音點(diǎn)
       //for (int i = 0; i < 50; i++)
      //{
      //  int x = random.Next(image.Width);
      //  int y = random.Next(image.Height);
      //  image.SetPixel(x, y, Color.FromArgb(random.Next()));

      //}

 

      //畫(huà)圖片的邊框線

      //g.DrawRectangle(new Pen(Color.White), 0, 0, image.Width - 1, image.Height - 1);

 

      System.IO.MemoryStream ms = new System.IO.MemoryStream();
      Color backColor = image.GetPixel(1, 1);
      image.MakeTransparent(backColor);
      image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
      context.Response.ClearContent();
      context.Response.ContentType = "image/x-png";
      context.Response.BinaryWrite(ms.ToArray());
    }
    finally
    {
      g.Dispose();
      image.Dispose();

    }

參考資料 

http://www.blue1000.com/bkhtml/c17/2013-03/71115.htm

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:WPF 自定義雷達(dá)圖開(kāi)發(fā)實(shí)例教程

欄    目:C#教程

下一篇:解決C#中Linq GroupBy 和OrderBy失效的方法

本文標(biāo)題:C#如何消除驗(yàn)證碼圖片的鋸齒效果

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6256.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有