- added wxGetFontFromUser() convenience function
- added EVT_MENU_OPEN and EVT_MENU_CLOSE events
- added Hungarian translations (Janos Vegh)
+- added wxImage::SaveFile(filename) method (Chris Elliott)
wxMSW:
- refresh the buttons properly when the window is resized (Hans Van Leemputten)
- huge (40*) speed up in wxMask::Create()
- changing wxWindows styles also changes the underlying Windows window style
-- wxTreeCtrl supports wxTR_HIDE_ROOT stle (George Policello)
+- wxTreeCtrl supports wxTR_HIDE_ROOT style (George Policello)
- fixed flicker in wxTreeCtrl::SetItemXXX()
- fixed redraw problems in dynamically resized wxStaticText
- improvements to wxWindows applications behaviour when the system colours
delete cmap;
}
- bool saved = FALSE;
-
+ bool loaded;
wxString extension = savefilename.AfterLast('.').Lower();
- if (extension == "bmp")
- saved=image.SaveFile(savefilename, wxBITMAP_TYPE_BMP);
- else if (extension == "png")
- saved=image.SaveFile(savefilename, wxBITMAP_TYPE_PNG);
- else if (extension == "pcx")
- saved=image.SaveFile(savefilename, wxBITMAP_TYPE_PCX);
- else if ((extension == "tif") || (extension == "tiff"))
- saved=image.SaveFile(savefilename, wxBITMAP_TYPE_TIF);
- else if (extension == "jpg")
- saved=image.SaveFile(savefilename, wxBITMAP_TYPE_JPEG);
- else if (extension == "pnm")
- saved=image.SaveFile(savefilename, wxBITMAP_TYPE_PNM);
- else if (extension == "ico")
- saved=image.SaveFile(savefilename, wxBITMAP_TYPE_ICO);
- else if (extension == "cur")
- {
+ if (extension == "cur")
+ {
image.Rescale(32,32);
image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 0);
- image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 0);
- saved=image.SaveFile(savefilename, wxBITMAP_TYPE_CUR);
- }
- else
- wxMessageBox("Unknown file type, see options in file selector.",
- "Unknown file type",
+ image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 0);
+ // This shows how you can save an image with explicitly
+ // specified image format:
+ loaded = image.SaveFile(savefilename, wxBITMAP_TYPE_CUR);
+ }
+ else
+ {
+ // This one guesses image format from filename extension
+ // (it may fail if the extension is not recognized):
+ loaded = image.SaveFile(savefilename);
+ }
+
+ if ( !loaded )
+ wxMessageBox("No handler for this file type.",
+ "File was not saved",
wxOK|wxCENTRE, this);
}
#endif // wxUSE_STREAMS
}
+
+
+bool wxImage::SaveFile( const wxString& filename ) const
+{
+ wxString ext = filename.AfterLast('.').Lower();
+
+ wxImageHandler * pHandler = FindHandler(ext, -1);
+ if (pHandler)
+ {
+ SaveFile(filename, pHandler->GetType());
+ return TRUE;
+ }
+
+ wxLogError(_("Can't save image to file '%s': unknown extension."), filename.c_str());
+
+ return FALSE;
+}
+
bool wxImage::SaveFile( const wxString& filename, int type ) const
{
#if wxUSE_STREAMS