Archmaga 发表于 2008-6-8 09:40

pictureBox 里的图片怎么用windows的图片查看器打开

pictureBox 里的图片怎么用windows的图片查看器打开 我的pictureBox里面的图片是数据库获取的2进制数

转成image的

Archmaga 发表于 2008-6-8 10:36

貌似没人关心这问题

wang01 发表于 2008-6-8 19:09

void Button1Click(object sender, System.EventArgs e)
                {
            
        OdbcConnection cn;
        OdbcCommand cmd;
        OdbcDataReader rs=null;
        string MyString;
        MyString="Select * from gen_studentinfo";
       cn= new OdbcConnection("DSN=mysql1;");
       cn.Open();
      cmd=new OdbcCommand(MyString,cn);
     try
     {
      rs=cmd.ExecuteReader();
    if(rs.Read())
    {
       byte[]tmp;
       Bitmap   MyImage;
       tmp=(byte[])rs["si_photo"];
    if(File.Exists("tmp.tmp"))  //文件是否存在
    {
       File.Delete("tmp.tmp");      
     }
   FileStream fs = new FileStream("tmp.tmp",FileMode.CreateNew);
   BinaryWriter w = new BinaryWriter(fs);
   w.Write(tmp);
   w.Close();
  pictureBox1.SizeMode   =   PictureBoxSizeMode.StretchImage   ;   
  MyImage   =   new   Bitmap("tmp.tmp");   
  pictureBox1.ClientSize   =   new   Size(pictureBox1.Width,pictureBox1.Height);   
  pictureBox1.Image=(Image)MyImage   ;
     
      System.Windows.Forms.MessageBox.Show(rs["si_name"].ToString());
    }

   }
   catch
   {   }
  finally
  {
     cn.Close();
     cn.Dispose();
   }
System.Windows.Forms.MessageBox.Show("Connected");


}

wang01 发表于 2008-6-8 19:23

this.pictureBox1.Image.Save(@"d:\1.jpg");

Archmaga 发表于 2008-6-9 15:10

谢谢  不过你不是我想要的东西  还是谢谢你们

页: [1]

编程论坛