How to make it possible to save raw photos on Samsung Galaxy A3 2017?


Question

I have a rooted Galaxy A3 2017 (SM-A320F) running Android 8.0.0. I'm trying to capture raw photos, but neither the stock Camera app nor Open Camera show any relevant options (I have enabled Camera2 API). This option wasn't present before rooting too. On another phone, unrooted Galaxy Note8, the option is present at least in Open Camera.



So I suppose the option is somehow disabled in my A3. Can it be re-enabled without switching to a completely different firmware? How?



Note that another question proposed as a duplicate is 1) asking about very old version of Android — 4.2.2, which doesn't have Camera2 API, and 2) asks simply whether there exist any apps with such functionality, which today is of course yes. So this one is not a duplicate. This question is about how to re-enable the missing raw photo support instead.


Answer

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 ioctls 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.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes