是吗?我好象没有碰到过这个问题如果实在不行就把图片放在Panel中或者放在Label上,看看能不能解决

解决方案 »

  1.   

    放在label上的确可以实现,学了一招
      

  2.   

    还是不行啊,我的图片数据是从数据库读出来,然后通过流赋给bitmap对象,再赋给Image对象,然后赋给Label的Image属性的,但是还是不行,显示静态的图片就可以,动态的图片显示清况跟picturebox的一样,出现N个有X的Label。我的代码如下:
    DataRow dataRowProduct = dataSet.Tables["Product"].Rows.Find(currentProductID);
    this.byteProductImage = new byte[((byte[])dataRowProduct["ImageData"]).Length];
    this.byteProductImage = (byte[])dataRowProduct["ImageData"];
    MemoryStream memoryStreamImage = new MemoryStream();
    memoryStreamImage.Write(this.byteProductImage,0,this.byteProductImage.Length);bitmapProduct = new Bitmap(memoryStreamImage);this.imageProduct = this.bitmapProduct;
    this.imageWidth = this.bitmapProduct.Width;
    this.imageHeight = this.bitmapProduct.Height;
    memoryStreamImage.Close();this.labelProductImage.Image = this.imageProduct;
    this.labelProductImage.Width = this.imageWidth;
    this.labelProductImage.Height = this.imageHeight;
    this.labelProductImage.Left = (this.Width/2)-((int)(this.imageWidth/2));
    this.labelProductImage.Top  = (this.Height/2)-((int)(this.imageHeight/2));
    this.labelProductImage.Visible = true;
    不知你们的是怎么实现的呢?
      

  3.   

    你最好用Datareader读blob内容(byte[])假设你读取的数据为byte[] data,显示图片用picturebox,我试过可以的
    byte[]  data;string sqlText = "SELECT img_data, img_contenttype FROM Image WHERE img_pk = " + ImageId; SqlConnection connection = new SqlConnection( connstring );
    SqlCommand command = new SqlCommand( sqlText, connection); //open the database and get a datareader
    connection.Open();
    SqlDataReader dr = command.ExecuteReader();
    if ( dr.Read()) 
    {
    data=(byte[]) dr["img_data"] ;

    }MemoryStream ms = new MemoryStream(data);Image img = new Bitmap(ms);
    this.pictureBox1.Image=img;
      

  4.   

    嗯,如果是我得话,用pictureBox 得话,会从库中读出图片,然后在资源里面建议这个一个文件,把动画图片写好,再装到pictureBox里面。就没事了。你可以试试,pictureBox是可以直接显示GIF动画的。不会有一点异样
      

  5.   

    我的例子是没问题的:
    Image ima=new Bitmap(@"H:\图片\素材库\箭头动画\07arrow15.gif");
    this.pictureBox1.Image=ima;
      

  6.   

    coollzh(良子)的方法和我的似乎没有什么不同,但在我的程序里就是不能显示有动画的GIF图片(普通的GIF可以显示),doinfo(野比效果器)和xj516(流浪汉)的方法其实是同属一种,都是有了一个文件,我也用过的,虽然是可以,不过感觉将数据库的数据读出来还要进行一步在硬盘里保存为一个文件,然后再用bitmap取出来,程序就显得有点罗嗦了,不过没有其它好办法就只好这样做了。另外我觉得像doinfo(野比效果器)那样在资源里创建一个文件的方式不够在硬盘上创建一个文件的方式好,因为资源是保存比较固定的资源文件的,而这里的图片数据会很频繁地更新,保存在资源里的话,可能会导致性能有所下降。
      

  7.   

    我从本地load到内存,然后生成image的,动画可以动呀:)