Forum Discussion

sshah1's avatar
sshah1
Contributor
9 years ago

Using "Transparent" in Regions.compare does not work

Hi,

I am using TC11.20 for Desktop testing. I read all the related topics previously posted for image comparison, but couldn't find answer, so posting question with my scenario.

I have script written to compare screenshots and I use Regions.Compare method to compare two images.

I have saved baseline image in Stores (as Regions), and image to compare with in some folder. I am using Transparent=true as I need to skip some parts of the image from comparision. I used MS paint to edit Baseline image and filled some areas with Transparent color, making sure top left pixel (0,0) has same color.

 

Both screenshots are exactly same except date and battery power at top, still comparision result shows lot of differences.

If I compare images without editing baseline with Transparent color, it only shows two difference.

 

Why comparison shows so many differences using Transparent parameter?

How exactly I can fill Transparent color for some areas of image?

 

Thanks for your help,

Samixa

  • sshah1's avatar
    sshah1
    9 years ago

    Thanks for your response.

    With the help of Test Complete support team figured out that I need to use high quality image format. I was using .jpg format. I created new images with ".png" format, now image comarison excludes areas with Transparent color and shows images are equal.

    • sshah1's avatar
      sshah1
      Contributor

      Do we need to use Pixel Tolerance value in order to use "Transparent" parameter? I just like to exclude date filed from comparision, so use of Transparent parameter makes more sense.

      Thanks for suggestions.

  • It would be interesting to see your two images and the command you're using for the comparison.

    • sshah1's avatar
      sshah1
      Contributor

      Hi,

      My script looks like this, I have many screenshots to compare, so I have For loop to get all Test images from C: drive and Base images are stored in Regions.

       

      ObjTestPict = Utils["Picture"];

      FolderPath = "C:\\Users\\...";
      ObjFolder = aqFileSystem["GetFolderInfo"](FolderPath);
      AllTestFiles = ObjFolder["Files"];
      TestFileCount = AllTestFiles["Count"];
      for(i=0; i<TestFileCount; i++)
      {
             TestPict = AllTestFiles["Item"](i);

       

             BasePict = Regions["GetPicture"](BasePictName);  

             ObjTestPict["LoadFromFile"](TestPict["Path"]);

       

             if (! Regions["Compare"](BasePict, ObjTestPict, true)) // compare screenshots
            {
                 Log["Message"]("Pictures are not identical");
            }

      }

       

      Thanks,

      Samixa

      • joseph_michaud's avatar
        joseph_michaud
        Moderator

        If I compare images without editing baseline with Transparent color, it only shows two difference.

         

        Don't know if you've resolved this, but perhaps the transparent pixel (0, 0) is not actually what you think it is...