【问题标题】:Screen capture with OpenNetCF - Missing page title/header使用 OpenNetCF 截屏 - 缺少页面标题/页眉
【发布时间】:2014-10-25 20:07:10
【问题描述】:

我正在 Windows Mobile 上测试几种屏幕捕获功能的实现。

使用 SO,我通过 @ctacke 使用 OpenNetCF.Drawing 库 (http://blog.opennetcf.com/2009/03/11/screen-capture-in-the-compact-framework/) 找到了以下方法:

// create a bitmap and graphics objects for the capture
Drawing.Bitmap destinationBmp = new Drawing.Bitmap(Forms.Screen.PrimaryScreen.Bounds.Width, Forms.Screen.PrimaryScreen.Bounds.Height);
Drawing.Graphics g = Drawing.Graphics.FromImage(destinationBmp);
GraphicsEx gx = GraphicsEx.FromGraphics(g);

// capture the current screen
gx.CopyFromScreen(0, 0, 0, 0, Forms.Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);

// save the file
destinationBmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);

// clean house
gx.Dispose();
g.Dispose();
destinationBmp.Dispose();

我尝试在 Windows Mobile 6.5 VGA Emulator 上的一个简单应用程序上测试此方法并获得无人参与的结果:

保存的图像大小正确(480x640),但内容不是我屏幕的完整副本:缺少标题部分,底部是“黑色填充”(缺少的像素线是黑色的)。

在 Windows Mobile 6 模拟器上尝试,遇到了同样的问题。如何获取全屏?

【问题讨论】:

    标签: windows-mobile windows-mobile-6.5 opennetcf


    【解决方案1】:

    我设法通过使用PrimaryScreen.WorkingArea 的属性修改CopyFromScreen 调用中的X 和Y 字段来找到解决方案:

    gx.CopyFromScreen(-Forms.Screen.PrimaryScreen.WorkingArea.X, -Forms.Screen.PrimaryScreen.WorkingArea.Y, 0, 0, Forms.Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
    

    以这种方式编辑这一行,我得到了所有的屏幕。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-06
      • 2021-11-20
      • 1970-01-01
      • 1970-01-01
      • 2013-10-24
      • 1970-01-01
      • 2018-08-25
      • 1970-01-01
      相关资源
      最近更新 更多