如何解决在哪里可以找到 /usr/include/X11/extensions/Xcomposite.h
我需要将我的应用程序放在全屏视频上并捕获它以放入我的 python tkinter 应用程序中的“画中画”框架中。我已经查看了常见的可疑对象(ImageGrab、mss 等),但它们似乎都只是抓取了监视器上可见的内容。似乎没有人能够抓住一个不可见的窗口。
我在 Stack Overflow 上发现了这个看起来很有前途的 C 程序:
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
int
main ()
{
display *display = XOpendisplay (NULL);
XID xid = 90177543; // xdotool search --name "World of Warcraft" | head -1
// Check if Composite extension is enabled
int event_base_return;
int error_base_return;
if (XCompositeQueryExtension (display,&event_base_return,&error_base_return))
printf ("COMPOSITE IS ENABLED!\n");
// Requests the X server to direct the hierarchy starting at window to off-screen storage
XCompositeRedirectwindow (display,xid,CompositeRedirectAutomatic);
// Preventing the backing pixmap from being freed when the window is hidden/destroyed
// If you want the window contents to still be available after the window has been destroyed,// or after the window has been resized (but not yet redrawn),you can increment the backing
// pixmaps ref count to prevent it from being deallocated.
pixmap pixmap = XCompositeNameWindowpixmap (display,xid);
// Get window attributes
XWindowAttributes attr;
Status s = XGetwindowAttributes (display,&attr);
if (s == 0)
printf ("Fail to get window attributes!\n");
// Extract the data
XRenderPictFormat *format = XRenderFindVisualFormat (display,attr.visual);
int width = attr.width;
int height = attr.height;
int depth = attr.depth;
// What we need to do Now is to create an XRender Picture for the window,// which we'll need to draw it with the Render extension.
// A picture is a basically a handle to a server side struct with some
// additional information about a drawable (in this case a window),// such as its format,which clipping region should be used when
// drawing it (if any),whether it should be tiled etc.
XRenderPictureAttributes pa;
pa.subwindow_mode = IncludeInferiors;
Picture picture = XRenderCreatePicture (display,format,cpsubwindowMode,&pa);
// We Now have all the information we need in order to be able to draw the window
// using the Xrender extension,and we've created and prepared a source picture
// for the window for this purpose.
// The Xrender function we'll use to draw the window is XRenderComposite().
//XRenderComposite (display,PictOpSrc,picture,None,???destination???,width,height);
XFreepixmap (display,pixmap);
XCompositeUnredirectwindow (display,CompositeRedirectAutomatic);
return 0;
}
现在真正的问题...
我的问题是这个部分:
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
所有这些文件都存在于 /usr/include/X11
下,<X11/extensions/Xcomposite.h>
除外。我在哪里可以找到它?
Ubuntu 16.04 LTS (ESM),内核 4.14.216-0414216-generic。太忙于学习新事物,无法破解,嗯,错误,升级到新版本。
FWIW 这是一个音乐播放器应用程序,它已经在运行,点击按钮可以调低电视音量,音乐会继续播放。我只是增强它以移动到电视,拍摄全屏视频并将其放入专辑插图通常旋转的 tkinter 框架中。计时器完成后,电视恢复,音乐播放器移回它来自的其他显示器。因此,我认为我找到的这个 C 程序是唯一的解决方案,但我欢迎罐头解决方案。
解决方法
如果您 search packages.ubuntu.com,您会发现它位于 libxcomposite-dev
软件包中,因此您需要安装它。
为了找到这个,我去了packages.ubuntu.com,然后在“搜索包的内容”下输入“Xcomposite.h”,为“分发”选择“xenial”,以及“包含名称结尾的文件的包”与关键字"像这样:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。