Ask a Question

How to get the pixel tolerance value?

SOLVED
slaugier
Occasional Contributor

How to get the pixel tolerance value?

Hello, 

 

I compare 2 files. My goal is to set a warning message if the pixel tolerance is below a certain value. An error message if it is up to this value.

How can I get the exact pixelTolerance value?

 

Here is my code. I want to update it and put an If condition before the Log.Warning line


     

if (!pic_1.Compare(pic_2, false, 5, false, 5, 0))     
{
// Images are differents
// Post image differences to the log
imgError = pic_1.Difference(pic_2, false, 5, false, 5, 0);
Log.Picture(imgMaskError);

//png file with errors
imgError.SaveToFile(sDirectoryPath + sReportName + "_error_p"
+ aqConvert.IntToStr(i+1) + ".png");

// Post a warning message
Log.Warning("Pages " + aqConvert.IntToStr(i+1) + " are differents.");
aqFile.WriteToTextFile(sDirectoryPath + "log.log", "Page "
+ aqConvert.IntToStr(i+1) + " KO : " + sReportName + "_error_p"
+ aqConvert.IntToStr(i+1) + ".png created.\r\n",
aqFile.ctANSI, false);
}

else
{
// Pages are equals
Log.Message("Pages " + aqConvert.IntToStr(i+1) + " are equals.")
aqFile.WriteToTextFile(sDirectoryPath + "log.log",
"Page " + aqConvert.IntToStr(i+1) + " OK.\r\n",
aqFile.ctANSI, false);
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
cunderw
Community Hero

Re: How to get the pixel tolerance value?

I'm not sure of way to get the difference value returned from not matching values, but you specify the tolerance in your compare. 

 

https://support.smartbear.com/testcomplete/docs/reference/program-objects/picture/compare.html

 

But for what you're doing I don't think you really even need it. You could just nest compares with varying tolerances.

 

  let maxDifference = 20;
  // check if they're identical
  if(!pic_1.Compare(pic_2)) {
    // if they're more than maxDifference log error
    if(!pic_1.Compare(pic_2, false, maxDifference, false, 5, 0)) {
      Log.Error()
    } else {
      // they're different but acceptable log a warning
      Log.Warning();
    }
  }

Thanks,
Carson

Click the Accept as Solution button if my answer has helped

View solution in original post

1 REPLY 1
cunderw
Community Hero

Re: How to get the pixel tolerance value?

I'm not sure of way to get the difference value returned from not matching values, but you specify the tolerance in your compare. 

 

https://support.smartbear.com/testcomplete/docs/reference/program-objects/picture/compare.html

 

But for what you're doing I don't think you really even need it. You could just nest compares with varying tolerances.

 

  let maxDifference = 20;
  // check if they're identical
  if(!pic_1.Compare(pic_2)) {
    // if they're more than maxDifference log error
    if(!pic_1.Compare(pic_2, false, maxDifference, false, 5, 0)) {
      Log.Error()
    } else {
      // they're different but acceptable log a warning
      Log.Warning();
    }
  }

Thanks,
Carson

Click the Accept as Solution button if my answer has helped

View solution in original post

cancel
Showing results for 
Search instead for 
Did you mean: