간단한 그림 축소판 응용 프로그램을 만들려고합니다. 저는 웹을 검색하여 간단한 섬네일 앱과 상당히 복잡한 섬네일 앱을 발견했습니다. 내가 좋은 ImageButton 해상도를 얻을 수 있다면 좋은 일을했습니다. 현재 모든 것이 잘 작동하지만 버튼의 재사용은 끔찍합니다 (다양한 폭/높이 변형을 시도했습니다).C# ImageButton 그림 해상도
간단히 버튼 Image의 배열을 반복하고 속성을 설정합니다. ThumbnailSize()를 호출하여 Imagebutton의 너비/높이를 설정합니다.
코드는 현재로서는 다소 엉성합니다. ImageButton 해상도를 유지하거나 높이는 방법 (800x600 +/-)을 ImageButton으로 줄이는 방법을 알고 싶습니다.
string[] files = null;
files = Directory.GetFiles(Server.MapPath("Pictures"), "*.jpg");
ImageButton[] arrIbs = new ImageButton[files.Length];
for (int i = 0; i < files.Length; i++)
{
arrIbs[i] = new ImageButton();
arrIbs[i].ID = "imgbtn" + Convert.ToString(i);
arrIbs[i].ImageUrl = "~/Gallery/Pictures/pic" + i.ToString() + ".jpg";
ThumbNailSize(ref arrIbs[i]);
//arrIbs[i].BorderStyle = BorderStyle.Inset;
arrIbs[i].AlternateText = System.IO.Path.GetFileName(Convert.ToString(files[i]));
arrIbs[i].PostBackUrl = "default.aspx?img=" + "pic" + i.ToString();
pnlThumbs.Controls.Add(arrIbs[i]);
}
}
public ImageButton ThumbNailSize(ref ImageButton imgBtn)
{
//Create Image with ImageButton path, and determine image size
System.Drawing.Image img =
System.Drawing.Image.FromFile(Server.MapPath(imgBtn.ImageUrl));
if (img.Height > img.Width)
{
//Direction is Verticle
imgBtn.Height = 140;
imgBtn.Width = 90;
return imgBtn;
}
else
{
//Direction is Horizontal
imgBtn.Height = 110;
imgBtn.Width = 130;
return imgBtn;
}
}
http://stackoverflow.com/questions/249587/high-quality-image-scaling-c –