C# 比较asp.net图像的尺寸
我们有两张图片C# 比较asp.net图像的尺寸,c#,asp.net,image,compare,dimensions,C#,Asp.net,Image,Compare,Dimensions,我们有两张图片 Image tempImage = new Image(); tempImage.width = 500; Image tempImage2 = new Image(); tempImage2.width = 1000; 我想比较这些图像的宽度,找到宽度更大的图像: 我尝试了以下几点: if (tempImage.Width < tempImage2.Width) Response.write("width of tempImage2 is bigger"); else
Image tempImage = new Image();
tempImage.width = 500;
Image tempImage2 = new Image();
tempImage2.width = 1000;
我想比较这些图像的宽度,找到宽度更大的图像:
我尝试了以下几点:
if (tempImage.Width < tempImage2.Width) Response.write("width of tempImage2 is bigger");
else Response.write("width of tempImage1 is bigger");
Image1.Width = (int)Math.Max(Convert.toDouble(tempImage.Width),Convert.toDouble(tempImage2.Width));
Response.Write("max width is " + Image1.Width);
编译器无法将宽度转换为双精度
那么,如何比较图像的宽度并找到宽度更大的图像呢?这对我很有用:
protected void Page_Load(object sender, EventArgs e)
{
Image tmp1 = new Image();
Image tmp2 = new Image();
tmp1.Width = new Unit(500);
tmp2.Width = new Unit(1000);
Response.Write(tmp1.Width.Value < tmp2.Width.Value);
}
受保护的无效页面加载(对象发送方,事件参数e)
{
图像tmp1=新图像();
图像tmp2=新图像();
tmp1.宽度=新装置(500);
tmp2.宽度=新单位(1000);
写入(tmp1.Width.Value
祝你好运 这对我很有用:
protected void Page_Load(object sender, EventArgs e)
{
Image tmp1 = new Image();
Image tmp2 = new Image();
tmp1.Width = new Unit(500);
tmp2.Width = new Unit(1000);
Response.Write(tmp1.Width.Value < tmp2.Width.Value);
}
受保护的无效页面加载(对象发送方,事件参数e)
{
图像tmp1=新图像();
图像tmp2=新图像();
tmp1.宽度=新装置(500);
tmp2.宽度=新单位(1000);
写入(tmp1.Width.Value
祝你好运 我会先将宽度放入var中,然后比较它
int width1 = image1.Width.Value;
int width2 = image2.Width.Value;
if(width1 < width2){
//apply code }
int-width1=image1.Width.Value;
int width2=image2.Width.Value;
如果(宽度1<宽度2){
//应用代码}
我会先将宽度放入变量中,然后比较它
int width1 = image1.Width.Value;
int width2 = image2.Width.Value;
if(width1 < width2){
//apply code }
int-width1=image1.Width.Value;
int width2=image2.Width.Value;
如果(宽度1<宽度2){
//应用代码}
出现错误是因为图像的Width属性是一种类型,而不是标量,并且没有为其实现比较运算符
if (i.Width.Value < j.Width.Value)
if(i.Width.Value
将起作用,但该比较仅在单元的参数相同时才有效。在您的示例中,它默认为“像素”,但在更一般的情况下,您需要确保比较的是同一单位的值。出现错误是因为图像的“宽度”属性是一种类型,而不是标量,并且没有为其实现比较运算符
if (i.Width.Value < j.Width.Value)
if(i.Width.Value
将起作用,但该比较仅在单元的参数相同时才有效。在您的示例中,它默认为像素,但在更一般的情况下,您需要确保比较相同单位的值