Forum Discussion

sonya_m's avatar
sonya_m
SmartBear Alumni (Retired)
5 years ago

[TechCorner Challenge #12] Compare images using the Region Checkpoint

Hi TestComplete Community!

 

Dare to take the challenge?๐Ÿ™‚

By completing the tasks, you can practice your skills of working with TestComplete features and also get into the TechCorner Leaderboard! 

 

Task: Compare the two images below using TC Region Checkpoint ...and reveal a secret message! Post the message and the script to the comments.

Difficulty:

 

Steps to do this:

1. Add the images below to the Regions collection.

2. Perform a pixel-by-pixel comparison using the Check method.

3. Click the โ€œView Comparison Resultโ€ button in the log to reveal the secret message and post it along with your script to the comments!

 

Images to compare:

 

 

Have fun and good luck๐Ÿ˜Š

 

  • Task: Compare the two images below using TC Region Checkpoint ...and reveal a secret message! Post the message and the script to the comments.

     

    This is a solution created for [TechCorner Challenge #12]

     

    Secret message:

     

    function Test()

    {

       var pic2 = Utils.Picture;

       pic2.LoadFromFile('D:\\img2.png');

      Regions.img1_png.Check(pic2, false, false, 1, 1);

    }

     

    Result:

    Click here to show or modify data of the checkpoint "img1_png".

    The images are not equal.

    The pixel difference is 1 %.
    The color difference is 20 %.

    There is a slight difference between the compared images. If you want the checkpoint to report them as equal, set its Pixel Tolerance parameter to 277.

    Update the "img1_png" checkpoint data.

     

  • Task: Compare the two images below using TC Region Checkpoint ...and reveal a secret message! Post the message and the script to the comments.

     

    This is a solution created for [TechCorner Challenge #12]

     

    [DelphiScript]

    procedure comparingPictures();

    begin

    if Not Regions.img1_png.Check('img2_png') then

    Log.Message('Differ')

    end;

     

    Project Explorer:

    Workspace

     

    Results

  • anupamchampati's avatar
    anupamchampati
    Frequent Contributor

    Task: Compare the two images below using TC Region Checkpoint ...and reveal a secret message! Post the message and the script to the comments.

     

    This is a solution created for [TechCorner Challenge #12]

     

    Secret message:

     

    function Test()

    {

       var pic2 = Utils.Picture;

       pic2.LoadFromFile('D:\\img2.png');

      Regions.img1_png.Check(pic2, false, false, 1, 1);

    }

     

    Result:

    Click here to show or modify data of the checkpoint "img1_png".

    The images are not equal.

    The pixel difference is 1 %.
    The color difference is 20 %.

    There is a slight difference between the compared images. If you want the checkpoint to report them as equal, set its Pixel Tolerance parameter to 277.

    Update the "img1_png" checkpoint data.

     

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      anupamchampati glad to see you participating in our challenge๐Ÿ™‚

       

      Did you manage to read the secret message? Check out the highlighted changes on the picture tab (like shown in this topic) and post the text you find ๐Ÿ™‚

  • elanto's avatar
    elanto
    Occasional Contributor

    Task: Compare the two images below using TC Region Checkpoint ...and reveal a secret message! Post the message and the script to the comments.

     

    This is a solution created for [TechCorner Challenge #12]

     

    [DelphiScript]

    procedure comparingPictures();

    begin

    if Not Regions.img1_png.Check('img2_png') then

    Log.Message('Differ')

    end;

     

    Project Explorer:

    Workspace

     

    Results

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Good job elanto ! Now we have a Delphi solution as well๐Ÿ™‚