在 Android 中使用相机
我正在 Android 中开发一个使用相机的应用程序,我面临以下问题。
1.如果我只是简单地拍摄一张照片,没有对相机进行特殊设置(我的意思是方向设置),预览和生成的图片将如下所示: http://i51.tinypic.com/xfx3jq.png 这根本不正确。 现在我对这张图片所做的就是将其上传到一个以相同方向设置的网站!
2.如果我将 Activity 设置为 LANDSCAPE
模式,那么我的图片将如下所示: http://i56.tinypic.com/152c41e.png 按钮设置如您所见任何额外的视图都设置错误,如下所示: http://i56.tinypic.com/16ifxqx.png 这是极其错误的。 最重要的是,当我将图片上传到网站时,其方向不再正确,如下所示: http:// /i51.tinypic.com/xfx3jq.png。
我应该如何继续才能获得正确定向的图片,并且额外的视图看起来正常,并且当我将其上传到网站时看起来也垂直定向??? 谢谢你!
我必须说我正在 Android 中构建自己的相机。
编辑:我尝试过
Camera.Parameters p = mCamera.getParameters();
p.setRotation(270);
mCamera.setParameters(p);
,但对我的形象没有影响!
编辑:
在我的 onCreate()
中,我以这种方式设置了方向:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
这使我的图像看起来像我想要的样子,但是当我将图像加载到网站时,我的视图设置错误它又回到了最初的方向!
I'm working on an application in android which uses the camera and I'm facing the following issue.
1.If I simply take a picture with no special settings for the camera(orientation settings I mean) also the preview and my resulting picture will look like this:
http://i51.tinypic.com/xfx3jq.png which is not right at all.
Now what I do with this picture is to upload it to a website where is set up with the same orientation!!!
2.If I setup my activity in the LANDSCAPE
mode then my picture will look like this:
http://i56.tinypic.com/152c41e.png with the buttons setup the way you seee.And any extra view is setup wrong like in here: http://i56.tinypic.com/16ifxqx.png which is extremly wrong.
And above all when I upload the picture to a website is not orientated corectly anymore and it looks like this: http://i51.tinypic.com/xfx3jq.png.
How should I proceed in order to get a corectly orientated picture with the extra view looking normally and when I upload it to the website to look also vertically orientated???
Thank you!
I must say that I'm bulilding my own camera in android.
EDIT: I tried
Camera.Parameters p = mCamera.getParameters();
p.setRotation(270);
mCamera.setParameters(p);
but has no effect upon my image!
EDIT:
in my onCreate()
I've setup my orientation this way:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this makes my image look the way I want to look, but my views are setup astray and when I load the image to a website it comes back to the initial orientation!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
较旧的 Android 版本有一个关于相机方向的错误,将其添加到您的 onCreate() 方法中应该可以解决此问题(为了向后兼容,在较新的 Android 版本中也是如此):
这与您想要的方向无关。但要注意:这对很多手机都有帮助,但在三星手机上会严重失败,因为他们似乎已经解决了这个破坏向后兼容性的问题。对于那些您可以添加类似内容的内容(但仅适用于这些设备):
请参阅此处以获取更多信息:相机方向问题
Older Android-Versions had a bug concerning the camera orientation, adding this to your onCreate()-Method should fix this (for backward compatibility this is also the case in newer android versions):
This is regardless of the orientation you want. But beware: this will help on a lot of phones, but e.g. will terribly fail on samsung phones as they seem to have fixed this issue breaking backward compatibility. For those you can add something like this (but only for those devices):
Have a look here for further informations: Orientation Problem in Camera