diff options
author | John Hoford <hoford@google.com> | 2013-08-02 00:49:20 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-02 00:49:20 +0000 |
commit | a1168a948830022c599a6164d92ce537794a1247 (patch) | |
tree | 8a7fcc5714420127e5b7aec76cf29675393980a9 | |
parent | 8bd17465ed2058eee581fdf8e6c401796692161c (diff) | |
parent | 2f1ff6df511486b307ea8facbea8656015c93c20 (diff) | |
download | android_packages_apps_Snap-a1168a948830022c599a6164d92ce537794a1247.tar.gz android_packages_apps_Snap-a1168a948830022c599a6164d92ce537794a1247.tar.bz2 android_packages_apps_Snap-a1168a948830022c599a6164d92ce537794a1247.zip |
Merge "add Per Channel Saturation" into gb-ub-photos-carlsbad
6 files changed, 270 insertions, 3 deletions
diff --git a/res/menu/filtershow_menu_chan_sat.xml b/res/menu/filtershow_menu_chan_sat.xml new file mode 100644 index 000000000..eae559d41 --- /dev/null +++ b/res/menu/filtershow_menu_chan_sat.xml @@ -0,0 +1,43 @@ +<!-- + 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. +--> + +<menu xmlns:android="http://schemas.android.com/apk/res/android" > + + <group android:id="@+id/grunge_popupmenu" > + <item + android:id="@+id/editor_chan_sat_main" + android:title="@string/editor_chan_sat_main"/> + <item + android:id="@+id/editor_chan_sat_red" + android:title="@string/editor_chan_sat_red"/> + <item + android:id="@+id/editor_chan_sat_yellow" + android:title="@string/editor_chan_sat_yellow"/> + <item + android:id="@+id/editor_chan_sat_green" + android:title="@string/editor_chan_sat_green"/> + <item + android:id="@+id/editor_chan_sat_cyan" + android:title="@string/editor_chan_sat_cyan"/> + <item + android:id="@+id/editor_chan_sat_blue" + android:title="@string/editor_chan_sat_blue"/> + <item + android:id="@+id/editor_chan_sat_magenta" + android:title="@string/editor_chan_sat_magenta"/> + </group> + +</menu>
\ No newline at end of file diff --git a/res/values/filtershow_ids.xml b/res/values/filtershow_ids.xml index e57a0d559..b315d12d9 100644 --- a/res/values/filtershow_ids.xml +++ b/res/values/filtershow_ids.xml @@ -48,4 +48,5 @@ <item type="id" name="editorStraighten" /> <item type="id" name="editorParametric" /> <item type="id" name="editorGrad" /> + <item type="id" name="editorChanSat" /> </resources> diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml index a820871c6..68eca34f3 100644 --- a/res/values/filtershow_strings.xml +++ b/res/values/filtershow_strings.xml @@ -168,7 +168,20 @@ <string name="editor_grad_contrast">Contrast</string> <!-- Label for the saturation effect [CHAR LIMIT=20] --> <string name="editor_grad_saturation">Saturation</string> - + <!-- Label for the Main or Master control for per channel saturation effect [CHAR LIMIT=20] --> + <string name="editor_chan_sat_main">Main</string> + <!-- Label for the red control for per channel saturation effect [CHAR LIMIT=20] --> + <string name="editor_chan_sat_red">Red</string> + <!-- Label for the yellow control for per channel saturation effect [CHAR LIMIT=20] --> + <string name="editor_chan_sat_yellow">Yellow</string> + <!-- Label for the green control for per channel saturation effect [CHAR LIMIT=20] --> + <string name="editor_chan_sat_green">Green</string> + <!-- Label for the cyan control for per channel saturation effect [CHAR LIMIT=20] --> + <string name="editor_chan_sat_cyan">Cyan</string> + <!-- Label for the blue control for per channel saturation effect [CHAR LIMIT=20] --> + <string name="editor_chan_sat_blue">Blue</string> + <!-- Label for the Magenta control for per channel saturation effect [CHAR LIMIT=20] --> + <string name="editor_chan_sat_magenta">Magenta</string> <!-- Label for the image graduated filter effect [CHAR LIMIT=20] --> <string name="editor_grad_style">Style</string> <!-- Label for the image new grad layer [CHAR LIMIT=20] --> diff --git a/src/com/android/gallery3d/filtershow/filters/FilterChanSatRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterChanSatRepresentation.java new file mode 100644 index 000000000..7ce67dd96 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/filters/FilterChanSatRepresentation.java @@ -0,0 +1,211 @@ +/* + * 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.util.JsonReader; +import android.util.JsonWriter; + +import com.android.gallery3d.R; +import com.android.gallery3d.filtershow.controller.BasicParameterInt; +import com.android.gallery3d.filtershow.controller.Parameter; +import com.android.gallery3d.filtershow.controller.ParameterSet; +import com.android.gallery3d.filtershow.editors.EditorChanSat; +import com.android.gallery3d.filtershow.imageshow.ControlPoint; +import com.android.gallery3d.filtershow.imageshow.Spline; + +import java.io.IOException; +import java.util.Vector; + +/** + * Representation for a filter that has per channel & Master saturation + */ +public class FilterChanSatRepresentation extends FilterRepresentation implements ParameterSet { + private static final String LOGTAG = "FilterChanSatRepresentation"; + private static final String ARGS = "ARGS"; + private static final String SERIALIZATION_NAME = "channelsaturation"; + + public static final int MODE_MASTER = 0; + public static final int MODE_RED = 1; + public static final int MODE_YELLOW = 2; + public static final int MODE_GREEN = 3; + public static final int MODE_CYAN = 4; + public static final int MODE_BLUE = 5; + public static final int MODE_MAGENTA = 6; + private int mParameterMode = MODE_MASTER; + + private static int MINSAT = -100; + private static int MAXSAT = 100; + private BasicParameterInt mParamMaster = new BasicParameterInt(MODE_MASTER, 0, MINSAT, MAXSAT); + private BasicParameterInt mParamRed = new BasicParameterInt(MODE_RED, 0, MINSAT, MAXSAT); + private BasicParameterInt mParamYellow = new BasicParameterInt(MODE_YELLOW, 0, MINSAT, MAXSAT); + private BasicParameterInt mParamGreen = new BasicParameterInt(MODE_GREEN, 0, MINSAT, MAXSAT); + private BasicParameterInt mParamCyan = new BasicParameterInt(MODE_CYAN, 0, MINSAT, MAXSAT); + private BasicParameterInt mParamBlue = new BasicParameterInt(MODE_BLUE, 0, MINSAT, MAXSAT); + private BasicParameterInt mParamMagenta = new BasicParameterInt(MODE_MAGENTA, 0, MINSAT, MAXSAT); + + private BasicParameterInt[] mAllParam = { + mParamMaster, + mParamRed, + mParamYellow, + mParamGreen, + mParamCyan, + mParamBlue, + mParamMagenta}; + + public FilterChanSatRepresentation() { + super("ChannelSaturation"); + setTextId(R.string.saturation); + setFilterType(FilterRepresentation.TYPE_NORMAL); + setSerializationName(SERIALIZATION_NAME); + setFilterClass(ImageFilterChanSat.class); + setEditorId(EditorChanSat.ID); + } + + public String toString() { + return getName() + " : " + mParamRed + ", " + mParamCyan + ", " + mParamRed + + ", " + mParamGreen + ", " + mParamMaster + ", " + mParamYellow; + } + + @Override + public FilterRepresentation copy() { + FilterChanSatRepresentation representation = new FilterChanSatRepresentation(); + copyAllParameters(representation); + return representation; + } + + @Override + protected void copyAllParameters(FilterRepresentation representation) { + super.copyAllParameters(representation); + representation.useParametersFrom(this); + } + + public void useParametersFrom(FilterRepresentation a) { + if (a instanceof FilterChanSatRepresentation) { + FilterChanSatRepresentation representation = (FilterChanSatRepresentation) a; + + for (int i = 0; i < mAllParam.length; i++) { + mAllParam[i].copyFrom(representation.mAllParam[i]); + } + } + } + + @Override + public boolean equals(FilterRepresentation representation) { + if (!super.equals(representation)) { + return false; + } + if (representation instanceof FilterChanSatRepresentation) { + FilterChanSatRepresentation rep = (FilterChanSatRepresentation) representation; + for (int i = 0; i < mAllParam.length; i++) { + if (rep.getValue(i) != getValue(i)) + return false; + } + return true; + } + return false; + } + + public int getValue(int mode) { + return mAllParam[mode].getValue(); + } + + public void setValue(int mode, int value) { + mAllParam[mode].setValue(value); + } + + public int getMinimum() { + return mParamMaster.getMinimum(); + } + + public int getMaximum() { + return mParamMaster.getMaximum(); + } + + public int getParameterMode() { + return mParameterMode; + } + + public void setParameterMode(int parameterMode) { + mParameterMode = parameterMode; + } + + public int getCurrentParameter() { + return getValue(mParameterMode); + } + + public void setCurrentParameter(int value) { + setValue(mParameterMode, value); + } + + @Override + public int getNumberOfParameters() { + return 6; + } + + @Override + public Parameter getFilterParameter(int index) { + return mAllParam[index]; + } + + @Override + public void serializeRepresentation(JsonWriter writer) throws IOException { + writer.beginObject(); + + writer.name(ARGS); + writer.beginArray(); + writer.value(getValue(MODE_MASTER)); + writer.value(getValue(MODE_RED)); + writer.value(getValue(MODE_YELLOW)); + writer.value(getValue(MODE_GREEN)); + writer.value(getValue(MODE_CYAN)); + writer.value(getValue(MODE_BLUE)); + writer.value(getValue(MODE_MAGENTA)); + writer.endArray(); + writer.endObject(); + } + + @Override + public void deSerializeRepresentation(JsonReader sreader) throws IOException { + sreader.beginObject(); + + while (sreader.hasNext()) { + String name = sreader.nextName(); + if (name.startsWith(ARGS)) { + sreader.beginArray(); + sreader.hasNext(); + setValue(MODE_MASTER, sreader.nextInt()); + sreader.hasNext(); + setValue(MODE_RED, sreader.nextInt()); + sreader.hasNext(); + setValue(MODE_YELLOW, sreader.nextInt()); + sreader.hasNext(); + setValue(MODE_GREEN, sreader.nextInt()); + sreader.hasNext(); + setValue(MODE_CYAN, sreader.nextInt()); + sreader.hasNext(); + setValue(MODE_BLUE, sreader.nextInt()); + sreader.hasNext(); + setValue(MODE_MAGENTA, sreader.nextInt()); + sreader.hasNext(); + sreader.endArray(); + } else { + sreader.skipValue(); + } + } + sreader.endObject(); + } +}
\ No newline at end of file diff --git a/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java index 64e7fb0c9..0c272d48a 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java @@ -419,7 +419,6 @@ public class FilterGradRepresentation extends FilterRepresentation public float getPoint1Y() { return mCurrentBand.yPos1; } - @Override public float getPoint2X() { return mCurrentBand.xPos2; diff --git a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java index 64643e455..d34216ad6 100644 --- a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java +++ b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java @@ -613,7 +613,7 @@ public class ImagePreset { writer.endObject(); } catch (IOException e) { - e.printStackTrace(); + Log.e(LOGTAG,"Error encoding JASON",e); } } |