简体   繁体   English

三星银河S2始终将相机视图视为风景?

[英]samsung galaxy s2 always treat camera view as landscape?

My app ask the user to take a photo and then saves it. 我的应用程序要求用户拍照,然后将其保存。

I have noticed that Samsung Galaxy S2 takes a portrait photo 我注意到三星Galaxy S2拍摄人像照片

but when I save it to the server I see it in landscape only in the server. 但是,当我将其保存到服务器时,只能在服务器中以横向方式看到它。

(even though it was taken in portrait). (即使是纵向拍摄)。

It doesn't happen for me with other phones (Samsung S4, Nexus 5). 对于其他手机(三星S4,Nexus 5),这对我而言并非如此。

When I look at the photo gallery I see the photo in portrait. 当我看着照片库时,我看到的是肖像照片。

Update 更新资料

The weird thing is that in my java code it seemed to be portrait orientation 奇怪的是,在我的Java代码中,它似乎是纵向的

so I really don't get it: 所以我真的不明白:

            if (getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                //a             
}else {
                //b
            }

But i saw something odd: the settings and other native dialog are all landscape when using S2 camera. 但是我看到了奇怪的事情:使用S2相机时,设置和其他本机对话框都是横向的。 see attachment: 详见附件:

Update2 更新2

I have checked exif.getAttributeInt(ExifInterface.TAG_ORIENTATION and got 6 ( ExifInterface.ORIENTATION_ROTATE_90) 我检查了exif.getAttributeInt(ExifInterface.TAG_ORIENTATION并得到6(ExifInterface.ORIENTATION_ROTATE_90)

So i have tried to set this to ORIENTATION_ROTATE_270 or ORIENTATION_NORMAL 所以我试图将其设置为ORIENTATION_ROTATE_270或ORIENTATION_NORMAL

but it didn't help 但这没有帮助

    ExifInterface exif;
    try {
      exif = new ExifInterface(imageFilename);
      int orientation =
          exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
      exif.setAttribute(ExifInterface.TAG_ORIENTATION,
          String.valueOf(ExifInterface.ORIENTATION_ROTATE_270));
      exif.saveAttributes();
      orientation =
          exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
      boolean b = orientation == Configuration.ORIENTATION_LANDSCAPE;

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

在此处输入图片说明

You are right. 你是对的。 The documentation of Camera.Parameters.setRotation() is very clear: Camera.Parameters.setRotation()的文档非常清楚:

The camera driver may set orientation in the EXIF header without rotating the picture. 相机驱动程序可以在EXIF标头中设置方向而无需旋转图片。 Or the driver may rotate the picture and the EXIF thumbnail. 否则,驱动程序可能会旋转图片和EXIF缩略图。 If the Jpeg picture is rotated, the orientation in the EXIF header will be missing or 1 (row #0 is top and column #0 is left side). 如果旋转Jpeg图片,则EXIF标头中的方向将丢失或为1(行#0在顶部,列#0在左侧)。

The solution is to actually perform rotation of the pictures before upload, or maybe on the server (the choice depends on your product requirements). 解决方案是在上传之前或可能在服务器上实际执行图片旋转(选择取决于您的产品要求)。 You can use a Java MediaUtil library, see eg https://stackoverflow.com/a/15302674/192373 . 您可以使用Java MediaUtil库,请参见例如https://stackoverflow.com/a/15302674/192373

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM