Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:44:17+00:00 2026-06-18T00:44:17+00:00

I am making an application with a built in camera. The Activity is fixed

  • 0

I am making an application with a built in camera. The Activity is fixed to portrait orientation but I want to have the images saved properly right-side up, like so:

Camera camera = getCameraInstance(); //method found on http://developer.android.com/guide/topics/media/camera.html
Camera.Parameters params = camera.getParameters();
params.setRotation(someInteger); //I want to get the proper value for this method
camera.setParameters(params);

Has anyone been able to achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:44:19+00:00Added an answer on June 18, 2026 at 12:44 am

    If you’re just trying to rotate the JPEG images you receive from calling takePicture, then setRotation is the right method to use.

    Is the question about what value to pass into setRotation? Assuming you want real-world ‘up’ to be ‘up’ in the saved JPEG image, setRotate needs to be set based on the current orientation of the camera sensor relative to the world.

    You can find out what the relative orientation of the whole device to the world is, and you can find out what the orientation of the camera sensor is relative to the device’s ‘natural’ orientation, and combine the two rotations into the final answer. The math is easy to get wrong, which is why we have it explicitly spelled out in the API documentation for setRotation, reproduced here:

    public void onOrientationChanged(int orientation) {
       if (orientation == ORIENTATION_UNKNOWNsetRotation) return;
       android.hardware.Camera.CameraInfo info =
            new android.hardware.Camera.CameraInfo();
       android.hardware.Camera.getCameraInfo(cameraId, info);
       orientation = (orientation + 45) / 90 * 90;
       int rotation = 0;
       if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
         rotation = (info.orientation - orientation + 360) % 360;
       } else {  // back-facing camera
         rotation = (info.orientation + orientation) % 360;
       }
       mParameters.setRotation(rotation);
    }
    

    You’ll need to inherit from OrientationEventListener and implement the above for the callback method. Of course, you should check that your camera is open, and that mParameters, etc, is valid before updating the parameters.

    Please note that this only rotates the JPEGs that are sent out by the camera. If you see that your preview is not correctly oriented in your UI, you need to call setDisplayOrientation for that. The camera sensor is normally lined up with the landscape orientation of the device, so landscape camera apps can often get away without calling this function, even though they should in case they’re on an unusual Android device. However, if you’re writing a portrait app, it’s likely mandatory you adjust the display orientation to align with your UI. As with setRotation, you need to take a few factors into account, and sample code for doing the math right is included in the documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a java web application on Eclipse. But i am naive in
So I have an application already built and I'm in charge of making it
I making an application with my own keyboard and I want to completely DISABLE
I have built an ASP.NET mvc web application and it seems that some of
I'm making a Windows Forms application in Visual Studio 2010 Ultimate, but can't get
I have a REST service built using Jersey. I want to be able to
I have an application built with AutoPlay Media Studio which needs to be able
I have an application built in PHP/Symfony. Part of it requires sending what is
I have tested a web application I have built using MVC 2 on local
I'm making a non-garbage-collected MacFUSE Cocoa application, inside of which I want to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.