【发布时间】:2011-02-01 05:38:20
【问题描述】:
int newWidth = 100;
int newHeight = 100;
double ratio = 0;
if (img1.Width > img1.Height)
{
ratio = img1.Width / img1.Height;
newHeight = (int)(newHeight / ratio);
}
else
{
ratio = img1.Height / img1.Width;
newWidth = (int)(newWidth / ratio);
}
Image bmp1 = img1.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero);
bmp1.Save(Server.MapPath("~/Uploads/Photos/Thumbnails/") + photo.PhotoID + ".jpg");
我总是得到高度和宽度具有相同值的图像 (100)
我在类型转换方面明显做错了什么?
【问题讨论】:
-
img1.Width和img1.Height有什么值? -
@Präriewolf:我没有收到任何错误。 @PéterTörök:嗯...我不太确定,但我认为它是整数,因为我可以毫无错误地声明 newWidth = img1.Width。
-
你能举一些你正在测试的图片尺寸的例子吗?
-
width=800 和 height=533
标签: c# integer double type-conversion