我需要一种方法来计算图像的宽度和高度值调整到1024px时如何在调整大小时计算图像的宽度和高度值?
图像的最大值,高度或宽度将被调整为1024px,我需要找出剩余的宽度或高度值。
调整大小时,图像(3200 x 2400px)转换为(1024 x 768px)。
这需要是动态的,因为一些图像将是人像和一些风景。
任何人都可以建议如何我工作的解决方案为以下:
<msxsl:script language="C#" implements-prefix="emint">
<![CDATA[public string GetExtension(string fileName)
{
string[] terms = fileName.Split('.');
if (terms.Length <= 0)
{
return string.Empty;
}
return terms[terms.Length -1];
}
public string GetFileName(string fileName)
{
string[] terms = fileName.Split('/');
if (terms.Length <= 0)
{
return string.Empty;
}
return terms[terms.Length -1];
}
public string GetFileSize(Decimal mbs)
{
Decimal result = Decimal.Round(mbs, 2);
if (result == 0)
{
result = mbs * 1024;
return Decimal.Round(result, 2).ToString() + " KB";
}
return result.ToString() + " MB";
}
public string GetCentimeters(Decimal pix)
{
Decimal formula = (decimal)0.026458333;
Decimal result = pix * formula;
return Decimal.Round(result,0).ToString();
}]]>
</msxsl:script>
可能重复的[如何“智能调整大小”所显示的图像以原始长宽比](http://stackoverflow.com/questions/3008772/how-to-smart-resize-a-displayed-image -to-原始长宽比) – PleaseStand 2011-04-19 02:32:28