从资源文件中加载wxWidgets中的动画GIF

3

我正在尝试将一个动态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文件中,这样它就会被编译到可执行文件中。我该怎么做呢?

2个回答

5

1
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();
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接