tags:

views:

44

answers:

2

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. 
}
A: 

Does type casting works:

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

Priyank Bolia
Even if it would, don't. Please specify what C++ cast you mean. Is this a `static_cast<>` or a `reinterpret_cast<>` ?
MSalters
+1  A: 

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)

Andreas Brinck