1

我制作了一个自定义相机应用程序,并在相机点击后在图像视图中显示我的图像。但是在这里我面临一个问题,即我捕获的图像总是以改变方向设置。

即,如果我在将相机作为人像时拍摄照片,它不会将图像设置为人像,它会改变方向。

这是相机点击代码:-

@Override
        public void onPictureTaken(byte[] data, Camera camera) {

            //here we write the code for saving the picture onto the sdCard


            File pictureFileDir = getDir();

            //to check whether directory exists or not!!
            if (!pictureFileDir.exists() && !pictureFileDir.mkdirs()) {

                //Log.d(Constants.DEBUG_TAG, "Can't create directory to save image.");
                Toast.makeText(Irant_Custom_cameraApplication.this, "Can't create directory to save image.",
                        Toast.LENGTH_LONG).show();
                return;

            }

            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyymmddhhmmss");
            String date = dateFormat.format(new Date());
            photo_file="Picture_"+date+".jpg";

            photo_FileName = pictureFileDir.getPath()+File.separator+photo_file;

            picture_file = new File(photo_FileName);

            FileOutputStream outStream = null;
            try{
                Toast.makeText(getApplicationContext(), "Image captured!", Toast.LENGTH_LONG).show();
                outStream = new FileOutputStream(picture_file);
                outStream.write(data);
                outStream.close();

                String imgpath = photo_file;
                System.out.println("Path for the image*********************"+photo_file);
                SignupDetails.imagePath=imgpath;

            }


            catch (Exception e) {

                Log.d("Image save error :", e.getMessage());    
            }
        }
    };
4

1 回答 1

0

每个设备的实现并不总是相同的,有些会自动旋转,有些则不会。我认为最好的方法是查看文件的EXIF数据。那是你最好的选择。

于 2012-08-23T21:45:31.330 回答