summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/camera_controls.xml2
-rw-r--r--res/values/dimens.xml3
-rw-r--r--src/com/android/camera/PhotoModule.java1
-rw-r--r--src/com/android/camera/ui/CameraControls.java13
-rw-r--r--src/com/android/camera/ui/HistogramView.java94
5 files changed, 73 insertions, 40 deletions
diff --git a/res/layout/camera_controls.xml b/res/layout/camera_controls.xml
index 99a7133..b447dec 100644
--- a/res/layout/camera_controls.xml
+++ b/res/layout/camera_controls.xml
@@ -150,7 +150,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
- android:background="@color/camera_controls_bg_translucent"
+ android:background="@color/transparent"
android:visibility="gone" />
<TextView
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c6dde51..513c8c8 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -187,4 +187,7 @@
<dimen name="refocus_stroke_width">2dp</dimen>
<dimen name="bottom_bar_ripple_radius">30dp</dimen>
+
+ <dimen name="histogram_height">50dp</dimen>
+ <dimen name="histogram_width">120dp</dimen>
</resources>
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index ed7ad8d..6883a36 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -3683,6 +3683,7 @@ public class PhotoModule extends BaseModule<PhotoUI> implements
}
});
mCameraDevice.setHistogramMode(mHistogramEnabled ? mStatsCallback : null);
+ mParameters.set("histogram", histogram);
}
setFlipValue();
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 9102db3..9d023bb 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -145,6 +145,10 @@ public class CameraControls extends RotatableLayout {
}
}
+ if (mHistogramView.getVisibility() != View.GONE) {
+ mHistogramView.setVisibility(enable ? View.VISIBLE : View.INVISIBLE);
+ }
+
((ShutterButton) mShutter).enableTouch(enable);
mVideoShutter.setClickable(enable);
mTopBar.setEnabled(enable);
@@ -290,8 +294,11 @@ public class CameraControls extends RotatableLayout {
mAutoHdrNotice.layout(l, t + mTopMargin,
r, t + mTopMargin + mAutoHdrNotice.getMeasuredHeight());
- mHistogramView.layout(l, b - mBottomMargin - mHistogramView.getMeasuredHeight(),
- r, b - mBottomMargin);
+ int hw = getResources().getDimensionPixelSize(R.dimen.histogram_width);
+ int hh = getResources().getDimensionPixelSize(R.dimen.histogram_height);
+
+ mHistogramView.layout(r - hw, b - mBottomMargin - hh - 4,
+ r, b - mBottomMargin - 4);
View retake = findViewById(R.id.btn_retake);
if (retake != null) {
@@ -478,7 +485,7 @@ public class CameraControls extends RotatableLayout {
if (v instanceof RotateImageView) {
((RotateImageView) v).setOrientation(orientation, animation);
} else if (v instanceof HistogramView) {
- ((HistogramView) v).setRotation(-orientation);
+ ((HistogramView) v).setOrientation(orientation);
}
}
}
diff --git a/src/com/android/camera/ui/HistogramView.java b/src/com/android/camera/ui/HistogramView.java
index 2ae2c40..11a4bb4 100644
--- a/src/com/android/camera/ui/HistogramView.java
+++ b/src/com/android/camera/ui/HistogramView.java
@@ -22,31 +22,38 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.PorterDuff;
import android.util.AttributeSet;
+import android.util.MathUtils;
import android.view.View;
import com.android.camera.CameraManager;
+import org.codeaurora.snapcam.R;
+
public class HistogramView extends View {
+ private static final String TAG = "CAM_" + HistogramView.class.getSimpleName();
+
private static final int STATS_SIZE = 256;
+ private static final int CELL_COUNT = 64;
private int[] mData = new int[STATS_SIZE + 1];
private boolean mDataValid;
- private Bitmap mBitmap;
- private Paint mPaint = new Paint();
- private Paint mPaintRect = new Paint();
- private Canvas mCanvas = new Canvas();
- private float mWidth;
- private float mHeight;
+ private Bitmap mBitmap;
+ private Paint mPaint = new Paint();
+ private Paint mPaintRect = new Paint();
+ private Canvas mCanvas = new Canvas();
+ private float mWidth;
+ private float mHeight;
private CameraManager.CameraProxy mGraphCameraDevice;
public HistogramView(Context context, AttributeSet attrs) {
- super(context,attrs);
+ super(context, attrs);
mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
- mPaintRect.setColor(0xFFFFFFFF);
- mPaintRect.setStyle(Paint.Style.FILL);
+
+ setWillNotDraw(false);
}
public void setCamera(CameraManager.CameraProxy camera) {
@@ -67,7 +74,7 @@ public class HistogramView extends View {
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
+ mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_4444);
mCanvas.setBitmap(mBitmap);
mWidth = w;
mHeight = h;
@@ -87,43 +94,58 @@ public class HistogramView extends View {
}
}
- private void drawGraph() {
- final float border = 5;
- float graphheight = mHeight - (2 * border);
- float graphwidth = mWidth - (2 * border);
- float bargap = 0.0f;
- float barwidth = graphwidth/STATS_SIZE;
-
- mCanvas.drawColor(0xFFAAAAAA);
- mPaint.setColor(Color.BLACK);
-
- for (int k = 0; k <= (graphheight /32) ; k++) {
- float y = (float)(32 * k)+ border;
- mCanvas.drawLine(border, y, graphwidth + border , y, mPaint);
- }
- for (int j = 0; j <= (graphwidth /32); j++) {
- float x = (float)(32 * j)+ border;
- mCanvas.drawLine(x, border, x, graphheight + border, mPaint);
+ public void setOrientation(int orientation) {
+ setRotation(-orientation);
+ int top = getContext().getResources().getDimensionPixelSize(R.dimen.preview_top_margin);
+
+ if (orientation == 0 || orientation == 180) {
+ setTranslationX(0);
+ setTranslationY(0);
+ } else {
+ setTranslationX(mHeight / 2);
+ setTranslationY(-(top / 2));
}
+ }
+
+ private void drawGraph() {
+ float padding = 10;
+ float height = mHeight - (padding * 2);
+ float width = mWidth - (padding * 2);
+ int cellWidth = Math.round(width / CELL_COUNT);
+
+
+ mCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
+
+ mPaintRect.setColor(Color.WHITE);
//Assumption: The first element contains the maximum value.
int maxValue = Integer.MIN_VALUE;
if (mData[0] == 0) {
- for (int i = 1; i <= STATS_SIZE ; i++) {
+ for (int i = 1; i <= STATS_SIZE; i++) {
maxValue = Math.max(maxValue, mData[i]);
}
} else {
maxValue = mData[0];
}
- for (int i = 1; i <= STATS_SIZE; i++) {
- float scaled = Math.min(STATS_SIZE,
- (float) mData[i] * (float) STATS_SIZE / (float) maxValue);
- float left = (bargap * (i+1)) + (barwidth * i) + border;
- float top = graphheight + border;
- float right = left + barwidth;
- float bottom = top - scaled;
- mCanvas.drawRect(left, top, right, bottom, mPaintRect);
+ int[] values = new int[CELL_COUNT];
+ int cell = 0;
+ float sum = 0.0f;
+ for (int i = 1; i < STATS_SIZE; i++) {
+ sum += (float) mData[i] / (float) maxValue;
+ if ((i % cellWidth) == 0) {
+ float mean = sum / cellWidth;
+ int value = Math.round(MathUtils.lerp(0, height, mean));
+ values[cell] = value;
+
+ float left = padding + (cell * cellWidth);
+ float right = left + cellWidth - 2;
+ float bottom = mHeight - (padding / 2);
+ float top = bottom - value;
+ mCanvas.drawRect(left, top, right, bottom, mPaintRect);
+ sum = 0.0f;
+ cell++;
+ }
}
}
}