IDXGIOutputDuplication::AcquireNextFrame

JTurner 1 Reputation point
2021-03-16T22:23:07.353+00:00

I'm using IDXGIOutputDuplication::AcquireNextFrame with a rotated monitor. When using on Win10 I'm getting an un-rotated orientation frame like the documentation states. When using on Win8.1 the frame returned is not un-rotated but is matching the screen orientation. Is there a way to determine if the returned frame is un-rotated or not?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,389 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Strive Sun-MSFT 426 Reputation points
    2021-03-18T02:26:20.277+00:00

    Hello, @JTurner

    I save the Rotation value from when I'm calling IDXGIOutputDuplication::GetDesc when I'm calling IDXGIAdapter::EnumOutputs.

    typedef struct DXGI_OUTPUT_DESC {  
      WCHAR              DeviceName[32];  
      RECT               DesktopCoordinates;  
      BOOL               AttachedToDesktop;  
      DXGI_MODE_ROTATION Rotation;  
      HMONITOR           Monitor;  
    } DXGI_OUTPUT_DESC;  
    

    1.png

    Do you mean the DesktopCoordinates and Rotation parameters? They will change as the display orientation changes.

    When using on Win8.1 the frame returned is not un-rotated but is matching the screen orientation.

    What does un-rotated mean? How will the Rotation value change?

    What I really need to know is if this a Win8 behavior or if it is the graphic driver behavior.

    I'm not sure for the time being whether the results I got are consistent with yours, so I need more details on debugging before we get the correct answer.

    ----------

    Thank you!

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. JTurner 1 Reputation point
    2021-03-19T14:41:31.22+00:00

    From https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/desktop-dup-api

    Rotating the desktop image
    You must add explicit code to your desktop duplication client app to support rotated modes. In a rotated mode, the surface that you receive from IDXGIOutputDuplication::AcquireNextFrame is always in the un-rotated orientation, and the desktop image is rotated within the surface. For example, if the desktop is set to 768x1024 at 90 degrees rotation, AcquireNextFrame returns a 1024x768 surface with the desktop image rotated within it. Here are some rotation examples.

    On a Win10 machine a 1920x1080 monitor in portrait mode will return an un-rotated image in 1920x1080. On Win8.1 the image I get matches the orientation of the monitor and is 1080x1920. This makes it really hard to try and handle both cases. My concern is that it is the video driver that is returning the image in 1080x1920 and that on Win10 I'll still have a problem. I'm trying to find an api that will tell me if the captured frame is rotated or un-rotated other than the width and height values. Because if the monitor is in landscaped (flipped) there is no way to determine what the orientation is.