[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-xorg
Subject: Screen capture troubles
From: Bram Biesbrouck <b () beligum ! org>
Date: 2005-09-28 23:17:38
Message-ID: 200509290117.39038.b () beligum ! org
[Download RAW message or body]
Hi,
First of all, I would like to introduce myself to this list. My name is Bram
from Belgium and I'm in the middle of developing a(nother) screen capturing
program for GNU/Linux.
I'm quite new to using Xlib and therefore, I'm having some beginner problems
and I hope someone here could help me out with one of them. Maybe this isn't
the right list for that kind of questions, but I couldn't find an
alternative, so please accept my apologies if so.
On the bottom is the code for a routine that should select a window on the
screen, make a pixmap of it and write that pixmap toa XPM file.
When I try to run this code, sometimes I get a correct dump of the window and
at other times, the colors are a mess. I think it has something to do with
colormaps (I have read the tutorials and docs, but I couldn't figure out all
of it), but I'm stuck.
Please help me out.
Bram
-------START CODE----------
display = XOpenDisplay(DEFAULT_DISPLAY);
if (display==NULL)
fatalError("Error while fetching display.");
screen = DefaultScreen(display);
rootWin = XRootWindow(display, screen);
if (!XGetWindowAttributes(display, rootWin, &rootAttr))
fatalError("Couldn't retrieve rootwindow information.");
targetWindow = SelectWindow(display);
if (!XGetWindowAttributes(display, targetWindow, &targetAttr))
fatalError("Couldn't retrieve window information.");
targetWindow = rootWin;
gcValuemask = GCFunction | GCSubwindowMode;
gcValues.function = GXcopy;
gcValues.subwindow_mode = IncludeInferiors;
winGc = XCreateGC(display, targetWindow, gcValuemask, &gcValues);
dumpPixmap = XCreatePixmap(display, targetWindow, targetAttr.width,
targetAttr.height, targetAttr.depth);
XCopyArea(display, targetWindow, dumpPixmap, winGc, targetAttr.x,
targetAttr.y, targetAttr.width, targetAttr.height, 0, 0);
XpmWriteFileFromPixmap(display, DUMP_FILENAME, dumpPixmap, (Pixmap)0, NULL);
XCloseDisplay(display);
-------END CODE---------
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic