0
现在,我保存2大小的图像在数据库中,真正的大小和缩略图,然后显示他们当我需要。显示图像处理程序与调整大小
在ashx的处理程序我设置我需要哪种类型,这里是我的代码:
string field = context.Request.QueryString["field"];
string table = context.Request.QueryString["table"];
string id = context.Request.QueryString["id"];
string conn = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
SqlConnection myConnection = new SqlConnection(conn);
myConnection.Open();
string sql = "";
sql = "Select " + field + ", pictureType from " + table + " where [email protected]";
SqlCommand cmd = new SqlCommand(sql, myConnection);
cmd.Parameters.Add("@imageId", SqlDbType.Int).Value = id;
cmd.Prepare();
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
context.Response.ContentType = dr["pictureType"].ToString();
context.Response.BinaryWrite((byte[])dr[field]);
dr.Close();
myConnection.Close();
,我用这样的方式:
<img src="handlers/ShowPic.ashx?table=tblEnBackGrounds&field=image&id=1" alt="s" />
,但现在我决定要救就真实大小的图像,然后在ashx文件中重新调整大小并显示正确的类型(这里是真实或缩略图)。
现在我需要第一个到现在是好还是不好?第二我没有任何想法如何重新大小二进制数据之前显示在ashx处理程序
谢谢ivan.sivak,让我查一下 – user3400838
你很受欢迎。这对我来说很好:) –
什么ResizeSettings和ImageBuilder在你的代码?这是考虑图片方面? – user3400838