summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-02-07 18:58:33 -0800
committernicolasroard <nicolasroard@google.com>2013-02-07 18:58:33 -0800
commita3454ceb32741f7e2914958598b2372a05847805 (patch)
treea8c47695df070ba83dff2f77d173e1866d5fd38c /src/com/android/gallery3d/filtershow
parenta2413503eaddf5cb15ea55946b15026e1164be44 (diff)
downloadandroid_packages_apps_Snap-a3454ceb32741f7e2914958598b2372a05847805.tar.gz
android_packages_apps_Snap-a3454ceb32741f7e2914958598b2372a05847805.tar.bz2
android_packages_apps_Snap-a3454ceb32741f7e2914958598b2372a05847805.zip
Fix borders
Change-Id: Ia77660872f3baf10968e20b5656d97c4fbfc815e
Diffstat (limited to 'src/com/android/gallery3d/filtershow')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java100
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java4
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java88
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java7
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java27
5 files changed, 213 insertions, 13 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java
new file mode 100644
index 000000000..3ea678c44
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java
@@ -0,0 +1,100 @@
+/*
+ * 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.filters;
+
+public class FilterColorBorderRepresentation extends FilterRepresentation {
+ private int mColor;
+ private int mBorderSize;
+ private int mBorderRadius;
+
+ public FilterColorBorderRepresentation(int color, int size, int radius) {
+ super("ColorBorder");
+ mColor = color;
+ mBorderSize = size;
+ mBorderRadius = radius;
+ setFilterClass(ImageFilterParametricBorder.class);
+ setPriority(ImageFilter.TYPE_BORDER);
+ }
+
+ public String toString() {
+ return "FilterBorder: " + getName();
+ }
+
+ @Override
+ public FilterRepresentation clone() throws CloneNotSupportedException {
+ FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) super.clone();
+ representation.setName(getName());
+ representation.setColor(getColor());
+ representation.setBorderSize(getBorderSize());
+ representation.setBorderRadius(getBorderRadius());
+ return representation;
+ }
+
+ public void useParametersFrom(FilterRepresentation a) {
+ if (a instanceof FilterColorBorderRepresentation) {
+ FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) a;
+ setName(representation.getName());
+ setColor(representation.getColor());
+ setBorderSize(representation.getBorderSize());
+ setBorderRadius(representation.getBorderRadius());
+ }
+ }
+
+ @Override
+ public boolean equals(FilterRepresentation representation) {
+ if (!super.equals(representation)) {
+ return false;
+ }
+ if (representation instanceof FilterColorBorderRepresentation) {
+ FilterColorBorderRepresentation border = (FilterColorBorderRepresentation) representation;
+ if (border.mColor == mColor
+ && border.mBorderSize == mBorderSize
+ && border.mBorderRadius == mBorderRadius) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean allowsMultipleInstances() {
+ return true;
+ }
+
+ public int getColor() {
+ return mColor;
+ }
+
+ public void setColor(int color) {
+ mColor = color;
+ }
+
+ public int getBorderSize() {
+ return mBorderSize;
+ }
+
+ public void setBorderSize(int borderSize) {
+ mBorderSize = borderSize;
+ }
+
+ public int getBorderRadius() {
+ return mBorderRadius;
+ }
+
+ public void setBorderRadius(int borderRadius) {
+ mBorderRadius = borderRadius;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
index 54a227f6a..06987d2e6 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
@@ -72,6 +72,10 @@ public class FilterFxRepresentation extends FilterRepresentation {
return false;
}
+ public boolean allowsMultipleInstances() {
+ return false;
+ }
+
public Bitmap getFxBitmap() {
return mFxBitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java
new file mode 100644
index 000000000..467409fb8
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java
@@ -0,0 +1,88 @@
+/*
+ * 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.filters;
+
+import android.graphics.drawable.Drawable;
+
+public class FilterImageBorderRepresentation extends FilterRepresentation {
+ private Drawable mDrawable;
+ private int mDrawableResource = 0;
+
+ public FilterImageBorderRepresentation(int drawableResource, Drawable drawable) {
+ super("ImageBorder");
+ mDrawableResource = drawableResource;
+ mDrawable = drawable;
+ setFilterClass(ImageFilterBorder.class);
+ setPriority(ImageFilter.TYPE_BORDER);
+ }
+
+ public String toString() {
+ return "FilterBorder: " + getName();
+ }
+
+ @Override
+ public FilterRepresentation clone() throws CloneNotSupportedException {
+ FilterImageBorderRepresentation representation = (FilterImageBorderRepresentation) super.clone();
+ representation.setName(getName());
+ representation.setDrawable(getDrawable());
+ representation.setDrawableResource(getDrawableResource());
+ return representation;
+ }
+
+ public void useParametersFrom(FilterRepresentation a) {
+ if (a instanceof FilterImageBorderRepresentation) {
+ FilterImageBorderRepresentation representation = (FilterImageBorderRepresentation) a;
+ setName(representation.getName());
+ setDrawable(representation.getDrawable());
+ setDrawableResource(representation.getDrawableResource());
+ }
+ }
+
+ @Override
+ public boolean equals(FilterRepresentation representation) {
+ if (!super.equals(representation)) {
+ return false;
+ }
+ if (representation instanceof FilterImageBorderRepresentation) {
+ FilterImageBorderRepresentation border = (FilterImageBorderRepresentation) representation;
+ if (border.mDrawableResource == mDrawableResource) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean allowsMultipleInstances() {
+ return true;
+ }
+
+ public Drawable getDrawable() {
+ return mDrawable;
+ }
+
+ public void setDrawable(Drawable drawable) {
+ mDrawable = drawable;
+ }
+
+ public int getDrawableResource() {
+ return mDrawableResource;
+ }
+
+ public void setDrawableResource(int drawableResource) {
+ mDrawableResource = drawableResource;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index 1415f14ad..d92b323bb 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -46,6 +46,9 @@ public class FilterRepresentation implements Cloneable {
}
public boolean equals(FilterRepresentation representation) {
+ if (representation == null) {
+ return false;
+ }
if (representation.mFilterClass == representation.mFilterClass
&& representation.mName.equalsIgnoreCase(mName)
&& representation.mPriority == mPriority
@@ -94,6 +97,10 @@ public class FilterRepresentation implements Cloneable {
return mShowParameterValue;
}
+ public boolean allowsMultipleInstances() {
+ return false;
+ }
+
public Class getFilterClass() {
return mFilterClass;
}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index aba868829..fb58d1ff9 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -24,19 +24,16 @@ import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
-import com.android.gallery3d.filtershow.filters.ImageFilterCurves;
import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.imageshow.ImageShow;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import java.util.HashMap;
import java.util.Vector;
public class ImagePreset {
private static final String LOGTAG = "ImagePreset";
- private FilterRepresentation mImageBorder = null;
+ private FilterRepresentation mBorder = null;
private float mScaleFactor = 1.0f;
private boolean mIsHighQuality = false;
private ImageLoader mImageLoader = null;
@@ -70,8 +67,8 @@ public class ImagePreset {
public ImagePreset(ImagePreset source) {
try {
- if (source.mImageBorder != null) {
- mImageBorder = source.mImageBorder.clone();
+ if (source.mBorder != null) {
+ mBorder = source.mBorder.clone();
}
for (int i = 0; i < source.mFilters.size(); i++) {
FilterRepresentation representation = source.mFilters.elementAt(i).clone();
@@ -152,7 +149,7 @@ public class ImagePreset {
}
public boolean hasModifications() {
- if (mImageBorder != null && !mImageBorder.isNil()) {
+ if (mBorder != null && !mBorder.isNil()) {
return true;
}
if (mGeoData.hasModifications()) {
@@ -168,7 +165,7 @@ public class ImagePreset {
}
public boolean isPanoramaSafe() {
- if (mImageBorder != null && !mImageBorder.isNil()) {
+ if (mBorder != null && !mBorder.isNil()) {
return false;
}
if (mGeoData.hasModifications()) {
@@ -192,7 +189,7 @@ public class ImagePreset {
}
private void setBorder(FilterRepresentation filter) {
- mImageBorder = filter;
+ mBorder = filter;
}
public boolean isFx() {
@@ -257,11 +254,11 @@ public class ImagePreset {
return false;
}
- if (mDoApplyGeometry && mImageBorder != preset.mImageBorder) {
+ if (mDoApplyGeometry && mBorder != preset.mBorder) {
return false;
}
- if (mImageBorder != null && !mImageBorder.equals(preset.mImageBorder)) {
+ if (mBorder != null && !mBorder.equals(preset.mBorder)) {
return false;
}
@@ -364,6 +361,9 @@ public class ImagePreset {
return representation;
}
}
+ if (mBorder != null && mBorder.getFilterClass() == filterRepresentation.getFilterClass()) {
+ return mBorder;
+ }
return null;
}
@@ -384,8 +384,9 @@ public class ImagePreset {
}
public Bitmap applyBorder(Bitmap bitmap) {
- if (mImageBorder != null && mDoApplyGeometry) {
- ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(mImageBorder);
+ if (mBorder != null && mDoApplyGeometry) {
+ ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(mBorder);
+ filter.useRepresentation(mBorder);
bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality);
}
return bitmap;