summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/gallery3d/filtershow/EditorPlaceHolder.java4
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java63
-rw-r--r--src/com/android/gallery3d/filtershow/PanelController.java36
-rw-r--r--src/com/android/gallery3d/filtershow/cache/ImageLoader.java12
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorCrop.java59
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorFlip.java57
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorInfo.java23
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorRotate.java57
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorStraighten.java57
-rw-r--r--src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java18
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java6
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java46
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java12
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageFlip.java6
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java3
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java6
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java6
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java8
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java28
-rw-r--r--src/com/android/gallery3d/filtershow/ui/FilterIconButton.java13
-rw-r--r--src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java4
22 files changed, 433 insertions, 93 deletions
diff --git a/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java b/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
index dee9d2e..4cba0e3 100644
--- a/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
+++ b/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
@@ -79,4 +79,8 @@ public class EditorPlaceHolder {
public void setImageLoader(ImageLoader imageLoader) {
mImageLoader = imageLoader;
}
+
+ public Editor getEditor(int editorId) {
+ return mEditors.get(editorId);
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 516a192..7401a1c 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -53,12 +53,18 @@ import com.android.gallery3d.data.LocalAlbum;
import com.android.gallery3d.filtershow.cache.FilteringPipeline;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.editors.BasicEditor;
+import com.android.gallery3d.filtershow.editors.EditorCrop;
import com.android.gallery3d.filtershow.editors.EditorDraw;
+import com.android.gallery3d.filtershow.editors.EditorFlip;
+import com.android.gallery3d.filtershow.editors.EditorInfo;
import com.android.gallery3d.filtershow.editors.EditorManager;
import com.android.gallery3d.filtershow.editors.EditorRedEye;
+import com.android.gallery3d.filtershow.editors.EditorRotate;
+import com.android.gallery3d.filtershow.editors.EditorStraighten;
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
import com.android.gallery3d.filtershow.filters.*;
+import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.ImageCrop;
import com.android.gallery3d.filtershow.imageshow.ImageFlip;
import com.android.gallery3d.filtershow.imageshow.ImageRotate;
@@ -96,10 +102,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
private final PanelController mPanelController = new PanelController();
private ImageLoader mImageLoader = null;
private ImageShow mImageShow = null;
- private ImageStraighten mImageStraighten = null;
- private ImageCrop mImageCrop = null;
- private ImageRotate mImageRotate = null;
- private ImageFlip mImageFlip = null;
private ImageTinyPlanet mImageTinyPlanet = null;
private View mSaveButton = null;
@@ -175,22 +177,13 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
});
mImageLoader = new ImageLoader(this, getApplicationContext());
-
mImageShow = (ImageShow) findViewById(R.id.imageShow);
- mImageStraighten = (ImageStraighten) findViewById(R.id.imageStraighten);
- mImageCrop = (ImageCrop) findViewById(R.id.imageCrop);
- mImageRotate = (ImageRotate) findViewById(R.id.imageRotate);
- mImageFlip = (ImageFlip) findViewById(R.id.imageFlip);
mImageTinyPlanet = (ImageTinyPlanet) findViewById(R.id.imageTinyPlanet);
- mImageCrop.setAspectTextSize((int) getPixelsFromDip(18));
+ ImageCrop.setAspectTextSize((int) getPixelsFromDip(18));
ImageCrop.setTouchTolerance((int) getPixelsFromDip(25));
ImageCrop.setMinCropSize((int) getPixelsFromDip(55));
mImageViews.add(mImageShow);
- mImageViews.add(mImageStraighten);
- mImageViews.add(mImageCrop);
- mImageViews.add(mImageRotate);
- mImageViews.add(mImageFlip);
mImageViews.add(mImageTinyPlanet);
mEditorPlaceHolder.setContainer((FrameLayout) findViewById(R.id.editorContainer));
@@ -199,6 +192,10 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mEditorPlaceHolder.addEditor(new ImageOnlyEditor());
mEditorPlaceHolder.addEditor(new EditorTinyPlanet());
mEditorPlaceHolder.addEditor(new EditorRedEye());
+ mEditorPlaceHolder.addEditor(new EditorCrop());
+ mEditorPlaceHolder.addEditor(new EditorFlip());
+ mEditorPlaceHolder.addEditor(new EditorRotate());
+ mEditorPlaceHolder.addEditor(new EditorStraighten());
EditorManager.addEditors(mEditorPlaceHolder);
mEditorPlaceHolder.setOldViews(mImageViews);
mEditorPlaceHolder.setImageLoader(mImageLoader);
@@ -211,30 +208,32 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mColorsButton = (ImageButton) findViewById(R.id.colorsButton);
mImageShow.setImageLoader(mImageLoader);
- mImageStraighten.setImageLoader(mImageLoader);
- mImageCrop.setImageLoader(mImageLoader);
- mImageRotate.setImageLoader(mImageLoader);
- mImageFlip.setImageLoader(mImageLoader);
mImageTinyPlanet.setImageLoader(mImageLoader);
mPanelController.setActivity(this);
mPanelController.setEditorPlaceHolder(mEditorPlaceHolder);
mPanelController.addImageView(findViewById(R.id.imageShow));
- mPanelController.addImageView(findViewById(R.id.imageStraighten));
- mPanelController.addImageView(findViewById(R.id.imageCrop));
- mPanelController.addImageView(findViewById(R.id.imageRotate));
- mPanelController.addImageView(findViewById(R.id.imageFlip));
mPanelController.addImageView(findViewById(R.id.imageTinyPlanet));
mPanelController.addPanel(mFxButton, findViewById(R.id.fxList), 0);
mPanelController.addPanel(mBorderButton, findViewById(R.id.bordersList), 1);
-
mPanelController.addPanel(mGeometryButton, findViewById(R.id.geometryList), 2);
- mPanelController.addComponent(mGeometryButton, findViewById(R.id.straightenButton));
- mPanelController.addComponent(mGeometryButton, findViewById(R.id.cropButton));
- mPanelController.addComponent(mGeometryButton, findViewById(R.id.rotateButton));
- mPanelController.addComponent(mGeometryButton, findViewById(R.id.flipButton));
+
+ // TODO: move to a separate function.
+ GeometryMetadata geo = new GeometryMetadata();
+ int[] editorsId = geo.getEditorIds();
+ for (int i = 0; i < editorsId.length; i++) {
+ int editorId = editorsId[i];
+ GeometryMetadata geometry = new GeometryMetadata(geo);
+ geometry.setEditorId(editorId);
+ EditorInfo editorInfo = (EditorInfo) mEditorPlaceHolder.getEditor(editorId);
+ geometry.setTextId(editorInfo.getTextId());
+ geometry.setOverlayId(editorInfo.getOverlayId());
+ geometry.setOverlayOnly(editorInfo.getOverlayOnly());
+ setupFilterRepresentationButton(
+ geometry, (LinearLayout) findViewById(R.id.listGeometry), mGeometryButton);
+ }
mPanelController.addPanel(mColorsButton, findViewById(R.id.colorsFxList), 3);
@@ -305,10 +304,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
}
mImageShow.getImagePreset().mGeoData.setCropExtras(mCropExtras);
- mImageCrop.setExtras(mCropExtras);
+ // FIXME: moving to editors breaks the crop action
+// mImageCrop.setExtras(mCropExtras);
String s = getString(R.string.Fixed);
- mImageCrop.setAspectString(s);
- mImageCrop.setCropActionFlag(true);
+// mImageCrop.setAspectString(s);
+// mImageCrop.setCropActionFlag(true);
mPanelController.setFixedAspect(mCropExtras.getAspectX() > 0
&& mCropExtras.getAspectY() > 0);
}
@@ -470,7 +470,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mLoadBitmapTask = null;
if (mAction == CROP_ACTION) {
- mPanelController.showComponent(findViewById(R.id.cropButton));
+ // FIXME: broken by the move to editors
+ // mPanelController.showComponent(findViewById(R.id.cropButton));
} else if (mAction == TINY_PLANET_ACTION) {
mPanelController.showComponent(findViewById(R.id.tinyplanetButton));
}
diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java
index 3c3de89..519733e 100644
--- a/src/com/android/gallery3d/filtershow/PanelController.java
+++ b/src/com/android/gallery3d/filtershow/PanelController.java
@@ -31,6 +31,7 @@ import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.filters.ImageFilterTinyPlanet;
import com.android.gallery3d.filtershow.imageshow.ImageCrop;
+import com.android.gallery3d.filtershow.imageshow.ImageGeometry;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.presets.ImagePreset;
@@ -155,7 +156,6 @@ public class PanelController implements OnClickListener {
private String mEffectName = null;
private int mParameterValue = 0;
private boolean mShowParameterValue = false;
- boolean firstTimeCropDisplayed = true;
public UtilityPanel(Context context, View view, View accessoryViewList,
View textView) {
@@ -532,44 +532,10 @@ public class PanelController implements OnClickListener {
mUtilityPanel.setEffectName(ename);
break;
}
- case R.id.straightenButton: {
- mCurrentImage = showImageView(R.id.imageStraighten);
- String ename = mCurrentImage.getContext().getString(R.string.straighten);
- mUtilityPanel.setEffectName(ename);
- break;
- }
- case R.id.cropButton: {
- mCurrentImage = showImageView(R.id.imageCrop);
- String ename = mCurrentImage.getContext().getString(R.string.crop);
- mUtilityPanel.setEffectName(ename);
- mUtilityPanel.setShowParameter(false);
- if (mCurrentImage instanceof ImageCrop && mUtilityPanel.firstTimeCropDisplayed) {
- ((ImageCrop) mCurrentImage).clear();
- mUtilityPanel.firstTimeCropDisplayed = false;
- ((ImageCrop) mCurrentImage).setFixedAspect(mFixedAspect);
- }
- break;
- }
- case R.id.rotateButton: {
- mCurrentImage = showImageView(R.id.imageRotate);
- String ename = mCurrentImage.getContext().getString(R.string.rotate);
- mUtilityPanel.setEffectName(ename);
- break;
- }
- case R.id.flipButton: {
- mCurrentImage = showImageView(R.id.imageFlip);
- String ename = mCurrentImage.getContext().getString(R.string.mirror);
- mUtilityPanel.setEffectName(ename);
- mUtilityPanel.setShowParameter(false);
- break;
- }
case R.id.applyEffect: {
if (MasterImage.getImage().getCurrentFilter() instanceof ImageFilterTinyPlanet) {
mActivity.saveImage();
} else {
- if (mCurrentImage instanceof ImageCrop) {
- ((ImageCrop) mCurrentImage).saveAndSetPreset();
- }
showPanel(mCurrentPanel);
}
MasterImage.getImage().invalidateFiltersOnly();
diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
index b5ed9ee..d284a03 100644
--- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
+++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
@@ -28,6 +28,7 @@ import android.graphics.BitmapRegionDecoder;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.Bitmap.CompressFormat;
+import android.graphics.RectF;
import android.media.ExifInterface;
import android.net.Uri;
import android.provider.MediaStore;
@@ -44,8 +45,10 @@ import com.android.gallery3d.exif.ExifTag;
import com.android.gallery3d.filtershow.CropExtras;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.HistoryAdapter;
+import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.ImageCrop;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.presets.ImagePreset;
import com.android.gallery3d.filtershow.tools.BitmapTask;
import com.android.gallery3d.filtershow.tools.SaveCopyTask;
@@ -131,6 +134,15 @@ public class ImageLoader {
return false;
}
updateBitmaps();
+ // TODO: cleanup
+ GeometryMetadata geo = MasterImage.getImage().getPreset().mGeoData;
+ float w = mOriginalBitmapLarge.getWidth();
+ float h = mOriginalBitmapLarge.getHeight();
+ RectF r = new RectF(0, 0, w, h);
+ geo.setPhotoBounds(r);
+ geo.setCropBounds(r);
+ MasterImage.getImage().getPreset().setGeometry(geo);
+ MasterImage.getImage().notifyGeometryChange();
mLoadingLock.unlock();
return true;
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorCrop.java b/src/com/android/gallery3d/filtershow/editors/EditorCrop.java
new file mode 100644
index 0000000..53e07ab
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorCrop.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.widget.FrameLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.imageshow.ImageCrop;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class EditorCrop extends Editor implements EditorInfo {
+ public static final int ID = R.id.editorCrop;
+ private static final String LOGTAG = "EditorCrop";
+
+ ImageCrop mImageCrop;
+
+ public EditorCrop() {
+ super(ID);
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ mView = mImageShow = mImageCrop = new ImageCrop(context);
+ mImageCrop.setImageLoader(MasterImage.getImage().getImageLoader());
+ mImageCrop.setEditor(this);
+ mImageCrop.syncLocalToMasterGeometry();
+ }
+
+ @Override
+ public int getTextId() {
+ return R.string.crop;
+ }
+
+ @Override
+ public int getOverlayId() {
+ return R.drawable.filtershow_button_geometry_crop;
+ }
+
+ @Override
+ public boolean getOverlayOnly() {
+ return true;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorFlip.java b/src/com/android/gallery3d/filtershow/editors/EditorFlip.java
new file mode 100644
index 0000000..bc04c11
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorFlip.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.widget.FrameLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.imageshow.ImageFlip;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class EditorFlip extends Editor implements EditorInfo {
+ public static final int ID = R.id.editorFlip;
+ ImageFlip mImageFlip;
+
+ public EditorFlip() {
+ super(ID);
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ mView = mImageShow = mImageFlip = new ImageFlip(context);
+ mImageFlip.setImageLoader(MasterImage.getImage().getImageLoader());
+ mImageFlip.setEditor(this);
+ mImageFlip.syncLocalToMasterGeometry();
+ }
+
+ @Override
+ public int getTextId() {
+ return R.string.mirror;
+ }
+
+ @Override
+ public int getOverlayId() {
+ return R.drawable.filtershow_button_geometry_flip;
+ }
+
+ @Override
+ public boolean getOverlayOnly() {
+ return true;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorInfo.java b/src/com/android/gallery3d/filtershow/editors/EditorInfo.java
new file mode 100644
index 0000000..75afe49
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorInfo.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+public interface EditorInfo {
+ public int getTextId();
+ public int getOverlayId();
+ public boolean getOverlayOnly();
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorRotate.java b/src/com/android/gallery3d/filtershow/editors/EditorRotate.java
new file mode 100644
index 0000000..1385ec8
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorRotate.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.widget.FrameLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.imageshow.ImageRotate;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class EditorRotate extends Editor implements EditorInfo {
+ public static final int ID = R.id.editorRotate;
+ ImageRotate mImageRotate;
+
+ public EditorRotate() {
+ super(ID);
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ mView = mImageShow = mImageRotate = new ImageRotate(context);
+ mImageRotate.setImageLoader(MasterImage.getImage().getImageLoader());
+ mImageRotate.setEditor(this);
+ mImageRotate.syncLocalToMasterGeometry();
+ }
+
+ @Override
+ public int getTextId() {
+ return R.string.rotate;
+ }
+
+ @Override
+ public int getOverlayId() {
+ return R.drawable.filtershow_button_geometry_rotate;
+ }
+
+ @Override
+ public boolean getOverlayOnly() {
+ return true;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
new file mode 100644
index 0000000..0925589
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.widget.FrameLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.imageshow.ImageStraighten;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class EditorStraighten extends Editor implements EditorInfo {
+ public static final int ID = R.id.editorStraighten;
+ ImageStraighten mImageStraighten;
+
+ public EditorStraighten() {
+ super(ID);
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ mView = mImageShow = mImageStraighten = new ImageStraighten(context);
+ mImageStraighten.setImageLoader(MasterImage.getImage().getImageLoader());
+ mImageStraighten.setEditor(this);
+ mImageStraighten.syncLocalToMasterGeometry();
+ }
+
+ @Override
+ public int getTextId() {
+ return R.string.straighten;
+ }
+
+ @Override
+ public int getOverlayId() {
+ return R.drawable.filtershow_button_geometry_straighten;
+ }
+
+ @Override
+ public boolean getOverlayOnly() {
+ return true;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
index 4dbf91a..820bdbf 100644
--- a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
+++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
@@ -44,6 +44,8 @@ public abstract class BaseFiltersManager {
filters.put(ImageFilterFx.class, new ImageFilterFx());
filters.put(ImageFilterBorder.class, new ImageFilterBorder());
filters.put(ImageFilterParametricBorder.class, new ImageFilterParametricBorder());
+ filters.put(ImageFilterGeometry.class, new ImageFilterGeometry());
+
}
public ImageFilter getFilter(Class c) {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index 83f2a1b..5dd72c9 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -30,6 +30,7 @@ public class FilterRepresentation implements Cloneable {
private int mEditorId = BasicEditor.ID;
private int mButtonId = 0;
private int mOverlayId = 0;
+ private boolean mOverlayOnly = false;
private boolean mShowEditingControls = true;
private boolean mShowParameterValue = true;
private boolean mShowUtilityPanel = true;
@@ -58,6 +59,7 @@ public class FilterRepresentation implements Cloneable {
representation.setEditorId(getEditorId());
representation.setButtonId(getButtonId());
representation.setOverlayId(getOverlayId());
+ representation.setOverlayOnly(getOverlayOnly());
representation.setShowEditingControls(showEditingControls());
representation.setShowParameterValue(showParameterValue());
representation.setShowUtilityPanel(showUtilityPanel());
@@ -77,6 +79,7 @@ public class FilterRepresentation implements Cloneable {
&& representation.mEditorId == mEditorId
&& representation.mButtonId == mButtonId
&& representation.mOverlayId == mOverlayId
+ && representation.mOverlayOnly == mOverlayOnly
&& representation.mShowEditingControls == mShowEditingControls
&& representation.mShowParameterValue == mShowParameterValue
&& representation.mShowUtilityPanel == mShowUtilityPanel) {
@@ -181,10 +184,23 @@ public class FilterRepresentation implements Cloneable {
mOverlayId = overlayId;
}
- public int getEditorId() {
+ public boolean getOverlayOnly() {
+ return mOverlayOnly;
+ }
+
+ public void setOverlayOnly(boolean value) {
+ mOverlayOnly = value;
+ }
+
+ final public int getEditorId() {
return mEditorId;
}
+ public int[] getEditorIds() {
+ return new int[] {
+ mEditorId };
+ }
+
public void setEditorId(int editorId) {
mEditorId = editorId;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
index 329ca81..cbb443f 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
@@ -50,10 +50,6 @@ public class ImageFilterGeometry extends ImageFilter {
return filter;
}
- public void setGeometryMetadata(GeometryMetadata m) {
- mGeometry = m;
- }
-
native protected void nativeApplyFilterFlip(Bitmap src, int srcWidth, int srcHeight,
Bitmap dst, int dstWidth, int dstHeight, int flip);
@@ -68,7 +64,7 @@ public class ImageFilterGeometry extends ImageFilter {
@Override
public void useRepresentation(FilterRepresentation representation) {
-
+ mGeometry = (GeometryMetadata) representation;
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
index a3645d6..647b101 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
@@ -23,10 +23,14 @@ import android.graphics.RectF;
import com.android.gallery3d.filtershow.CropExtras;
import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.editors.EditorCrop;
+import com.android.gallery3d.filtershow.editors.EditorFlip;
+import com.android.gallery3d.filtershow.editors.EditorRotate;
+import com.android.gallery3d.filtershow.editors.EditorStraighten;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilterGeometry;
-public class GeometryMetadata {
- private static final ImageFilterGeometry mImageFilter = new ImageFilterGeometry();
+public class GeometryMetadata extends FilterRepresentation {
private static final String LOGTAG = "GeometryMetadata";
private float mScaleFactor = 1.0f;
private float mRotation = 0;
@@ -59,9 +63,25 @@ public class GeometryMetadata {
}
public GeometryMetadata() {
+ super("GeometryMetadata");
+ setFilterClass(ImageFilterGeometry.class);
+ setEditorId(EditorCrop.ID);
+ setName("Crop");
+ setTextId(0);
+ }
+
+ @Override
+ public int[] getEditorIds() {
+ return new int[] {
+ EditorCrop.ID,
+ EditorStraighten.ID,
+ EditorRotate.ID,
+ EditorFlip.ID
+ };
}
public GeometryMetadata(GeometryMetadata g) {
+ super("GeometryMetadata");
set(g);
}
@@ -86,15 +106,6 @@ public class GeometryMetadata {
return false;
}
- public Bitmap apply(Bitmap original, float scaleFactor, int quality) {
- if (!hasModifications()) {
- return original;
- }
- mImageFilter.setGeometryMetadata(this);
- Bitmap m = mImageFilter.apply(original, scaleFactor, quality);
- return m;
- }
-
public void set(GeometryMetadata g) {
mScaleFactor = g.mScaleFactor;
mRotation = g.mRotation;
@@ -436,4 +447,17 @@ public class GeometryMetadata {
m.preRotate(-straighten, photo.centerX(), photo.centerY());
return m;
}
+
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ GeometryMetadata data = (GeometryMetadata) a;
+ set(data);
+ }
+
+ @Override
+ public FilterRepresentation clone() throws CloneNotSupportedException {
+ GeometryMetadata representation = (GeometryMetadata) super.clone();
+ representation.useParametersFrom(this);
+ return representation;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
index 284bfde..beaa93d 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
@@ -37,6 +37,8 @@ import android.widget.PopupMenu;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.CropExtras;
+import com.android.gallery3d.filtershow.editors.EditorCrop;
+import com.android.gallery3d.filtershow.filters.FilterCurvesRepresentation;
import com.android.gallery3d.filtershow.ui.FramedTextButton;
public class ImageCrop extends ImageGeometry {
@@ -81,11 +83,13 @@ public class ImageCrop extends ImageGeometry {
private static final String LOGTAG = "ImageCrop";
private String mAspect = "";
- private int mAspectTextSize = 24;
+ private static int mAspectTextSize = 24;
private boolean mFixedAspect = false;
- public void setAspectTextSize(int textSize) {
+ private EditorCrop mEditorCrop;
+
+ public static void setAspectTextSize(int textSize) {
mAspectTextSize = textSize;
}
@@ -779,4 +783,8 @@ public class ImageCrop extends ImageGeometry {
}
}
+ public void setEditor(EditorCrop editorCrop) {
+ mEditorCrop = editorCrop;
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageFlip.java b/src/com/android/gallery3d/filtershow/imageshow/ImageFlip.java
index 6bfba1b..70637a3 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageFlip.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageFlip.java
@@ -24,6 +24,7 @@ import android.graphics.RectF;
import android.util.AttributeSet;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorFlip;
import com.android.gallery3d.filtershow.imageshow.GeometryMetadata.FLIP;
public class ImageFlip extends ImageGeometry {
@@ -32,6 +33,7 @@ public class ImageFlip extends ImageGeometry {
private static final float MIN_FLICK_DIST_FOR_FLIP = 0.1f;
private static final String LOGTAG = "ImageFlip";
private FLIP mNextFlip = FLIP.NONE;
+ private EditorFlip mEditorFlip;
public ImageFlip(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -140,4 +142,8 @@ public class ImageFlip extends ImageGeometry {
drawTransformedCropped(canvas, image, gPaint);
}
+ public void setEditor(EditorFlip editorFlip) {
+ mEditorFlip = editorFlip;
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java b/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java
index e18f0d0..352329e 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java
@@ -138,7 +138,7 @@ public abstract class ImageGeometry extends ImageShow {
}
// Overwrites local with master
- protected void syncLocalToMasterGeometry() {
+ public void syncLocalToMasterGeometry() {
mLocalGeometry = getGeometry();
calculateLocalScalingFactorAndOffset();
}
@@ -423,6 +423,7 @@ public abstract class ImageGeometry extends ImageShow {
return;
}
mHasDrawn = true;
+
drawShape(canvas, image);
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java b/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
index 30cc9e2..c4b9aa2 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
@@ -23,6 +23,7 @@ import android.graphics.Paint;
import android.util.AttributeSet;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorRotate;
public class ImageRotate extends ImageGeometry {
@@ -30,6 +31,7 @@ public class ImageRotate extends ImageGeometry {
private float mAngle = 0;
private final boolean mSnapToNinety = true;
+ private EditorRotate mEditorRotate;
private static final String LOGTAG = "ImageRotate";
public ImageRotate(Context context, AttributeSet attrs) {
@@ -84,4 +86,8 @@ public class ImageRotate extends ImageGeometry {
gPaint.setARGB(255, 255, 255, 255);
drawTransformedCropped(canvas, image, gPaint);
}
+
+ public void setEditor(EditorRotate editorRotate) {
+ mEditorRotate = editorRotate;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java b/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
index dfd9505..be116bd 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
@@ -26,11 +26,13 @@ import android.graphics.RectF;
import android.util.AttributeSet;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorStraighten;
public class ImageStraighten extends ImageGeometry {
private float mBaseAngle = 0;
private float mAngle = 0;
+ private EditorStraighten mEditorStraighten;
private static final String LOGTAG = "ImageStraighten";
private static final Paint gPaint = new Paint();
@@ -134,4 +136,8 @@ public class ImageStraighten extends ImageGeometry {
}
}
+ public void setEditor(EditorStraighten editorStraighten) {
+ mEditorStraighten = editorStraighten;
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 9eafe22..4ca7430 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.filtershow.imageshow;
import android.graphics.*;
+import android.util.Log;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.HistoryAdapter;
@@ -208,7 +209,8 @@ public class MasterImage implements RenderingRequestCaller {
if (force || mGeometryOnlyPreset == null) {
ImagePreset newPreset = new ImagePreset(mPreset);
newPreset.setDoApplyFilters(false);
- if (mGeometryOnlyPreset == null
+ newPreset.setDoApplyGeometry(true);
+ if (force || mGeometryOnlyPreset == null
|| !newPreset.same(mGeometryOnlyPreset)) {
mGeometryOnlyPreset = newPreset;
RenderingRequest.post(mLoader.getOriginalBitmapLarge(),
@@ -217,8 +219,9 @@ public class MasterImage implements RenderingRequestCaller {
}
if (force || mFiltersOnlyPreset == null) {
ImagePreset newPreset = new ImagePreset(mPreset);
+ newPreset.setDoApplyFilters(true);
newPreset.setDoApplyGeometry(false);
- if (mFiltersOnlyPreset == null
+ if (force || mFiltersOnlyPreset == null
|| !newPreset.same(mFiltersOnlyPreset)) {
mFiltersOnlyPreset = newPreset;
RenderingRequest.post(mLoader.getOriginalBitmapLarge(),
@@ -330,6 +333,7 @@ public class MasterImage implements RenderingRequestCaller {
}
public void notifyGeometryChange() {
+ updatePresets(true);
for (GeometryListener listener : mGeometryListeners) {
listener.geometryChanged();
}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index 1400fd4..7ceed73 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -130,9 +130,13 @@ public class ImagePreset {
public void updateFilterRepresentation(FilterRepresentation representation) {
synchronized (mFilters) {
- int position = getPositionForRepresentation(representation);
- FilterRepresentation old = mFilters.elementAt(position);
- old.updateTempParametersFrom(representation);
+ if (representation instanceof GeometryMetadata) {
+ setGeometry((GeometryMetadata) representation);
+ } else {
+ int position = getPositionForRepresentation(representation);
+ FilterRepresentation old = mFilters.elementAt(position);
+ old.updateTempParametersFrom(representation);
+ }
}
MasterImage.getImage().invalidatePreview();
}
@@ -191,6 +195,7 @@ public class ImagePreset {
public synchronized void setGeometry(GeometryMetadata m) {
mGeoData.set(m);
+ MasterImage.getImage().notifyGeometryChange();
}
private void setBorder(FilterRepresentation filter) {
@@ -327,7 +332,10 @@ public class ImagePreset {
}
public void addFilter(FilterRepresentation representation) {
- Log.v(LOGTAG, "*** Add Filter *** " + representation);
+ if (representation instanceof GeometryMetadata) {
+ setGeometry((GeometryMetadata) representation);
+ return;
+ }
if (representation.getPriority() == FilterRepresentation.TYPE_BORDER) {
setHistoryName(representation.getName());
setBorder(representation);
@@ -359,6 +367,9 @@ public class ImagePreset {
}
public FilterRepresentation getRepresentation(FilterRepresentation filterRepresentation) {
+ if (filterRepresentation instanceof GeometryMetadata) {
+ return mGeoData;
+ }
for (int i = 0; i < mFilters.size(); i++) {
FilterRepresentation representation = mFilters.elementAt(i);
if (representation.getFilterClass() == filterRepresentation.getFilterClass()) {
@@ -384,7 +395,14 @@ public class ImagePreset {
public Bitmap applyGeometry(Bitmap bitmap) {
// Apply any transform -- 90 rotate, flip, straighten, crop
// Returns a new bitmap.
- return mGeoData.apply(bitmap, mScaleFactor, mQuality);
+ if (mDoApplyGeometry) {
+ ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(mGeoData);
+ mGeoData.synchronizeRepresentation();
+ filter.useRepresentation(mGeoData);
+ filter.setImagePreset(this);
+ bitmap = filter.apply(bitmap, mScaleFactor, mQuality);
+ }
+ return bitmap;
}
public Bitmap applyBorder(Bitmap bitmap) {
diff --git a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
index de2e1e5..746ad12 100644
--- a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
+++ b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
@@ -21,6 +21,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
@@ -30,6 +31,7 @@ import com.android.gallery3d.filtershow.cache.RenderingRequest;
import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.GeometryListener;
+import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.presets.ImagePreset;
@@ -37,6 +39,7 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
RenderingRequestCaller, GeometryListener {
private static final String LOGTAG = "FilterIconButton";
private Bitmap mOverlayBitmap = null;
+ private boolean mOverlayOnly = false;
private PanelController mController = null;
private FilterRepresentation mFilterRepresentation = null;
private LinearLayout mParentContainer = null;
@@ -68,6 +71,10 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
@Override
protected Bitmap drawImage(Bitmap dst, Bitmap image, Rect destination) {
+ if (mOverlayOnly) {
+ // TODO: merge back IconButton and FilterIconButton
+ return super.drawImage(dst, image, destination);
+ }
if (mIconBitmap == null && mPreset == null) {
ImageLoader loader = MasterImage.getImage().getLoader();
if (loader != null) {
@@ -76,6 +83,7 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
dst = super.drawImage(dst, image, destination);
ImagePreset mPreset = new ImagePreset();
mPreset.addFilter(mFilterRepresentation);
+ mPreset.setDoApplyGeometry(false);
mDestination = destination;
RenderingRequest.post(dst.copy(Bitmap.Config.ARGB_8888, true), mPreset, RenderingRequest.ICON_RENDERING, this);
}
@@ -112,6 +120,10 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
mOverlayBitmap = BitmapFactory.decodeResource(getResources(),
mFilterRepresentation.getOverlayId());
}
+ mOverlayOnly = mFilterRepresentation.getOverlayOnly();
+ if (mOverlayOnly) {
+ setIcon(mOverlayBitmap);
+ }
invalidate();
}
@@ -131,6 +143,7 @@ public class FilterIconButton extends IconButton implements View.OnClickListener
@Override
public void geometryChanged() {
stale_icon = true;
+
mIconBitmap = null;
mPreset = null;
invalidate();
diff --git a/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java b/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
index 92962cb..2a39b68 100644
--- a/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
@@ -29,6 +29,10 @@ public class EditorManager {
editorPlaceHolder.addEditor(new EditorTinyPlanet());
editorPlaceHolder.addEditor(new EditorDraw());
editorPlaceHolder.addEditor(new EditorVignette());
+ editorPlaceHolder.addEditor(new EditorFlip());
+ editorPlaceHolder.addEditor(new EditorRotate());
+ editorPlaceHolder.addEditor(new EditorStraighten());
+ editorPlaceHolder.addEditor(new EditorCrop());
}
}