通过流将 wxImage 转换为 Zip 文件。可能的?
我正在尝试使用 wxZipOutputStream 写出一个 zip 文件。该代码来自此论坛,适用于 xml 文件(当我使用 wxTextOutputStream 时)。现在,我试图包含一个图像文件,但 wxImage 类中的 SaveFile 函数需要一个类 wxOutputStream 但 wxTextOutputStream/wxDataOutputStream 没有基类,所以我无法编译它。我只想将 wxImage 和 xml 文件写入 zip 中。我该怎么办?
//convert stream to zip file.
wxFFileOutputStream out(m_loaded_filename.GetFullPath());
wxZipOutputStream zip(out);
// wxTextOutputStream txt(zip);
wxDataOutputStream txt(zip);
zip.PutNextEntry("my.xml");
txt << xmltext;
...
...
...
//value is wxImage*
//key is wxString
zip.PutNextEntry(key); //filename
if(value->IsOk())
{
value->SaveFile(zip); //compiler throws error.
}
I'm trying to write out a zip file using the wxZipOutputStream. The code is from this forum and works with the xml file (when I used wxTextOutputStream). Now, I'm trying to include an image file but the SaveFile function in the wxImage class expects a class wxOutputStream but wxTextOutputStream/wxDataOutputStream have no base class so I can't compile it. I just want to write out a wxImage and an xml file to a zip. how do I go about it?
//convert stream to zip file.
wxFFileOutputStream out(m_loaded_filename.GetFullPath());
wxZipOutputStream zip(out);
// wxTextOutputStream txt(zip);
wxDataOutputStream txt(zip);
zip.PutNextEntry("my.xml");
txt << xmltext;
...
...
...
//value is wxImage*
//key is wxString
zip.PutNextEntry(key); //filename
if(value->IsOk())
{
value->SaveFile(zip); //compiler throws error.
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您必须指定存档中的图像类型,请尝试:
(
key
中的文件扩展名当然应该是.png)It looks like you have to specify the type of image in the archive, try:
(The file extension in
key
should of course be .png)类型转换是否有效:
value->SaveFile((wxOutputStream&)zip);
Does type casting works:
value->SaveFile((wxOutputStream&)zip);