这
更多信息是当图片对话框不显示文件图像的解决方案,但它是在与GDI +渲染。
public partial class Form1 : Form
{
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
// call render function
RenderGraphics(e.Graphics, pictureBox1.ClientRectangle);
}
private void pictureBox1_Resize(object sender, EventArgs e)
{
// refresh drawing on resize
pictureBox1.Refresh();
}
private void copyToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
{
// create a memory image with the size taken from the picturebox dimensions
RectangleF client=new RectangleF(
0, 0, pictureBox1.Width, pictureBox1.Height);
Image img=new Bitmap((int)client.Width, (int)client.Height);
// create a graphics target from image and draw on the image
Graphics g=Graphics.FromImage(img);
RenderGraphics(g, client);
// copy image to clipboard.
Clipboard.SetImage(img);
}
private void RenderGraphics(Graphics g, RectangleF client)
{
g.SmoothingMode=SmoothingMode.AntiAlias;
// draw code goes here
}
}
你到目前为止试过了什么?添加一些代码,让我们看看你已经做了什么,并帮助你通过其余的 – Mehran 2013-05-14 15:04:26
我使用此代码,但由此用户只能将图像粘贴到单词中。 'var img = Image.FromFile(pnlContent_Picture_PictureBox.ImageLocation); Clipboard.SetImage(img);' – 2013-05-14 15:05:46
图片框是否包含来自文件的图像,内存中的图像还是使用“Paint()”事件渲染? – ja72 2013-05-14 16:01:24