Forum Discussion

KateIV's avatar
KateIV
New Member
5 years ago

Region iImage Comparison Fails by color depth

Hi,

 

I am running tests on a VM using TestExecute. Snapshots (regions) make by TestComplete not on VM. All time was all good, but recently (maybe new version of TestComplete, maybe updates on Windows) but the comparisons on real computer is failed. The difference is the color depth (it was 32 but now is 24). Where can I set the option of 32 bit depth? The display option in Windows is 32 bit. Maybe some option in TestComplete?

Please help me

 
  • Attached the sample code to change the resolution and color depth , please let me know if you need any help in configuration. I tried it very long back in one of my projects so not tried it on the latest version.

    function Test()
    {
    SetDisplay(800, 600, 32);
    }

    // The function changes the display settings:
    // x - resolution
    // y - resolution
    // d - color depth
    function SetDisplay(x, y, d)
    {
    var dm = Win32API.DEVMODE();
    if(0 < Win32API.EnumDisplaySettings(0, -1, dm)) {
    dm.dmPelsWidth = x;
    dm.dmPelsHeight = y;
    dm.dmBitsPerPel = d;

    var res = Win32API.ChangeDisplaySettings(dm, 0);
    if(res == DISP_CHANGE_BADMODE){
    Log.Error("A call to the ChangeDisplaySettings() function failed in the " +
    "SetDisplay() function.",
    "The specified graphics mode (screen resolution: " + x + "*" +
    y + "; color depth: " + d + " bits per pixel) is not supported.",
    pmLower);
    }
    return res;
    }
    else {
    var dwLastError = Win32API.GetLastError();
    Log.Error("A call to the EnumDisplaySettings() failed in the " +
    "SetDisplay() function.",
    "System error code: " + dwLastError + " (" +
    + Utilities.SysErrorMessage(dwLastError) + ")", pmLower);
    return -1;
    }
    }

  • Wamboo's avatar
    Wamboo
    Community Hero

    In my opinion, it's impossible to set it on TestComplete page.

     

    It will be easier for you to change operating system settings.

    • anupamchampati's avatar
      anupamchampati
      Frequent Contributor

      Attached the sample code to change the resolution and color depth , please let me know if you need any help in configuration. I tried it very long back in one of my projects so not tried it on the latest version.

      function Test()
      {
      SetDisplay(800, 600, 32);
      }

      // The function changes the display settings:
      // x - resolution
      // y - resolution
      // d - color depth
      function SetDisplay(x, y, d)
      {
      var dm = Win32API.DEVMODE();
      if(0 < Win32API.EnumDisplaySettings(0, -1, dm)) {
      dm.dmPelsWidth = x;
      dm.dmPelsHeight = y;
      dm.dmBitsPerPel = d;

      var res = Win32API.ChangeDisplaySettings(dm, 0);
      if(res == DISP_CHANGE_BADMODE){
      Log.Error("A call to the ChangeDisplaySettings() function failed in the " +
      "SetDisplay() function.",
      "The specified graphics mode (screen resolution: " + x + "*" +
      y + "; color depth: " + d + " bits per pixel) is not supported.",
      pmLower);
      }
      return res;
      }
      else {
      var dwLastError = Win32API.GetLastError();
      Log.Error("A call to the EnumDisplaySettings() failed in the " +
      "SetDisplay() function.",
      "System error code: " + dwLastError + " (" +
      + Utilities.SysErrorMessage(dwLastError) + ")", pmLower);
      return -1;
      }
      }

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        Thank you Wamboo, Anupam! 

         

        KateIV Have you tried the suggestions? Please share your results🙂