保存实时图表图像
Save Live Charts image
我需要保存并打印来自 cartesian live chart, I've searched in docs and tutorials 的图像,但我找不到任何东西。我怎样才能做到这一点?我在 Visual Studio 2012 Express 中使用 WinForms 和 C#。
由于图形本身似乎不支持打印/拍摄屏幕图像,我建议您自己创建此功能。
您需要什么?
- 截图 - Capture screenshot of active window?
-
ScreenCapture sc = new ScreenCapture();
// capture entire screen, and save it to a file
Image img = sc.CaptureScreen();
// display image in a Picture control named imageDisplay
this.imageDisplay.Image = img;
// capture this window, and save it
sc.CaptureWindowToFile(this.Handle,"C:\temp2.gif",ImageFormat.Gif);
如果您只需要控制的打印屏幕: C# Take ScreenShot of .net control within application and attach to Outlook Email
-
public static void TakeCroppedScreenShot( string fileName, int x, int y, int width, int height, ImageFormat format)
{
Rectangle r = new Rectangle(x, y, width, height);
Bitmap bmp = new Bitmap(r.Width, r.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(r.Left, r.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
bmp.Save(fileName, format);
}
- 打印屏幕截图 - Print images c#.net
-
using System.Drawing.Printing;
...
protected void btnPrint_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += PrintPage;
pd.Print();
}
private void PrintPage(object o, PrintPageEventArgs e)
{
System.Drawing.Image img = System.Drawing.Image.FromFile("D:\Foto.jpg");
Point loc = new Point(100, 100);
e.Graphics.DrawImage(img, loc);
}
您可以简单地将图形控件转换为位图,如this answer and then save it to a file. Using the graph control (cartesianChart1
) from the LiveCharts example所示:
Bitmap bmp = new Bitmap(cartesianChart1.Width, cartesianChart1.Height);
cartesianChart1.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save("C:\graph.png", ImageFormat.Png);
即使您的图表位于另一个图表后面,此方法仍然有效 window。
使用打印图像。
我需要保存并打印来自 cartesian live chart, I've searched in docs and tutorials 的图像,但我找不到任何东西。我怎样才能做到这一点?我在 Visual Studio 2012 Express 中使用 WinForms 和 C#。
由于图形本身似乎不支持打印/拍摄屏幕图像,我建议您自己创建此功能。
您需要什么?
- 截图 - Capture screenshot of active window?
-
ScreenCapture sc = new ScreenCapture();
// capture entire screen, and save it to a file
Image img = sc.CaptureScreen();
// display image in a Picture control named imageDisplay
this.imageDisplay.Image = img;
// capture this window, and save it
sc.CaptureWindowToFile(this.Handle,"C:\temp2.gif",ImageFormat.Gif);
如果您只需要控制的打印屏幕: C# Take ScreenShot of .net control within application and attach to Outlook Email
-
public static void TakeCroppedScreenShot( string fileName, int x, int y, int width, int height, ImageFormat format)
{
Rectangle r = new Rectangle(x, y, width, height);
Bitmap bmp = new Bitmap(r.Width, r.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(r.Left, r.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
bmp.Save(fileName, format);
}
- 打印屏幕截图 - Print images c#.net
-
using System.Drawing.Printing;
...
protected void btnPrint_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += PrintPage;
pd.Print();
}
private void PrintPage(object o, PrintPageEventArgs e)
{
System.Drawing.Image img = System.Drawing.Image.FromFile("D:\Foto.jpg");
Point loc = new Point(100, 100);
e.Graphics.DrawImage(img, loc);
}
您可以简单地将图形控件转换为位图,如this answer and then save it to a file. Using the graph control (cartesianChart1
) from the LiveCharts example所示:
Bitmap bmp = new Bitmap(cartesianChart1.Width, cartesianChart1.Height);
cartesianChart1.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save("C:\graph.png", ImageFormat.Png);
即使您的图表位于另一个图表后面,此方法仍然有效 window。
使用