【问题标题】:Cairo to Cairo-xlib: cairo_xlib_surface_create problems (C)Cairo 到 Cairo-xlib:cairo_xlib_surface_create 问题 (C)
【发布时间】:2013-12-24 15:57:07
【问题描述】:

我正在尝试从 Cairo 图像表面切换到 xlib 表面。我的代码在图像表面上运行良好,但我认为我没有正确初始化 xlib 表面。它可以编译,但会引发警告,并且不再显示任何内容。

这是我当前初始化表面的代码:

    int width, height;
    gdk_threads_enter();
    gdk_drawable_get_size(pixmap, &width, &height);
    gdk_threads_leave();

    /*** Create surface to draw on ***/
    cairo_surface_t *cst = cairo_xlib_surface_create(gdk_x11_drawable_get_xdisplay(pixmap),
                                        gdk_x11_drawable_get_xid(pixmap),
                                        gdk_x11_visual_get_xvisual(gvis), 
                                        width, height);

编译时收到以下警告:

In function 'do_draw':
evis.c:112:11: warning: passing argument 1 of 'cairo_xlib_surface_create' makes pointer from integer without a cast [enabled by default]
           width, height);
           ^
In file included from evis.c:6:0:
/usr/include/cairo/cairo-xlib.h:49:1: note: expected 'struct Display *' but argument is of type 'int'
 cairo_xlib_surface_create (Display     *dpy,
 ^
evis.c:112:11: warning: passing argument 3 of 'cairo_xlib_surface_create' makes pointer from integer without a cast [enabled by default]
           width, height);
           ^
In file included from evis.c:6:0:
/usr/include/cairo/cairo-xlib.h:49:1: note: expected 'struct Visual *' but argument is of type 'int'
 cairo_xlib_surface_create (Display     *dpy,
 ^

我很确定这些警告会破坏代码,但我不确定如何修复它们。我尝试将第一个参数和第三个参数分别转换为(Display *)(Visual *),但这也不起作用。开始抛出其他警告。

*编辑 1 * 试图理解这一点,但我对指针的理解仅限于到目前为止不存在。 gdk_drawable_get_xdisplay() 返回 Display*,但我的函数正在寻找指向 struct Display * 的指针。 2 和我如何从Display*Display * 有什么区别。

【问题讨论】:

    标签: c linux cairo xlib


    【解决方案1】:

    编译器认为函数返回 int 的“通常”原因是它找不到函数的原型,这意味着您缺少#include。 (虽然我希望在这种情况下找到其他警告?)

    【讨论】:

      猜你喜欢
      • 2019-05-12
      • 1970-01-01
      • 1970-01-01
      • 2022-11-20
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 2018-09-20
      • 1970-01-01
      相关资源
      最近更新 更多