最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實(shí)現(xiàn)將Email地址轉(zhuǎn)成圖片顯示的方法

 更新時(shí)間:2015年06月16日 15:54:03   作者:紅薯  
這篇文章主要介紹了C#實(shí)現(xiàn)將Email地址轉(zhuǎn)成圖片顯示的方法,涉及C#操作圖片的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了C#實(shí)現(xiàn)將Email地址轉(zhuǎn)成圖片顯示的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

private final static IndexColorModel icm = createIndexColorModel();
/**
 * 生成電子郵件圖片
 * @param email
 * @param out
 * @throws IOException
 */
public static void MakeEmailImage(String email, OutputStream out) throws IOException {
  int height = 22;
  BufferedImage bi = new BufferedImage(255,height,BufferedImage.TYPE_INT_RGB);    
  Graphics2D g = (Graphics2D)bi.getGraphics();
  Font mFont = new Font("Verdana", Font.PLAIN, 14);
  g.setFont(mFont);
  g.drawString(email, 2, 19);
  FontMetrics fm = g.getFontMetrics();
  int new_width = fm.charsWidth(email.toCharArray(), 0, email.length()) + 4;
  int new_height = fm.getHeight();
  BufferedImage nbi = new BufferedImage(new_width, new_height, BufferedImage.TYPE_BYTE_INDEXED, icm);
  Graphics2D g2 = (Graphics2D)nbi.getGraphics();
  g2.setColor(new Color(0,0,0,0));//透明
  g2.fillRect(0,0,new_width,new_height);
  g2.setFont(mFont);
  g2.setColor(new Color(200,0,0));
  g2.drawString(email, 2, new_height-4);
  ImageIO.write(nbi, "gif", out);
}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

梧州市| 南和县| 大安市| 西峡县| 宣武区| 开远市| 喜德县| 遂溪县| 五常市| 双流县| 黄大仙区| 中西区| 富阳市| 伊宁市| 文成县| 永顺县| 吉木萨尔县| 綦江县| 越西县| 思茅市| 古丈县| 福建省| 江津市| 汶川县| 田阳县| 高唐县| 南召县| 绥滨县| 哈巴河县| 腾冲县| 恩施市| 太仓市| 泽库县| 宜阳县| 酉阳| 新郑市| 青海省| 沭阳县| 宜川县| 建昌县| 上饶县|