It appears to already be possible, with the stock firmware! I was about to try tracing an NDK-powered camera app (thanks to Sisik's tutorial with a demo) with strace
to see which API calls lead to which ioctl
s to aid further searches, when, while trimming down the demo, I noticed that the native camera API exposes AIMAGE_FORMAT_RAW16
with dimensions 4144×3106 on my Galaxy SM-A320F/DS. After I went ahead and tried capturing an image in this format, I indeed got a true 16-bit Bayer output, which after simplistic demosaicing and white-balancing resulted in a pretty decent raw image.
There's a small strangeness though: the bottom part of the image (pixels 2333 through 3106) is always filled with zeros. I'm not sure why this is so, but at least the upper 75% of the data are present and usable.
How to get RAW support in OpenCamera
Currently, OpenCamera detects whether a camera supports RAW by REQUEST_AVAILABLE_CAPABILITIES_RAW
. If there's no such capability, the detection simply gives negative result. For SM-A320F this is incorrect, because it doesn't report this capability, but RAW16 format is among the supported output formats.
To work around this misdetection, we can apply the following patch to OpenCamera 1.47.3, and build our own APK. This patch will stub out the check for the capability, making OpenCamera search for the format desired regardless.
diff --git a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java
index 2c6463c..939b00b 100644
--- a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java
+++ b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java
@@ -2062,7 +2062,7 @@ public class CameraController2 extends CameraController {
//camera_features.picture_sizes.get(0).supports_burst = false;
raw_size = null;
-
if( capabilities_raw ) {
+
if( true || capabilities_raw ) {
android.util.Size [] raw_camera_picture_sizes = configs.getOutputSizes(ImageFormat.RAW_SENSOR);
if( raw_camera_picture_sizes == null ) {
if( MyDebug.LOG )
I've reported this at OpenCamera's issue tracker as ticket 661.