Question

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. 
} 
Was it helpful?

Solution

It looks like you have to specify the type of image in the archive, try:

value->SaveFile(zip, wxBITMAP_TYPE_PNG)

(The file extension in key should of course be .png)

OTHER TIPS

Does type casting works:

value->SaveFile((wxOutputStream&)zip);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top