0

i am trying to save captured image in portrait mode ... but not getting click how to do this?

here is my code...

captureImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            camera.takePicture(null, null, mPicture);
        }
    });

PictureCallback mPicture = new PictureCallback() {
    @Override
    public void onPictureTaken(byte[] data, Camera camera) {
        File pictureFile = getOutputMediaFile();
        if (pictureFile == null) {
            System.out.println("picture file is null");
            return;
        }
        try { 

            FileOutputStream fos = new FileOutputStream(pictureFile);
            fos.write(data);
            // map.compress(Bitmap.CompressFormat.JPEG, 20, fos);
            // fos.flush();
            fos.close();
        } catch (FileNotFoundException e) {

        } catch (IOException e) {
        }
    }
};

and the outputmedia ...

private File getOutputMediaFile() {
    File mediaStorageDir = new File(
            Environment
                    .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
            "MyCameraApp");
    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d("MyCameraApp", "failed to create directory");
            return null;
        }
    }
    // Create a media file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
            .format(new Date());
    File mediaFile;
    mediaFile = new File(mediaStorageDir.getPath() + File.separator
            + "IMG_" + timeStamp + "_" + userId + ".jpg");
    String imageName = "IMG_" + timeStamp + "_" + userId + ".jpg";
    System.out.println("###### image is: " + imageName);
    Intent intent = new Intent(this, VideoPlaybackActivity.class);
    intent.putExtra("file_name", imageName);
    intent.putExtra("data_type", "image");
    intent.putExtra("fromClass", "Captured_Image");
    intent.putExtra("expiry_time", "5");
    intent.putExtra("cameraId", cameraId);
    super.startActivity(intent);
    finish();
    return mediaFile;
}

i am getting image in my directory
but all images are in landscape mode. so please if any body can help...

dev_android
  • 493
  • 1
  • 11
  • 29
  • 1
    exif rotation problem as far as i can see it. the work around is to look for exif rotation via exif interface and rotate accordingly – Illegal Argument Jun 19 '14 at 14:39
  • You are starting a VideoPlaybackActivity before you saved the file. Moreover you do that in a function which name does not tell that that would happen. – greenapps Jun 19 '14 at 14:55
  • i am opening other activity to show image in next activity.. @greenapps – dev_android Jun 19 '14 at 14:59
  • 1
    Yes I understood that of course. But that was not my remark. Read carefully please. – greenapps Jun 19 '14 at 16:19
  • so what should be the exact way for doing this? @greenapps – dev_android Jun 20 '14 at 11:15
  • i have also checked on stackoverflow like here but i am unable to check where is issue... http://stackoverflow.com/questions/14066038/why-image-captured-using-camera-intent-gets-rotated-on-some-devices-in-android?lq=1 @IllegalArgument – dev_android Jun 20 '14 at 11:17
  • What is the problem exactly? Is your image always rotated? I mean independent from the camera hold in portrait or landsape? Did you have a look at the function `rotateImageIfRequired` there? Why are you saying `i am trying to save captured image in portrait mode`? If it is taken holding the camera in landscape? Please explain better. – greenapps Jun 20 '14 at 11:46

0 Answers0