本文介绍了我有150mb的图像大小,当我启动Web应用程序时必须等待很长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
i have got 150mb image size , when i start my web application then have to wait long time.... thats why , i did split into small part
when user drag left hand side two small part join together current display image and left hand side..... similar way right hand side top ...., bottom like a google map when you drag image mege it and cache it help me
<%@ WebHandler Language="C#" Class="ReadImage" %>
using System;
using System.Web;
using System.Data.SqlClient;
using System.IO;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
public class ReadImage : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
Int32 e_id = 1;
if (context.Request.QueryString["id"] != null)
{
e_id = Convert.ToInt32(context.Request.QueryString["id"]);
}
else
throw new ArgumentException("No parameter specified");
context.Response.ContentType = "image/jpeg";
Stream strm = DisplayImage(e_id);
byte[] buffer = new byte[strm.Length];
int byteSeq = strm.Read(buffer, 0,(int) strm.Length);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, (int)strm.Length);
}
}
public Stream DisplayImage(int ID)
{
string cs = ConfigurationManager.ConnectionStrings["LocationTrackingConnectionString"].ConnectionString;
using (SqlConnection connection = new SqlConnection(cs))
{
string sql = "SELECT image FROM tblImage WHERE id between @ID1 and @ID2 ";
using (SqlCommand cmd = new SqlCommand(sql, connection))
{
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.Add("@ID1",System.Data.SqlDbType.Int).Value=ID;
cmd.Parameters.Add("@ID2", System.Data.SqlDbType.Int).Value = 20;
connection.Open();
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
//SqlDataReader theImg = cmd.ExecuteReader();
object img1 = ds.Tables[0].Rows[0].ItemArray[0];
object img2 = ds.Tables[0].Rows[1].ItemArray[0];
try
{
return new MemoryStream((byte[])img1);
}
catch
{
return null;
}
finally
{
cmd.Dispose();
connection.Close();
connection.Dispose();
}
}
}
}
public bool IsReusable {
get {
return false;
}
}
}
推荐答案
这篇关于我有150mb的图像大小,当我启动Web应用程序时必须等待很长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!