diff options
48 files changed, 1080 insertions, 0 deletions
diff --git a/res/drawable/filtershow_background.png b/res/drawable/filtershow_background.png Binary files differnew file mode 100644 index 000000000..e7646c33a --- /dev/null +++ b/res/drawable/filtershow_background.png diff --git a/res/drawable/filtershow_border_black.9.png b/res/drawable/filtershow_border_black.9.png Binary files differnew file mode 100755 index 000000000..24bb5e11d --- /dev/null +++ b/res/drawable/filtershow_border_black.9.png diff --git a/res/drawable/filtershow_border_film.png b/res/drawable/filtershow_border_film.png Binary files differnew file mode 100755 index 000000000..9fbd637c1 --- /dev/null +++ b/res/drawable/filtershow_border_film.png diff --git a/res/drawable/filtershow_border_film2.9.png b/res/drawable/filtershow_border_film2.9.png Binary files differnew file mode 100644 index 000000000..bef5e1061 --- /dev/null +++ b/res/drawable/filtershow_border_film2.9.png diff --git a/res/drawable/filtershow_border_film3.9.png b/res/drawable/filtershow_border_film3.9.png Binary files differnew file mode 100644 index 000000000..8ce70cb94 --- /dev/null +++ b/res/drawable/filtershow_border_film3.9.png diff --git a/res/drawable/filtershow_border_rounded_black.9.png b/res/drawable/filtershow_border_rounded_black.9.png Binary files differnew file mode 100755 index 000000000..590a34393 --- /dev/null +++ b/res/drawable/filtershow_border_rounded_black.9.png diff --git a/res/drawable/filtershow_border_rounded_white.9.png b/res/drawable/filtershow_border_rounded_white.9.png Binary files differnew file mode 100755 index 000000000..4ddc97a19 --- /dev/null +++ b/res/drawable/filtershow_border_rounded_white.9.png diff --git a/res/drawable/filtershow_border_scratch3.9.png b/res/drawable/filtershow_border_scratch3.9.png Binary files differnew file mode 100644 index 000000000..7552785cd --- /dev/null +++ b/res/drawable/filtershow_border_scratch3.9.png diff --git a/res/drawable/filtershow_border_white.9.png b/res/drawable/filtershow_border_white.9.png Binary files differnew file mode 100755 index 000000000..d8c88267e --- /dev/null +++ b/res/drawable/filtershow_border_white.9.png diff --git a/res/drawable/filtershow_button_background.xml b/res/drawable/filtershow_button_background.xml new file mode 100644 index 000000000..ee8a92dd9 --- /dev/null +++ b/res/drawable/filtershow_button_background.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <item android:drawable="@android:color/holo_blue_light" android:state_pressed="true"/> + <item android:drawable="@drawable/filtershow_button_selected_background" android:state_selected="true"/> + <item android:drawable="@android:color/transparent" android:state_selected="false"/> + +</selector>
\ No newline at end of file diff --git a/res/drawable/filtershow_button_border.png b/res/drawable/filtershow_button_border.png Binary files differnew file mode 100644 index 000000000..69195a902 --- /dev/null +++ b/res/drawable/filtershow_button_border.png diff --git a/res/drawable/filtershow_button_colors.png b/res/drawable/filtershow_button_colors.png Binary files differnew file mode 100644 index 000000000..566773dbe --- /dev/null +++ b/res/drawable/filtershow_button_colors.png diff --git a/res/drawable/filtershow_button_colors_contrast.png b/res/drawable/filtershow_button_colors_contrast.png Binary files differnew file mode 100644 index 000000000..ccb2dc630 --- /dev/null +++ b/res/drawable/filtershow_button_colors_contrast.png diff --git a/res/drawable/filtershow_button_colors_curve.png b/res/drawable/filtershow_button_colors_curve.png Binary files differnew file mode 100644 index 000000000..7046bd8dd --- /dev/null +++ b/res/drawable/filtershow_button_colors_curve.png diff --git a/res/drawable/filtershow_button_colors_sharpen.png b/res/drawable/filtershow_button_colors_sharpen.png Binary files differnew file mode 100644 index 000000000..2bd0fff6d --- /dev/null +++ b/res/drawable/filtershow_button_colors_sharpen.png diff --git a/res/drawable/filtershow_button_colors_vignette.png b/res/drawable/filtershow_button_colors_vignette.png Binary files differnew file mode 100644 index 000000000..ac3d53fa9 --- /dev/null +++ b/res/drawable/filtershow_button_colors_vignette.png diff --git a/res/drawable/filtershow_button_current.png b/res/drawable/filtershow_button_current.png Binary files differnew file mode 100644 index 000000000..8c4b379b5 --- /dev/null +++ b/res/drawable/filtershow_button_current.png diff --git a/res/drawable/filtershow_button_fx.png b/res/drawable/filtershow_button_fx.png Binary files differnew file mode 100644 index 000000000..c887fe4d1 --- /dev/null +++ b/res/drawable/filtershow_button_fx.png diff --git a/res/drawable/filtershow_button_geometry.png b/res/drawable/filtershow_button_geometry.png Binary files differnew file mode 100644 index 000000000..4b8f3b881 --- /dev/null +++ b/res/drawable/filtershow_button_geometry.png diff --git a/res/drawable/filtershow_button_geometry_crop.png b/res/drawable/filtershow_button_geometry_crop.png Binary files differnew file mode 100644 index 000000000..eb7da1b21 --- /dev/null +++ b/res/drawable/filtershow_button_geometry_crop.png diff --git a/res/drawable/filtershow_button_geometry_flip.png b/res/drawable/filtershow_button_geometry_flip.png Binary files differnew file mode 100644 index 000000000..dd74813a7 --- /dev/null +++ b/res/drawable/filtershow_button_geometry_flip.png diff --git a/res/drawable/filtershow_button_geometry_rotate.png b/res/drawable/filtershow_button_geometry_rotate.png Binary files differnew file mode 100644 index 000000000..fa50ce26f --- /dev/null +++ b/res/drawable/filtershow_button_geometry_rotate.png diff --git a/res/drawable/filtershow_button_geometry_straighten.png b/res/drawable/filtershow_button_geometry_straighten.png Binary files differnew file mode 100644 index 000000000..309eb5ae2 --- /dev/null +++ b/res/drawable/filtershow_button_geometry_straighten.png diff --git a/res/drawable/filtershow_button_operations.png b/res/drawable/filtershow_button_operations.png Binary files differnew file mode 100644 index 000000000..79e9a446b --- /dev/null +++ b/res/drawable/filtershow_button_operations.png diff --git a/res/drawable/filtershow_button_origin.png b/res/drawable/filtershow_button_origin.png Binary files differnew file mode 100644 index 000000000..0cd0bc28b --- /dev/null +++ b/res/drawable/filtershow_button_origin.png diff --git a/res/drawable/filtershow_button_redo.png b/res/drawable/filtershow_button_redo.png Binary files differnew file mode 100644 index 000000000..9daa01c34 --- /dev/null +++ b/res/drawable/filtershow_button_redo.png diff --git a/res/drawable/filtershow_button_selected_background.9.png b/res/drawable/filtershow_button_selected_background.9.png Binary files differnew file mode 100644 index 000000000..bb412454c --- /dev/null +++ b/res/drawable/filtershow_button_selected_background.9.png diff --git a/res/drawable/filtershow_button_settings.png b/res/drawable/filtershow_button_settings.png Binary files differnew file mode 100644 index 000000000..df3925aca --- /dev/null +++ b/res/drawable/filtershow_button_settings.png diff --git a/res/drawable/filtershow_button_show_original.png b/res/drawable/filtershow_button_show_original.png Binary files differnew file mode 100644 index 000000000..925954beb --- /dev/null +++ b/res/drawable/filtershow_button_show_original.png diff --git a/res/drawable/filtershow_button_undo.png b/res/drawable/filtershow_button_undo.png Binary files differnew file mode 100644 index 000000000..0a7e0d1b8 --- /dev/null +++ b/res/drawable/filtershow_button_undo.png diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml new file mode 100644 index 000000000..1521585ad --- /dev/null +++ b/res/layout/filtershow_activity.xml @@ -0,0 +1,323 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 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. +--> + +<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <LinearLayout + android:id="@+id/historyPanel" + android:layout_width="200dip" + android:layout_height="match_parent" + android:orientation="vertical" + android:visibility="invisible" > + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@android:color/transparent" + android:gravity="center" + android:padding="2dip" + android:text="@string/history" + android:textColor="@android:color/white" + android:textSize="24sp" + android:textStyle="bold" /> + + <ListView + android:id="@+id/operationsList" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" > + </ListView> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" > + + <Button + android:id="@+id/resetOperationsButton" + style="@style/FilterShowHistoryButton" + android:text="@string/reset" /> + + <Button + android:id="@+id/saveOperationsButton" + style="@style/FilterShowHistoryButton" + android:text="@string/save" /> + </LinearLayout> + </LinearLayout> + + <LinearLayout + android:id="@+id/mainPanel" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layerType="hardware" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="48dip" > + + <Button + android:id="@+id/saveButton" + style="@style/FilterShowTopButton" + android:layout_weight="1" + android:gravity="center_vertical|left" + android:text="@string/done" /> + + <ImageButton + android:id="@+id/showOriginalButton" + style="@style/FilterShowTopButton" + android:src="@drawable/filtershow_button_show_original" /> + + <ImageButton + android:id="@+id/undoButton" + style="@style/FilterShowTopButton" + android:src="@drawable/filtershow_button_undo" /> + + <ImageButton + android:id="@+id/redoButton" + style="@style/FilterShowTopButton" + android:src="@drawable/filtershow_button_redo" /> + + <ImageButton + android:id="@+id/operationsButton" + style="@style/FilterShowTopButton" + android:src="@drawable/filtershow_button_operations" /> + + </LinearLayout> + + <com.android.gallery3d.filtershow.imageshow.ImageShow + android:id="@+id/imageShow" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" /> + + <com.android.gallery3d.filtershow.imageshow.ImageStraighten + android:id="@+id/imageStraighten" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:visibility="gone" /> + + <com.android.gallery3d.filtershow.ui.ImageCurves + android:id="@+id/imageCurves" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:visibility="gone" /> + + <com.android.gallery3d.filtershow.imageshow.ImageBorder + android:id="@+id/imageBorder" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:visibility="gone" /> + + <HorizontalScrollView + android:id="@+id/fxList" + android:layout_width="match_parent" + android:layout_height="96dip" > + + <LinearLayout + android:id="@+id/listFilters" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="horizontal" > + </LinearLayout> + </HorizontalScrollView> + + <HorizontalScrollView + android:id="@+id/bordersList" + android:layout_width="match_parent" + android:layout_height="96dip" + android:visibility="gone" > + + <LinearLayout + android:id="@+id/listBorders" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="horizontal" > + </LinearLayout> + </HorizontalScrollView> + + <HorizontalScrollView + android:id="@+id/gemoetryList" + android:layout_width="fill_parent" + android:layout_height="96dip" + android:background="@color/background_toolbar" + android:visibility="gone" > + + <LinearLayout + android:id="@+id/listGeometry" + android:layout_width="wrap_content" + android:layout_height="fill_parent" + android:orientation="horizontal" > + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/straightenButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_geometry_straighten" + android:text="@string/straighten" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/cropButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_geometry_crop" + android:text="@string/crop" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/rotateButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_geometry_rotate" + android:text="@string/rotate" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/flipButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_geometry_flip" + android:text="@string/flip" /> + </LinearLayout> + </HorizontalScrollView> + + <HorizontalScrollView + android:id="@+id/colorsFxList" + android:layout_width="fill_parent" + android:layout_height="96dip" + android:background="@color/background_toolbar" + android:visibility="gone" > + + <LinearLayout + android:id="@+id/listColorsFx" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" > + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/vignetteButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_vignette" + android:text="@string/vignette" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/curvesButtonRGB" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_curve" + android:text="@string/curvesRGB" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/curvesButtonRed" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_curve" + android:text="@string/curvesRed" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/curvesButtonGreen" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_curve" + android:text="@string/curvesGreen" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/curvesButtonBlue" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_curve" + android:text="@string/curvesBlue" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/sharpenButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_sharpen" + android:text="@string/sharpen" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/vibranceButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_contrast" + android:text="@string/vibrance" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/contrastButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_contrast" + android:text="@string/contrast" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/saturationButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_contrast" + android:text="@string/saturation" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/exposureButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_contrast" + android:text="@string/exposure" /> + + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/shadowRecoveryButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_contrast" + android:text="@string/shadow_recovery" /> + </LinearLayout> + </HorizontalScrollView> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="48dip" + android:background="@color/background_main_toolbar" > + + <ImageButton + android:id="@+id/fxButton" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@drawable/filtershow_button_background" + android:scaleType="centerInside" + android:src="@drawable/filtershow_button_fx" /> + + <ImageButton + android:id="@+id/borderButton" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@drawable/filtershow_button_background" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/filtershow_button_border" /> + + <ImageButton + android:id="@+id/geometryButton" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@drawable/filtershow_button_background" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/filtershow_button_geometry" /> + + <ImageButton + android:id="@+id/colorsButton" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@drawable/filtershow_button_background" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/filtershow_button_colors" /> + </LinearLayout> + </LinearLayout> + +</AbsoluteLayout> diff --git a/res/layout/filtershow_history_operation_row.xml b/res/layout/filtershow_history_operation_row.xml new file mode 100644 index 000000000..6f9ea1b8f --- /dev/null +++ b/res/layout/filtershow_history_operation_row.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 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. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:background="@drawable/filtershow_button_background"> + + <ImageView + android:id="@+id/selectedMark" + android:src="@drawable/filtershow_button_current" + android:background="@android:color/transparent" + android:layout_width="32dip" + android:layout_height="match_parent" + android:scaleType="centerInside" + android:visibility="invisible" + > + </ImageView> + + <TextView + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/rowTextView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:padding="10dip" + android:textSize="16dip" > + </TextView> + + <ImageView + android:id="@+id/typeMark" + android:src="@drawable/filtershow_button_origin" + android:background="@android:color/transparent" + android:layout_width="32dip" + android:layout_height="match_parent" + android:scaleType="centerInside" + android:paddingRight="4dip" + android:visibility="visible" + > + </ImageView> + +</LinearLayout>
\ No newline at end of file diff --git a/res/menu/filtershow_activity_menu.xml b/res/menu/filtershow_activity_menu.xml new file mode 100644 index 000000000..44a11e7db --- /dev/null +++ b/res/menu/filtershow_activity_menu.xml @@ -0,0 +1,5 @@ +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:id="@+id/menu_settings" + android:title="@string/menu_settings" + android:orderInCategory="100" /> +</menu> diff --git a/res/menu/filtershow_menu_curves.xml b/res/menu/filtershow_menu_curves.xml new file mode 100644 index 000000000..fe190213a --- /dev/null +++ b/res/menu/filtershow_menu_curves.xml @@ -0,0 +1,18 @@ +<menu xmlns:android="http://schemas.android.com/apk/res/android" > + + <group android:id="@+id/group_popupmenu" > + <item + android:id="@+id/menu1" + android:title="@string/curves_channel_rgb"/> + <item + android:id="@+id/menu2" + android:title="@string/curves_channel_red"/> + <item + android:id="@+id/menu3" + android:title="@string/curves_channel_green"/> + <item + android:id="@+id/menu4" + android:title="@string/curves_channel_blue"/> + </group> + +</menu>
\ No newline at end of file diff --git a/res/values/filtershow_color.xml b/res/values/filtershow_color.xml new file mode 100644 index 000000000..2d097edaf --- /dev/null +++ b/res/values/filtershow_color.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 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. +--> +<resources> + <color name="yellow">#FFFF00</color> + <color name="green">#00FF00</color> + <color name="red">#FF0000</color> + <color name="blue">#0000FF</color> + <color name="text_toolbar">#FFFFFF</color> + <color name="background_toolbar">#363949</color> + <color name="background_main_toolbar">#1e2028</color> +</resources>
\ No newline at end of file diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml new file mode 100644 index 000000000..3a0a3afba --- /dev/null +++ b/res/values/filtershow_strings.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 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. +--> + +<resources> + + <string name="app_name">FilterShow</string> + <string name="menu_settings">Settings</string> + <string name="title_activity_filter_show">FilterShowActivity</string> + <string name="save">Save</string> + <string name="done">Done</string> + <string name="history">History</string> + <string name="reset">Reset</string> + <string name="undo">Undo</string> + <string name="redo">Redo</string> + <string name="straighten">Straighten</string> + <string name="crop">Crop</string> + <string name="rotate">Rotate</string> + <string name="flip">Flip</string> + <string name="vignette">Vignette</string> + <string name="curvesRGB">Curves (RGB)</string> + <string name="curvesRed">Curves (Red)</string> + <string name="curvesGreen">Curves (Green)</string> + <string name="curvesBlue">Curves (Blue)</string> + <string name="sharpen">Sharpen</string> + <string name="contrast">Contrast</string> + <string name="vibrance">Vibrance</string> + <string name="exposure">Exposure</string> + <string name="saturation">Saturation</string> + <string name="shadow_recovery">Shadow Recovery</string> + <string name="curves_channel">Channel</string> + <string name="curves_channel_rgb">RGB</string> + <string name="curves_channel_red">Red</string> + <string name="curves_channel_green">Green</string> + <string name="curves_channel_blue">Blue</string> + +</resources>
\ No newline at end of file diff --git a/res/values/filtershow_styles.xml b/res/values/filtershow_styles.xml new file mode 100644 index 000000000..14d0d9446 --- /dev/null +++ b/res/values/filtershow_styles.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2012 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. +--> +<resources> + + <style name="FilterShowHistoryButton"> + <item name="android:layout_width">wrap_content</item> + <item name="android:layout_height">48dip</item> + <item name="android:layout_weight">1</item> + <item name="android:background">@drawable/filtershow_button_background</item> + <item name="android:gravity">center</item> + <item name="android:padding">2dip</item> + <item name="android:textColor">@android:color/white</item> + <item name="android:textSize">18dip</item> + <item name="android:textStyle">bold</item> + </style> + + <style name="FilterShowTopButton"> + <item name="android:layout_width">wrap_content</item> + <item name="android:layout_height">match_parent</item> + <item name="android:background">@drawable/filtershow_button_background</item> + <item name="android:gravity">center</item> + <item name="android:padding">8dip</item> + <item name="android:textColor">@android:color/white</item> + <item name="android:textSize">18dip</item> + <item name="android:textStyle">bold</item> + <item name="android:scaleType">centerInside</item> + </style> + + <style name="FilterShowBottomButton"> + <item name="android:layout_width">wrap_content</item> + <item name="android:layout_height">wrap_content</item> + <item name="android:background">@drawable/filtershow_button_background</item> + <item name="android:gravity">center</item> + <item name="android:paddingBottom">16dip</item> + <item name="android:textColor">@android:color/white</item> + <item name="android:textSize">18dip</item> + <item name="android:textStyle">bold</item> + <item name="android:scaleType">centerInside</item> + </style> + +</resources>
\ No newline at end of file diff --git a/res/values/filtershow_values_attrs.xml b/res/values/filtershow_values_attrs.xml new file mode 100644 index 000000000..67c645dd8 --- /dev/null +++ b/res/values/filtershow_values_attrs.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 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. +--> + +<resources> + <declare-styleable name="ImageButtonTitle"> + <attr name="android:text"/> + <attr name="android:textColor"/> + </declare-styleable> +</resources>
\ No newline at end of file diff --git a/src/com/android/gallery3d/filtershow/cache/DelayedPresetCache.java b/src/com/android/gallery3d/filtershow/cache/DelayedPresetCache.java new file mode 100644 index 000000000..8acb539b6 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/cache/DelayedPresetCache.java @@ -0,0 +1,59 @@ + +package com.android.gallery3d.filtershow.cache; + +import android.os.Handler; +import android.os.Handler.Callback; +import android.os.HandlerThread; +import android.os.Message; +import android.os.Process; + +public class DelayedPresetCache extends DirectPresetCache implements Callback { + private HandlerThread mHandlerThread = null; + + private final static int NEW_PRESET = 0; + private final static int COMPUTE_PRESET = 1; + + private Handler mProcessingHandler = null; + private Handler mUIHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case NEW_PRESET: { + CachedPreset cache = (CachedPreset) msg.obj; + didCompute(cache); + break; + } + } + } + }; + + @Override + public boolean handleMessage(Message msg) { + switch (msg.what) { + case COMPUTE_PRESET: { + CachedPreset cache = (CachedPreset) msg.obj; + compute(cache); + Message uimsg = mUIHandler.obtainMessage(NEW_PRESET, cache); + mUIHandler.sendMessage(uimsg); + break; + } + } + return false; + } + + public DelayedPresetCache(int size) { + super(size); + mHandlerThread = new HandlerThread("ImageProcessing", Process.THREAD_PRIORITY_BACKGROUND); + mHandlerThread.start(); + mProcessingHandler = new Handler(mHandlerThread.getLooper(), this); + } + + protected void willCompute(CachedPreset cache) { + if (cache == null) { + return; + } + cache.setBusy(true); + Message msg = mProcessingHandler.obtainMessage(COMPUTE_PRESET, cache); + mProcessingHandler.sendMessage(msg); + } +} diff --git a/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java b/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java new file mode 100644 index 000000000..1ba835673 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java @@ -0,0 +1,144 @@ + +package com.android.gallery3d.filtershow.cache; + +import java.util.Vector; + +import android.graphics.Bitmap; +import android.util.Log; + +import com.android.gallery3d.filtershow.imageshow.ImageShow; +import com.android.gallery3d.filtershow.presets.ImagePreset; + +public class DirectPresetCache implements Cache { + + private static final String LOGTAG = "DirectPresetCache"; + private Bitmap mOriginalBitmap = null; + private Vector<ImageShow> mObservers = new Vector<ImageShow>(); + private Vector<CachedPreset> mCache = new Vector<CachedPreset>(); + private int mCacheSize = 1; + private Bitmap.Config mBitmapConfig = Bitmap.Config.ARGB_8888; + private long mGlobalAge = 0; + + protected class CachedPreset { + private Bitmap mBitmap = null; + private ImagePreset mPreset = null; + private long mAge = 0; + private boolean mBusy = false; + + public void setBusy(boolean value) { + mBusy = value; + } + + public boolean busy() { + return mBusy; + } + } + + public DirectPresetCache(int size) { + mCacheSize = size; + } + + public void setOriginalBitmap(Bitmap bitmap) { + mOriginalBitmap = bitmap; + notifyObservers(); + } + + public void notifyObservers() { + for (int i = 0; i < mObservers.size(); i++) { + ImageShow imageShow = mObservers.elementAt(i); + imageShow.invalidate(); + } + } + + public void addObserver(ImageShow observer) { + if (!mObservers.contains(observer)) { + mObservers.add(observer); + } + } + + private CachedPreset getCachedPreset(ImagePreset preset) { + for (int i = 0; i < mCache.size(); i++) { + CachedPreset cache = mCache.elementAt(i); + if (cache.mPreset == preset && !cache.mBusy) { + return cache; + } + } + return null; + } + + public Bitmap get(ImagePreset preset) { + // Log.v(LOGTAG, "get preset " + preset.name() + " : " + preset); + CachedPreset cache = getCachedPreset(preset); + if (cache != null) { + return cache.mBitmap; + } + // Log.v(LOGTAG, "didn't find preset " + preset.name() + " : " + preset + // + " we have " + mCache.size() + " elts / " + mCacheSize); + return null; + } + + public void reset(ImagePreset preset) { + CachedPreset cache = getCachedPreset(preset); + if (cache != null && !cache.mBusy) { + cache.mBitmap = null; + willCompute(cache); + } + } + + private CachedPreset getOldestCachedPreset() { + CachedPreset found = null; + for (int i = 0; i < mCache.size(); i++) { + CachedPreset cache = mCache.elementAt(i); + if (cache.mBusy) { + continue; + } + if (found == null) { + found = cache; + } else { + if (found.mAge > cache.mAge) { + found = cache; + } + } + } + return found; + } + + protected void willCompute(CachedPreset cache) { + if (cache == null) { + return; + } + cache.mBusy = true; + compute(cache); + didCompute(cache); + } + + protected void didCompute(CachedPreset cache) { + cache.mBusy = false; + notifyObservers(); + } + + protected void compute(CachedPreset cache) { + cache.mBitmap = null; + cache.mBitmap = mOriginalBitmap.copy(mBitmapConfig, true); + cache.mPreset.apply(cache.mBitmap); + cache.mAge = mGlobalAge++; + } + + public void prepare(ImagePreset preset) { + // Log.v(LOGTAG, "prepare preset " + preset.name() + " : " + preset); + CachedPreset cache = getCachedPreset(preset); + if (cache == null) { + if (mCache.size() < mCacheSize) { + cache = new CachedPreset(); + mCache.add(cache); + } else { + cache = getOldestCachedPreset(); + } + if (cache != null) { + cache.mPreset = preset; + } + } + willCompute(cache); + } + +} diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java new file mode 100644 index 000000000..302b94bed --- /dev/null +++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java @@ -0,0 +1,193 @@ + +package com.android.gallery3d.filtershow.presets; + +import java.util.Vector; + +import android.graphics.Bitmap; +import android.graphics.RectF; +import android.util.Log; + +import com.android.gallery3d.filtershow.filters.ImageFilter; +import com.android.gallery3d.filtershow.filters.ImageFilterStraighten; +import com.android.gallery3d.filtershow.imageshow.ImageShow; + +public class ImagePreset { + + private static final String LOGTAG = "ImagePreset"; + ImageShow mEndPoint = null; + protected int mParameter = 50; + protected Vector<ImageFilter> mFilters = new Vector<ImageFilter>(); + protected String mName = "Original"; + protected String mHistoryName = "Original"; + protected boolean mIsFxPreset = false; + + enum FullRotate { + ZERO, NINETY, HUNDRED_HEIGHTY, TWO_HUNDRED_SEVENTY + } + + protected FullRotate mFullRotate = FullRotate.ZERO; + protected float mStraightenRotate = 0; + protected float mStraightenZoom = 0; + protected boolean mHorizontalFlip = false; + protected boolean mVerticalFlip = false; + protected RectF mCrop = null; + + public ImagePreset() { + setup(); + } + + public ImagePreset(ImagePreset source) { + for (int i = 0; i < source.mFilters.size(); i++) { + add(source.mFilters.elementAt(i).copy()); + } + mName = source.name(); + mHistoryName = source.name(); + mIsFxPreset = source.isFx(); + + mStraightenRotate = source.mStraightenRotate; + mStraightenZoom = source.mStraightenZoom; + } + + public void setStraightenRotation(float rotate, float zoom) { + mStraightenRotate = rotate; + mStraightenZoom = zoom; + } + + private Bitmap applyGeometry(Bitmap original) { + Bitmap bitmap = original; + + if (mFullRotate != FullRotate.ZERO) { + // TODO + } + +// Log.v(LOGTAG, "applyGeometry with rotate " + mStraightenRotate + " and zoom " + // + mStraightenZoom); + + if (mStraightenRotate != 0) { + // TODO: keep the instances around + ImageFilter straighten = new ImageFilterStraighten(mStraightenRotate, mStraightenZoom); + straighten.apply(bitmap); + straighten = null; + } + + return bitmap; + } + + public boolean isFx() { + return mIsFxPreset; + } + + public void setIsFx(boolean value) { + mIsFxPreset = value; + } + + public void setName(String name) { + mName = name; + mHistoryName = name; + } + + public void setHistoryName(String name) { + mHistoryName = name; + } + + public boolean same(ImagePreset preset) { + if (preset.mFilters.size() != mFilters.size()) { + return false; + } + if (!mName.equalsIgnoreCase(preset.name())) { + return false; + } + if (mStraightenRotate != preset.mStraightenRotate) { + return false; + } + for (int i = 0; i < preset.mFilters.size(); i++) { + ImageFilter a = preset.mFilters.elementAt(i); + ImageFilter b = mFilters.elementAt(i); + if (!a.same(b)) { + return false; + } + } + return true; + } + + public String name() { + return mName; + } + + public String historyName() { + return mHistoryName; + } + + public void add(ImageFilter preset) { + mFilters.add(preset); + } + + public void remove(String filterName) { + ImageFilter filter = getFilter(filterName); + if (filter != null) { + mFilters.remove(filter); + } + } + + public int getCount() { + return mFilters.size(); + } + + public ImageFilter getFilter(String name) { + for (int i = 0; i < mFilters.size(); i++) { + ImageFilter filter = mFilters.elementAt(i); + if (filter.name().equalsIgnoreCase(name)) { + return filter; + } + } + return null; + } + + public void setup() { + // do nothing here + } + + public void setEndpoint(ImageShow image) { + mEndPoint = image; + } + + public Bitmap apply(Bitmap original) { + // First we apply any transform -- 90 rotate, flip, straighten, crop + Bitmap bitmap = applyGeometry(original); + + // TODO -- apply borders separately + ImageFilter borderFilter = null; + for (int i = 0; i < mFilters.size(); i++) { + ImageFilter filter = mFilters.elementAt(i); + if (filter.name().equalsIgnoreCase("Border")) { + // TODO don't use the name as an id + borderFilter = filter; + } else { + filter.apply(bitmap); + } + } + if (borderFilter != null) { + borderFilter.apply(bitmap); + } + if (mEndPoint != null) { + mEndPoint.updateFilteredImage(bitmap); + } + return bitmap; + } + + /* + * public void applyFilter(Bitmap bitmap) { // do nothing here, subclasses + * will implement filtering here } native protected void + * nativeApplyGradientFilter(Bitmap bitmap, int w, int h, int[] redGradient, + * int[] greenGradient, int[] blueGradient); + */ + + public void setParameter(int value) { + mParameter = value; + for (int i = 0; i < mFilters.size(); i++) { + ImageFilter filter = mFilters.elementAt(i); + filter.setParameter(value); + } + } + +} diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java new file mode 100644 index 000000000..a270080f9 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java @@ -0,0 +1,16 @@ + +package com.android.gallery3d.filtershow.presets; + +import com.android.gallery3d.filtershow.filters.ImageFilterBW; + +public class ImagePresetBW extends ImagePreset { + + public String name() { + return "Black & White"; + } + + public void setup() { + mFilters.add(new ImageFilterBW()); + } + +} diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java new file mode 100644 index 000000000..1783b482b --- /dev/null +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java @@ -0,0 +1,16 @@ + +package com.android.gallery3d.filtershow.presets; + +import com.android.gallery3d.filtershow.filters.ImageFilterBWBlue; + +public class ImagePresetBWBlue extends ImagePreset { + + public String name() { + return "Black & White (Blue)"; + } + + public void setup() { + mFilters.add(new ImageFilterBWBlue()); + } + +} diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java new file mode 100644 index 000000000..5b317a1e0 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java @@ -0,0 +1,16 @@ + +package com.android.gallery3d.filtershow.presets; + +import com.android.gallery3d.filtershow.filters.ImageFilterBWGreen; + +public class ImagePresetBWGreen extends ImagePreset { + + public String name() { + return "Black & White (Green)"; + } + + public void setup() { + mFilters.add(new ImageFilterBWGreen()); + } + +} diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java new file mode 100644 index 000000000..7b9f0e141 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java @@ -0,0 +1,16 @@ + +package com.android.gallery3d.filtershow.presets; + +import com.android.gallery3d.filtershow.filters.ImageFilterBWRed; + +public class ImagePresetBWRed extends ImagePreset { + + public String name() { + return "Black & White (Red)"; + } + + public void setup() { + mFilters.add(new ImageFilterBWRed()); + } + +} diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetOld.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetOld.java new file mode 100644 index 000000000..56e1dab45 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetOld.java @@ -0,0 +1,21 @@ + +package com.android.gallery3d.filtershow.presets; + +import com.android.gallery3d.filtershow.filters.ImageFilterGradient; + +import android.graphics.Color; + +public class ImagePresetOld extends ImagePreset { + + public String name() { + return "Old"; + } + + public void setup() { + ImageFilterGradient filter = new ImageFilterGradient(); + filter.addColor(Color.BLACK, 0.0f); + filter.addColor(Color.argb(255, 228, 231, 193), 1.0f); + mFilters.add(filter); + } + +} diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetSaturated.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetSaturated.java new file mode 100644 index 000000000..cf280ee47 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetSaturated.java @@ -0,0 +1,16 @@ + +package com.android.gallery3d.filtershow.presets; + +import com.android.gallery3d.filtershow.filters.ImageFilterSaturated; + +public class ImagePresetSaturated extends ImagePreset { + + public String name() { + return "Saturated"; + } + + public void setup() { + mFilters.add(new ImageFilterSaturated()); + } + +} diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetXProcessing.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetXProcessing.java new file mode 100644 index 000000000..3e744be77 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/presets/ImagePresetXProcessing.java @@ -0,0 +1,22 @@ + +package com.android.gallery3d.filtershow.presets; + +import com.android.gallery3d.filtershow.filters.ImageFilterGradient; + +import android.graphics.Color; + +public class ImagePresetXProcessing extends ImagePreset { + + public String name() { + return "X-Process"; + } + + public void setup() { + ImageFilterGradient filter = new ImageFilterGradient(); + filter.addColor(Color.BLACK, 0.0f); + filter.addColor(Color.argb(255, 29, 82, 83), 0.4f); + filter.addColor(Color.argb(255, 211, 217, 186), 1.0f); + mFilters.add(filter); + } + +} |