[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Qt XRenderComposite question
From: Twister Rodriguez <rodriguez.twister () gmail ! com>
Date: 2010-07-21 7:44:32
Message-ID: AANLkTinpzacBALdkeeLJ8FydZ9xJKcsJP0m3xKY5zN0a () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hello,
I hope you could help with some code, which uses XRender XComposite and Qt.
The reason I'm asking, is because, I've seen similar code in the KDE source,
however, I can't make it work. May be you could help.
I'm trying to write a simple program, which redirects all the windows to the
backbuffer( as the composite manager does ), then write them to pixmap and
save to disk. Here is the code :
#include <QApplication>
#include <QDebug>
#include <X11/Xlib.h>
#include <QPaintDevice>
#include <QX11Info>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
#include <X11/extensions/Xdamage.h>
#include <QPixmap>
#include <QWidget>
int main( int argc, char *argv[] )
{
QApplication app( argc, argv );
Picture frontBuffer;
XRenderPictFormat *format;
Window rootWindow;
int depth;
Display *dpy = XOpenDisplay( getenv("DISPLAY") );
rootWindow = XRootWindow( dpy, XDefaultScreen( dpy ) );
depth = DefaultDepth( dpy, DefaultScreen(dpy) );
// Redirect all the windows
XCompositeRedirectSubwindows( dpy, rootWindow, CompositeRedirectManual
);
// Get the format
format = XRenderFindVisualFormat( dpy, DefaultVisual( dpy,
DefaultScreen(dpy) ) );
XRenderPictureAttributes pa;
pa.subwindow_mode = IncludeInferiors;
// Creating front buffer
frontBuffer = XRenderCreatePicture( dpy, rootWindow, format,
CPSubwindowMode, &pa );
uint nwindows;
Window root_return, parent_return, *windows;
XQueryTree( dpy, rootWindow, &root_return,
&parent_return, &windows, &nwindows );
for ( uint i = 0; i < nwindows; i++ ) {
XWindowAttributes attr;
if ( !XGetWindowAttributes( dpy, windows[i], &attr ) )
continue;
Pixmap pix = XCompositeNameWindowPixmap( dpy, windows[i] );
Picture pic = XRenderCreatePicture( dpy, pix, format, 0, 0 );
QPixmap pixmap(540, 900);
XRenderComposite( dpy, PictOpSrc, pic, None,
pixmap.x11PictureHandle(),
0, 0, 0, 0, 0 , 0, 540, 900 );
pixmap.save( QString::number( i )+".png", "PNG" );
}
}
XFree( windows );
return app.exec();
}
The code works fine if I redirect the pic to the frontBuffer, as a result I
see the images of the windows on the screen. However, when I use
pixmap.x11PictureHandle(), I get just black images saved to disk and no
window pictures passed to them, so obviously I'm missing something. The
tutorial I used :
http://ktown.kde.org/~fredrik/composite_howto.html<http://ktown.kde.org/%7Efredrik/composite_howto.html>
.
Of course, I understand that some windows won't be rendered, but I can't get
at least one rendered.
What I'm missing or misunderstanding ?
Thank you in advance.
Regards,
Vladimir.
[Attachment #5 (text/html)]
Hello,<br><br>I hope you could help with some code, which uses XRender XComposite and \
Qt. The reason I'm asking, is because, I've seen similar code in the KDE \
source, however, I can't make it work. May be you could help.<br> <br>I'm \
trying to write a simple program, which redirects all the windows to the backbuffer( \
as the composite manager does ), then write them to pixmap and save to disk. Here is \
the code : <br><br><code>#include <QApplication><br>#include \
<QDebug><br>#include <X11/Xlib.h><br>#include \
<QPaintDevice><br>#include <QX11Info><br>#include <X11/Xlib.h><br> \
#include <X11/Xutil.h><br>#include <X11/Xatom.h><br>#include \
<X11/extensions/Xcomposite.h><br>#include \
<X11/extensions/Xrender.h><br>#include \
<X11/extensions/Xdamage.h><br><br>#include <QPixmap><br> #include \
<QWidget><br><br>int main( int argc, char *argv[] )<br>{<br> QApplication \
app( argc, argv );<br><br> Picture frontBuffer;<br> XRenderPictFormat \
*format;<br> Window rootWindow;<br> int depth;<br> <br> Display *dpy = \
XOpenDisplay( getenv("DISPLAY") );<br> rootWindow = XRootWindow( dpy, \
XDefaultScreen( dpy ) );<br><br> depth = DefaultDepth( dpy, DefaultScreen(dpy) \
);<br><br> // Redirect all the windows<br> XCompositeRedirectSubwindows( dpy, \
rootWindow, CompositeRedirectManual );<br><br> // Get the format<br> format = \
XRenderFindVisualFormat( dpy, DefaultVisual( dpy, DefaultScreen(dpy) ) );<br><br> \
XRenderPictureAttributes pa;<br> pa.subwindow_mode = IncludeInferiors;<br><br> // \
Creating front buffer<br> frontBuffer = XRenderCreatePicture( dpy, rootWindow, \
format, CPSubwindowMode, &pa );<br><br> uint nwindows;<br> Window \
root_return, parent_return, *windows;<br> <br> XQueryTree( dpy, rootWindow, \
&root_return,<br> &parent_return, &windows, \
&nwindows );<br><br> for ( uint i = 0; i < nwindows; i++ ) {<br> \
XWindowAttributes attr;<br> if ( !XGetWindowAttributes( dpy, windows[i], &attr ) \
)<br> continue;<br><br> Pixmap pix = \
XCompositeNameWindowPixmap( dpy, windows[i] );<br><br> Picture pic = \
XRenderCreatePicture( dpy, pix, format, 0, 0 );<br> <br> QPixmap \
pixmap(540, 900);<br> XRenderComposite( dpy, PictOpSrc, pic, None, \
pixmap.x11PictureHandle(),<br> 0, 0, 0, 0, 0 \
, 0, 540, 900 );<br> pixmap.save( QString::number( i )+".png", \
"PNG" );<br> }<br> }<br> XFree( windows );<br> return \
app.exec();<br>}</code><br><br>The code works fine if I redirect the <span \
style="font-style: italic;">pic</span> to the <span style="font-style: \
italic;">frontBuffer</span>, as a result I see the images of the windows on the \
screen. However, when I use <span style="font-style: \
italic;">pixmap.x11PictureHandle()</span>, I get just black images saved to disk and \
no window pictures passed to them, so obviously I'm missing something. The \
tutorial I used : <a class="postlink" \
href="http://ktown.kde.org/%7Efredrik/composite_howto.html">http://ktown.kde.org/~fredrik/composite_howto.html</a>.<br>Of \
course, I understand that some windows won't be rendered, but I can't get at \
least one rendered.<br> <br>What I'm missing or misunderstanding ?<br><br>Thank \
you in advance.<br><br>Regards,<br>Vladimir.<br>
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic