GTK/GDK Algorithm to take full screenshots of all

2019-07-24 05:52发布

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:

  1. gdk_display_manager_list_displays
  2. each display can have multiple screens (screens means monitors?) so use gdk_display_get_n_screens to get monitors per display from 1
  3. get root gtk window of all screens from 2
  4. create new Pixbuf for each root gtk window for each screen from 3 with gdk_pixbuf_new
  5. fill each pixbuf from 4 with gdk_pixbuf_get_from_drawable for each respective root window from 3 for each respective screen from 2 for each respective display from 1 (may need to gdk_drawable_get_size and gdk_window_get_origin for each for args to pixbuf)
  6. gdk_pixbuf_get_pixels for each pixbuf

Is this a workable solution?

1条回答
2楼-- · 2019-07-24 06:34

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.

查看更多
登录 后发表回答