You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// All supported formats/dimensions for this device.
@@ -167,13 +167,18 @@ struct SDL_Camera
167
167
structSDL_PrivateCameraData*hidden;
168
168
};
169
169
170
+
171
+
// Note that for AcquireFrame, `rotation` is degrees, with positive values rotating clockwise. This is the amount to rotate an image so it would be right-side up.
172
+
// Rotations should be in 90 degree increments at this time (landscape to portrait, or upside down to right side up, etc).
173
+
// Most platforms won't care about this, but mobile devices might need to deal with the device itself being physically rotated, causing the fixed-orientation camera to be presenting sideways images.
Copy file name to clipboardExpand all lines: src/camera/android/SDL_camera_android.c
+31-2Lines changed: 31 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -149,6 +149,7 @@ struct SDL_PrivateCameraData
149
149
ACaptureRequest*request;
150
150
ACameraCaptureSession*session;
151
151
SDL_CameraSpecrequested_spec;
152
+
introtation; // degrees to rotate clockwise to get from camera's static orientation to device's native orientation. Apply this plus current phone rotation to get upright image!
if (!UIDeviceOrientationIsValidInterfaceOrientation(device_orientation)) {
236
+
device_orientation = hidden.last_device_orientation; // possible the phone is laying flat or something went wrong, just stay with the last known-good orientation.
237
+
} else {
238
+
hidden.last_device_orientation = device_orientation; // update the last known-good orientation for later.
case UIInterfaceOrientationPortrait: hidden.last_device_orientation = UIDeviceOrientationPortrait; break;
421
+
case UIInterfaceOrientationPortraitUpsideDown: hidden.last_device_orientation = UIDeviceOrientationPortraitUpsideDown; break;
422
+
case UIInterfaceOrientationLandscapeLeft: hidden.last_device_orientation = UIDeviceOrientationLandscapeRight; break; // Apple docs say UI and device orientations are reversed in landscape.
423
+
case UIInterfaceOrientationLandscapeRight: hidden.last_device_orientation = UIDeviceOrientationLandscapeLeft; break;
0 commit comments