diff options
Diffstat (limited to 'src/com/android/camera/PhotoModule.java')
-rw-r--r-- | src/com/android/camera/PhotoModule.java | 121 |
1 files changed, 116 insertions, 5 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index a6f8fb239..7803bad04 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -112,7 +112,7 @@ public class PhotoModule private int mBurstSnapNum = 1; private int mReceivedSnapNum = 0; public boolean mFaceDetectionEnabled = false; - + private DrawAutoHDR mDrawAutoHDR; /*Histogram variables*/ private GraphView mGraphView; private static final int STATS_DATA = 257; @@ -158,6 +158,7 @@ public class PhotoModule private PhotoUI mUI; + public boolean mAutoHdrEnable; // The activity is going to switch to the specified camera id. This is // needed because texture copy is done in GL thread. -1 means camera is not // switching. @@ -278,7 +279,7 @@ public class PhotoModule private final CameraErrorCallback mErrorCallback = new CameraErrorCallback(); private final StatsCallback mStatsCallback = new StatsCallback(); - + private final MetaDataCallback mMetaDataCallback = new MetaDataCallback(); private long mFocusStartTime; private long mShutterCallbackTime; private long mPostViewPictureCallbackTime; @@ -712,11 +713,13 @@ public class PhotoModule } mNamedImages = new NamedImages(); - mGraphView = (GraphView)mRootView.findViewById(R.id.graph_view); - if(mGraphView == null){ - Log.e(TAG, "mGraphView is null"); + mGraphView = (GraphView)mRootView.findViewById(R.id.graph_view); + mDrawAutoHDR = (DrawAutoHDR )mRootView.findViewById(R.id.autohdr_view); + if (mGraphView == null || mDrawAutoHDR == null){ + Log.e(TAG, "mGraphView or mDrawAutoHDR is null"); } else{ mGraphView.setPhotoModuleObject(this); + mDrawAutoHDR.setPhotoModuleObject(this); } mFirstTimeInitialized = true; @@ -874,6 +877,47 @@ public class PhotoModule }); } } + + private final class MetaDataCallback + implements android.hardware.Camera.CameraMetaDataCallback{ + @Override + public void onCameraMetaData (byte[] data, android.hardware.Camera camera) { + int metadata[] = new int[3]; + if (data.length <= 12) { + for (int i =0;i<3;i++) { + metadata[i] = byteToInt( (byte []) data, i*4); + } + if (metadata[2] == 1) { + mAutoHdrEnable = true; + mActivity.runOnUiThread(new Runnable() { + public void run() { + if (mDrawAutoHDR != null) + mDrawAutoHDR.AutoHDR(); + } + }); + } + else { + mAutoHdrEnable = false; + mActivity.runOnUiThread(new Runnable() { + public void run() { + if (mDrawAutoHDR != null) + mDrawAutoHDR.AutoHDR(); + } + }); + } + } + } + + private int byteToInt (byte[] b, int offset) { + int value = 0; + for (int i = 0; i < 4; i++) { + int shift = (4 - 1 - i) * 8; + value += (b[(3-i) + offset] & 0x000000FF) << shift; + } + return value; + } + } + private final class PostViewPictureCallback implements CameraPictureCallback { @Override @@ -2528,6 +2572,32 @@ public class PhotoModule String zsl = mPreferences.getString(CameraSettings.KEY_ZSL, mActivity.getString(R.string.pref_camera_zsl_default)); + String auto_hdr = mPreferences.getString(CameraSettings.KEY_AUTO_HDR, + mActivity.getString(R.string.pref_camera_hdr_default)); + if (CameraUtil.isAutoHDRSupported(mParameters)) { + mParameters.setAutoHDRMode(auto_hdr); + if (auto_hdr.equals("enable")) { + mActivity.runOnUiThread(new Runnable() { + public void run() { + if (mDrawAutoHDR != null) { + mDrawAutoHDR.setVisibility(View.VISIBLE); + } + } + }); + mParameters.setSceneMode("asd"); + mCameraDevice.setMetadataCb(mMetaDataCallback); + } + else { + mAutoHdrEnable = false; + mActivity.runOnUiThread( new Runnable() { + public void run () { + if (mDrawAutoHDR != null) { + mDrawAutoHDR.setVisibility (View.INVISIBLE); + } + } + }); + } + } mParameters.setZSLMode(zsl); if(zsl.equals("on")) { //Switch on ZSL Camera mode @@ -3411,3 +3481,44 @@ class GraphView extends View { mPhotoModule = photoModule; } } + +class DrawAutoHDR extends View{ + + private static final String TAG = "AutoHdrView"; + private PhotoModule mPhotoModule; + + public DrawAutoHDR (Context context, AttributeSet attrs) { + super(context,attrs); + } + + @Override + protected void onDraw (Canvas canvas) { + if (mPhotoModule == null) + return; + if (mPhotoModule.mAutoHdrEnable) { + Paint AutoHDRPaint = new Paint(); + AutoHDRPaint.setColor(Color.WHITE); + AutoHDRPaint.setAlpha (0); + canvas.drawPaint(AutoHDRPaint); + AutoHDRPaint.setStyle(Paint.Style.STROKE); + AutoHDRPaint.setColor(Color.MAGENTA); + AutoHDRPaint.setStrokeWidth(1); + AutoHDRPaint.setTextSize(16); + AutoHDRPaint.setAlpha (255); + canvas.drawText("HDR On",200,100,AutoHDRPaint); + } + else { + super.onDraw(canvas); + return; + } + } + + public void AutoHDR () { + invalidate(); + } + + public void setPhotoModuleObject (PhotoModule photoModule) { + mPhotoModule = photoModule; + } + +} |