当前位置: 动力学知识库 > 问答 > 编程问答 >

Windows 8 orientation from desktop application

问题描述:

I am developing a windows 8 compatible desktop service that uses a camera preview stream. On convertible laptops (dell xps 12), i am having trouble with the orientation of the camera. basically i need to rotate the stream in sync with the stream. I am using windows rt apis (SimpleOrientationSensor, DisplayProperties, DisplayInformation) to get this orientation information.

if i only use SimpleOrientationSensor, that does not always change in sync with the windows desktop. sometimes the desktop orientation is locked, and SimpleOrientationSensor fires events but the desktop doesn't change orientations (laptop mode).

I tried using DisplayProperties, but it only reports "landscape" while running from a service, and per http://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.display.displayproperties.aspx, DisplayProperties is deprecated: "DisplayProperties may be altered or unavailable for releases after Windows 8.1. Instead, use DisplayInformation."

if i try to use DisplayInformation.GetForCurrentView() from my desktop app, i get an exception "Windows.Graphics.Display: GetForCurrentView must be called on a thread that is associated with a CoreWindow".

I can use SimpleOrientationSensor, but I am wondering if there is an event or property for laptop mode (locked orientation) vs tablet mode (any orientation) in these convertible laptops. any help appreciated!

网友答案:

Update:

I found the GetSystemMetrics() API, which doesn't seem to work very well (bad error handling). Also found a registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\PriorityControl ConvertibleSlateMode DWORD which seems more reliable, this is what i am implementing with.

I also found this article: https://software.intel.com/en-us/articles/detecting-slateclamshell-mode-screen-orientation-in-convertible-pc

分享给朋友:
您可能感兴趣的文章:
随机阅读: