如何将图片转换为RTF编码格式?

解决方案 »

  1.   

    楼主你可以参考下面的代码:public void InsertImage()
            {
                OpenFileDialog fileDialog = new OpenFileDialog();
                fileDialog.ShowDialog();
                string lstrFile = fileDialog.FileName;
                Bitmap myBitmap = new Bitmap(lstrFile);
                // 拷贝位图到剪贴板  
                Clipboard.SetDataObject(myBitmap);
                // 获取对象格式  
                DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);
                // 验证并粘贴位图  
                if (this.richTextBox1.CanPaste(myFormat)) { this.richTextBox1.Paste(myFormat);}
                else
                {
                    MessageBox.Show("The data format that you attempted site" +" is not supportedby this control.");            }
            }
      

  2.   

    BASE64格式
    System.IO.MemoryStream m = new System.IO.MemoryStream();
    System.Drawing.Bitmap bp = new System.Drawing.Bitmap(@“c:\a.GIF”);
    bp.Save(m, System.Drawing.Imaging.ImageFormat.Gif);
    byte[]b= m.GetBuffer();
    string base64string=Convert.ToBase64String(b);MemoryStream ms = new MemoryStream();
    pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] buffer = new byte[ms.Length];
    ms.Position = 0;
    ms.Read(buffer, 0, buffer.Length); 
    ms.Close(); 
    File.WriteAllBytes("", buffer);
    File.WriteAllText("a.txt", Convert.ToBase64String(buffer));