]> git.cworth.org Git - apitrace/blobdiff - image.cpp
Remove spurious tag in snapdiff output.
[apitrace] / image.cpp
index 9fd1dc8096992e78c651609c1e58d68d68200d19..937f486bfbc01cbe3676b54ce67be52f84b1a754 100644 (file)
--- a/image.cpp
+++ b/image.cpp
@@ -165,7 +165,7 @@ Image::writePNG(const char *filename) const {
     png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB_ALPHA,
         PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
 
-    png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
+    png_set_compression_level(png_ptr, Z_DEFAULT_COMPRESSION);
 
     png_write_info(png_ptr, info_ptr);
 
@@ -286,9 +286,13 @@ double Image::compare(Image &ref)
 
     unsigned long long error = 0;
     for (unsigned y = 0; y < height; ++y) {
-        for (unsigned  x = 0; x < width*4; ++x) {
-            int delta = pSrc[x] - pRef[x];
-            error += delta*delta;
+        for (unsigned  x = 0; x < width; ++x) {
+            // FIXME: Ignore alpha channel until we are able to pick a visual
+            // that matches the traces
+            for (unsigned  c = 0; c < 3; ++c) {
+                int delta = pSrc[x*4 + c] - pRef[x*4 + c];
+                error += delta*delta;
+            }
         }
 
         pSrc += stride();
@@ -296,7 +300,7 @@ double Image::compare(Image &ref)
     }
 
     double numerator = error*2 + 1;
-    double denominator = height*width*4ULL*255ULL*255ULL*2;
+    double denominator = height*width*3ULL*255ULL*255ULL*2;
     double quotient = numerator/denominator;
 
     // Precision in bits