在后台new了一个img,然后给它赋地址,但是取出它的宽和高怎么无法使用啊。
Image img = new Image();
img.ImageUrl = "touxiang.aspx?table=sell_list&id=" + id;
if ( Convert.ToInt32(img.Width) > 0 && Convert.ToInt32(img.Height) > 0)
红色部分判断该怎么写呢,总说无法将类型为“System.Web.UI.WebControls.Unit”的对象强制转换为类型“System.IConvertible”。
不太理解其中的内涵
Image img = new Image();
img.ImageUrl = "touxiang.aspx?table=sell_list&id=" + id;
if ( Convert.ToInt32(img.Width) > 0 && Convert.ToInt32(img.Height) > 0)
红色部分判断该怎么写呢,总说无法将类型为“System.Web.UI.WebControls.Unit”的对象强制转换为类型“System.IConvertible”。
不太理解其中的内涵
I.Images .Add();
int WIDTH = I.Images[0].Width;
IMAGE可以实例化???
这样
System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("touxiang.aspx?table=sell_list&id=" + id));
if (Convert.ToInt32(img.Width) > 0 && Convert.ToInt32(img.Height) > 0)
{
}
this.image = System.Drawing.Image.FromFile(imagePath);
touxiang.aspx?table=sell_list&id="+id 是个页面从数据库中读出二进制数据流生成图片的,这样写,显示虚拟路径不正确啊。
用img.Width > System.Web.UI.WebControls.Unit.Pixel(0)试试
im.Images.Add(Bitmap.FromFile(@"D:\My Documents\我的视频\richie\Angel\1a3fdbfd05a12f1c08244dd2.jpg"));
int width = im.Images[0].Width;
int height = im.Images[0].Height;
MessageBox.Show(width.ToString()+" "+height .ToString ());
重新根据参数到数据库中去读图片,