wxWidgets 3.1.3
MSVC 16.2.5 (Visual C++ 2019)
Preprocessor Definitions: WIN32;_WINDOWS;UNICODE;_UNICODE;_DEBUG;__WXDEBUG__;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)
I have a wxImage object generated from a bitmap.
When I save it to a file stream, everything works find. The file is created as a valid PNG, which I can view in an external application.
However, when I try to save it to a wxStringOutputStream, the stream is empty.
Here is the relevant code:
Code: Select all
//Save to file - works!
wxImage myImage1 = myBitmap.ConvertToImage();
myImage1.SaveFile(imgPath, wxBITMAP_TYPE_PNG);
//Save to stream - results in an empty stream and string
wxImage myImage2 = myBitmap.ConvertToImage();
wxStringOutputStream ssImg;
bool imgSaveResult = myImage2.SaveFile(ssImg, wxBITMAP_TYPE_PNG);
std::string imgString = ssImg.GetString();
I have tried initializing the wxStringOutputStream with a wxString and also with various wxMBConv objects.
It would seem that the default MCConv is appropriate.
I also traced this into the wxImage file with the debugger. Both calls to SaveFile end up in the same function, leading me to believe that there is something amiss with my use of wxStringOutputStream.
Can anyone shed some light?
Thanks,
Matt.