ecere/gfx/Bitmap: Load(): Try other types on images with wrong extension
authorJerome St-Louis <jerome@ecere.com>
Tue, 11 Mar 2014 04:04:27 +0000 (00:04 -0400)
committerJerome St-Louis <jerome@ecere.com>
Tue, 11 Mar 2014 04:04:27 +0000 (00:04 -0400)
- If no type is specified and an image fails to load as the type its extension would suggest,
  we will now attempt to load it as one of the other image formats we support.

ecere/src/gfx/Bitmap.ec

index 3d9ad51..d2d5167 100644 (file)
@@ -516,16 +516,17 @@ public:
       char ext[MAX_EXTENSION];
       subclass(BitmapFormat) format;
       int typeToTry = -1;
+      char * guessedType = type;
 
       if(!fileName) return false;
-      if(!type)
+      if(!guessedType)
       {
-         type = GetExtension(fileName, ext);
-         strlwr(type);
+         guessedType = GetExtension(fileName, ext);
+         strlwr(guessedType);
       }
 
-      if(type)
-         format = FindFormat(type);
+      if(guessedType)
+         format = FindFormat(guessedType);
       if(!format)
          typeToTry = 0;
 
@@ -555,7 +556,11 @@ public:
                delete f;
             }
          }
-         if(typeToTry == -1) break;
+         if(typeToTry == -1)
+         {
+            if(type) break;
+            typeToTry = 0;
+         }
       }
 
       if(!result)