Test decoding the bounds in skimage.
authorscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 18 Jul 2013 20:08:26 +0000 (20:08 +0000)
committerscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 18 Jul 2013 20:08:26 +0000 (20:08 +0000)
Test that the bounds match the bounds from doing a pixel decode.

R=djsollen@google.com

Review URL: https://codereview.chromium.org/19587003

git-svn-id: http://skia.googlecode.com/svn/trunk@10164 2bbb7eff-a529-9590-31e7-b0007b416f81

tools/skimage_main.cpp

index 6cfc36c..ef5c133 100644 (file)
@@ -327,6 +327,22 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath)
         return;
     }
 
+    // Test decoding just the bounds. The bounds should always match.
+    {
+        stream.rewind();
+        SkBitmap dim;
+        if (!codec->decode(&stream, &dim, SkImageDecoder::kDecodeBounds_Mode)) {
+            SkString failure = SkStringPrintf("failed to decode bounds for %s", srcPath);
+            gDecodeFailures.push_back() = failure;
+        } else {
+            // Now check that the bounds match:
+            if (dim.width() != bitmap.width() || dim.height() != bitmap.height()) {
+                SkString failure = SkStringPrintf("bounds do not match for %s", srcPath);
+                gDecodeFailures.push_back() = failure;
+            }
+        }
+    }
+
     if (compare_to_expectations_if_necessary(bitmap, filename, &gDecodeFailures)) {
         gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.width(),
                                               bitmap.height());