GTK/GDK Algorithm to take full screenshots of all monitors

ε祈祈猫儿з 提交于 2019-12-23 22:30:15

问题


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:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!