GdkPixbuf 集合

发布于 2024-09-08 14:19:53 字数 657 浏览 0 评论 0原文

我需要创建 GdkPixBuf 集合。我尝试将 pixbufs 保存在 GList - mw->disp_list:

GtkTreeIter iter;
int i = 0;

for (i; i < g_list_length(list) - 1; ++i)
{                       
  char* file = image_list_get_current_file_path( list );

  mw->p1 = gdk_pixbuf_new_from_file(file,NULL);
  mw->p1 = scale_pix(mw->p1,128);

  mw->disp_list = g_list_append (mw->disp_list, mw->p1);

  if (!mw->img_list->current->next )
      image_list_get_first(mw->img_list);
  else
      image_list_get_next(mw->img_list);
}

其中 p1 - 它是 GtkPixBuf*。

但是当我尝试在另一个函数中使用 mw->disp_list 时,我发现它是 NULL。怎么了?

谢谢。

I need to create GdkPixBuf collection. I try to save pixbufs in GList - mw->disp_list:

GtkTreeIter iter;
int i = 0;

for (i; i < g_list_length(list) - 1; ++i)
{                       
  char* file = image_list_get_current_file_path( list );

  mw->p1 = gdk_pixbuf_new_from_file(file,NULL);
  mw->p1 = scale_pix(mw->p1,128);

  mw->disp_list = g_list_append (mw->disp_list, mw->p1);

  if (!mw->img_list->current->next )
      image_list_get_first(mw->img_list);
  else
      image_list_get_next(mw->img_list);
}

Where p1 - it's GtkPixBuf*.

But when i try to use mw->disp_list in another function i see that it is NULL. What's wrong?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感受沵的脚步 2024-09-15 14:19:53

目前我只看到一个问题,它与循环有关:

for (i = 0; i < g_list_length(list); ++i)

问题可能是 -1:如果列表包含 1 个元素,则根本不循环,因为 1-1 = 0 和 0< 0 为假。

At the moment I see just one problem, and it is about the loop that should be:

for (i = 0; i < g_list_length(list); ++i)

The problem could be the -1: if list contains 1 element, you do not loop at all, since 1-1 = 0 and 0 < 0 is false.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文