我正在尝试按OnPrintPage
事件打印图像,如下所示。
protected virtual void OnPrintPage(object sender, PrintPageEventArgs e)
{
Image img = ExportAsMetafile(0);
CultureInfo current = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
e.Graphics.DrawImage(img, new Rectangle(0, 0, (int)e.Graphics.VisibleClipBounds.Width, (int)e.Graphics.VisibleClipBounds.Height));
Thread.CurrentThread.CurrentCulture = current;
}
当我尝试保存 img 时img.Save("img.png");
,我得到了我需要的图像
但是,当我尝试在其中绘制此图像时e.Graphics.DrawImage
,它显示异常如下
谁能帮我解决这个问题。?