日期:2014-05-17 浏览次数:20615 次
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>test</title>
</head>
<body>
<form id="form1" runat="server" >
<asp:Image ID="Image1" runat="server" />
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (Request["getimg"] != null)
{
// 设定起止日期,可以从数据库中读取
DateTime start = DateTime.Parse("2005/1/1");
DateTime end = DateTime.Parse("2015/1/1");
// 获取背景图片,你也可以用Image.FromFile从文件创建对象
WebClient wc = new WebClient();
byte[] pic = wc.DownloadData("http://sign.liba.com/qm/baby/Basemap/a17.jpg");
System.Drawing.Image bg = System.Drawing.Image.FromStream(new MemoryStream(pic));
// 获取人物图片,你也可以用Image.FromFile从文件创建对象
pic = wc.DownloadData("http://sign.liba.com/qm/baby/person/cyworld473.gif");
System.Drawing.Image people = System.Drawing.Image.FromStream(new MemoryStream(pic));
// 计算当前进度位置
double p = (double)(DateTime.Now - start).Ticks / (end - start).Ticks;
int x = (int)(bg.Width * p);
// 把人物和图片混合起来
Bitmap bmp = new Bitmap(bg.Width, bg.Height, PixelFormat.Format32bppArgb);
Graphics gr = Graphics.FromImage(bmp);
gr.DrawImage(bg, 0, 0);
gr.DrawImage(people, x, 0);
// 写一些文字
gr.DrawString(string.Format("今天是{0}", DateTime.Now), new Font("宋体", 12), new SolidBrush(Color.Red), 0, 0);
// 输出图片
Response.Clear();
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
Response.End();
}
else
Image1.ImageUrl = Request.Url.AbsolutePath + "?getimg=true";
}
</script>
</form>
</body>
</html>
------解决方案--------------------
广告贴 鉴定完毕!
------解决方案--------------------
我也需要。。。。。。跪求高手