GTK / GDK算法对所有显示器进行完整截图 [英] GTK/GDK Algorithm to take full screenshots of all monitors

查看:544
本文介绍了GTK / GDK算法对所有显示器进行完整截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对整个GTK游戏相当陌生,并且想创建一个算法来截取所有显示器的屏幕截图。

我正在考虑以下几点:




  1. gdk_display_manager_list_displays

  2. 每个显示可以有多个屏幕(屏幕意味着监视器?),所以使用 gdk_display_get_n_screens 来从 1

  3. 2
  4. 获取所有屏幕的root gtk窗口
  5. 为每个屏幕的每个根gtk窗口创建新的Pixbuf从 3 gdk_pixbuf_new

  6. 填充每个pixbuf 4 gdk_pixbuf_get_from_drawable 用于从 3 每个相应的根窗口用于从每个相应的屏 1 (可能需要 gdk_drawable_get_size code> 2 和 gdk_window_get_origin ,其中每个参数都指向pixbuf)

  7. gd k_pixbuf_get_pixels 对于每个PIXBUF



  8. 这是一个可行的解决方案?


    解决方案

    如果您确信 cRootWin 不是NULL和 cWidth cHeight 大于0,那么你应该检查一下 by the doc

    疯狂的猜测是你的程序确实没有足够的内存来存储像素图(通常为6 Mb)。我会尝试分配12 Mb来查看是否属于这种情况。


    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?

    解决方案

    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.

    这篇关于GTK / GDK算法对所有显示器进行完整截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆