嗨我想让我的画框成为一个圆形 然后打印出来。画在画框上并打印出来
问题是我可以在窗体中看到图片框是圆形的,但当我预览它来打印它不是圆形。
这里是我的代码
public Form1()
{
InitializeComponent();
//This makes picturebox1 circle
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddEllipse(0, 0, pictureBox1.Width - 4, pictureBox1.Height - 4);
Region rg = new Region(gp);
pictureBox1.Region = rg;
}
//Preview the print
private void button1_Click(object sender, EventArgs e)
{
printPrev.Document = printDoc;
printPrev.ShowDialog();
}
private void printDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//Draw the picturebox on PDF
e.Graphics.DrawImage(pictureBox1.Image, 230, 230);
}
感谢
您的图片框圈,因为你告诉它是。但是当您打印时,您将打印图像,而不是图片框。你也必须为此设置一个剪辑区域。 –
绘制一个picturebox到纸是非常不明智的,你会发现显示器和打印机分辨率之间的巨大差异的影响。屏幕上的每个像素都会变成6x6的墨水块,使其看起来非常有颗粒感,并且只有在拥有长臂时才会看起来不错。但是,如果你想这样做,那么你必须使用它的DrawToBitmap()方法。 Graphics.Clip属性也接受一个Region。 –
@SamiKuhmonen如何设置剪辑区域?你能给我一些线索吗? –