Loading res/layout/filtershow_activity.xml +9 −0 Original line number Diff line number Diff line Loading @@ -192,6 +192,15 @@ android:orientation="horizontal" android:visibility="gone" > <com.android.gallery3d.filtershow.ui.ImageButtonTitle android:id="@+id/aspect" style="@style/FilterShowBottomButton" android:layout_gravity="left" android:layout_weight="0" android:visibility="gone" android:src="@drawable/filtershow_button_geometry_straighten" android:text="@string/aspectNone_effect" /> <ImageButton android:id="@+id/pickCurvesChannel" android:layout_width="64dip" Loading res/values/filtershow_strings.xml +14 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,20 @@ <string name="apply_effect">Apply</string> <!-- Label for the reset effect button [CHAR LIMIT=15] --> <string name="reset_effect">Reset</string> <!-- Label for the aspect 1:1 effect button [CHAR LIMIT=15] --> <string name="aspect">Aspect</string> <!-- Label for the aspect 1:1 effect button [CHAR LIMIT=15] --> <string name="aspect1to1_effect">1:1</string> <!-- Label for the aspect 4:7 effect button [CHAR LIMIT=15] --> <string name="aspect4to6_effect">4:6</string> <!-- Label for the aspect 1:1 effect button [CHAR LIMIT=15] --> <string name="aspect5to7_effect">5:7</string> <!-- Label for the aspect 1:1 effect button [CHAR LIMIT=15] --> <string name="aspect9to16_effect">16:9</string> <!-- Label for the aspect None effect button [CHAR LIMIT=15] --> <string name="aspectNone_effect">None</string> <!-- Label for the aspect None effect button [CHAR LIMIT=15] --> <string name="aspectOriginal_effect">Original</string> <!-- Filters buttons --> Loading src/com/android/gallery3d/filtershow/FilterShowActivity.java +24 −23 Original line number Diff line number Diff line Loading @@ -243,7 +243,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, new ImageFilterShadows() }; for (int i = 0; i < filters.length; i++) { ImageSmallFilter fView = new ImageSmallFilter(this); Loading Loading @@ -311,6 +310,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mPanelController.addView(findViewById(R.id.applyEffect)); mPanelController.addView(findViewById(R.id.pickCurvesChannel)); mPanelController.addView(findViewById(R.id.aspect)); findViewById(R.id.resetOperationsButton).setOnClickListener( createOnClickResetOperationsButton()); Loading @@ -330,7 +330,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mImageZoom.setSeekBar(seekBar); mPanelController.setRowPanel(findViewById(R.id.secondRowPanel)); mPanelController.setUtilityPanel(this, findViewById(R.id.filterButtonsList), findViewById(R.id.applyEffect)); findViewById(R.id.applyEffect), findViewById(R.id.aspect)); mPanelController.setMasterImage(mImageShow); mPanelController.setCurrentPanel(mFxButton); Intent intent = getIntent(); Loading Loading @@ -577,9 +577,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, Drawable npd2 = getResources().getDrawable(R.drawable.filtershow_border_brush); borders[p++] = new ImageFilterBorder(npd2); borders[p++] = new ImageFilterParametricBorder(Color.BLACK, mImageBorderSize, 0); borders[p++] = new ImageFilterParametricBorder(Color.BLACK, mImageBorderSize, mImageBorderSize); borders[p++] = new ImageFilterParametricBorder(Color.BLACK, mImageBorderSize, mImageBorderSize); borders[p++] = new ImageFilterParametricBorder(Color.WHITE, mImageBorderSize, 0); borders[p++] = new ImageFilterParametricBorder(Color.WHITE, mImageBorderSize, mImageBorderSize); borders[p++] = new ImageFilterParametricBorder(Color.WHITE, mImageBorderSize, mImageBorderSize); ImageSmallFilter previousFilter = null; for (int i = 0; i < p; i++) { Loading Loading @@ -637,7 +639,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, } } // ////////////////////////////////////////////////////////////////////////////// // imageState panel... Loading src/com/android/gallery3d/filtershow/PanelController.java +92 −5 Original line number Diff line number Diff line Loading @@ -20,9 +20,11 @@ import com.android.gallery3d.filtershow.filters.ImageFilterSharpen; import com.android.gallery3d.filtershow.filters.ImageFilterVibrance; import com.android.gallery3d.filtershow.filters.ImageFilterVignette; import com.android.gallery3d.filtershow.filters.ImageFilterWBalance; import com.android.gallery3d.filtershow.imageshow.ImageCrop; import com.android.gallery3d.filtershow.imageshow.ImageShow; import com.android.gallery3d.filtershow.presets.ImagePreset; import com.android.gallery3d.filtershow.ui.ImageCurves; import com.android.gallery3d.filtershow.ui.ImageButtonTitle; import java.util.HashMap; import java.util.Vector; Loading Loading @@ -113,17 +115,96 @@ public class PanelController implements OnClickListener { private String mEffectName = null; private int mParameterValue = 0; private boolean mShowParameterValue = false; public UtilityPanel(Context context, View view, View textView) { private View mAspectButton = null; private int mCurrentAspectButton = 0; private static final int NUMBER_OF_ASPECT_BUTTONS = 6; private static final int ASPECT_NONE = 0; private static final int ASPECT_1TO1 = 1; private static final int ASPECT_5TO7 = 2; private static final int ASPECT_4TO6 = 3; private static final int ASPECT_16TO9 = 4; private static final int ASPECT_ORIG = 5; public UtilityPanel(Context context, View view, View textView, View button) { mContext = context; mView = view; mTextView = (TextView) textView; mAspectButton = button; } public boolean selected() { return mSelected; } public void nextAspectButton() { if (mAspectButton instanceof ImageButtonTitle && mCurrentImage instanceof ImageCrop) { switch (mCurrentAspectButton) { case ASPECT_NONE: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect1to1_effect)); ((ImageCrop) mCurrentImage).apply(1, 1); break; case ASPECT_1TO1: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect5to7_effect)); ((ImageCrop) mCurrentImage).apply(7, 5); break; case ASPECT_5TO7: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect4to6_effect)); ((ImageCrop) mCurrentImage).apply(6, 4); break; case ASPECT_4TO6: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect9to16_effect)); ((ImageCrop) mCurrentImage).apply(16, 9); break; case ASPECT_16TO9: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspectOriginal_effect)); ((ImageCrop) mCurrentImage).applyOriginal(); break; case ASPECT_ORIG: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspectNone_effect)); ((ImageCrop) mCurrentImage).applyClear(); break; default: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect1to1_effect)); ((ImageCrop) mCurrentImage).applyClear(); break; } mCurrentAspectButton = (mCurrentAspectButton + 1) % NUMBER_OF_ASPECT_BUTTONS; } } public void showAspectButtons() { if (mAspectButton != null) mAspectButton.setVisibility(View.VISIBLE); mCurrentAspectButton = ASPECT_NONE; } public void hideAspectButtons() { if (mAspectButton != null) mAspectButton.setVisibility(View.GONE); } public void onNewValue(int value) { mParameterValue = value; updateText(); Loading Loading @@ -259,8 +340,9 @@ public class PanelController implements OnClickListener { mRowPanel = rowPanel; } public void setUtilityPanel(Context context, View utilityPanel, View textView) { mUtilityPanel = new UtilityPanel(context, utilityPanel, textView); public void setUtilityPanel(Context context, View utilityPanel, View textView, View button) { mUtilityPanel = new UtilityPanel(context, utilityPanel, textView, button); } public void setMasterImage(ImageShow imageShow) { Loading Loading @@ -402,7 +484,7 @@ public class PanelController implements OnClickListener { if (mCurrentImage != null) { mCurrentImage.unselect(); } mUtilityPanel.hideAspectButtons(); switch (view.getId()) { case R.id.straightenButton: { mCurrentImage = showImageView(R.id.imageStraighten); Loading @@ -415,6 +497,7 @@ public class PanelController implements OnClickListener { String ename = mCurrentImage.getContext().getString(R.string.crop); mUtilityPanel.setEffectName(ename); mUtilityPanel.setShowParameter(false); mUtilityPanel.showAspectButtons(); break; } case R.id.rotateButton: { Loading Loading @@ -510,6 +593,10 @@ public class PanelController implements OnClickListener { ensureFilter("Redeye"); break; } case R.id.aspect: { mUtilityPanel.nextAspectButton(); break; } case R.id.applyEffect: { showPanel(mCurrentPanel); break; Loading src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java 0 → 100644 +54 −0 Original line number Diff line number Diff line package com.android.gallery3d.filtershow.imageshow; public class GeometryMath { protected static float clamp(float i, float low, float high) { return Math.max(Math.min(i, high), low); } protected static float[] shortestVectorFromPointToLine(float[] point, float[] l1, float[] l2) { float x1 = l1[0]; float x2 = l2[0]; float y1 = l1[1]; float y2 = l2[1]; float xdelt = x2 - x1; float ydelt = y2 - y1; if (xdelt == 0 && ydelt == 0) return null; float u = ((point[0] - x1) * xdelt + (point[1] - y1) * ydelt) / (xdelt * xdelt + ydelt * ydelt); float[] ret = { (x1 + u * (x2 - x1)), (y1 + u * (y2 - y1)) }; return ret; } //A . B protected static float dotProduct(float[] a, float[] b){ return a[0] * b[0] + a[1] * b[1]; } protected static float[] normalize(float[] a){ float length = (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]); float[] b = { a[0] / length, a[1] / length }; return b; } //A onto B protected static float scalarProjection(float[] a, float[] b){ float length = (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]); return dotProduct(a, b) / length; } protected static float[] getVectorFromPoints(float [] point1, float [] point2){ float [] p = { point2[0] - point1[0], point2[1] - point1[1] }; return p; } protected static float[] getUnitVectorFromPoints(float [] point1, float [] point2){ float [] p = { point2[0] - point1[0], point2[1] - point1[1] }; float length = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1]); p[0] = p[0] / length; p[1] = p[1] / length; return p; } } Loading
res/layout/filtershow_activity.xml +9 −0 Original line number Diff line number Diff line Loading @@ -192,6 +192,15 @@ android:orientation="horizontal" android:visibility="gone" > <com.android.gallery3d.filtershow.ui.ImageButtonTitle android:id="@+id/aspect" style="@style/FilterShowBottomButton" android:layout_gravity="left" android:layout_weight="0" android:visibility="gone" android:src="@drawable/filtershow_button_geometry_straighten" android:text="@string/aspectNone_effect" /> <ImageButton android:id="@+id/pickCurvesChannel" android:layout_width="64dip" Loading
res/values/filtershow_strings.xml +14 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,20 @@ <string name="apply_effect">Apply</string> <!-- Label for the reset effect button [CHAR LIMIT=15] --> <string name="reset_effect">Reset</string> <!-- Label for the aspect 1:1 effect button [CHAR LIMIT=15] --> <string name="aspect">Aspect</string> <!-- Label for the aspect 1:1 effect button [CHAR LIMIT=15] --> <string name="aspect1to1_effect">1:1</string> <!-- Label for the aspect 4:7 effect button [CHAR LIMIT=15] --> <string name="aspect4to6_effect">4:6</string> <!-- Label for the aspect 1:1 effect button [CHAR LIMIT=15] --> <string name="aspect5to7_effect">5:7</string> <!-- Label for the aspect 1:1 effect button [CHAR LIMIT=15] --> <string name="aspect9to16_effect">16:9</string> <!-- Label for the aspect None effect button [CHAR LIMIT=15] --> <string name="aspectNone_effect">None</string> <!-- Label for the aspect None effect button [CHAR LIMIT=15] --> <string name="aspectOriginal_effect">Original</string> <!-- Filters buttons --> Loading
src/com/android/gallery3d/filtershow/FilterShowActivity.java +24 −23 Original line number Diff line number Diff line Loading @@ -243,7 +243,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, new ImageFilterShadows() }; for (int i = 0; i < filters.length; i++) { ImageSmallFilter fView = new ImageSmallFilter(this); Loading Loading @@ -311,6 +310,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mPanelController.addView(findViewById(R.id.applyEffect)); mPanelController.addView(findViewById(R.id.pickCurvesChannel)); mPanelController.addView(findViewById(R.id.aspect)); findViewById(R.id.resetOperationsButton).setOnClickListener( createOnClickResetOperationsButton()); Loading @@ -330,7 +330,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mImageZoom.setSeekBar(seekBar); mPanelController.setRowPanel(findViewById(R.id.secondRowPanel)); mPanelController.setUtilityPanel(this, findViewById(R.id.filterButtonsList), findViewById(R.id.applyEffect)); findViewById(R.id.applyEffect), findViewById(R.id.aspect)); mPanelController.setMasterImage(mImageShow); mPanelController.setCurrentPanel(mFxButton); Intent intent = getIntent(); Loading Loading @@ -577,9 +577,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, Drawable npd2 = getResources().getDrawable(R.drawable.filtershow_border_brush); borders[p++] = new ImageFilterBorder(npd2); borders[p++] = new ImageFilterParametricBorder(Color.BLACK, mImageBorderSize, 0); borders[p++] = new ImageFilterParametricBorder(Color.BLACK, mImageBorderSize, mImageBorderSize); borders[p++] = new ImageFilterParametricBorder(Color.BLACK, mImageBorderSize, mImageBorderSize); borders[p++] = new ImageFilterParametricBorder(Color.WHITE, mImageBorderSize, 0); borders[p++] = new ImageFilterParametricBorder(Color.WHITE, mImageBorderSize, mImageBorderSize); borders[p++] = new ImageFilterParametricBorder(Color.WHITE, mImageBorderSize, mImageBorderSize); ImageSmallFilter previousFilter = null; for (int i = 0; i < p; i++) { Loading Loading @@ -637,7 +639,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, } } // ////////////////////////////////////////////////////////////////////////////// // imageState panel... Loading
src/com/android/gallery3d/filtershow/PanelController.java +92 −5 Original line number Diff line number Diff line Loading @@ -20,9 +20,11 @@ import com.android.gallery3d.filtershow.filters.ImageFilterSharpen; import com.android.gallery3d.filtershow.filters.ImageFilterVibrance; import com.android.gallery3d.filtershow.filters.ImageFilterVignette; import com.android.gallery3d.filtershow.filters.ImageFilterWBalance; import com.android.gallery3d.filtershow.imageshow.ImageCrop; import com.android.gallery3d.filtershow.imageshow.ImageShow; import com.android.gallery3d.filtershow.presets.ImagePreset; import com.android.gallery3d.filtershow.ui.ImageCurves; import com.android.gallery3d.filtershow.ui.ImageButtonTitle; import java.util.HashMap; import java.util.Vector; Loading Loading @@ -113,17 +115,96 @@ public class PanelController implements OnClickListener { private String mEffectName = null; private int mParameterValue = 0; private boolean mShowParameterValue = false; public UtilityPanel(Context context, View view, View textView) { private View mAspectButton = null; private int mCurrentAspectButton = 0; private static final int NUMBER_OF_ASPECT_BUTTONS = 6; private static final int ASPECT_NONE = 0; private static final int ASPECT_1TO1 = 1; private static final int ASPECT_5TO7 = 2; private static final int ASPECT_4TO6 = 3; private static final int ASPECT_16TO9 = 4; private static final int ASPECT_ORIG = 5; public UtilityPanel(Context context, View view, View textView, View button) { mContext = context; mView = view; mTextView = (TextView) textView; mAspectButton = button; } public boolean selected() { return mSelected; } public void nextAspectButton() { if (mAspectButton instanceof ImageButtonTitle && mCurrentImage instanceof ImageCrop) { switch (mCurrentAspectButton) { case ASPECT_NONE: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect1to1_effect)); ((ImageCrop) mCurrentImage).apply(1, 1); break; case ASPECT_1TO1: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect5to7_effect)); ((ImageCrop) mCurrentImage).apply(7, 5); break; case ASPECT_5TO7: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect4to6_effect)); ((ImageCrop) mCurrentImage).apply(6, 4); break; case ASPECT_4TO6: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect9to16_effect)); ((ImageCrop) mCurrentImage).apply(16, 9); break; case ASPECT_16TO9: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspectOriginal_effect)); ((ImageCrop) mCurrentImage).applyOriginal(); break; case ASPECT_ORIG: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspectNone_effect)); ((ImageCrop) mCurrentImage).applyClear(); break; default: ((ImageButtonTitle) mAspectButton).setText(mContext .getString(R.string.aspect) + " " + mContext.getString(R.string.aspect1to1_effect)); ((ImageCrop) mCurrentImage).applyClear(); break; } mCurrentAspectButton = (mCurrentAspectButton + 1) % NUMBER_OF_ASPECT_BUTTONS; } } public void showAspectButtons() { if (mAspectButton != null) mAspectButton.setVisibility(View.VISIBLE); mCurrentAspectButton = ASPECT_NONE; } public void hideAspectButtons() { if (mAspectButton != null) mAspectButton.setVisibility(View.GONE); } public void onNewValue(int value) { mParameterValue = value; updateText(); Loading Loading @@ -259,8 +340,9 @@ public class PanelController implements OnClickListener { mRowPanel = rowPanel; } public void setUtilityPanel(Context context, View utilityPanel, View textView) { mUtilityPanel = new UtilityPanel(context, utilityPanel, textView); public void setUtilityPanel(Context context, View utilityPanel, View textView, View button) { mUtilityPanel = new UtilityPanel(context, utilityPanel, textView, button); } public void setMasterImage(ImageShow imageShow) { Loading Loading @@ -402,7 +484,7 @@ public class PanelController implements OnClickListener { if (mCurrentImage != null) { mCurrentImage.unselect(); } mUtilityPanel.hideAspectButtons(); switch (view.getId()) { case R.id.straightenButton: { mCurrentImage = showImageView(R.id.imageStraighten); Loading @@ -415,6 +497,7 @@ public class PanelController implements OnClickListener { String ename = mCurrentImage.getContext().getString(R.string.crop); mUtilityPanel.setEffectName(ename); mUtilityPanel.setShowParameter(false); mUtilityPanel.showAspectButtons(); break; } case R.id.rotateButton: { Loading Loading @@ -510,6 +593,10 @@ public class PanelController implements OnClickListener { ensureFilter("Redeye"); break; } case R.id.aspect: { mUtilityPanel.nextAspectButton(); break; } case R.id.applyEffect: { showPanel(mCurrentPanel); break; Loading
src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java 0 → 100644 +54 −0 Original line number Diff line number Diff line package com.android.gallery3d.filtershow.imageshow; public class GeometryMath { protected static float clamp(float i, float low, float high) { return Math.max(Math.min(i, high), low); } protected static float[] shortestVectorFromPointToLine(float[] point, float[] l1, float[] l2) { float x1 = l1[0]; float x2 = l2[0]; float y1 = l1[1]; float y2 = l2[1]; float xdelt = x2 - x1; float ydelt = y2 - y1; if (xdelt == 0 && ydelt == 0) return null; float u = ((point[0] - x1) * xdelt + (point[1] - y1) * ydelt) / (xdelt * xdelt + ydelt * ydelt); float[] ret = { (x1 + u * (x2 - x1)), (y1 + u * (y2 - y1)) }; return ret; } //A . B protected static float dotProduct(float[] a, float[] b){ return a[0] * b[0] + a[1] * b[1]; } protected static float[] normalize(float[] a){ float length = (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]); float[] b = { a[0] / length, a[1] / length }; return b; } //A onto B protected static float scalarProjection(float[] a, float[] b){ float length = (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]); return dotProduct(a, b) / length; } protected static float[] getVectorFromPoints(float [] point1, float [] point2){ float [] p = { point2[0] - point1[0], point2[1] - point1[1] }; return p; } protected static float[] getUnitVectorFromPoints(float [] point1, float [] point2){ float [] p = { point2[0] - point1[0], point2[1] - point1[1] }; float length = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1]); p[0] = p[0] / length; p[1] = p[1] / length; return p; } }