【问题标题】:Loading animated GIFs from resource file in wxWidgets从 wxWidgets 中的资源文件加载动画 GIF
【发布时间】:2011-07-24 02:32:29
【问题描述】:

我正在尝试将动画 GIF 图像嵌入到 wxWidgets C++ 程序中。我可以从文件中加载图像并像这样显示它:

wxAnimationCtrl *an = new wxAnimationCtrl(this, wxID_ANY, wxAnimation(wxT("image.gif"), wxANIMATION_TYPE_ANY), wxPoint(150,0));
an->Play();

但我宁愿将 GIF 图像放在我的 resource.rc 文件中,以便将其编译成可执行文件。我该怎么做?

【问题讨论】:

    标签: image wxwidgets gif


    【解决方案1】:

    您可以尝试使用wxMSWResourceswxLoadUserResource函数,将GIF资源加载到内存,然后获取wxMemoryInputStream,然后使用wxAnimation::Load()并将输入流传递给该函数

    【讨论】:

      【解决方案2】:
      m_ani = new wxAnimationCtrl();
      const void* data = NULL;
      size_t outLen = 0;
      
      // load the icon directory resource
      if ( !wxLoadUserResource(&data, &outLen, "ID_WAIT", RT_RCDATA) )
      {
          wxLogError(_("Failed to load icons from resource"));
      }
      else
      {
          wxMemoryInputStream stream(data, outLen);
          if (m_ani->Load(stream))  m_ani->Play();
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-09
        • 2014-10-14
        • 1970-01-01
        • 1970-01-01
        • 2017-04-10
        相关资源
        最近更新 更多