最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
在网页中动态的生成一个gif图片
时间:2022-07-02 12:06:25 编辑:袖梨 来源:一聚教程网
大家知道股票网站的K线图是动态生成的定时刷新PHP 就有动态生成图片的功能
那么怎样用asp.net在网页中动态的生成一个图片呢?
下面我要举的例子是动态的生成一个图片显示当前时间
namespace Wmj
{
using System;
using System.Drawing;
using System.Web.UI;
public class MyTempImage : Page
{
public string CreateImage()
{
string str=DateTime.Now.ToString();
Bitmap image=new Bitmap(200,30);
Graphics g=Graphics.FromImage(image);
string thefullname=Server.MapPath("/")+"nowtime.gif";
g.Clear(Color.White);
g.DrawString(str,new Font("Courier New", 10),new SolidBrush(Color.Red),20,5);
//Graphics 类还有很多绘图方法可以绘制 直线、曲线、圆等等
image.Save(thefullname,System.Drawing.Imaging.ImageFormat.Gif);
return "/nowtime.gif";
}
}
}
///////////////////////////////////////////
<%@page language="C#"%>
<%@Import namespace="Wmj"%>
那么怎样用asp.net在网页中动态的生成一个图片呢?
下面我要举的例子是动态的生成一个图片显示当前时间
namespace Wmj
{
using System;
using System.Drawing;
using System.Web.UI;
public class MyTempImage : Page
{
public string CreateImage()
{
string str=DateTime.Now.ToString();
Bitmap image=new Bitmap(200,30);
Graphics g=Graphics.FromImage(image);
string thefullname=Server.MapPath("/")+"nowtime.gif";
g.Clear(Color.White);
g.DrawString(str,new Font("Courier New", 10),new SolidBrush(Color.Red),20,5);
//Graphics 类还有很多绘图方法可以绘制 直线、曲线、圆等等
image.Save(thefullname,System.Drawing.Imaging.ImageFormat.Gif);
return "/nowtime.gif";
}
}
}
///////////////////////////////////////////
<%@page language="C#"%>
<%@Import namespace="Wmj"%>
相关文章
- 火影忍者木叶高手怎么快速升级 快速升级途径 08-17
- 植物大战僵尸杂交版2.5.1版本更新了什么-植物大战僵尸杂交版2.5.1版本更新内容介绍 08-17
- 火影忍者木叶高手前期怎么配队 前期队伍搭配攻略 08-17
- 燕云十六声武道心宫怎么玩 武道心宫玩法教学 08-17
- 燕云十六声家园庄客先招募哪些 家园庄客招募推荐 08-17
- 沙威玛传奇苹果怎么下载-沙威玛传奇iOS版本下载教程 08-17