I am working on an Android device with a camera set up in vertical orientation. The problem I am trying to fix is that, when you take a picture with the Camera app, the image gets save in horizontal mode instead of vertical mode. Basically, it’s like it’s rotating the image when saving it.
I have managed to make the camera save the images in vertical orientation by modifying the LegacyCamera app’s code in packages/apps/LegacyCamera/src/com/android/camera/Camera.java
. I have done this in the storeImage
function:
private void storeImage(final byte[] data, Location loc, int width,
int height, long dateTaken, int previewWidth) {
String title = Util.createJpegName(dateTaken);
int orientation = Exif.getOrientation(data);
CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId]; // This is my change
// Fix the orientation
orientation = info.orientation; // This is also my change
Uri uri = Storage.addImage(mContentResolver, title, dateTaken,
loc, orientation, data, width, height);
This does work, however, I would prefer to not have to modify the system code. Instead, I would like to change some configuration file or something like that to make the orientation of the pictures correct.
So, basically, my question is, where does CameraInfo gets its information from? I have been trying to find something in the Android documentation or in the code, but I haven’t been able to see where it’s reading that value from. Is there a way I can find that?