2017-02-08 21 views

回答

1

由于图形本身似乎不支持打印/拍摄屏幕图像,因此我建议您自己创建此功能。

你需要什么?

  1. 采取截屏 - 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); 

如果你只需要PRINTSCREEN控制: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);  
    }