如何将数据库里读出的图像缩小啊,它总是与原图像一样大小,改不了,请教一下。
这是我的代码:
ShowPhoto.aspx文件:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShowPhoto.aspx.cs" Inherits="_Default" %><!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:imagebutton ID="imagebutton1" runat ="server" Width =120 Height =150 ImageUrl ="ShowPhoto.aspx" ToolTip ="nihao"  />
    </div>
    </form>
</body>
</html>ShowPhoto.aspx.cs文件:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Configuration;
using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
{
    private string SQLCONNECTIONSTRING = ConfigurationSettings.AppSettings["SQLCONNECTIONSTRING"].ToString();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack) 
        { 
            SqlConnection conn=new SqlConnection(SQLCONNECTIONSTRING ); 
            //SqlCommand cmd=new SqlCommand("UpdateImage",conn); 
            string strSql="select * from test where id=2";//这里假设获取id为2的图片 
            SqlCommand cmd=new SqlCommand(strSql ,conn);
            conn.Open();
            SqlDataReader reader=cmd.ExecuteReader();
            reader.Read();
            //img1.Width = 2000;
            //img1.Height = 2000;
            Response.ContentType="application/octet-stream"; 
            Response.BinaryWrite((Byte[])reader["FImage"]); 
            Response.End();
            
            reader.Close();
            
        }
    }
}