[英]Screen capture program on Mac OS X Lion, preferable portable on other OS
I need to develop a screen capture program that runs on Mac OS X Lion. 我需要开发一个在Mac OS X Lion上运行的屏幕捕获程序。 I tried to make a screenshot using mono
and GTK#
, but the screenshot is black 我尝试使用mono
和GTK#
制作截图,但屏幕截图是黑色的
Gdk.Window window = Gdk.Global.DefaultRootWindow;
if (window!=null)
{
Gdk.Pixbuf pixBuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8,
window.Screen.Width, window.Screen.Height);
pixBuf.GetFromDrawable(window, Gdk.Colormap.System, 0, 0, 0, 0,
window.Screen.Width, window.Screen.Height);
pixBuf.ScaleSimple(400, 300, Gdk.InterpType.Bilinear);
pixBuf.Save("screenshot0.jpeg", "jpeg");
}
Can you point me in right direction. 你能指出我正确的方向吗? Preferably using mono
, but if will be java
, c++
or objective c
is also good. 最好使用mono
,但如果是java
, c++
或objective c
也是好的。
Thank in advance. 预先感谢。
For Java, see Robot.createScreenCapture(Rectangle) . 对于Java,请参阅Robot.createScreenCapture(Rectangle) 。 Note though, that Robot
commonly also produces a black screen image for apps. 但请注意, Robot
通常也会为应用程序生成黑屏图像。 that take direct control of the screen area (eg many games). 直接控制屏幕区域(例如许多游戏)。
Your best bet would probably be using a platform-specific API to do the actual image capture, while the rest of your app remains portable. 您最好的选择可能是使用特定于平台的API来进行实际的图像捕获,而您的应用程序的其余部分仍然是可移植的。 For OS X, Apple actually provides sample code on how to do this, and your code will probably work under X11. 对于OS X,Apple实际上提供了有关如何执行此操作的示例代码 ,并且您的代码可能在X11下运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.