i have stored image path in database. when i access these images from database i converted them to thumbnail so that images to be displayed in image box should not be distorted. i have converted the image in thumbnail but am not able to show that thumbnail to image box with in the same page .The thumbnail is stored in byte array and can response to next page but i want to show image in that page only when user clicks on the button show. please suggest something.
code is:
protected void Button1_Click(object sender, EventArgs e)
{
SqlDataAdapter adp = new SqlDataAdapter("select pic from images where userid=" + 1, con);
DataSet ds = new DataSet();
adp.Fill(ds);
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(ds.Tables[0].Rows[0][0].ToString()));
System.Drawing.Image thumbnailImage = image.GetThumbnailImage(900,900, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
MemoryStream imageStream = new MemoryStream();
thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageContent = new Byte[imageStream.Length];
imageStream.Position = 0;
imageStream.Read(imageContent, 0, (int)imageStream.Length);
byte[] bt;
Response.ContentType = "image/jpeg";
bt = ((byte[])imageContent);
Response.BinaryWrite(bt);
}
public bool ThumbnailCallback()
{
return true;
}
[edit]Code block added - OriginalGriff[/edit]