问题
I'm fairly new to the whole GTK game and want to create an algorithm to take screen shot of all monitors.
I was thinking something along these lines:
gdk_display_manager_list_displays
- each display can have multiple screens (screens means monitors?) so use
gdk_display_get_n_screens
to get monitors per display from1
- get root gtk window of all screens from
2
- create new Pixbuf for each root gtk window for each screen from
3
withgdk_pixbuf_new
- fill each pixbuf from
4
withgdk_pixbuf_get_from_drawable
for each respective root window from3
for each respective screen from2
for each respective display from1
(may need togdk_drawable_get_size
andgdk_window_get_origin
for each for args to pixbuf) gdk_pixbuf_get_pixels
for each pixbuf
Is this a workable solution?
回答1:
If you are sure cRootWin
is not NULL and cWidth
and cHeight
are greater than 0 then you should check for some additional problem mentioned by the doc.
A wild guess is your program does not have enough memory to store the pixmap (typically 6 Mb). I would try to allocate the 12 Mb just to see if this is the case.
来源:https://stackoverflow.com/questions/30145532/gtk-gdk-algorithm-to-take-full-screenshots-of-all-monitors