Fixed GDAL loader check
authorMaksim Shabunin <maksim.shabunin@itseez.com>
Wed, 21 Jan 2015 11:01:21 +0000 (14:01 +0300)
committerMaksim Shabunin <maksim.shabunin@itseez.com>
Wed, 21 Jan 2015 11:01:21 +0000 (14:01 +0300)
modules/imgcodecs/src/loadsave.cpp
modules/imgcodecs/test/test_grfmt.cpp

index c06b42a..8526a4a 100644 (file)
@@ -247,7 +247,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
     ImageDecoder decoder;
 
 #ifdef HAVE_GDAL
-    if( (flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL ){
+    if(flags != IMREAD_UNCHANGED && (flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL ){
         decoder = GdalDecoder().newDecoder();
     }else{
 #endif
@@ -275,7 +275,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
 
     // grab the decoded type
     int type = decoder->type();
-    if( flags != -1 )
+    if( flags != IMREAD_UNCHANGED )
     {
         if( (flags & CV_LOAD_IMAGE_ANYDEPTH) == 0 )
             type = CV_MAKETYPE(CV_8U, CV_MAT_CN(type));
@@ -336,7 +336,7 @@ imreadmulti_(const String& filename, int flags, std::vector<Mat>& mats)
     ImageDecoder decoder;
 
 #ifdef HAVE_GDAL
-    if ((flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL){
+    if (flags != IMREAD_UNCHANGED && (flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL){
         decoder = GdalDecoder().newDecoder();
     }
     else{
@@ -362,7 +362,7 @@ imreadmulti_(const String& filename, int flags, std::vector<Mat>& mats)
     {
         // grab the decoded type
         int type = decoder->type();
-        if (flags != -1)
+        if (flags != IMREAD_UNCHANGED)
         {
             if ((flags & CV_LOAD_IMAGE_ANYDEPTH) == 0)
                 type = CV_MAKETYPE(CV_8U, CV_MAT_CN(type));
@@ -508,7 +508,7 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
     size.height = decoder->height();
 
     int type = decoder->type();
-    if( flags != -1 )
+    if( flags != IMREAD_UNCHANGED )
     {
         if( (flags & CV_LOAD_IMAGE_ANYDEPTH) == 0 )
             type = CV_MAKETYPE(CV_8U, CV_MAT_CN(type));
index d1610ae..423d030 100644 (file)
@@ -104,7 +104,8 @@ TEST(Imgcodecs_imread, regression)
         ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_COLOR));
         ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_ANYDEPTH));
         ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_ANYCOLOR));
-        ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_LOAD_GDAL));
+        if (i != 2) // GDAL does not support hdr
+            ASSERT_TRUE(imread_compare(folder + string(filenames[i]), IMREAD_LOAD_GDAL));
     }
 }
 
@@ -684,7 +685,7 @@ public:
         compare(IMREAD_COLOR);
         compare(IMREAD_ANYDEPTH);
         compare(IMREAD_ANYCOLOR);
-        compare(IMREAD_LOAD_GDAL);
+        // compare(IMREAD_LOAD_GDAL); // GDAL does not support multi-page TIFFs
     }
 };