数据库:SQL Server 2005
语言:C#
数据类型:image
如何获取图片的width & height??

解决方案 »

  1.   

    只要你能把图片数据读出来还原成图片用Image属性就知道Height,Width了
      

  2.   

    1.                 if (Convert.IsDBNull(o))
                        {
                            hasPhoto = false;
                        }
                        else
                        {
                            ks_photo = (byte[])dt.Tables[0].Rows[0]["ks_photo"];
                            if (ks_photo.Length == 0)
                                hasPhoto = false;
                            else
                            hasPhoto = true;
                        }                    
    2.        public static Image Photo
            {
                get
                {
                    if (hasPhoto == false)
                        return null;
                    System.IO.MemoryStream ms = new System.IO.MemoryStream(ks_photo);
                    Image im = Image.FromStream(ms);
                    ms.Close();
                    return im;
                }
            }
    3.Photo.Width,Photo.Height