FLASH產生圖像的範例範例 http://www.lzlive.com/outjpg/
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="send.aspx.cs" Inherits="send2" %>
<!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 runat="server">
<title>無標題頁</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
=========================================.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing.Imaging;
using System.Text;
using System.IO;
public partial class send2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Request.SaveAs(Page.MapPath("./") + "/text.txt", true);
// isConn.HostCheckCookies(false, true, "Login.aspx?Url=" + Request.RawUrl.ToString(), null);
if (!Page.IsPostBack)
{
// int Mid = int.Parse(isConn.GetHostCookiesItem("v1").ToString());
string View = (Request.QueryString["View"] != null) ? Request.QueryString["View"].ToString() : null;
if (View == null)
{
// SetImg(Mid);
}
else if (View.Equals("Com"))
{
int w = int.Parse(Request.Form["width"].ToString());
int h = int.Parse(Request.Form["height"].ToString());
string[] pixelColor = new string[h];
for (int i = 0; i < h; i++)
{
pixelColor[i] = Request.Form["PX" + i].ToString();
}
SaveJpg(w, h, pixelColor);
}
}
}
protected void SaveJpg(int width, int height, string[] pixelColor)
{
Bitmap image = new Bitmap(width, height);
string delimStr = ",";
char[] delimiter = delimStr.ToCharArray();
for (int i = 0; i < height; i++)
{
string[] colDot = pixelColor[i].ToString().Split(delimiter);
for (int j = 0; j < colDot.Length; j++)
{
int rgb = Convert.ToInt32(colDot[j].ToString());
image.SetPixel(j, i, Color.FromArgb(rgb));
}
}
string text2 = DateTime.Now.ToString("yyyyMMddhhmmss") + ".jpg";
string SavePath = base.Server.MapPath("./") + text2;
image.Save(SavePath, ImageFormat.Jpeg);
Response.ContentType = "image/jpeg";
image.Save(Response.OutputStream, ImageFormat.Jpeg);
image.Dispose();
}
}
[Edit on 2006-7-9 13:15:46 By tansenen]
來源:
http://www.lzlive.net/riji/showlog.asp?cat_id=44&log_id=643