android:layout_width="match_parent"
android:layout_height="wrap_content" />
- <com.android.gallery3d.filtershow.imageshow.ImageStraighten
- android:id="@+id/imageStraighten"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone" />
-
- <com.android.gallery3d.filtershow.imageshow.ImageCrop
- android:id="@+id/imageCrop"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone" />
-
- <com.android.gallery3d.filtershow.imageshow.ImageRotate
- android:id="@+id/imageRotate"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone" />
-
- <com.android.gallery3d.filtershow.imageshow.ImageFlip
- android:id="@+id/imageFlip"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone" />
-
<com.android.gallery3d.filtershow.imageshow.ImageTinyPlanet
android:id="@+id/imageTinyPlanet"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="left"
- android:orientation="horizontal">
-
- <com.android.gallery3d.filtershow.ui.IconButton
- android:id="@+id/straightenButton"
- android:layout_height="match_parent"
- style="@style/IconButton"
- android:drawableTop="@drawable/filtershow_button_geometry_straighten"
- android:text="@string/straighten" />
-
- <com.android.gallery3d.filtershow.ui.IconButton
- android:id="@+id/cropButton"
- android:layout_height="match_parent"
- style="@style/IconButton"
- android:drawableTop="@drawable/filtershow_button_geometry_crop"
- android:text="@string/crop" />
-
- <com.android.gallery3d.filtershow.ui.IconButton
- android:id="@+id/rotateButton"
- android:layout_height="match_parent"
- style="@style/IconButton"
- android:drawableTop="@drawable/filtershow_button_geometry_rotate"
- android:text="@string/rotate" />
-
- <com.android.gallery3d.filtershow.ui.IconButton
- android:id="@+id/flipButton"
- android:layout_height="match_parent"
- style="@style/IconButton"
- android:drawableTop="@drawable/filtershow_button_geometry_flip"
- android:text="@string/mirror" />
+ android:orientation="horizontal" />
- </LinearLayout>
</HorizontalScrollView>
<HorizontalScrollView
<item type="id" name="editorRedEye" />
<item type="id" name="imageOnlyEditor" />
<item type="id" name="vignetteEditor" />
+ <item type="id" name="editorCrop" />
+ <item type="id" name="editorFlip" />
+ <item type="id" name="editorRotate" />
+ <item type="id" name="editorStraighten" />
</resources>
public void setImageLoader(ImageLoader imageLoader) {
mImageLoader = imageLoader;
}
+
+ public Editor getEditor(int editorId) {
+ return mEditors.get(editorId);
+ }
}
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;
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;
});
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));
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);
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);
}
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);
}
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));
}
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;
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) {
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();
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;
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;
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;
}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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();
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+}
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) {
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;
representation.setEditorId(getEditorId());
representation.setButtonId(getButtonId());
representation.setOverlayId(getOverlayId());
+ representation.setOverlayOnly(getOverlayOnly());
representation.setShowEditingControls(showEditingControls());
representation.setShowParameterValue(showParameterValue());
representation.setShowUtilityPanel(showUtilityPanel());
&& representation.mEditorId == mEditorId
&& representation.mButtonId == mButtonId
&& representation.mOverlayId == mOverlayId
+ && representation.mOverlayOnly == mOverlayOnly
&& representation.mShowEditingControls == mShowEditingControls
&& representation.mShowParameterValue == mShowParameterValue
&& representation.mShowUtilityPanel == mShowUtilityPanel) {
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;
}
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);
@Override
public void useRepresentation(FilterRepresentation representation) {
-
+ mGeometry = (GeometryMetadata) representation;
}
@Override
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;
}
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);
}
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;
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;
+ }
}
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 {
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;
}
}
}
+ public void setEditor(EditorCrop editorCrop) {
+ mEditorCrop = editorCrop;
+ }
+
}
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 {
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);
drawTransformedCropped(canvas, image, gPaint);
}
+ public void setEditor(EditorFlip editorFlip) {
+ mEditorFlip = editorFlip;
+ }
+
}
}
// Overwrites local with master
- protected void syncLocalToMasterGeometry() {
+ public void syncLocalToMasterGeometry() {
mLocalGeometry = getGeometry();
calculateLocalScalingFactorAndOffset();
}
return;
}
mHasDrawn = true;
+
drawShape(canvas, image);
}
import android.util.AttributeSet;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorRotate;
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) {
gPaint.setARGB(255, 255, 255, 255);
drawTransformedCropped(canvas, image, gPaint);
}
+
+ public void setEditor(EditorRotate editorRotate) {
+ mEditorRotate = editorRotate;
+ }
}
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();
}
}
+ public void setEditor(EditorStraighten editorStraighten) {
+ mEditorStraighten = editorStraighten;
+ }
+
}
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;
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(),
}
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(),
}
public void notifyGeometryChange() {
+ updatePresets(true);
for (GeometryListener listener : mGeometryListeners) {
listener.geometryChanged();
}
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();
}
public synchronized void setGeometry(GeometryMetadata m) {
mGeoData.set(m);
+ MasterImage.getImage().notifyGeometryChange();
}
private void setBorder(FilterRepresentation filter) {
}
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);
}
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()) {
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) {
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
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;
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;
@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) {
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);
}
mOverlayBitmap = BitmapFactory.decodeResource(getResources(),
mFilterRepresentation.getOverlayId());
}
+ mOverlayOnly = mFilterRepresentation.getOverlayOnly();
+ if (mOverlayOnly) {
+ setIcon(mOverlayBitmap);
+ }
invalidate();
}
@Override
public void geometryChanged() {
stale_icon = true;
+
mIconBitmap = null;
mPreset = null;
invalidate();
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());
}
}