저는 mvc2를 사용하고 있는데 컨트롤러에서 작업을 사용하고 싶습니다. 예를 들어 ShowSmallImage)
을 입력하고 브라우저에 www.url.com/ShowSmallImage를 입력하면 이미지가 출력됩니다. 내가 브라우저에서만 System.Drawing.Bitmap을 얻을 결과C를 사용하여 이미지 표시
public Bitmap CreateThumbnail()
{
Image img1 = Image.FromFile(@"C:...\Uploads\Photos\178.jpg");
int newWidth = 100;
int newHeight = 100;
double ratio = 0;
if (img1.Width > img1.Height)
{
ratio = img1.Width/(double)img1.Height;
newHeight = (int)(newHeight/ratio);
}
else
{
ratio = img1.Height/(double)img1.Width;
newWidth = (int)(newWidth/ratio);
}
//a holder for the result
Bitmap result = new Bitmap(newWidth, newHeight);
//use a graphics object to draw the resized image into the bitmap
using (Graphics graphics = Graphics.FromImage(result))
{
//set the resize quality modes to high quality
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//draw the image into the target bitmap
graphics.DrawImage(img1, 0, 0, result.Width, result.Height);
}
return result;
}
:
나는 이런 식으로 뭔가를 시도했다. 나는 ... 나는 페이지의 응답/콘텐츠 유형을 설정해야하지만, 그것을 수행하는 방법 아무 생각이감사합니다,
일드
실제로이 내용을 응답 스트림에 쓰고 있습니까? 여기에서하는 모든 작업은 이미지 조작입니다. –
컨트롤러에서. 먼저 조작을하고 썸네일을 표시하고 싶습니다 –