Browse Source

support image filenames with embedded dots

David Rose 23 years ago
parent
commit
07ab48032d
1 changed files with 11 additions and 7 deletions
  1. 11 7
      pandatool/src/egg-palettize/imageFile.cxx

+ 11 - 7
pandatool/src/egg-palettize/imageFile.cxx

@@ -193,15 +193,19 @@ void ImageFile::
 set_filename(const string &dirname, const string &basename) {
   _filename = Filename(dirname, basename);
 
-  if (_properties._color_type != (PNMFileType *)NULL) {
-    _filename.set_extension
-      (_properties._color_type->get_suggested_extension());
+  if (_properties._alpha_type != (PNMFileType *)NULL) {
+    _alpha_filename = 
+      _filename.get_fullpath() + "_a." +  
+      _properties._alpha_type->get_suggested_extension();
   }
 
-  if (_properties._alpha_type != (PNMFileType *)NULL) {
-    _alpha_filename = _filename.get_fullpath_wo_extension() + "_a";
-    _alpha_filename.set_extension
-      (_properties._alpha_type->get_suggested_extension());
+  if (_properties._color_type != (PNMFileType *)NULL) {
+    // We shouldn't use _filename.set_extension(), because that may
+    // inadvertently truncate the filename if it already includes a
+    // dot.
+    _filename = 
+      _filename.get_fullpath() + "." +
+      _properties._color_type->get_suggested_extension();
   }
 }