关于IMAGE控件读取图片,能读内存里的而不读本地的吗?
protected void Page_Load(object sender, EventArgs e)
{
string photoid;
photoid = Request.Params[ "id "];
Image aa = (Image)FormView1.FindControl( "Image1 ");
aa.ImageUrl = GetPicPath(photoid);
}
private string GetPicPath(string addictNo)
{
OracleConnection conn = new OracleConnection( " ");
OracleCommand Oraclecomm = new OracleCommand();
Oraclecomm.CommandText = "SELECT pic FROM pp WHERE rybh = ' " + addictNo + " ' ";
Oraclecomm.Connection = conn;
OracleDataAdapter da = new OracleDataAdapter(Oraclecomm);
DataSet ds = new DataSet();
conn.Open();
da.Fill(ds, "pp ");
conn.Close();
Response.Clear();
//将图片数据存成本地文件
string tempfile = " " + addictNo + ".jpg ";
string fpath = Server.MapPath(Request.ApplicationPath) + "\\temp\\ " + tempfile;
FileStream fs = new FileStream(fpath, FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write((byte[])ds.Tables[ "pp "].Rows[0][0]);
bw.Close();
return "temp/ " + tempfile;
}
这个是我写的满标准的从ORACLE数据库中读去图片然后显示,但是我有时候同时要取6张照片,这个时候速度问题就非常,请问如何直接让IMAGE控件读内存里的图片,而不需要做保存到本地那一步,谢谢指教。。真的不会写~~
------解决方案--------------------写个页面专门用来输出图片.
在这个页面中,根据传来的条件
bw.Write((byte[])ds.Tables[ "pp "].Rows[0][0]);
==>
换成
Response.BinaryWrite((byte)[]....)
就可以了.
调用
aa.ImageUrl = "showimage.aspx?id= "+id;
------解决方案--------------------试试这个方法:
http://www.eggheadcafe.com/articles/20050911.asp