图片 RTF格式 如何将图片转换为RTF编码格式? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主你可以参考下面的代码: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."); } } 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)); 问个XML的问题 C#程序打包问题 C#调用bat文件的问题 一个按钮问题 mdi中子窗体的大小调整问题 中手请进! 请教大家一个关于多个DataTable相互连接的问题 C#WINFORM考试系统问题 new N个线程问题 Session用法 datagridview选中行copy某cell的问题 外部程序高用旺旺登陆时怎么向密码框注入字符?
{
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."); }
}
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));