summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Roard <nicolasroard@google.com>2012-11-29 00:04:49 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-11-29 00:04:49 -0800
commit73487035ea64b59b62ee280cd73e8c1bfaf64f8f (patch)
treef04e057b8e446320734b8ce367e56426bcc5cc39
parent8d427b8a58fabb9164738b9ed0da2809ca3d60e0 (diff)
parent11d586fb5564be39ebb985d5371e867fcbd8b12f (diff)
downloadandroid_packages_apps_Snap-73487035ea64b59b62ee280cd73e8c1bfaf64f8f.tar.gz
android_packages_apps_Snap-73487035ea64b59b62ee280cd73e8c1bfaf64f8f.tar.bz2
android_packages_apps_Snap-73487035ea64b59b62ee280cd73e8c1bfaf64f8f.zip
Merge "Added dashed diagonal for crop." into gb-ub-photos-arches
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java1
-rw-r--r--src/com/android/gallery3d/filtershow/PanelController.java28
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java40
3 files changed, 62 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index ad26bfedf..c1e4f6add 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -203,6 +203,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mImageFlip = (ImageFlip) findViewById(R.id.imageFlip);
mImageTinyPlanet = (ImageTinyPlanet) findViewById(R.id.imageTinyPlanet);
+ mImageCrop.setAspectTextSize((int) getPixelsFromDip(18));
ImageCrop.setTouchTolerance((int) getPixelsFromDip(25));
mImageViews.add(mImageShow);
mImageViews.add(mImageCurves);
diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java
index 00af7e5a9..52bf98aa7 100644
--- a/src/com/android/gallery3d/filtershow/PanelController.java
+++ b/src/com/android/gallery3d/filtershow/PanelController.java
@@ -157,38 +157,52 @@ public class PanelController implements OnClickListener {
ImageCrop imageCrop = (ImageCrop) mCurrentImage;
switch (itemId) {
case R.id.crop_menu_1to1: {
- button.setText(mContext.getString(R.string.aspect1to1_effect));
+ String t = mContext.getString(R.string.aspect1to1_effect);
+ button.setText(t);
imageCrop.apply(1, 1);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_4to3: {
- button.setText(mContext.getString(R.string.aspect4to3_effect));
+ String t = mContext.getString(R.string.aspect4to3_effect);
+ button.setText(t);
imageCrop.apply(4, 3);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_3to4: {
- button.setText(mContext.getString(R.string.aspect3to4_effect));
+ String t = mContext.getString(R.string.aspect3to4_effect);
+ button.setText(t);
imageCrop.apply(3, 4);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_5to7: {
- button.setText(mContext.getString(R.string.aspect5to7_effect));
+ String t = mContext.getString(R.string.aspect5to7_effect);
+ button.setText(t);
imageCrop.apply(5, 7);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_7to5: {
- button.setText(mContext.getString(R.string.aspect7to5_effect));
+ String t = mContext.getString(R.string.aspect7to5_effect);
+ button.setText(t);
imageCrop.apply(7, 5);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_none: {
- button.setText(mContext.getString(R.string.aspectNone_effect));
+ String t = mContext.getString(R.string.aspectNone_effect);
+ button.setText(t);
imageCrop.applyClear();
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_original: {
- button.setText(mContext.getString(R.string.aspectOriginal_effect));
+ String t = mContext.getString(R.string.aspectOriginal_effect);
+ button.setText(t);
imageCrop.applyOriginal();
+ imageCrop.setAspectString(t);
break;
}
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
index a031fa58c..a352a16e7 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
@@ -62,6 +62,17 @@ public class ImageCrop extends ImageGeometry {
private static final String LOGTAG = "ImageCrop";
+ private String mAspect = "";
+ private int mAspectTextSize = 24;
+
+ public void setAspectTextSize(int textSize){
+ mAspectTextSize = textSize;
+ }
+
+ public void setAspectString(String a){
+ mAspect = a;
+ }
+
private static final Paint gPaint = new Paint();
public ImageCrop(Context context) {
@@ -642,6 +653,35 @@ public class ImageCrop extends ImageGeometry {
gPaint.setStyle(Paint.Style.STROKE);
drawRuleOfThird(canvas, crop, gPaint);
+ if (mFixAspectRatio){
+ float w = crop.width();
+ float h = crop.height();
+ float diag = (float) Math.sqrt(w*w + h*h);
+
+ float dash_len = 20;
+ int num_intervals = (int) (diag / dash_len);
+ float [] tl = { crop.left, crop.top };
+ float centX = tl[0] + w/2;
+ float centY = tl[1] + h/2 + 5;
+ float [] br = { crop.right, crop.bottom };
+ float [] vec = GeometryMath.getUnitVectorFromPoints(tl, br);
+
+ float [] counter = tl;
+ for (int x = 0; x < num_intervals; x++ ){
+ float tempX = counter[0] + vec[0] * dash_len;
+ float tempY = counter[1] + vec[1] * dash_len;
+ if ((x % 2) == 0 && Math.abs(x - num_intervals / 2) > 2){
+ canvas.drawLine(counter[0], counter[1], tempX, tempY, gPaint);
+ }
+ counter[0] = tempX;
+ counter[1] = tempY;
+ }
+
+ gPaint.setTextAlign(Paint.Align.CENTER);
+ gPaint.setTextSize(mAspectTextSize);
+ canvas.drawText(mAspect, centX, centY, gPaint);
+ }
+
gPaint.setColor(mBorderColor);
gPaint.setStrokeWidth(3);
gPaint.setStyle(Paint.Style.STROKE);