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 ...
  • anupamchampati's avatar
    anupamchampati
    5 years ago

    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;
    }
    }