A couple of changes to wxImage:

1. changed wxBMP_foo, wxCUR_foo to wxIMAGE_OPTION_{BMP,CUR}_foo
   (with backward compatiblity macros, of course)
2. applied Chris' patch to update hotspot when scaling an image
3. applied Chris' patch to write a filename in XPM and generalized it
   to pass wxIMAGE_OPTION_FILENAME to all saving handlers


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14247 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2002-02-16 01:45:30 +00:00
parent 06534aa178
commit fd94e8aa45
7 changed files with 67 additions and 33 deletions

View File

@@ -127,13 +127,26 @@ bool wxXPMHandler::SaveFile(wxImage * image,
for ( k = MaxCixels; cols > k; k *= MaxCixels)
chars_per_pixel++;
// 2. write the header:
// 2. write the header:
wxString sName;
if ( image->HasOption(wxIMAGE_OPTION_FILENAME) )
{
wxSplitPath(image->GetOption(wxIMAGE_OPTION_FILENAME),
NULL, &sName, NULL);
sName << wxT("_xpm");
}
if ( !sName.IsEmpty() )
sName = wxString(wxT("/* XPM */\nstatic char *")) + sName;
else
sName = wxT("/* XPM */\nstatic char *xpm_data");
stream.Write(sName.c_str(), sName.Len());
char tmpbuf[200];
// VS: 200b is safe upper bound for anything produced by sprintf below
// (101 bytes the string, neither %i can expand into more than 10 chars)
// (<101 bytes the string, neither %i can expand into more than 10 chars)
sprintf(tmpbuf,
"/* XPM */\n"
"static char *xpm_data[] = {\n"
"[] = {\n"
"/* columns rows colors chars-per-pixel */\n"
"\"%i %i %i %i\",\n",
image->GetWidth(), image->GetHeight(), cols, chars_per_pixel);