private void pictureBox1_Click(object sender, EventArgs e)
        {
            SqlCommand cmd2 = new SqlCommand();
            OpenFileDialog op1 = new OpenFileDialog();
            op1.Filter = "jpeg|*.jpeg";
            if (op1.ShowDialog(this) == DialogResult.OK)
            {
                Myimage.Image = System.Drawing.Image.FromFile(op1.FileName); //将图片文件存入到PictureBox控件中
                string strimg = op1.FileName.ToString(); //记录图片的所在路径
                FileStream fs = new FileStream(strimg, FileMode.Open, FileAccess.Read); //将图片以文件流的形式进行保存
                bydata = new byte[fs.Length];//将流读入到字节数组中
            }
        }
如何将这个2进制数组在richtextbox中显示成图片?

解决方案 »

  1.   

    private void inspic_Click(object sender, EventArgs e)
            {
                OpenFileDialog mydlgview = new OpenFileDialog();
                mydlgview.Title = "选择图片";
                mydlgview.Filter = "jpeg图像文件(*.jpg)|*.jpg|所有图像文件(jpeg,gif,bmp,etc)|*.jpg;*.jpeg;*.gif;*.bmp|所有文件(*.*)|*.*";            if (mydlgview.ShowDialog() == DialogResult.OK)
                {
                    srcpath = mydlgview.FileName;
                    //string myguid = System.Guid.NewGuid().ToString().ToUpper();//这句是否可以不要;
                    //string myextname = System.IO.Path.GetExtension(mydlgview.FileName);
                    //string myphotofile = myguid + myextname;
                    //mydestpath = Application.StartupPath + myphotofile;
                    //System.IO.File.Copy(srcpath, mydestpath);
                    //pictureBox1.Image = new Bitmap(mydestpath);
                    pictureBox1.Image = new Bitmap(srcpath);
                    if (pictureBox1.Image != null)
                    {
                        AddPic.Enabled = true;
                    }
                }
            }以前我自己做的 你好好参考揣摩一下就OK了