Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#代码文件的屏幕截图_C#_Vb.net_Visual Studio_Visual Studio 2010_Visual Studio 2008 - Fatal编程技术网

C#代码文件的屏幕截图

C#代码文件的屏幕截图,c#,vb.net,visual-studio,visual-studio-2010,visual-studio-2008,C#,Vb.net,Visual Studio,Visual Studio 2010,Visual Studio 2008,我想从VisualStudio单个文件中截取完整代码的屏幕截图。 可能吗 如果是,如何打印?打印到类似PDF编写器的格式?或“Microsoft Office文档图像编写器” 我想这是一个不错的选择。打印到类似PDF编写器的东西上?或“Microsoft Office文档图像编写器” 我想这是最好的办法。你可以试试这个 文件 印刷品 选择打印机名称作为Microsoft XPS文档编写器 按OK 你可以试试这个 文件 印刷品 选择打印机名称作为Microsoft XPS文档编写器 按OK 要支持

我想从VisualStudio单个文件中截取完整代码的屏幕截图。 可能吗


如果是,如何打印?

打印到类似PDF编写器的格式?或“Microsoft Office文档图像编写器”


我想这是一个不错的选择。

打印到类似PDF编写器的东西上?或“Microsoft Office文档图像编写器”

我想这是最好的办法。

你可以试试这个

  • 文件
  • 印刷品
  • 选择打印机名称作为Microsoft XPS文档编写器
  • 按OK
  • 你可以试试这个

  • 文件
  • 印刷品
  • 选择打印机名称作为Microsoft XPS文档编写器
  • 按OK

  • 要支持颜色,您可以将代码粘贴到一个巨大的RichTextBox(或使用NumericUpdown控制宽度和高度的常规大小)中,并使用一个按钮来执行以下操作:

    var bitmap = new Bitmap(this.richTextBox1.Width, this.richTextBox1.Height);
    this.richTextBox1.DrawToBitmap(bitmap, new Rectangle(Point.Empty, bitmap.Size));
    bitmap.Save("code.bmp");
    
    旧版(不支持颜色):


    要支持颜色,您可以将代码粘贴到一个巨大的RichTextBox(或使用NumericUpdown控制宽度和高度的常规大小)中,并使用一个按钮来执行以下操作:

    var bitmap = new Bitmap(this.richTextBox1.Width, this.richTextBox1.Height);
    this.richTextBox1.DrawToBitmap(bitmap, new Rectangle(Point.Empty, bitmap.Size));
    bitmap.Save("code.bmp");
    
    旧版(不支持颜色):

    您可以使用以下选项:

    Bitmap BmpScreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
    Graphics ScreenShot = Graphics.FromImage(BmpScreen);
    ScreenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
    string file = "C:\\test.jpg";
    BmpScreen.Save(file, System.Drawing.Imaging.ImageFormat.Png);
    
    必要时:
    使用系统图纸

    您可以使用:

    Bitmap BmpScreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
    Graphics ScreenShot = Graphics.FromImage(BmpScreen);
    ScreenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
    string file = "C:\\test.jpg";
    BmpScreen.Save(file, System.Drawing.Imaging.ImageFormat.Png);
    

    必要时:
    使用系统图纸

    为什么需要代码的屏幕截图?您的意思是希望在屏幕客户端下的滚动条下隐藏代码?为什么需要代码的屏幕截图?您的意思是希望在屏幕客户端下的滚动条下隐藏代码?当然,第一行是获取位图对象中的屏幕宽度和高度。之后,定义图像的方向。当然,第一行是获取位图对象中的屏幕宽度和高度。之后,为图像定义dir。