Galaxy 选项卡上的肖像相机方向
我正在三星 Galaxy Tab(7 英寸)上进行开发。我的应用程序必须仅处于纵向模式,即我已在我的应用程序和设备设置中将其锁定为纵向模式。问题是当我尝试旋转相机预览时,它当前以错误的方向旋转 90 度。
现在这是我的surfaceCreatedcamera.setDisplayOrientation
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
try {
camera.setPreviewDisplay(holder);
Camera.Parameters parameters = camera.getParameters();
parameters.setPictureFormat(PixelFormat.JPEG);
parameters.set("orientation", "portrait");
//camera.setDisplayOrientation(90);
parameters.setRotation(90);
camera.setParameters(parameters);
}
catch (IOException exception) {
camera.release();
}
}
(90)似乎不起作用(它什么也没做,这就是我将其注释掉的原因)。然而,parameters.setRotation(90) 实际上完成了工作!但它会在应用程序的一侧创建一个丑陋的“闪烁颜色”“条纹”。 setDisplayOrientation() 应该对我有用,因为我正在运行 android api 8 (Froyo 2.2)!
谷歌上有一个关于与旋转问题相关的问题http:// /code.google.com/p/android/issues/detail?id=1193#c26,但据我所知,它没有对我的问题提出任何建议。
与此问题相关的任何和所有解决方案将不胜感激!谢谢!
I am developing on/for a Samsung Galaxy Tab (7inches). My application has to be in portrait mode only, i.e i have locked it to portrait mode in my application and in the device settings. The problem is when i try to rotate the camera preview, it is currently rotated 90 degrees in the wrong direction.
Right now this is my surfaceCreated
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
try {
camera.setPreviewDisplay(holder);
Camera.Parameters parameters = camera.getParameters();
parameters.setPictureFormat(PixelFormat.JPEG);
parameters.set("orientation", "portrait");
//camera.setDisplayOrientation(90);
parameters.setRotation(90);
camera.setParameters(parameters);
}
catch (IOException exception) {
camera.release();
}
}
The camera.setDisplayOrientation(90) does not seem to be working (it does nothing, which is why i have commented it away). However the parameters.setRotation(90) DOES IN FACT GET THE JOB DONE! but it creates an ugly "stripe" of "flickering colors" along the side of the application. setDisplayOrientation() should work for me, since i am running android api 8 (Froyo 2.2)!!
There is a thread on google about problems pertaining to rotational issues http://code.google.com/p/android/issues/detail?id=1193#c26, but to the best of my knowledge it does not suggest anything for my problem.
Any and all solutions pertaining to this problem will be greatly appreciated! thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这在 Samsung Galaxy 选项卡中对我有用:
This worked for me in Samsung Galaxy tab:
如果您的应用程序设计为仅拍摄肖像照片,那么最简单的方法就是在拍摄照片后旋转图像数据,而不必担心相机设置。我不确定选项卡是否有问题(我从未尝试过旋转相机预览),但拍摄后旋转图像非常简单......问题仅在于您需要知道哪个方向拍摄照片时正在握住设备。如果这不是您关心的问题,请不要担心:)
If your application is designed to only take Portrait photos, then the simplest thing to do is to just rotate the image data after you've taken the photo, and not worry about the camera settings. I'm not sure if the Tab is buggy (I've never tried to rotate the camera preview) but rotating the image after you've taken the shot is very simple... the problem is only if you need to know which way the device was being held when the picture was taken. If that's not a concern for you, then don't fret over it :)
试试这个。我编写了这段代码并在 Galaxy Tab 上进行了测试。代码运行良好
try this. I make this code and test on Galaxy Tab. The code works well