C# richtextbox添加gif图片
1个回答
展开全部
public void ImageOpen(OpenFileDialog openImageDlg)
{
Bitmap bmp;
string fileName = openImageDlg.FileName;
if (null == fileName || fileName.Trim().Length == 0)
return;
try
{
bmp = new Bitmap(fileName);
Clipboard.SetDataObject(bmp);
DataFormats.Format dataFormat =
DataFormats.GetFormat(DataFormats.Bitmap);
if (this.CanPaste(dataFormat))
this.Paste(dataFormat);
}
catch (Exception exc)
{
MessageBox.Show("图片插入失败。" + exc.Message, "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
具体是现将图片加载到剪切板 然后再粘贴到控件中 jpg,bmp都可以这么加载
{
Bitmap bmp;
string fileName = openImageDlg.FileName;
if (null == fileName || fileName.Trim().Length == 0)
return;
try
{
bmp = new Bitmap(fileName);
Clipboard.SetDataObject(bmp);
DataFormats.Format dataFormat =
DataFormats.GetFormat(DataFormats.Bitmap);
if (this.CanPaste(dataFormat))
this.Paste(dataFormat);
}
catch (Exception exc)
{
MessageBox.Show("图片插入失败。" + exc.Message, "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
具体是现将图片加载到剪切板 然后再粘贴到控件中 jpg,bmp都可以这么加载
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询