使用android NDK NativeWindow显示图像时,如何锁定方向?
在android NDK中,当使用NativeWindow显示图像时,如何锁定方向?基本上,当手机旋转时,我希望图像相对于手机相对静止。 (如果我不清楚,请参见下图)。
_____
| ^ |
| o |
|____|
_______
| < o |
|______|
我遵循示例程序native Plasma,并使用ANativeWindow_Buffer。我的图像分辨率是 480x800,如果我以纵向模式握住手机,本机窗口的分辨率也是 480x800。但是,如果我以横向模式握住手机,本机窗口大小将变为 800x480,并且显示的图像会变得混乱,除非我更改填充缓冲区的方式。我想知道是否有一种方法可以将本机窗口缓冲区大小始终设置为 480x800,并防止它在手机旋转时发生变化。
我在 ANativeWindow API 中看到,有一个函数 ANativeWindow_setBuffersGeometry 我尝试用它来将缓冲区几何形状设置为 480 x 800,但没有任何效果。
请帮忙。 谢谢。
In android NDK, when use NativeWindow to display image, how to lock the orientation? Basically, when the phone rotate, I want the image relatively still to the phone. (See the illustration below, in case I’m not clear).
_____
| ^ |
| o |
|____|
_______
| < o |
|______|
I followed the sample program native plasma, and used the ANativeWindow_Buffer. My image resolution is 480x800, the native window’s resolution is also 480x800 if I hold the phone in portrait mode. However if I hold the phone in landscape mode, the native window size becomes 800x480, and my displayed image mess up unless I change how I fill the buffer. I wonder if there is a way to set the native window buffer size always to 480x800, and prevent it change when the phone rotates.
I see in the ANativeWindow API, there is a function, ANativeWindow_setBuffersGeometry
I tried to use it to set the buffer geometry to 480 by 800, but it did not have any effect.
Please help.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信,您仍然应该能够在 Java 端清单中处理这个问题...
在活动标记中,添加
You should still be able to handle this in your Java side manifest, I believe...
in the activity tag, add