日期:2014-05-18 浏览次数:21651 次
private void button2_Click(object sender, EventArgs e)
        {
            richTextBox1.SelectAll();
            richTextBox1.Copy(); 
            string str = richTextBox1.Text;//获取文本部分
            Image img1 = (Image)Clipboard.GetData(System.Windows.Forms.DataFormats.Bitmap);//获取图片部分
            if (img1 != null)
            {
                img1.Save(Application.ExecutablePath + "a.bmp");
            }
        }
     string _RtfText=richTextBox1.SelectedRtf;
            IList<string> _ImageList =new List<string>();
            while(true)
            {
                int _Index = _RtfText.IndexOf("pichgoal");
                if(_Index==-1)break;
                _RtfText=_RtfText.Remove(0,_Index+8);
                _Index = _RtfText.IndexOf("\r\n");
                
                int _Temp = Convert.ToInt32(_RtfText.Substring(0, _Index));
                _RtfText = _RtfText.Remove(0, _Index);
                _RtfText = _RtfText.Replace("\r\n", "");
                _Index = _RtfText.IndexOf("}");
                _ImageList.Add(_RtfText.Substring(0, _Index));
                _RtfText = _RtfText.Remove(0, _Index);                
                
            }
            for (int i = 0; i != _ImageList.Count; i++)
            {
                System.IO.FileStream _File = new FileStream(Application.StartupPath + "\\" + i.ToString() + ".dat", System.IO.FileMode.Create);
                int _Count=_ImageList[i].Length/2;
                for (int z = 0; z != _Count; z++)
                {
                    string _TempText=_ImageList[i][z*2].ToString()+_ImageList[i][(z*2)+1].ToString();
                    _File.WriteByte(Convert.ToByte(_TempText, 16));
                }
                _File.Close();
            }           
            MessageBox.Show(_ImageList.Count.ToString());