summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable/truescanner.xml63
-rw-r--r--res/layout/filtershow_main_panel.xml20
-rw-r--r--res/values/filtershow_ids.xml1
-rw-r--r--res/values/filtershow_strings.xml2
-rwxr-xr-xres/values/strings.xml2
-rw-r--r--src/com/android/gallery3d/filtershow/EditorPlaceHolder.java3
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java35
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryAdapter.java5
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryPanel.java6
-rw-r--r--src/com/android/gallery3d/filtershow/category/MainPanel.java40
-rw-r--r--src/com/android/gallery3d/filtershow/editors/TrueScannerEditor.java79
-rw-r--r--src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java15
-rw-r--r--src/com/android/gallery3d/filtershow/filters/TrueScannerActs.java184
-rw-r--r--src/com/android/gallery3d/filtershow/filters/TrueScannerWhiteBoardActs.java63
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java2
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageTrueScanner.java249
-rw-r--r--src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java2
-rw-r--r--src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java1
18 files changed, 764 insertions, 8 deletions
diff --git a/res/drawable/truescanner.xml b/res/drawable/truescanner.xml
new file mode 100644
index 000000000..49236ef07
--- /dev/null
+++ b/res/drawable/truescanner.xml
@@ -0,0 +1,63 @@
+<!--
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="32dp"
+ android:height="32dp"
+ android:viewportWidth="32"
+ android:viewportHeight="32">
+
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M15.1,23.4c0,0.8,0,1.6,0,2.3c-4,0-7.9,0-11.9,0c0-6.7,0-13.4,0-20c4,0,7.9,0,11.9,0c0,0.8,0,1.5,0,2.3
+c-3.2,0-6.4,0-9.6,0c0,5.1,0,10.2,0,15.4C8.7,23.4,11.9,23.4,15.1,23.4z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M15.1,10c0,0,0,0.1,0,0.1c0,1.9,0,3.7,0,5.6c0,0.1,0,0.2-0.1,0.3c-0.1,0.2-0.2,0.4-0.3,0.6c0,0,0,0.1,0,0.1
+c0.1,0,0.3,0,0.4,0c0,0.8,0,1.5,0,2.2c-0.1,0-0.2,0-0.3,0c-0.3,0-0.7,0-1,0c-0.1,0-0.1,0-0.2,0.1c-0.4,0.8-0.7,1.6-1.1,2.4
+c0,0.1-0.1,0.1-0.1,0.1c-0.9,0-1.8,0-2.8,0c0,0,0,0-0.1,0C11.4,17.7,13.2,13.9,15.1,10C15.1,10,15.1,10,15.1,10z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M17,16.4c0,4.2,0,8.4,0,12.5c0,0.3-0.2,0.5-0.4,0.5c-0.3,0-0.5-0.2-0.5-0.4c0,0,0-0.1,0-0.1
+c0-8.3,0-16.7,0-25c0-0.1,0-0.2,0-0.2c0.1-0.2,0.3-0.4,0.5-0.3c0.2,0,0.4,0.2,0.4,0.5c0,0,0,0.1,0,0.1C17,8.1,17,12.3,17,16.4z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M28.7,6.5c0,6.1,0,12.2,0,18.3c-3.4,0-6.9,0-10.3,0c0-0.1,0-0.2,0-0.3c3.3,0,6.7,0,10,0
+c0-5.9,0-11.8,0-17.7c-3.3,0-6.6,0-9.9,0c0-0.1,0-0.2,0-0.3C21.9,6.5,25.3,6.5,28.7,6.5z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M18,9.6c1.9,4,3.8,8,5.7,12.1c-0.1,0-0.1,0-0.1,0c-1,0-2,0-3,0c-0.1,0-0.1,0-0.2-0.1
+c-0.4-0.8-0.7-1.6-1.1-2.4c0-0.1-0.1-0.1-0.2-0.1c-0.3,0-0.7,0-1,0c0,0-0.1,0-0.1,0c0-0.1,0-0.2,0-0.3c0,0,0.1,0,0.1,0
+c0.4,0,0.9,0,1.3,0c0.1,0,0.1,0,0.2,0.1c0.4,0.8,0.7,1.6,1.1,2.4c0,0.1,0.1,0.1,0.2,0.1c0.8,0,1.5,0,2.3,0c0,0,0.1,0,0.1,0
+c-0.1-0.2-0.2-0.5-0.3-0.7c-1.6-3.3-3.1-6.6-4.7-9.9c0,0,0-0.1,0-0.1C17.9,10.4,17.9,10,18,9.6C18,9.7,18,9.6,18,9.6
+C18,9.6,18,9.6,18,9.6z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:pathData="M18.6,16.8c-0.2,0-0.4,0-0.6,0c0-0.1,0-0.2,0-0.3c0,0,0.1,0,0.1,0c-0.2-0.3-0.1-0.7-0.1-1
+C18.2,15.9,18.4,16.4,18.6,16.8z" />
+</vector>
diff --git a/res/layout/filtershow_main_panel.xml b/res/layout/filtershow_main_panel.xml
index d0e624665..36e21b7ae 100644
--- a/res/layout/filtershow_main_panel.xml
+++ b/res/layout/filtershow_main_panel.xml
@@ -110,6 +110,16 @@
android:scaleType="centerInside"
android:visibility="gone"
android:src="@drawable/dualcamera"/>
+
+ <ImageButton
+ android:id="@+id/trueScannerButton"
+ android:layout_width="@dimen/thumbnail_size"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="@android:color/transparent"
+ android:padding="2dip"
+ android:scaleType="centerInside"
+ android:src="@drawable/truescanner"/>
</LinearLayout>
<LinearLayout
@@ -179,6 +189,16 @@
android:textColor="#ffffff"
android:textSize="@dimen/edit_main_font"
android:visibility="gone" />
+
+ <TextView
+ android:id="@+id/tvTrueScanner"
+ android:layout_width="@dimen/thumbnail_size"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/trueScanner"
+ android:gravity="center"
+ android:textColor="#ffffff"
+ android:textSize="@dimen/edit_main_font" />
</LinearLayout>
</com.android.gallery3d.filtershow.CenteredLinearLayout>
</LinearLayout>
diff --git a/res/values/filtershow_ids.xml b/res/values/filtershow_ids.xml
index 7dc34c357..8251604a2 100644
--- a/res/values/filtershow_ids.xml
+++ b/res/values/filtershow_ids.xml
@@ -54,4 +54,5 @@
<item type="id" name="editorDualCam" />
<item type="id" name="editorDualCamSketch" />
<item type="id" name="editorDualCamFusion" />
+ <item type="id" name="trueScannerEditor" />
</resources>
diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml
index 8e1c4e27f..cd671bd2e 100644
--- a/res/values/filtershow_strings.xml
+++ b/res/values/filtershow_strings.xml
@@ -132,6 +132,8 @@
<!-- Filters buttons -->
+ <!-- True Effect button -->
+ <string name="trueScanner">True Scanner</string>
<!-- Label for the image exposure (brightness) filter button [CHAR LIMIT=10] -->
<string name="exposure" msgid="1229093066434614811">Exposure</string>
<!-- Label for the image sharpness (clarity, distinctness) filter button [CHAR LIMIT=10] -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 977475f24..e57529936 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1187,4 +1187,6 @@ CHAR LIMIT = NONE] -->
<string name="text_makeup_trimface">Trimface</string>
<string name="text_makeup_bigeye">Bigeye</string>
<string name="drawer_desc" translatable="false">drawer</string>
+ <string name="truescanner_normal">Normal</string>
+ <string name="truescanner_white">WhiteBoard</string>
</resources>
diff --git a/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java b/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
index 95fc56d4f..86cc87034 100644
--- a/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
+++ b/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
@@ -66,7 +66,8 @@ public class EditorPlaceHolder {
}
public void hide() {
- mContainer.setVisibility(View.GONE);
+ if(mContainer != null)
+ mContainer.setVisibility(View.GONE);
}
public void hideOldViews() {
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index ab921e689..4c2e6ef67 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -94,6 +94,7 @@ import com.android.gallery3d.filtershow.editors.EditorDualCamFusion;
import com.android.gallery3d.filtershow.editors.EditorManager;
import com.android.gallery3d.filtershow.editors.EditorPanel;
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+import com.android.gallery3d.filtershow.editors.TrueScannerEditor;
import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
@@ -102,6 +103,7 @@ import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter;
+import com.android.gallery3d.filtershow.filters.TrueScannerActs;
import com.android.gallery3d.filtershow.history.HistoryItem;
import com.android.gallery3d.filtershow.history.HistoryManager;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
@@ -181,6 +183,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
private CategoryAdapter mCategoryBordersAdapter = null;
private CategoryAdapter mCategoryGeometryAdapter = null;
private CategoryAdapter mCategoryFiltersAdapter = null;
+ private CategoryAdapter mCategoryTrueScannerAdapter = null;
private CategoryAdapter mCategoryVersionsAdapter = null;
private CategoryAdapter mCategoryMakeupAdapter = null;
private CategoryAdapter mCategoryDualCamAdapter = null;
@@ -571,6 +574,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
fillBorders();
fillTools();
fillEffects();
+ fillTrueScanner();
fillVersions();
fillMakeup();
fillDualCamera();
@@ -696,6 +700,21 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
}
+ private void fillTrueScanner() {
+ FiltersManager filtersManager = FiltersManager.getManager();
+ ArrayList<FilterRepresentation> trueScannerRepresentations = filtersManager.getTrueScanner();
+ if (mCategoryTrueScannerAdapter != null) {
+ mCategoryTrueScannerAdapter.clear();
+ }
+ mCategoryTrueScannerAdapter = new CategoryAdapter(this);
+ for (FilterRepresentation representation : trueScannerRepresentations) {
+ if (representation.getTextId() != 0) {
+ representation.setName(getString(representation.getTextId()));
+ }
+ mCategoryTrueScannerAdapter.add(new Action(this, representation));
+ }
+ }
+
private void fillTools() {
FiltersManager filtersManager = FiltersManager.getManager();
ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getTools();
@@ -834,6 +853,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
return mCategoryFiltersAdapter;
}
+ public CategoryAdapter getCategoryTrueScannerAdapter() {
+ return mCategoryTrueScannerAdapter;
+ }
+
public CategoryAdapter getCategoryVersionsAdapter() {
return mCategoryVersionsAdapter;
}
@@ -1646,10 +1669,14 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
public void showDefaultImageView() {
- mEditorPlaceHolder.hide();
- mImageShow.setVisibility(View.VISIBLE);
- MasterImage.getImage().setCurrentFilter(null);
- MasterImage.getImage().setCurrentFilterRepresentation(null);
+ if(mEditorPlaceHolder != null)
+ mEditorPlaceHolder.hide();
+ if(mImageShow != null)
+ mImageShow.setVisibility(View.VISIBLE);
+ if(MasterImage.getImage() != null) {
+ MasterImage.getImage().setCurrentFilter(null);
+ MasterImage.getImage().setCurrentFilterRepresentation(null);
+ }
}
public void backToMain() {
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
index 9571d8b16..83ab5b2a3 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
@@ -88,6 +88,11 @@ public class CategoryAdapter extends ArrayAdapter<Action> {
if (category == MainPanel.DUALCAM) {
mSelectedPosition = 0;
}
+
+ if (category == MainPanel.TRUESCANNER) {
+ mSelectedPosition = 0;
+ }
+
if (category == MainPanel.VERSIONS) {
mAddButtonText = getContext().getString(R.string.filtershow_add_button_versions);
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
index 3ee9e45eb..62071f309 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
@@ -88,6 +88,12 @@ public class CategoryPanel extends Fragment implements View.OnClickListener {
mAdapter.initializeSelection(MainPanel.DUALCAM);
}
activity.updateCategories();
+ }
+ case MainPanel.TRUESCANNER: {
+ mAdapter = activity.getCategoryTrueScannerAdapter();
+ if (mAdapter != null) {
+ mAdapter.initializeSelection(MainPanel.TRUESCANNER);
+ }
break;
}
case MainPanel.VERSIONS: {
diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java
index 0d7d6f6ce..17766dfd1 100644
--- a/src/com/android/gallery3d/filtershow/category/MainPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java
@@ -31,6 +31,7 @@ import android.util.Log;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter;
+import com.android.gallery3d.filtershow.filters.TrueScannerActs;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.state.StatePanel;
import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine;
@@ -51,6 +52,7 @@ public class MainPanel extends Fragment {
private View mEffectsTextContainer;
private FrameLayout mCategoryFragment;
private View mBottomView;
+ private ImageButton trueScannerButton;
public static final String FRAGMENT_TAG = "MainPanel";
public static final String EDITOR_TAG = "coming-from-editor-panel";
@@ -61,6 +63,7 @@ public class MainPanel extends Fragment {
public static final int MAKEUP = 4;
public static final int DUALCAM = 5;
public static final int VERSIONS = 6;
+ public static final int TRUESCANNER = 7;
private int mCurrentSelected = -1;
private int mPreviousToggleVersions = -1;
@@ -98,6 +101,10 @@ public class MainPanel extends Fragment {
dualCamButton.setSelected(value);
break;
}
+ case TRUESCANNER: {
+ //trueScannerButton.setSelected(value);
+ break;
+ }
}
}
@@ -129,19 +136,19 @@ public class MainPanel extends Fragment {
mBottomView = mMainView.findViewById(R.id.bottom_panel);
mEffectsContainer = mMainView.findViewById(R.id.effectsContainer);
mEffectsTextContainer = mMainView.findViewById(R.id.effectsText);
- if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+ if (SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
makeupButton = (ImageButton) mMainView.findViewById(R.id.makeupButton);
makeupButton.setVisibility(View.VISIBLE);
TextView beautify = (TextView) mEffectsTextContainer
.findViewById(R.id.tvBeautify);
beautify.setVisibility(View.VISIBLE);
}
- boolean showPanel = false;
+ boolean showPanel = false;
if (getArguments() != null) {
showPanel = getArguments().getBoolean(EDITOR_TAG);
}
- if(makeupButton != null) {
+ if (makeupButton != null) {
makeupButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -149,6 +156,12 @@ public class MainPanel extends Fragment {
}
});
}
+ TextView trueScannerTv = (TextView) mMainView.findViewById(R.id.tvTrueScanner);
+ trueScannerButton = (ImageButton) mMainView.findViewById(R.id.trueScannerButton);
+ if (!TrueScannerActs.isTrueScannerEnabled()) {
+ trueScannerTv.setVisibility(View.GONE);
+ trueScannerButton.setVisibility(View.GONE);
+ }
looksButton.setOnClickListener(new View.OnClickListener() {
@Override
@@ -183,6 +196,13 @@ public class MainPanel extends Fragment {
updateDualCameraButton();
+ trueScannerButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showPanel(TRUESCANNER);
+ }
+ });
+
FilterShowActivity activity = (FilterShowActivity) getActivity();
//showImageStatePanel(activity.isShowingImageStatePanel());
if (showPanel) {
@@ -290,6 +310,16 @@ public class MainPanel extends Fragment {
selection(mCurrentSelected, true);
}
+ public void loadCategoryTrueScannerPanel() {
+ boolean fromRight = isRightAnimation(TRUESCANNER);
+ selection(mCurrentSelected, false);
+ CategoryPanel categoryPanel = new CategoryPanel();
+ categoryPanel.setAdapter(TRUESCANNER);
+ setCategoryFragment(categoryPanel, fromRight);
+ mCurrentSelected = TRUESCANNER;
+ selection(mCurrentSelected, true);
+ }
+
public void loadCategoryFiltersPanel() {
/*if (mCurrentSelected == FILTERS) {
return;
@@ -361,6 +391,10 @@ public class MainPanel extends Fragment {
loadCategoryDualCamPanel();
break;
}
+ case TRUESCANNER: {
+ loadCategoryTrueScannerPanel();
+ break;
+ }
case VERSIONS: {
loadCategoryVersionsPanel();
break;
diff --git a/src/com/android/gallery3d/filtershow/editors/TrueScannerEditor.java b/src/com/android/gallery3d/filtershow/editors/TrueScannerEditor.java
new file mode 100644
index 000000000..30f099ca5
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/TrueScannerEditor.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.widget.FrameLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
+import com.android.gallery3d.filtershow.filters.TrueScannerActs;
+import com.android.gallery3d.filtershow.imageshow.ImageShow;
+import com.android.gallery3d.filtershow.imageshow.ImageTrueScanner;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+/**
+ * The editor with no slider for filters without UI
+ */
+public class TrueScannerEditor extends Editor {
+ public final static int ID = R.id.trueScannerEditor;
+ private final String LOGTAG = "TrueScannerEditor";
+ protected ImageTrueScanner mImageTrueScanner;
+
+ public TrueScannerEditor() {
+ super(ID);
+ }
+
+ protected TrueScannerEditor(int id) {
+ super(id);
+ }
+
+ public boolean useUtilityPanel() {
+ return true;
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ mView = mImageShow = mImageTrueScanner = new ImageTrueScanner(context);
+ mImageTrueScanner.setEditor(this);
+ }
+
+ @Override
+ public void finalApplyCalled() {
+ super.finalApplyCalled();
+ }
+
+ @Override
+ public boolean showsSeekBar() {
+ return false;
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
index 3de93cf5a..9970cfa65 100644
--- a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
+++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
@@ -39,6 +39,7 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
protected ArrayList<FilterRepresentation> mEffects = new ArrayList<FilterRepresentation>();
protected ArrayList<FilterRepresentation> mMakeup = new ArrayList<FilterRepresentation>();
protected ArrayList<FilterRepresentation> mDualCam = new ArrayList<FilterRepresentation>();
+ protected ArrayList<FilterRepresentation> mTrueScanner = new ArrayList<FilterRepresentation>();
private static int mImageBorderSize = 4; // in percent
protected void init() {
@@ -46,6 +47,7 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
mRepresentationLookup = new HashMap<String, FilterRepresentation>();
Vector<Class> filters = new Vector<Class>();
addFilterClasses(filters);
+ addTrueScannerClasses(filters);
for (Class filterClass : filters) {
try {
Object filterInstance = filterClass.newInstance();
@@ -155,6 +157,11 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
}
}
+ protected void addTrueScannerClasses(Vector<Class> filters) {
+ filters.add(TrueScannerActs.class);
+ filters.add(TrueScannerWhiteBoardActs.class);
+ }
+
public ArrayList<FilterRepresentation> getLooks() {
return mLooks;
}
@@ -178,6 +185,9 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
public ArrayList<FilterRepresentation> getMakeup() {
return mMakeup;
}
+ public ArrayList<FilterRepresentation> getTrueScanner() {
+ return mTrueScanner;
+ }
public void addBorders(Context context) {
// Do not localize
@@ -335,6 +345,11 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
}
}
+ public void addTrueScanner() {
+ mTrueScanner.add(getRepresentation(TrueScannerActs.class));
+ mTrueScanner.add(getRepresentation(TrueScannerWhiteBoardActs.class));
+ }
+
public void addTools(Context context) {
int[] textId = {
diff --git a/src/com/android/gallery3d/filtershow/filters/TrueScannerActs.java b/src/com/android/gallery3d/filtershow/filters/TrueScannerActs.java
new file mode 100644
index 000000000..63c3a1299
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/TrueScannerActs.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.editors.TrueScannerEditor;
+import com.android.gallery3d.filtershow.imageshow.ImageTrueScanner;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+import static com.android.gallery3d.filtershow.imageshow.ImageTrueScanner.*;
+
+public class TrueScannerActs extends SimpleImageFilter {
+ public static final String SERIALIZATION_NAME = "TrueScannerActs";
+ private static final int MIN_WIDTH = 512;
+ private static final int MIN_HEIGHT = 512;
+ private static final boolean DEBUG = false;
+ private static boolean isTrueScannerEnabled = true;
+ private static boolean isPointsAcquired;
+ private final static int POINTS_LEN = 8;
+ private static int[] mAcquiredPoints = new int[POINTS_LEN+2];
+ protected boolean isWhiteBoard = false;
+ private boolean mLocked = false;
+ private Bitmap rectifiedImage = null;
+ private Bitmap whiteboardImage = null;
+ private int[] oldPts = new int[POINTS_LEN];
+
+ private void printDebug(String str) {
+ if(DEBUG)
+ android.util.Log.d("TrueScanner", str);
+ }
+
+ public static boolean isTrueScannerEnabled() {
+ return isTrueScannerEnabled;
+ }
+
+ public TrueScannerActs() {
+ mName = "TrueScannerActs";
+ isPointsAcquired = false;
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation = (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("TrueScanner");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(TrueScannerActs.class);
+ representation.setTextId(R.string.truescanner_normal);
+ representation.setMinimum(0);
+ representation.setMaximum(10);
+ representation.setValue(0);
+ representation.setDefaultValue(0);
+ representation.setSupportsPartialRendering(false);
+ representation.setEditorId(TrueScannerEditor.ID);
+
+ return representation;
+ }
+
+ private native int[] processImage(Bitmap orgBitmap, Bitmap rectifiedBitmap, Bitmap whiteboardBitmap, int[] cornerPts);
+ private native int[] getPoints(Bitmap orgBitmap);
+
+ public static int[] getPoints() {
+ if(!isPointsAcquired)
+ return null;
+ return mAcquiredPoints;
+ }
+
+ private synchronized boolean acquireLock(boolean isAcquiring) {
+ if(mLocked != isAcquiring) {
+ mLocked = isAcquiring;
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isReNewed(int pts[]) {
+ if(rectifiedImage == null || whiteboardImage == null) {
+ return true;
+ } else {
+ for(int i=0; i<oldPts.length;i++) {
+ if(pts[i] != oldPts[i]) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float not_use, int quality) {
+ if(bitmap == null)
+ return null;
+
+ if(bitmap.getWidth() <= MIN_WIDTH && bitmap.getHeight() <= MIN_HEIGHT)
+ return bitmap;
+
+ if(!acquireLock(true)) {
+ sActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(sActivity, "Still processing the previous request... ", Toast.LENGTH_LONG).show();
+ }
+ });
+
+ return bitmap;
+ }
+
+ if(!isPointsAcquired) {
+ int[] recPoints = getPoints(bitmap);
+ for(int i=0; i < POINTS_LEN; i++) {
+ mAcquiredPoints[i] = recPoints[i];
+ }
+ mAcquiredPoints[POINTS_LEN] = bitmap.getWidth();
+ mAcquiredPoints[POINTS_LEN+1] = bitmap.getHeight();
+ isPointsAcquired = true;
+ }
+
+ int[] pts = ImageTrueScanner.getDeterminedPoints();
+ int[] resultPts = new int[POINTS_LEN];
+ float xScale = ((float)bitmap.getWidth())/pts[POINTS_LEN];
+ float yScale = ((float)bitmap.getHeight())/pts[POINTS_LEN+1];
+ for(int i=0; i < POINTS_LEN; i++) {
+ if(i%2 == 0)
+ resultPts[i] = (int)((pts[i] - pts[POINTS_LEN+2])*xScale);
+ else
+ resultPts[i] = (int)((pts[i] - pts[POINTS_LEN+3])*yScale);
+ }
+
+ if(isReNewed(pts)) {
+ rectifiedImage = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
+ whiteboardImage = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
+ int[] outputSize = processImage(bitmap, rectifiedImage, whiteboardImage, resultPts);
+ rectifiedImage = Bitmap.createBitmap(rectifiedImage, 0, 0, outputSize[0], outputSize[1]);
+ whiteboardImage = Bitmap.createBitmap(whiteboardImage, 0, 0, outputSize[2], outputSize[3]);
+ }
+
+ acquireLock(false);
+ if(isWhiteBoard)
+ return whiteboardImage;
+
+ return rectifiedImage;
+ }
+
+ static {
+ try {
+ System.loadLibrary("jni_truescanner");
+ isTrueScannerEnabled = true;
+ } catch(UnsatisfiedLinkError e) {
+ isTrueScannerEnabled = false;
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/TrueScannerWhiteBoardActs.java b/src/com/android/gallery3d/filtershow/filters/TrueScannerWhiteBoardActs.java
new file mode 100644
index 000000000..9b4eedb4e
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/TrueScannerWhiteBoardActs.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.TrueScannerEditor;
+
+public class TrueScannerWhiteBoardActs extends TrueScannerActs {
+
+ public TrueScannerWhiteBoardActs() {
+ super();
+ isWhiteBoard = true;
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation = (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("TrueScannerWhiteBoard");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(TrueScannerWhiteBoardActs.class);
+ representation.setTextId(R.string.truescanner_white);
+ representation.setMinimum(0);
+ representation.setMaximum(10);
+ representation.setValue(0);
+ representation.setDefaultValue(0);
+ representation.setSupportsPartialRendering(false);
+ representation.setEditorId(TrueScannerEditor.ID);
+
+ return representation;
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float not_use, int quality) {
+ return super.apply(bitmap, not_use, quality);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index d6f7e228b..adbb63da5 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -1034,6 +1034,8 @@ public class ImageShow extends View implements OnGestureListener,
public void scaleImage(boolean isScaled, Context context) {
float scale = 1.0f;
Bitmap bitmap = MasterImage.getImage().getOriginalBitmapLarge();
+ if(bitmap == null)
+ return;
int bitmapWidth = bitmap.getWidth();
int bitmapheight = bitmap.getHeight();
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageTrueScanner.java b/src/com/android/gallery3d/filtershow/imageshow/ImageTrueScanner.java
new file mode 100644
index 000000000..c11729ae8
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageTrueScanner.java
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.MotionEvent;
+
+import com.android.gallery3d.filtershow.crop.CropDrawingUtils;
+import com.android.gallery3d.filtershow.crop.CropMath;
+import com.android.gallery3d.filtershow.crop.CropObject;
+import com.android.gallery3d.filtershow.editors.TrueScannerEditor;
+import com.android.gallery3d.filtershow.filters.FilterCropRepresentation;
+import com.android.gallery3d.filtershow.filters.TrueScannerActs;
+
+public class ImageTrueScanner extends ImageShow {
+ private static final String TAG = ImageTrueScanner.class.getSimpleName();
+ TrueScannerEditor mEditor;
+ private Matrix mDisplayMatrix;
+ private GeometryMathUtils.GeometryHolder mGeometry;
+ public final static int POINT_NUMS = 4;
+ private static int[] mSegPoints = new int[POINT_NUMS*2+4];
+ private boolean[] isTouched = new boolean[POINT_NUMS];
+ private RectF mBitmapBound = new RectF();
+ private Bitmap mBitmap;
+ private Paint mSegmentPaint;
+ private final static float RADIUS = 20f;
+ private final static float CHECK_RADIUS = 100f;
+ private int mMarginalGapX = 10;
+ private int mMarginalGapY = 10;
+ private boolean isPointsAcquired = false;
+
+ public ImageTrueScanner(Context context) {
+ super(context);
+ init();
+ }
+
+ public ImageTrueScanner(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public ImageTrueScanner(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init();
+ }
+
+ public static int[] getDeterminedPoints() {
+ return mSegPoints;
+ }
+
+ private void init() {
+ mBitmap = MasterImage.getImage().getFiltersOnlyImage();
+ mMarginalGapX = mBitmap.getWidth()/4;
+ mMarginalGapY = mBitmap.getHeight()/4;
+ mGeometry = new GeometryMathUtils.GeometryHolder();
+
+ mSegmentPaint = new Paint();
+ mSegmentPaint.setColor(Color.CYAN);
+ }
+
+ private void checkPointTouch(float x, float y) {
+ for(int i=0; i<POINT_NUMS; i++) {
+ if ( x > mSegPoints[i*2] - CHECK_RADIUS && x < mSegPoints[i*2] + CHECK_RADIUS
+ && y > mSegPoints[i*2+1] - CHECK_RADIUS && y < mSegPoints[i*2+1] + CHECK_RADIUS) {
+ isTouched[i] = true;
+ }
+ }
+ }
+
+ private void moveTouch(float x, float y) {
+ int i;
+ for(i=0; i<POINT_NUMS; i++) {
+ if(isTouched[i]) {
+ mSegPoints[i*2] = (int) x;
+ mSegPoints[i*2+1] = (int) y;
+ break;
+ }
+ }
+ switch(i)
+ {
+ case 0:
+ if(mSegPoints[0] < mBitmapBound.left) mSegPoints[0] = (int)mBitmapBound.left;
+ if(mSegPoints[0] >= mSegPoints[2]-mMarginalGapX)
+ mSegPoints[0] = mSegPoints[2]-mMarginalGapX;
+ if(mSegPoints[1] < mBitmapBound.top) mSegPoints[1] = (int)mBitmapBound.top;
+ if(mSegPoints[1] >= mSegPoints[7]-mMarginalGapY)
+ mSegPoints[1] = mSegPoints[7]-mMarginalGapY;
+ break;
+ case 1:
+ if(mSegPoints[2] > mBitmapBound.right) mSegPoints[2] = (int)mBitmapBound.right;
+ if(mSegPoints[2] <= mSegPoints[0]+mMarginalGapX)
+ mSegPoints[2] = mSegPoints[0]+mMarginalGapX;
+ if(mSegPoints[3] < mBitmapBound.top) mSegPoints[3] = (int)mBitmapBound.top;
+ if(mSegPoints[3] >= mSegPoints[5]-mMarginalGapY)
+ mSegPoints[3] = mSegPoints[5]-mMarginalGapY;
+ break;
+ case 2:
+ if(mSegPoints[4] > mBitmapBound.right) mSegPoints[4] = (int)mBitmapBound.right;
+ if(mSegPoints[4] <= mSegPoints[6]+mMarginalGapX)
+ mSegPoints[4] = mSegPoints[6]+mMarginalGapX;
+ if(mSegPoints[5] > mBitmapBound.bottom) mSegPoints[5] = (int)mBitmapBound.bottom;
+ if(mSegPoints[5] <= mSegPoints[3]+mMarginalGapY)
+ mSegPoints[5] = mSegPoints[3]+mMarginalGapY;
+ break;
+ case 3:
+ if(mSegPoints[6] < mBitmapBound.left) mSegPoints[6] = (int)mBitmapBound.left;
+ if(mSegPoints[6] >= mSegPoints[4]-mMarginalGapX)
+ mSegPoints[6] = mSegPoints[4]-mMarginalGapX;
+ if(mSegPoints[7] > mBitmapBound.bottom) mSegPoints[7] = (int)mBitmapBound.bottom;
+ if(mSegPoints[7] <= mSegPoints[1]+mMarginalGapY)
+ mSegPoints[7] = mSegPoints[1]+mMarginalGapY;
+ break;
+ }
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ float x = event.getX();
+ float y = event.getY();
+
+ switch (event.getActionMasked()) {
+ case (MotionEvent.ACTION_DOWN):
+ checkPointTouch(x, y);
+ case (MotionEvent.ACTION_MOVE):
+ moveTouch(x,y);
+ break;
+ case (MotionEvent.ACTION_UP):
+ for(int i=0; i<POINT_NUMS; i++) {
+ isTouched[i] = false;
+ }
+ break;
+ }
+
+ invalidate();
+ return true;
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ }
+
+ private void getBitmapBound() {
+ mBitmapBound.left = 0;
+ mBitmapBound.right = mBitmap.getWidth();
+ mBitmapBound.top = 0;
+ mBitmapBound.bottom = mBitmap.getHeight();
+ mDisplayMatrix.mapRect(mBitmapBound);
+ }
+
+ private void getInitialInput() {
+ int[] points = TrueScannerActs.getPoints();
+ if (points == null) {
+ mSegPoints[0] = (int) mBitmapBound.left;
+ mSegPoints[1] = (int) mBitmapBound.top;
+ mSegPoints[2] = (int) mBitmapBound.right;
+ mSegPoints[3] = (int) mBitmapBound.top;
+ mSegPoints[4] = (int) mBitmapBound.right;
+ mSegPoints[5] = (int) mBitmapBound.bottom;
+ mSegPoints[6] = (int) mBitmapBound.left;
+ mSegPoints[7] = (int) mBitmapBound.bottom;
+ } else {
+ float xScale = mBitmapBound.width()/points[8];
+ float yScale = mBitmapBound.height()/points[9];
+ mSegPoints[0] = (int) (mBitmapBound.left + points[0]*xScale);
+ mSegPoints[1] = (int) (mBitmapBound.top + points[1]*yScale);
+ mSegPoints[2] = (int) (mBitmapBound.left + points[2]*xScale);
+ mSegPoints[3] = (int) (mBitmapBound.top + points[3]*yScale);
+ mSegPoints[4] = (int) (mBitmapBound.left + points[4]*xScale);
+ mSegPoints[5] = (int) (mBitmapBound.top + points[5]*yScale);
+ mSegPoints[6] = (int) (mBitmapBound.left + points[6]*xScale);
+ mSegPoints[7] = (int) (mBitmapBound.top + points[7]*yScale);
+ isPointsAcquired = true;
+ }
+ mSegPoints[8] = (int)mBitmapBound.width();
+ mSegPoints[9] = (int)mBitmapBound.height();
+ mSegPoints[10] = (int)mBitmapBound.left;
+ mSegPoints[11] = (int)mBitmapBound.top;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ if(mBitmap == null)
+ return;
+
+ if(mDisplayMatrix == null) {
+ mDisplayMatrix = GeometryMathUtils.getFullGeometryToScreenMatrix(mGeometry,
+ mBitmap.getWidth(), mBitmap.getHeight(), canvas.getWidth(), canvas.getHeight());
+ getBitmapBound();
+ }
+ if(!isPointsAcquired) {
+ getInitialInput();
+ }
+ canvas.drawBitmap(mBitmap, mDisplayMatrix, null);
+ drawSegments(canvas);
+ }
+
+ private void drawSegments(Canvas canvas)
+ {
+ for(int i=0; i<POINT_NUMS; i++) {
+ canvas.drawCircle(mSegPoints[i*2], mSegPoints[i*2+1], RADIUS, mSegmentPaint);
+ }
+ canvas.drawLine(mSegPoints[0], mSegPoints[1], mSegPoints[2], mSegPoints[3], mSegmentPaint);
+ canvas.drawLine(mSegPoints[2], mSegPoints[3], mSegPoints[4], mSegPoints[5], mSegmentPaint);
+ canvas.drawLine(mSegPoints[4], mSegPoints[5], mSegPoints[6], mSegPoints[7], mSegmentPaint);
+ canvas.drawLine(mSegPoints[0], mSegPoints[1], mSegPoints[6], mSegPoints[7], mSegmentPaint);
+ }
+
+ public void setEditor(TrueScannerEditor editor) {
+ mEditor = editor;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java
index c645c3b29..899dc13c8 100644
--- a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java
+++ b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java
@@ -309,6 +309,7 @@ public class ProcessingService extends Service {
filtersManager.addEffects();
filtersManager.addDualCam(this);
filtersManager.addMakeups(this);
+ filtersManager.addTrueScanner();
FiltersManager highresFiltersManager = FiltersManager.getHighresManager();
highresFiltersManager.addLooks(this);
@@ -317,6 +318,7 @@ public class ProcessingService extends Service {
highresFiltersManager.addEffects();
highresFiltersManager.addDualCam(this);
// highresFiltersManager.addMakeups(this);
+ highresFiltersManager.addTrueScanner();
}
private void tearDownPipeline() {
diff --git a/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java b/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
index 8c668d482..1e07ce380 100644
--- a/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
@@ -39,6 +39,7 @@ public class EditorManager {
editorPlaceHolder.addEditor(new EditorDualCamera());
editorPlaceHolder.addEditor(new EditorDualCamFusion());
editorPlaceHolder.addEditor(new EditorDualCamSketch());
+ editorPlaceHolder.addEditor(new TrueScannerEditor());
}
}