0
다음 HttpHandler는 데이터베이스에서 이미지를 검색합니다. 처음 테스트했을 때 제대로 작동했습니다. 하지만 이제 문제는 이미지를 여전히 retieve하지만 Listview에있는 이미지 컨트롤에 표시하지 않는다는 것입니다.HttpHandler 문제, 이미지 가져 오기
`public void ProcessRequest (HttpContext context)
{
string imageid = context.Request.QueryString["ImID"];
using (SqlConnection connection = ConnectionManager.GetConnection())
{
SqlCommand command = new SqlCommand("select Normal_Thumbs from User_Images where Id=" + imageid, connection);
SqlDataReader dr = command.ExecuteReader();
dr.Read();
if (dr[0] != DBNull.Value)
{
Stream str = new MemoryStream((Byte[])dr[0]);
Bitmap Photo = new Bitmap(str);
int Width = Photo.Width;
int Height = Photo.Height;
int imagesize = 200;
if (Photo.Width > Photo.Height)
{
Width = imagesize;
Height = Photo.Height * imagesize/Photo.Width;
}
else
{
Width = Photo.Width * imagesize/Photo.Height;
Height = imagesize;
}
Bitmap bmpOut = new Bitmap(150, 150);
Graphics g = Graphics.FromImage(bmpOut);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(Brushes.White, 0, 0, Width, Height);
g.DrawImage(Photo, 0, 0, Width, Height);
MemoryStream ms = new MemoryStream();
bmpOut.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] bmpBytes = ms.GetBuffer();
bmpOut.Dispose();
ms.Close();
context.Response.Write(bmpBytes);
context.Response.End();
}
}
}
처리기 이미지를 가져 오지만 목록보기에는 표시되지 않습니다.
와우 .. 붐 ... 고마워 ... 그게 효과가 ... 사실이게 왜 문제 야? 응답을 삭제하는 이유는 무엇입니까? – user1575229
출력물을 [** fiddler **] (http://www.fiddler2.com/fiddler2/)로 확인할 수 있습니다. 그렇게하면 코드가 응답에 미치는 영향을 이해할 수있을뿐만 아니라 강력한 도구를 알게됩니다. – danielQ
감사합니다 ... 다니엘 .. 정말 도움이됩니다. – user1575229