当前位置:首页 > 网络编程 > WEB编程 > ASP.net > 如何用.NET技术在线生成网站LOGO

如何用.NET技术在线生成网站LOGO

点击次数:50 次 发布日期:2008-11-21 22:06:43 作者:源代码网
源代码网推荐

源代码网整理以下也许大家一看标题就知道,又是老生常谈了,在线生成LOGO其实就是在线生成图片,原理听起来很简单:

源代码网整理以下1. new一个bitmap或类似之物;

源代码网整理以下2. 用一个graphic在上边画出你想要的东西;

源代码网整理以下3. 保存,显示出来,大功告成。

源代码网整理以下今天要说的是生成中的一些细节问题。没有真正做过,你可能永远也不知道有这样的问题。下边提到的问题和代码,希望对各位有所帮助。

源代码网整理以下本文的示例程序在http://www.ladysolution.cn/logo.aspx

源代码网整理以下一。 字体位置。

源代码网整理以下用不同的字体,如果通过计算字体高度来给字体定位是不精确的,不同的字体有不同的em baseline,而且descending 和 ascending 得出来的值几乎很难用来算精确高度,更麻烦的是如果字体是某人造的,那EM更靠不住,最大的问题是文字上方的空白目前我没有找到适合的公式来计算。我用的是比较笨的办法,计算精确的字体高度:

源代码网整理以下

以下为引用的内容:

源代码网整理以下  private static int[] GetRealFontHeight(Bitmap bmp)

源代码网整理以下  {

源代码网整理以下  int width, height;

源代码网整理以下  int frequency = 2;// higher frequency gets lower performance.

源代码网整理以下  int[] ret = new int[2];

源代码网整理以下  Color c;

源代码网整理以下  bool goOut = false;

源代码网整理以下  for (height = 1; height < bmp.Height - 1; height += frequency)

源代码网整理以下  {

源代码网整理以下  for (width = 1; width < bmp.Width - 1; width += frequency)

源代码网整理以下  {

源代码网整理以下  c = bmp.GetPixel(width, height);

源代码网整理以下  if (c.Name.Length>0 && c.Name != "0")//got it!

源代码网整理以下  {

源代码网整理以下  ret[0] = height;

源代码网整理以下  goOut = true;

源代码网整理以下  break;

源代码网整理以下  }

源代码网整理以下  else

源代码网整理以下  {

源代码网整理以下  goOut = false;

源代码网整理以下  }

源代码网整理以下  }

源代码网整理以下  if (goOut)

源代码网整理以下  break;

源代码网整理以下  }

源代码网整理以下  goOut = false;

源代码网整理以下 源代码网供稿.

网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华