Merge commit '289306f103b181378d5d58850cf61495facc3204' into HEAD
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8da36db
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+# Project files and paths.
+.classpath
+.project
+*.iml
+**/*.iml
+.settings/
+bin/
+libs/
+gen/
+.idea/
+project.properties
diff --git a/Android.mk b/Android.mk
index c17ee04..cf5b767 100644
--- a/Android.mk
+++ b/Android.mk
@@ -37,9 +37,9 @@
# the libraries in the APK, otherwise just put them in /system/lib and
# leave them out of the APK
ifneq (,$(TARGET_BUILD_APPS))
- LOCAL_JNI_SHARED_LIBRARIES := libjni_mosaic libjni_eglfence libjni_filtershow_filters librsjni
+ LOCAL_JNI_SHARED_LIBRARIES := libjni_eglfence libjni_filtershow_filters librsjni libjni_jpegstream
else
- LOCAL_REQUIRED_MODULES := libjni_mosaic libjni_eglfence libjni_filtershow_filters
+ LOCAL_REQUIRED_MODULES := libjni_eglfence libjni_filtershow_filters libjni_jpegstream
endif
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
@@ -50,7 +50,7 @@
ifeq ($(strip $(LOCAL_PACKAGE_OVERRIDES)),)
-# Use the following include to make gallery test apk and the mosaic library
+# Use the following include to make gallery test apk
include $(call all-makefiles-under, $(LOCAL_PATH))
endif
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 62acc00..8f48edf 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
-<manifest android:versionCode="40012"
- android:versionName="1.1.40012"
+<manifest android:versionCode="40030"
+ android:versionName="1.1.40030"
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.gallery3d">
@@ -42,11 +42,9 @@
android:logo="@mipmap/ic_launcher_gallery"
android:hardwareAccelerated="true"
android:largeHeap="true"
- android:backupAgent="com.android.camera.CameraBackupAgent"
- android:restoreAnyVersion="true">
+ android:restoreAnyVersion="true"
+ android:supportsRtl="true">
<uses-library android:name="com.google.android.media.effects" android:required="false" />
- <meta-data android:name="com.google.android.backup.api_key"
- android:value="AEdPqrEAAAAIRIXquXawbz6duuuCIUAZ_YJv1zbFMMcjZ0NoVw" />
<activity android:name="com.android.gallery3d.app.MovieActivity"
android:label="@string/movie_view_label"
android:configChanges="orientation|keyboardHidden|screenSize">
@@ -87,7 +85,7 @@
</intent-filter>
</activity>
- <activity android:name="com.android.gallery3d.app.Gallery" android:label="@string/app_name"
+ <activity android:name="com.android.gallery3d.app.GalleryActivity" android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -163,10 +161,21 @@
</intent-filter>
</activity>
+ <!-- This activity acts as a trampoline to the new Gallery activity,
+ so that existing shortcuts are preserved. -->
+ <activity android:name="com.android.gallery3d.app.Gallery"
+ android:excludeFromRecents="true"
+ android:theme="@style/android:Theme.NoDisplay">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<!-- we add this activity-alias for shortcut backward compatibility -->
<!-- Note: The alias must put after the target activity -->
<activity-alias android:name="com.cooliris.media.Gallery"
- android:targetActivity="com.android.gallery3d.app.Gallery"
+ android:targetActivity="com.android.gallery3d.app.GalleryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name">
<intent-filter>
@@ -174,6 +183,23 @@
</intent-filter>
</activity-alias>
+ <!-- This activity acts as a trampoline to the new Camera activity
+ in com.android.camera2 package, so that existing shortcuts
+ are preserved. -->
+ <activity android:name="com.android.camera.CameraActivity"
+ android:icon="@mipmap/ic_launcher_camera"
+ android:label="@string/camera_label"
+ android:taskAffinity="com.android.camera.CameraActivity"
+ android:theme="@style/android:Theme.NoDisplay" />
+ <activity-alias android:name="com.android.camera.CameraLauncher"
+ android:label="@string/camera_label"
+ android:targetActivity="com.android.camera.CameraActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity-alias>
+
<!-- This activity receives USB_DEVICE_ATTACHED intents and allows importing
media from attached MTP devices, like cameras and camera phones -->
<activity android:launchMode="singleInstance"
@@ -205,6 +231,13 @@
</activity>
<activity android:name="com.android.gallery3d.app.TrimVideo"
android:label="@string/trim_label">
+ <intent-filter android:label="@string/crop_label">
+ <action android:name="com.android.camera.action.TRIM" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="content" />
+ <data android:scheme="file" />
+ <data android:mimeType="video/*" />
+ </intent-filter>
</activity>
<permission android:name="com.android.gallery3d.filtershow.permission.READ"
@@ -219,6 +252,11 @@
android:grantUriPermissions="true"
android:readPermission="com.android.gallery3d.filtershow.permission.READ"
android:writePermission="com.android.gallery3d.filtershow.permission.WRITE" />
+
+ <service
+ android:name=".filtershow.pipeline.ProcessingService"
+ android:exported="false" />
+
<activity
android:name="com.android.gallery3d.filtershow.FilterShowActivity"
android:label="@string/title_activity_filter_show"
@@ -239,7 +277,7 @@
<activity
android:name="com.android.gallery3d.filtershow.crop.CropActivity"
android:label="@string/crop"
- android:theme="@style/Theme.FilterShow"
+ android:theme="@style/Theme.Crop"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter android:label="@string/crop_label">
<action android:name="com.android.camera.action.CROP" />
@@ -284,82 +322,6 @@
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/Theme.Gallery.Dialog"/>
- <activity android:name="com.android.camera.CameraActivity"
- android:taskAffinity="com.android.camera.CameraActivity"
- android:label="@string/camera_label"
- android:theme="@style/Theme.Camera"
- android:icon="@mipmap/ic_launcher_camera"
- android:configChanges="orientation|screenSize|keyboardHidden"
- android:clearTaskOnLaunch="true"
- android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
- <intent-filter>
- <action android:name="android.media.action.IMAGE_CAPTURE" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.media.action.STILL_IMAGE_CAMERA" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <meta-data android:name="com.android.keyguard.layout"
- android:resource="@layout/keyguard_widget" />
- </activity>
-
- <activity android:name="com.android.camera.SecureCameraActivity"
- android:taskAffinity="com.android.camera.SecureCameraActivity"
- android:excludeFromRecents="true"
- android:label="@string/camera_label"
- android:theme="@style/Theme.Camera"
- android:icon="@mipmap/ic_launcher_camera"
- android:configChanges="orientation|screenSize|keyboardHidden"
- android:clearTaskOnLaunch="true"
- android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
- <intent-filter>
- <action android:name="android.media.action.STILL_IMAGE_CAMERA_SECURE" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.media.action.IMAGE_CAPTURE_SECURE" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <meta-data android:name="com.android.keyguard.layout"
- android:resource="@layout/keyguard_widget" />
- </activity>
-
- <activity-alias android:icon="@mipmap/ic_launcher_camera"
- android:label="@string/camera_label"
- android:name="com.android.camera.CameraLauncher"
- android:targetActivity="com.android.camera.CameraActivity" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity-alias>
-
- <activity-alias android:icon="@mipmap/ic_launcher_camera"
- android:label="@string/camera_label"
- android:name="com.android.camera.Camera"
- android:targetActivity="com.android.camera.CameraActivity" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity-alias>
-
- <activity-alias android:icon="@mipmap/ic_launcher_video_camera"
- android:label="@string/video_camera_label"
- android:name="com.android.camera.VideoCamera"
- android:targetActivity="com.android.camera.CameraActivity" >
- <intent-filter>
- <action android:name="android.media.action.VIDEO_CAMERA" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.media.action.VIDEO_CAPTURE" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity-alias>
-
<receiver android:name="com.android.gallery3d.gadget.PhotoAppWidgetProvider"
android:label="@string/appwidget_title">
<intent-filter>
@@ -377,16 +339,6 @@
</intent-filter>
</receiver>
<service android:name="com.android.gallery3d.app.PackagesMonitor$AsyncService"/>
- <receiver android:name="com.android.camera.CameraButtonIntentReceiver">
- <intent-filter>
- <action android:name="android.intent.action.CAMERA_BUTTON"/>
- </intent-filter>
- </receiver>
- <receiver android:name="com.android.camera.DisableCameraReceiver">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
<service android:name="com.android.gallery3d.gadget.WidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS"/>
<activity android:name="com.android.gallery3d.gadget.WidgetConfigure"
@@ -396,10 +348,14 @@
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
- <activity android:name="com.android.camera.ProxyLauncher"
- android:theme="@style/Theme.ProxyLauncher">
- </activity>
<service android:name="com.android.gallery3d.app.BatchService" />
+
+ <receiver android:name="com.android.camera.DisableCameraReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
+
<service android:name="com.android.camera.MediaSaveService" />
</application>
</manifest>
diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
index dde4c56..f4de5c9 100644
--- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
+++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
@@ -113,9 +113,6 @@
public static final boolean HAS_MEDIA_ACTION_SOUND =
Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
- public static final boolean HAS_OLD_PANORAMA =
- Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH;
-
public static final boolean HAS_TIME_LAPSE_RECORDING =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
@@ -128,9 +125,6 @@
public static final boolean HAS_CAMERA_METERING_AREA =
Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH;
- public static final boolean HAS_FINE_RESOLUTION_QUALITY_LEVELS =
- Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
-
public static final boolean HAS_MOTION_EVENT_TRANSFORM =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
diff --git a/gallerycommon/src/com/android/gallery3d/jpegstream/JPEGInputStream.java b/gallerycommon/src/com/android/gallery3d/jpegstream/JPEGInputStream.java
new file mode 100644
index 0000000..44ccd4c
--- /dev/null
+++ b/gallerycommon/src/com/android/gallery3d/jpegstream/JPEGInputStream.java
@@ -0,0 +1,193 @@
+/*
+ * 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.jpegstream;
+
+import android.graphics.Point;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class JPEGInputStream extends FilterInputStream {
+ private long JNIPointer = 0; // Used by JNI code. Don't touch.
+
+ private boolean mValidConfig = false;
+ private boolean mConfigChanged = false;
+ private int mFormat = -1;
+ private byte[] mTmpBuffer = new byte[1];
+ private int mWidth = 0;
+ private int mHeight = 0;
+
+ public JPEGInputStream(InputStream in) {
+ super(in);
+ }
+
+ public JPEGInputStream(InputStream in, int format) {
+ super(in);
+ setConfig(format);
+ }
+
+ public boolean setConfig(int format) {
+ // Make sure format is valid
+ switch (format) {
+ case JpegConfig.FORMAT_GRAYSCALE:
+ case JpegConfig.FORMAT_RGB:
+ case JpegConfig.FORMAT_ABGR:
+ case JpegConfig.FORMAT_RGBA:
+ break;
+ default:
+ return false;
+ }
+ mFormat = format;
+ mValidConfig = true;
+ mConfigChanged = true;
+ return true;
+ }
+
+ public Point getDimensions() throws IOException {
+ if (mValidConfig) {
+ applyConfigChange();
+ return new Point(mWidth, mHeight);
+ }
+ return null;
+ }
+
+ @Override
+ public int available() {
+ return 0; // TODO
+ }
+
+ @Override
+ public void close() throws IOException {
+ cleanup();
+ super.close();
+ }
+
+ @Override
+ public synchronized void mark(int readlimit) {
+ // Do nothing
+ }
+
+ @Override
+ public boolean markSupported() {
+ return false;
+ }
+
+ @Override
+ public int read() throws IOException {
+ read(mTmpBuffer, 0, 1);
+ return 0xFF & mTmpBuffer[0];
+ }
+
+ @Override
+ public int read(byte[] buffer) throws IOException {
+ return read(buffer, 0, buffer.length);
+ }
+
+ @Override
+ public int read(byte[] buffer, int offset, int count) throws IOException {
+ if (offset < 0 || count < 0 || (offset + count) > buffer.length) {
+ throw new ArrayIndexOutOfBoundsException(String.format(
+ " buffer length %d, offset %d, length %d",
+ buffer.length, offset, count));
+ }
+ if (!mValidConfig) {
+ return 0;
+ }
+ applyConfigChange();
+ int flag = JpegConfig.J_ERROR_FATAL;
+ try {
+ flag = readDecodedBytes(buffer, offset, count);
+ } finally {
+ if (flag < 0) {
+ cleanup();
+ }
+ }
+ if (flag < 0) {
+ switch (flag) {
+ case JpegConfig.J_DONE:
+ return -1; // Returns -1 after reading EOS.
+ default:
+ throw new IOException("Error reading jpeg stream");
+ }
+ }
+ return flag;
+ }
+
+ @Override
+ public synchronized void reset() throws IOException {
+ throw new IOException("Reset not supported.");
+ }
+
+ @Override
+ public long skip(long byteCount) throws IOException {
+ if (byteCount <= 0) {
+ return 0;
+ }
+ // Shorten skip to a reasonable amount
+ int flag = skipDecodedBytes((int) (0x7FFFFFFF & byteCount));
+ if (flag < 0) {
+ switch (flag) {
+ case JpegConfig.J_DONE:
+ return 0; // Returns 0 after reading EOS.
+ default:
+ throw new IOException("Error skipping jpeg stream");
+ }
+ }
+ return flag;
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ cleanup();
+ } finally {
+ super.finalize();
+ }
+ }
+
+ private void applyConfigChange() throws IOException {
+ if (mConfigChanged) {
+ cleanup();
+ Point dimens = new Point(0, 0);
+ int flag = setup(dimens, in, mFormat);
+ switch(flag) {
+ case JpegConfig.J_SUCCESS:
+ break; // allow setup to continue
+ case JpegConfig.J_ERROR_BAD_ARGS:
+ throw new IllegalArgumentException("Bad arguments to read");
+ default:
+ throw new IOException("Error to reading jpeg headers.");
+ }
+ mWidth = dimens.x;
+ mHeight = dimens.y;
+ mConfigChanged = false;
+ }
+ }
+
+ native private int setup(Point dimens, InputStream in, int format);
+
+ native private void cleanup();
+
+ native private int readDecodedBytes( byte[] inBuffer, int offset, int inCount);
+
+ native private int skipDecodedBytes(int bytes);
+
+ static {
+ System.loadLibrary("jni_jpegstream");
+ }
+}
diff --git a/gallerycommon/src/com/android/gallery3d/jpegstream/JPEGOutputStream.java b/gallerycommon/src/com/android/gallery3d/jpegstream/JPEGOutputStream.java
new file mode 100644
index 0000000..c49d375
--- /dev/null
+++ b/gallerycommon/src/com/android/gallery3d/jpegstream/JPEGOutputStream.java
@@ -0,0 +1,144 @@
+/*
+ * 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.jpegstream;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+public class JPEGOutputStream extends FilterOutputStream {
+ private long JNIPointer = 0; // Used by JNI code. Don't touch.
+
+ private byte[] mTmpBuffer = new byte[1];
+ private int mWidth = 0;
+ private int mHeight = 0;
+ private int mQuality = 0;
+ private int mFormat = -1;
+ private boolean mValidConfig = false;
+ private boolean mConfigChanged = false;
+
+ public JPEGOutputStream(OutputStream out) {
+ super(out);
+ }
+
+ public JPEGOutputStream(OutputStream out, int width, int height, int quality,
+ int format) {
+ super(out);
+ setConfig(width, height, quality, format);
+ }
+
+ public boolean setConfig(int width, int height, int quality, int format) {
+ // Clamp quality to range (0, 100]
+ quality = Math.max(Math.min(quality, 100), 1);
+
+ // Make sure format is valid
+ switch (format) {
+ case JpegConfig.FORMAT_GRAYSCALE:
+ case JpegConfig.FORMAT_RGB:
+ case JpegConfig.FORMAT_ABGR:
+ case JpegConfig.FORMAT_RGBA:
+ break;
+ default:
+ return false;
+ }
+
+ // If valid, set configuration
+ if (width > 0 && height > 0) {
+ mWidth = width;
+ mHeight = height;
+ mFormat = format;
+ mQuality = quality;
+ mValidConfig = true;
+ mConfigChanged = true;
+ } else {
+ return false;
+ }
+
+ return mValidConfig;
+ }
+
+ @Override
+ public void close() throws IOException {
+ cleanup();
+ super.close();
+ }
+
+ @Override
+ public void write(byte[] buffer, int offset, int length) throws IOException {
+ if (offset < 0 || length < 0 || (offset + length) > buffer.length) {
+ throw new ArrayIndexOutOfBoundsException(String.format(
+ " buffer length %d, offset %d, length %d",
+ buffer.length, offset, length));
+ }
+ if (!mValidConfig) {
+ return;
+ }
+ if (mConfigChanged) {
+ cleanup();
+ int flag = setup(out, mWidth, mHeight, mFormat, mQuality);
+ switch(flag) {
+ case JpegConfig.J_SUCCESS:
+ break; // allow setup to continue
+ case JpegConfig.J_ERROR_BAD_ARGS:
+ throw new IllegalArgumentException("Bad arguments to write");
+ default:
+ throw new IOException("Error to writing jpeg headers.");
+ }
+ mConfigChanged = false;
+ }
+ int returnCode = JpegConfig.J_ERROR_FATAL;
+ try {
+ returnCode = writeInputBytes(buffer, offset, length);
+ } finally {
+ if (returnCode < 0) {
+ cleanup();
+ }
+ }
+ if (returnCode < 0) {
+ throw new IOException("Error writing jpeg stream");
+ }
+ }
+
+ @Override
+ public void write(byte[] buffer) throws IOException {
+ write(buffer, 0, buffer.length);
+ }
+
+ @Override
+ public void write(int oneByte) throws IOException {
+ mTmpBuffer[0] = (byte) oneByte;
+ write(mTmpBuffer);
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ cleanup();
+ } finally {
+ super.finalize();
+ }
+ }
+
+ native private int setup(OutputStream out, int width, int height, int format, int quality);
+
+ native private void cleanup();
+
+ native private int writeInputBytes(byte[] inBuffer, int offset, int inCount);
+
+ static {
+ System.loadLibrary("jni_jpegstream");
+ }
+}
diff --git a/gallerycommon/src/com/android/gallery3d/jpegstream/JpegConfig.java b/gallerycommon/src/com/android/gallery3d/jpegstream/JpegConfig.java
new file mode 100644
index 0000000..e514e3b
--- /dev/null
+++ b/gallerycommon/src/com/android/gallery3d/jpegstream/JpegConfig.java
@@ -0,0 +1,32 @@
+/*
+ * 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.jpegstream;
+
+public interface JpegConfig {
+ // Pixel formats
+ public static final int FORMAT_GRAYSCALE = 0x001; // 1 byte/pixel
+ public static final int FORMAT_RGB = 0x003; // 3 bytes/pixel RGBRGBRGBRGB...
+ public static final int FORMAT_RGBA = 0x004; // 4 bytes/pixel RGBARGBARGBARGBA...
+ public static final int FORMAT_ABGR = 0x104; // 4 bytes/pixel ABGRABGRABGR...
+
+ // Jni error codes
+ static final int J_SUCCESS = 0;
+ static final int J_ERROR_FATAL = -1;
+ static final int J_ERROR_BAD_ARGS = -2;
+ static final int J_EXCEPTION = -3;
+ static final int J_DONE = -4;
+}
diff --git a/gallerycommon/src/com/android/gallery3d/jpegstream/StreamUtils.java b/gallerycommon/src/com/android/gallery3d/jpegstream/StreamUtils.java
new file mode 100644
index 0000000..abd8f68
--- /dev/null
+++ b/gallerycommon/src/com/android/gallery3d/jpegstream/StreamUtils.java
@@ -0,0 +1,80 @@
+/*
+ * 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.jpegstream;
+
+import java.nio.ByteOrder;
+
+public class StreamUtils {
+
+ private StreamUtils() {
+ }
+
+ /**
+ * Copies the input byte array into the output int array with the given
+ * endianness. If input is not a multiple of 4, ignores the last 1-3 bytes
+ * and returns true.
+ */
+ public static boolean byteToIntArray(int[] output, byte[] input, ByteOrder endianness) {
+ int length = input.length - (input.length % 4);
+ if (output.length * 4 < length) {
+ throw new ArrayIndexOutOfBoundsException("Output array is too short to hold input");
+ }
+ if (endianness == ByteOrder.BIG_ENDIAN) {
+ for (int i = 0, j = 0; i < output.length; i++, j += 4) {
+ output[i] = ((input[j] & 0xFF) << 24) | ((input[j + 1] & 0xFF) << 16)
+ | ((input[j + 2] & 0xFF) << 8) | ((input[j + 3] & 0xFF));
+ }
+ } else {
+ for (int i = 0, j = 0; i < output.length; i++, j += 4) {
+ output[i] = ((input[j + 3] & 0xFF) << 24) | ((input[j + 2] & 0xFF) << 16)
+ | ((input[j + 1] & 0xFF) << 8) | ((input[j] & 0xFF));
+ }
+ }
+ return input.length % 4 != 0;
+ }
+
+ public static int[] byteToIntArray(byte[] input, ByteOrder endianness) {
+ int[] output = new int[input.length / 4];
+ byteToIntArray(output, input, endianness);
+ return output;
+ }
+
+ /**
+ * Uses native endianness.
+ */
+ public static int[] byteToIntArray(byte[] input) {
+ return byteToIntArray(input, ByteOrder.nativeOrder());
+ }
+
+ /**
+ * Returns the number of bytes in a pixel for a given format defined in
+ * JpegConfig.
+ */
+ public static int pixelSize(int format) {
+ switch (format) {
+ case JpegConfig.FORMAT_ABGR:
+ case JpegConfig.FORMAT_RGBA:
+ return 4;
+ case JpegConfig.FORMAT_RGB:
+ return 3;
+ case JpegConfig.FORMAT_GRAYSCALE:
+ return 1;
+ default:
+ return -1;
+ }
+ }
+}
diff --git a/jni/Android.mk b/jni/Android.mk
index e612486..0b8480e 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -37,7 +37,6 @@
filters/vibrance.c \
filters/geometry.c \
filters/negative.c \
- filters/vignette.c \
filters/redEyeMath.c \
filters/fx.c \
filters/wbalance.c \
diff --git a/jni/filters/fx.c b/jni/filters/fx.c
index 24fa5e0..c3c9cbd 100644
--- a/jni/filters/fx.c
+++ b/jni/filters/fx.c
@@ -29,7 +29,9 @@
return (int)frbg ;
}
-void JNIFUNCF(ImageFilterFx, nativeApplyFilter, jobject bitmap, jint width, jint height, jobject lutbitmap,jint lutwidth, jint lutheight )
+void JNIFUNCF(ImageFilterFx, nativeApplyFilter, jobject bitmap, jint width, jint height,
+ jobject lutbitmap, jint lutwidth, jint lutheight,
+ jint start, jint end)
{
char* destination = 0;
char* lut = 0;
@@ -58,9 +60,7 @@
float scale_B = (lutdim_b-1.f)/256.f;
int i;
- int len = width * height * STEP;
-
- for (i = 0; i < len; i+=STEP)
+ for (i = start; i < end; i+= STEP)
{
int r = rgb[RED];
int g = rgb[GREEN];
diff --git a/jni/filters/vignette.c b/jni/filters/vignette.c
deleted file mode 100644
index b9ee3ff..0000000
--- a/jni/filters/vignette.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.
- */
-
-#include "filters.h"
-#include <math.h>
-
-static int* gVignetteMap = 0;
-static int gVignetteWidth = 0;
-static int gVignetteHeight = 0;
-
-void JNIFUNCF(ImageFilterVignette, nativeApplyFilter, jobject bitmap, jint width, jint height, jint centerx, jint centery, jfloat radiusx, jfloat radiusy, jfloat strength)
-{
- char* destination = 0;
- AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
- int i;
- int len = width * height * 4;
- int vignette = 0;
- float d = centerx;
- if (radiusx == 0) radiusx = 10;
- if (radiusy == 0) radiusy = 10;
- float scalex = 1/radiusx;
- float scaley = 1/radiusy;
-
- for (i = 0; i < len; i += 4)
- {
- int p = i/4;
- float x = ((p%width)-centerx)*scalex;
- float y = ((p/width)-centery)*scaley;
- float dist = sqrt(x*x+y*y)-1;
- vignette = (int) (strength*256*MAX(dist,0));
- destination[RED] = CLAMP(destination[RED] - vignette);
- destination[GREEN] = CLAMP(destination[GREEN] - vignette);
- destination[BLUE] = CLAMP(destination[BLUE] - vignette);
- }
- AndroidBitmap_unlockPixels(env, bitmap);
-}
diff --git a/jni_jpegstream/Android.mk b/jni_jpegstream/Android.mk
new file mode 100644
index 0000000..2a09fb5
--- /dev/null
+++ b/jni_jpegstream/Android.mk
@@ -0,0 +1,37 @@
+LOCAL_PATH:= $(call my-dir)
+
+# Jpeg Streaming native
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libjni_jpegstream
+
+LOCAL_NDK_STL_VARIANT := stlport_static
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+ $(LOCAL_PATH)/src \
+ external/jpeg
+
+LOCAL_SHARED_LIBRARIES := libjpeg
+
+LOCAL_LDFLAGS := -llog
+LOCAL_SDK_VERSION := 9
+LOCAL_ARM_MODE := arm
+
+LOCAL_CFLAGS += -ffast-math -O3 -funroll-loops
+LOCAL_CPPFLAGS += $(JNI_CFLAGS)
+
+
+LOCAL_CPP_EXTENSION := .cpp
+LOCAL_SRC_FILES := \
+ src/inputstream_wrapper.cpp \
+ src/jpegstream.cpp \
+ src/jerr_hook.cpp \
+ src/jpeg_hook.cpp \
+ src/jpeg_writer.cpp \
+ src/jpeg_reader.cpp \
+ src/outputstream_wrapper.cpp \
+ src/stream_wrapper.cpp
+
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/jni_jpegstream/src/error_codes.h b/jni_jpegstream/src/error_codes.h
new file mode 100644
index 0000000..be55a00
--- /dev/null
+++ b/jni_jpegstream/src/error_codes.h
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+#ifndef JPEG_ERROR_CODES_H_
+#define JPEG_ERROR_CODES_H_
+
+#define J_DONE -4
+#define J_EXCEPTION -3
+#define J_ERROR_BAD_ARGS -2
+#define J_ERROR_FATAL -1
+#define J_SUCCESS 0
+
+#endif // JPEG_ERROR_CODES_H_
diff --git a/jni_jpegstream/src/inputstream_wrapper.cpp b/jni_jpegstream/src/inputstream_wrapper.cpp
new file mode 100644
index 0000000..98721b0
--- /dev/null
+++ b/jni_jpegstream/src/inputstream_wrapper.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#include "inputstream_wrapper.h"
+#include "error_codes.h"
+
+jmethodID InputStreamWrapper::sReadID = NULL;
+jmethodID InputStreamWrapper::sSkipID = NULL;
+
+int32_t InputStreamWrapper::read(int32_t length, int32_t offset) {
+ if (offset < 0 || length < 0 || (offset + length) > getBufferSize()) {
+ return J_ERROR_BAD_ARGS;
+ }
+ int32_t bytesRead = 0;
+ mEnv->ReleaseByteArrayElements(mByteArray, mBytes, JNI_COMMIT);
+ mBytes = NULL;
+ if (mEnv->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+ bytesRead = static_cast<int32_t>(mEnv->CallIntMethod(mStream, sReadID,
+ mByteArray, offset, length));
+ if (mEnv->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+ mBytes = mEnv->GetByteArrayElements(mByteArray, NULL);
+ if (mBytes == NULL || mEnv->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+ if (bytesRead == END_OF_STREAM) {
+ return J_DONE;
+ }
+ return bytesRead;
+}
+
+int64_t InputStreamWrapper::skip(int64_t count) {
+ int64_t bytesSkipped = 0;
+ bytesSkipped = static_cast<int64_t>(mEnv->CallLongMethod(mStream, sSkipID,
+ static_cast<jlong>(count)));
+ if (mEnv->ExceptionCheck() || bytesSkipped < 0) {
+ return J_EXCEPTION;
+ }
+ return bytesSkipped;
+}
+
+// Acts like a read call that returns the End Of Image marker for a JPEG file.
+int32_t InputStreamWrapper::forceReadEOI() {
+ mBytes[0] = (jbyte) 0xFF;
+ mBytes[1] = (jbyte) 0xD9;
+ return 2;
+}
+
+void InputStreamWrapper::setReadSkipMethodIDs(jmethodID readID,
+ jmethodID skipID) {
+ sReadID = readID;
+ sSkipID = skipID;
+}
diff --git a/jni_jpegstream/src/inputstream_wrapper.h b/jni_jpegstream/src/inputstream_wrapper.h
new file mode 100644
index 0000000..ed9942b
--- /dev/null
+++ b/jni_jpegstream/src/inputstream_wrapper.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#ifndef INPUTSTREAM_WRAPPER_H_
+#define INPUTSTREAM_WRAPPER_H_
+
+#include "jni_defines.h"
+#include "stream_wrapper.h"
+
+#include <stdint.h>
+
+class InputStreamWrapper : public StreamWrapper {
+public:
+ virtual int32_t read(int32_t length, int32_t offset);
+ virtual int64_t skip(int64_t count);
+ virtual int32_t forceReadEOI();
+
+ // Call this in JNI_OnLoad to cache read/skip method IDs
+ static void setReadSkipMethodIDs(jmethodID readID, jmethodID skipID);
+protected:
+ static jmethodID sReadID;
+ static jmethodID sSkipID;
+};
+
+#endif // INPUTSTREAM_WRAPPER_H_
diff --git a/jni_jpegstream/src/jerr_hook.cpp b/jni_jpegstream/src/jerr_hook.cpp
new file mode 100644
index 0000000..f8f864f
--- /dev/null
+++ b/jni_jpegstream/src/jerr_hook.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+
+#include "jerr_hook.h"
+#include "jni_defines.h"
+
+/**
+ * Replaces libjpeg's error_exit function, returns control to
+ * the point
+ */
+void ErrExit(j_common_ptr cinfo) {
+ ErrManager* mgr = reinterpret_cast<ErrManager*>(cinfo->err);
+ (*cinfo->err->output_message) (cinfo);
+ // Returns control to error handling in jpeg_writer
+ longjmp(mgr->setjmp_buf, 1);
+}
+
+/**
+ * Replaces libjpeg's output_message function, writes message
+ * to logcat's error log.
+ */
+void ErrOutput(j_common_ptr cinfo) {
+ ErrManager* mgr = reinterpret_cast<ErrManager*>(cinfo->err);
+ char buf[JMSG_LENGTH_MAX];
+ (*cinfo->err->format_message) (cinfo, buf);
+ buf[JMSG_LENGTH_MAX - 1] = '\0'; // Force null terminator
+ // Output error message in ndk logcat.
+ LOGE("%s\n", buf);
+}
+
+void SetupErrMgr(j_common_ptr cinfo, ErrManager* errMgr) {
+ jpeg_std_error(&(errMgr->mgr));
+ errMgr->mgr.error_exit = ErrExit;
+ errMgr->mgr.output_message = ErrOutput;
+ cinfo->err = reinterpret_cast<struct jpeg_error_mgr*>(errMgr);
+}
+
+
diff --git a/jni_jpegstream/src/jerr_hook.h b/jni_jpegstream/src/jerr_hook.h
new file mode 100644
index 0000000..f2ba7cd
--- /dev/null
+++ b/jni_jpegstream/src/jerr_hook.h
@@ -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.
+ */
+
+#ifndef JERR_HOOK_H_
+#define JERR_HOOK_H_
+
+extern "C" {
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jerror.h"
+}
+
+#include <setjmp.h>
+
+/**
+ * ErrManager replaces libjpeg's default error handling with
+ * the following behavior:
+ * - libjpeg function calls return to the position set by
+ * setjmp for error cleanup.
+ * - libjpeg error and warning messages are printed to
+ * logcat's error output.
+ */
+typedef struct {
+ struct jpeg_error_mgr mgr;
+ jmp_buf setjmp_buf;
+} ErrManager;
+
+void SetupErrMgr(j_common_ptr cinfo, ErrManager* errMgr);
+
+#endif // JERR_HOOK_H_
diff --git a/jni_jpegstream/src/jni_defines.h b/jni_jpegstream/src/jni_defines.h
new file mode 100644
index 0000000..8c9bd04
--- /dev/null
+++ b/jni_jpegstream/src/jni_defines.h
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+#ifndef JNIDEFINES_H
+#define JNIDEFINES_H
+
+
+#include <jni.h>
+#include <string.h>
+#include <android/log.h>
+
+#define LOGV(msg...) __android_log_print(ANDROID_LOG_VERBOSE, "Native_JPEGStream", msg)
+#define LOGE(msg...) __android_log_print(ANDROID_LOG_ERROR, "Native_JPEGStream", msg)
+#define LOGW(msg...) __android_log_print(ANDROID_LOG_WARN, "Native_JPEGStream", msg)
+
+#endif // JNIDEFINES_H
diff --git a/jni_jpegstream/src/jpeg_config.h b/jni_jpegstream/src/jpeg_config.h
new file mode 100644
index 0000000..a997552
--- /dev/null
+++ b/jni_jpegstream/src/jpeg_config.h
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+#ifndef JPEG_CONFIG_H_
+#define JPEG_CONFIG_H_
+namespace Jpeg_Config {
+
+// Pixel format
+enum Format {
+ FORMAT_GRAYSCALE = 0x001, // 1 byte/pixel
+ FORMAT_RGB = 0x003, // 3 bytes/pixel RGBRGBRGBRGB...
+ FORMAT_RGBA = 0x004, // 4 bytes/pixel RGBARGBARGBARGBA...
+ FORMAT_ABGR = 0x104 // 4 bytes/pixel ABGRABGRABGR...
+};
+
+} // end namespace Jpeg_Config
+
+#endif // JPEG_CONFIG_H_
diff --git a/jni_jpegstream/src/jpeg_hook.cpp b/jni_jpegstream/src/jpeg_hook.cpp
new file mode 100644
index 0000000..cca54e4
--- /dev/null
+++ b/jni_jpegstream/src/jpeg_hook.cpp
@@ -0,0 +1,198 @@
+/*
+ * 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.
+ */
+
+#include "error_codes.h"
+#include "jni_defines.h"
+#include "jpeg_hook.h"
+
+#include <stddef.h>
+#include <string.h>
+
+void Mgr_init_destination_fcn(j_compress_ptr cinfo) {
+ DestManager *dst = reinterpret_cast<DestManager*>(cinfo->dest);
+ dst->mgr.next_output_byte = reinterpret_cast<JOCTET*>(dst->outStream->getBufferPtr());
+ dst->mgr.free_in_buffer = dst->outStream->getBufferSize();
+}
+
+boolean Mgr_empty_output_buffer_fcn(j_compress_ptr cinfo) {
+ DestManager *dst = reinterpret_cast<DestManager*>(cinfo->dest);
+ int32_t len = dst->outStream->getBufferSize();
+ if (dst->outStream->write(len, 0) != J_SUCCESS) {
+ ERREXIT(cinfo, JERR_FILE_WRITE);
+ }
+ dst->mgr.next_output_byte = reinterpret_cast<JOCTET*>(dst->outStream->getBufferPtr());
+ dst->mgr.free_in_buffer = len;
+ return TRUE;
+}
+
+void Mgr_term_destination_fcn(j_compress_ptr cinfo) {
+ DestManager *dst = reinterpret_cast<DestManager*>(cinfo->dest);
+ int32_t remaining = dst->outStream->getBufferSize() - dst->mgr.free_in_buffer;
+ if (dst->outStream->write(remaining, 0) != J_SUCCESS) {
+ ERREXIT(cinfo, JERR_FILE_WRITE);
+ }
+}
+
+int32_t MakeDst(j_compress_ptr cinfo, JNIEnv *env, jobject outStream) {
+ if (cinfo->dest != NULL) {
+ LOGE("DestManager already exists, cannot allocate!");
+ return J_ERROR_FATAL;
+ } else {
+ size_t size = sizeof(DestManager);
+ cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_PERMANENT, size);
+ if (cinfo->dest == NULL) {
+ LOGE("Could not allocate memory for DestManager.");
+ return J_ERROR_FATAL;
+ }
+ memset(cinfo->dest, '0', size);
+ }
+ DestManager *d = reinterpret_cast<DestManager*>(cinfo->dest);
+ d->mgr.init_destination = Mgr_init_destination_fcn;
+ d->mgr.empty_output_buffer = Mgr_empty_output_buffer_fcn;
+ d->mgr.term_destination = Mgr_term_destination_fcn;
+ d->outStream = new OutputStreamWrapper();
+ if(d->outStream->init(env, outStream)) {
+ return J_SUCCESS;
+ }
+ return J_ERROR_FATAL;
+}
+
+void UpdateDstEnv(j_compress_ptr cinfo, JNIEnv* env) {
+ DestManager* d = reinterpret_cast<DestManager*>(cinfo->dest);
+ d->outStream->updateEnv(env);
+}
+
+void CleanDst(j_compress_ptr cinfo) {
+ if (cinfo != NULL && cinfo->dest != NULL) {
+ DestManager *d = reinterpret_cast<DestManager*>(cinfo->dest);
+ if (d->outStream != NULL) {
+ delete d->outStream;
+ d->outStream = NULL;
+ }
+ }
+}
+
+boolean Mgr_fill_input_buffer_fcn(j_decompress_ptr cinfo) {
+ SourceManager *src = reinterpret_cast<SourceManager*>(cinfo->src);
+ int32_t bytesRead = src->inStream->read(src->inStream->getBufferSize(), 0);
+ if (bytesRead == J_DONE) {
+ if (src->start_of_file == TRUE) {
+ ERREXIT(cinfo, JERR_INPUT_EMPTY);
+ }
+ WARNMS(cinfo, JWRN_JPEG_EOF);
+ bytesRead = src->inStream->forceReadEOI();
+ } else if (bytesRead < 0) {
+ ERREXIT(cinfo, JERR_FILE_READ);
+ } else if (bytesRead == 0) {
+ LOGW("read 0 bytes from InputStream.");
+ }
+ src->mgr.next_input_byte = reinterpret_cast<JOCTET*>(src->inStream->getBufferPtr());
+ src->mgr.bytes_in_buffer = bytesRead;
+ if (bytesRead != 0) {
+ src->start_of_file = FALSE;
+ }
+ return TRUE;
+}
+
+void Mgr_init_source_fcn(j_decompress_ptr cinfo) {
+ SourceManager *s = reinterpret_cast<SourceManager*>(cinfo->src);
+ s->start_of_file = TRUE;
+ Mgr_fill_input_buffer_fcn(cinfo);
+}
+
+void Mgr_skip_input_data_fcn(j_decompress_ptr cinfo, long num_bytes) {
+ // Cannot skip negative or 0 bytes.
+ if (num_bytes <= 0) {
+ LOGW("skipping 0 bytes in InputStream");
+ return;
+ }
+ SourceManager *src = reinterpret_cast<SourceManager*>(cinfo->src);
+ if (src->mgr.bytes_in_buffer >= num_bytes) {
+ src->mgr.bytes_in_buffer -= num_bytes;
+ src->mgr.next_input_byte += num_bytes;
+ } else {
+ // if skipping more bytes than remain in buffer, set skip_bytes
+ int64_t skip = num_bytes - src->mgr.bytes_in_buffer;
+ src->mgr.next_input_byte += src->mgr.bytes_in_buffer;
+ src->mgr.bytes_in_buffer = 0;
+ int64_t actual = src->inStream->skip(skip);
+ if (actual < 0) {
+ ERREXIT(cinfo, JERR_FILE_READ);
+ }
+ skip -= actual;
+ while (skip > 0) {
+ actual = src->inStream->skip(skip);
+ if (actual < 0) {
+ ERREXIT(cinfo, JERR_FILE_READ);
+ }
+ skip -= actual;
+ if (actual == 0) {
+ // Multiple zero byte skips, likely EOF
+ WARNMS(cinfo, JWRN_JPEG_EOF);
+ return;
+ }
+ }
+ }
+}
+
+void Mgr_term_source_fcn(j_decompress_ptr cinfo) {
+ //noop
+}
+
+int32_t MakeSrc(j_decompress_ptr cinfo, JNIEnv *env, jobject inStream){
+ if (cinfo->src != NULL) {
+ LOGE("SourceManager already exists, cannot allocate!");
+ return J_ERROR_FATAL;
+ } else {
+ size_t size = sizeof(SourceManager);
+ cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_PERMANENT, size);
+ if (cinfo->src == NULL) {
+ // Could not allocate memory.
+ LOGE("Could not allocate memory for SourceManager.");
+ return J_ERROR_FATAL;
+ }
+ memset(cinfo->src, '0', size);
+ }
+ SourceManager *s = reinterpret_cast<SourceManager*>(cinfo->src);
+ s->start_of_file = TRUE;
+ s->mgr.init_source = Mgr_init_source_fcn;
+ s->mgr.fill_input_buffer = Mgr_fill_input_buffer_fcn;
+ s->mgr.skip_input_data = Mgr_skip_input_data_fcn;
+ s->mgr.resync_to_restart = jpeg_resync_to_restart; // use default restart
+ s->mgr.term_source = Mgr_term_source_fcn;
+ s->inStream = new InputStreamWrapper();
+ if(s->inStream->init(env, inStream)) {
+ return J_SUCCESS;
+ }
+ return J_ERROR_FATAL;
+}
+
+void UpdateSrcEnv(j_decompress_ptr cinfo, JNIEnv* env) {
+ SourceManager* s = reinterpret_cast<SourceManager*>(cinfo->src);
+ s->inStream->updateEnv(env);
+}
+
+void CleanSrc(j_decompress_ptr cinfo) {
+ if (cinfo != NULL && cinfo->src != NULL) {
+ SourceManager *s = reinterpret_cast<SourceManager*>(cinfo->src);
+ if (s->inStream != NULL) {
+ delete s->inStream;
+ s->inStream = NULL;
+ }
+ }
+}
diff --git a/jni_jpegstream/src/jpeg_hook.h b/jni_jpegstream/src/jpeg_hook.h
new file mode 100644
index 0000000..b02bb34
--- /dev/null
+++ b/jni_jpegstream/src/jpeg_hook.h
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+#ifndef LIBJPEG_HOOK_H_
+#define LIBJPEG_HOOK_H_
+
+extern "C" {
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jerror.h"
+}
+
+#include "inputstream_wrapper.h"
+#include "outputstream_wrapper.h"
+
+#include <stdint.h>
+
+/**
+ * DestManager holds the libjpeg destination manager struct and
+ * a holder with a java OutputStream.
+ */
+typedef struct {
+ struct jpeg_destination_mgr mgr;
+ OutputStreamWrapper *outStream;
+} DestManager;
+
+// Initializes the DestManager struct, sets up the jni refs
+int32_t MakeDst(j_compress_ptr cinfo, JNIEnv *env, jobject outStream);
+
+/**
+ * Updates the jni env pointer. This should be called in the beginning of any
+ * JNI method in jpegstream.cpp before CleanDst or any of the libjpeg functions
+ * that can trigger a call to an OutputStreamWrapper method.
+ */
+void UpdateDstEnv(j_compress_ptr cinfo, JNIEnv* env);
+
+// Cleans the jni refs. To wipe the compress object call jpeg_destroy_compress
+void CleanDst(j_compress_ptr cinfo);
+
+/**
+ * SourceManager holds the libjpeg source manager struct and a
+ * holder with a java InputStream.
+ */
+typedef struct {
+ struct jpeg_source_mgr mgr;
+ boolean start_of_file;
+ InputStreamWrapper *inStream;
+} SourceManager;
+
+// Initializes the SourceManager struct, sets up the jni refs
+int32_t MakeSrc(j_decompress_ptr cinfo, JNIEnv *env, jobject inStream);
+
+/**
+ * Updates the jni env pointer. This should be called in the beginning of any
+ * JNI method in jpegstream.cpp before CleanSrc or any of the libjpeg functions
+ * that can trigger a call to an InputStreamWrapper method.
+ */
+void UpdateSrcEnv(j_decompress_ptr cinfo, JNIEnv* env);
+
+// Cleans the jni refs. To wipe the decompress object, call jpeg_destroy_decompress
+void CleanSrc(j_decompress_ptr cinfo);
+
+#endif // LIBJPEG_HOOK_H_
diff --git a/jni_jpegstream/src/jpeg_reader.cpp b/jni_jpegstream/src/jpeg_reader.cpp
new file mode 100644
index 0000000..4726b64
--- /dev/null
+++ b/jni_jpegstream/src/jpeg_reader.cpp
@@ -0,0 +1,254 @@
+/*
+ * 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.
+ */
+
+#include "jpeg_reader.h"
+#include "error_codes.h"
+#include "jpeg_hook.h"
+
+#include <setjmp.h>
+
+JpegReader::JpegReader() :
+ mInfo(),
+ mErrorManager(),
+ mScanlineBuf(NULL),
+ mScanlineIter(NULL),
+ mScanlineBuflen(0),
+ mScanlineUnformattedBuflen(0),
+ mScanlineBytesRemaining(0),
+ mFormat(),
+ mFinished(false),
+ mSetup(false) {}
+
+JpegReader::~JpegReader() {
+ if (reset() != J_SUCCESS) {
+ LOGE("Failed to destroy compress object, JpegReader may leak memory.");
+ }
+}
+
+int32_t JpegReader::setup(JNIEnv *env, jobject in, int32_t* width, int32_t* height,
+ Jpeg_Config::Format format) {
+ if (mFinished || mSetup) {
+ return J_ERROR_FATAL;
+ }
+ if (env->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+
+ // Setup error handler
+ SetupErrMgr(reinterpret_cast<j_common_ptr>(&mInfo), &mErrorManager);
+ // Set jump address for error handling
+ if (setjmp(mErrorManager.setjmp_buf)) {
+ return J_ERROR_FATAL;
+ }
+
+ // Call libjpeg setup
+ jpeg_create_decompress(&mInfo);
+
+ // Setup our data source object, this allocates java global references
+ int32_t flags = MakeSrc(&mInfo, env, in);
+ if (flags != J_SUCCESS) {
+ LOGE("Failed to make source with error code: %d ", flags);
+ return flags;
+ }
+
+ // Reads jpeg file header
+ jpeg_read_header(&mInfo, TRUE);
+ jpeg_calc_output_dimensions(&mInfo);
+
+ const int components = (static_cast<int>(format) & 0xff);
+
+ // Do setup for input format
+ switch (components) {
+ case 1:
+ mInfo.out_color_space = JCS_GRAYSCALE;
+ mScanlineUnformattedBuflen = mInfo.output_width;
+ break;
+ case 3:
+ case 4:
+ mScanlineUnformattedBuflen = mInfo.output_width * components;
+ if (mInfo.jpeg_color_space == JCS_CMYK
+ || mInfo.jpeg_color_space == JCS_YCCK) {
+ // Always use cmyk for output in a 4 channel jpeg.
+ // libjpeg has a builtin cmyk->rgb decoder.
+ mScanlineUnformattedBuflen = mInfo.output_width * 4;
+ mInfo.out_color_space = JCS_CMYK;
+ } else {
+ mInfo.out_color_space = JCS_RGB;
+ }
+ break;
+ default:
+ return J_ERROR_BAD_ARGS;
+ }
+
+ mScanlineBuflen = mInfo.output_width * components;
+ mScanlineBytesRemaining = mScanlineBuflen;
+ mScanlineBuf = (JSAMPLE *) (mInfo.mem->alloc_small)(
+ reinterpret_cast<j_common_ptr>(&mInfo), JPOOL_PERMANENT,
+ mScanlineUnformattedBuflen * sizeof(JSAMPLE));
+ mScanlineIter = mScanlineBuf;
+ jpeg_start_decompress(&mInfo);
+
+ // Output image dimensions
+ if (width != NULL) {
+ *width = mInfo.output_width;
+ }
+ if (height != NULL) {
+ *height = mInfo.output_height;
+ }
+
+ mFormat = format;
+ mSetup = true;
+ return J_SUCCESS;
+}
+
+int32_t JpegReader::read(int8_t* bytes, int32_t offset, int32_t count) {
+ if (!mSetup) {
+ return J_ERROR_FATAL;
+ }
+ if (mFinished) {
+ return J_DONE;
+ }
+ // Set jump address for error handling
+ if (setjmp(mErrorManager.setjmp_buf)) {
+ return J_ERROR_FATAL;
+ }
+ if (count <= 0) {
+ return J_ERROR_BAD_ARGS;
+ }
+ int32_t total_length = count;
+ while (mInfo.output_scanline < mInfo.output_height) {
+ if (count < mScanlineBytesRemaining) {
+ // read partial scanline and return
+ if (bytes != NULL) {
+ // Treat NULL bytes as a skip
+ memcpy((void*) (bytes + offset), (void*) mScanlineIter,
+ count * sizeof(int8_t));
+ }
+ mScanlineBytesRemaining -= count;
+ mScanlineIter += count;
+ return total_length;
+ } else if (count > 0) {
+ // read full scanline
+ if (bytes != NULL) {
+ // Treat NULL bytes as a skip
+ memcpy((void*) (bytes + offset), (void*) mScanlineIter,
+ mScanlineBytesRemaining * sizeof(int8_t));
+ bytes += mScanlineBytesRemaining;
+ }
+ count -= mScanlineBytesRemaining;
+ mScanlineBytesRemaining = 0;
+ }
+ // Scanline buffer exhausted, read next scanline
+ if (jpeg_read_scanlines(&mInfo, &mScanlineBuf, 1) != 1) {
+ // Always read full scanline, no IO suspension
+ return J_ERROR_FATAL;
+ }
+ // Do in-place pixel formatting
+ formatPixels(static_cast<uint8_t*>(mScanlineBuf),
+ mScanlineUnformattedBuflen);
+
+ // Reset iterators
+ mScanlineIter = mScanlineBuf;
+ mScanlineBytesRemaining = mScanlineBuflen;
+ }
+
+ // Read all of the scanlines
+ jpeg_finish_decompress(&mInfo);
+ mFinished = true;
+ return total_length - count;
+}
+
+void JpegReader::updateEnv(JNIEnv *env) {
+ UpdateSrcEnv(&mInfo, env);
+}
+
+// Does in-place pixel formatting
+void JpegReader::formatPixels(uint8_t* buf, int32_t len) {
+ uint8_t *iter = buf;
+
+ // Do cmyk->rgb conversion if necessary
+ switch (mInfo.out_color_space) {
+ case JCS_CMYK:
+ // Convert CMYK to RGB
+ int r, g, b, c, m, y, k;
+ for (int i = 0; i < len; i += 4) {
+ c = buf[i + 0];
+ m = buf[i + 1];
+ y = buf[i + 2];
+ k = buf[i + 3];
+ // Handle fmt for weird photoshop markers
+ if (mInfo.saw_Adobe_marker) {
+ r = (k * c) / 255;
+ g = (k * m) / 255;
+ b = (k * y) / 255;
+ } else {
+ r = (255 - k) * (255 - c) / 255;
+ g = (255 - k) * (255 - m) / 255;
+ b = (255 - k) * (255 - y) / 255;
+ }
+ *iter++ = r;
+ *iter++ = g;
+ *iter++ = b;
+ }
+ break;
+ case JCS_RGB:
+ iter += (len * 3 / 4);
+ break;
+ case JCS_GRAYSCALE:
+ default:
+ return;
+ }
+
+ // Do endianness and alpha for output format
+ if (mFormat == Jpeg_Config::FORMAT_RGBA) {
+ // Set alphas to 255
+ uint8_t* end = buf + len - 1;
+ for (int i = len - 1; i >= 0; i -= 4) {
+ buf[i] = 255;
+ buf[i - 1] = *--iter;
+ buf[i - 2] = *--iter;
+ buf[i - 3] = *--iter;
+ }
+ } else if (mFormat == Jpeg_Config::FORMAT_ABGR) {
+ // Reverse endianness and set alphas to 255
+ uint8_t* end = buf + len - 1;
+ int r, g, b;
+ for (int i = len - 1; i >= 0; i -= 4) {
+ b = *--iter;
+ g = *--iter;
+ r = *--iter;
+ buf[i] = r;
+ buf[i - 1] = g;
+ buf[i - 2] = b;
+ buf[i - 3] = 255;
+ }
+ }
+}
+
+int32_t JpegReader::reset() {
+ // Set jump address for error handling
+ if (setjmp(mErrorManager.setjmp_buf)) {
+ return J_ERROR_FATAL;
+ }
+ // Clean up global java references
+ CleanSrc(&mInfo);
+ // Wipe decompress struct, free memory pools
+ jpeg_destroy_decompress(&mInfo);
+ mFinished = false;
+ mSetup = false;
+ return J_SUCCESS;
+}
+
diff --git a/jni_jpegstream/src/jpeg_reader.h b/jni_jpegstream/src/jpeg_reader.h
new file mode 100644
index 0000000..afde27b
--- /dev/null
+++ b/jni_jpegstream/src/jpeg_reader.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef JPEG_READER_H_
+#define JPEG_READER_H_
+
+#include "jerr_hook.h"
+#include "jni_defines.h"
+#include "jpeg_config.h"
+
+#include <stdint.h>
+
+/**
+ * JpegReader wraps libjpeg's decompression functionality and a
+ * java InputStream object. Read calls return data from the
+ * InputStream that has been decompressed.
+ */
+class JpegReader {
+public:
+ JpegReader();
+ ~JpegReader();
+
+ /**
+ * Call setup with a valid InputStream reference and pixel format.
+ * If this method is successful, the contents of width and height will
+ * be set to the dimensions of the bitmap to be read.
+ *
+ * ***This method will result in the jpeg file header being read
+ * from the InputStream***
+ *
+ * Returns J_SUCCESS on success or a negative error code.
+ */
+ int32_t setup(JNIEnv *env, jobject in, int32_t* width, int32_t* height,
+ Jpeg_Config::Format format);
+
+ /**
+ * Decompresses bytes from the InputStream and writes at most count
+ * bytes into the buffer, bytes, starting at some offset. Passing a
+ * NULL as the bytes pointer effectively skips those bytes.
+ *
+ * ***This method will result in bytes being read from the InputStream***
+ *
+ * Returns the number of bytes written into the input buffer or a
+ * negative error code.
+ */
+ int32_t read(int8_t * bytes, int32_t offset, int32_t count);
+
+ /**
+ * Updates the environment pointer. Call this before read or reset
+ * in any jni function call.
+ */
+ void updateEnv(JNIEnv *env);
+
+ /**
+ * Frees any java global references held by the JpegReader, destroys
+ * the decompress structure, and frees allocations in libjpeg's pools.
+ */
+ int32_t reset();
+
+private:
+ void formatPixels(uint8_t* buf, int32_t len);
+ struct jpeg_decompress_struct mInfo;
+ ErrManager mErrorManager;
+
+ JSAMPLE* mScanlineBuf;
+ JSAMPLE* mScanlineIter;
+ int32_t mScanlineBuflen;
+ int32_t mScanlineUnformattedBuflen;
+ int32_t mScanlineBytesRemaining;
+
+ Jpeg_Config::Format mFormat;
+ bool mFinished;
+ bool mSetup;
+};
+
+#endif // JPEG_READER_H_
diff --git a/jni_jpegstream/src/jpeg_writer.cpp b/jni_jpegstream/src/jpeg_writer.cpp
new file mode 100644
index 0000000..4f78917
--- /dev/null
+++ b/jni_jpegstream/src/jpeg_writer.cpp
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ */
+
+#include "jpeg_hook.h"
+#include "jpeg_writer.h"
+#include "error_codes.h"
+
+#include <setjmp.h>
+#include <assert.h>
+
+JpegWriter::JpegWriter() : mInfo(),
+ mErrorManager(),
+ mScanlineBuf(NULL),
+ mScanlineIter(NULL),
+ mScanlineBuflen(0),
+ mScanlineBytesRemaining(0),
+ mFormat(),
+ mFinished(false),
+ mSetup(false) {}
+
+JpegWriter::~JpegWriter() {
+ if (reset() != J_SUCCESS) {
+ LOGE("Failed to destroy compress object, may leak memory.");
+ }
+}
+
+const int32_t JpegWriter::DEFAULT_X_DENSITY = 300;
+const int32_t JpegWriter::DEFAULT_Y_DENSITY = 300;
+const int32_t JpegWriter::DEFAULT_DENSITY_UNIT = 1;
+
+int32_t JpegWriter::setup(JNIEnv *env, jobject out, int32_t width, int32_t height,
+ Jpeg_Config::Format format, int32_t quality) {
+ if (mFinished || mSetup) {
+ return J_ERROR_FATAL;
+ }
+ if (env->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+ if (height <= 0 || width <= 0 || quality <= 0 || quality > 100) {
+ return J_ERROR_BAD_ARGS;
+ }
+ // Setup error handler
+ SetupErrMgr(reinterpret_cast<j_common_ptr>(&mInfo), &mErrorManager);
+
+ // Set jump address for error handling
+ if (setjmp(mErrorManager.setjmp_buf)) {
+ return J_ERROR_FATAL;
+ }
+
+ // Setup cinfo struct
+ jpeg_create_compress(&mInfo);
+
+ // Setup global java refs
+ int32_t flags = MakeDst(&mInfo, env, out);
+ if (flags != J_SUCCESS) {
+ return flags;
+ }
+
+ // Initialize width, height, and color space
+ mInfo.image_width = width;
+ mInfo.image_height = height;
+ const int components = (static_cast<int>(format) & 0xff);
+ switch (components) {
+ case 1:
+ mInfo.input_components = 1;
+ mInfo.in_color_space = JCS_GRAYSCALE;
+ break;
+ case 3:
+ case 4:
+ mInfo.input_components = 3;
+ mInfo.in_color_space = JCS_RGB;
+ break;
+ default:
+ return J_ERROR_BAD_ARGS;
+ }
+
+ // Set defaults
+ jpeg_set_defaults(&mInfo);
+ mInfo.density_unit = DEFAULT_DENSITY_UNIT; // JFIF code for pixel size units:
+ // 1 = in, 2 = cm
+ mInfo.X_density = DEFAULT_X_DENSITY; // Horizontal pixel density
+ mInfo.Y_density = DEFAULT_Y_DENSITY; // Vertical pixel density
+
+ // Set compress quality
+ jpeg_set_quality(&mInfo, quality, TRUE);
+
+ mFormat = format;
+
+ // Setup scanline buffer
+ mScanlineBuflen = width * components;
+ mScanlineBytesRemaining = mScanlineBuflen;
+ mScanlineBuf = (JSAMPLE *) (mInfo.mem->alloc_small)(
+ reinterpret_cast<j_common_ptr>(&mInfo), JPOOL_PERMANENT,
+ mScanlineBuflen * sizeof(JSAMPLE));
+ mScanlineIter = mScanlineBuf;
+
+ // Start compression
+ jpeg_start_compress(&mInfo, TRUE);
+ mSetup = true;
+ return J_SUCCESS;
+}
+
+int32_t JpegWriter::write(int8_t* bytes, int32_t length) {
+ if (!mSetup) {
+ return J_ERROR_FATAL;
+ }
+ if (mFinished) {
+ return 0;
+ }
+ // Set jump address for error handling
+ if (setjmp(mErrorManager.setjmp_buf)) {
+ return J_ERROR_FATAL;
+ }
+ if (length < 0 || bytes == NULL) {
+ return J_ERROR_BAD_ARGS;
+ }
+
+ int32_t total_length = length;
+ JSAMPROW row_pointer[1];
+ while (mInfo.next_scanline < mInfo.image_height) {
+ if (length < mScanlineBytesRemaining) {
+ // read partial scanline and return
+ memcpy((void*) mScanlineIter, (void*) bytes,
+ length * sizeof(int8_t));
+ mScanlineBytesRemaining -= length;
+ mScanlineIter += length;
+ return total_length;
+ } else if (length > 0) {
+ // read full scanline
+ memcpy((void*) mScanlineIter, (void*) bytes,
+ mScanlineBytesRemaining * sizeof(int8_t));
+ bytes += mScanlineBytesRemaining;
+ length -= mScanlineBytesRemaining;
+ mScanlineBytesRemaining = 0;
+ }
+ // Do in-place pixel formatting
+ formatPixels(static_cast<uint8_t*>(mScanlineBuf), mScanlineBuflen);
+ row_pointer[0] = mScanlineBuf;
+ // Do compression
+ if (jpeg_write_scanlines(&mInfo, row_pointer, 1) != 1) {
+ return J_ERROR_FATAL;
+ }
+ // Reset scanline buffer
+ mScanlineBytesRemaining = mScanlineBuflen;
+ mScanlineIter = mScanlineBuf;
+ }
+ jpeg_finish_compress(&mInfo);
+ mFinished = true;
+ return total_length - length;
+}
+
+// Does in-place pixel formatting
+void JpegWriter::formatPixels(uint8_t* buf, int32_t len) {
+ // Assumes len is a multiple of 4 for RGBA and ABGR pixels.
+ assert((len % 4) == 0);
+ uint8_t* d = buf;
+ switch (mFormat) {
+ case Jpeg_Config::FORMAT_RGBA: {
+ // Strips alphas
+ for (int i = 0; i < len / 4; ++i, buf += 4) {
+ *d++ = buf[0];
+ *d++ = buf[1];
+ *d++ = buf[2];
+ }
+ break;
+ }
+ case Jpeg_Config::FORMAT_ABGR: {
+ // Strips alphas and flips endianness
+ if (len / 4 >= 1) {
+ *d++ = buf[3];
+ uint8_t tmp = *d;
+ *d++ = buf[2];
+ *d++ = tmp;
+ }
+ for (int i = 1; i < len / 4; ++i, buf += 4) {
+ *d++ = buf[3];
+ *d++ = buf[2];
+ *d++ = buf[1];
+ }
+ break;
+ }
+ default: {
+ // Do nothing
+ break;
+ }
+ }
+}
+
+void JpegWriter::updateEnv(JNIEnv *env) {
+ UpdateDstEnv(&mInfo, env);
+}
+
+int32_t JpegWriter::reset() {
+ // Set jump address for error handling
+ if (setjmp(mErrorManager.setjmp_buf)) {
+ return J_ERROR_FATAL;
+ }
+ // Clean up global java references
+ CleanDst(&mInfo);
+ // Wipe compress struct, free memory pools
+ jpeg_destroy_compress(&mInfo);
+ mFinished = false;
+ mSetup = false;
+ return J_SUCCESS;
+}
diff --git a/jni_jpegstream/src/jpeg_writer.h b/jni_jpegstream/src/jpeg_writer.h
new file mode 100644
index 0000000..bd9a42d
--- /dev/null
+++ b/jni_jpegstream/src/jpeg_writer.h
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+#ifndef JPEG_WRITER_H_
+#define JPEG_WRITER_H_
+
+#include "jerr_hook.h"
+#include "jni_defines.h"
+#include "jpeg_config.h"
+
+#include <stdint.h>
+
+/**
+ * JpegWriter wraps libjpeg's compression functionality and a
+ * java OutputStream object. Write calls result in input data
+ * being compressed and written to the OuputStream.
+ */
+class JpegWriter {
+public:
+ JpegWriter();
+ ~JpegWriter();
+
+ /**
+ * Call setup with a valid OutputStream reference, bitmap height and
+ * width, pixel format, and compression quality in range (0, 100].
+ *
+ * Returns J_SUCCESS on success or a negative error code.
+ */
+ int32_t setup(JNIEnv *env, jobject out, int32_t width, int32_t height,
+ Jpeg_Config::Format format, int32_t quality);
+
+ /**
+ * Compresses bytes from the input buffer.
+ *
+ * ***This method will result in bytes being written to the OutputStream***
+ *
+ * Returns J_SUCCESS on success or a negative error code.
+ */
+ int32_t write(int8_t* bytes, int32_t length);
+
+ /**
+ * Updates the environment pointer. Call this before write or reset
+ * in any jni function call.
+ */
+ void updateEnv(JNIEnv *env);
+
+ /**
+ * Frees any java global references held by the JpegWriter, destroys
+ * the compress structure, and frees allocations in libjpeg's pools.
+ */
+ int32_t reset();
+
+ static const int32_t DEFAULT_X_DENSITY;
+ static const int32_t DEFAULT_Y_DENSITY;
+ static const int32_t DEFAULT_DENSITY_UNIT;
+private:
+ void formatPixels(uint8_t* buf, int32_t len);
+ struct jpeg_compress_struct mInfo;
+ ErrManager mErrorManager;
+
+ JSAMPLE* mScanlineBuf;
+ JSAMPLE* mScanlineIter;
+ int32_t mScanlineBuflen;
+ int32_t mScanlineBytesRemaining;
+
+ Jpeg_Config::Format mFormat;
+ bool mFinished;
+ bool mSetup;
+};
+
+#endif // JPEG_WRITER_H_
diff --git a/jni_jpegstream/src/jpegstream.cpp b/jni_jpegstream/src/jpegstream.cpp
new file mode 100644
index 0000000..3b9a683
--- /dev/null
+++ b/jni_jpegstream/src/jpegstream.cpp
@@ -0,0 +1,377 @@
+/*
+ * 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.
+ */
+
+#include "error_codes.h"
+#include "jni_defines.h"
+#include "jpeg_writer.h"
+#include "jpeg_reader.h"
+#include "jpeg_config.h"
+#include "outputstream_wrapper.h"
+#include "inputstream_wrapper.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static jint OutputStream_setup(JNIEnv* env, jobject thiz, jobject out,
+ jint width, jint height, jint format, jint quality) {
+ // Get a reference to this object's class
+ jclass thisClass = env->GetObjectClass(thiz);
+ if (env->ExceptionCheck() || thisClass == NULL) {
+ return J_EXCEPTION;
+ }
+ // Get field for storing C pointer
+ jfieldID fidNumber = env->GetFieldID(thisClass, "JNIPointer", "J");
+ if (NULL == fidNumber || env->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+
+ // Check size
+ if (width <= 0 || height <= 0) {
+ return J_ERROR_BAD_ARGS;
+ }
+ Jpeg_Config::Format fmt = static_cast<Jpeg_Config::Format>(format);
+ // Check format
+ switch (fmt) {
+ case Jpeg_Config::FORMAT_GRAYSCALE:
+ case Jpeg_Config::FORMAT_RGB:
+ case Jpeg_Config::FORMAT_RGBA:
+ case Jpeg_Config::FORMAT_ABGR:
+ break;
+ default:
+ return J_ERROR_BAD_ARGS;
+ }
+
+ uint32_t w = static_cast<uint32_t>(width);
+ uint32_t h = static_cast<uint32_t>(height);
+ int32_t q = static_cast<int32_t>(quality);
+ // Clamp quality to (0, 100]
+ q = (q > 100) ? 100 : ((q < 1) ? 1 : q);
+
+ JpegWriter* w_ptr = new JpegWriter();
+
+ // Do JpegWriter setup.
+ int32_t errorFlag = w_ptr->setup(env, out, w, h, fmt, q);
+ if (env->ExceptionCheck() || errorFlag != J_SUCCESS) {
+ delete w_ptr;
+ return errorFlag;
+ }
+
+ // Store C pointer for writer
+ env->SetLongField(thiz, fidNumber, reinterpret_cast<jlong>(w_ptr));
+ if (env->ExceptionCheck()) {
+ delete w_ptr;
+ return J_EXCEPTION;
+ }
+ return J_SUCCESS;
+}
+
+static jint InputStream_setup(JNIEnv* env, jobject thiz, jobject dimens,
+ jobject in, jint format) {
+ // Get a reference to this object's class
+ jclass thisClass = env->GetObjectClass(thiz);
+ if (env->ExceptionCheck() || thisClass == NULL) {
+ return J_EXCEPTION;
+ }
+ jmethodID setMethod = NULL;
+
+ // Get dimensions object setter method
+ if (dimens != NULL) {
+ jclass pointClass = env->GetObjectClass(dimens);
+ if (env->ExceptionCheck() || pointClass == NULL) {
+ return J_EXCEPTION;
+ }
+ setMethod = env->GetMethodID(pointClass, "set", "(II)V");
+ if (env->ExceptionCheck() || setMethod == NULL) {
+ return J_EXCEPTION;
+ }
+ }
+ // Get field for storing C pointer
+ jfieldID fidNumber = env->GetFieldID(thisClass, "JNIPointer", "J");
+ if (NULL == fidNumber || env->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+ Jpeg_Config::Format fmt = static_cast<Jpeg_Config::Format>(format);
+ // Check format
+ switch (fmt) {
+ case Jpeg_Config::FORMAT_GRAYSCALE:
+ case Jpeg_Config::FORMAT_RGB:
+ case Jpeg_Config::FORMAT_RGBA:
+ case Jpeg_Config::FORMAT_ABGR:
+ break;
+ default:
+ return J_ERROR_BAD_ARGS;
+ }
+
+ JpegReader* r_ptr = new JpegReader();
+ int32_t w = 0, h = 0;
+ // Do JpegReader setup.
+ int32_t errorFlag = r_ptr->setup(env, in, &w, &h, fmt);
+ if (env->ExceptionCheck() || errorFlag != J_SUCCESS) {
+ delete r_ptr;
+ return errorFlag;
+ }
+
+ // Set dimensions to return
+ if (dimens != NULL) {
+ env->CallVoidMethod(dimens, setMethod, static_cast<jint>(w),
+ static_cast<jint>(h));
+ if (env->ExceptionCheck()) {
+ delete r_ptr;
+ return J_EXCEPTION;
+ }
+ }
+ // Store C pointer for reader
+ env->SetLongField(thiz, fidNumber, reinterpret_cast<jlong>(r_ptr));
+ if (env->ExceptionCheck()) {
+ delete r_ptr;
+ return J_EXCEPTION;
+ }
+ return J_SUCCESS;
+}
+
+static JpegWriter* getWPtr(JNIEnv* env, jobject thiz, jfieldID* fid) {
+ jclass thisClass = env->GetObjectClass(thiz);
+ if (env->ExceptionCheck() || thisClass == NULL) {
+ return NULL;
+ }
+ jfieldID fidNumber = env->GetFieldID(thisClass, "JNIPointer", "J");
+ if (NULL == fidNumber || env->ExceptionCheck()) {
+ return NULL;
+ }
+ jlong ptr = env->GetLongField(thiz, fidNumber);
+ if (env->ExceptionCheck()) {
+ return NULL;
+ }
+ // Get writer C pointer out of java field.
+ JpegWriter* w_ptr = reinterpret_cast<JpegWriter*>(ptr);
+ if (fid != NULL) {
+ *fid = fidNumber;
+ }
+ return w_ptr;
+}
+
+static JpegReader* getRPtr(JNIEnv* env, jobject thiz, jfieldID* fid) {
+ jclass thisClass = env->GetObjectClass(thiz);
+ if (env->ExceptionCheck() || thisClass == NULL) {
+ return NULL;
+ }
+ jfieldID fidNumber = env->GetFieldID(thisClass, "JNIPointer", "J");
+ if (NULL == fidNumber || env->ExceptionCheck()) {
+ return NULL;
+ }
+ jlong ptr = env->GetLongField(thiz, fidNumber);
+ if (env->ExceptionCheck()) {
+ return NULL;
+ }
+ // Get reader C pointer out of java field.
+ JpegReader* r_ptr = reinterpret_cast<JpegReader*>(ptr);
+ if (fid != NULL) {
+ *fid = fidNumber;
+ }
+ return r_ptr;
+}
+
+static void OutputStream_cleanup(JNIEnv* env, jobject thiz) {
+ jfieldID fidNumber = NULL;
+ JpegWriter* w_ptr = getWPtr(env, thiz, &fidNumber);
+ if (w_ptr == NULL) {
+ return;
+ }
+ // Update environment
+ w_ptr->updateEnv(env);
+ // Destroy writer object
+ delete w_ptr;
+ w_ptr = NULL;
+ // Set the java field to null
+ env->SetLongField(thiz, fidNumber, reinterpret_cast<jlong>(w_ptr));
+}
+
+static void InputStream_cleanup(JNIEnv* env, jobject thiz) {
+ jfieldID fidNumber = NULL;
+ JpegReader* r_ptr = getRPtr(env, thiz, &fidNumber);
+ if (r_ptr == NULL) {
+ return;
+ }
+ // Update environment
+ r_ptr->updateEnv(env);
+ // Destroy the reader object
+ delete r_ptr;
+ r_ptr = NULL;
+ // Set the java field to null
+ env->SetLongField(thiz, fidNumber, reinterpret_cast<jlong>(r_ptr));
+}
+
+static jint OutputStream_writeInputBytes(JNIEnv* env, jobject thiz,
+ jbyteArray inBuffer, jint offset, jint inCount) {
+ JpegWriter* w_ptr = getWPtr(env, thiz, NULL);
+ if (w_ptr == NULL) {
+ return J_EXCEPTION;
+ }
+ // Pin input buffer
+ jbyte* in_buf = (jbyte*) env->GetByteArrayElements(inBuffer, 0);
+ if (env->ExceptionCheck() || in_buf == NULL) {
+ return J_EXCEPTION;
+ }
+
+ int8_t* in_bytes = static_cast<int8_t*>(in_buf);
+ int32_t in_len = static_cast<int32_t>(inCount);
+ int32_t off = static_cast<int32_t>(offset);
+ in_bytes += off;
+ int32_t written = 0;
+
+ // Update environment
+ w_ptr->updateEnv(env);
+ // Write out and unpin buffer.
+ written = w_ptr->write(in_bytes, in_len);
+ env->ReleaseByteArrayElements(inBuffer, in_buf, JNI_ABORT);
+ return written;
+}
+
+static jint InputStream_readDecodedBytes(JNIEnv* env, jobject thiz,
+ jbyteArray inBuffer, jint offset, jint inCount) {
+ JpegReader* r_ptr = getRPtr(env, thiz, NULL);
+ if (r_ptr == NULL) {
+ return J_EXCEPTION;
+ }
+ // Pin input buffer
+ jbyte* in_buf = (jbyte*) env->GetByteArrayElements(inBuffer, 0);
+ if (env->ExceptionCheck() || in_buf == NULL) {
+ return J_EXCEPTION;
+ }
+ int8_t* in_bytes = static_cast<int8_t*>(in_buf);
+ int32_t in_len = static_cast<int32_t>(inCount);
+ int32_t off = static_cast<int32_t>(offset);
+ int32_t read = 0;
+
+ // Update environment
+ r_ptr->updateEnv(env);
+ // Read into buffer
+ read = r_ptr->read(in_bytes, off, in_len);
+
+ // Unpin buffer
+ if (read < 0) {
+ env->ReleaseByteArrayElements(inBuffer, in_buf, JNI_ABORT);
+ } else {
+ env->ReleaseByteArrayElements(inBuffer, in_buf, JNI_COMMIT);
+ }
+ return read;
+}
+
+static jint InputStream_skipDecodedBytes(JNIEnv* env, jobject thiz,
+ jint bytes) {
+ if (bytes <= 0) {
+ return J_ERROR_BAD_ARGS;
+ }
+ JpegReader* r_ptr = getRPtr(env, thiz, NULL);
+ if (r_ptr == NULL) {
+ return J_EXCEPTION;
+ }
+
+ // Update environment
+ r_ptr->updateEnv(env);
+ int32_t skip = 0;
+ // Read with null buffer to skip
+ skip = r_ptr->read(NULL, 0, bytes);
+ return skip;
+}
+
+static const char *outClassPathName =
+ "com/android/gallery3d/jpegstream/JPEGOutputStream";
+static const char *inClassPathName =
+ "com/android/gallery3d/jpegstream/JPEGInputStream";
+
+static JNINativeMethod writeMethods[] = { { "setup",
+ "(Ljava/io/OutputStream;IIII)I", (void*) OutputStream_setup }, {
+ "cleanup", "()V", (void*) OutputStream_cleanup }, { "writeInputBytes",
+ "([BII)I", (void*) OutputStream_writeInputBytes } };
+
+static JNINativeMethod readMethods[] = { { "setup",
+ "(Landroid/graphics/Point;Ljava/io/InputStream;I)I",
+ (void*) InputStream_setup }, { "cleanup", "()V",
+ (void*) InputStream_cleanup }, { "readDecodedBytes", "([BII)I",
+ (void*) InputStream_readDecodedBytes }, { "skipDecodedBytes", "(I)I",
+ (void*) InputStream_skipDecodedBytes } };
+
+static int registerNativeMethods(JNIEnv* env, const char* className,
+ JNINativeMethod* gMethods, int numMethods) {
+ jclass clazz;
+ clazz = env->FindClass(className);
+ if (clazz == NULL) {
+ LOGE("Native registration unable to find class '%s'", className);
+ return JNI_FALSE;
+ }
+ if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
+ LOGE("RegisterNatives failed for '%s'", className);
+ return JNI_FALSE;
+ }
+ return JNI_TRUE;
+}
+
+jint JNI_OnLoad(JavaVM* vm, void* reserved) {
+ JNIEnv* env;
+ if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
+ LOGE("Error: GetEnv failed in JNI_OnLoad");
+ return -1;
+ }
+ if (!registerNativeMethods(env, outClassPathName, writeMethods,
+ sizeof(writeMethods) / sizeof(writeMethods[0]))) {
+ LOGE("Error: could not register native methods for JPEGOutputStream");
+ return -1;
+ }
+ if (!registerNativeMethods(env, inClassPathName, readMethods,
+ sizeof(readMethods) / sizeof(readMethods[0]))) {
+ LOGE("Error: could not register native methods for JPEGInputStream");
+ return -1;
+ }
+ // cache method IDs for OutputStream
+ jclass outCls = env->FindClass("java/io/OutputStream");
+ if (outCls == NULL) {
+ LOGE("Unable to find class 'OutputStream'");
+ return -1;
+ }
+ jmethodID cachedWriteFun = env->GetMethodID(outCls, "write", "([BII)V");
+ if (cachedWriteFun == NULL) {
+ LOGE("Unable to find write function in class 'OutputStream'");
+ return -1;
+ }
+ OutputStreamWrapper::setWriteMethodID(cachedWriteFun);
+
+ // cache method IDs for InputStream
+ jclass inCls = env->FindClass("java/io/InputStream");
+ if (inCls == NULL) {
+ LOGE("Unable to find class 'InputStream'");
+ return -1;
+ }
+ jmethodID cachedReadFun = env->GetMethodID(inCls, "read", "([BII)I");
+ if (cachedReadFun == NULL) {
+ LOGE("Unable to find read function in class 'InputStream'");
+ return -1;
+ }
+ jmethodID cachedSkipFun = env->GetMethodID(inCls, "skip", "(J)J");
+ if (cachedSkipFun == NULL) {
+ LOGE("Unable to find skip function in class 'InputStream'");
+ return -1;
+ }
+ InputStreamWrapper::setReadSkipMethodIDs(cachedReadFun, cachedSkipFun);
+ return JNI_VERSION_1_6;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/jni_jpegstream/src/outputstream_wrapper.cpp b/jni_jpegstream/src/outputstream_wrapper.cpp
new file mode 100644
index 0000000..0639b6e
--- /dev/null
+++ b/jni_jpegstream/src/outputstream_wrapper.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+#include "outputstream_wrapper.h"
+#include "error_codes.h"
+
+jmethodID OutputStreamWrapper::sWriteID = NULL;
+
+int32_t OutputStreamWrapper::write(int32_t length, int32_t offset) {
+ if (offset < 0 || length < 0 || (offset + length) > getBufferSize()) {
+ return J_ERROR_BAD_ARGS;
+ }
+ mEnv->ReleaseByteArrayElements(mByteArray, mBytes, JNI_COMMIT);
+ mBytes = NULL;
+ if (mEnv->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+ if (sWriteID == NULL) {
+ LOGE("Uninitialized method ID for OutputStream write function.");
+ return J_ERROR_FATAL;
+ }
+ // Call OutputStream write with byte array.
+ mEnv->CallVoidMethod(mStream, sWriteID, mByteArray, offset, length);
+ if (mEnv->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+ mBytes = mEnv->GetByteArrayElements(mByteArray, NULL);
+ if (mBytes == NULL || mEnv->ExceptionCheck()) {
+ return J_EXCEPTION;
+ }
+ return J_SUCCESS;
+}
+
+void OutputStreamWrapper::setWriteMethodID(jmethodID id) {
+ sWriteID = id;
+}
diff --git a/jni_jpegstream/src/outputstream_wrapper.h b/jni_jpegstream/src/outputstream_wrapper.h
new file mode 100644
index 0000000..9b8b007
--- /dev/null
+++ b/jni_jpegstream/src/outputstream_wrapper.h
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#ifndef OUTPUTSTREAM_WRAPPER_H_
+#define OUTPUTSTREAM_WRAPPER_H_
+
+#include "jni_defines.h"
+#include "stream_wrapper.h"
+
+#include <stdint.h>
+
+class OutputStreamWrapper : public StreamWrapper {
+public:
+ virtual int32_t write(int32_t length, int32_t offset);
+
+ // Call this in JNI_OnLoad to cache write method
+ static void setWriteMethodID(jmethodID id);
+protected:
+ static jmethodID sWriteID;
+};
+
+#endif // OUTPUTSTREAM_WRAPPER_H_
diff --git a/jni_jpegstream/src/stream_wrapper.cpp b/jni_jpegstream/src/stream_wrapper.cpp
new file mode 100644
index 0000000..049d84f
--- /dev/null
+++ b/jni_jpegstream/src/stream_wrapper.cpp
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+#include "stream_wrapper.h"
+
+const int32_t StreamWrapper::END_OF_STREAM = -1;
+const int32_t StreamWrapper::DEFAULT_BUFFER_SIZE = 1 << 16; // 64Kb
+
+StreamWrapper::StreamWrapper() : mEnv(NULL),
+ mStream(NULL),
+ mByteArray(NULL),
+ mBytes(NULL),
+ mByteArrayLen(0) {}
+
+StreamWrapper::~StreamWrapper() {
+ cleanup();
+}
+
+void StreamWrapper::updateEnv(JNIEnv *env) {
+ if (env == NULL) {
+ LOGE("Cannot update StreamWrapper with a null JNIEnv pointer!");
+ return;
+ }
+ mEnv = env;
+}
+
+bool StreamWrapper::init(JNIEnv *env, jobject stream) {
+ if (mEnv != NULL) {
+ LOGW("StreamWrapper already initialized!");
+ return false;
+ }
+ mEnv = env;
+ mStream = env->NewGlobalRef(stream);
+ if (mStream == NULL || env->ExceptionCheck()) {
+ cleanup();
+ return false;
+ }
+ mByteArrayLen = DEFAULT_BUFFER_SIZE;
+ jbyteArray tmp = env->NewByteArray(getBufferSize());
+ if (tmp == NULL || env->ExceptionCheck()){
+ cleanup();
+ return false;
+ }
+ mByteArray = reinterpret_cast<jbyteArray>(env->NewGlobalRef(tmp));
+ if (mByteArray == NULL || env->ExceptionCheck()){
+ cleanup();
+ return false;
+ }
+ mBytes = env->GetByteArrayElements(mByteArray, NULL);
+ if (mBytes == NULL || env->ExceptionCheck()){
+ cleanup();
+ return false;
+ }
+ return true;
+}
+
+void StreamWrapper::cleanup() {
+ if (mEnv != NULL) {
+ if (mStream != NULL) {
+ mEnv->DeleteGlobalRef(mStream);
+ mStream = NULL;
+ }
+ if (mByteArray != NULL) {
+ if (mBytes != NULL) {
+ mEnv->ReleaseByteArrayElements(mByteArray, mBytes, JNI_ABORT);
+ mBytes = NULL;
+ }
+ mEnv->DeleteGlobalRef(mByteArray);
+ mByteArray = NULL;
+ } else {
+ mBytes = NULL;
+ }
+ mByteArrayLen = 0;
+ mEnv = NULL;
+ }
+}
+
+int32_t StreamWrapper::getBufferSize() {
+ return mByteArrayLen;
+}
+
+jbyte* StreamWrapper::getBufferPtr() {
+ return mBytes;
+}
diff --git a/jni_jpegstream/src/stream_wrapper.h b/jni_jpegstream/src/stream_wrapper.h
new file mode 100644
index 0000000..e036a91
--- /dev/null
+++ b/jni_jpegstream/src/stream_wrapper.h
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#ifndef STREAM_WRAPPER_H_
+#define STREAM_WRAPPER_H_
+
+#include "jni_defines.h"
+
+#include <stdint.h>
+
+class StreamWrapper {
+public:
+ StreamWrapper();
+ virtual ~StreamWrapper();
+ virtual void updateEnv(JNIEnv *env);
+ virtual bool init(JNIEnv *env, jobject stream);
+ virtual void cleanup();
+ virtual int32_t getBufferSize();
+ virtual jbyte* getBufferPtr();
+
+ const static int32_t DEFAULT_BUFFER_SIZE;
+ const static int32_t END_OF_STREAM;
+protected:
+ JNIEnv *mEnv;
+ jobject mStream;
+ jbyteArray mByteArray;
+ jbyte* mBytes;
+ int32_t mByteArrayLen;
+};
+
+#endif // STREAM_WRAPPER_H_
diff --git a/jni_mosaic/Android.mk b/jni_mosaic/Android.mk
deleted file mode 100755
index 9f6f739..0000000
--- a/jni_mosaic/Android.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/feature_stab/db_vlvm \
- $(LOCAL_PATH)/feature_stab/src \
- $(LOCAL_PATH)/feature_stab/src/dbreg \
- $(LOCAL_PATH)/feature_mos/src \
- $(LOCAL_PATH)/feature_mos/src/mosaic
-
-LOCAL_CFLAGS := -O3 -DNDEBUG -fstrict-aliasing
-
-LOCAL_SRC_FILES := \
- feature_mos_jni.cpp \
- mosaic_renderer_jni.cpp \
- feature_mos/src/mosaic/trsMatrix.cpp \
- feature_mos/src/mosaic/AlignFeatures.cpp \
- feature_mos/src/mosaic/Blend.cpp \
- feature_mos/src/mosaic/Delaunay.cpp \
- feature_mos/src/mosaic/ImageUtils.cpp \
- feature_mos/src/mosaic/Mosaic.cpp \
- feature_mos/src/mosaic/Pyramid.cpp \
- feature_mos/src/mosaic_renderer/Renderer.cpp \
- feature_mos/src/mosaic_renderer/WarpRenderer.cpp \
- feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp \
- feature_mos/src/mosaic_renderer/YVURenderer.cpp \
- feature_mos/src/mosaic_renderer/FrameBuffer.cpp \
- feature_stab/db_vlvm/db_feature_detection.cpp \
- feature_stab/db_vlvm/db_feature_matching.cpp \
- feature_stab/db_vlvm/db_framestitching.cpp \
- feature_stab/db_vlvm/db_image_homography.cpp \
- feature_stab/db_vlvm/db_rob_image_homography.cpp \
- feature_stab/db_vlvm/db_utilities.cpp \
- feature_stab/db_vlvm/db_utilities_camera.cpp \
- feature_stab/db_vlvm/db_utilities_indexing.cpp \
- feature_stab/db_vlvm/db_utilities_linalg.cpp \
- feature_stab/db_vlvm/db_utilities_poly.cpp \
- feature_stab/src/dbreg/dbreg.cpp \
- feature_stab/src/dbreg/dbstabsmooth.cpp \
- feature_stab/src/dbreg/vp_motionmodel.c
-
-ifeq ($(TARGET_ARCH), arm)
- LOCAL_SDK_VERSION := 9
-endif
-
-ifeq ($(TARGET_ARCH), x86)
- LOCAL_SDK_VERSION := 9
-endif
-
-ifeq ($(TARGET_ARCH), mips)
- LOCAL_SDK_VERSION := 9
-endif
-
-LOCAL_LDFLAGS := -llog -lGLESv2
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := libjni_mosaic
-include $(BUILD_SHARED_LIBRARY)
diff --git a/jni_mosaic/NOTICE b/jni_mosaic/NOTICE
deleted file mode 100644
index 7317ae2..0000000
--- a/jni_mosaic/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2011, 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.
-
- 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.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/jni_mosaic/feature_mos/doc/Readme.txt b/jni_mosaic/feature_mos/doc/Readme.txt
deleted file mode 100644
index 83ce165..0000000
--- a/jni_mosaic/feature_mos/doc/Readme.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-To generate the html docs, execute
-doxygen feature_mos_API_doxyfile
-
diff --git a/jni_mosaic/feature_mos/doc/feature_mos_API_doxyfile b/jni_mosaic/feature_mos/doc/feature_mos_API_doxyfile
deleted file mode 100755
index dca8c8c..0000000
--- a/jni_mosaic/feature_mos/doc/feature_mos_API_doxyfile
+++ /dev/null
@@ -1,1557 +0,0 @@
-# Doxyfile 1.6.1
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all
-# text before the first occurrence of this tag. Doxygen uses libiconv (or the
-# iconv built into libc) for the transcoding. See
-# http://www.gnu.org/software/libiconv for the list of possible encodings.
-
-DOXYFILE_ENCODING = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME =
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER =
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY = .
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of
-# source files, where putting all generated files in the same directory would
-# otherwise cause performance problems for the file system.
-
-CREATE_SUBDIRS = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
-# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
-# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
-# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
-# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
-
-OUTPUT_LANGUAGE = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is
-# used as the annotated text. Otherwise, the brief description is used as-is.
-# If left blank, the following values are used ("$name" is automatically
-# replaced with the name of the entity): "The $name class" "The $name widget"
-# "The $name file" "is" "provides" "specifies" "contains"
-# "represents" "a" "an" "the"
-
-ABBREVIATE_BRIEF = "The $name class" \
- "The $name widget" \
- "The $name file" \
- is \
- provides \
- specifies \
- contains \
- represents \
- a \
- an \
- the
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-
-INLINE_INHERITED_MEMB = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip.
-
-STRIP_FROM_PATH = /Users/dimitri/doxygen/mail/1.5.7/doxywizard/
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
-
-STRIP_FROM_INC_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like regular Qt-style comments
-# (thus requiring an explicit @brief command for a brief description.)
-
-JAVADOC_AUTOBRIEF = NO
-
-# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
-# interpret the first line (until the first dot) of a Qt-style
-# comment as the brief description. If set to NO, the comments
-# will behave just like regular Qt-style comments (thus requiring
-# an explicit \brief command for a brief description.)
-
-QT_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
-
-INHERIT_DOCS = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
-# a new page for each member. If set to NO, the documentation of a member will
-# be part of the file/class/namespace that contains it.
-
-SEPARATE_MEMBER_PAGES = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE = 8
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
-# sources only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C = NO
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
-# sources only. Doxygen will then generate output that is more tailored for
-# Java. For instance, namespaces will be presented as packages, qualified
-# scopes will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
-# sources only. Doxygen will then generate output that is more tailored for
-# Fortran.
-
-OPTIMIZE_FOR_FORTRAN = NO
-
-# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
-# sources. Doxygen will then generate output that is tailored for
-# VHDL.
-
-OPTIMIZE_OUTPUT_VHDL = NO
-
-# Doxygen selects the parser to use depending on the extension of the files it parses.
-# With this tag you can assign which parser to use for a given extension.
-# Doxygen has a built-in mapping, but you can override or extend it using this tag.
-# The format is ext=language, where ext is a file extension, and language is one of
-# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
-# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
-# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
-# use: inc=Fortran f=C. Note that for custom extensions you also need to set
-# FILE_PATTERNS otherwise the files are not read by doxygen.
-
-EXTENSION_MAPPING =
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
-# to include (a tag file for) the STL sources as input, then you should
-# set this tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-
-BUILTIN_STL_SUPPORT = NO
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
-# enable parsing support.
-
-CPP_CLI_SUPPORT = NO
-
-# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
-# Doxygen will parse them like normal C++ but will assume all classes use public
-# instead of private inheritance when no explicit protection keyword is present.
-
-SIP_SUPPORT = NO
-
-# For Microsoft's IDL there are propget and propput attributes to indicate getter
-# and setter methods for a property. Setting this option to YES (the default)
-# will make doxygen to replace the get and set methods by a property in the
-# documentation. This will only work if the methods are indeed getting or
-# setting a simple type. If this is not the case, or you want to show the
-# methods anyway, you should set this option to NO.
-
-IDL_PROPERTY_SUPPORT = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING = YES
-
-# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
-# is documented as struct, union, or enum with the name of the typedef. So
-# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
-# with name TypeT. When disabled the typedef will appear as a member of a file,
-# namespace, or class. And the struct will be named TypeS. This can typically
-# be useful for C code in case the coding convention dictates that all compound
-# types are typedef'ed and only the typedef is referenced, never the tag name.
-
-TYPEDEF_HIDES_STRUCT = NO
-
-# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
-# determine which symbols to keep in memory and which to flush to disk.
-# When the cache is full, less often used symbols will be written to disk.
-# For small to medium size projects (<1000 input files) the default value is
-# probably good enough. For larger projects a too small cache size can cause
-# doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penality.
-# If the system has enough physical memory increasing the cache will improve the
-# performance by keeping more symbols in memory. Note that the value works on
-# a logarithmic scale so increasing the size by one will rougly double the
-# memory usage. The cache size is given by this formula:
-# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols
-
-SYMBOL_CACHE_SIZE = 0
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL = NO
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE = NO
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC = NO
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES = YES
-
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
-
-EXTRACT_LOCAL_METHODS = NO
-
-# If this flag is set to YES, the members of anonymous namespaces will be
-# extracted and appear in the documentation as a namespace called
-# 'anonymous_namespace{file}', where file will be replaced with the base
-# name of the file that contains the anonymous namespace. By default
-# anonymous namespace are hidden.
-
-EXTRACT_ANON_NSPACES = NO
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES = NO
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
-
-SORT_BRIEF_DOCS = NO
-
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
-# will sort the (brief and detailed) documentation of class members so that
-# constructors and destructors are listed first. If set to NO (the default)
-# the constructors will appear in the respective orders defined by
-# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
-# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
-# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
-
-SORT_MEMBERS_CTORS_1ST = NO
-
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
-# hierarchy of group names into alphabetical order. If set to NO (the default)
-# the group names will appear in their defined order.
-
-SORT_GROUP_NAMES = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
-
-SORT_BY_SCOPE_NAME = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES = YES
-
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES = NO
-
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
-# This will remove the Files entry from the Quick Index and from the
-# Folder Tree View (if specified). The default is YES.
-
-SHOW_FILES = YES
-
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
-# Namespaces page. This will remove the Namespaces entry from the Quick Index
-# and from the Folder Tree View (if specified). The default is YES.
-
-SHOW_NAMESPACES = YES
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from
-# the version control system). Doxygen will invoke the program by executing (via
-# popen()) the command <command> <input-file>, where <command> is the value of
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
-# provided by doxygen. Whatever the program writes to standard output
-# is used as the file version. See the manual for examples.
-
-FILE_VERSION_FILTER =
-
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
-# doxygen. The layout file controls the global structure of the generated output files
-# in an output format independent way. The create the layout file that represents
-# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
-# file name after the option, if omitted DoxygenLayout.xml will be used as the name
-# of the layout file.
-
-LAYOUT_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET = NO
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR = YES
-
-# This WARN_NO_PARAMDOC option can be abled to get warnings for
-# functions that are documented, but have no documentation for their parameters
-# or return value. If set to NO (the default) doxygen will only warn about
-# wrong or incomplete parameter documentation, but not about the absence of
-# documentation.
-
-WARN_NO_PARAMDOC = NO
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text. Optionally the format may contain
-# $version, which will be replaced by the version of the file (if it could
-# be obtained via FILE_VERSION_FILTER)
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT = ../src/mosaic/Mosaic.h
-
-# This tag can be used to specify the character encoding of the source files
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
-# also the default input encoding. Doxygen uses libiconv (or the iconv built
-# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
-# the list of possible encodings.
-
-INPUT_ENCODING = UTF-8
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-
-FILE_PATTERNS = *.c \
- *.cc \
- *.cxx \
- *.cpp \
- *.c++ \
- *.d \
- *.java \
- *.ii \
- *.ixx \
- *.ipp \
- *.i++ \
- *.inl \
- *.h \
- *.hh \
- *.hxx \
- *.hpp \
- *.h++ \
- *.idl \
- *.odl \
- *.cs \
- *.php \
- *.php3 \
- *.inc \
- *.m \
- *.mm \
- *.dox \
- *.py \
- *.f90 \
- *.f \
- *.vhd \
- *.vhdl
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE =
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
-# from the input.
-
-EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories. Note that the wildcards are matched
-# against the file with absolute path, so to exclude all test directories
-# for example use the pattern */test/*
-
-EXCLUDE_PATTERNS =
-
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
-# (namespaces, classes, functions, etc.) that should be excluded from the
-# output. The symbol name can be a fully qualified name, a word, or if the
-# wildcard * is used, a substring. Examples: ANamespace, AClass,
-# AClass::ANamespace, ANamespace::*Test
-
-EXCLUDE_SYMBOLS =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS = *
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output. If FILTER_PATTERNS is specified, this tag will be
-# ignored.
-
-INPUT_FILTER =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis. Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match. The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
-
-FILTER_PATTERNS =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
-
-SOURCE_BROWSER = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = NO
-
-# If the REFERENCES_RELATION tag is set to YES
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION = NO
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code. Otherwise they will link to the documentation.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code
-# will point to the HTML generated by the htags(1) tool instead of doxygen
-# built-in source browser. The htags tool is part of GNU's global source
-# tagging system (see http://www.gnu.org/software/global/global.html). You
-# will need version 4.8.6 or higher.
-
-USE_HTAGS = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX = NO
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER =
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet. Note that doxygen will try to copy
-# the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET =
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS = YES
-
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
-# documentation will contain sections that can be hidden and shown after the
-# page has loaded. For this to work a browser that supports
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
-
-HTML_DYNAMIC_SECTIONS = NO
-
-# If the GENERATE_DOCSET tag is set to YES, additional index files
-# will be generated that can be used as input for Apple's Xcode 3
-# integrated development environment, introduced with OSX 10.5 (Leopard).
-# To create a documentation set, doxygen will generate a Makefile in the
-# HTML output directory. Running make will produce the docset in that
-# directory and running "make install" will install the docset in
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
-# it at startup.
-# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
-
-GENERATE_DOCSET = NO
-
-# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
-# feed. A documentation feed provides an umbrella under which multiple
-# documentation sets from a single provider (such as a company or product suite)
-# can be grouped.
-
-DOCSET_FEEDNAME = "Doxygen generated docs"
-
-# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
-# should uniquely identify the documentation set bundle. This should be a
-# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
-# will append .docset to the name.
-
-DOCSET_BUNDLE_ID = org.doxygen.Project
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output directory.
-
-CHM_FILE =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
-# is used to encode HtmlHelp index (hhk), content (hhc) and project file
-# content.
-
-CHM_INDEX_ENCODING =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND = NO
-
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
-# are set, an additional index file will be generated that can be used as input for
-# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
-# HTML documentation.
-
-GENERATE_QHP = NO
-
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
-# be used to specify the file name of the resulting .qch file.
-# The path specified is relative to the HTML output folder.
-
-QCH_FILE =
-
-# The QHP_NAMESPACE tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#namespace
-
-QHP_NAMESPACE =
-
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#virtual-folders
-
-QHP_VIRTUAL_FOLDER = doc
-
-# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
-# For more information please see
-# http://doc.trolltech.com/qthelpproject.html#custom-filters
-
-QHP_CUST_FILTER_NAME =
-
-# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
-# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
-
-QHP_CUST_FILTER_ATTRS =
-
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
-# filter section matches.
-# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
-
-QHP_SECT_FILTER_ATTRS =
-
-# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
-# be used to specify the location of Qt's qhelpgenerator.
-# If non-empty doxygen will try to run qhelpgenerator on the generated
-# .qhp file.
-
-QHG_LOCATION =
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE = 4
-
-# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
-# structure should be generated to display hierarchical information.
-# If the tag value is set to YES, a side panel will be generated
-# containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
-# Windows users are probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW = NO
-
-# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
-# and Class Hierarchy pages using a tree view instead of an ordered list.
-
-USE_INLINE_TREES = NO
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH = 250
-
-# Use this tag to change the font size of Latex formulas included
-# as images in the HTML documentation. The default is 10. Note that
-# when you change the font size after a successful doxygen run you need
-# to manually remove any form_*.png images from the HTML output directory
-# to force them to be regenerated.
-
-FORMULA_FONTSIZE = 10
-
-# When the SEARCHENGINE tag is enable doxygen will generate a search box
-# for the HTML output. The underlying search engine uses javascript
-# and DHTML and should work on any modern browser. Note that when using
-# HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP)
-# there is already a search function so this one should typically
-# be disabled.
-
-SEARCHENGINE = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-
-LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS = YES
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX = YES
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES = NO
-
-# If LATEX_SOURCE_CODE is set to YES then doxygen will include
-# source code with syntax highlighting in the LaTeX output.
-# Note that which sources are shown also depends on other settings
-# such as SOURCE_BROWSER.
-
-LATEX_SOURCE_CODE = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
-
-XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader. This is useful
-# if you want to understand what is going on. On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_DEFINED tags.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed. To prevent a macro definition from being
-# undefined via #undef or recursively expanded use the := operator
-# instead of the = operator.
-
-PREDEFINED =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
-# or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option is superseded by the HAVE_DOT option below. This is only a
-# fallback. It is recommended to install and use dot, since it yields more
-# powerful graphs.
-
-CLASS_DIAGRAMS = YES
-
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see
-# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT = NO
-
-# By default doxygen will write a font called FreeSans.ttf to the output
-# directory and reference it in all dot files that doxygen generates. This
-# font does not include all possible unicode characters however, so when you need
-# these (or just want a differently looking font) you can specify the font name
-# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
-# which can be done by putting it in a standard location or by setting the
-# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
-# containing the font.
-
-DOT_FONTNAME = FreeSans
-
-# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
-# The default size is 10pt.
-
-DOT_FONTSIZE = 10
-
-# By default doxygen will tell dot to use the output directory to look for the
-# FreeSans.ttf font (which doxygen will put there itself). If you specify a
-# different font using DOT_FONTNAME you can set the path where dot
-# can find it using this tag.
-
-DOT_FONTPATH =
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH = YES
-
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for groups, showing the direct groups dependencies
-
-GROUP_GRAPHS = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH and HAVE_DOT options are set to YES then
-# doxygen will generate a call dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable call graphs
-# for selected functions only using the \callgraph command.
-
-CALL_GRAPH = NO
-
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
-# doxygen will generate a caller dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable caller
-# graphs for selected functions only using the \callergraph command.
-
-CALLER_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
-# then doxygen will show the dependencies a directory has on other directories
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
-
-DIRECTORY_GRAPH = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-
-DOT_PATH =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS =
-
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
-# nodes that will be shown in the graph. If the number of nodes in a graph
-# becomes larger than this value, doxygen will truncate the graph, which is
-# visualized by representing a node as a red box. Note that doxygen if the
-# number of direct children of the root node in a graph is already larger than
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
-# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
-
-DOT_GRAPH_MAX_NODES = 50
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes
-# that lay further from the root node will be omitted. Note that setting this
-# option to 1 or 2 may greatly reduce the computation time needed for large
-# code bases. Also note that the size of a graph can be further restricted by
-# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
-
-MAX_DOT_GRAPH_DEPTH = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, because dot on Windows does not
-# seem to support this out of the box. Warning: Depending on the platform used,
-# enabling this option may lead to badly anti-aliased labels on the edges of
-# a graph (i.e. they become hard to read).
-
-DOT_TRANSPARENT = NO
-
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10)
-# support this, this feature is disabled by default.
-
-DOT_MULTI_TARGETS = NO
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP = YES
diff --git a/jni_mosaic/feature_mos/src/mosaic/AlignFeatures.cpp b/jni_mosaic/feature_mos/src/mosaic/AlignFeatures.cpp
deleted file mode 100644
index aeabf8f..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/AlignFeatures.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// AlignFeatures.cpp
-// S.O. # :
-// Author(s): zkira, mbansal, bsouthall, narodits
-// $Id: AlignFeatures.cpp,v 1.20 2011/06/17 13:35:47 mbansal Exp $
-
-#include <stdio.h>
-#include <string.h>
-
-#include "trsMatrix.h"
-#include "MatrixUtils.h"
-#include "AlignFeatures.h"
-#include "Log.h"
-
-#define LOG_TAG "AlignFeatures"
-
-Align::Align()
-{
- width = height = 0;
- frame_number = 0;
- num_frames_captured = 0;
- reference_frame_index = 0;
- db_Identity3x3(Hcurr);
- db_Identity3x3(Hprev);
-}
-
-Align::~Align()
-{
- // Free gray-scale image
- if (imageGray != ImageUtils::IMAGE_TYPE_NOIMAGE)
- ImageUtils::freeImage(imageGray);
-}
-
-char* Align::getRegProfileString()
-{
- return reg.profile_string;
-}
-
-int Align::initialize(int width, int height, bool _quarter_res, float _thresh_still)
-{
- int nr_corners = DEFAULT_NR_CORNERS;
- double max_disparity = DEFAULT_MAX_DISPARITY;
- int motion_model_type = DEFAULT_MOTION_MODEL;
- int nrsamples = DB_DEFAULT_NR_SAMPLES;
- double scale = DB_POINT_STANDARDDEV;
- int chunk_size = DB_DEFAULT_CHUNK_SIZE;
- int nrhorz = width/48; // Empirically determined number of horizontal
- int nrvert = height/60; // and vertical buckets for harris corner detection.
- bool linear_polish = false;
- unsigned int reference_update_period = DEFAULT_REFERENCE_UPDATE_PERIOD;
-
- const bool DEFAULT_USE_SMALLER_MATCHING_WINDOW = false;
- bool use_smaller_matching_window = DEFAULT_USE_SMALLER_MATCHING_WINDOW;
-
- quarter_res = _quarter_res;
- thresh_still = _thresh_still;
-
- frame_number = 0;
- num_frames_captured = 0;
- reference_frame_index = 0;
- db_Identity3x3(Hcurr);
- db_Identity3x3(Hprev);
-
- if (!reg.Initialized())
- {
- reg.Init(width, height, motion_model_type, 20, linear_polish, quarter_res,
- scale, reference_update_period, false, 0, nrsamples, chunk_size,
- nr_corners, max_disparity, use_smaller_matching_window,
- nrhorz, nrvert);
- }
- this->width = width;
- this->height = height;
-
- imageGray = ImageUtils::allocateImage(width, height, 1);
-
- if (reg.Initialized())
- return ALIGN_RET_OK;
- else
- return ALIGN_RET_ERROR;
-}
-
-int Align::addFrameRGB(ImageType imageRGB)
-{
- ImageUtils::rgb2gray(imageGray, imageRGB, width, height);
- return addFrame(imageGray);
-}
-
-int Align::addFrame(ImageType imageGray_)
-{
- int ret_code = ALIGN_RET_OK;
-
- // Obtain a vector of pointers to rows in image and pass in to dbreg
- ImageType *m_rows = ImageUtils::imageTypeToRowPointers(imageGray_, width, height);
-
- if (frame_number == 0)
- {
- reg.AddFrame(m_rows, Hcurr, true); // Force this to be a reference frame
- int num_corner_ref = reg.GetNrRefCorners();
-
- if (num_corner_ref < MIN_NR_REF_CORNERS)
- {
- return ALIGN_RET_LOW_TEXTURE;
- }
- }
- else
- {
- reg.AddFrame(m_rows, Hcurr, false);
- }
-
- // Average translation per frame =
- // [Translation from Frame0 to Frame(n-1)] / [(n-1)]
- average_tx_per_frame = (num_frames_captured < 2) ? 0.0 :
- Hprev[2] / (num_frames_captured - 1);
-
- // Increment the captured frame counter if we already have a reference frame
- num_frames_captured++;
-
- if (frame_number != 0)
- {
- int num_inliers = reg.GetNrInliers();
-
- if(num_inliers < MIN_NR_INLIERS)
- {
- ret_code = ALIGN_RET_FEW_INLIERS;
-
- Hcurr[0] = 1.0;
- Hcurr[1] = 0.0;
- // Set this as the average per frame translation taking into acccount
- // the separation of the current frame from the reference frame...
- Hcurr[2] = -average_tx_per_frame *
- (num_frames_captured - reference_frame_index);
- Hcurr[3] = 0.0;
- Hcurr[4] = 1.0;
- Hcurr[5] = 0.0;
- Hcurr[6] = 0.0;
- Hcurr[7] = 0.0;
- Hcurr[8] = 1.0;
- }
-
- if(fabs(Hcurr[2])<thresh_still && fabs(Hcurr[5])<thresh_still) // Still camera
- {
- return ALIGN_RET_ERROR;
- }
-
- // compute the homography:
- double Hinv33[3][3];
- double Hprev33[3][3];
- double Hcurr33[3][3];
-
- // Invert and multiple with previous transformation
- Matrix33::convert9to33(Hcurr33, Hcurr);
- Matrix33::convert9to33(Hprev33, Hprev);
- normProjMat33d(Hcurr33);
-
- inv33d(Hcurr33, Hinv33);
-
- mult33d(Hcurr33, Hprev33, Hinv33);
- normProjMat33d(Hcurr33);
- Matrix9::convert33to9(Hprev, Hcurr33);
- // Since we have already factored the current transformation
- // into Hprev, we can reset the Hcurr to identity
- db_Identity3x3(Hcurr);
-
- // Update the reference frame to be the current frame
- reg.UpdateReference(m_rows,quarter_res,false);
-
- // Update the reference frame index
- reference_frame_index = num_frames_captured;
- }
-
- frame_number++;
-
- return ret_code;
-}
-
-// Get current transformation
-int Align::getLastTRS(double trs[3][3])
-{
- if (frame_number < 1)
- {
- trs[0][0] = 1.0;
- trs[0][1] = 0.0;
- trs[0][2] = 0.0;
- trs[1][0] = 0.0;
- trs[1][1] = 1.0;
- trs[1][2] = 0.0;
- trs[2][0] = 0.0;
- trs[2][1] = 0.0;
- trs[2][2] = 1.0;
- return ALIGN_RET_ERROR;
- }
-
- // Note that the logic here handles the case, where a frame is not used for
- // mosaicing but is captured and used in the preview-rendering.
- // For these frames, we don't set Hcurr to identity in AddFrame() and the
- // logic here appends their transformation to Hprev to render them with the
- // correct transformation. For the frames we do use for mosaicing, we already
- // append their Hcurr to Hprev in AddFrame() and then set Hcurr to identity.
-
- double Hinv33[3][3];
- double Hprev33[3][3];
- double Hcurr33[3][3];
-
- Matrix33::convert9to33(Hcurr33, Hcurr);
- normProjMat33d(Hcurr33);
- inv33d(Hcurr33, Hinv33);
-
- Matrix33::convert9to33(Hprev33, Hprev);
-
- mult33d(trs, Hprev33, Hinv33);
- normProjMat33d(trs);
-
- return ALIGN_RET_OK;
-}
-
diff --git a/jni_mosaic/feature_mos/src/mosaic/AlignFeatures.h b/jni_mosaic/feature_mos/src/mosaic/AlignFeatures.h
deleted file mode 100644
index 19f3905..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/AlignFeatures.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// Align.h
-// S.O. # :
-// Author(s): zkira
-// $Id: AlignFeatures.h,v 1.13 2011/06/17 13:35:47 mbansal Exp $
-
-#ifndef ALIGN_H
-#define ALIGN_H
-
-#include "dbreg/dbreg.h"
-#include <db_utilities_camera.h>
-
-#include "ImageUtils.h"
-#include "MatrixUtils.h"
-
-class Align {
-
-public:
- // Types of alignment possible
- static const int ALIGN_TYPE_PAN = 1;
-
- // Return codes
- static const int ALIGN_RET_LOW_TEXTURE = -2;
- static const int ALIGN_RET_ERROR = -1;
- static const int ALIGN_RET_OK = 0;
- static const int ALIGN_RET_FEW_INLIERS = 1;
-
- ///// Settings for feature-based alignment
- // Number of features to use from corner detection
- static const int DEFAULT_NR_CORNERS=750;
- static const double DEFAULT_MAX_DISPARITY=0.1;//0.4;
- // Type of homography to model
- static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_R_T;
-// static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_PROJECTIVE;
-// static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_AFFINE;
- static const unsigned int DEFAULT_REFERENCE_UPDATE_PERIOD=1500; // Manual reference frame update so set this to a large number
-
- static const int MIN_NR_REF_CORNERS = 25;
- static const int MIN_NR_INLIERS = 10;
-
- Align();
- ~Align();
-
- // Initialization of structures, etc.
- int initialize(int width, int height, bool quarter_res, float thresh_still);
-
- // Add a frame. Note: The alignment computation is performed
- // in this function
- int addFrameRGB(ImageType image);
- int addFrame(ImageType image);
-
- // Obtain the TRS matrix from the last two frames
- int getLastTRS(double trs[3][3]);
- char* getRegProfileString();
-
-protected:
-
- db_FrameToReferenceRegistration reg;
-
- int frame_number;
-
- double Hcurr[9]; // Homography from the alignment reference to the frame-t
- double Hprev[9]; // Homography from frame-0 to the frame-(t-1)
-
- int reference_frame_index; // Index of the reference frame from all captured frames
- int num_frames_captured; // Total number of frames captured (different from frame_number)
- double average_tx_per_frame; // Average pixel translation per captured frame
-
- int width,height;
-
- bool quarter_res; // Whether to process at quarter resolution
- float thresh_still; // Translation threshold in pixels to detect still camera
- ImageType imageGray;
-};
-
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/Blend.cpp b/jni_mosaic/feature_mos/src/mosaic/Blend.cpp
deleted file mode 100644
index ef983ff..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Blend.cpp
+++ /dev/null
@@ -1,1410 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// Blend.cpp
-// $Id: Blend.cpp,v 1.22 2011/06/24 04:22:14 mbansal Exp $
-
-#include <string.h>
-
-#include "Interp.h"
-#include "Blend.h"
-
-#include "Geometry.h"
-#include "trsMatrix.h"
-
-#include "Log.h"
-#define LOG_TAG "BLEND"
-
-Blend::Blend()
-{
- m_wb.blendingType = BLEND_TYPE_NONE;
-}
-
-Blend::~Blend()
-{
- if (m_pFrameVPyr) free(m_pFrameVPyr);
- if (m_pFrameUPyr) free(m_pFrameUPyr);
- if (m_pFrameYPyr) free(m_pFrameYPyr);
-}
-
-int Blend::initialize(int blendingType, int stripType, int frame_width, int frame_height)
-{
- this->width = frame_width;
- this->height = frame_height;
- this->m_wb.blendingType = blendingType;
- this->m_wb.stripType = stripType;
-
- m_wb.blendRange = m_wb.blendRangeUV = BLEND_RANGE_DEFAULT;
- m_wb.nlevs = m_wb.blendRange;
- m_wb.nlevsC = m_wb.blendRangeUV;
-
- if (m_wb.nlevs <= 0) m_wb.nlevs = 1; // Need levels for YUV processing
- if (m_wb.nlevsC > m_wb.nlevs) m_wb.nlevsC = m_wb.nlevs;
-
- m_wb.roundoffOverlap = 1.5;
-
- m_pFrameYPyr = NULL;
- m_pFrameUPyr = NULL;
- m_pFrameVPyr = NULL;
-
- m_pFrameYPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevs, (unsigned short) width, (unsigned short) height, BORDER);
- m_pFrameUPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevsC, (unsigned short) (width), (unsigned short) (height), BORDER);
- m_pFrameVPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevsC, (unsigned short) (width), (unsigned short) (height), BORDER);
-
- if (!m_pFrameYPyr || !m_pFrameUPyr || !m_pFrameVPyr)
- {
- LOGE("Error: Could not allocate pyramids for blending");
- return BLEND_RET_ERROR_MEMORY;
- }
-
- return BLEND_RET_OK;
-}
-
-inline double max(double a, double b) { return a > b ? a : b; }
-inline double min(double a, double b) { return a < b ? a : b; }
-
-void Blend::AlignToMiddleFrame(MosaicFrame **frames, int frames_size)
-{
- // Unwarp this frame and Warp the others to match
- MosaicFrame *mb = NULL;
- MosaicFrame *ref = frames[int(frames_size/2)]; // Middle frame
-
- double invtrs[3][3];
- inv33d(ref->trs, invtrs);
-
- for(int mfit = 0; mfit < frames_size; mfit++)
- {
- mb = frames[mfit];
- double temp[3][3];
- mult33d(temp, invtrs, mb->trs);
- memcpy(mb->trs, temp, sizeof(temp));
- normProjMat33d(mb->trs);
- }
-}
-
-int Blend::runBlend(MosaicFrame **oframes, MosaicFrame **rframes,
- int frames_size,
- ImageType &imageMosaicYVU, int &mosaicWidth, int &mosaicHeight,
- float &progress, bool &cancelComputation)
-{
- int ret;
- int numCenters;
-
- MosaicFrame **frames;
-
- // For THIN strip mode, accept all frames for blending
- if (m_wb.stripType == STRIP_TYPE_THIN)
- {
- frames = oframes;
- }
- else // For WIDE strip mode, first select the relevant frames to blend.
- {
- SelectRelevantFrames(oframes, frames_size, rframes, frames_size);
- frames = rframes;
- }
-
- ComputeBlendParameters(frames, frames_size, true);
- numCenters = frames_size;
-
- if (numCenters == 0)
- {
- LOGE("Error: No frames to blend");
- return BLEND_RET_ERROR;
- }
-
- if (!(m_AllSites = m_Triangulator.allocMemory(numCenters)))
- {
- return BLEND_RET_ERROR_MEMORY;
- }
-
- // Bounding rectangle (real numbers) of the final mosaic computed by projecting
- // each input frame into the mosaic coordinate system.
- BlendRect global_rect;
-
- global_rect.lft = global_rect.bot = 2e30; // min values
- global_rect.rgt = global_rect.top = -2e30; // max values
- MosaicFrame *mb = NULL;
- double halfwidth = width / 2.0;
- double halfheight = height / 2.0;
-
- double z, x0, y0, x1, y1, x2, y2, x3, y3;
-
- // Corners of the left-most and right-most frames respectively in the
- // mosaic coordinate system.
- double xLeftCorners[2] = {2e30, 2e30};
- double xRightCorners[2] = {-2e30, -2e30};
-
- // Corners of the top-most and bottom-most frames respectively in the
- // mosaic coordinate system.
- double yTopCorners[2] = {2e30, 2e30};
- double yBottomCorners[2] = {-2e30, -2e30};
-
-
- // Determine the extents of the final mosaic
- CSite *csite = m_AllSites ;
- for(int mfit = 0; mfit < frames_size; mfit++)
- {
- mb = frames[mfit];
-
- // Compute clipping for this frame's rect
- FrameToMosaicRect(mb->width, mb->height, mb->trs, mb->brect);
- // Clip global rect using this frame's rect
- ClipRect(mb->brect, global_rect);
-
- // Calculate the corner points
- FrameToMosaic(mb->trs, 0.0, 0.0, x0, y0);
- FrameToMosaic(mb->trs, 0.0, mb->height-1.0, x1, y1);
- FrameToMosaic(mb->trs, mb->width-1.0, mb->height-1.0, x2, y2);
- FrameToMosaic(mb->trs, mb->width-1.0, 0.0, x3, y3);
-
- if(x0 < xLeftCorners[0] || x1 < xLeftCorners[1]) // If either of the left corners is lower
- {
- xLeftCorners[0] = x0;
- xLeftCorners[1] = x1;
- }
-
- if(x3 > xRightCorners[0] || x2 > xRightCorners[1]) // If either of the right corners is higher
- {
- xRightCorners[0] = x3;
- xRightCorners[1] = x2;
- }
-
- if(y0 < yTopCorners[0] || y3 < yTopCorners[1]) // If either of the top corners is lower
- {
- yTopCorners[0] = y0;
- yTopCorners[1] = y3;
- }
-
- if(y1 > yBottomCorners[0] || y2 > yBottomCorners[1]) // If either of the bottom corners is higher
- {
- yBottomCorners[0] = y1;
- yBottomCorners[1] = y2;
- }
-
-
- // Compute the centroid of the warped region
- FindQuadCentroid(x0, y0, x1, y1, x2, y2, x3, y3, csite->getVCenter().x, csite->getVCenter().y);
-
- csite->setMb(mb);
- csite++;
- }
-
- // Get origin and sizes
-
- // Bounding rectangle (int numbers) of the final mosaic computed by projecting
- // each input frame into the mosaic coordinate system.
- MosaicRect fullRect;
-
- fullRect.left = (int) floor(global_rect.lft); // min-x
- fullRect.top = (int) floor(global_rect.bot); // min-y
- fullRect.right = (int) ceil(global_rect.rgt); // max-x
- fullRect.bottom = (int) ceil(global_rect.top);// max-y
- Mwidth = (unsigned short) (fullRect.right - fullRect.left + 1);
- Mheight = (unsigned short) (fullRect.bottom - fullRect.top + 1);
-
- int xLeftMost, xRightMost;
- int yTopMost, yBottomMost;
-
- // Rounding up, so that we don't include the gray border.
- xLeftMost = max(0, max(xLeftCorners[0], xLeftCorners[1]) - fullRect.left + 1);
- xRightMost = min(Mwidth - 1, min(xRightCorners[0], xRightCorners[1]) - fullRect.left - 1);
-
- yTopMost = max(0, max(yTopCorners[0], yTopCorners[1]) - fullRect.top + 1);
- yBottomMost = min(Mheight - 1, min(yBottomCorners[0], yBottomCorners[1]) - fullRect.top - 1);
-
- if (xRightMost <= xLeftMost || yBottomMost <= yTopMost)
- {
- LOGE("RunBlend: aborting -consistency check failed,"
- "(xLeftMost, xRightMost, yTopMost, yBottomMost): (%d, %d, %d, %d)",
- xLeftMost, xRightMost, yTopMost, yBottomMost);
- return BLEND_RET_ERROR;
- }
-
- // Make sure image width is multiple of 4
- Mwidth = (unsigned short) ((Mwidth + 3) & ~3);
- Mheight = (unsigned short) ((Mheight + 3) & ~3); // Round up.
-
- ret = MosaicSizeCheck(LIMIT_SIZE_MULTIPLIER, LIMIT_HEIGHT_MULTIPLIER);
- if (ret != BLEND_RET_OK)
- {
- LOGE("RunBlend: aborting - mosaic size check failed, "
- "(frame_width, frame_height) vs (mosaic_width, mosaic_height): "
- "(%d, %d) vs (%d, %d)", width, height, Mwidth, Mheight);
- return ret;
- }
-
- LOGI("Allocate mosaic image for blending - size: %d x %d", Mwidth, Mheight);
- YUVinfo *imgMos = YUVinfo::allocateImage(Mwidth, Mheight);
- if (imgMos == NULL)
- {
- LOGE("RunBlend: aborting - couldn't alloc %d x %d mosaic image", Mwidth, Mheight);
- return BLEND_RET_ERROR_MEMORY;
- }
-
- // Set the Y image to 255 so we can distinguish when frame idx are written to it
- memset(imgMos->Y.ptr[0], 255, (imgMos->Y.width * imgMos->Y.height));
- // Set the v and u images to black
- memset(imgMos->V.ptr[0], 128, (imgMos->V.width * imgMos->V.height) << 1);
-
- // Do the triangulation. It returns a sorted list of edges
- SEdgeVector *edge;
- int n = m_Triangulator.triangulate(&edge, numCenters, width, height);
- m_Triangulator.linkNeighbors(edge, n, numCenters);
-
- // Bounding rectangle that determines the positioning of the rectangle that is
- // cropped out of the computed mosaic to get rid of the gray borders.
- MosaicRect cropping_rect;
-
- if (m_wb.horizontal)
- {
- cropping_rect.left = xLeftMost;
- cropping_rect.right = xRightMost;
- }
- else
- {
- cropping_rect.top = yTopMost;
- cropping_rect.bottom = yBottomMost;
- }
-
- // Do merging and blending :
- ret = DoMergeAndBlend(frames, numCenters, width, height, *imgMos, fullRect,
- cropping_rect, progress, cancelComputation);
-
- if (m_wb.blendingType == BLEND_TYPE_HORZ)
- CropFinalMosaic(*imgMos, cropping_rect);
-
-
- m_Triangulator.freeMemory(); // note: can be called even if delaunay_alloc() wasn't successful
-
- imageMosaicYVU = imgMos->Y.ptr[0];
-
-
- if (m_wb.blendingType == BLEND_TYPE_HORZ)
- {
- mosaicWidth = cropping_rect.right - cropping_rect.left + 1;
- mosaicHeight = cropping_rect.bottom - cropping_rect.top + 1;
- }
- else
- {
- mosaicWidth = Mwidth;
- mosaicHeight = Mheight;
- }
-
- return ret;
-}
-
-int Blend::MosaicSizeCheck(float sizeMultiplier, float heightMultiplier) {
- if (Mwidth < width || Mheight < height) {
- return BLEND_RET_ERROR;
- }
-
- if ((Mwidth * Mheight) > (width * height * sizeMultiplier)) {
- return BLEND_RET_ERROR;
- }
-
- // We won't do blending for the cases where users swing the device too much
- // in the secondary direction. We use a short side to determine the
- // secondary direction because users may hold the device in landsape
- // or portrait.
- int shortSide = min(Mwidth, Mheight);
- if (shortSide > height * heightMultiplier) {
- return BLEND_RET_ERROR;
- }
-
- return BLEND_RET_OK;
-}
-
-int Blend::FillFramePyramid(MosaicFrame *mb)
-{
- ImageType mbY, mbU, mbV;
- // Lay this image, centered into the temporary buffer
- mbY = mb->image;
- mbU = mb->getU();
- mbV = mb->getV();
-
- int h, w;
-
- for(h=0; h<height; h++)
- {
- ImageTypeShort yptr = m_pFrameYPyr->ptr[h];
- ImageTypeShort uptr = m_pFrameUPyr->ptr[h];
- ImageTypeShort vptr = m_pFrameVPyr->ptr[h];
-
- for(w=0; w<width; w++)
- {
- yptr[w] = (short) ((*(mbY++)) << 3);
- uptr[w] = (short) ((*(mbU++)) << 3);
- vptr[w] = (short) ((*(mbV++)) << 3);
- }
- }
-
- // Spread the image through the border
- PyramidShort::BorderSpread(m_pFrameYPyr, BORDER, BORDER, BORDER, BORDER);
- PyramidShort::BorderSpread(m_pFrameUPyr, BORDER, BORDER, BORDER, BORDER);
- PyramidShort::BorderSpread(m_pFrameVPyr, BORDER, BORDER, BORDER, BORDER);
-
- // Generate Laplacian pyramids
- if (!PyramidShort::BorderReduce(m_pFrameYPyr, m_wb.nlevs) || !PyramidShort::BorderExpand(m_pFrameYPyr, m_wb.nlevs, -1) ||
- !PyramidShort::BorderReduce(m_pFrameUPyr, m_wb.nlevsC) || !PyramidShort::BorderExpand(m_pFrameUPyr, m_wb.nlevsC, -1) ||
- !PyramidShort::BorderReduce(m_pFrameVPyr, m_wb.nlevsC) || !PyramidShort::BorderExpand(m_pFrameVPyr, m_wb.nlevsC, -1))
- {
- LOGE("Error: Could not generate Laplacian pyramids");
- return BLEND_RET_ERROR;
- }
- else
- {
- return BLEND_RET_OK;
- }
-}
-
-int Blend::DoMergeAndBlend(MosaicFrame **frames, int nsite,
- int width, int height, YUVinfo &imgMos, MosaicRect &rect,
- MosaicRect &cropping_rect, float &progress, bool &cancelComputation)
-{
- m_pMosaicYPyr = NULL;
- m_pMosaicUPyr = NULL;
- m_pMosaicVPyr = NULL;
-
- m_pMosaicYPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevs,(unsigned short)rect.Width(),(unsigned short)rect.Height(),BORDER);
- m_pMosaicUPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevsC,(unsigned short)rect.Width(),(unsigned short)rect.Height(),BORDER);
- m_pMosaicVPyr = PyramidShort::allocatePyramidPacked(m_wb.nlevsC,(unsigned short)rect.Width(),(unsigned short)rect.Height(),BORDER);
- if (!m_pMosaicYPyr || !m_pMosaicUPyr || !m_pMosaicVPyr)
- {
- LOGE("Error: Could not allocate pyramids for blending");
- return BLEND_RET_ERROR_MEMORY;
- }
-
- MosaicFrame *mb;
-
- CSite *esite = m_AllSites + nsite;
- int site_idx;
-
- // First go through each frame and for each mosaic pixel determine which frame it should come from
- site_idx = 0;
- for(CSite *csite = m_AllSites; csite < esite; csite++)
- {
- if(cancelComputation)
- {
- if (m_pMosaicVPyr) free(m_pMosaicVPyr);
- if (m_pMosaicUPyr) free(m_pMosaicUPyr);
- if (m_pMosaicYPyr) free(m_pMosaicYPyr);
- return BLEND_RET_CANCELLED;
- }
-
- mb = csite->getMb();
-
- mb->vcrect = mb->brect;
- ClipBlendRect(csite, mb->vcrect);
-
- ComputeMask(csite, mb->vcrect, mb->brect, rect, imgMos, site_idx);
-
- site_idx++;
- }
-
- ////////// imgMos.Y, imgMos.V, imgMos.U are used as follows //////////////
- ////////////////////// THIN STRIP MODE ///////////////////////////////////
-
- // imgMos.Y is used to store the index of the image from which each pixel
- // in the output mosaic can be read out for the thin-strip mode. Thus,
- // there is no special handling for pixels around the seam. Also, imgMos.Y
- // is set to 255 wherever we can't get its value from any input image e.g.
- // in the gray border areas. imgMos.V and imgMos.U are set to 128 for the
- // thin-strip mode.
-
- ////////////////////// WIDE STRIP MODE ///////////////////////////////////
-
- // imgMos.Y is used the same way as the thin-strip mode.
- // imgMos.V is used to store the index of the neighboring image which
- // should contribute to the color of an output pixel in a band around
- // the seam. Thus, in this band, we will crossfade between the color values
- // from the image index imgMos.Y and image index imgMos.V. imgMos.U is
- // used to store the weight (multiplied by 100) that each image will
- // contribute to the blending process. Thus, we start at 99% contribution
- // from the first image, then go to 50% contribution from each image at
- // the seam. Then, the contribution from the second image goes up to 99%.
-
- // For WIDE mode, set the pixel masks to guide the blender to cross-fade
- // between the images on either side of each seam:
- if (m_wb.stripType == STRIP_TYPE_WIDE)
- {
- if(m_wb.horizontal)
- {
- // Set the number of pixels around the seam to cross-fade between
- // the two component images,
- int tw = STRIP_CROSS_FADE_WIDTH_PXLS;
-
- // Proceed with the image index calculation for cross-fading
- // only if the cross-fading width is larger than 0
- if (tw > 0)
- {
- for(int y = 0; y < imgMos.Y.height; y++)
- {
- // Since we compare two adjecant pixels to determine
- // whether there is a seam, the termination condition of x
- // is set to imgMos.Y.width - tw, so that x+1 below
- // won't exceed the imgMos' boundary.
- for(int x = tw; x < imgMos.Y.width - tw; )
- {
- // Determine where the seam is...
- if (imgMos.Y.ptr[y][x] != imgMos.Y.ptr[y][x+1] &&
- imgMos.Y.ptr[y][x] != 255 &&
- imgMos.Y.ptr[y][x+1] != 255)
- {
- // Find the image indices on both sides of the seam
- unsigned char idx1 = imgMos.Y.ptr[y][x];
- unsigned char idx2 = imgMos.Y.ptr[y][x+1];
-
- for (int o = tw; o >= 0; o--)
- {
- // Set the image index to use for cross-fading
- imgMos.V.ptr[y][x - o] = idx2;
- // Set the intensity weights to use for cross-fading
- imgMos.U.ptr[y][x - o] = 50 + (99 - 50) * o / tw;
- }
-
- for (int o = 1; o <= tw; o++)
- {
- // Set the image index to use for cross-fading
- imgMos.V.ptr[y][x + o] = idx1;
- // Set the intensity weights to use for cross-fading
- imgMos.U.ptr[y][x + o] = imgMos.U.ptr[y][x - o];
- }
-
- x += (tw + 1);
- }
- else
- {
- x++;
- }
- }
- }
- }
- }
- else
- {
- // Set the number of pixels around the seam to cross-fade between
- // the two component images,
- int tw = STRIP_CROSS_FADE_WIDTH_PXLS;
-
- // Proceed with the image index calculation for cross-fading
- // only if the cross-fading width is larger than 0
- if (tw > 0)
- {
- for(int x = 0; x < imgMos.Y.width; x++)
- {
- // Since we compare two adjecant pixels to determine
- // whether there is a seam, the termination condition of y
- // is set to imgMos.Y.height - tw, so that y+1 below
- // won't exceed the imgMos' boundary.
- for(int y = tw; y < imgMos.Y.height - tw; )
- {
- // Determine where the seam is...
- if (imgMos.Y.ptr[y][x] != imgMos.Y.ptr[y+1][x] &&
- imgMos.Y.ptr[y][x] != 255 &&
- imgMos.Y.ptr[y+1][x] != 255)
- {
- // Find the image indices on both sides of the seam
- unsigned char idx1 = imgMos.Y.ptr[y][x];
- unsigned char idx2 = imgMos.Y.ptr[y+1][x];
-
- for (int o = tw; o >= 0; o--)
- {
- // Set the image index to use for cross-fading
- imgMos.V.ptr[y - o][x] = idx2;
- // Set the intensity weights to use for cross-fading
- imgMos.U.ptr[y - o][x] = 50 + (99 - 50) * o / tw;
- }
-
- for (int o = 1; o <= tw; o++)
- {
- // Set the image index to use for cross-fading
- imgMos.V.ptr[y + o][x] = idx1;
- // Set the intensity weights to use for cross-fading
- imgMos.U.ptr[y + o][x] = imgMos.U.ptr[y - o][x];
- }
-
- y += (tw + 1);
- }
- else
- {
- y++;
- }
- }
- }
- }
- }
-
- }
-
- // Now perform the actual blending using the frame assignment determined above
- site_idx = 0;
- for(CSite *csite = m_AllSites; csite < esite; csite++)
- {
- if(cancelComputation)
- {
- if (m_pMosaicVPyr) free(m_pMosaicVPyr);
- if (m_pMosaicUPyr) free(m_pMosaicUPyr);
- if (m_pMosaicYPyr) free(m_pMosaicYPyr);
- return BLEND_RET_CANCELLED;
- }
-
- mb = csite->getMb();
-
-
- if(FillFramePyramid(mb)!=BLEND_RET_OK)
- return BLEND_RET_ERROR;
-
- ProcessPyramidForThisFrame(csite, mb->vcrect, mb->brect, rect, imgMos, mb->trs, site_idx);
-
- progress += TIME_PERCENT_BLEND/nsite;
-
- site_idx++;
- }
-
-
- // Blend
- PerformFinalBlending(imgMos, cropping_rect);
-
- if (cropping_rect.Width() <= 0 || cropping_rect.Height() <= 0)
- {
- LOGE("Size of the cropping_rect is invalid - (width, height): (%d, %d)",
- cropping_rect.Width(), cropping_rect.Height());
- return BLEND_RET_ERROR;
- }
-
- if (m_pMosaicVPyr) free(m_pMosaicVPyr);
- if (m_pMosaicUPyr) free(m_pMosaicUPyr);
- if (m_pMosaicYPyr) free(m_pMosaicYPyr);
-
- progress += TIME_PERCENT_FINAL;
-
- return BLEND_RET_OK;
-}
-
-void Blend::CropFinalMosaic(YUVinfo &imgMos, MosaicRect &cropping_rect)
-{
- int i, j, k;
- ImageType yimg;
- ImageType uimg;
- ImageType vimg;
-
-
- yimg = imgMos.Y.ptr[0];
- uimg = imgMos.U.ptr[0];
- vimg = imgMos.V.ptr[0];
-
- k = 0;
- for (j = cropping_rect.top; j <= cropping_rect.bottom; j++)
- {
- for (i = cropping_rect.left; i <= cropping_rect.right; i++)
- {
- yimg[k] = yimg[j*imgMos.Y.width+i];
- k++;
- }
- }
- for (j = cropping_rect.top; j <= cropping_rect.bottom; j++)
- {
- for (i = cropping_rect.left; i <= cropping_rect.right; i++)
- {
- yimg[k] = vimg[j*imgMos.Y.width+i];
- k++;
- }
- }
- for (j = cropping_rect.top; j <= cropping_rect.bottom; j++)
- {
- for (i = cropping_rect.left; i <= cropping_rect.right; i++)
- {
- yimg[k] = uimg[j*imgMos.Y.width+i];
- k++;
- }
- }
-}
-
-int Blend::PerformFinalBlending(YUVinfo &imgMos, MosaicRect &cropping_rect)
-{
- if (!PyramidShort::BorderExpand(m_pMosaicYPyr, m_wb.nlevs, 1) || !PyramidShort::BorderExpand(m_pMosaicUPyr, m_wb.nlevsC, 1) ||
- !PyramidShort::BorderExpand(m_pMosaicVPyr, m_wb.nlevsC, 1))
- {
- LOGE("Error: Could not BorderExpand!");
- return BLEND_RET_ERROR;
- }
-
- ImageTypeShort myimg;
- ImageTypeShort muimg;
- ImageTypeShort mvimg;
- ImageType yimg;
- ImageType uimg;
- ImageType vimg;
-
- int cx = (int)imgMos.Y.width/2;
- int cy = (int)imgMos.Y.height/2;
-
- // 2D boolean array that contains true wherever the mosaic image data is
- // invalid (i.e. in the gray border).
- bool **b = new bool*[imgMos.Y.height];
-
- for(int j=0; j<imgMos.Y.height; j++)
- {
- b[j] = new bool[imgMos.Y.width];
- }
-
- // Copy the resulting image into the full image using the mask
- int i, j;
-
- yimg = imgMos.Y.ptr[0];
- uimg = imgMos.U.ptr[0];
- vimg = imgMos.V.ptr[0];
-
- for (j = 0; j < imgMos.Y.height; j++)
- {
- myimg = m_pMosaicYPyr->ptr[j];
- muimg = m_pMosaicUPyr->ptr[j];
- mvimg = m_pMosaicVPyr->ptr[j];
-
- for (i = 0; i<imgMos.Y.width; i++)
- {
- // A final mask was set up previously,
- // if the value is zero skip it, otherwise replace it.
- if (*yimg <255)
- {
- short value = (short) ((*myimg) >> 3);
- if (value < 0) value = 0;
- else if (value > 255) value = 255;
- *yimg = (unsigned char) value;
-
- value = (short) ((*muimg) >> 3);
- if (value < 0) value = 0;
- else if (value > 255) value = 255;
- *uimg = (unsigned char) value;
-
- value = (short) ((*mvimg) >> 3);
- if (value < 0) value = 0;
- else if (value > 255) value = 255;
- *vimg = (unsigned char) value;
-
- b[j][i] = false;
-
- }
- else
- { // set border color in here
- *yimg = (unsigned char) 96;
- *uimg = (unsigned char) 128;
- *vimg = (unsigned char) 128;
-
- b[j][i] = true;
- }
-
- yimg++;
- uimg++;
- vimg++;
- myimg++;
- muimg++;
- mvimg++;
- }
- }
-
- if(m_wb.horizontal)
- {
- //Scan through each row and increment top if the row contains any gray
- for (j = 0; j < imgMos.Y.height; j++)
- {
- for (i = cropping_rect.left; i < cropping_rect.right; i++)
- {
- if (b[j][i])
- {
- break; // to next row
- }
- }
-
- if (i == cropping_rect.right) //no gray pixel in this row!
- {
- cropping_rect.top = j;
- break;
- }
- }
-
- //Scan through each row and decrement bottom if the row contains any gray
- for (j = imgMos.Y.height-1; j >= 0; j--)
- {
- for (i = cropping_rect.left; i < cropping_rect.right; i++)
- {
- if (b[j][i])
- {
- break; // to next row
- }
- }
-
- if (i == cropping_rect.right) //no gray pixel in this row!
- {
- cropping_rect.bottom = j;
- break;
- }
- }
- }
- else // Vertical Mosaic
- {
- //Scan through each column and increment left if the column contains any gray
- for (i = 0; i < imgMos.Y.width; i++)
- {
- for (j = cropping_rect.top; j < cropping_rect.bottom; j++)
- {
- if (b[j][i])
- {
- break; // to next column
- }
- }
-
- if (j == cropping_rect.bottom) //no gray pixel in this column!
- {
- cropping_rect.left = i;
- break;
- }
- }
-
- //Scan through each column and decrement right if the column contains any gray
- for (i = imgMos.Y.width-1; i >= 0; i--)
- {
- for (j = cropping_rect.top; j < cropping_rect.bottom; j++)
- {
- if (b[j][i])
- {
- break; // to next column
- }
- }
-
- if (j == cropping_rect.bottom) //no gray pixel in this column!
- {
- cropping_rect.right = i;
- break;
- }
- }
-
- }
-
- RoundingCroppingSizeToMultipleOf8(cropping_rect);
-
- for(int j=0; j<imgMos.Y.height; j++)
- {
- delete b[j];
- }
-
- delete b;
-
- return BLEND_RET_OK;
-}
-
-void Blend::RoundingCroppingSizeToMultipleOf8(MosaicRect &rect) {
- int height = rect.bottom - rect.top + 1;
- int residue = height & 7;
- rect.bottom -= residue;
-
- int width = rect.right - rect.left + 1;
- residue = width & 7;
- rect.right -= residue;
-}
-
-void Blend::ComputeMask(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, int site_idx)
-{
- PyramidShort *dptr = m_pMosaicYPyr;
-
- int nC = m_wb.nlevsC;
- int l = (int) ((vcrect.lft - rect.left));
- int b = (int) ((vcrect.bot - rect.top));
- int r = (int) ((vcrect.rgt - rect.left));
- int t = (int) ((vcrect.top - rect.top));
-
- if (vcrect.lft == brect.lft)
- l = (l <= 0) ? -BORDER : l - BORDER;
- else if (l < -BORDER)
- l = -BORDER;
-
- if (vcrect.bot == brect.bot)
- b = (b <= 0) ? -BORDER : b - BORDER;
- else if (b < -BORDER)
- b = -BORDER;
-
- if (vcrect.rgt == brect.rgt)
- r = (r >= dptr->width) ? dptr->width + BORDER - 1 : r + BORDER;
- else if (r >= dptr->width + BORDER)
- r = dptr->width + BORDER - 1;
-
- if (vcrect.top == brect.top)
- t = (t >= dptr->height) ? dptr->height + BORDER - 1 : t + BORDER;
- else if (t >= dptr->height + BORDER)
- t = dptr->height + BORDER - 1;
-
- // Walk the Region of interest and populate the pyramid
- for (int j = b; j <= t; j++)
- {
- int jj = j;
- double sj = jj + rect.top;
-
- for (int i = l; i <= r; i++)
- {
- int ii = i;
- // project point and then triangulate to neighbors
- double si = ii + rect.left;
-
- double dself = hypotSq(csite->getVCenter().x - si, csite->getVCenter().y - sj);
- int inMask = ((unsigned) ii < imgMos.Y.width &&
- (unsigned) jj < imgMos.Y.height) ? 1 : 0;
-
- if(!inMask)
- continue;
-
- // scan the neighbors to see if this is a valid position
- unsigned char mask = (unsigned char) 255;
- SEdgeVector *ce;
- int ecnt;
- for (ce = csite->getNeighbor(), ecnt = csite->getNumNeighbors(); ecnt--; ce++)
- {
- double d1 = hypotSq(m_AllSites[ce->second].getVCenter().x - si,
- m_AllSites[ce->second].getVCenter().y - sj);
- if (d1 < dself)
- {
- break;
- }
- }
-
- if (ecnt >= 0) continue;
-
- imgMos.Y.ptr[jj][ii] = (unsigned char)site_idx;
- }
- }
-}
-
-void Blend::ProcessPyramidForThisFrame(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, double trs[3][3], int site_idx)
-{
- // Put the Region of interest (for all levels) into m_pMosaicYPyr
- double inv_trs[3][3];
- inv33d(trs, inv_trs);
-
- // Process each pyramid level
- PyramidShort *sptr = m_pFrameYPyr;
- PyramidShort *suptr = m_pFrameUPyr;
- PyramidShort *svptr = m_pFrameVPyr;
-
- PyramidShort *dptr = m_pMosaicYPyr;
- PyramidShort *duptr = m_pMosaicUPyr;
- PyramidShort *dvptr = m_pMosaicVPyr;
-
- int dscale = 0; // distance scale for the current level
- int nC = m_wb.nlevsC;
- for (int n = m_wb.nlevs; n--; dscale++, dptr++, sptr++, dvptr++, duptr++, svptr++, suptr++, nC--)
- {
- int l = (int) ((vcrect.lft - rect.left) / (1 << dscale));
- int b = (int) ((vcrect.bot - rect.top) / (1 << dscale));
- int r = (int) ((vcrect.rgt - rect.left) / (1 << dscale) + .5);
- int t = (int) ((vcrect.top - rect.top) / (1 << dscale) + .5);
-
- if (vcrect.lft == brect.lft)
- l = (l <= 0) ? -BORDER : l - BORDER;
- else if (l < -BORDER)
- l = -BORDER;
-
- if (vcrect.bot == brect.bot)
- b = (b <= 0) ? -BORDER : b - BORDER;
- else if (b < -BORDER)
- b = -BORDER;
-
- if (vcrect.rgt == brect.rgt)
- r = (r >= dptr->width) ? dptr->width + BORDER - 1 : r + BORDER;
- else if (r >= dptr->width + BORDER)
- r = dptr->width + BORDER - 1;
-
- if (vcrect.top == brect.top)
- t = (t >= dptr->height) ? dptr->height + BORDER - 1 : t + BORDER;
- else if (t >= dptr->height + BORDER)
- t = dptr->height + BORDER - 1;
-
- // Walk the Region of interest and populate the pyramid
- for (int j = b; j <= t; j++)
- {
- int jj = (j << dscale);
- double sj = jj + rect.top;
-
- for (int i = l; i <= r; i++)
- {
- int ii = (i << dscale);
- // project point and then triangulate to neighbors
- double si = ii + rect.left;
-
- int inMask = ((unsigned) ii < imgMos.Y.width &&
- (unsigned) jj < imgMos.Y.height) ? 1 : 0;
-
- if(inMask && imgMos.Y.ptr[jj][ii] != site_idx &&
- imgMos.V.ptr[jj][ii] != site_idx &&
- imgMos.Y.ptr[jj][ii] != 255)
- continue;
-
- // Setup weights for cross-fading
- // Weight of the intensity already in the output pixel
- double wt0 = 0.0;
- // Weight of the intensity from the input pixel (current frame)
- double wt1 = 1.0;
-
- if (m_wb.stripType == STRIP_TYPE_WIDE)
- {
- if(inMask && imgMos.Y.ptr[jj][ii] != 255)
- {
- // If not on a seam OR pyramid level exceeds
- // maximum level for cross-fading.
- if((imgMos.V.ptr[jj][ii] == 128) ||
- (dscale > STRIP_CROSS_FADE_MAX_PYR_LEVEL))
- {
- wt0 = 0.0;
- wt1 = 1.0;
- }
- else
- {
- wt0 = 1.0;
- wt1 = ((imgMos.Y.ptr[jj][ii] == site_idx) ?
- (double)imgMos.U.ptr[jj][ii] / 100.0 :
- 1.0 - (double)imgMos.U.ptr[jj][ii] / 100.0);
- }
- }
- }
-
- // Project this mosaic point into the original frame coordinate space
- double xx, yy;
-
- MosaicToFrame(inv_trs, si, sj, xx, yy);
-
- if (xx < 0.0 || yy < 0.0 || xx > width - 1.0 || yy > height - 1.0)
- {
- if(inMask)
- {
- imgMos.Y.ptr[jj][ii] = 255;
- wt0 = 0.0f;
- wt1 = 1.0f;
- }
- }
-
- xx /= (1 << dscale);
- yy /= (1 << dscale);
-
-
- int x1 = (xx >= 0.0) ? (int) xx : (int) floor(xx);
- int y1 = (yy >= 0.0) ? (int) yy : (int) floor(yy);
-
- // Final destination in extended pyramid
-#ifndef LINEAR_INTERP
- if(inSegment(x1, sptr->width, BORDER-1) &&
- inSegment(y1, sptr->height, BORDER-1))
- {
- double xfrac = xx - x1;
- double yfrac = yy - y1;
- dptr->ptr[j][i] = (short) (wt0 * dptr->ptr[j][i] + .5 +
- wt1 * ciCalc(sptr, x1, y1, xfrac, yfrac));
- if (dvptr >= m_pMosaicVPyr && nC > 0)
- {
- duptr->ptr[j][i] = (short) (wt0 * duptr->ptr[j][i] + .5 +
- wt1 * ciCalc(suptr, x1, y1, xfrac, yfrac));
- dvptr->ptr[j][i] = (short) (wt0 * dvptr->ptr[j][i] + .5 +
- wt1 * ciCalc(svptr, x1, y1, xfrac, yfrac));
- }
- }
-#else
- if(inSegment(x1, sptr->width, BORDER) && inSegment(y1, sptr->height, BORDER))
- {
- int x2 = x1 + 1;
- int y2 = y1 + 1;
- double xfrac = xx - x1;
- double yfrac = yy - y1;
- double y1val = sptr->ptr[y1][x1] +
- (sptr->ptr[y1][x2] - sptr->ptr[y1][x1]) * xfrac;
- double y2val = sptr->ptr[y2][x1] +
- (sptr->ptr[y2][x2] - sptr->ptr[y2][x1]) * xfrac;
- dptr->ptr[j][i] = (short) (y1val + yfrac * (y2val - y1val));
-
- if (dvptr >= m_pMosaicVPyr && nC > 0)
- {
- y1val = suptr->ptr[y1][x1] +
- (suptr->ptr[y1][x2] - suptr->ptr[y1][x1]) * xfrac;
- y2val = suptr->ptr[y2][x1] +
- (suptr->ptr[y2][x2] - suptr->ptr[y2][x1]) * xfrac;
-
- duptr->ptr[j][i] = (short) (y1val + yfrac * (y2val - y1val));
-
- y1val = svptr->ptr[y1][x1] +
- (svptr->ptr[y1][x2] - svptr->ptr[y1][x1]) * xfrac;
- y2val = svptr->ptr[y2][x1] +
- (svptr->ptr[y2][x2] - svptr->ptr[y2][x1]) * xfrac;
-
- dvptr->ptr[j][i] = (short) (y1val + yfrac * (y2val - y1val));
- }
- }
-#endif
- else
- {
- clipToSegment(x1, sptr->width, BORDER);
- clipToSegment(y1, sptr->height, BORDER);
-
- dptr->ptr[j][i] = (short) (wt0 * dptr->ptr[j][i] + 0.5 +
- wt1 * sptr->ptr[y1][x1] );
- if (dvptr >= m_pMosaicVPyr && nC > 0)
- {
- dvptr->ptr[j][i] = (short) (wt0 * dvptr->ptr[j][i] +
- 0.5 + wt1 * svptr->ptr[y1][x1] );
- duptr->ptr[j][i] = (short) (wt0 * duptr->ptr[j][i] +
- 0.5 + wt1 * suptr->ptr[y1][x1] );
- }
- }
- }
- }
- }
-}
-
-void Blend::MosaicToFrame(double trs[3][3], double x, double y, double &wx, double &wy)
-{
- double X, Y, z;
- if (m_wb.theta == 0.0)
- {
- X = x;
- Y = y;
- }
- else if (m_wb.horizontal)
- {
- double alpha = x * m_wb.direction / m_wb.width;
- double length = (y - alpha * m_wb.correction) * m_wb.direction + m_wb.radius;
- double deltaTheta = m_wb.theta * alpha;
- double sinTheta = sin(deltaTheta);
- double cosTheta = sqrt(1.0 - sinTheta * sinTheta) * m_wb.direction;
- X = length * sinTheta + m_wb.x;
- Y = length * cosTheta + m_wb.y;
- }
- else
- {
- double alpha = y * m_wb.direction / m_wb.width;
- double length = (x - alpha * m_wb.correction) * m_wb.direction + m_wb.radius;
- double deltaTheta = m_wb.theta * alpha;
- double sinTheta = sin(deltaTheta);
- double cosTheta = sqrt(1.0 - sinTheta * sinTheta) * m_wb.direction;
- Y = length * sinTheta + m_wb.y;
- X = length * cosTheta + m_wb.x;
- }
- z = ProjZ(trs, X, Y, 1.0);
- wx = ProjX(trs, X, Y, z, 1.0);
- wy = ProjY(trs, X, Y, z, 1.0);
-}
-
-void Blend::FrameToMosaic(double trs[3][3], double x, double y, double &wx, double &wy)
-{
- // Project into the intermediate Mosaic coordinate system
- double z = ProjZ(trs, x, y, 1.0);
- double X = ProjX(trs, x, y, z, 1.0);
- double Y = ProjY(trs, x, y, z, 1.0);
-
- if (m_wb.theta == 0.0)
- {
- // No rotation, then this is all we need to do.
- wx = X;
- wy = Y;
- }
- else if (m_wb.horizontal)
- {
- double deltaX = X - m_wb.x;
- double deltaY = Y - m_wb.y;
- double length = sqrt(deltaX * deltaX + deltaY * deltaY);
- double deltaTheta = asin(deltaX / length);
- double alpha = deltaTheta / m_wb.theta;
- wx = alpha * m_wb.width * m_wb.direction;
- wy = (length - m_wb.radius) * m_wb.direction + alpha * m_wb.correction;
- }
- else
- {
- double deltaX = X - m_wb.x;
- double deltaY = Y - m_wb.y;
- double length = sqrt(deltaX * deltaX + deltaY * deltaY);
- double deltaTheta = asin(deltaY / length);
- double alpha = deltaTheta / m_wb.theta;
- wy = alpha * m_wb.width * m_wb.direction;
- wx = (length - m_wb.radius) * m_wb.direction + alpha * m_wb.correction;
- }
-}
-
-
-
-// Clip the region of interest as small as possible by using the Voronoi edges of
-// the neighbors
-void Blend::ClipBlendRect(CSite *csite, BlendRect &brect)
-{
- SEdgeVector *ce;
- int ecnt;
- for (ce = csite->getNeighbor(), ecnt = csite->getNumNeighbors(); ecnt--; ce++)
- {
- // calculate the Voronoi bisector intersection
- const double epsilon = 1e-5;
- double dx = (m_AllSites[ce->second].getVCenter().x - m_AllSites[ce->first].getVCenter().x);
- double dy = (m_AllSites[ce->second].getVCenter().y - m_AllSites[ce->first].getVCenter().y);
- double xmid = m_AllSites[ce->first].getVCenter().x + dx/2.0;
- double ymid = m_AllSites[ce->first].getVCenter().y + dy/2.0;
- double inter;
-
- if (dx > epsilon)
- {
- // neighbor is on right
- if ((inter = m_wb.roundoffOverlap + xmid - dy * (((dy >= 0.0) ? brect.bot : brect.top) - ymid) / dx) < brect.rgt)
- brect.rgt = inter;
- }
- else if (dx < -epsilon)
- {
- // neighbor is on left
- if ((inter = -m_wb.roundoffOverlap + xmid - dy * (((dy >= 0.0) ? brect.bot : brect.top) - ymid) / dx) > brect.lft)
- brect.lft = inter;
- }
- if (dy > epsilon)
- {
- // neighbor is above
- if ((inter = m_wb.roundoffOverlap + ymid - dx * (((dx >= 0.0) ? brect.lft : brect.rgt) - xmid) / dy) < brect.top)
- brect.top = inter;
- }
- else if (dy < -epsilon)
- {
- // neighbor is below
- if ((inter = -m_wb.roundoffOverlap + ymid - dx * (((dx >= 0.0) ? brect.lft : brect.rgt) - xmid) / dy) > brect.bot)
- brect.bot = inter;
- }
- }
-}
-
-void Blend::FrameToMosaicRect(int width, int height, double trs[3][3], BlendRect &brect)
-{
- // We need to walk the perimeter since the borders can be bent.
- brect.lft = brect.bot = 2e30;
- brect.rgt = brect.top = -2e30;
- double xpos, ypos;
- double lasty = height - 1.0;
- double lastx = width - 1.0;
- int i;
-
- for (i = width; i--;)
- {
-
- FrameToMosaic(trs, (double) i, 0.0, xpos, ypos);
- ClipRect(xpos, ypos, brect);
- FrameToMosaic(trs, (double) i, lasty, xpos, ypos);
- ClipRect(xpos, ypos, brect);
- }
- for (i = height; i--;)
- {
- FrameToMosaic(trs, 0.0, (double) i, xpos, ypos);
- ClipRect(xpos, ypos, brect);
- FrameToMosaic(trs, lastx, (double) i, xpos, ypos);
- ClipRect(xpos, ypos, brect);
- }
-}
-
-void Blend::SelectRelevantFrames(MosaicFrame **frames, int frames_size,
- MosaicFrame **relevant_frames, int &relevant_frames_size)
-{
- MosaicFrame *first = frames[0];
- MosaicFrame *last = frames[frames_size-1];
- MosaicFrame *mb;
-
- double fxpos = first->trs[0][2], fypos = first->trs[1][2];
-
- double midX = last->width / 2.0;
- double midY = last->height / 2.0;
- double z = ProjZ(first->trs, midX, midY, 1.0);
- double firstX, firstY;
- double prevX = firstX = ProjX(first->trs, midX, midY, z, 1.0);
- double prevY = firstY = ProjY(first->trs, midX, midY, z, 1.0);
-
- relevant_frames[0] = first; // Add first frame by default
- relevant_frames_size = 1;
-
- for (int i = 0; i < frames_size - 1; i++)
- {
- mb = frames[i];
- double currX, currY;
- z = ProjZ(mb->trs, midX, midY, 1.0);
- currX = ProjX(mb->trs, midX, midY, z, 1.0);
- currY = ProjY(mb->trs, midX, midY, z, 1.0);
- double deltaX = currX - prevX;
- double deltaY = currY - prevY;
- double center2centerDist = sqrt(deltaY * deltaY + deltaX * deltaX);
-
- if (fabs(deltaX) > STRIP_SEPARATION_THRESHOLD_PXLS ||
- fabs(deltaY) > STRIP_SEPARATION_THRESHOLD_PXLS)
- {
- relevant_frames[relevant_frames_size] = mb;
- relevant_frames_size++;
-
- prevX = currX;
- prevY = currY;
- }
- }
-
- // Add last frame by default
- relevant_frames[relevant_frames_size] = last;
- relevant_frames_size++;
-}
-
-void Blend::ComputeBlendParameters(MosaicFrame **frames, int frames_size, int is360)
-{
- // For FULL and PAN modes, we do not unwarp the mosaic into a rectangular coordinate system
- // and so we set the theta to 0 and return.
- if (m_wb.blendingType != BLEND_TYPE_CYLPAN && m_wb.blendingType != BLEND_TYPE_HORZ)
- {
- m_wb.theta = 0.0;
- return;
- }
-
- MosaicFrame *first = frames[0];
- MosaicFrame *last = frames[frames_size-1];
- MosaicFrame *mb;
-
- double lxpos = last->trs[0][2], lypos = last->trs[1][2];
- double fxpos = first->trs[0][2], fypos = first->trs[1][2];
-
- // Calculate warp to produce proper stitching.
- // get x, y displacement
- double midX = last->width / 2.0;
- double midY = last->height / 2.0;
- double z = ProjZ(first->trs, midX, midY, 1.0);
- double firstX, firstY;
- double prevX = firstX = ProjX(first->trs, midX, midY, z, 1.0);
- double prevY = firstY = ProjY(first->trs, midX, midY, z, 1.0);
-
- double arcLength, lastTheta;
- m_wb.theta = lastTheta = arcLength = 0.0;
-
- // Step through all the frames to compute the total arc-length of the cone
- // swept while capturing the mosaic (in the original conical coordinate system).
- for (int i = 0; i < frames_size; i++)
- {
- mb = frames[i];
- double currX, currY;
- z = ProjZ(mb->trs, midX, midY, 1.0);
- currX = ProjX(mb->trs, midX, midY, z, 1.0);
- currY = ProjY(mb->trs, midX, midY, z, 1.0);
- double deltaX = currX - prevX;
- double deltaY = currY - prevY;
-
- // The arcLength is computed by summing the lengths of the chords
- // connecting the pairwise projected image centers of the input image frames.
- arcLength += sqrt(deltaY * deltaY + deltaX * deltaX);
-
- if (!is360)
- {
- double thisTheta = asin(mb->trs[1][0]);
- m_wb.theta += thisTheta - lastTheta;
- lastTheta = thisTheta;
- }
-
- prevX = currX;
- prevY = currY;
- }
-
- // Stretch this to end at the proper alignment i.e. the width of the
- // rectangle is determined by the arcLength computed above and the cone
- // sector angle is determined using the rotation of the last frame.
- m_wb.width = arcLength;
- if (is360) m_wb.theta = asin(last->trs[1][0]);
-
- // If there is no rotation, we're done.
- if (m_wb.theta != 0.0)
- {
- double dx = prevX - firstX;
- double dy = prevY - firstY;
-
- // If the mosaic was captured by sweeping horizontally
- if (abs(lxpos - fxpos) > abs(lypos - fypos))
- {
- m_wb.horizontal = 1;
- // Calculate radius position to make ends exactly the same Y offset
- double radiusTheta = dx / cos(3.14159 / 2.0 - m_wb.theta);
- m_wb.radius = dy + radiusTheta * cos(m_wb.theta);
- if (m_wb.radius < 0.0) m_wb.radius = -m_wb.radius;
- }
- else
- {
- m_wb.horizontal = 0;
- // Calculate radius position to make ends exactly the same Y offset
- double radiusTheta = dy / cos(3.14159 / 2.0 - m_wb.theta);
- m_wb.radius = dx + radiusTheta * cos(m_wb.theta);
- if (m_wb.radius < 0.0) m_wb.radius = -m_wb.radius;
- }
-
- // Determine major direction
- if (m_wb.horizontal)
- {
- // Horizontal strip
- // m_wb.x,y record the origin of the rectangle coordinate system.
- if (is360) m_wb.x = firstX;
- else
- {
- if (lxpos - fxpos < 0)
- {
- m_wb.x = firstX + midX;
- z = ProjZ(last->trs, 0.0, midY, 1.0);
- prevX = ProjX(last->trs, 0.0, midY, z, 1.0);
- prevY = ProjY(last->trs, 0.0, midY, z, 1.0);
- }
- else
- {
- m_wb.x = firstX - midX;
- z = ProjZ(last->trs, last->width - 1.0, midY, 1.0);
- prevX = ProjX(last->trs, last->width - 1.0, midY, z, 1.0);
- prevY = ProjY(last->trs, last->width - 1.0, midY, z, 1.0);
- }
- }
- dy = prevY - firstY;
- if (dy < 0.0) m_wb.direction = 1.0;
- else m_wb.direction = -1.0;
- m_wb.y = firstY - m_wb.radius * m_wb.direction;
- if (dy * m_wb.theta > 0.0) m_wb.width = -m_wb.width;
- }
- else
- {
- // Vertical strip
- if (is360) m_wb.y = firstY;
- else
- {
- if (lypos - fypos < 0)
- {
- m_wb.x = firstY + midY;
- z = ProjZ(last->trs, midX, 0.0, 1.0);
- prevX = ProjX(last->trs, midX, 0.0, z, 1.0);
- prevY = ProjY(last->trs, midX, 0.0, z, 1.0);
- }
- else
- {
- m_wb.x = firstX - midX;
- z = ProjZ(last->trs, midX, last->height - 1.0, 1.0);
- prevX = ProjX(last->trs, midX, last->height - 1.0, z, 1.0);
- prevY = ProjY(last->trs, midX, last->height - 1.0, z, 1.0);
- }
- }
- dx = prevX - firstX;
- if (dx < 0.0) m_wb.direction = 1.0;
- else m_wb.direction = -1.0;
- m_wb.x = firstX - m_wb.radius * m_wb.direction;
- if (dx * m_wb.theta > 0.0) m_wb.width = -m_wb.width;
- }
-
- // Calculate the correct correction factor
- double deltaX = prevX - m_wb.x;
- double deltaY = prevY - m_wb.y;
- double length = sqrt(deltaX * deltaX + deltaY * deltaY);
- double deltaTheta = (m_wb.horizontal) ? deltaX : deltaY;
- deltaTheta = asin(deltaTheta / length);
- m_wb.correction = ((m_wb.radius - length) * m_wb.direction) /
- (deltaTheta / m_wb.theta);
- }
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic/Blend.h b/jni_mosaic/feature_mos/src/mosaic/Blend.h
deleted file mode 100644
index 2c7ee5c..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Blend.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// Blend.h
-// $Id: Blend.h,v 1.23 2011/06/24 04:22:14 mbansal Exp $
-
-#ifndef BLEND_H
-#define BLEND_H
-
-#include "MosaicTypes.h"
-#include "Pyramid.h"
-#include "Delaunay.h"
-
-#define BLEND_RANGE_DEFAULT 6
-#define BORDER 8
-
-// Percent of total mosaicing time spent on each of the following operations
-const float TIME_PERCENT_ALIGN = 20.0;
-const float TIME_PERCENT_BLEND = 75.0;
-const float TIME_PERCENT_FINAL = 5.0;
-
-// This threshold determines the minimum separation between the image centers
-// of the input image frames for them to be accepted for blending in the
-// STRIP_TYPE_WIDE mode.
-const float STRIP_SEPARATION_THRESHOLD_PXLS = 10;
-
-// This threshold determines the number of pixels on either side of the strip
-// to cross-fade using the images contributing to each seam.
-const float STRIP_CROSS_FADE_WIDTH_PXLS = 2;
-// This specifies the maximum pyramid level to which cross-fading is applied.
-// The original image resolution is Level-0, half of that size is Level-1 and
-// so on. BLEND_RANGE_DEFAULT specifies the number of pyramid levels used by
-// the blending algorithm.
-const int STRIP_CROSS_FADE_MAX_PYR_LEVEL = 2;
-
-/**
- * Class for pyramid blending a mosaic.
- */
-class Blend {
-
-public:
-
- static const int BLEND_TYPE_NONE = -1;
- static const int BLEND_TYPE_FULL = 0;
- static const int BLEND_TYPE_PAN = 1;
- static const int BLEND_TYPE_CYLPAN = 2;
- static const int BLEND_TYPE_HORZ = 3;
-
- static const int STRIP_TYPE_THIN = 0;
- static const int STRIP_TYPE_WIDE = 1;
-
- static const int BLEND_RET_ERROR = -1;
- static const int BLEND_RET_OK = 0;
- static const int BLEND_RET_ERROR_MEMORY = 1;
- static const int BLEND_RET_CANCELLED = -2;
-
- Blend();
- ~Blend();
-
- int initialize(int blendingType, int stripType, int frame_width, int frame_height);
-
- int runBlend(MosaicFrame **frames, MosaicFrame **rframes, int frames_size, ImageType &imageMosaicYVU,
- int &mosaicWidth, int &mosaicHeight, float &progress, bool &cancelComputation);
-
-protected:
-
- PyramidShort *m_pFrameYPyr;
- PyramidShort *m_pFrameUPyr;
- PyramidShort *m_pFrameVPyr;
-
- PyramidShort *m_pMosaicYPyr;
- PyramidShort *m_pMosaicUPyr;
- PyramidShort *m_pMosaicVPyr;
-
- CDelaunay m_Triangulator;
- CSite *m_AllSites;
-
- BlendParams m_wb;
-
- // Height and width of individual frames
- int width, height;
-
- // Height and width of mosaic
- unsigned short Mwidth, Mheight;
-
- // Helper functions
- void FrameToMosaic(double trs[3][3], double x, double y, double &wx, double &wy);
- void MosaicToFrame(double trs[3][3], double x, double y, double &wx, double &wy);
- void FrameToMosaicRect(int width, int height, double trs[3][3], BlendRect &brect);
- void ClipBlendRect(CSite *csite, BlendRect &brect);
- void AlignToMiddleFrame(MosaicFrame **frames, int frames_size);
-
- int DoMergeAndBlend(MosaicFrame **frames, int nsite, int width, int height, YUVinfo &imgMos, MosaicRect &rect, MosaicRect &cropping_rect, float &progress, bool &cancelComputation);
- void ComputeMask(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, int site_idx);
- void ProcessPyramidForThisFrame(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, double trs[3][3], int site_idx);
-
- int FillFramePyramid(MosaicFrame *mb);
-
- // TODO: need to add documentation about the parameters
- void ComputeBlendParameters(MosaicFrame **frames, int frames_size, int is360);
- void SelectRelevantFrames(MosaicFrame **frames, int frames_size,
- MosaicFrame **relevant_frames, int &relevant_frames_size);
-
- int PerformFinalBlending(YUVinfo &imgMos, MosaicRect &cropping_rect);
- void CropFinalMosaic(YUVinfo &imgMos, MosaicRect &cropping_rect);
-
-private:
- static const float LIMIT_SIZE_MULTIPLIER = 5.0f * 2.0f;
- static const float LIMIT_HEIGHT_MULTIPLIER = 2.5f;
- int MosaicSizeCheck(float sizeMultiplier, float heightMultiplier);
- void RoundingCroppingSizeToMultipleOf8(MosaicRect& rect);
-};
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/CSite.h b/jni_mosaic/feature_mos/src/mosaic/CSite.h
deleted file mode 100644
index 928c173..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/CSite.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// CSite.h
-// $Id: CSite.h,v 1.3 2011/06/17 13:35:47 mbansal Exp $
-
-#ifndef TRIDEL_H
-#define TRIDEL_H
-
-#include "MosaicTypes.h"
-
-typedef struct
-{
- short first;
- short second;
-} SEdgeVector;
-
-typedef struct
-{
- double x;
- double y;
-} SVec2d;
-
-class CSite
-{
-private:
- MosaicFrame *mosaicFrame;
- SEdgeVector *neighbor;
- int numNeighbors;
- SVec2d voronoiCenter;
-
-public:
- CSite();
- ~CSite();
-
- inline MosaicFrame* getMb() { return mosaicFrame; }
- inline SEdgeVector* getNeighbor() { return neighbor; }
- inline int getNumNeighbors() { return numNeighbors; }
- inline SVec2d& getVCenter() { return voronoiCenter; }
- inline double X() { return voronoiCenter.x; }
- inline double Y() { return voronoiCenter.y; }
-
- inline void incrNumNeighbors() { numNeighbors++; }
- inline void setNumNeighbors(int num) { numNeighbors = num; }
- inline void setNeighbor(SEdgeVector *nb) { neighbor = nb; }
- inline void setMb(MosaicFrame *mb) { mosaicFrame = mb; }
-};
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/Delaunay.cpp b/jni_mosaic/feature_mos/src/mosaic/Delaunay.cpp
deleted file mode 100644
index 0ce09fc..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Delaunay.cpp
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// Delaunay.cpp
-// $Id: Delaunay.cpp,v 1.10 2011/06/17 13:35:48 mbansal Exp $
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#include "Delaunay.h"
-
-#define QQ 9 // Optimal value as determined by testing
-#define DM 38 // 2^(1+DM/2) element sort capability. DM=38 for >10^6 elements
-#define NYL -1
-#define valid(l) ccw(orig(basel), dest(l), dest(basel))
-
-
-CDelaunay::CDelaunay()
-{
-}
-
-CDelaunay::~CDelaunay()
-{
-}
-
-// Allocate storage, construct triangulation, compute voronoi corners
-int CDelaunay::triangulate(SEdgeVector **edges, int n_sites, int width, int height)
-{
- EdgePointer cep;
-
- deleteAllEdges();
- buildTriangulation(n_sites);
- cep = consolidateEdges();
- *edges = ev;
-
- // Note: construction_list will change ev
- return constructList(cep, width, height);
-}
-
-// builds delaunay triangulation
-void CDelaunay::buildTriangulation(int size)
-{
- int i, rows;
- EdgePointer lefte, righte;
-
- rows = (int)( 0.5 + sqrt( (double) size / log( (double) size )));
-
- // Sort the pointers by x-coordinate of site
- for ( i=0 ; i < size ; i++ ) {
- sp[i] = (SitePointer) i;
- }
-
- spsortx( sp, 0, size-1 );
- build( 0, size-1, &lefte, &righte, rows );
- oneBndryEdge = lefte;
-}
-
-// Recursive Delaunay Triangulation Procedure
-// Contains modifications for axis-switching division.
-void CDelaunay::build(int lo, int hi, EdgePointer *le, EdgePointer *re, int rows)
-{
- EdgePointer a, b, c, ldo, rdi, ldi, rdo, maxx, minx;
- int split, lowrows;
- int low, high;
- SitePointer s1, s2, s3;
- low = lo;
- high = hi;
-
- if ( low < (high-2) ) {
- // more than three elements; do recursion
- minx = sp[low];
- maxx = sp[high];
- if (rows == 1) { // time to switch axis of division
- spsorty( sp, low, high);
- rows = 65536;
- }
- lowrows = rows/2;
- split = low - 1 + (int)
- (0.5 + ((double)(high-low+1) * ((double)lowrows / (double)rows)));
- build( low, split, &ldo, &ldi, lowrows );
- build( split+1, high, &rdi, &rdo, (rows-lowrows) );
- doMerge(&ldo, ldi, rdi, &rdo);
- while (orig(ldo) != minx) {
- ldo = rprev(ldo);
- }
- while (orig(rdo) != maxx) {
- rdo = (SitePointer) lprev(rdo);
- }
- *le = ldo;
- *re = rdo;
- }
- else if (low >= (high - 1)) { // two or one points
- a = makeEdge(sp[low], sp[high]);
- *le = a;
- *re = (EdgePointer) sym(a);
- } else { // three points
- // 3 cases: triangles of 2 orientations, and 3 points on a line
- a = makeEdge((s1 = sp[low]), (s2 = sp[low+1]));
- b = makeEdge(s2, (s3 = sp[high]));
- splice((EdgePointer) sym(a), b);
- if (ccw(s1, s3, s2)) {
- c = connectLeft(b, a);
- *le = (EdgePointer) sym(c);
- *re = c;
- } else {
- *le = a;
- *re = (EdgePointer) sym(b);
- if (ccw(s1, s2, s3)) {
- // not colinear
- c = connectLeft(b, a);
- }
- }
- }
-}
-
-// Quad-edge manipulation primitives
-EdgePointer CDelaunay::makeEdge(SitePointer origin, SitePointer destination)
-{
- EdgePointer temp, ans;
- temp = allocEdge();
- ans = temp;
-
- onext(temp) = ans;
- orig(temp) = origin;
- onext(++temp) = (EdgePointer) (ans + 3);
- onext(++temp) = (EdgePointer) (ans + 2);
- orig(temp) = destination;
- onext(++temp) = (EdgePointer) (ans + 1);
-
- return(ans);
-}
-
-void CDelaunay::splice(EdgePointer a, EdgePointer b)
-{
- EdgePointer alpha, beta, temp;
- alpha = (EdgePointer) rot(onext(a));
- beta = (EdgePointer) rot(onext(b));
- temp = onext(alpha);
- onext(alpha) = onext(beta);
- onext(beta) = temp;
- temp = onext(a);
- onext(a) = onext(b);
- onext(b) = temp;
-}
-
-EdgePointer CDelaunay::connectLeft(EdgePointer a, EdgePointer b)
-{
- EdgePointer ans;
- ans = makeEdge(dest(a), orig(b));
- splice(ans, (EdgePointer) lnext(a));
- splice((EdgePointer) sym(ans), b);
- return(ans);
-}
-
-EdgePointer CDelaunay::connectRight(EdgePointer a, EdgePointer b)
-{
- EdgePointer ans;
- ans = makeEdge(dest(a), orig(b));
- splice(ans, (EdgePointer) sym(a));
- splice((EdgePointer) sym(ans), (EdgePointer) oprev(b));
- return(ans);
-}
-
-// disconnects e from the rest of the structure and destroys it
-void CDelaunay::deleteEdge(EdgePointer e)
-{
- splice(e, (EdgePointer) oprev(e));
- splice((EdgePointer) sym(e), (EdgePointer) oprev(sym(e)));
- freeEdge(e);
-}
-
-//
-// Overall storage allocation
-//
-
-// Quad-edge storage allocation
-CSite *CDelaunay::allocMemory(int n)
-{
- unsigned int size;
-
- size = ((sizeof(CSite) + sizeof(SitePointer)) * n +
- (sizeof(SitePointer) + sizeof(EdgePointer)) * 12
- ) * n;
- if (!(sa = (CSite*) malloc(size))) {
- return NULL;
- }
- sp = (SitePointer *) (sa + n);
- ev = (SEdgeVector *) (org = sp + n);
- next = (EdgePointer *) (org + 12 * n);
- ei = (struct EDGE_INFO *) (next + 12 * n);
- return sa;
-}
-
-void CDelaunay::freeMemory()
-{
- if (sa) {
- free(sa);
- sa = (CSite*)NULL;
- }
-}
-
-//
-// Edge storage management
-//
-
-void CDelaunay::deleteAllEdges()
-{
- nextEdge = 0;
- availEdge = NYL;
-}
-
-EdgePointer CDelaunay::allocEdge()
-{
- EdgePointer ans;
-
- if (availEdge == NYL) {
- ans = nextEdge, nextEdge += 4;
- } else {
- ans = availEdge, availEdge = onext(availEdge);
- }
- return(ans);
-}
-
-void CDelaunay::freeEdge(EdgePointer e)
-{
- e ^= e & 3;
- onext(e) = availEdge;
- availEdge = e;
-}
-
-EdgePointer CDelaunay::consolidateEdges()
-{
- EdgePointer e;
- int i,j;
-
- while (availEdge != NYL) {
- nextEdge -= 4; e = availEdge; availEdge = onext(availEdge);
-
- if (e==nextEdge) {
- continue; // the one deleted was the last one anyway
- }
- if ((oneBndryEdge&~3) == nextEdge) {
- oneBndryEdge = (EdgePointer) (e | (oneBndryEdge&3));
- }
- for (i=0,j=3; i<4; i++,j=rot(j)) {
- onext(e+i) = onext(nextEdge+i);
- onext(rot(onext(e+i))) = (EdgePointer) (e+j);
- }
- }
- return nextEdge;
-}
-
-//
-// Sorting Routines
-//
-
-int CDelaunay::xcmpsp(int i, int j)
-{
- double d = sa[(i>=0)?sp[i]:sp1].X() - sa[(j>=0)?sp[j]:sp1].X();
- if ( d > 0. ) {
- return 1;
- }
- if ( d < 0. ) {
- return -1;
- }
- d = sa[(i>=0)?sp[i]:sp1].Y() - sa[(j>=0)?sp[j]:sp1].Y();
- if ( d > 0. ) {
- return 1;
- }
- if ( d < 0. ) {
- return -1;
- }
- return 0;
-}
-
-int CDelaunay::ycmpsp(int i, int j)
-{
- double d = sa[(i>=0)?sp[i]:sp1].Y() - sa[(j>=0)?sp[j]:sp1].Y();
- if ( d > 0. ) {
- return 1;
- }
- if ( d < 0. ) {
- return -1;
- }
- d = sa[(i>=0)?sp[i]:sp1].X() - sa[(j>=0)?sp[j]:sp1].X();
- if ( d > 0. ) {
- return 1;
- }
- if ( d < 0. ) {
- return -1;
- }
- return 0;
-}
-
-int CDelaunay::cmpev(int i, int j)
-{
- return (ev[i].first - ev[j].first);
-}
-
-void CDelaunay::swapsp(int i, int j)
-{
- int t;
- t = (i>=0) ? sp[i] : sp1;
-
- if (i>=0) {
- sp[i] = (j>=0)?sp[j]:sp1;
- } else {
- sp1 = (j>=0)?sp[j]:sp1;
- }
-
- if (j>=0) {
- sp[j] = (SitePointer) t;
- } else {
- sp1 = (SitePointer) t;
- }
-}
-
-void CDelaunay::swapev(int i, int j)
-{
- SEdgeVector temp;
-
- temp = ev[i];
- ev[i] = ev[j];
- ev[j] = temp;
-}
-
-void CDelaunay::copysp(int i, int j)
-{
- if (j>=0) {
- sp[j] = (i>=0)?sp[i]:sp1;
- } else {
- sp1 = (i>=0)?sp[i]:sp1;
- }
-}
-
-void CDelaunay::copyev(int i, int j)
-{
- ev[j] = ev[i];
-}
-
-void CDelaunay::spsortx(SitePointer *sp_in, int low, int high)
-{
- sp = sp_in;
- rcssort(low,high,-1,&CDelaunay::xcmpsp,&CDelaunay::swapsp,&CDelaunay::copysp);
-}
-
-void CDelaunay::spsorty(SitePointer *sp_in, int low, int high )
-{
- sp = sp_in;
- rcssort(low,high,-1,&CDelaunay::ycmpsp,&CDelaunay::swapsp,&CDelaunay::copysp);
-}
-
-void CDelaunay::rcssort(int lowelt, int highelt, int temp,
- int (CDelaunay::*comparison)(int,int),
- void (CDelaunay::*swap)(int,int),
- void (CDelaunay::*copy)(int,int))
-{
- int m,sij,si,sj,sL,sk;
- int stack[DM];
-
- if (highelt-lowelt<=1) {
- return;
- }
- if (highelt-lowelt>QQ) {
- m = 0;
- si = lowelt; sj = highelt;
- for (;;) { // partition [si,sj] about median-of-3.
- sij = (sj+si) >> 1;
-
- // Now to sort elements si,sij,sj into order & set temp=their median
- if ( (this->*comparison)( si,sij ) > 0 ) {
- (this->*swap)( si,sij );
- }
- if ( (this->*comparison)( sij,sj ) > 0 ) {
- (this->*swap)( sj,sij );
- if ( (this->*comparison)( si,sij ) > 0 ) {
- (this->*swap)( si,sij );
- }
- }
- (this->*copy)( sij,temp );
-
- // Now to partition into elements <=temp, >=temp, and ==temp.
- sk = si; sL = sj;
- do {
- do {
- sL--;
- } while( (this->*comparison)( sL,temp ) > 0 );
- do {
- sk++;
- } while( (this->*comparison)( temp,sk ) > 0 );
- if ( sk < sL ) {
- (this->*swap)( sL,sk );
- }
- } while(sk <= sL);
-
- // Now to recurse on shorter partition, store longer partition on stack
- if ( sL-si > sj-sk ) {
- if ( sL-si < QQ ) {
- if( m==0 ) {
- break; // empty stack && both partitions < QQ so break
- } else {
- sj = stack[--m];
- si = stack[--m];
- }
- }
- else {
- if ( sj-sk < QQ ) {
- sj = sL;
- } else {
- stack[m++] = si;
- stack[m++] = sL;
- si = sk;
- }
- }
- }
- else {
- if ( sj-sk < QQ ) {
- if ( m==0 ) {
- break; // empty stack && both partitions < QQ so break
- } else {
- sj = stack[--m];
- si = stack[--m];
- }
- }
- else {
- if ( sL-si < QQ ) {
- si = sk;
- } else {
- stack[m++] = sk;
- stack[m++] = sj;
- sj = sL;
- }
- }
- }
- }
- }
-
- // Now for 0 or Data bounded "straight insertion" sort of [0,nels-1]; if it is
- // known that el[-1] = -INF, then can omit the "sk>=0" test and save time.
- for (si=lowelt; si<highelt; si++) {
- if ( (this->*comparison)( si,si+1 ) > 0 ) {
- (this->*copy)( si+1,temp );
- sj = sk = si;
- sj++;
- do {
- (this->*copy)( sk,sj );
- sj = sk;
- sk--;
- } while ( (this->*comparison)( sk,temp ) > 0 && sk>=lowelt );
- (this->*copy)( temp,sj );
- }
- }
-}
-
-//
-// Geometric primitives
-//
-
-// incircle, as in the Guibas-Stolfi paper.
-int CDelaunay::incircle(SitePointer a, SitePointer b, SitePointer c, SitePointer d)
-{
- double adx, ady, bdx, bdy, cdx, cdy, dx, dy, nad, nbd, ncd;
- dx = sa[d].X();
- dy = sa[d].Y();
- adx = sa[a].X() - dx;
- ady = sa[a].Y() - dy;
- bdx = sa[b].X() - dx;
- bdy = sa[b].Y() - dy;
- cdx = sa[c].X() - dx;
- cdy = sa[c].Y() - dy;
- nad = adx*adx+ady*ady;
- nbd = bdx*bdx+bdy*bdy;
- ncd = cdx*cdx+cdy*cdy;
- return( (0.0 < (nad * (bdx * cdy - bdy * cdx)
- + nbd * (cdx * ady - cdy * adx)
- + ncd * (adx * bdy - ady * bdx))) ? TRUE : FALSE );
-}
-
-// TRUE iff A, B, C form a counterclockwise oriented triangle
-int CDelaunay::ccw(SitePointer a, SitePointer b, SitePointer c)
-{
- int result;
-
- double ax = sa[a].X();
- double bx = sa[b].X();
- double cx = sa[c].X();
- double ay = sa[a].Y();
- double by = sa[b].Y();
- double cy = sa[c].Y();
-
- double val = (ax - cx)*(by - cy) - (bx - cx)*(ay - cy);
- if ( val > 0.0) {
- return true;
- }
-
- return false;
-}
-
-//
-// The Merge Procedure.
-//
-
-void CDelaunay::doMerge(EdgePointer *ldo, EdgePointer ldi, EdgePointer rdi, EdgePointer *rdo)
-{
- int rvalid, lvalid;
- EdgePointer basel,lcand,rcand,t;
-
- for (;;) {
- while (ccw(orig(ldi), dest(ldi), orig(rdi))) {
- ldi = (EdgePointer) lnext(ldi);
- }
- if (ccw(dest(rdi), orig(rdi), orig(ldi))) {
- rdi = (EdgePointer)rprev(rdi);
- } else {
- break;
- }
- }
-
- basel = connectLeft((EdgePointer) sym(rdi), ldi);
- lcand = rprev(basel);
- rcand = (EdgePointer) oprev(basel);
- if (orig(basel) == orig(*rdo)) {
- *rdo = basel;
- }
- if (dest(basel) == orig(*ldo)) {
- *ldo = (EdgePointer) sym(basel);
- }
-
- for (;;) {
-#if 1
- if (valid(t=onext(lcand))) {
-#else
- t = (EdgePointer)onext(lcand);
- if (valid(basel, t)) {
-#endif
- while (incircle(dest(lcand), dest(t), orig(lcand), orig(basel))) {
- deleteEdge(lcand);
- lcand = t;
- t = onext(lcand);
- }
- }
-#if 1
- if (valid(t=(EdgePointer)oprev(rcand))) {
-#else
- t = (EdgePointer)oprev(rcand);
- if (valid(basel, t)) {
-#endif
- while (incircle(dest(t), dest(rcand), orig(rcand), dest(basel))) {
- deleteEdge(rcand);
- rcand = t;
- t = (EdgePointer)oprev(rcand);
- }
- }
-
-#if 1
- lvalid = valid(lcand);
- rvalid = valid(rcand);
-#else
- lvalid = valid(basel, lcand);
- rvalid = valid(basel, rcand);
-#endif
- if ((! lvalid) && (! rvalid)) {
- return;
- }
-
- if (!lvalid ||
- (rvalid && incircle(dest(lcand), orig(lcand), orig(rcand), dest(rcand)))) {
- basel = connectLeft(rcand, (EdgePointer) sym(basel));
- rcand = (EdgePointer) lnext(sym(basel));
- } else {
- basel = (EdgePointer) sym(connectRight(lcand, basel));
- lcand = rprev(basel);
- }
- }
-}
-
-int CDelaunay::constructList(EdgePointer last, int width, int height)
-{
- int c, i;
- EdgePointer curr, src, nex;
- SEdgeVector *currv, *prevv;
-
- c = (int) ((curr = (EdgePointer) ((last & ~3))) >> 1);
-
- for (last -= 4; last >= 0; last -= 4) {
- src = orig(last);
- nex = dest(last);
- orig(--curr) = src;
- orig(--curr) = nex;
- orig(--curr) = nex;
- orig(--curr) = src;
- }
- rcssort(0, c - 1, -1, &CDelaunay::cmpev, &CDelaunay::swapev, &CDelaunay::copyev);
-
- // Throw out any edges that are too far apart
- currv = prevv = ev;
- for (i = c; i--; currv++) {
- if ((int) fabs(sa[currv->first].getVCenter().x - sa[currv->second].getVCenter().x) <= width &&
- (int) fabs(sa[currv->first].getVCenter().y - sa[currv->second].getVCenter().y) <= height) {
- *(prevv++) = *currv;
- } else {
- c--;
- }
- }
- return c;
-}
-
-// Fill in site neighbor information
-void CDelaunay::linkNeighbors(SEdgeVector *edge, int nedge, int nsite)
-{
- int i;
-
- for (i = 0; i < nsite; i++) {
- sa[i].setNeighbor(edge);
- sa[i].setNumNeighbors(0);
- for (; edge->first == i && nedge; edge++, nedge--) {
- sa[i].incrNumNeighbors();
- }
- }
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic/Delaunay.h b/jni_mosaic/feature_mos/src/mosaic/Delaunay.h
deleted file mode 100644
index 7a450b5..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Delaunay.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// Delaunay.h
-// $Id: Delaunay.h,v 1.9 2011/06/17 13:35:48 mbansal Exp $
-
-#ifndef DELAUNAY_H
-#define DELAUNAY_H
-#include <stdio.h>
-#include <math.h>
-#include "CSite.h"
-#include "EdgePointerUtil.h"
-
-#ifndef TRUE
-#define TRUE 1==1
-#define FALSE 0==1
-#endif
-
-//******************************************************************************
-// Reference for Quad-edge data structure:
-//
-// Leonidas Guibas and Jorge Stolfi, "Primitives for the manipulation of general
-// subdivisions and the computations of Voronoi diagrams",
-// ACM Transactions on Graphics 4, 74-123 (1985).
-//
-//******************************************************************************
-
-//
-// Common data structures
-//
-
-typedef short SitePointer;
-typedef short TrianglePointer;
-
-class CDelaunay
-{
-private:
- CSite *sa;
- EdgePointer oneBndryEdge;
- EdgePointer *next;
- SitePointer *org;
- struct EDGE_INFO *ei;
- SitePointer *sp;
- SEdgeVector *ev;
-
- SitePointer sp1;
- EdgePointer nextEdge;
- EdgePointer availEdge;
-
-private:
- void build(int lo, int hi, EdgePointer *le, EdgePointer *re, int rows);
- void buildTriangulation(int size);
-
- EdgePointer allocEdge();
- void freeEdge(EdgePointer e);
-
- EdgePointer makeEdge(SitePointer origin, SitePointer destination);
- void deleteEdge(EdgePointer e);
-
- void splice(EdgePointer, EdgePointer);
- EdgePointer consolidateEdges();
- void deleteAllEdges();
-
- void spsortx(SitePointer *, int, int);
- void spsorty(SitePointer *, int, int);
-
- int cmpev(int i, int j);
- int xcmpsp(int i, int j);
- int ycmpsp(int i, int j);
-
- void swapsp(int i, int j);
- void swapev(int i, int j);
-
- void copysp(int i, int j);
- void copyev(int i, int j);
-
- void rcssort(int lowelt, int highelt, int temp,
- int (CDelaunay::*comparison)(int,int),
- void (CDelaunay::*swap)(int,int),
- void (CDelaunay::*copy)(int,int));
-
- void doMerge(EdgePointer *ldo, EdgePointer ldi, EdgePointer rdi, EdgePointer *rdo);
- EdgePointer connectLeft(EdgePointer a, EdgePointer b);
- EdgePointer connectRight(EdgePointer a, EdgePointer b);
- int ccw(SitePointer a, SitePointer b, SitePointer c);
- int incircle(SitePointer a, SitePointer b, SitePointer c, SitePointer d);
- int constructList(EdgePointer e, int width, int height);
-
-public:
- CDelaunay();
- ~CDelaunay();
-
- CSite *allocMemory(int nsite);
- void freeMemory();
- int triangulate(SEdgeVector **edge, int nsite, int width, int height);
- void linkNeighbors(SEdgeVector *edge, int nedge, int nsite);
-};
-
-#define onext(a) next[a]
-#define oprev(a) rot(onext(rot(a)))
-#define lnext(a) rot(onext(rotinv(a)))
-#define lprev(a) sym(onext(a))
-#define rnext(a) rotinv(onext(rot(a)))
-#define rprev(a) onext(sym(a))
-#define dnext(a) sym(onext(sym(a)))
-#define dprev(a) rotinv(onext(rotinv(a)))
-
-#define orig(a) org[a]
-#define dest(a) orig(sym(a))
-#define left(a) orig(rotinv(a))
-#define right(a) orig(rot(a))
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/EdgePointerUtil.h b/jni_mosaic/feature_mos/src/mosaic/EdgePointerUtil.h
deleted file mode 100644
index fad05d7..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/EdgePointerUtil.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef _EDGEPOINTERUTIL_H_
-#define _EDGEPOINTERUTIL_H_
-
-typedef short EdgePointer;
-
-inline EdgePointer sym(EdgePointer a)
-{
- return a ^ 2;
-}
-
-inline EdgePointer rot(EdgePointer a)
-{
- return (((a) + 1) & 3) | ((a) & ~3);
-}
-
-inline EdgePointer rotinv(EdgePointer a)
-{
- return (((a) + 3) & 3) | ((a) & ~3);
-}
-
-#endif //_EDGEPOINTERUTIL_H_
diff --git a/jni_mosaic/feature_mos/src/mosaic/Geometry.h b/jni_mosaic/feature_mos/src/mosaic/Geometry.h
deleted file mode 100644
index 0efa0f4..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Geometry.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/////////////////////////////
-// Geometry.h
-// $Id: Geometry.h,v 1.2 2011/06/17 13:35:48 mbansal Exp $
-
-#pragma once
-#include "MosaicTypes.h"
-
-///////////////////////////////////////////////////////////////
-///////////////// BEG GLOBAL ROUTINES /////////////////////////
-///////////////////////////////////////////////////////////////
-
-
-inline double hypotSq(double a, double b)
-{
- return ((a)*(a)+(b)*(b));
-}
-
-inline void ClipRect(double x, double y, BlendRect &brect)
-{
- if (y < brect.bot) brect.bot = y;
- if (y > brect.top) brect.top = y;
- if (x < brect.lft) brect.lft = x;
- if (x > brect.rgt) brect.rgt = x;
-}
-
-inline void ClipRect(BlendRect rrect, BlendRect &brect)
-{
- if (rrect.bot < brect.bot) brect.bot = rrect.bot;
- if (rrect.top > brect.top) brect.top = rrect.top;
- if (rrect.lft < brect.lft) brect.lft = rrect.lft;
- if (rrect.rgt > brect.rgt) brect.rgt = rrect.rgt;
-}
-
-// Clip x to be within [-border,width+border-1]
-inline void clipToSegment(int &x, int width, int border)
-{
- if(x < -border)
- x = -border;
- else if(x >= width+border)
- x = width + border - 1;
-}
-
-// Return true if x within [-border,width+border-1]
-inline bool inSegment(int x, int width, int border)
-{
- return (x >= -border && x < width + border - 1);
-}
-
-inline void FindTriangleCentroid(double x0, double y0, double x1, double y1,
- double x2, double y2,
- double &mass, double ¢X, double ¢Y)
-{
- // Calculate the centroid of the triangle
- centX = (x0 + x1 + x2) / 3.0;
- centY = (y0 + y1 + y2) / 3.0;
-
- // Calculate 2*Area for the triangle
- if (y0 == y2)
- {
- if (x0 == x1)
- {
- mass = fabs((y1 - y0) * (x2 - x0)); // Special case 1a
- }
- else
- {
- mass = fabs((y1 - y0) * (x1 - x0)); // Special case 1b
- }
- }
- else if (x0 == x2)
- {
- if (x0 == x1)
- {
- mass = fabs((x2 - x0) * (y2 - y0)); // Special case 2a
- }
- else
- {
- mass = fabs((x1 - x0) * (y2 - y0)); // Special case 2a
- }
- }
- else if (x1 == x2)
- {
- mass = fabs((x1 - x0) * (y2 - y0)); // Special case 3
- }
- else
- {
- // Calculate line equation from x0,y0 to x2,y2
- double dx = x2 - x0;
- double dy = y2 - y0;
- // Calculate the length of the side
- double len1 = sqrt(dx * dx + dy * dy);
- double m1 = dy / dx;
- double b1 = y0 - m1 * x0;
- // Calculate the line that goes through x1,y1 and is perpendicular to
- // the other line
- double m2 = 1.0 / m1;
- double b2 = y1 - m2 * x1;
- // Calculate the intersection of the two lines
- if (fabs( m1 - m2 ) > 1.e-6)
- {
- double x = (b2 - b1) / (m1 - m2);
- // the mass is the base * height
- dx = x1 - x;
- dy = y1 - m1 * x + b1;
- mass = len1 * sqrt(dx * dx + dy * dy);
- }
- else
- {
- mass = fabs( (y1 - y0) * (x2 - x0) );
- }
- }
-}
-
-inline void FindQuadCentroid(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3,
- double ¢X, double ¢Y)
-
-{
- // To find the centroid:
- // 1) Divide the quadrilateral into two triangles by scribing a diagonal
- // 2) Calculate the centroid of each triangle (the intersection of the angle bisections).
- // 3) Find the centroid of the quad by weighting each triangle centroids by their area.
-
- // Calculate the corner points
- double z;
-
- // The quad is split from x0,y0 to x2,y2
- double mass1, mass2, cent1x, cent2x, cent1y, cent2y;
- FindTriangleCentroid(x0, y0, x1, y1, x2, y2, mass1, cent1x, cent1y);
- FindTriangleCentroid(x0, y0, x3, y3, x2, y2, mass2, cent2x, cent2y);
-
- // determine position of quad centroid
- z = mass2 / (mass1 + mass2);
- centX = cent1x + (cent2x - cent1x) * z;
- centY = cent1y + (cent2y - cent1y) * z;
-}
-
-///////////////////////////////////////////////////////////////
-////////////////// END GLOBAL ROUTINES ////////////////////////
-///////////////////////////////////////////////////////////////
-
-
diff --git a/jni_mosaic/feature_mos/src/mosaic/ImageUtils.cpp b/jni_mosaic/feature_mos/src/mosaic/ImageUtils.cpp
deleted file mode 100644
index 6d0aac0..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/ImageUtils.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// ImageUtils.cpp
-// $Id: ImageUtils.cpp,v 1.12 2011/06/17 13:35:48 mbansal Exp $
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-
-#include "ImageUtils.h"
-
-void ImageUtils::rgba2yvu(ImageType out, ImageType in, int width, int height)
-{
- int r,g,b, a;
- ImageType yimg = out;
- ImageType vimg = yimg + width*height;
- ImageType uimg = vimg + width*height;
- ImageType image = in;
-
- for (int ii = 0; ii < height; ii++) {
- for (int ij = 0; ij < width; ij++) {
- r = (*image++);
- g = (*image++);
- b = (*image++);
- a = (*image++);
-
- if (r < 0) r = 0;
- if (r > 255) r = 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
-
- int val = (int) (REDY * r + GREENY * g + BLUEY * b) / 1000 + 16;
- if (val < 0) val = 0;
- if (val > 255) val = 255;
- *(yimg) = val;
-
- val = (int) (REDV * r - GREENV * g - BLUEV * b) / 1000 + 128;
- if (val < 0) val = 0;
- if (val > 255) val = 255;
- *(vimg) = val;
-
- val = (int) (-REDU * r - GREENU * g + BLUEU * b) / 1000 + 128;
- if (val < 0) val = 0;
- if (val > 255) val = 255;
- *(uimg) = val;
-
- yimg++;
- uimg++;
- vimg++;
- }
- }
-}
-
-
-void ImageUtils::rgb2yvu(ImageType out, ImageType in, int width, int height)
-{
- int r,g,b;
- ImageType yimg = out;
- ImageType vimg = yimg + width*height;
- ImageType uimg = vimg + width*height;
- ImageType image = in;
-
- for (int ii = 0; ii < height; ii++) {
- for (int ij = 0; ij < width; ij++) {
- r = (*image++);
- g = (*image++);
- b = (*image++);
-
- if (r < 0) r = 0;
- if (r > 255) r = 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
-
- int val = (int) (REDY * r + GREENY * g + BLUEY * b) / 1000 + 16;
- if (val < 0) val = 0;
- if (val > 255) val = 255;
- *(yimg) = val;
-
- val = (int) (REDV * r - GREENV * g - BLUEV * b) / 1000 + 128;
- if (val < 0) val = 0;
- if (val > 255) val = 255;
- *(vimg) = val;
-
- val = (int) (-REDU * r - GREENU * g + BLUEU * b) / 1000 + 128;
- if (val < 0) val = 0;
- if (val > 255) val = 255;
- *(uimg) = val;
-
- yimg++;
- uimg++;
- vimg++;
- }
- }
-}
-
-ImageType ImageUtils::rgb2gray(ImageType in, int width, int height)
-{
- int r,g,b, nr, ng, nb, val;
- ImageType gray = NULL;
- ImageType image = in;
- ImageType out = ImageUtils::allocateImage(width, height, 1);
- ImageType outCopy = out;
-
- for (int ii = 0; ii < height; ii++) {
- for (int ij = 0; ij < width; ij++) {
- r = (*image++);
- g = (*image++);
- b = (*image++);
-
- if (r < 0) r = 0;
- if (r > 255) r = 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
-
- (*outCopy) = ( 0.3*r + 0.59*g + 0.11*b);
-
- outCopy++;
- }
- }
-
- return out;
-}
-
-ImageType ImageUtils::rgb2gray(ImageType out, ImageType in, int width, int height)
-{
- int r,g,b, nr, ng, nb, val;
- ImageType gray = out;
- ImageType image = in;
- ImageType outCopy = out;
-
- for (int ii = 0; ii < height; ii++) {
- for (int ij = 0; ij < width; ij++) {
- r = (*image++);
- g = (*image++);
- b = (*image++);
-
- if (r < 0) r = 0;
- if (r > 255) r = 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
-
- (*outCopy) = ( 0.3*r + 0.59*g + 0.11*b);
-
- outCopy++;
- }
- }
-
- return out;
-
-}
-
-ImageType *ImageUtils::imageTypeToRowPointers(ImageType in, int width, int height)
-{
- int i;
- int m_h = height;
- int m_w = width;
-
- ImageType *m_rows = new ImageType[m_h];
-
- for (i=0;i<m_h;i++) {
- m_rows[i] = &in[(m_w)*i];
- }
- return m_rows;
-}
-
-void ImageUtils::yvu2rgb(ImageType out, ImageType in, int width, int height)
-{
- int y,v,u, r, g, b;
- unsigned char *yimg = in;
- unsigned char *vimg = yimg + width*height;
- unsigned char *uimg = vimg + width*height;
- unsigned char *image = out;
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
-
- y = (*yimg);
- v = (*vimg);
- u = (*uimg);
-
- if (y < 0) y = 0;
- if (y > 255) y = 255;
- if (u < 0) u = 0;
- if (u > 255) u = 255;
- if (v < 0) v = 0;
- if (v > 255) v = 255;
-
- b = (int) ( 1.164*(y - 16) + 2.018*(u-128));
- g = (int) ( 1.164*(y - 16) - 0.813*(v-128) - 0.391*(u-128));
- r = (int) ( 1.164*(y - 16) + 1.596*(v-128));
-
- if (r < 0) r = 0;
- if (r > 255) r = 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
-
- *(image++) = r;
- *(image++) = g;
- *(image++) = b;
-
- yimg++;
- uimg++;
- vimg++;
-
- }
- }
-}
-
-void ImageUtils::yvu2bgr(ImageType out, ImageType in, int width, int height)
-{
- int y,v,u, r, g, b;
- unsigned char *yimg = in;
- unsigned char *vimg = yimg + width*height;
- unsigned char *uimg = vimg + width*height;
- unsigned char *image = out;
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
-
- y = (*yimg);
- v = (*vimg);
- u = (*uimg);
-
- if (y < 0) y = 0;
- if (y > 255) y = 255;
- if (u < 0) u = 0;
- if (u > 255) u = 255;
- if (v < 0) v = 0;
- if (v > 255) v = 255;
-
- b = (int) ( 1.164*(y - 16) + 2.018*(u-128));
- g = (int) ( 1.164*(y - 16) - 0.813*(v-128) - 0.391*(u-128));
- r = (int) ( 1.164*(y - 16) + 1.596*(v-128));
-
- if (r < 0) r = 0;
- if (r > 255) r = 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
-
- *(image++) = b;
- *(image++) = g;
- *(image++) = r;
-
- yimg++;
- uimg++;
- vimg++;
-
- }
- }
-}
-
-
-ImageType ImageUtils::readBinaryPPM(const char *filename, int &width, int &height)
-{
-
- FILE *imgin = NULL;
- int mval=0, format=0, eret;
- ImageType ret = IMAGE_TYPE_NOIMAGE;
-
- imgin = fopen(filename, "r");
- if (imgin == NULL) {
- fprintf(stderr, "Error: Filename %s not found\n", filename);
- return ret;
- }
-
- eret = fscanf(imgin, "P%d\n", &format);
- if (format != 6) {
- fprintf(stderr, "Error: readBinaryPPM only supports PPM format (P6)\n");
- return ret;
- }
-
- eret = fscanf(imgin, "%d %d\n", &width, &height);
- eret = fscanf(imgin, "%d\n", &mval);
- ret = allocateImage(width, height, IMAGE_TYPE_NUM_CHANNELS);
- eret = fread(ret, sizeof(ImageTypeBase), IMAGE_TYPE_NUM_CHANNELS*width*height, imgin);
-
- fclose(imgin);
-
- return ret;
-
-}
-
-void ImageUtils::writeBinaryPPM(ImageType image, const char *filename, int width, int height, int numChannels)
-{
- FILE *imgout = fopen(filename, "w");
-
- if (imgout == NULL) {
- fprintf(stderr, "Error: Filename %s could not be opened for writing\n", filename);
- return;
- }
-
- if (numChannels == 3) {
- fprintf(imgout, "P6\n%d %d\n255\n", width, height);
- } else if (numChannels == 1) {
- fprintf(imgout, "P5\n%d %d\n255\n", width, height);
- } else {
- fprintf(stderr, "Error: writeBinaryPPM: Unsupported number of channels\n");
- }
- fwrite(image, sizeof(ImageTypeBase), numChannels*width*height, imgout);
-
- fclose(imgout);
-
-}
-
-ImageType ImageUtils::allocateImage(int width, int height, int numChannels, short int border)
-{
- int overallocation = 256;
- return (ImageType) calloc(width*height*numChannels+overallocation, sizeof(ImageTypeBase));
-}
-
-
-void ImageUtils::freeImage(ImageType image)
-{
- free(image);
-}
-
-
-// allocation of one color image used for tmp buffers, etc.
-// format of contiguous memory block:
-// YUVInfo struct (type + BimageInfo for Y,U, and V),
-// Y row pointers
-// U row pointers
-// V row pointers
-// Y image pixels
-// U image pixels
-// V image pixels
-YUVinfo *YUVinfo::allocateImage(unsigned short width, unsigned short height)
-{
- unsigned short heightUV, widthUV;
-
- widthUV = width;
- heightUV = height;
-
- // figure out how much space to hold all pixels...
- int size = ((width * height * 3) + 8);
- unsigned char *position = 0;
-
- // VC 8 does not like calling free on yuv->Y.ptr since it is in
- // the middle of a block. So rearrange the memory layout so after
- // calling mapYUVInforToImage yuv->Y.ptr points to the begginning
- // of the calloc'ed block.
- YUVinfo *yuv = (YUVinfo *) calloc(sizeof(YUVinfo), 1);
- if (yuv) {
- yuv->Y.width = yuv->Y.pitch = width;
- yuv->Y.height = height;
- yuv->Y.border = yuv->U.border = yuv->V.border = (unsigned short) 0;
- yuv->U.width = yuv->U.pitch = yuv->V.width = yuv->V.pitch = widthUV;
- yuv->U.height = yuv->V.height = heightUV;
-
- unsigned char* block = (unsigned char*) calloc(
- sizeof(unsigned char *) * (height + heightUV + heightUV) +
- sizeof(unsigned char) * size, 1);
-
- position = block;
- unsigned char **y = (unsigned char **) (block + size);
-
- /* Initialize and assign row pointers */
- yuv->Y.ptr = y;
- yuv->V.ptr = &y[height];
- yuv->U.ptr = &y[height + heightUV];
- }
- if (size)
- mapYUVInfoToImage(yuv, position);
- return yuv;
-}
-
-// wrap YUVInfo row pointers around 3 contiguous image (color component) planes.
-// position = starting pixel in image.
-void YUVinfo::mapYUVInfoToImage(YUVinfo *img, unsigned char *position)
-{
- int i;
- for (i = 0; i < img->Y.height; i++, position += img->Y.width)
- img->Y.ptr[i] = position;
- for (i = 0; i < img->V.height; i++, position += img->V.width)
- img->V.ptr[i] = position;
- for (i = 0; i < img->U.height; i++, position += img->U.width)
- img->U.ptr[i] = position;
-}
-
-
diff --git a/jni_mosaic/feature_mos/src/mosaic/ImageUtils.h b/jni_mosaic/feature_mos/src/mosaic/ImageUtils.h
deleted file mode 100644
index 92965ca..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/ImageUtils.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// ImageUtils.h
-// $Id: ImageUtils.h,v 1.9 2011/05/16 15:33:06 mbansal Exp $
-
-#ifndef IMAGE_UTILS_H
-#define IMAGE_UTILS_H
-
-#include <stdlib.h>
-
-/**
- * Definition of basic image types
- */
-typedef unsigned char ImageTypeBase;
-typedef ImageTypeBase *ImageType;
-
-typedef short ImageTypeShortBase;
-typedef ImageTypeShortBase *ImageTypeShort;
-
-typedef float ImageTypeFloatBase;
-typedef ImageTypeFloatBase *ImageTypeFloat;
-
-
-class ImageUtils {
-public:
-
- /**
- * Default number of channels in image.
- */
- static const int IMAGE_TYPE_NUM_CHANNELS = 3;
-
- /**
- * Definition of an empty image.
- */
- static const int IMAGE_TYPE_NOIMAGE = 0;
-
- /**
- * Convert image from BGR (interlaced) to YVU (non-interlaced)
- *
- * Arguments:
- * out: Resulting image (note must be preallocated before
- * call)
- * in: Input image
- * width: Width of input image
- * height: Height of input image
- */
- static void rgb2yvu(ImageType out, ImageType in, int width, int height);
-
- static void rgba2yvu(ImageType out, ImageType in, int width, int height);
-
- /**
- * Convert image from YVU (non-interlaced) to BGR (interlaced)
- *
- * Arguments:
- * out: Resulting image (note must be preallocated before
- * call)
- * in: Input image
- * width: Width of input image
- * height: Height of input image
- */
- static void yvu2rgb(ImageType out, ImageType in, int width, int height);
- static void yvu2bgr(ImageType out, ImageType in, int width, int height);
-
- /**
- * Convert image from BGR to grayscale
- *
- * Arguments:
- * in: Input image
- * width: Width of input image
- * height: Height of input image
- *
- * Return:
- * Pointer to resulting image (allocation is done here, free
- * must be done by caller)
- */
- static ImageType rgb2gray(ImageType in, int width, int height);
- static ImageType rgb2gray(ImageType out, ImageType in, int width, int height);
-
- /**
- * Read a binary PPM image
- */
- static ImageType readBinaryPPM(const char *filename, int &width, int &height);
-
- /**
- * Write a binary PPM image
- */
- static void writeBinaryPPM(ImageType image, const char *filename, int width, int height, int numChannels = IMAGE_TYPE_NUM_CHANNELS);
-
- /**
- * Allocate space for a standard image.
- */
- static ImageType allocateImage(int width, int height, int numChannels, short int border = 0);
-
- /**
- * Free memory of image
- */
- static void freeImage(ImageType image);
-
- static ImageType *imageTypeToRowPointers(ImageType out, int width, int height);
- /**
- * Get time.
- */
- static double getTime();
-
-protected:
-
- /**
- * Constants for YVU/RGB conversion
- */
- static const int REDY = 257;
- static const int REDV = 439;
- static const int REDU = 148;
- static const int GREENY = 504;
- static const int GREENV = 368;
- static const int GREENU = 291;
- static const int BLUEY = 98;
- static const int BLUEV = 71;
- static const int BLUEU = 439;
-
-};
-
-/**
- * Structure containing an image and other bookkeeping items.
- * Used in YUVinfo to store separate YVU image planes.
- */
-typedef struct {
- ImageType *ptr;
- unsigned short width;
- unsigned short height;
- unsigned short border;
- unsigned short pitch;
-} BimageInfo;
-
-/**
- * A YUV image container,
- */
-class YUVinfo {
-public:
- static YUVinfo *allocateImage(unsigned short width, unsigned short height);
- static void mapYUVInfoToImage(YUVinfo *img, unsigned char *position);
-
- /**
- * Y Plane
- */
- BimageInfo Y;
-
- /**
- * V (1st color) plane
- */
- BimageInfo V;
-
- /**
- * U (1st color) plane
- */
- BimageInfo U;
-};
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/Interp.h b/jni_mosaic/feature_mos/src/mosaic/Interp.h
deleted file mode 100644
index 19c4a40..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Interp.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////////////
-// Interp.h
-// $Id: Interp.h,v 1.2 2011/06/17 13:35:48 mbansal Exp $
-
-#ifndef INTERP_H
-#define INTERP_H
-
-#include "Pyramid.h"
-
-#define CTAPS 40
-static double ciTable[81] = {
- 1, 0.998461, 0.993938, 0.98657, 0.9765,
- 0.963867, 0.948813, 0.931477, 0.912, 0.890523,
- 0.867188, 0.842133, 0.8155, 0.78743, 0.758062,
- 0.727539, 0.696, 0.663586, 0.630437, 0.596695,
- 0.5625, 0.527992, 0.493312, 0.458602, 0.424,
- 0.389648, 0.355687, 0.322258, 0.2895, 0.257555,
- 0.226562, 0.196664, 0.168, 0.140711, 0.114937,
- 0.0908203, 0.0685, 0.0481172, 0.0298125, 0.0137266,
- 0, -0.0118828, -0.0225625, -0.0320859, -0.0405,
- -0.0478516, -0.0541875, -0.0595547, -0.064, -0.0675703,
- -0.0703125, -0.0722734, -0.0735, -0.0740391, -0.0739375,
- -0.0732422, -0.072, -0.0702578, -0.0680625, -0.0654609,
- -0.0625, -0.0592266, -0.0556875, -0.0519297, -0.048,
- -0.0439453, -0.0398125, -0.0356484, -0.0315, -0.0274141,
- -0.0234375, -0.0196172, -0.016, -0.0126328, -0.0095625,
- -0.00683594, -0.0045, -0.00260156, -0.0011875, -0.000304687, 0.0
-};
-
-inline double ciCalc(PyramidShort *img, int xi, int yi, double xfrac, double yfrac)
-{
- double tmpf[4];
-
- // Interpolate using 16 points
- ImageTypeShortBase *in = img->ptr[yi-1] + xi - 1;
- int off = (int)(xfrac * CTAPS);
-
- tmpf[0] = in[0] * ciTable[off + 40];
- tmpf[0] += in[1] * ciTable[off];
- tmpf[0] += in[2] * ciTable[40 - off];
- tmpf[0] += in[3] * ciTable[80 - off];
- in += img->pitch;
- tmpf[1] = in[0] * ciTable[off + 40];
- tmpf[1] += in[1] * ciTable[off];
- tmpf[1] += in[2] * ciTable[40 - off];
- tmpf[1] += in[3] * ciTable[80 - off];
- in += img->pitch;
- tmpf[2] = in[0] * ciTable[off + 40];
- tmpf[2] += in[1] * ciTable[off];
- tmpf[2] += in[2] * ciTable[40 - off];
- tmpf[2] += in[3] * ciTable[80 - off];
- in += img->pitch;
- tmpf[3] = in[0] * ciTable[off + 40];
- tmpf[3] += in[1] * ciTable[off];
- tmpf[3] += in[2] * ciTable[40 - off];
- tmpf[3] += in[3] * ciTable[80 - off];
-
- // this is the final interpolation
- off = (int)(yfrac * CTAPS);
- return (ciTable[off + 40] * tmpf[0] + ciTable[off] * tmpf[1] +
- ciTable[40 - off] * tmpf[2] + ciTable[80 - off] * tmpf[3]);
-}
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/Log.h b/jni_mosaic/feature_mos/src/mosaic/Log.h
deleted file mode 100644
index cf6f14b..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Log.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-#ifndef LOG_H_
-#define LOG_H
-
-#include <android/log.h>
-#define LOGV(...) __android_log_print(ANDROID_LOG_SILENT, LOG_TAG, __VA_ARGS__)
-#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
-#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/MatrixUtils.h b/jni_mosaic/feature_mos/src/mosaic/MatrixUtils.h
deleted file mode 100644
index a0b84d8..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/MatrixUtils.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// Matrixutils.h
-// $Id: MatrixUtils.h,v 1.5 2011/05/16 15:33:06 mbansal Exp $
-
-
-#ifndef MATRIX_UTILS_H
-#define MATRIX_UTILS_H
-
-/* Simple class for 3x3 matrix, mainly used to convert from 9x1
- * to 3x3
- */
-class Matrix33 {
-public:
-
- /**
- * Empty constructor
- */
- Matrix33() {
- initialize();
- }
-
- /**
- * Constructor with identity initialization
- * Arguments:
- * identity: Specifies wether to initialize matrix to
- * identity or zeros
- */
- Matrix33(bool identity) {
- initialize(identity);
- }
-
- /**
- * Initialize to identity matrix
- */
- void initialize(bool identity = false) {
- mat[0][1] = mat[0][2] = mat[1][0] = mat[1][2] = mat[2][0] = mat[2][1] = 0.0;
- if (identity) {
- mat[0][0] = mat[1][1] = mat[2][2] = 1.0;
- } else {
- mat[0][0] = mat[1][1] = mat[2][2] = 0.0;
- }
- }
-
- /**
- * Conver ta 9x1 matrix to a 3x3 matrix
- */
- static void convert9to33(double out[3][3], double in[9]) {
- out[0][0] = in[0];
- out[0][1] = in[1];
- out[0][2] = in[2];
-
- out[1][0] = in[3];
- out[1][1] = in[4];
- out[1][2] = in[5];
-
- out[2][0] = in[6];
- out[2][1] = in[7];
- out[2][2] = in[8];
-
- }
-
- /* Matrix data */
- double mat[3][3];
-
-};
-
-/* Simple class for 9x1 matrix, mainly used to convert from 3x3
- * to 9x1
- */
-class Matrix9 {
-public:
-
- /**
- * Empty constructor
- */
- Matrix9() {
- initialize();
- }
-
- /**
- * Constructor with identity initialization
- * Arguments:
- * identity: Specifies wether to initialize matrix to
- * identity or zeros
- */
- Matrix9(bool identity) {
- initialize(identity);
- }
-
- /**
- * Initialize to identity matrix
- */
- void initialize(bool identity = false) {
- mat[1] = mat[2] = mat[3] = mat[5] = mat[6] = mat[7] = 0.0;
- if (identity) {
- mat[0] = mat[4] = mat[8] = 1.0;
- } else {
- mat[0] = mat[4] = mat[8] = 0.0;
- }
- }
-
- /**
- * Conver ta 3x3 matrix to a 9x1 matrix
- */
- static void convert33to9(double out[9], double in[3][3]) {
- out[0] = in[0][0];
- out[1] = in[0][1];
- out[2] = in[0][2];
-
- out[3] = in[1][0];
- out[4] = in[1][1];
- out[5] = in[1][2];
-
- out[6] = in[2][0];
- out[7] = in[2][1];
- out[8] = in[2][2];
-
- }
-
- /* Matrix data */
- double mat[9];
-
-};
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/Mosaic.cpp b/jni_mosaic/feature_mos/src/mosaic/Mosaic.cpp
deleted file mode 100644
index 7b96fa5..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Mosaic.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// Mosaic.pp
-// S.O. # :
-// Author(s): zkira
-// $Id: Mosaic.cpp,v 1.20 2011/06/24 04:22:14 mbansal Exp $
-
-#include <stdio.h>
-#include <string.h>
-
-#include "Mosaic.h"
-#include "trsMatrix.h"
-
-#include "Log.h"
-#define LOG_TAG "MOSAIC"
-
-Mosaic::Mosaic()
-{
- initialized = false;
- imageMosaicYVU = NULL;
- frames_size = 0;
- max_frames = 200;
-}
-
-Mosaic::~Mosaic()
-{
- for (int i = 0; i < frames_size; i++)
- {
- if (frames[i])
- delete frames[i];
- }
- delete frames;
- delete rframes;
-
- for (int j = 0; j < owned_size; j++)
- delete owned_frames[j];
- delete owned_frames;
-
- if (aligner != NULL)
- delete aligner;
- if (blender != NULL)
- delete blender;
-}
-
-int Mosaic::initialize(int blendingType, int stripType, int width, int height, int nframes, bool quarter_res, float thresh_still)
-{
- this->blendingType = blendingType;
-
- // TODO: Review this logic if enabling FULL or PAN mode
- if (blendingType == Blend::BLEND_TYPE_FULL ||
- blendingType == Blend::BLEND_TYPE_PAN)
- {
- stripType = Blend::STRIP_TYPE_THIN;
- }
-
- this->stripType = stripType;
- this->width = width;
- this->height = height;
-
-
- mosaicWidth = mosaicHeight = 0;
- imageMosaicYVU = NULL;
-
- frames = new MosaicFrame *[max_frames];
- rframes = new MosaicFrame *[max_frames];
-
- if(nframes>-1)
- {
- for(int i=0; i<nframes; i++)
- {
- frames[i] = new MosaicFrame(this->width,this->height,false); // Do no allocate memory for YUV data
- }
- }
- else
- {
- for(int i=0; i<max_frames; i++)
- {
- frames[i] = NULL;
- }
- }
-
- owned_frames = new ImageType[max_frames];
- owned_size = 0;
-
- LOGV("Initialize %d %d", width, height);
- LOGV("Frame width %d,%d", width, height);
- LOGV("Max num frames %d", max_frames);
-
- aligner = new Align();
- aligner->initialize(width, height,quarter_res,thresh_still);
-
- if (blendingType == Blend::BLEND_TYPE_FULL ||
- blendingType == Blend::BLEND_TYPE_PAN ||
- blendingType == Blend::BLEND_TYPE_CYLPAN ||
- blendingType == Blend::BLEND_TYPE_HORZ) {
- blender = new Blend();
- blender->initialize(blendingType, stripType, width, height);
- } else {
- blender = NULL;
- LOGE("Error: Unknown blending type %d",blendingType);
- return MOSAIC_RET_ERROR;
- }
-
- initialized = true;
-
- return MOSAIC_RET_OK;
-}
-
-int Mosaic::addFrameRGB(ImageType imageRGB)
-{
- ImageType imageYVU;
- // Convert to YVU24 which is used by blending
- imageYVU = ImageUtils::allocateImage(this->width, this->height, ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
- ImageUtils::rgb2yvu(imageYVU, imageRGB, width, height);
-
- int existing_frames_size = frames_size;
- int ret = addFrame(imageYVU);
-
- if (frames_size > existing_frames_size)
- owned_frames[owned_size++] = imageYVU;
- else
- ImageUtils::freeImage(imageYVU);
-
- return ret;
-}
-
-int Mosaic::addFrame(ImageType imageYVU)
-{
- if(frames[frames_size]==NULL)
- frames[frames_size] = new MosaicFrame(this->width,this->height,false);
-
- MosaicFrame *frame = frames[frames_size];
-
- frame->image = imageYVU;
-
- // Add frame to aligner
- int ret = MOSAIC_RET_ERROR;
- if (aligner != NULL)
- {
- // Note aligner takes in RGB images
- int align_flag = Align::ALIGN_RET_OK;
- align_flag = aligner->addFrame(frame->image);
- aligner->getLastTRS(frame->trs);
-
- if (frames_size >= max_frames)
- {
- LOGV("WARNING: More frames than preallocated, ignoring."
- "Increase maximum number of frames (-f <max_frames>) to avoid this");
- return MOSAIC_RET_ERROR;
- }
-
- switch (align_flag)
- {
- case Align::ALIGN_RET_OK:
- frames_size++;
- ret = MOSAIC_RET_OK;
- break;
- case Align::ALIGN_RET_FEW_INLIERS:
- frames_size++;
- ret = MOSAIC_RET_FEW_INLIERS;
- break;
- case Align::ALIGN_RET_LOW_TEXTURE:
- ret = MOSAIC_RET_LOW_TEXTURE;
- break;
- case Align::ALIGN_RET_ERROR:
- ret = MOSAIC_RET_ERROR;
- break;
- default:
- break;
- }
- }
-
- return ret;
-}
-
-
-int Mosaic::createMosaic(float &progress, bool &cancelComputation)
-{
- if (frames_size <= 0)
- {
- // Haven't accepted any frame in aligner. No need to do blending.
- progress = TIME_PERCENT_ALIGN + TIME_PERCENT_BLEND
- + TIME_PERCENT_FINAL;
- return MOSAIC_RET_OK;
- }
-
- if (blendingType == Blend::BLEND_TYPE_PAN)
- {
-
- balanceRotations();
-
- }
-
- int ret = Blend::BLEND_RET_ERROR;
-
- // Blend the mosaic (alignment has already been done)
- if (blender != NULL)
- {
- ret = blender->runBlend((MosaicFrame **) frames, (MosaicFrame **) rframes,
- frames_size, imageMosaicYVU,
- mosaicWidth, mosaicHeight, progress, cancelComputation);
- }
-
- switch(ret)
- {
- case Blend::BLEND_RET_ERROR:
- case Blend::BLEND_RET_ERROR_MEMORY:
- ret = MOSAIC_RET_ERROR;
- break;
- case Blend::BLEND_RET_CANCELLED:
- ret = MOSAIC_RET_CANCELLED;
- break;
- case Blend::BLEND_RET_OK:
- ret = MOSAIC_RET_OK;
- }
- return ret;
-}
-
-ImageType Mosaic::getMosaic(int &width, int &height)
-{
- width = mosaicWidth;
- height = mosaicHeight;
-
- return imageMosaicYVU;
-}
-
-
-
-int Mosaic::balanceRotations()
-{
- // Normalize to the mean angle of rotation (Smiley face)
- double sineAngle = 0.0;
-
- for (int i = 0; i < frames_size; i++) sineAngle += frames[i]->trs[0][1];
- sineAngle /= frames_size;
- // Calculate the cosineAngle (1 - sineAngle*sineAngle) = cosineAngle*cosineAngle
- double cosineAngle = sqrt(1.0 - sineAngle*sineAngle);
- double m[3][3] = {
- { cosineAngle, -sineAngle, 0 },
- { sineAngle, cosineAngle, 0},
- { 0, 0, 1}};
- double tmp[3][3];
-
- for (int i = 0; i < frames_size; i++) {
- memcpy(tmp, frames[i]->trs, sizeof(tmp));
- mult33d(frames[i]->trs, m, tmp);
- }
-
- return MOSAIC_RET_OK;
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic/Mosaic.h b/jni_mosaic/feature_mos/src/mosaic/Mosaic.h
deleted file mode 100644
index 9dea664..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Mosaic.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// Mosaic.h
-// S.O. # :
-// Author(s): zkira
-// $Id: Mosaic.h,v 1.16 2011/06/24 04:22:14 mbansal Exp $
-
-#ifndef MOSAIC_H
-#define MOSAIC_H
-
-#include "ImageUtils.h"
-#include "AlignFeatures.h"
-#include "Blend.h"
-#include "MosaicTypes.h"
-
-/*! \mainpage Mosaic
-
- \section intro Introduction
- The class Mosaic provides a simple interface to the panoramic mosaicing algorithm. The class allows passing in individual image frames to be stitched together, computes the alignment transformation between them, and then stitches and blends them together into a single panoramic output which can then be accessed as a single image. \
-
- \section usage Usage
- The class methods need to be called as outlined in the sample application which is created from the mosaic_main.cpp file in the directory src/mosaic/. A brief snapshot of the flow is given below:
-
- \code
- Mosaic mosaic;
- // Define blending types to use, and the frame dimensions
- int blendingType = Blend::BLEND_TYPE_CYLPAN;
- int stripType = Blend::STRIP_TYPE_THIN;
- int width = 640;
- int height = 480;
-
- while (<image frames are available>)
- {
- // Check for initialization and if not, initialize
- if (!mosaic.isInitialized())
- {
- // Initialize mosaic processing
- mosaic.initialize(blendingType, stripType, width, height, -1, false, 5.0f);
- }
-
- // Add to list of frames
- mosaic.addFrameRGB(imageRGB);
-
- // Free image
- ImageUtils::freeImage(imageRGB);
- }
-
- // Create the mosaic
- ret = mosaic.createMosaic();
-
- // Get back the result
- resultYVU = mosaic.getMosaic(mosaicWidth, mosaicHeight);
-
- printf("Got mosaic of size %d,%d\n", mosaicWidth, mosaicHeight);
-
- \endcode
-*/
-
-/*!
- * Main class that creates a mosaic by creating an aligner and blender.
- */
-class Mosaic
-{
-
-public:
-
- Mosaic();
- ~Mosaic();
-
- /*!
- * Creates the aligner and blender and initializes state.
- * \param blendingType Type of blending to perform
- * \param stripType Type of strip to use. 0: thin, 1: wide. stripType
- * is effective only when blendingType is CylPan or
- * Horz. Otherwise, it is set to thin irrespective of the input.
- * \param width Width of input images (note: all images must be same size)
- * \param height Height of input images (note: all images must be same size)
- * \param nframes Number of frames to pre-allocate; default value -1 will allocate each frame as it comes
- * \param quarter_res Whether to compute alignment at quarter the input resolution (default = false)
- * \param thresh_still Minimum number of pixels of translation detected between the new frame and the last frame before this frame is added to be mosaiced. For the low-res processing at 320x180 resolution input, we set this to 5 pixels. To reject no frames, set this to 0.0 (default value).
- * \return Return code signifying success or failure.
- */
- int initialize(int blendingType, int stripType, int width, int height, int nframes = -1, bool quarter_res = false, float thresh_still = 0.0);
-
- /*!
- * Adds a YVU frame to the mosaic.
- * \param imageYVU Pointer to a YVU image.
- * \return Return code signifying success or failure.
- */
- int addFrame(ImageType imageYVU);
-
- /*!
- * Adds a RGB frame to the mosaic.
- * \param imageRGB Pointer to a RGB image.
- * \return Return code signifying success or failure.
- */
- int addFrameRGB(ImageType imageRGB);
-
- /*!
- * After adding all frames, call this function to perform the final blending.
- * \param progress Variable to set the current progress in.
- * \return Return code signifying success or failure.
- */
- int createMosaic(float &progress, bool &cancelComputation);
-
- /*!
- * Obtains the resulting mosaic and its dimensions.
- * \param width Width of the resulting mosaic (returned)
- * \param height Height of the resulting mosaic (returned)
- * \return Pointer to image.
- */
- ImageType getMosaic(int &width, int &height);
-
- /*!
- * Provides access to the internal alignment object pointer.
- * \return Pointer to the aligner object.
- */
- Align* getAligner() { return aligner; }
-
- /*!
- * Obtain initialization state.
- *
- * return Returns true if initialized, false otherwise.
- */
- bool isInitialized() { return initialized; }
-
-
- /*!
- * Return codes for mosaic.
- */
- static const int MOSAIC_RET_OK = 1;
- static const int MOSAIC_RET_ERROR = -1;
- static const int MOSAIC_RET_CANCELLED = -2;
- static const int MOSAIC_RET_LOW_TEXTURE = -3;
- static const int MOSAIC_RET_FEW_INLIERS = 2;
-
-protected:
-
- /**
- * Size of image frames making up mosaic
- */
- int width, height;
-
- /**
- * Size of actual mosaic
- */
- int mosaicWidth, mosaicHeight;
-
- /**
- * Bounding box to crop the mosaic when the gray border is not desired.
- */
- MosaicRect mosaicCroppingRect;
-
- ImageType imageMosaicYVU;
-
- /**
- * Collection of frames that will make up mosaic.
- */
- MosaicFrame **frames;
-
- /**
- * Subset of frames that are considered as relevant.
- */
- MosaicFrame **rframes;
-
- int frames_size;
- int max_frames;
-
- /**
- * Implicitly created frames, should be freed by Mosaic.
- */
- ImageType *owned_frames;
- int owned_size;
-
- /**
- * Initialization state.
- */
- bool initialized;
-
- /**
- * Type of blending to perform.
- */
- int blendingType;
-
- /**
- * Type of strip to use. 0: thin (default), 1: wide
- */
- int stripType;
-
- /**
- * Pointer to aligner.
- */
- Align *aligner;
-
- /**
- * Pointer to blender.
- */
- Blend *blender;
-
- /**
- * Modifies TRS matrices so that rotations are balanced
- * about center of mosaic
- *
- * Side effect: TRS matrices of all mosaic frames
- * are modified
- */
- int balanceRotations();
-
-};
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/MosaicTypes.h b/jni_mosaic/feature_mos/src/mosaic/MosaicTypes.h
deleted file mode 100644
index 395ec45..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/MosaicTypes.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// MosaicTypes.h
-// S.O. # :
-// Author(s): zkira
-// $Id: MosaicTypes.h,v 1.15 2011/06/17 13:35:48 mbansal Exp $
-
-
-#ifndef MOSAIC_TYPES_H
-#define MOSAIC_TYPES_H
-
-#include "ImageUtils.h"
-
-/**
- * Definition of rectangle in a mosaic.
- */
-class MosaicRect
-{
- public:
- MosaicRect()
- {
- left = right = top = bottom = 0.0;
- }
-
- inline int Width()
- {
- return right - left;
- }
-
- inline int Height()
- {
- return bottom - top;
- }
-
- /**
- * Bounds of the rectangle
- */
- int left, right, top, bottom;
-};
-
-class BlendRect
-{
- public:
- double lft, rgt, top, bot;
-};
-
-/**
- * A frame making up the mosaic.
- * Note: Currently assumes a YVU image
- * containing separate Y,V, and U planes
- * in contiguous memory (in that order).
- */
-class MosaicFrame {
-public:
- ImageType image;
- double trs[3][3];
- int width, height;
- BlendRect brect; // This frame warped to the Mosaic coordinate system
- BlendRect vcrect; // brect clipped using the voronoi neighbors
- bool internal_allocation;
-
- MosaicFrame() { };
- MosaicFrame(int _width, int _height, bool allocate=true)
- {
- width = _width;
- height = _height;
- internal_allocation = allocate;
- if(internal_allocation)
- image = ImageUtils::allocateImage(width, height, ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
- }
-
-
- ~MosaicFrame()
- {
- if(internal_allocation)
- if (image)
- free(image);
- }
-
- /**
- * Get the V plane of the image.
- */
- inline ImageType getV()
- {
- return (image + (width*height));
- }
-
- /**
- * Get the U plane of the image.
- */
- inline ImageType getU()
- {
- return (image + (width*height*2));
- }
-
- /**
- * Get a pixel from the V plane of the image.
- */
- inline int getV(int y, int x)
- {
- ImageType U = image + (width*height);
- return U[y*width+x];
- }
-
- /**
- * Get a pixel from the U plane of the image.
- */
- inline int getU(int y, int x)
- {
- ImageType U = image + (width*height*2);
- return U[y*width+x];
- }
-
-};
-
-/**
- * Structure for describing a warp.
- */
-typedef struct {
- int horizontal;
- double theta;
- double x;
- double y;
- double width;
- double radius;
- double direction;
- double correction;
- int blendRange;
- int blendRangeUV;
- int nlevs;
- int nlevsC;
- int blendingType;
- int stripType;
- // Add an overlap to prevent a gap between pictures due to roundoffs
- double roundoffOverlap;// 1.5
-
-} BlendParams;
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/Pyramid.cpp b/jni_mosaic/feature_mos/src/mosaic/Pyramid.cpp
deleted file mode 100644
index b022d73..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Pyramid.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// pyramid.cpp
-
-#include <stdio.h>
-#include <string.h>
-
-#include "Pyramid.h"
-
-// We allocate the entire pyramid into one contiguous storage. This makes
-// cleanup easier than fragmented stuff. In addition, we added a "pitch"
-// field, so pointer manipulation is much simpler when it would be faster.
-PyramidShort *PyramidShort::allocatePyramidPacked(real levels,
- real width, real height, real border)
-{
- real border2 = (real) (border << 1);
- int lines, size = calcStorage(width, height, border2, levels, &lines);
-
- PyramidShort *img = (PyramidShort *) calloc(sizeof(PyramidShort) * levels
- + sizeof(short *) * lines +
- + sizeof(short) * size, 1);
-
- if (img) {
- PyramidShort *curr, *last;
- ImageTypeShort *y = (ImageTypeShort *) &img[levels];
- ImageTypeShort position = (ImageTypeShort) &y[lines];
- for (last = (curr = img) + levels; curr < last; curr++) {
- curr->width = width;
- curr->height = height;
- curr->border = border;
- curr->pitch = (real) (width + border2);
- curr->ptr = y + border;
-
- // Assign row pointers
- for (int j = height + border2; j--; y++, position += curr->pitch) {
- *y = position + border;
- }
-
- width >>= 1;
- height >>= 1;
- }
- }
-
- return img;
-}
-
-// Allocate an image of type short
-PyramidShort *PyramidShort::allocateImage(real width, real height, real border)
-{
- real border2 = (real) (border << 1);
- PyramidShort *img = (PyramidShort *)
- calloc(sizeof(PyramidShort) + sizeof(short *) * (height + border2) +
- sizeof(short) * (width + border2) * (height + border2), 1);
-
- if (img) {
- short **y = (short **) &img[1];
- short *position = (short *) &y[height + border2];
- img->width = width;
- img->height = height;
- img->border = border;
- img->pitch = (real) (width + border2);
- img->ptr = y + border;
- position += border; // Move position down to origin of real image
-
- // Assign row pointers
- for (int j = height + border2; j--; y++, position += img->pitch) {
- *y = position;
- }
- }
-
- return img;
-}
-
-// Free the images
-void PyramidShort::freeImage(PyramidShort *image)
-{
- if (image != NULL)
- free(image);
-}
-
-// Calculate amount of storage needed taking into account the borders, etc.
-unsigned int PyramidShort::calcStorage(real width, real height, real border2, int levels, int *lines)
-{
- int size;
-
- *lines = size = 0;
-
- while(levels--) {
- size += (width + border2) * (height + border2);
- *lines += height + border2;
- width >>= 1;
- height >>= 1;
- }
-
- return size;
-}
-
-void PyramidShort::BorderSpread(PyramidShort *pyr, int left, int right,
- int top, int bot)
-{
- int off, off2, height, h, w;
- ImageTypeShort base;
-
- if (left || right) {
- off = pyr->border - left;
- off2 = pyr->width + off + pyr->border - right - 1;
- h = pyr->border - top;
- height = pyr->height + (h << 1);
- base = pyr->ptr[-h] - off;
-
- // spread in X
- for (h = height; h--; base += pyr->pitch) {
- for (w = left; w--;)
- base[-1 - w] = base[0];
- for (w = right; w--;)
- base[off2 + w + 1] = base[off2];
- }
- }
-
- if (top || bot) {
- // spread in Y
- base = pyr->ptr[top - pyr->border] - pyr->border;
- for (h = top; h--; base -= pyr->pitch) {
- memcpy(base - pyr->pitch, base, pyr->pitch * sizeof(short));
- }
-
- base = pyr->ptr[pyr->height + pyr->border - bot] - pyr->border;
- for (h = bot; h--; base += pyr->pitch) {
- memcpy(base, base - pyr->pitch, pyr->pitch * sizeof(short));
- }
- }
-}
-
-void PyramidShort::BorderExpandOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr,
- int mode)
-{
- int i,j;
- int off = in->border / 2;
-
- // Vertical Filter
- for (j = -off; j < in->height + off; j++) {
- int j2 = j * 2;
- int limit = scr->width + scr->border;
- for (i = -scr->border; i < limit; i++) {
- int t1 = in->ptr[j][i];
- int t2 = in->ptr[j+1][i];
- scr->ptr[j2][i] = (short)
- ((6 * t1 + (in->ptr[j-1][i] + t2) + 4) >> 3);
- scr->ptr[j2+1][i] = (short)((t1 + t2 + 1) >> 1);
- }
- }
-
- BorderSpread(scr, 0, 0, 3, 3);
-
- // Horizontal Filter
- int limit = out->height + out->border;
- for (j = -out->border; j < limit; j++) {
- for (i = -off; i < scr->width + off; i++) {
- int i2 = i * 2;
- int t1 = scr->ptr[j][i];
- int t2 = scr->ptr[j][i+1];
- out->ptr[j][i2] = (short) (out->ptr[j][i2] +
- (mode * ((6 * t1 +
- scr->ptr[j][i-1] + t2 + 4) >> 3)));
- out->ptr[j][i2+1] = (short) (out->ptr[j][i2+1] +
- (mode * ((t1 + t2 + 1) >> 1)));
- }
- }
-
-}
-
-int PyramidShort::BorderExpand(PyramidShort *pyr, int nlev, int mode)
-{
- PyramidShort *tpyr = pyr + nlev - 1;
- PyramidShort *scr = allocateImage(pyr[1].width, pyr[0].height, pyr->border);
- if (scr == NULL) return 0;
-
- if (mode > 0) {
- // Expand and add (reconstruct from Laplacian)
- for (; tpyr > pyr; tpyr--) {
- scr->width = tpyr[0].width;
- scr->height = tpyr[-1].height;
- BorderExpandOdd(tpyr, tpyr - 1, scr, 1);
- }
- }
- else if (mode < 0) {
- // Expand and subtract (build Laplacian)
- while ((pyr++) < tpyr) {
- scr->width = pyr[0].width;
- scr->height = pyr[-1].height;
- BorderExpandOdd(pyr, pyr - 1, scr, -1);
- }
- }
-
- freeImage(scr);
- return 1;
-}
-
-void PyramidShort::BorderReduceOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr)
-{
- ImageTypeShortBase *s, *ns, *ls, *p, *np;
-
- int off = scr->border - 2;
- s = scr->ptr[-scr->border] - (off >> 1);
- ns = s + scr->pitch;
- ls = scr->ptr[scr->height + scr->border - 1] + scr->pitch - (off >> 1);
- int width = scr->width + scr->border;
- p = in->ptr[-scr->border] - off;
- np = p + in->pitch;
-
- // treat it as if the whole thing were the image
- for (; s < ls; s = ns, ns += scr->pitch, p = np, np += in->pitch) {
- for (int w = width; w--; s++, p += 2) {
- *s = (short)((((int) p[-2]) + ((int) p[2]) + 8 + // 1
- ((((int) p[-1]) + ((int) p[1])) << 2) + // 4
- ((int) *p) * 6) >> 4); // 6
- }
- }
-
- BorderSpread(scr, 5, 4 + ((in->width ^ 1) & 1), 0, 0); //
-
- s = out->ptr[-(off >> 1)] - out->border;
- ns = s + out->pitch;
- ls = s + out->pitch * (out->height + off);
- p = scr->ptr[-off] - out->border;
- int pitch = scr->pitch;
- int pitch2 = pitch << 1;
- np = p + pitch2;
- for (; s < ls; s = ns, ns += out->pitch, p = np, np += pitch2) {
- for (int w = out->pitch; w--; s++, p++) {
- *s = (short)((((int) p[-pitch2]) + ((int) p[pitch2]) + 8 + // 1
- ((((int) p[-pitch]) + ((int) p[pitch])) << 2) + // 4
- ((int) *p) * 6) >> 4); // 6
- }
- }
- BorderSpread(out, 0, 0, 5, 5);
-
-}
-
-int PyramidShort::BorderReduce(PyramidShort *pyr, int nlev)
-{
- PyramidShort *scr = allocateImage(pyr[1].width, pyr[0].height, pyr->border);
- if (scr == NULL)
- return 0;
-
- BorderSpread(pyr, pyr->border, pyr->border, pyr->border, pyr->border);
- while (--nlev) {
- BorderReduceOdd(pyr, pyr + 1, scr);
- pyr++;
- scr->width = pyr[1].width;
- scr->height = pyr[0].height;
- }
-
- freeImage(scr);
- return 1;
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic/Pyramid.h b/jni_mosaic/feature_mos/src/mosaic/Pyramid.h
deleted file mode 100644
index c5fe907..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/Pyramid.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// Pyramid.h
-
-#ifndef PYRAMID_H
-#define PYRAMID_H
-
-#include "ImageUtils.h"
-
-typedef unsigned short int real;
-
-// Structure containing a packed pyramid of type ImageTypeShort. Used for pyramid
-// blending, among other things.
-
-class PyramidShort
-{
-
-public:
-
- ImageTypeShort *ptr; // Pointer containing the image
- real width, height; // Width and height of input images
- real numChannels; // Number of channels in input images
- real border; // border size
- real pitch; // Pitch. Used for moving through image efficiently.
-
- static PyramidShort *allocatePyramidPacked(real width, real height, real levels, real border = 0);
- static PyramidShort *allocateImage(real width, real height, real border);
- static void createPyramid(ImageType image, PyramidShort *pyramid, int last = 3 );
- static void freeImage(PyramidShort *image);
-
- static unsigned int calcStorage(real width, real height, real border2, int levels, int *lines);
-
- static void BorderSpread(PyramidShort *pyr, int left, int right, int top, int bot);
- static void BorderExpandOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr, int mode);
- static int BorderExpand(PyramidShort *pyr, int nlev, int mode);
- static int BorderReduce(PyramidShort *pyr, int nlev);
- static void BorderReduceOdd(PyramidShort *in, PyramidShort *out, PyramidShort *scr);
-};
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic/trsMatrix.cpp b/jni_mosaic/feature_mos/src/mosaic/trsMatrix.cpp
deleted file mode 100644
index 5fc6a86..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/trsMatrix.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// trsMatrix.cpp
-// $Id: trsMatrix.cpp,v 1.9 2011/06/17 13:35:48 mbansal Exp $
-
-#include "stdio.h"
-#include <math.h>
-#include "trsMatrix.h"
-
-void mult33d(double a[3][3], double b[3][3], double c[3][3])
-{
- a[0][0] = b[0][0]*c[0][0] + b[0][1]*c[1][0] + b[0][2]*c[2][0];
- a[0][1] = b[0][0]*c[0][1] + b[0][1]*c[1][1] + b[0][2]*c[2][1];
- a[0][2] = b[0][0]*c[0][2] + b[0][1]*c[1][2] + b[0][2]*c[2][2];
- a[1][0] = b[1][0]*c[0][0] + b[1][1]*c[1][0] + b[1][2]*c[2][0];
- a[1][1] = b[1][0]*c[0][1] + b[1][1]*c[1][1] + b[1][2]*c[2][1];
- a[1][2] = b[1][0]*c[0][2] + b[1][1]*c[1][2] + b[1][2]*c[2][2];
- a[2][0] = b[2][0]*c[0][0] + b[2][1]*c[1][0] + b[2][2]*c[2][0];
- a[2][1] = b[2][0]*c[0][1] + b[2][1]*c[1][1] + b[2][2]*c[2][1];
- a[2][2] = b[2][0]*c[0][2] + b[2][1]*c[1][2] + b[2][2]*c[2][2];
-}
-
-
-// normProjMat33d
-// m = input matrix
-// return: result if successful
-int normProjMat33d(double m[3][3])
-{
- double m22;
-
- if(m[2][2] == 0.0)
- {
- return 0;
-}
-
- m[0][0] /= m[2][2];
- m[0][1] /= m[2][2];
- m[0][2] /= m[2][2];
- m[1][0] /= m[2][2];
- m[1][1] /= m[2][2];
- m[1][2] /= m[2][2];
- m[2][0] /= m[2][2];
- m[2][1] /= m[2][2];
- m[2][2] = 1.0;
-
- return 1;
-}
-
-// det33d
-// m = input matrix
-// returns: determinant
-double det33d(const double m[3][3])
-{
- double result;
-
- result = m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]);
- result += m[0][1] * (m[1][2] * m[2][0] - m[1][0] * m[2][2]);
- result += m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
-
- return result;
-}
-
-// inv33d
-//
-void inv33d(const double m[3][3], double out[3][3])
-{
- double det = det33d(m);
-
- out[0][0] = (m[1][1]*m[2][2] - m[1][2]*m[2][1]) / det;
- out[1][0] = (m[1][2]*m[2][0] - m[1][0]*m[2][2]) / det;
- out[2][0] = (m[1][0]*m[2][1] - m[1][1]*m[2][0]) / det;
-
- out[0][1] = (m[0][2]*m[2][1] - m[0][1]*m[2][2]) / det;
- out[1][1] = (m[0][0]*m[2][2] - m[0][2]*m[2][0]) / det;
- out[2][1] = (m[0][1]*m[2][0] - m[0][0]*m[2][1]) / det;
-
- out[0][2] = (m[0][1]*m[1][2] - m[0][2]*m[1][1]) / det;
- out[1][2] = (m[0][2]*m[1][0] - m[0][0]*m[1][2]) / det;
- out[2][2] = (m[0][0]*m[1][1] - m[0][1]*m[1][0]) / det;
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic/trsMatrix.h b/jni_mosaic/feature_mos/src/mosaic/trsMatrix.h
deleted file mode 100644
index 054cc33..0000000
--- a/jni_mosaic/feature_mos/src/mosaic/trsMatrix.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-///////////////////////////////////////////////////
-// trsMatrix.h
-// $Id: trsMatrix.h,v 1.8 2011/06/17 13:35:48 mbansal Exp $
-
-#ifndef TRSMATRIX_H_
-#define TRSMATRIX_H_
-
-
-// Calculate the determinant of a matrix
-double det33d(const double m[3][3]);
-
-// Invert a matrix
-void inv33d(const double m[3][3], double out[3][3]);
-
-// Multiply a = b * c
-void mult33d(double a[3][3], double b[3][3], double c[3][3]);
-
-// Normalize matrix so matrix[2][2] is '1'
-int normProjMat33d(double m[3][3]);
-
-inline double ProjZ(double trs[3][3], double x, double y, double f)
-{
- return ((trs)[2][0]*(x) + (trs)[2][1]*(y) + (trs)[2][2]*(f));
-}
-
-inline double ProjX(double trs[3][3], double x, double y, double z, double f)
-{
- return (((trs)[0][0]*(x) + (trs)[0][1]*(y) + (trs)[0][2]*(f)) / (z));
-}
-
-inline double ProjY(double trs[3][3], double x, double y, double z, double f)
-{
- return (((trs)[1][0]*(x) + (trs)[1][1]*(y) + (trs)[1][2]*(f)) / (z));
-}
-
-
-#endif
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/FrameBuffer.cpp b/jni_mosaic/feature_mos/src/mosaic_renderer/FrameBuffer.cpp
deleted file mode 100755
index a956f23..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/FrameBuffer.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "FrameBuffer.h"
-
-FrameBuffer::FrameBuffer()
-{
- Reset();
-}
-
-FrameBuffer::~FrameBuffer() {
-}
-
-void FrameBuffer::Reset() {
- mFrameBufferName = -1;
- mTextureName = -1;
- mWidth = 0;
- mHeight = 0;
- mFormat = -1;
-}
-
-bool FrameBuffer::InitializeGLContext() {
- Reset();
- return CreateBuffers();
-}
-
-bool FrameBuffer::Init(int width, int height, GLenum format) {
- if (mFrameBufferName == (GLuint)-1) {
- if (!CreateBuffers()) {
- return false;
- }
- }
- glBindFramebuffer(GL_FRAMEBUFFER, mFrameBufferName);
- glBindTexture(GL_TEXTURE_2D, mTextureName);
-
- glTexImage2D(GL_TEXTURE_2D,
- 0,
- format,
- width,
- height,
- 0,
- format,
- GL_UNSIGNED_BYTE,
- NULL);
- if (!checkGlError("bind/teximage")) {
- return false;
- }
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- // This is necessary to work with user-generated frame buffers with
- // dimensions that are NOT powers of 2.
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- // Attach texture to frame buffer.
- glFramebufferTexture2D(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- mTextureName,
- 0);
- checkFramebufferStatus("FrameBuffer.cpp");
- checkGlError("framebuffertexture2d");
-
- if (!checkGlError("texture setup")) {
- return false;
- }
- mWidth = width;
- mHeight = height;
- mFormat = format;
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- return true;
-}
-
-bool FrameBuffer::CreateBuffers() {
- glGenFramebuffers(1, &mFrameBufferName);
- glGenTextures(1, &mTextureName);
- if (!checkGlError("texture generation")) {
- return false;
- }
- return true;
-}
-
-GLuint FrameBuffer::GetTextureName() const {
- return mTextureName;
-}
-
-GLuint FrameBuffer::GetFrameBufferName() const {
- return mFrameBufferName;
-}
-
-GLenum FrameBuffer::GetFormat() const {
- return mFormat;
-}
-
-int FrameBuffer::GetWidth() const {
- return mWidth;
-}
-
-int FrameBuffer::GetHeight() const {
- return mHeight;
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/FrameBuffer.h b/jni_mosaic/feature_mos/src/mosaic_renderer/FrameBuffer.h
deleted file mode 100755
index 314b126..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/FrameBuffer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-
-#include <EGL/egl.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-#define checkGlError(op) checkGLErrorDetail(__FILE__, __LINE__, (op))
-
-extern bool checkGLErrorDetail(const char* file, int line, const char* op);
-extern void checkFramebufferStatus(const char* name);
-
-class FrameBuffer {
- public:
- FrameBuffer();
- virtual ~FrameBuffer();
-
- bool InitializeGLContext();
- bool Init(int width, int height, GLenum format);
- GLuint GetTextureName() const;
- GLuint GetFrameBufferName() const;
- GLenum GetFormat() const;
-
- int GetWidth() const;
- int GetHeight() const;
-
- private:
- void Reset();
- bool CreateBuffers();
- GLuint mFrameBufferName;
- GLuint mTextureName;
- int mWidth;
- int mHeight;
- GLenum mFormat;
-};
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/Renderer.cpp b/jni_mosaic/feature_mos/src/mosaic_renderer/Renderer.cpp
deleted file mode 100755
index b9938eb..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/Renderer.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "Renderer.h"
-
-#include "mosaic/Log.h"
-#define LOG_TAG "Renderer"
-
-#include <GLES2/gl2ext.h>
-
-Renderer::Renderer()
- : mGlProgram(0),
- mInputTextureName(-1),
- mInputTextureWidth(0),
- mInputTextureHeight(0),
- mSurfaceWidth(0),
- mSurfaceHeight(0)
-{
- InitializeGLContext();
-}
-
-Renderer::~Renderer() {
-}
-
-GLuint Renderer::loadShader(GLenum shaderType, const char* pSource) {
- GLuint shader = glCreateShader(shaderType);
- if (shader) {
- glShaderSource(shader, 1, &pSource, NULL);
- glCompileShader(shader);
- GLint compiled = 0;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
- if (!compiled) {
- GLint infoLen = 0;
- glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
- if (infoLen) {
- char* buf = (char*) malloc(infoLen);
- if (buf) {
- glGetShaderInfoLog(shader, infoLen, NULL, buf);
- LOGE("Could not compile shader %d:\n%s\n",
- shaderType, buf);
- free(buf);
- }
- glDeleteShader(shader);
- shader = 0;
- }
- }
- }
- return shader;
-}
-
-GLuint Renderer::createProgram(const char* pVertexSource, const char* pFragmentSource)
-{
- GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource);
- if (!vertexShader)
- {
- return 0;
- }
-
- GLuint pixelShader = loadShader(GL_FRAGMENT_SHADER, pFragmentSource);
- if (!pixelShader)
- {
- return 0;
- }
-
- GLuint program = glCreateProgram();
- if (program)
- {
- glAttachShader(program, vertexShader);
- checkGlError("glAttachShader");
- glAttachShader(program, pixelShader);
- checkGlError("glAttachShader");
-
- glLinkProgram(program);
- GLint linkStatus = GL_FALSE;
- glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
-
- LOGI("Program Linked (%d)!", program);
-
- if (linkStatus != GL_TRUE)
- {
- GLint bufLength = 0;
- glGetProgramiv(program, GL_INFO_LOG_LENGTH, &bufLength);
- if (bufLength)
- {
- char* buf = (char*) malloc(bufLength);
- if (buf)
- {
- glGetProgramInfoLog(program, bufLength, NULL, buf);
- LOGE("Could not link program:\n%s\n", buf);
- free(buf);
- }
- }
- glDeleteProgram(program);
- program = 0;
- }
- }
- return program;
-}
-
-// Set this renderer to use the default frame-buffer (screen) and
-// set the viewport size to be the given width and height (pixels).
-bool Renderer::SetupGraphics(int width, int height)
-{
- bool succeeded = false;
- do {
- if (mGlProgram == 0)
- {
- if (!InitializeGLProgram())
- {
- break;
- }
- }
- glUseProgram(mGlProgram);
- if (!checkGlError("glUseProgram")) break;
-
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
- mFrameBuffer = NULL;
- mSurfaceWidth = width;
- mSurfaceHeight = height;
-
- glViewport(0, 0, mSurfaceWidth, mSurfaceHeight);
- if (!checkGlError("glViewport")) break;
- succeeded = true;
- } while (false);
-
- return succeeded;
-}
-
-
-// Set this renderer to use the specified FBO and
-// set the viewport size to be the width and height of this FBO.
-bool Renderer::SetupGraphics(FrameBuffer* buffer)
-{
- bool succeeded = false;
- do {
- if (mGlProgram == 0)
- {
- if (!InitializeGLProgram())
- {
- break;
- }
- }
- glUseProgram(mGlProgram);
- if (!checkGlError("glUseProgram")) break;
-
- glBindFramebuffer(GL_FRAMEBUFFER, buffer->GetFrameBufferName());
-
- mFrameBuffer = buffer;
- mSurfaceWidth = mFrameBuffer->GetWidth();
- mSurfaceHeight = mFrameBuffer->GetHeight();
-
- glViewport(0, 0, mSurfaceWidth, mSurfaceHeight);
- if (!checkGlError("glViewport")) break;
- succeeded = true;
- } while (false);
-
- return succeeded;
-}
-
-bool Renderer::Clear(float r, float g, float b, float a)
-{
- bool succeeded = false;
- do {
- bool rt = (mFrameBuffer == NULL)?
- SetupGraphics(mSurfaceWidth, mSurfaceHeight) :
- SetupGraphics(mFrameBuffer);
-
- if(!rt)
- break;
-
- glClearColor(r, g, b, a);
- glClear(GL_COLOR_BUFFER_BIT);
-
- succeeded = true;
- } while (false);
- return succeeded;
-
-}
-
-void Renderer::InitializeGLContext()
-{
- if(mFrameBuffer != NULL)
- {
- delete mFrameBuffer;
- mFrameBuffer = NULL;
- }
-
- mInputTextureName = -1;
- mInputTextureType = GL_TEXTURE_2D;
- mGlProgram = 0;
-}
-
-int Renderer::GetTextureName()
-{
- return mInputTextureName;
-}
-
-void Renderer::SetInputTextureName(GLuint textureName)
-{
- mInputTextureName = textureName;
-}
-
-void Renderer::SetInputTextureType(GLenum textureType)
-{
- mInputTextureType = textureType;
-}
-
-void Renderer::SetInputTextureDimensions(int width, int height)
-{
- mInputTextureWidth = width;
- mInputTextureHeight = height;
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/Renderer.h b/jni_mosaic/feature_mos/src/mosaic_renderer/Renderer.h
deleted file mode 100755
index a43e802..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/Renderer.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#pragma once
-
-#include "FrameBuffer.h"
-
-#include <GLES2/gl2.h>
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-class Renderer {
- public:
- Renderer();
- virtual ~Renderer();
-
- // Initialize OpenGL resources
- // @return true if successful
- virtual bool InitializeGLProgram() = 0;
-
- bool SetupGraphics(FrameBuffer* buffer);
- bool SetupGraphics(int width, int height);
-
- bool Clear(float r, float g, float b, float a);
-
- int GetTextureName();
- void SetInputTextureName(GLuint textureName);
- void SetInputTextureDimensions(int width, int height);
- void SetInputTextureType(GLenum textureType);
-
- void InitializeGLContext();
-
- protected:
-
- GLuint loadShader(GLenum shaderType, const char* pSource);
- GLuint createProgram(const char*, const char* );
-
- int SurfaceWidth() const { return mSurfaceWidth; }
- int SurfaceHeight() const { return mSurfaceHeight; }
-
- // Source code for shaders.
- virtual const char* VertexShaderSource() const = 0;
- virtual const char* FragmentShaderSource() const = 0;
-
- // Redefine this to use special texture types such as
- // GL_TEXTURE_EXTERNAL_OES.
- GLenum InputTextureType() const { return mInputTextureType; }
-
- GLuint mGlProgram;
- GLuint mInputTextureName;
- GLenum mInputTextureType;
- int mInputTextureWidth;
- int mInputTextureHeight;
-
- // Attribute locations
- GLint mScalingtransLoc;
- GLint maPositionHandle;
- GLint maTextureHandle;
-
-
- int mSurfaceWidth; // Width of target surface.
- int mSurfaceHeight; // Height of target surface.
-
- FrameBuffer *mFrameBuffer;
-};
-
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp b/jni_mosaic/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp
deleted file mode 100755
index 88aac36..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "SurfaceTextureRenderer.h"
-
-#include <GLES2/gl2ext.h>
-const GLfloat g_vVertices[] = {
- -1.f, -1.f, 0.0f, 1.0f, // Position 0
- 0.0f, 0.0f, // TexCoord 0
- 1.f, -1.f, 0.0f, 1.0f, // Position 1
- 1.0f, 0.0f, // TexCoord 1
- -1.f, 1.f, 0.0f, 1.0f, // Position 2
- 0.0f, 1.0f, // TexCoord 2
- 1.f, 1.f, 0.0f, 1.0f, // Position 3
- 1.0f, 1.0f // TexCoord 3
-};
-GLushort g_iIndices2[] = { 0, 1, 2, 3 };
-
-const int GL_TEXTURE_EXTERNAL_OES_ENUM = 0x8D65;
-
-const int VERTEX_STRIDE = 6 * sizeof(GLfloat);
-
-SurfaceTextureRenderer::SurfaceTextureRenderer() : Renderer() {
- memset(mSTMatrix, 0.0, 16*sizeof(float));
- mSTMatrix[0] = 1.0f;
- mSTMatrix[5] = 1.0f;
- mSTMatrix[10] = 1.0f;
- mSTMatrix[15] = 1.0f;
-}
-
-SurfaceTextureRenderer::~SurfaceTextureRenderer() {
-}
-
-void SurfaceTextureRenderer::SetViewportMatrix(int w, int h, int W, int H)
-{
- for(int i=0; i<16; i++)
- {
- mViewportMatrix[i] = 0.0f;
- }
-
- mViewportMatrix[0] = float(w)/float(W);
- mViewportMatrix[5] = float(h)/float(H);
- mViewportMatrix[10] = 1.0f;
- mViewportMatrix[12] = -1.0f + float(w)/float(W);
- mViewportMatrix[13] = -1.0f + float(h)/float(H);
- mViewportMatrix[15] = 1.0f;
-}
-
-void SurfaceTextureRenderer::SetScalingMatrix(float xscale, float yscale)
-{
- for(int i=0; i<16; i++)
- {
- mScalingMatrix[i] = 0.0f;
- }
-
- mScalingMatrix[0] = xscale;
- mScalingMatrix[5] = yscale;
- mScalingMatrix[10] = 1.0f;
- mScalingMatrix[15] = 1.0f;
-}
-
-void SurfaceTextureRenderer::SetSTMatrix(float *stmat)
-{
- memcpy(mSTMatrix, stmat, 16*sizeof(float));
-}
-
-
-bool SurfaceTextureRenderer::InitializeGLProgram()
-{
- bool succeeded = false;
- do {
- GLuint glProgram;
- glProgram = createProgram(VertexShaderSource(),
- FragmentShaderSource());
- if (!glProgram) {
- break;
- }
-
- glUseProgram(glProgram);
- if (!checkGlError("glUseProgram")) break;
-
- maPositionHandle = glGetAttribLocation(glProgram, "aPosition");
- checkGlError("glGetAttribLocation aPosition");
- maTextureHandle = glGetAttribLocation(glProgram, "aTextureCoord");
- checkGlError("glGetAttribLocation aTextureCoord");
- muSTMatrixHandle = glGetUniformLocation(glProgram, "uSTMatrix");
- checkGlError("glGetUniformLocation uSTMatrix");
- mScalingtransLoc = glGetUniformLocation(glProgram, "u_scalingtrans");
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- mGlProgram = glProgram;
- succeeded = true;
- } while (false);
-
- if (!succeeded && (mGlProgram != 0))
- {
- glDeleteProgram(mGlProgram);
- checkGlError("glDeleteProgram");
- mGlProgram = 0;
- }
- return succeeded;
-}
-
-bool SurfaceTextureRenderer::DrawTexture(GLfloat *affine)
-{
- bool succeeded = false;
- do {
- bool rt = (mFrameBuffer == NULL)?
- SetupGraphics(mSurfaceWidth, mSurfaceHeight) :
- SetupGraphics(mFrameBuffer);
-
- if(!rt)
- break;
-
- glDisable(GL_BLEND);
-
- glActiveTexture(GL_TEXTURE0);
- if (!checkGlError("glActiveTexture")) break;
-
- const GLenum texture_type = InputTextureType();
- glBindTexture(texture_type, mInputTextureName);
- if (!checkGlError("glBindTexture")) break;
-
- glUniformMatrix4fv(mScalingtransLoc, 1, GL_FALSE, mScalingMatrix);
- glUniformMatrix4fv(muSTMatrixHandle, 1, GL_FALSE, mSTMatrix);
-
- // Load the vertex position
- glVertexAttribPointer(maPositionHandle, 4, GL_FLOAT,
- GL_FALSE, VERTEX_STRIDE, g_vVertices);
- glEnableVertexAttribArray(maPositionHandle);
- // Load the texture coordinate
- glVertexAttribPointer(maTextureHandle, 2, GL_FLOAT,
- GL_FALSE, VERTEX_STRIDE, &g_vVertices[4]);
- glEnableVertexAttribArray(maTextureHandle);
-
- // And, finally, execute the GL draw command.
- glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, g_iIndices2);
-
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- succeeded = true;
- } while (false);
- return succeeded;
-}
-
-const char* SurfaceTextureRenderer::VertexShaderSource() const
-{
- static const char gVertexShader[] =
- "uniform mat4 uSTMatrix;\n"
- "uniform mat4 u_scalingtrans; \n"
- "attribute vec4 aPosition;\n"
- "attribute vec4 aTextureCoord;\n"
- "varying vec2 vTextureNormCoord;\n"
- "void main() {\n"
- " gl_Position = u_scalingtrans * aPosition;\n"
- " vTextureNormCoord = (uSTMatrix * aTextureCoord).xy;\n"
- "}\n";
-
- return gVertexShader;
-}
-
-const char* SurfaceTextureRenderer::FragmentShaderSource() const
-{
- static const char gFragmentShader[] =
- "#extension GL_OES_EGL_image_external : require\n"
- "precision mediump float;\n"
- "varying vec2 vTextureNormCoord;\n"
- "uniform samplerExternalOES sTexture;\n"
- "void main() {\n"
- " gl_FragColor = texture2D(sTexture, vTextureNormCoord);\n"
- "}\n";
-
- return gFragmentShader;
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.h b/jni_mosaic/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.h
deleted file mode 100755
index ea2b81a..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/SurfaceTextureRenderer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#pragma once
-
-#include "FrameBuffer.h"
-#include "Renderer.h"
-
-#include <GLES2/gl2.h>
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-class SurfaceTextureRenderer: public Renderer {
- public:
- SurfaceTextureRenderer();
- virtual ~SurfaceTextureRenderer();
-
- // Initialize OpenGL resources
- // @return true if successful
- bool InitializeGLProgram();
-
- bool DrawTexture(GLfloat *affine);
-
- void SetViewportMatrix(int w, int h, int W, int H);
- void SetScalingMatrix(float xscale, float yscale);
- void SetSTMatrix(float *stmat);
-
- private:
- // Source code for shaders.
- const char* VertexShaderSource() const;
- const char* FragmentShaderSource() const;
-
- // Attribute locations
- GLint mScalingtransLoc;
- GLint muSTMatrixHandle;
- GLint maPositionHandle;
- GLint maTextureHandle;
-
- GLfloat mViewportMatrix[16];
- GLfloat mScalingMatrix[16];
-
- GLfloat mSTMatrix[16];
-
-};
-
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/WarpRenderer.cpp b/jni_mosaic/feature_mos/src/mosaic_renderer/WarpRenderer.cpp
deleted file mode 100755
index af6779a..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/WarpRenderer.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "WarpRenderer.h"
-
-#include <GLES2/gl2ext.h>
-
-const GLfloat g_vVertices[] = {
- -1.f, 1.f, 0.0f, 1.0f, // Position 0
- 0.0f, 1.0f, // TexCoord 0
- 1.f, 1.f, 0.0f, 1.0f, // Position 1
- 1.0f, 1.0f, // TexCoord 1
- -1.f, -1.f, 0.0f, 1.0f, // Position 2
- 0.0f, 0.0f, // TexCoord 2
- 1.f, -1.f, 0.0f, 1.0f, // Position 3
- 1.0f, 0.0f // TexCoord 3
-};
-
-const int VERTEX_STRIDE = 6 * sizeof(GLfloat);
-
-GLushort g_iIndices[] = { 0, 1, 2, 3 };
-
-WarpRenderer::WarpRenderer() : Renderer()
-{
-}
-
-WarpRenderer::~WarpRenderer() {
-}
-
-void WarpRenderer::SetViewportMatrix(int w, int h, int W, int H)
-{
- for(int i=0; i<16; i++)
- {
- mViewportMatrix[i] = 0.0f;
- }
-
- mViewportMatrix[0] = float(w)/float(W);
- mViewportMatrix[5] = float(h)/float(H);
- mViewportMatrix[10] = 1.0f;
- mViewportMatrix[12] = -1.0f + float(w)/float(W);
- mViewportMatrix[13] = -1.0f + float(h)/float(H);
- mViewportMatrix[15] = 1.0f;
-}
-
-void WarpRenderer::SetScalingMatrix(float xscale, float yscale)
-{
- for(int i=0; i<16; i++)
- {
- mScalingMatrix[i] = 0.0f;
- }
-
- mScalingMatrix[0] = xscale;
- mScalingMatrix[5] = yscale;
- mScalingMatrix[10] = 1.0f;
- mScalingMatrix[15] = 1.0f;
-}
-
-bool WarpRenderer::InitializeGLProgram()
-{
- bool succeeded = false;
- do {
- GLuint glProgram;
- glProgram = createProgram(VertexShaderSource(),
- FragmentShaderSource());
- if (!glProgram) {
- break;
- }
-
- glUseProgram(glProgram);
- if (!checkGlError("glUseProgram")) break;
-
- // Get attribute locations
- mPositionLoc = glGetAttribLocation(glProgram, "a_position");
- mAffinetransLoc = glGetUniformLocation(glProgram, "u_affinetrans");
- mViewporttransLoc = glGetUniformLocation(glProgram, "u_viewporttrans");
- mScalingtransLoc = glGetUniformLocation(glProgram, "u_scalingtrans");
- mTexCoordLoc = glGetAttribLocation(glProgram, "a_texCoord");
-
- // Get sampler location
- mSamplerLoc = glGetUniformLocation(glProgram, "s_texture");
-
- mGlProgram = glProgram;
- succeeded = true;
- } while (false);
-
- if (!succeeded && (mGlProgram != 0))
- {
- glDeleteProgram(mGlProgram);
- checkGlError("glDeleteProgram");
- mGlProgram = 0;
- }
- return succeeded;
-}
-
-bool WarpRenderer::DrawTexture(GLfloat *affine)
-{
- bool succeeded = false;
- do {
- bool rt = (mFrameBuffer == NULL)?
- SetupGraphics(mSurfaceWidth, mSurfaceHeight) :
- SetupGraphics(mFrameBuffer);
-
- if(!rt)
- break;
-
- glDisable(GL_BLEND);
-
- glActiveTexture(GL_TEXTURE0);
- if (!checkGlError("glActiveTexture")) break;
-
- const GLenum texture_type = InputTextureType();
- glBindTexture(texture_type, mInputTextureName);
- if (!checkGlError("glBindTexture")) break;
-
- // Set the sampler texture unit to 0
- glUniform1i(mSamplerLoc, 0);
-
- // Load the vertex position
- glVertexAttribPointer(mPositionLoc, 4, GL_FLOAT,
- GL_FALSE, VERTEX_STRIDE, g_vVertices);
-
- // Load the texture coordinate
- glVertexAttribPointer(mTexCoordLoc, 2, GL_FLOAT,
- GL_FALSE, VERTEX_STRIDE, &g_vVertices[4]);
-
- glEnableVertexAttribArray(mPositionLoc);
- glEnableVertexAttribArray(mTexCoordLoc);
-
- // pass matrix information to the vertex shader
- glUniformMatrix4fv(mAffinetransLoc, 1, GL_FALSE, affine);
- glUniformMatrix4fv(mViewporttransLoc, 1, GL_FALSE, mViewportMatrix);
- glUniformMatrix4fv(mScalingtransLoc, 1, GL_FALSE, mScalingMatrix);
-
- // And, finally, execute the GL draw command.
- glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, g_iIndices);
-
- checkGlError("glDrawElements");
-
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- succeeded = true;
- } while (false);
- return succeeded;
-}
-
-const char* WarpRenderer::VertexShaderSource() const
-{
- static const char gVertexShader[] =
- "uniform mat4 u_affinetrans; \n"
- "uniform mat4 u_viewporttrans; \n"
- "uniform mat4 u_scalingtrans; \n"
- "attribute vec4 a_position; \n"
- "attribute vec2 a_texCoord; \n"
- "varying vec2 v_texCoord; \n"
- "void main() \n"
- "{ \n"
- " gl_Position = u_scalingtrans * u_viewporttrans * u_affinetrans * a_position; \n"
- " v_texCoord = a_texCoord; \n"
- "} \n";
-
- return gVertexShader;
-}
-
-const char* WarpRenderer::FragmentShaderSource() const
-{
- static const char gFragmentShader[] =
- "precision mediump float; \n"
- "varying vec2 v_texCoord; \n"
- "uniform sampler2D s_texture; \n"
- "void main() \n"
- "{ \n"
- " vec4 color; \n"
- " color = texture2D(s_texture, v_texCoord); \n"
- " gl_FragColor = color; \n"
- "} \n";
-
- return gFragmentShader;
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/WarpRenderer.h b/jni_mosaic/feature_mos/src/mosaic_renderer/WarpRenderer.h
deleted file mode 100755
index 8e9a694..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/WarpRenderer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#pragma once
-
-#include "FrameBuffer.h"
-#include "Renderer.h"
-
-#include <GLES2/gl2.h>
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-class WarpRenderer: public Renderer {
- public:
- WarpRenderer();
- virtual ~WarpRenderer();
-
- // Initialize OpenGL resources
- // @return true if successful
- bool InitializeGLProgram();
-
- void SetViewportMatrix(int w, int h, int W, int H);
- void SetScalingMatrix(float xscale, float yscale);
-
- bool DrawTexture(GLfloat *affine);
-
- private:
- // Source code for shaders.
- const char* VertexShaderSource() const;
- const char* FragmentShaderSource() const;
-
- GLuint mTexHandle; // Handle to s_texture.
- GLuint mTexCoordHandle; // Handle to a_texCoord.
- GLuint mTriangleVerticesHandle; // Handle to vPosition.
-
- // Attribute locations
- GLint mPositionLoc;
- GLint mAffinetransLoc;
- GLint mViewporttransLoc;
- GLint mScalingtransLoc;
- GLint mTexCoordLoc;
-
- GLfloat mViewportMatrix[16];
- GLfloat mScalingMatrix[16];
-
- // Sampler location
- GLint mSamplerLoc;
-};
-
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/YVURenderer.cpp b/jni_mosaic/feature_mos/src/mosaic_renderer/YVURenderer.cpp
deleted file mode 100755
index f7dcf6f..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/YVURenderer.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "YVURenderer.h"
-
-#include <GLES2/gl2ext.h>
-
-const GLfloat g_vVertices[] = {
- -1.f, 1.f, 0.0f, 1.0f, // Position 0
- 0.0f, 1.0f, // TexCoord 0
- 1.f, 1.f, 0.0f, 1.0f, // Position 1
- 1.0f, 1.0f, // TexCoord 1
- -1.f, -1.f, 0.0f, 1.0f, // Position 2
- 0.0f, 0.0f, // TexCoord 2
- 1.f, -1.f, 0.0f, 1.0f, // Position 3
- 1.0f, 0.0f // TexCoord 3
-};
-
-const int VERTEX_STRIDE = 6 * sizeof(GLfloat);
-
-GLushort g_iIndices3[] = { 0, 1, 2, 3 };
-
-YVURenderer::YVURenderer() : Renderer()
- {
-}
-
-YVURenderer::~YVURenderer() {
-}
-
-bool YVURenderer::InitializeGLProgram()
-{
- bool succeeded = false;
- do {
- GLuint glProgram;
- glProgram = createProgram(VertexShaderSource(),
- FragmentShaderSource());
- if (!glProgram) {
- break;
- }
-
- glUseProgram(glProgram);
- if (!checkGlError("glUseProgram")) break;
-
- // Get attribute locations
- mPositionLoc = glGetAttribLocation(glProgram, "a_Position");
- mTexCoordLoc = glGetAttribLocation(glProgram, "a_texCoord");
-
- // Get sampler location
- mSamplerLoc = glGetUniformLocation(glProgram, "s_texture");
-
- mGlProgram = glProgram;
- succeeded = true;
- } while (false);
-
- if (!succeeded && (mGlProgram != 0))
- {
- glDeleteProgram(mGlProgram);
- checkGlError("glDeleteProgram");
- mGlProgram = 0;
- }
- return succeeded;
-}
-
-bool YVURenderer::DrawTexture()
-{
- bool succeeded = false;
- do {
- bool rt = (mFrameBuffer == NULL)?
- SetupGraphics(mSurfaceWidth, mSurfaceHeight) :
- SetupGraphics(mFrameBuffer);
-
- if(!rt)
- break;
-
- glDisable(GL_BLEND);
-
- glActiveTexture(GL_TEXTURE0);
- if (!checkGlError("glActiveTexture")) break;
-
- const GLenum texture_type = InputTextureType();
- glBindTexture(texture_type, mInputTextureName);
- if (!checkGlError("glBindTexture")) break;
-
- // Set the sampler texture unit to 0
- glUniform1i(mSamplerLoc, 0);
-
- // Load the vertex position
- glVertexAttribPointer(mPositionLoc, 4, GL_FLOAT,
- GL_FALSE, VERTEX_STRIDE, g_vVertices);
-
- // Load the texture coordinate
- glVertexAttribPointer(mTexCoordLoc, 2, GL_FLOAT,
- GL_FALSE, VERTEX_STRIDE, &g_vVertices[4]);
-
- glEnableVertexAttribArray(mPositionLoc);
- glEnableVertexAttribArray(mTexCoordLoc);
-
- // And, finally, execute the GL draw command.
- glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, g_iIndices3);
-
- checkGlError("glDrawElements");
-
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- succeeded = true;
- } while (false);
- return succeeded;
-}
-
-const char* YVURenderer::VertexShaderSource() const
-{
- // All this really does is copy the coordinates into
- // variables for the fragment shader to pick up.
- static const char gVertexShader[] =
- "attribute vec4 a_Position;\n"
- "attribute vec2 a_texCoord;\n"
- "varying vec2 v_texCoord;\n"
- "void main() {\n"
- " gl_Position = a_Position;\n"
- " v_texCoord = a_texCoord;\n"
- "}\n";
-
- return gVertexShader;
-}
-
-const char* YVURenderer::FragmentShaderSource() const
-{
- static const char gFragmentShader[] =
- "precision mediump float;\n"
- "uniform sampler2D s_texture;\n"
- "const vec4 coeff_y = vec4(0.257, 0.594, 0.098, 0.063);\n"
- "const vec4 coeff_v = vec4(0.439, -0.368, -0.071, 0.500);\n"
- "const vec4 coeff_u = vec4(-0.148, -0.291, 0.439, 0.500);\n"
- "varying vec2 v_texCoord;\n"
- "void main() {\n"
- " vec4 p;\n"
- " p = texture2D(s_texture, v_texCoord);\n"
- " gl_FragColor[0] = dot(p, coeff_y);\n"
- " p = texture2D(s_texture, v_texCoord);\n"
- " gl_FragColor[1] = dot(p, coeff_v);\n"
- " p = texture2D(s_texture, v_texCoord);\n"
- " gl_FragColor[2] = dot(p, coeff_u);\n"
- " p = texture2D(s_texture, v_texCoord);\n"
- " gl_FragColor[3] = dot(p, coeff_y);\n"
- "}\n";
-
- return gFragmentShader;
-}
diff --git a/jni_mosaic/feature_mos/src/mosaic_renderer/YVURenderer.h b/jni_mosaic/feature_mos/src/mosaic_renderer/YVURenderer.h
deleted file mode 100755
index d14a4b9..0000000
--- a/jni_mosaic/feature_mos/src/mosaic_renderer/YVURenderer.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-
-#include "FrameBuffer.h"
-#include "Renderer.h"
-
-#include <GLES2/gl2.h>
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-class YVURenderer: public Renderer {
- public:
- YVURenderer();
- virtual ~YVURenderer();
-
- // Initialize OpenGL resources
- // @return true if successful
- bool InitializeGLProgram();
-
- bool DrawTexture();
-
- private:
- // Source code for shaders.
- const char* VertexShaderSource() const;
- const char* FragmentShaderSource() const;
-
- // Attribute locations
- GLint mPositionLoc;
- GLint mTexCoordLoc;
-
- // Sampler location
- GLint mSamplerLoc;
-};
-
diff --git a/jni_mosaic/feature_mos_jni.cpp b/jni_mosaic/feature_mos_jni.cpp
deleted file mode 100644
index 0fa792a..0000000
--- a/jni_mosaic/feature_mos_jni.cpp
+++ /dev/null
@@ -1,669 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/*
-*
- */
-#include <string.h>
-#include <jni.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <db_utilities_camera.h>
-
-#include "mosaic/AlignFeatures.h"
-#include "mosaic/Blend.h"
-#include "mosaic/Mosaic.h"
-#include "mosaic/Log.h"
-#define LOG_TAG "FEATURE_MOS_JNI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "mosaic_renderer_jni.h"
-
-char buffer[1024];
-
-const int MAX_FRAMES = 100;
-
-static double mTx;
-
-int tWidth[NR];
-int tHeight[NR];
-
-ImageType tImage[NR][MAX_FRAMES];// = {{ImageUtils::IMAGE_TYPE_NOIMAGE}}; // YVU24 format image
-Mosaic *mosaic[NR] = {NULL,NULL};
-ImageType resultYVU = ImageUtils::IMAGE_TYPE_NOIMAGE;
-ImageType resultBGR = ImageUtils::IMAGE_TYPE_NOIMAGE;
-float gTRS[11]; // 9 elements of the transformation, 1 for frame-number, 1 for alignment error code.
-// Variables to keep track of the mosaic computation progress for both LR & HR.
-float gProgress[NR];
-// Variables to be able to cancel the mosaic computation when the GUI says so.
-bool gCancelComputation[NR];
-
-int c;
-int width=0, height=0;
-int mosaicWidth=0, mosaicHeight=0;
-
-//int blendingType = Blend::BLEND_TYPE_FULL;
-//int blendingType = Blend::BLEND_TYPE_CYLPAN;
-int blendingType = Blend::BLEND_TYPE_HORZ;
-int stripType = Blend::STRIP_TYPE_THIN;
-bool high_res = false;
-bool quarter_res[NR] = {false,false};
-float thresh_still[NR] = {5.0f,0.0f};
-
-/* return current time in milliseconds*/
-
-#ifndef now_ms
-static double
-now_ms(void)
-{
- //struct timespec res;
- struct timeval res;
- //clock_gettime(CLOCK_REALTIME, &res);
- gettimeofday(&res, NULL);
- return 1000.0*res.tv_sec + (double)res.tv_usec/1e3;
-}
-#endif
-
-
-static int frame_number_HR = 0;
-static int frame_number_LR = 0;
-
-int Init(int mID, int nmax)
-{
- double t0, t1, time_c;
-
- if(mosaic[mID]!=NULL)
- {
- delete mosaic[mID];
- mosaic[mID] = NULL;
- }
-
- mosaic[mID] = new Mosaic();
-
- t0 = now_ms();
-
- // When processing higher than 720x480 video, process low-res at
- // quarter resolution
- if(tWidth[LR]>180)
- quarter_res[LR] = true;
-
-
- // Check for initialization and if not, initialize
- if (!mosaic[mID]->isInitialized())
- {
- mosaic[mID]->initialize(blendingType, stripType, tWidth[mID], tHeight[mID],
- nmax, quarter_res[mID], thresh_still[mID]);
- }
-
- t1 = now_ms();
- time_c = t1 - t0;
- LOGV("Init[%d]: %g ms [%d frames]",mID,time_c,nmax);
- return 1;
-}
-
-void GenerateQuarterResImagePlanar(ImageType im, int input_w, int input_h,
- ImageType &out)
-{
- ImageType imp;
- ImageType outp;
-
- int count = 0;
-
- for (int j = 0; j < input_h; j += H2L_FACTOR)
- {
- imp = im + j * input_w;
- outp = out + (j / H2L_FACTOR) * (input_w / H2L_FACTOR);
-
- for (int i = 0; i < input_w; i += H2L_FACTOR)
- {
- *outp++ = *(imp + i);
- count++;
- }
- }
-
- for (int j = input_h; j < 2 * input_h; j += H2L_FACTOR)
- {
- imp = im + j * input_w;
- outp = out + (j / H2L_FACTOR) * (input_w / H2L_FACTOR);
-
- for (int i = 0; i < input_w; i += H2L_FACTOR)
- {
- *outp++ = *(imp + i);
- count++;
- }
- }
-
- for (int j = 2 * input_h; j < 3 * input_h; j += H2L_FACTOR)
- {
- imp = im + j * input_w;
- outp = out + (j / H2L_FACTOR) * (input_w / H2L_FACTOR);
-
- for (int i = 0; i < input_w; i += H2L_FACTOR)
- {
- *outp++ = *(imp + i);
- count++;
- }
- }
-}
-
-int AddFrame(int mID, int k, float* trs1d)
-{
- double t0, t1, time_c;
- double trs[3][3];
-
- int ret_code = mosaic[mID]->addFrame(tImage[mID][k]);
-
- mosaic[mID]->getAligner()->getLastTRS(trs);
-
- if(trs1d!=NULL)
- {
-
- trs1d[0] = trs[0][0];
- trs1d[1] = trs[0][1];
- trs1d[2] = trs[0][2];
- trs1d[3] = trs[1][0];
- trs1d[4] = trs[1][1];
- trs1d[5] = trs[1][2];
- trs1d[6] = trs[2][0];
- trs1d[7] = trs[2][1];
- trs1d[8] = trs[2][2];
- }
-
- return ret_code;
-}
-
-int Finalize(int mID)
-{
- double t0, t1, time_c;
-
- t0 = now_ms();
- // Create the mosaic
- int ret = mosaic[mID]->createMosaic(gProgress[mID], gCancelComputation[mID]);
- t1 = now_ms();
- time_c = t1 - t0;
- LOGV("CreateMosaic: %g ms",time_c);
-
- // Get back the result
- resultYVU = mosaic[mID]->getMosaic(mosaicWidth, mosaicHeight);
-
- return ret;
-}
-
-void YUV420toYVU24(ImageType yvu24, ImageType yuv420sp, int width, int height)
-{
- int frameSize = width * height;
-
- ImageType oyp = yvu24;
- ImageType ovp = yvu24+frameSize;
- ImageType oup = yvu24+frameSize+frameSize;
-
- for (int j = 0, yp = 0; j < height; j++)
- {
- unsigned char u = 0, v = 0;
- int uvp = frameSize + (j >> 1) * width;
- for (int i = 0; i < width; i++, yp++)
- {
- *oyp++ = yuv420sp[yp];
- //int y = (0xff & (int)yuv420sp[yp]) -16;
- //yvu24p[yp] = (y<0)?0:y;
-
- if ((i & 1) == 0)
- {
- v = yuv420sp[uvp++];
- u = yuv420sp[uvp++];
- }
-
- *ovp++ = v;
- *oup++ = u;
- }
- }
-}
-
-void YUV420toYVU24_NEW(ImageType yvu24, ImageType yuv420sp, int width,
- int height)
-{
- int frameSize = width * height;
-
- ImageType oyp = yvu24;
- ImageType ovp = yvu24 + frameSize;
- ImageType oup = yvu24 + frameSize + frameSize;
-
- memcpy(yvu24, yuv420sp, frameSize * sizeof(unsigned char));
-
- for (int j = 0; j < height; j += 2)
- {
- unsigned char u = 0, v = 0;
- int uvp = frameSize + (j >> 1) * width;
- ovp = yvu24 + frameSize + j * width;
- oup = ovp + frameSize;
-
- ImageType iuvp = yuv420sp + uvp;
-
- for (int i = 0; i < width; i += 2)
- {
- v = *iuvp++;
- u = *iuvp++;
-
- *ovp++ = v;
- *oup++ = u;
-
- *ovp++ = v;
- *oup++ = u;
-
- }
- memcpy(ovp, ovp - width, width * sizeof(unsigned char));
- memcpy(oup, oup - width, width * sizeof(unsigned char));
- }
-}
-
-
-JNIEXPORT void JNICALL Java_com_android_camera_Mosaic_allocateMosaicMemory(
- JNIEnv* env, jobject thiz, jint width, jint height)
-{
- tWidth[HR] = width;
- tHeight[HR] = height;
- tWidth[LR] = int(width / H2L_FACTOR);
- tHeight[LR] = int(height / H2L_FACTOR);
-
- for(int i=0; i<MAX_FRAMES; i++)
- {
- tImage[LR][i] = ImageUtils::allocateImage(tWidth[LR], tHeight[LR],
- ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
- tImage[HR][i] = ImageUtils::allocateImage(tWidth[HR], tHeight[HR],
- ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
- }
-
- AllocateTextureMemory(tWidth[HR], tHeight[HR], tWidth[LR], tHeight[LR]);
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_Mosaic_freeMosaicMemory(
- JNIEnv* env, jobject thiz)
-{
- for(int i = 0; i < MAX_FRAMES; i++)
- {
- ImageUtils::freeImage(tImage[LR][i]);
- ImageUtils::freeImage(tImage[HR][i]);
- }
-
- FreeTextureMemory();
-}
-
-
-void decodeYUV444SP(unsigned char* rgb, unsigned char* yuv420sp, int width,
- int height)
-{
- int frameSize = width * height;
-
- for (int j = 0, yp = 0; j < height; j++)
- {
- int vp = frameSize + j * width, u = 0, v = 0;
- int up = vp + frameSize;
-
- for (int i = 0; i < width; i++, yp++, vp++, up++)
- {
- int y = (0xff & ((int) yuv420sp[yp])) - 16;
- if (y < 0) y = 0;
-
- v = (0xff & yuv420sp[vp]) - 128;
- u = (0xff & yuv420sp[up]) - 128;
-
- int y1192 = 1192 * y;
- int r = (y1192 + 1634 * v);
- int g = (y1192 - 833 * v - 400 * u);
- int b = (y1192 + 2066 * u);
-
- if (r < 0) r = 0; else if (r > 262143) r = 262143;
- if (g < 0) g = 0; else if (g > 262143) g = 262143;
- if (b < 0) b = 0; else if (b > 262143) b = 262143;
-
- //rgb[yp] = 0xff000000 | ((r << 6) & 0xff0000) | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff);
- int p = j*width*3+i*3;
- rgb[p+0] = (r<<6 & 0xFF0000)>>16;
- rgb[p+1] = (g>>2 & 0xFF00)>>8;
- rgb[p+2] = b>>10 & 0xFF;
- }
- }
-}
-
-static int count = 0;
-
-void ConvertYVUAiToPlanarYVU(unsigned char *planar, unsigned char *in, int width,
- int height)
-{
- int planeSize = width * height;
- unsigned char* Yptr = planar;
- unsigned char* Vptr = planar + planeSize;
- unsigned char* Uptr = Vptr + planeSize;
-
- for (int i = 0; i < planeSize; i++)
- {
- *Yptr++ = *in++;
- *Vptr++ = *in++;
- *Uptr++ = *in++;
- in++; // Alpha
- }
-}
-
-JNIEXPORT jfloatArray JNICALL Java_com_android_camera_Mosaic_setSourceImageFromGPU(
- JNIEnv* env, jobject thiz)
-{
- double t0, t1, time_c;
- t0 = now_ms();
- int ret_code = Mosaic::MOSAIC_RET_OK;
-
- if(frame_number_HR<MAX_FRAMES && frame_number_LR<MAX_FRAMES)
- {
- double last_tx = mTx;
-
- sem_wait(&gPreviewImage_semaphore);
- ConvertYVUAiToPlanarYVU(tImage[LR][frame_number_LR], gPreviewImage[LR],
- tWidth[LR], tHeight[LR]);
-
- sem_post(&gPreviewImage_semaphore);
-
- ret_code = AddFrame(LR, frame_number_LR, gTRS);
-
- if(ret_code == Mosaic::MOSAIC_RET_OK || ret_code == Mosaic::MOSAIC_RET_FEW_INLIERS)
- {
- // Copy into HR buffer only if this is a valid frame
- sem_wait(&gPreviewImage_semaphore);
- ConvertYVUAiToPlanarYVU(tImage[HR][frame_number_HR], gPreviewImage[HR],
- tWidth[HR], tHeight[HR]);
- sem_post(&gPreviewImage_semaphore);
-
- frame_number_LR++;
- frame_number_HR++;
- }
- }
- else
- {
- gTRS[1] = gTRS[2] = gTRS[3] = gTRS[5] = gTRS[6] = gTRS[7] = 0.0f;
- gTRS[0] = gTRS[4] = gTRS[8] = 1.0f;
- }
-
- UpdateWarpTransformation(gTRS);
-
- gTRS[9] = frame_number_HR;
- gTRS[10] = ret_code;
-
- jfloatArray bytes = env->NewFloatArray(11);
- if(bytes != 0)
- {
- env->SetFloatArrayRegion(bytes, 0, 11, (jfloat*) gTRS);
- }
- return bytes;
-}
-
-
-
-JNIEXPORT jfloatArray JNICALL Java_com_android_camera_Mosaic_setSourceImage(
- JNIEnv* env, jobject thiz, jbyteArray photo_data)
-{
- double t0, t1, time_c;
- t0 = now_ms();
-
- int ret_code = Mosaic::MOSAIC_RET_OK;
-
- if(frame_number_HR<MAX_FRAMES && frame_number_LR<MAX_FRAMES)
- {
- jbyte *pixels = env->GetByteArrayElements(photo_data, 0);
-
- YUV420toYVU24_NEW(tImage[HR][frame_number_HR], (ImageType)pixels,
- tWidth[HR], tHeight[HR]);
-
- env->ReleaseByteArrayElements(photo_data, pixels, 0);
-
- double last_tx = mTx;
-
- t0 = now_ms();
- GenerateQuarterResImagePlanar(tImage[HR][frame_number_HR], tWidth[HR],
- tHeight[HR], tImage[LR][frame_number_LR]);
-
-
- sem_wait(&gPreviewImage_semaphore);
- decodeYUV444SP(gPreviewImage[LR], tImage[LR][frame_number_LR],
- gPreviewImageWidth[LR], gPreviewImageHeight[LR]);
- sem_post(&gPreviewImage_semaphore);
-
- ret_code = AddFrame(LR, frame_number_LR, gTRS);
-
- if(ret_code == Mosaic::MOSAIC_RET_OK || ret_code == Mosaic::MOSAIC_RET_FEW_INLIERS)
- {
- frame_number_LR++;
- frame_number_HR++;
- }
-
- }
- else
- {
- gTRS[1] = gTRS[2] = gTRS[3] = gTRS[5] = gTRS[6] = gTRS[7] = 0.0f;
- gTRS[0] = gTRS[4] = gTRS[8] = 1.0f;
- }
-
- UpdateWarpTransformation(gTRS);
-
- gTRS[9] = frame_number_HR;
- gTRS[10] = ret_code;
-
- jfloatArray bytes = env->NewFloatArray(11);
- if(bytes != 0)
- {
- env->SetFloatArrayRegion(bytes, 0, 11, (jfloat*) gTRS);
- }
- return bytes;
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_Mosaic_setBlendingType(
- JNIEnv* env, jobject thiz, jint type)
-{
- blendingType = int(type);
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_Mosaic_setStripType(
- JNIEnv* env, jobject thiz, jint type)
-{
- stripType = int(type);
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_Mosaic_reset(
- JNIEnv* env, jobject thiz)
-{
- frame_number_HR = 0;
- frame_number_LR = 0;
-
- gProgress[LR] = 0.0;
- gProgress[HR] = 0.0;
-
- gCancelComputation[LR] = false;
- gCancelComputation[HR] = false;
-
- Init(LR,MAX_FRAMES);
-}
-
-JNIEXPORT jint JNICALL Java_com_android_camera_Mosaic_reportProgress(
- JNIEnv* env, jobject thiz, jboolean hires, jboolean cancel_computation)
-{
- if(bool(hires))
- gCancelComputation[HR] = cancel_computation;
- else
- gCancelComputation[LR] = cancel_computation;
-
- if(bool(hires))
- return (jint) gProgress[HR];
- else
- return (jint) gProgress[LR];
-}
-
-JNIEXPORT jint JNICALL Java_com_android_camera_Mosaic_createMosaic(
- JNIEnv* env, jobject thiz, jboolean value)
-{
- high_res = bool(value);
-
- int ret;
-
- if(high_res)
- {
- LOGV("createMosaic() - High-Res Mode");
- double t0, t1, time_c;
-
- gProgress[HR] = 0.0;
- t0 = now_ms();
-
- Init(HR, frame_number_HR);
-
- for(int k = 0; k < frame_number_HR; k++)
- {
- if (gCancelComputation[HR])
- break;
- AddFrame(HR, k, NULL);
- gProgress[HR] += TIME_PERCENT_ALIGN/frame_number_HR;
- }
-
- if (gCancelComputation[HR])
- {
- ret = Mosaic::MOSAIC_RET_CANCELLED;
- }
- else
- {
- gProgress[HR] = TIME_PERCENT_ALIGN;
-
- t1 = now_ms();
- time_c = t1 - t0;
- LOGV("AlignAll - %d frames [HR]: %g ms", frame_number_HR, time_c);
-
- ret = Finalize(HR);
-
- gProgress[HR] = 100.0;
- }
-
- high_res = false;
- }
- else
- {
- LOGV("createMosaic() - Low-Res Mode");
- gProgress[LR] = TIME_PERCENT_ALIGN;
-
- ret = Finalize(LR);
-
- gProgress[LR] = 100.0;
- }
-
- return (jint) ret;
-}
-
-JNIEXPORT jintArray JNICALL Java_com_android_camera_Mosaic_getFinalMosaic(
- JNIEnv* env, jobject thiz)
-{
- int y,x;
- int width = mosaicWidth;
- int height = mosaicHeight;
- int imageSize = width * height;
-
- // Convert back to RGB24
- resultBGR = ImageUtils::allocateImage(mosaicWidth, mosaicHeight,
- ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
- ImageUtils::yvu2bgr(resultBGR, resultYVU, mosaicWidth, mosaicHeight);
-
- LOGV("MosBytes: %d, W = %d, H = %d", imageSize, width, height);
-
- int* image = new int[imageSize];
- int* dims = new int[2];
-
- for(y=0; y<height; y++)
- {
- for(x=0; x<width; x++)
- {
- image[y*width+x] = (0xFF<<24) | (resultBGR[y*width*3+x*3+2]<<16)|
- (resultBGR[y*width*3+x*3+1]<<8)| (resultBGR[y*width*3+x*3]);
- }
- }
-
- dims[0] = width;
- dims[1] = height;
-
- ImageUtils::freeImage(resultBGR);
-
- jintArray bytes = env->NewIntArray(imageSize+2);
- if (bytes == 0) {
- LOGE("Error in creating the image.");
- delete[] image;
- return 0;
- }
- env->SetIntArrayRegion(bytes, 0, imageSize, (jint*) image);
- env->SetIntArrayRegion(bytes, imageSize, 2, (jint*) dims);
- delete[] image;
- delete[] dims;
- return bytes;
-}
-
-JNIEXPORT jbyteArray JNICALL Java_com_android_camera_Mosaic_getFinalMosaicNV21(
- JNIEnv* env, jobject thiz)
-{
- int y,x;
- int width;
- int height;
-
- width = mosaicWidth;
- height = mosaicHeight;
-
- int imageSize = 1.5*width * height;
-
- // Convert YVU to NV21 format in-place
- ImageType V = resultYVU+mosaicWidth*mosaicHeight;
- ImageType U = V+mosaicWidth*mosaicHeight;
- for(int j=0; j<mosaicHeight/2; j++)
- {
- for(int i=0; i<mosaicWidth; i+=2)
- {
- V[j*mosaicWidth+i] = V[(2*j)*mosaicWidth+i]; // V
- V[j*mosaicWidth+i+1] = U[(2*j)*mosaicWidth+i]; // U
- }
- }
-
- LOGV("MosBytes: %d, W = %d, H = %d", imageSize, width, height);
-
- unsigned char* dims = new unsigned char[8];
-
- dims[0] = (unsigned char)(width >> 24);
- dims[1] = (unsigned char)(width >> 16);
- dims[2] = (unsigned char)(width >> 8);
- dims[3] = (unsigned char)width;
-
- dims[4] = (unsigned char)(height >> 24);
- dims[5] = (unsigned char)(height >> 16);
- dims[6] = (unsigned char)(height >> 8);
- dims[7] = (unsigned char)height;
-
- jbyteArray bytes = env->NewByteArray(imageSize+8);
- if (bytes == 0) {
- LOGE("Error in creating the image.");
- ImageUtils::freeImage(resultYVU);
- return 0;
- }
- env->SetByteArrayRegion(bytes, 0, imageSize, (jbyte*) resultYVU);
- env->SetByteArrayRegion(bytes, imageSize, 8, (jbyte*) dims);
- delete[] dims;
- ImageUtils::freeImage(resultYVU);
- return bytes;
-}
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_bundle.h b/jni_mosaic/feature_stab/db_vlvm/db_bundle.h
deleted file mode 100644
index e4fb8db..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_bundle.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_bundle.h,v 1.2 2011/06/17 14:03:30 mbansal Exp $ */
-
-#ifndef DB_BUNDLE_H
-#define DB_BUNDLE_H
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMBundle (LM) Bundle adjustment utilities (a.k.a. Levenberg-Marquardt algorithm)
- */
-/*\{*/
-
-#include "db_utilities.h"
-
-/*!
-Solve for update dx such that diagmult(1+lambda,transpose(J)%J)%dx= -Jtf
-using only upper half of JtJ, destroying lower half below diagonal in the process
-dimension is n and d should point to n allocated doubles of scratch memory
-*/
-inline void db_Compute_dx(double *dx,double **JtJ,double *min_Jtf,double lambda,double *d,int n)
-{
- int i;
- double opl;
-
- opl=1.0+lambda;
- for(i=0;i<n;i++) d[i]=JtJ[i][i]*opl;
-
- db_CholeskyDecompSeparateDiagonal(JtJ,d,n);
- db_CholeskyBacksub(dx,JtJ,d,n,min_Jtf);
-}
-
-/*!
-Solve for update dx such that diagmult(1+lambda,transpose(J)%J)%dx= -Jtf
-using only upper half of JtJ, destroying lower half below diagonal in the process
-*/
-inline void db_Compute_dx_3x3(double dx[3],double JtJ[9],const double min_Jtf[3],double lambda)
-{
- double d[3],opl;
-
- opl=1.0+lambda;
- d[0]=JtJ[0]*opl;
- d[1]=JtJ[4]*opl;
- d[2]=JtJ[8]*opl;
- db_CholeskyDecomp3x3SeparateDiagonal(JtJ,d);
- db_CholeskyBacksub3x3(dx,JtJ,d,min_Jtf);
-}
-
-/*\}*/
-
-#endif /* DB_BUNDLE_H */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_feature_detection.cpp b/jni_mosaic/feature_stab/db_vlvm/db_feature_detection.cpp
deleted file mode 100644
index 28cb4a7..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_feature_detection.cpp
+++ /dev/null
@@ -1,1770 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/*$Id: db_feature_detection.cpp,v 1.4 2011/06/17 14:03:30 mbansal Exp $*/
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-#include "db_utilities.h"
-#include "db_feature_detection.h"
-#ifdef _VERBOSE_
-#include <iostream>
-#endif
-#include <float.h>
-
-#define DB_SUB_PIXEL
-
-#define BORDER 10 // 5
-
-float** db_AllocStrengthImage_f(float **im,int w,int h)
-{
- int i,n,aw;
- long c,size;
- float **img,*aim,*p;
-
- /*Determine number of 124 element chunks needed*/
- n=(db_maxi(1,w-6)+123)/124;
- /*Determine the total allocation width aw*/
- aw=n*124+8;
- /*Allocate*/
- size=aw*h+16;
- *im=new float [size];
- /*Clean up*/
- p=(*im);
- for(c=0;c<size;c++) p[c]=0.0;
- /*Get a 16 byte aligned pointer*/
- aim=db_AlignPointer_f(*im,16);
- /*Allocate pointer table*/
- img=new float* [h];
- /*Initialize the pointer table*/
- for(i=0;i<h;i++)
- {
- img[i]=aim+aw*i+1;
- }
-
- return(img);
-}
-
-void db_FreeStrengthImage_f(float *im,float **img,int h)
-{
- delete [] im;
- delete [] img;
-}
-
-/*Compute derivatives Ix,Iy for a subrow of img with upper left (i,j) and width chunk_width
-Memory references occur one pixel outside the subrow*/
-inline void db_IxIyRow_f(float *Ix,float *Iy,const float * const *img,int i,int j,int chunk_width)
-{
- int c;
-
- for(c=0;c<chunk_width;c++)
- {
- Ix[c]=img[i][j+c-1]-img[i][j+c+1];
- Iy[c]=img[i-1][j+c]-img[i+1][j+c];
- }
-}
-
-/*Compute derivatives Ix,Iy for a subrow of img with upper left (i,j) and width 128
-Memory references occur one pixel outside the subrow*/
-inline void db_IxIyRow_u(int *dxx,const unsigned char * const *img,int i,int j,int nc)
-{
-#ifdef DB_USE_MMX
- const unsigned char *r1,*r2,*r3;
-
- r1=img[i-1]+j; r2=img[i]+j; r3=img[i+1]+j;
-
- _asm
- {
- mov esi,16
- mov eax,r1
- mov ebx,r2
- mov ecx,r3
- mov edx,dxx
-
- /*Get bitmask into mm7*/
- mov edi,7F7F7F7Fh
- movd mm7,edi
- punpckldq mm7,mm7
-
-loopstart:
- /***************dx part 1-12*********************************/
- movq mm0,[eax] /*1 Get upper*/
- pxor mm6,mm6 /*2 Set to zero*/
- movq mm1,[ecx] /*3 Get lower*/
- psrlq mm0,1 /*4 Shift*/
- psrlq mm1,1 /*5 Shift*/
- pand mm0,mm7 /*6 And*/
- movq mm2,[ebx-1] /*13 Get left*/
- pand mm1,mm7 /*7 And*/
- psubb mm0,mm1 /*8 Subtract*/
- pxor mm5,mm5 /*14 Set to zero*/
- movq mm1,mm0 /*9 Copy*/
- pcmpgtb mm6,mm0 /*10 Create unpack mask*/
- movq mm3,[ebx+1] /*15 Get right*/
- punpcklbw mm0,mm6 /*11 Unpack low*/
- punpckhbw mm1,mm6 /*12 Unpack high*/
- /***************dy part 13-24*********************************/
- movq mm4,mm0 /*25 Copy dx*/
- psrlq mm2,1 /*16 Shift*/
- pmullw mm0,mm0 /*26 Multiply dx*dx*/
- psrlq mm3,1 /*17 Shift*/
- pand mm2,mm7 /*18 And*/
- pand mm3,mm7 /*19 And*/
- /*Stall*/
- psubb mm2,mm3 /*20 Subtract*/
- /*Stall*/
- movq mm3,mm2 /*21 Copy*/
- pcmpgtb mm5,mm2 /*22 Create unpack mask*/
- punpcklbw mm2,mm5 /*23 Unpack low*/
- /*Stall*/
- punpckhbw mm3,mm5 /*24 Unpack high*/
- /***************dxx dxy dyy low part 25-49*********************************/
- pmullw mm4,mm2 /*27 Multiply dx*dy*/
- pmullw mm2,mm2 /*28 Multiply dy*dy*/
- pxor mm6,mm6 /*29 Set to zero*/
- movq mm5,mm0 /*30 Copy dx*dx*/
- pcmpgtw mm6,mm0 /*31 Create unpack mask for dx*dx*/
- punpcklwd mm0,mm6 /*32 Unpack dx*dx lows*/
- /*Stall*/
- punpckhwd mm5,mm6 /*33 Unpack dx*dx highs*/
- pxor mm6,mm6 /*36 Set to zero*/
- movq [edx],mm0 /*34 Store dx*dx lows*/
- movq mm0,mm4 /*37 Copy dx*dy*/
- movq [edx+8],mm5 /*35 Store dx*dx highs*/
- pcmpgtw mm6,mm4 /*38 Create unpack mask for dx*dy*/
- punpcklwd mm4,mm6 /*39 Unpack dx*dy lows*/
- /*Stall*/
- punpckhwd mm0,mm6 /*40 Unpack dx*dy highs*/
- pxor mm6,mm6 /*43 Set to zero*/
- movq [edx+512],mm4 /*41 Store dx*dy lows*/
- movq mm5,mm2 /*44 Copy dy*dy*/
- movq [edx+520],mm0 /*42 Store dx*dy highs*/
- pcmpgtw mm6,mm2 /*45 Create unpack mask for dy*dy*/
- punpcklwd mm2,mm6 /*46 Unpack dy*dy lows*/
- movq mm4,mm1 /*50 Copy dx*/
- punpckhwd mm5,mm6 /*47 Unpack dy*dy highs*/
- pmullw mm1,mm1 /*51 Multiply dx*dx*/
- movq [edx+1024],mm2 /*48 Store dy*dy lows*/
- pmullw mm4,mm3 /*52 Multiply dx*dy*/
- movq [edx+1032],mm5 /*49 Store dy*dy highs*/
- /***************dxx dxy dyy high part 50-79*********************************/
- pmullw mm3,mm3 /*53 Multiply dy*dy*/
- pxor mm6,mm6 /*54 Set to zero*/
- movq mm5,mm1 /*55 Copy dx*dx*/
- pcmpgtw mm6,mm1 /*56 Create unpack mask for dx*dx*/
- pxor mm2,mm2 /*61 Set to zero*/
- punpcklwd mm1,mm6 /*57 Unpack dx*dx lows*/
- movq mm0,mm4 /*62 Copy dx*dy*/
- punpckhwd mm5,mm6 /*58 Unpack dx*dx highs*/
- pcmpgtw mm2,mm4 /*63 Create unpack mask for dx*dy*/
- movq [edx+16],mm1 /*59 Store dx*dx lows*/
- punpcklwd mm4,mm2 /*64 Unpack dx*dy lows*/
- movq [edx+24],mm5 /*60 Store dx*dx highs*/
- punpckhwd mm0,mm2 /*65 Unpack dx*dy highs*/
- movq [edx+528],mm4 /*66 Store dx*dy lows*/
- pxor mm6,mm6 /*68 Set to zero*/
- movq [edx+536],mm0 /*67 Store dx*dy highs*/
- movq mm5,mm3 /*69 Copy dy*dy*/
- pcmpgtw mm6,mm3 /*70 Create unpack mask for dy*dy*/
- add eax,8 /*75*/
- punpcklwd mm3,mm6 /*71 Unpack dy*dy lows*/
- add ebx,8 /*76*/
- punpckhwd mm5,mm6 /*72 Unpack dy*dy highs*/
- add ecx,8 /*77*/
- movq [edx+1040],mm3 /*73 Store dy*dy lows*/
- /*Stall*/
- movq [edx+1048],mm5 /*74 Store dy*dy highs*/
- /*Stall*/
- add edx,32 /*78*/
- dec esi /*79*/
- jnz loopstart
-
- emms
- }
-
-#else
- int c;
- int Ix,Iy;
-
- for(c=0;c<nc;c++)
- {
- Ix=(img[i][j+c-1]-img[i][j+c+1])>>1;
- Iy=(img[i-1][j+c]-img[i+1][j+c])>>1;
- dxx[c]=Ix*Ix;
- dxx[c+128]=Ix*Iy;
- dxx[c+256]=Iy*Iy;
- }
-#endif /*DB_USE_MMX*/
-}
-
-/*Filter vertically five rows of derivatives of length chunk_width into gxx,gxy,gyy*/
-inline void db_gxx_gxy_gyy_row_f(float *gxx,float *gxy,float *gyy,int chunk_width,
- float *Ix0,float *Ix1,float *Ix2,float *Ix3,float *Ix4,
- float *Iy0,float *Iy1,float *Iy2,float *Iy3,float *Iy4)
-{
- int c;
- float dx,dy;
- float Ixx0,Ixy0,Iyy0,Ixx1,Ixy1,Iyy1,Ixx2,Ixy2,Iyy2,Ixx3,Ixy3,Iyy3,Ixx4,Ixy4,Iyy4;
-
- for(c=0;c<chunk_width;c++)
- {
- dx=Ix0[c];
- dy=Iy0[c];
- Ixx0=dx*dx;
- Ixy0=dx*dy;
- Iyy0=dy*dy;
-
- dx=Ix1[c];
- dy=Iy1[c];
- Ixx1=dx*dx;
- Ixy1=dx*dy;
- Iyy1=dy*dy;
-
- dx=Ix2[c];
- dy=Iy2[c];
- Ixx2=dx*dx;
- Ixy2=dx*dy;
- Iyy2=dy*dy;
-
- dx=Ix3[c];
- dy=Iy3[c];
- Ixx3=dx*dx;
- Ixy3=dx*dy;
- Iyy3=dy*dy;
-
- dx=Ix4[c];
- dy=Iy4[c];
- Ixx4=dx*dx;
- Ixy4=dx*dy;
- Iyy4=dy*dy;
-
- /*Filter vertically*/
- gxx[c]=Ixx0+Ixx1*4.0f+Ixx2*6.0f+Ixx3*4.0f+Ixx4;
- gxy[c]=Ixy0+Ixy1*4.0f+Ixy2*6.0f+Ixy3*4.0f+Ixy4;
- gyy[c]=Iyy0+Iyy1*4.0f+Iyy2*6.0f+Iyy3*4.0f+Iyy4;
- }
-}
-
-/*Filter vertically five rows of derivatives of length 128 into gxx,gxy,gyy*/
-inline void db_gxx_gxy_gyy_row_s(int *g,int *d0,int *d1,int *d2,int *d3,int *d4,int nc)
-{
-#ifdef DB_USE_MMX
- int c;
-
- _asm
- {
- mov c,64
- mov eax,d0
- mov ebx,d1
- mov ecx,d2
- mov edx,d3
- mov edi,d4
- mov esi,g
-
-loopstart:
- /***************dxx part 1-14*********************************/
- movq mm0,[eax] /*1 Get dxx0*/
- /*Stall*/
- movq mm1,[ebx] /*2 Get dxx1*/
- /*Stall*/
- movq mm2,[ecx] /*5 Get dxx2*/
- pslld mm1,2 /*3 Shift dxx1*/
- movq mm3,[edx] /*10 Get dxx3*/
- paddd mm0,mm1 /*4 Accumulate dxx1*/
- movq mm4,[eax+512] /*15 Get dxy0*/
- pslld mm2,1 /*6 Shift dxx2 1*/
- paddd mm0,mm2 /*7 Accumulate dxx2 1*/
- pslld mm2,1 /*8 Shift dxx2 2*/
- movq mm5,[ebx+512] /*16 Get dxy1*/
- paddd mm0,mm2 /*9 Accumulate dxx2 2*/
- pslld mm3,2 /*11 Shift dxx3*/
- /*Stall*/
- paddd mm0,mm3 /*12 Accumulate dxx3*/
- pslld mm5,2 /*17 Shift dxy1*/
- paddd mm0,[edi] /*13 Accumulate dxx4*/
- paddd mm4,mm5 /*18 Accumulate dxy1*/
- movq mm6,[ecx+512] /*19 Get dxy2*/
- /*Stall*/
- movq [esi],mm0 /*14 Store dxx sums*/
- /***************dxy part 15-28*********************************/
- pslld mm6,1 /*20 Shift dxy2 1*/
- paddd mm4,mm6 /*21 Accumulate dxy2 1*/
- pslld mm6,1 /*22 Shift dxy2 2*/
- movq mm0,[eax+1024] /*29 Get dyy0*/
- paddd mm4,mm6 /*23 Accumulate dxy2 2*/
- movq mm7,[edx+512] /*24 Get dxy3*/
- pslld mm7,2 /*25 Shift dxy3*/
- movq mm1,[ebx+1024] /*30 Get dyy1*/
- paddd mm4,mm7 /*26 Accumulate dxy3*/
- paddd mm4,[edi+512] /*27 Accumulate dxy4*/
- pslld mm1,2 /*31 Shift dyy1*/
- movq mm2,[ecx+1024] /*33 Get dyy2*/
- paddd mm0,mm1 /*32 Accumulate dyy1*/
- movq [esi+512],mm4 /*28 Store dxy sums*/
- pslld mm2,1 /*34 Shift dyy2 1*/
- /***************dyy part 29-49*********************************/
-
-
- movq mm3,[edx+1024] /*38 Get dyy3*/
- paddd mm0,mm2 /*35 Accumulate dyy2 1*/
- paddd mm0,[edi+1024] /*41 Accumulate dyy4*/
- pslld mm2,1 /*36 Shift dyy2 2*/
- paddd mm0,mm2 /*37 Accumulate dyy2 2*/
- pslld mm3,2 /*39 Shift dyy3*/
- paddd mm0,mm3 /*40 Accumulate dyy3*/
- add eax,8 /*43*/
- add ebx,8 /*44*/
- add ecx,8 /*45*/
- movq [esi+1024],mm0 /*42 Store dyy sums*/
- /*Stall*/
- add edx,8 /*46*/
- add edi,8 /*47*/
- add esi,8 /*48*/
- dec c /*49*/
- jnz loopstart
-
- emms
- }
-
-#else
- int c,dd;
-
- for(c=0;c<nc;c++)
- {
- /*Filter vertically*/
- dd=d2[c];
- g[c]=d0[c]+(d1[c]<<2)+(dd<<2)+(dd<<1)+(d3[c]<<2)+d4[c];
-
- dd=d2[c+128];
- g[c+128]=d0[c+128]+(d1[c+128]<<2)+(dd<<2)+(dd<<1)+(d3[c+128]<<2)+d4[c+128];
-
- dd=d2[c+256];
- g[c+256]=d0[c+256]+(d1[c+256]<<2)+(dd<<2)+(dd<<1)+(d3[c+256]<<2)+d4[c+256];
- }
-#endif /*DB_USE_MMX*/
-}
-
-/*Filter horizontally the three rows gxx,gxy,gyy into the strength subrow starting at i,j
-and with width chunk_width. gxx,gxy and gyy are assumed to be four pixels wider than chunk_width
-and starting at (i,j-2)*/
-inline void db_HarrisStrength_row_f(float **s,float *gxx,float *gxy,float *gyy,int i,int j,int chunk_width)
-{
- float Gxx,Gxy,Gyy,det,trc;
- int c;
-
- for(c=0;c<chunk_width;c++)
- {
- Gxx=gxx[c]+gxx[c+1]*4.0f+gxx[c+2]*6.0f+gxx[c+3]*4.0f+gxx[c+4];
- Gxy=gxy[c]+gxy[c+1]*4.0f+gxy[c+2]*6.0f+gxy[c+3]*4.0f+gxy[c+4];
- Gyy=gyy[c]+gyy[c+1]*4.0f+gyy[c+2]*6.0f+gyy[c+3]*4.0f+gyy[c+4];
-
- det=Gxx*Gyy-Gxy*Gxy;
- trc=Gxx+Gyy;
- s[i][j+c]=det-0.06f*trc*trc;
- }
-}
-
-/*Filter g of length 128 in place with 14641. Output is shifted two steps
-and of length 124*/
-inline void db_Filter14641_128_i(int *g,int nc)
-{
-#ifdef DB_USE_MMX
- int mask;
-
- mask=0xFFFFFFFF;
- _asm
- {
- mov esi,31
- mov eax,g
-
- /*Get bitmask 00000000FFFFFFFF into mm7*/
- movd mm7,mask
-
- /*Warming iteration one 1-16********************/
- movq mm6,[eax] /*1 Load new data*/
- paddd mm0,mm6 /*2 Add 1* behind two steps*/
- movq mm2,mm6 /*3 Start with 1* in front two steps*/
- pslld mm6,1 /*4*/
- paddd mm1,mm6 /*5 Add 2* same place*/
- pslld mm6,1 /*6*/
- paddd mm1,mm6 /*7 Add 4* same place*/
- pshufw mm6,mm6,4Eh /*8 Swap the two double-words using bitmask 01001110=4Eh*/
- paddd mm1,mm6 /*9 Add 4* swapped*/
- movq mm5,mm6 /*10 Copy*/
- pand mm6,mm7 /*11 Get low double-word only*/
- paddd mm2,mm6 /*12 Add 4* in front one step*/
- pxor mm6,mm5 /*13 Get high double-word only*/
- paddd mm0,mm6 /*14 Add 4* behind one step*/
- movq mm0,mm1 /*15 Shift along*/
- movq mm1,mm2 /*16 Shift along*/
- /*Warming iteration two 17-32********************/
- movq mm4,[eax+8] /*17 Load new data*/
- paddd mm0,mm4 /*18 Add 1* behind two steps*/
- movq mm2,mm4 /*19 Start with 1* in front two steps*/
- pslld mm4,1 /*20*/
- paddd mm1,mm4 /*21 Add 2* same place*/
- pslld mm4,1 /*22*/
- paddd mm1,mm4 /*23 Add 4* same place*/
- pshufw mm4,mm4,4Eh /*24 Swap the two double-words using bitmask 01001110=4Eh*/
- paddd mm1,mm4 /*25 Add 4* swapped*/
- movq mm3,mm4 /*26 Copy*/
- pand mm4,mm7 /*27 Get low double-word only*/
- paddd mm2,mm4 /*28 Add 4* in front one step*/
- pxor mm4,mm3 /*29 Get high double-word only*/
- paddd mm0,mm4 /*30 Add 4* behind one step*/
- movq mm0,mm1 /*31 Shift along*/
- movq mm1,mm2 /*32 Shift along*/
-
- /*Loop********************/
-loopstart:
- /*First part of loop 33-47********/
- movq mm6,[eax+16] /*33 Load new data*/
- /*Stall*/
- paddd mm0,mm6 /*34 Add 1* behind two steps*/
- movq mm2,mm6 /*35 Start with 1* in front two steps*/
- movq mm4,[eax+24] /*48 Load new data*/
- pslld mm6,1 /*36*/
- paddd mm1,mm6 /*37 Add 2* same place*/
- pslld mm6,1 /*38*/
- paddd mm1,mm6 /*39 Add 4* same place*/
- pshufw mm6,mm6,4Eh /*40 Swap the two double-words using bitmask 01001110=4Eh*/
- paddd mm1,mm4 /*49 Add 1* behind two steps*/
- movq mm5,mm6 /*41 Copy*/
- paddd mm1,mm6 /*42 Add 4* swapped*/
- pand mm6,mm7 /*43 Get low double-word only*/
- paddd mm2,mm6 /*44 Add 4* in front one step*/
- pxor mm6,mm5 /*45 Get high double-word only*/
- paddd mm0,mm6 /*46 Add 4* behind one step*/
- movq mm6,mm4 /*50a Copy*/
- pslld mm4,1 /*51*/
- /*Stall*/
- movq [eax],mm0 /*47 Store result two steps behind*/
- /*Second part of loop 48-66********/
- movq mm0,mm6 /*50b Start with 1* in front two steps*/
- paddd mm2,mm4 /*52 Add 2* same place*/
- pslld mm4,1 /*53*/
- paddd mm2,mm4 /*54 Add 4* same place*/
- pshufw mm4,mm4,4Eh /*55 Swap the two double-words using bitmask 01001110=4Eh*/
- paddd mm2,mm4 /*56 Add 4* swapped*/
- movq mm3,mm4 /*57 Copy*/
- pand mm4,mm7 /*58 Get low double-word only*/
- /*Stall*/
- paddd mm0,mm4 /*59 Add 4* in front one step*/
- pxor mm4,mm3 /*60 Get high double-word only*/
- paddd mm1,mm4 /*61 Add 4* behind one step*/
- add eax,16 /*65*/
- dec esi /*66*/
- /*Stall*/
- movq [eax-8],mm1 /*62 Store result two steps behind*/
- movq mm1,mm0 /*63 Shift along*/
- movq mm0,mm2 /*64 Shift along*/
- jnz loopstart
-
- emms
- }
-
-#else
- int c;
-
- for(c=0;c<nc-4;c++)
- {
- g[c]=g[c]+(g[c+1]<<2)+(g[c+2]<<2)+(g[c+2]<<1)+(g[c+3]<<2)+g[c+4];
- }
-#endif /*DB_USE_MMX*/
-}
-
-/*Filter horizontally the three rows gxx,gxy,gyy of length 128 into the strength subrow s
-of length 124. gxx,gxy and gyy are assumed to be starting at (i,j-2) if s[i][j] is sought.
-s should be 16 byte aligned*/
-inline void db_HarrisStrength_row_s(float *s,int *gxx,int *gxy,int *gyy,int nc)
-{
- float k;
-
- k=0.06f;
-
- db_Filter14641_128_i(gxx,nc);
- db_Filter14641_128_i(gxy,nc);
- db_Filter14641_128_i(gyy,nc);
-
-#ifdef DB_USE_SIMD
-
-
- _asm
- {
- mov esi,15
- mov eax,gxx
- mov ebx,gxy
- mov ecx,gyy
- mov edx,s
-
- /*broadcast k to all positions of xmm7*/
- movss xmm7,k
- shufps xmm7,xmm7,0
-
- /*****Warm up 1-10**************************************/
- cvtpi2ps xmm0,[eax+8] /*1 Convert two integers into floating point of low double-word*/
- /*Stall*/
- cvtpi2ps xmm1,[ebx+8] /*4 Convert two integers into floating point of low double-word*/
- movlhps xmm0,xmm0 /*2 Move them to the high double-word*/
- cvtpi2ps xmm2,[ecx+8] /*7 Convert two integers into floating point of low double-word*/
- movlhps xmm1,xmm1 /*5 Move them to the high double-word*/
- cvtpi2ps xmm0,[eax] /*3 Convert two integers into floating point of low double-word*/
- movlhps xmm2,xmm2 /*8 Move them to the high double-word*/
- cvtpi2ps xmm1,[ebx] /*6 Convert two integers into floating point of low double-word*/
- movaps xmm3,xmm0 /*10 Copy Cxx*/
- cvtpi2ps xmm2,[ecx] /*9 Convert two integers into floating point of low double-word*/
- /*Stall*/
-loopstart:
- /*****First part of loop 11-18***********************/
- mulps xmm0,xmm2 /*11 Multiply to get Gxx*Gyy*/
- addps xmm2,xmm3 /*12 Add to get Gxx+Gyy*/
- cvtpi2ps xmm4,[eax+24] /*19 Convert two integers into floating point of low double-word*/
- mulps xmm1,xmm1 /*13 Multiply to get Gxy*Gxy*/
- mulps xmm2,xmm2 /*14 Multiply to get (Gxx+Gyy)*(Gxx+Gyy)*/
- movlhps xmm4,xmm4 /*20 Move them to the high double-word*/
- cvtpi2ps xmm4,[eax+16] /*21 Convert two integers into floating point of low double-word*/
- /*Stall*/
- subps xmm0,xmm1 /*15 Subtract to get Gxx*Gyy-Gxy*Gxy*/
- mulps xmm2,xmm7 /*16 Multiply to get k*(Gxx+Gyy)*(Gxx+Gyy)*/
- cvtpi2ps xmm5,[ebx+24] /*22 Convert two integers into floating point of low double-word*/
- /*Stall*/
- movlhps xmm5,xmm5 /*23 Move them to the high double-word*/
- /*Stall*/
- cvtpi2ps xmm5,[ebx+16] /*24 Convert two integers into floating point of low double-word*/
- subps xmm0,xmm2 /*17 Subtract to get Gxx*Gyy-Gxy*Gxy-k*(Gxx+Gyy)*(Gxx+Gyy)*/
- cvtpi2ps xmm6,[ecx+24] /*25 Convert two integers into floating point of low double-word*/
- /*Stall*/
- movaps [edx],xmm0 /*18 Store*/
- /*****Second part of loop 26-40***********************/
- movlhps xmm6,xmm6 /*26 Move them to the high double-word*/
- cvtpi2ps xmm6,[ecx+16] /*27 Convert two integers into floating point of low double-word*/
- movaps xmm3,xmm4 /*28 Copy Cxx*/
- mulps xmm4,xmm6 /*29 Multiply to get Gxx*Gyy*/
- addps xmm6,xmm3 /*30 Add to get Gxx+Gyy*/
- cvtpi2ps xmm0,[eax+40] /*(1 Next) Convert two integers into floating point of low double-word*/
- mulps xmm5,xmm5 /*31 Multiply to get Gxy*Gxy*/
- cvtpi2ps xmm1,[ebx+40] /*(4 Next) Convert two integers into floating point of low double-word*/
- mulps xmm6,xmm6 /*32 Multiply to get (Gxx+Gyy)*(Gxx+Gyy)*/
- cvtpi2ps xmm2,[ecx+40] /*(7 Next) Convert two integers into floating point of low double-word*/
- movlhps xmm0,xmm0 /*(2 Next) Move them to the high double-word*/
- subps xmm4,xmm5 /*33 Subtract to get Gxx*Gyy-Gxy*Gxy*/
- movlhps xmm1,xmm1 /*(5 Next) Move them to the high double-word*/
- cvtpi2ps xmm0,[eax+32] /*(3 Next)Convert two integers into floating point of low double-word*/
- mulps xmm6,xmm7 /*34 Multiply to get k*(Gxx+Gyy)*(Gxx+Gyy)*/
- cvtpi2ps xmm1,[ebx+32] /*(6 Next) Convert two integers into floating point of low double-word*/
- movlhps xmm2,xmm2 /*(8 Next) Move them to the high double-word*/
- movaps xmm3,xmm0 /*(10 Next) Copy Cxx*/
- add eax,32 /*37*/
- subps xmm4,xmm6 /*35 Subtract to get Gxx*Gyy-Gxy*Gxy-k*(Gxx+Gyy)*(Gxx+Gyy)*/
- add ebx,32 /*38*/
- cvtpi2ps xmm2,[ecx+32] /*(9 Next) Convert two integers into floating point of low double-word*/
- /*Stall*/
- movaps [edx+16],xmm4 /*36 Store*/
- /*Stall*/
- add ecx,32 /*39*/
- add edx,32 /*40*/
- dec esi /*41*/
- jnz loopstart
-
- /****Cool down***************/
- mulps xmm0,xmm2 /*Multiply to get Gxx*Gyy*/
- addps xmm2,xmm3 /*Add to get Gxx+Gyy*/
- mulps xmm1,xmm1 /*Multiply to get Gxy*Gxy*/
- mulps xmm2,xmm2 /*Multiply to get (Gxx+Gyy)*(Gxx+Gyy)*/
- subps xmm0,xmm1 /*Subtract to get Gxx*Gyy-Gxy*Gxy*/
- mulps xmm2,xmm7 /*Multiply to get k*(Gxx+Gyy)*(Gxx+Gyy)*/
- subps xmm0,xmm2 /*Subtract to get Gxx*Gyy-Gxy*Gxy-k*(Gxx+Gyy)*(Gxx+Gyy)*/
- movaps [edx],xmm0 /*Store*/
- }
-
-#else
- float Gxx,Gxy,Gyy,det,trc;
- int c;
-
- //for(c=0;c<124;c++)
- for(c=0;c<nc-4;c++)
- {
- Gxx=(float)gxx[c];
- Gxy=(float)gxy[c];
- Gyy=(float)gyy[c];
-
- det=Gxx*Gyy-Gxy*Gxy;
- trc=Gxx+Gyy;
- s[c]=det-k*trc*trc;
- }
-#endif /*DB_USE_SIMD*/
-}
-
-/*Compute the Harris corner strength of the chunk [left,top,right,bottom] of img and
-store it into the corresponding region of s. left and top have to be at least 3 and
-right and bottom have to be at most width-4,height-4*/
-inline void db_HarrisStrengthChunk_f(float **s,const float * const *img,int left,int top,int right,int bottom,
- /*temp should point to at least
- 13*(right-left+5) of allocated memory*/
- float *temp)
-{
- float *Ix[5],*Iy[5];
- float *gxx,*gxy,*gyy;
- int i,chunk_width,chunk_width_p4;
-
- chunk_width=right-left+1;
- chunk_width_p4=chunk_width+4;
- gxx=temp;
- gxy=gxx+chunk_width_p4;
- gyy=gxy+chunk_width_p4;
- for(i=0;i<5;i++)
- {
- Ix[i]=gyy+chunk_width_p4+(2*i*chunk_width_p4);
- Iy[i]=Ix[i]+chunk_width_p4;
- }
-
- /*Fill four rows of the wrap-around derivative buffers*/
- for(i=top-2;i<top+2;i++) db_IxIyRow_f(Ix[i%5],Iy[i%5],img,i,left-2,chunk_width_p4);
-
- /*For each output row*/
- for(i=top;i<=bottom;i++)
- {
- /*Step the derivative buffers*/
- db_IxIyRow_f(Ix[(i+2)%5],Iy[(i+2)%5],img,(i+2),left-2,chunk_width_p4);
-
- /*Filter Ix2,IxIy,Iy2 vertically into gxx,gxy,gyy*/
- db_gxx_gxy_gyy_row_f(gxx,gxy,gyy,chunk_width_p4,
- Ix[(i-2)%5],Ix[(i-1)%5],Ix[i%5],Ix[(i+1)%5],Ix[(i+2)%5],
- Iy[(i-2)%5],Iy[(i-1)%5],Iy[i%5],Iy[(i+1)%5],Iy[(i+2)%5]);
-
- /*Filter gxx,gxy,gyy horizontally and compute corner response s*/
- db_HarrisStrength_row_f(s,gxx,gxy,gyy,i,left,chunk_width);
- }
-}
-
-/*Compute the Harris corner strength of the chunk [left,top,left+123,bottom] of img and
-store it into the corresponding region of s. left and top have to be at least 3 and
-right and bottom have to be at most width-4,height-4. The left of the region in s should
-be 16 byte aligned*/
-inline void db_HarrisStrengthChunk_u(float **s,const unsigned char * const *img,int left,int top,int bottom,
- /*temp should point to at least
- 18*128 of allocated memory*/
- int *temp, int nc)
-{
- int *Ixx[5],*Ixy[5],*Iyy[5];
- int *gxx,*gxy,*gyy;
- int i;
-
- gxx=temp;
- gxy=gxx+128;
- gyy=gxy+128;
- for(i=0;i<5;i++)
- {
- Ixx[i]=gyy+(3*i+1)*128;
- Ixy[i]=gyy+(3*i+2)*128;
- Iyy[i]=gyy+(3*i+3)*128;
- }
-
- /*Fill four rows of the wrap-around derivative buffers*/
- for(i=top-2;i<top+2;i++) db_IxIyRow_u(Ixx[i%5],img,i,left-2,nc);
-
- /*For each output row*/
- for(i=top;i<=bottom;i++)
- {
- /*Step the derivative buffers*/
- db_IxIyRow_u(Ixx[(i+2)%5],img,(i+2),left-2,nc);
-
- /*Filter Ix2,IxIy,Iy2 vertically into gxx,gxy,gyy*/
- db_gxx_gxy_gyy_row_s(gxx,Ixx[(i-2)%5],Ixx[(i-1)%5],Ixx[i%5],Ixx[(i+1)%5],Ixx[(i+2)%5],nc);
-
- /*Filter gxx,gxy,gyy horizontally and compute corner response s*/
- db_HarrisStrength_row_s(s[i]+left,gxx,gxy,gyy,nc);
- }
-
-}
-
-/*Compute Harris corner strength of img. Strength is returned for the region
-with (3,3) as upper left and (w-4,h-4) as lower right, positioned in the
-same place in s. In other words,image should be at least 7 pixels wide and 7 pixels high
-for a meaningful result*/
-void db_HarrisStrength_f(float **s,const float * const *img,int w,int h,
- /*temp should point to at least
- 13*(chunk_width+4) of allocated memory*/
- float *temp,
- int chunk_width)
-{
- int x,next_x,last,right;
-
- last=w-4;
- for(x=3;x<=last;x=next_x)
- {
- next_x=x+chunk_width;
- right=next_x-1;
- if(right>last) right=last;
- /*Compute the Harris strength of a chunk*/
- db_HarrisStrengthChunk_f(s,img,x,3,right,h-4,temp);
- }
-}
-
-/*Compute Harris corner strength of img. Strength is returned for the region
-with (3,3) as upper left and (w-4,h-4) as lower right, positioned in the
-same place in s. In other words,image should be at least 7 pixels wide and 7 pixels high
-for a meaningful result.Moreover, the image should be overallocated by 256 bytes.
-s[i][3] should by 16 byte aligned for any i*/
-void db_HarrisStrength_u(float **s, const unsigned char * const *img,int w,int h,
- /*temp should point to at least
- 18*128 of allocated memory*/
- int *temp)
-{
- int x,next_x,last;
- int nc;
-
- last=w-4;
- for(x=3;x<=last;x=next_x)
- {
- next_x=x+124;
-
- // mayban: to revert to the original full chunks state, change the line below to: nc = 128;
- nc = db_mini(128,last-x+1);
- //nc = 128;
-
- /*Compute the Harris strength of a chunk*/
- db_HarrisStrengthChunk_u(s,img,x,3,h-4,temp,nc);
- }
-}
-
-inline float db_Max_128Aligned16_f(float *v)
-{
-#ifdef DB_USE_SIMD
- float back;
-
- _asm
- {
- mov eax,v
-
- /*Chunk1*/
- movaps xmm0,[eax]
- movaps xmm1,[eax+16]
- movaps xmm2,[eax+32]
- movaps xmm3,[eax+48]
- movaps xmm4,[eax+64]
- movaps xmm5,[eax+80]
- movaps xmm6,[eax+96]
- movaps xmm7,[eax+112]
-
- /*Chunk2*/
- maxps xmm0,[eax+128]
- maxps xmm1,[eax+144]
- maxps xmm2,[eax+160]
- maxps xmm3,[eax+176]
- maxps xmm4,[eax+192]
- maxps xmm5,[eax+208]
- maxps xmm6,[eax+224]
- maxps xmm7,[eax+240]
-
- /*Chunk3*/
- maxps xmm0,[eax+256]
- maxps xmm1,[eax+272]
- maxps xmm2,[eax+288]
- maxps xmm3,[eax+304]
- maxps xmm4,[eax+320]
- maxps xmm5,[eax+336]
- maxps xmm6,[eax+352]
- maxps xmm7,[eax+368]
-
- /*Chunk4*/
- maxps xmm0,[eax+384]
- maxps xmm1,[eax+400]
- maxps xmm2,[eax+416]
- maxps xmm3,[eax+432]
- maxps xmm4,[eax+448]
- maxps xmm5,[eax+464]
- maxps xmm6,[eax+480]
- maxps xmm7,[eax+496]
-
- /*Collect*/
- maxps xmm0,xmm1
- maxps xmm2,xmm3
- maxps xmm4,xmm5
- maxps xmm6,xmm7
- maxps xmm0,xmm2
- maxps xmm4,xmm6
- maxps xmm0,xmm4
- movhlps xmm1,xmm0
- maxps xmm0,xmm1
- shufps xmm1,xmm0,1
- maxps xmm0,xmm1
- movss back,xmm0
- }
-
- return(back);
-#else
- float val,max_val;
- float *p,*stop_p;
- max_val=v[0];
- for(p=v+1,stop_p=v+128;p!=stop_p;)
- {
- val= *p++;
- if(val>max_val) max_val=val;
- }
- return(max_val);
-#endif /*DB_USE_SIMD*/
-}
-
-inline float db_Max_64Aligned16_f(float *v)
-{
-#ifdef DB_USE_SIMD
- float back;
-
- _asm
- {
- mov eax,v
-
- /*Chunk1*/
- movaps xmm0,[eax]
- movaps xmm1,[eax+16]
- movaps xmm2,[eax+32]
- movaps xmm3,[eax+48]
- movaps xmm4,[eax+64]
- movaps xmm5,[eax+80]
- movaps xmm6,[eax+96]
- movaps xmm7,[eax+112]
-
- /*Chunk2*/
- maxps xmm0,[eax+128]
- maxps xmm1,[eax+144]
- maxps xmm2,[eax+160]
- maxps xmm3,[eax+176]
- maxps xmm4,[eax+192]
- maxps xmm5,[eax+208]
- maxps xmm6,[eax+224]
- maxps xmm7,[eax+240]
-
- /*Collect*/
- maxps xmm0,xmm1
- maxps xmm2,xmm3
- maxps xmm4,xmm5
- maxps xmm6,xmm7
- maxps xmm0,xmm2
- maxps xmm4,xmm6
- maxps xmm0,xmm4
- movhlps xmm1,xmm0
- maxps xmm0,xmm1
- shufps xmm1,xmm0,1
- maxps xmm0,xmm1
- movss back,xmm0
- }
-
- return(back);
-#else
- float val,max_val;
- float *p,*stop_p;
- max_val=v[0];
- for(p=v+1,stop_p=v+64;p!=stop_p;)
- {
- val= *p++;
- if(val>max_val) max_val=val;
- }
- return(max_val);
-#endif /*DB_USE_SIMD*/
-}
-
-inline float db_Max_32Aligned16_f(float *v)
-{
-#ifdef DB_USE_SIMD
- float back;
-
- _asm
- {
- mov eax,v
-
- /*Chunk1*/
- movaps xmm0,[eax]
- movaps xmm1,[eax+16]
- movaps xmm2,[eax+32]
- movaps xmm3,[eax+48]
- movaps xmm4,[eax+64]
- movaps xmm5,[eax+80]
- movaps xmm6,[eax+96]
- movaps xmm7,[eax+112]
-
- /*Collect*/
- maxps xmm0,xmm1
- maxps xmm2,xmm3
- maxps xmm4,xmm5
- maxps xmm6,xmm7
- maxps xmm0,xmm2
- maxps xmm4,xmm6
- maxps xmm0,xmm4
- movhlps xmm1,xmm0
- maxps xmm0,xmm1
- shufps xmm1,xmm0,1
- maxps xmm0,xmm1
- movss back,xmm0
- }
-
- return(back);
-#else
- float val,max_val;
- float *p,*stop_p;
- max_val=v[0];
- for(p=v+1,stop_p=v+32;p!=stop_p;)
- {
- val= *p++;
- if(val>max_val) max_val=val;
- }
- return(max_val);
-#endif /*DB_USE_SIMD*/
-}
-
-inline float db_Max_16Aligned16_f(float *v)
-{
-#ifdef DB_USE_SIMD
- float back;
-
- _asm
- {
- mov eax,v
-
- /*Chunk1*/
- movaps xmm0,[eax]
- movaps xmm1,[eax+16]
- movaps xmm2,[eax+32]
- movaps xmm3,[eax+48]
-
- /*Collect*/
- maxps xmm0,xmm1
- maxps xmm2,xmm3
- maxps xmm0,xmm2
- movhlps xmm1,xmm0
- maxps xmm0,xmm1
- shufps xmm1,xmm0,1
- maxps xmm0,xmm1
- movss back,xmm0
- }
-
- return(back);
-#else
- float val,max_val;
- float *p,*stop_p;
- max_val=v[0];
- for(p=v+1,stop_p=v+16;p!=stop_p;)
- {
- val= *p++;
- if(val>max_val) max_val=val;
- }
- return(max_val);
-#endif /*DB_USE_SIMD*/
-}
-
-inline float db_Max_8Aligned16_f(float *v)
-{
-#ifdef DB_USE_SIMD
- float back;
-
- _asm
- {
- mov eax,v
-
- /*Chunk1*/
- movaps xmm0,[eax]
- movaps xmm1,[eax+16]
-
- /*Collect*/
- maxps xmm0,xmm1
- movhlps xmm1,xmm0
- maxps xmm0,xmm1
- shufps xmm1,xmm0,1
- maxps xmm0,xmm1
- movss back,xmm0
- }
-
- return(back);
-#else
- float val,max_val;
- float *p,*stop_p;
- max_val=v[0];
- for(p=v+1,stop_p=v+8;p!=stop_p;)
- {
- val= *p++;
- if(val>max_val) max_val=val;
- }
- return(max_val);
-#endif /*DB_USE_SIMD*/
-}
-
-inline float db_Max_Aligned16_f(float *v,int size)
-{
- float val,max_val;
- float *stop_v;
-
- max_val=v[0];
- for(;size>=128;size-=128)
- {
- val=db_Max_128Aligned16_f(v);
- v+=128;
- if(val>max_val) max_val=val;
- }
- if(size&64)
- {
- val=db_Max_64Aligned16_f(v);
- v+=64;
- if(val>max_val) max_val=val;
- }
- if(size&32)
- {
- val=db_Max_32Aligned16_f(v);
- v+=32;
- if(val>max_val) max_val=val;
- }
- if(size&16)
- {
- val=db_Max_16Aligned16_f(v);
- v+=16;
- if(val>max_val) max_val=val;
- }
- if(size&8)
- {
- val=db_Max_8Aligned16_f(v);
- v+=8;
- if(val>max_val) max_val=val;
- }
- if(size&7)
- {
- for(stop_v=v+(size&7);v!=stop_v;)
- {
- val= *v++;
- if(val>max_val) max_val=val;
- }
- }
-
- return(max_val);
-}
-
-/*Find maximum value of img in the region starting at (left,top)
-and with width w and height h. img[left] should be 16 byte aligned*/
-float db_MaxImage_Aligned16_f(float **img,int left,int top,int w,int h)
-{
- float val,max_val;
- int i,stop_i;
-
- if(w && h)
- {
- stop_i=top+h;
- max_val=img[top][left];
-
- for(i=top;i<stop_i;i++)
- {
- val=db_Max_Aligned16_f(img[i]+left,w);
- if(val>max_val) max_val=val;
- }
- return(max_val);
- }
- return(0.0);
-}
-
-inline void db_MaxVector_128_Aligned16_f(float *m,float *v1,float *v2)
-{
-#ifdef DB_USE_SIMD
- _asm
- {
- mov eax,v1
- mov ebx,v2
- mov ecx,m
-
- /*Chunk1*/
- movaps xmm0,[eax]
- movaps xmm1,[eax+16]
- movaps xmm2,[eax+32]
- movaps xmm3,[eax+48]
- movaps xmm4,[eax+64]
- movaps xmm5,[eax+80]
- movaps xmm6,[eax+96]
- movaps xmm7,[eax+112]
- maxps xmm0,[ebx]
- maxps xmm1,[ebx+16]
- maxps xmm2,[ebx+32]
- maxps xmm3,[ebx+48]
- maxps xmm4,[ebx+64]
- maxps xmm5,[ebx+80]
- maxps xmm6,[ebx+96]
- maxps xmm7,[ebx+112]
- movaps [ecx],xmm0
- movaps [ecx+16],xmm1
- movaps [ecx+32],xmm2
- movaps [ecx+48],xmm3
- movaps [ecx+64],xmm4
- movaps [ecx+80],xmm5
- movaps [ecx+96],xmm6
- movaps [ecx+112],xmm7
-
- /*Chunk2*/
- movaps xmm0,[eax+128]
- movaps xmm1,[eax+144]
- movaps xmm2,[eax+160]
- movaps xmm3,[eax+176]
- movaps xmm4,[eax+192]
- movaps xmm5,[eax+208]
- movaps xmm6,[eax+224]
- movaps xmm7,[eax+240]
- maxps xmm0,[ebx+128]
- maxps xmm1,[ebx+144]
- maxps xmm2,[ebx+160]
- maxps xmm3,[ebx+176]
- maxps xmm4,[ebx+192]
- maxps xmm5,[ebx+208]
- maxps xmm6,[ebx+224]
- maxps xmm7,[ebx+240]
- movaps [ecx+128],xmm0
- movaps [ecx+144],xmm1
- movaps [ecx+160],xmm2
- movaps [ecx+176],xmm3
- movaps [ecx+192],xmm4
- movaps [ecx+208],xmm5
- movaps [ecx+224],xmm6
- movaps [ecx+240],xmm7
-
- /*Chunk3*/
- movaps xmm0,[eax+256]
- movaps xmm1,[eax+272]
- movaps xmm2,[eax+288]
- movaps xmm3,[eax+304]
- movaps xmm4,[eax+320]
- movaps xmm5,[eax+336]
- movaps xmm6,[eax+352]
- movaps xmm7,[eax+368]
- maxps xmm0,[ebx+256]
- maxps xmm1,[ebx+272]
- maxps xmm2,[ebx+288]
- maxps xmm3,[ebx+304]
- maxps xmm4,[ebx+320]
- maxps xmm5,[ebx+336]
- maxps xmm6,[ebx+352]
- maxps xmm7,[ebx+368]
- movaps [ecx+256],xmm0
- movaps [ecx+272],xmm1
- movaps [ecx+288],xmm2
- movaps [ecx+304],xmm3
- movaps [ecx+320],xmm4
- movaps [ecx+336],xmm5
- movaps [ecx+352],xmm6
- movaps [ecx+368],xmm7
-
- /*Chunk4*/
- movaps xmm0,[eax+384]
- movaps xmm1,[eax+400]
- movaps xmm2,[eax+416]
- movaps xmm3,[eax+432]
- movaps xmm4,[eax+448]
- movaps xmm5,[eax+464]
- movaps xmm6,[eax+480]
- movaps xmm7,[eax+496]
- maxps xmm0,[ebx+384]
- maxps xmm1,[ebx+400]
- maxps xmm2,[ebx+416]
- maxps xmm3,[ebx+432]
- maxps xmm4,[ebx+448]
- maxps xmm5,[ebx+464]
- maxps xmm6,[ebx+480]
- maxps xmm7,[ebx+496]
- movaps [ecx+384],xmm0
- movaps [ecx+400],xmm1
- movaps [ecx+416],xmm2
- movaps [ecx+432],xmm3
- movaps [ecx+448],xmm4
- movaps [ecx+464],xmm5
- movaps [ecx+480],xmm6
- movaps [ecx+496],xmm7
- }
-#else
- int i;
- float a,b;
- for(i=0;i<128;i++)
- {
- a=v1[i];
- b=v2[i];
- if(a>=b) m[i]=a;
- else m[i]=b;
- }
-#endif /*DB_USE_SIMD*/
-}
-
-inline void db_MaxVector_128_SecondSourceDestAligned16_f(float *m,float *v1,float *v2)
-{
-#ifdef DB_USE_SIMD
- _asm
- {
- mov eax,v1
- mov ebx,v2
- mov ecx,m
-
- /*Chunk1*/
- movups xmm0,[eax]
- movups xmm1,[eax+16]
- movups xmm2,[eax+32]
- movups xmm3,[eax+48]
- movups xmm4,[eax+64]
- movups xmm5,[eax+80]
- movups xmm6,[eax+96]
- movups xmm7,[eax+112]
- maxps xmm0,[ebx]
- maxps xmm1,[ebx+16]
- maxps xmm2,[ebx+32]
- maxps xmm3,[ebx+48]
- maxps xmm4,[ebx+64]
- maxps xmm5,[ebx+80]
- maxps xmm6,[ebx+96]
- maxps xmm7,[ebx+112]
- movaps [ecx],xmm0
- movaps [ecx+16],xmm1
- movaps [ecx+32],xmm2
- movaps [ecx+48],xmm3
- movaps [ecx+64],xmm4
- movaps [ecx+80],xmm5
- movaps [ecx+96],xmm6
- movaps [ecx+112],xmm7
-
- /*Chunk2*/
- movups xmm0,[eax+128]
- movups xmm1,[eax+144]
- movups xmm2,[eax+160]
- movups xmm3,[eax+176]
- movups xmm4,[eax+192]
- movups xmm5,[eax+208]
- movups xmm6,[eax+224]
- movups xmm7,[eax+240]
- maxps xmm0,[ebx+128]
- maxps xmm1,[ebx+144]
- maxps xmm2,[ebx+160]
- maxps xmm3,[ebx+176]
- maxps xmm4,[ebx+192]
- maxps xmm5,[ebx+208]
- maxps xmm6,[ebx+224]
- maxps xmm7,[ebx+240]
- movaps [ecx+128],xmm0
- movaps [ecx+144],xmm1
- movaps [ecx+160],xmm2
- movaps [ecx+176],xmm3
- movaps [ecx+192],xmm4
- movaps [ecx+208],xmm5
- movaps [ecx+224],xmm6
- movaps [ecx+240],xmm7
-
- /*Chunk3*/
- movups xmm0,[eax+256]
- movups xmm1,[eax+272]
- movups xmm2,[eax+288]
- movups xmm3,[eax+304]
- movups xmm4,[eax+320]
- movups xmm5,[eax+336]
- movups xmm6,[eax+352]
- movups xmm7,[eax+368]
- maxps xmm0,[ebx+256]
- maxps xmm1,[ebx+272]
- maxps xmm2,[ebx+288]
- maxps xmm3,[ebx+304]
- maxps xmm4,[ebx+320]
- maxps xmm5,[ebx+336]
- maxps xmm6,[ebx+352]
- maxps xmm7,[ebx+368]
- movaps [ecx+256],xmm0
- movaps [ecx+272],xmm1
- movaps [ecx+288],xmm2
- movaps [ecx+304],xmm3
- movaps [ecx+320],xmm4
- movaps [ecx+336],xmm5
- movaps [ecx+352],xmm6
- movaps [ecx+368],xmm7
-
- /*Chunk4*/
- movups xmm0,[eax+384]
- movups xmm1,[eax+400]
- movups xmm2,[eax+416]
- movups xmm3,[eax+432]
- movups xmm4,[eax+448]
- movups xmm5,[eax+464]
- movups xmm6,[eax+480]
- movups xmm7,[eax+496]
- maxps xmm0,[ebx+384]
- maxps xmm1,[ebx+400]
- maxps xmm2,[ebx+416]
- maxps xmm3,[ebx+432]
- maxps xmm4,[ebx+448]
- maxps xmm5,[ebx+464]
- maxps xmm6,[ebx+480]
- maxps xmm7,[ebx+496]
- movaps [ecx+384],xmm0
- movaps [ecx+400],xmm1
- movaps [ecx+416],xmm2
- movaps [ecx+432],xmm3
- movaps [ecx+448],xmm4
- movaps [ecx+464],xmm5
- movaps [ecx+480],xmm6
- movaps [ecx+496],xmm7
- }
-#else
- int i;
- float a,b;
- for(i=0;i<128;i++)
- {
- a=v1[i];
- b=v2[i];
- if(a>=b) m[i]=a;
- else m[i]=b;
- }
-#endif /*DB_USE_SIMD*/
-}
-
-/*Compute Max-suppression-filtered image for a chunk of sf starting at (left,top), of width 124 and
-stopping at bottom. The output is shifted two steps left and overwrites 128 elements for each row.
-The input s should be of width at least 128, and exist for 2 pixels outside the specified region.
-s[i][left-2] and sf[i][left-2] should be 16 byte aligned. Top must be at least 3*/
-inline void db_MaxSuppressFilterChunk_5x5_Aligned16_f(float **sf,float **s,int left,int top,int bottom,
- /*temp should point to at least
- 6*132 floats of 16-byte-aligned allocated memory*/
- float *temp)
-{
-#ifdef DB_USE_SIMD
- int i,lm2;
- float *two[4];
- float *four,*five;
-
- lm2=left-2;
-
- /*Set pointers to pre-allocated memory*/
- four=temp;
- five=four+132;
- for(i=0;i<4;i++)
- {
- two[i]=five+(i+1)*132;
- }
-
- /*Set rests of four and five to zero to avoid
- floating point exceptions*/
- for(i=129;i<132;i++)
- {
- four[i]=0.0;
- five[i]=0.0;
- }
-
- /*Fill three rows of the wrap-around max buffers*/
- for(i=top-3;i<top;i++) db_MaxVector_128_Aligned16_f(two[i&3],s[i+1]+lm2,s[i+2]+lm2);
-
- /*For each output row*/
- for(;i<=bottom;i++)
- {
- /*Compute max of the lowest pair of rows in the five row window*/
- db_MaxVector_128_Aligned16_f(two[i&3],s[i+1]+lm2,s[i+2]+lm2);
- /*Compute max of the lowest and highest pair of rows in the five row window*/
- db_MaxVector_128_Aligned16_f(four,two[i&3],two[(i-3)&3]);
- /*Compute max of all rows*/
- db_MaxVector_128_Aligned16_f(five,four,two[(i-1)&3]);
- /*Compute max of 2x5 chunks*/
- db_MaxVector_128_SecondSourceDestAligned16_f(five,five+1,five);
- /*Compute max of pairs of 2x5 chunks*/
- db_MaxVector_128_SecondSourceDestAligned16_f(five,five+3,five);
- /*Compute max of pairs of 5x5 except middle*/
- db_MaxVector_128_SecondSourceDestAligned16_f(sf[i]+lm2,four+2,five);
- }
-
-#else
- int i,j,right;
- float sv;
-
- right=left+128;
- for(i=top;i<=bottom;i++) for(j=left;j<right;j++)
- {
- sv=s[i][j];
-
- if( sv>s[i-2][j-2] && sv>s[i-2][j-1] && sv>s[i-2][j] && sv>s[i-2][j+1] && sv>s[i-2][j+2] &&
- sv>s[i-1][j-2] && sv>s[i-1][j-1] && sv>s[i-1][j] && sv>s[i-1][j+1] && sv>s[i-1][j+2] &&
- sv>s[ i][j-2] && sv>s[ i][j-1] && sv>s[ i][j+1] && sv>s[ i][j+2] &&
- sv>s[i+1][j-2] && sv>s[i+1][j-1] && sv>s[i+1][j] && sv>s[i+1][j+1] && sv>s[i+1][j+2] &&
- sv>s[i+2][j-2] && sv>s[i+2][j-1] && sv>s[i+2][j] && sv>s[i+2][j+1] && sv>s[i+2][j+2])
- {
- sf[i][j-2]=0.0;
- }
- else sf[i][j-2]=sv;
- }
-#endif /*DB_USE_SIMD*/
-}
-
-/*Compute Max-suppression-filtered image for a chunk of sf starting at (left,top) and
-stopping at bottom. The output is shifted two steps left. The input s should exist for 2 pixels
-outside the specified region. s[i][left-2] and sf[i][left-2] should be 16 byte aligned.
-Top must be at least 3. Reading and writing from and to the input and output images is done
-as if the region had a width equal to a multiple of 124. If this is not the case, the images
-should be over-allocated and the input cleared for a sufficient region*/
-void db_MaxSuppressFilter_5x5_Aligned16_f(float **sf,float **s,int left,int top,int right,int bottom,
- /*temp should point to at least
- 6*132 floats of 16-byte-aligned allocated memory*/
- float *temp)
-{
- int x,next_x;
-
- for(x=left;x<=right;x=next_x)
- {
- next_x=x+124;
- db_MaxSuppressFilterChunk_5x5_Aligned16_f(sf,s,x,top,bottom,temp);
- }
-}
-
-/*Extract corners from the chunk (left,top) to (right,bottom). Store in x_temp,y_temp and s_temp
-which should point to space of at least as many positions as there are pixels in the chunk*/
-inline int db_CornersFromChunk(float **strength,int left,int top,int right,int bottom,float threshold,double *x_temp,double *y_temp,double *s_temp)
-{
- int i,j,nr;
- float s;
-
- nr=0;
- for(i=top;i<=bottom;i++) for(j=left;j<=right;j++)
- {
- s=strength[i][j];
-
- if(s>=threshold &&
- s>strength[i-2][j-2] && s>strength[i-2][j-1] && s>strength[i-2][j] && s>strength[i-2][j+1] && s>strength[i-2][j+2] &&
- s>strength[i-1][j-2] && s>strength[i-1][j-1] && s>strength[i-1][j] && s>strength[i-1][j+1] && s>strength[i-1][j+2] &&
- s>strength[ i][j-2] && s>strength[ i][j-1] && s>strength[ i][j+1] && s>strength[ i][j+2] &&
- s>strength[i+1][j-2] && s>strength[i+1][j-1] && s>strength[i+1][j] && s>strength[i+1][j+1] && s>strength[i+1][j+2] &&
- s>strength[i+2][j-2] && s>strength[i+2][j-1] && s>strength[i+2][j] && s>strength[i+2][j+1] && s>strength[i+2][j+2])
- {
- x_temp[nr]=(double) j;
- y_temp[nr]=(double) i;
- s_temp[nr]=(double) s;
- nr++;
- }
- }
- return(nr);
-}
-
-
-//Sub-pixel accuracy using 2D quadratic interpolation.(YCJ)
-inline void db_SubPixel(float **strength, const double xd, const double yd, double &xs, double &ys)
-{
- int x = (int) xd;
- int y = (int) yd;
-
- float fxx = strength[y][x-1] - strength[y][x] - strength[y][x] + strength[y][x+1];
- float fyy = strength[y-1][x] - strength[y][x] - strength[y][x] + strength[y+1][x];
- float fxy = (strength[y-1][x-1] - strength[y-1][x+1] - strength[y+1][x-1] + strength[y+1][x+1])/(float)4.0;
-
- float denom = (fxx * fyy - fxy * fxy) * (float) 2.0;
-
- xs = xd;
- ys = yd;
-
- if ( db_absf(denom) <= FLT_EPSILON )
- {
- return;
- }
- else
- {
- float fx = strength[y][x+1] - strength[y][x-1];
- float fy = strength[y+1][x] - strength[y-1][x];
-
- float dx = (fyy * fx - fxy * fy) / denom;
- float dy = (fxx * fy - fxy * fx) / denom;
-
- if ( db_absf(dx) > 1.0 || db_absf(dy) > 1.0 )
- {
- return;
- }
- else
- {
- xs -= dx;
- ys -= dy;
- }
- }
-
- return;
-}
-
-/*Extract corners from the image part from (left,top) to (right,bottom).
-Store in x and y, extracting at most satnr corners in each block of size (bw,bh).
-The pointer temp_d should point to at least 5*bw*bh positions.
-area_factor holds how many corners max to extract per 10000 pixels*/
-void db_ExtractCornersSaturated(float **strength,int left,int top,int right,int bottom,
- int bw,int bh,unsigned long area_factor,
- float threshold,double *temp_d,
- double *x_coord,double *y_coord,int *nr_corners)
-{
- double *x_temp,*y_temp,*s_temp,*select_temp;
- double loc_thresh;
- unsigned long bwbh,area,saturation;
- int x,next_x,last_x;
- int y,next_y,last_y;
- int nr,nr_points,i,stop;
-
- bwbh=bw*bh;
- x_temp=temp_d;
- y_temp=x_temp+bwbh;
- s_temp=y_temp+bwbh;
- select_temp=s_temp+bwbh;
-
-#ifdef DB_SUB_PIXEL
- // subpixel processing may sometimes push the corner ourside the real border
- // increasing border size:
- left++;
- top++;
- bottom--;
- right--;
-#endif /*DB_SUB_PIXEL*/
-
- nr_points=0;
- for(y=top;y<=bottom;y=next_y)
- {
- next_y=y+bh;
- last_y=next_y-1;
- if(last_y>bottom) last_y=bottom;
- for(x=left;x<=right;x=next_x)
- {
- next_x=x+bw;
- last_x=next_x-1;
- if(last_x>right) last_x=right;
-
- area=(last_x-x+1)*(last_y-y+1);
- saturation=(area*area_factor)/10000;
- nr=db_CornersFromChunk(strength,x,y,last_x,last_y,threshold,x_temp,y_temp,s_temp);
- if(nr)
- {
- if(((unsigned long)nr)>saturation) loc_thresh=db_LeanQuickSelect(s_temp,nr,nr-saturation,select_temp);
- else loc_thresh=threshold;
-
- stop=nr_points+saturation;
- for(i=0;(i<nr)&&(nr_points<stop);i++)
- {
- if(s_temp[i]>=loc_thresh)
- {
- #ifdef DB_SUB_PIXEL
- db_SubPixel(strength, x_temp[i], y_temp[i], x_coord[nr_points], y_coord[nr_points]);
- #else
- x_coord[nr_points]=x_temp[i];
- y_coord[nr_points]=y_temp[i];
- #endif
-
- nr_points++;
- }
- }
- }
- }
- }
- *nr_corners=nr_points;
-}
-
-db_CornerDetector_f::db_CornerDetector_f()
-{
- m_w=0; m_h=0;
-}
-
-db_CornerDetector_f::~db_CornerDetector_f()
-{
- Clean();
-}
-
-void db_CornerDetector_f::Clean()
-{
- if(m_w!=0)
- {
- delete [] m_temp_f;
- delete [] m_temp_d;
- db_FreeStrengthImage_f(m_strength_mem,m_strength,m_h);
- }
- m_w=0; m_h=0;
-}
-
-unsigned long db_CornerDetector_f::Init(int im_width,int im_height,int target_nr_corners,
- int nr_horizontal_blocks,int nr_vertical_blocks,
- double absolute_threshold,double relative_threshold)
-{
- int chunkwidth=208;
- int block_width,block_height;
- unsigned long area_factor;
- int active_width,active_height;
-
- active_width=db_maxi(1,im_width-10);
- active_height=db_maxi(1,im_height-10);
- block_width=db_maxi(1,active_width/nr_horizontal_blocks);
- block_height=db_maxi(1,active_height/nr_vertical_blocks);
-
- area_factor=db_minl(1000,db_maxl(1,(long)(10000.0*((double)target_nr_corners)/
- (((double)active_width)*((double)active_height)))));
-
- return(Start(im_width,im_height,block_width,block_height,area_factor,
- absolute_threshold,relative_threshold,chunkwidth));
-}
-
-unsigned long db_CornerDetector_f::Start(int im_width,int im_height,
- int block_width,int block_height,unsigned long area_factor,
- double absolute_threshold,double relative_threshold,int chunkwidth)
-{
- Clean();
-
- m_w=im_width;
- m_h=im_height;
- m_cw=chunkwidth;
- m_bw=block_width;
- m_bh=block_height;
- m_area_factor=area_factor;
- m_r_thresh=relative_threshold;
- m_a_thresh=absolute_threshold;
- m_max_nr=db_maxl(1,1+(m_w*m_h*m_area_factor)/10000);
-
- m_temp_f=new float[13*(m_cw+4)];
- m_temp_d=new double[5*m_bw*m_bh];
- m_strength=db_AllocStrengthImage_f(&m_strength_mem,m_w,m_h);
-
- return(m_max_nr);
-}
-
-void db_CornerDetector_f::DetectCorners(const float * const *img,double *x_coord,double *y_coord,int *nr_corners) const
-{
- float max_val,threshold;
-
- db_HarrisStrength_f(m_strength,img,m_w,m_h,m_temp_f,m_cw);
-
- if(m_r_thresh)
- {
- max_val=db_MaxImage_Aligned16_f(m_strength,3,3,m_w-6,m_h-6);
- threshold= (float) db_maxd(m_a_thresh,max_val*m_r_thresh);
- }
- else threshold= (float) m_a_thresh;
-
- db_ExtractCornersSaturated(m_strength,BORDER,BORDER,m_w-BORDER-1,m_h-BORDER-1,m_bw,m_bh,m_area_factor,threshold,
- m_temp_d,x_coord,y_coord,nr_corners);
-}
-
-db_CornerDetector_u::db_CornerDetector_u()
-{
- m_w=0; m_h=0;
-}
-
-db_CornerDetector_u::~db_CornerDetector_u()
-{
- Clean();
-}
-
-db_CornerDetector_u::db_CornerDetector_u(const db_CornerDetector_u& cd)
-{
- Start(cd.m_w, cd.m_h, cd.m_bw, cd.m_bh, cd.m_area_factor,
- cd.m_a_thresh, cd.m_r_thresh);
-}
-
-db_CornerDetector_u& db_CornerDetector_u::operator=(const db_CornerDetector_u& cd)
-{
- if ( this == &cd ) return *this;
-
- Clean();
-
- Start(cd.m_w, cd.m_h, cd.m_bw, cd.m_bh, cd.m_area_factor,
- cd.m_a_thresh, cd.m_r_thresh);
-
- return *this;
-}
-
-void db_CornerDetector_u::Clean()
-{
- if(m_w!=0)
- {
- delete [] m_temp_i;
- delete [] m_temp_d;
- db_FreeStrengthImage_f(m_strength_mem,m_strength,m_h);
- }
- m_w=0; m_h=0;
-}
-
-unsigned long db_CornerDetector_u::Init(int im_width,int im_height,int target_nr_corners,
- int nr_horizontal_blocks,int nr_vertical_blocks,
- double absolute_threshold,double relative_threshold)
-{
- int block_width,block_height;
- unsigned long area_factor;
- int active_width,active_height;
-
- active_width=db_maxi(1,im_width-10);
- active_height=db_maxi(1,im_height-10);
- block_width=db_maxi(1,active_width/nr_horizontal_blocks);
- block_height=db_maxi(1,active_height/nr_vertical_blocks);
-
- area_factor=db_minl(1000,db_maxl(1,(long)(10000.0*((double)target_nr_corners)/
- (((double)active_width)*((double)active_height)))));
-
- return(Start(im_width,im_height,block_width,block_height,area_factor,
- 16.0*absolute_threshold,relative_threshold));
-}
-
-unsigned long db_CornerDetector_u::Start(int im_width,int im_height,
- int block_width,int block_height,unsigned long area_factor,
- double absolute_threshold,double relative_threshold)
-{
- Clean();
-
- m_w=im_width;
- m_h=im_height;
- m_bw=block_width;
- m_bh=block_height;
- m_area_factor=area_factor;
- m_r_thresh=relative_threshold;
- m_a_thresh=absolute_threshold;
- m_max_nr=db_maxl(1,1+(m_w*m_h*m_area_factor)/10000);
-
- m_temp_i=new int[18*128];
- m_temp_d=new double[5*m_bw*m_bh];
- m_strength=db_AllocStrengthImage_f(&m_strength_mem,m_w,m_h);
-
- return(m_max_nr);
-}
-
-void db_CornerDetector_u::DetectCorners(const unsigned char * const *img,double *x_coord,double *y_coord,int *nr_corners,
- const unsigned char * const *msk, unsigned char fgnd) const
-{
- float max_val,threshold;
-
- db_HarrisStrength_u(m_strength,img,m_w,m_h,m_temp_i);
-
-
- if(m_r_thresh)
- {
- max_val=db_MaxImage_Aligned16_f(m_strength,3,3,m_w-6,m_h-6);
- threshold= (float) db_maxd(m_a_thresh,max_val*m_r_thresh);
- }
- else threshold= (float) m_a_thresh;
-
- db_ExtractCornersSaturated(m_strength,BORDER,BORDER,m_w-BORDER-1,m_h-BORDER-1,m_bw,m_bh,m_area_factor,threshold,
- m_temp_d,x_coord,y_coord,nr_corners);
-
-
- if ( msk )
- {
- int nr_corners_mask=0;
-
- for ( int i = 0; i < *nr_corners; ++i)
- {
- int cor_x = db_roundi(*(x_coord+i));
- int cor_y = db_roundi(*(y_coord+i));
- if ( msk[cor_y][cor_x] == fgnd )
- {
- x_coord[nr_corners_mask] = x_coord[i];
- y_coord[nr_corners_mask] = y_coord[i];
- nr_corners_mask++;
- }
- }
- *nr_corners = nr_corners_mask;
- }
-}
-
-void db_CornerDetector_u::ExtractCorners(float ** strength, double *x_coord, double *y_coord, int *nr_corners) {
- if ( m_w!=0 )
- db_ExtractCornersSaturated(strength,BORDER,BORDER,m_w-BORDER-1,m_h-BORDER-1,m_bw,m_bh,m_area_factor,float(m_a_thresh),
- m_temp_d,x_coord,y_coord,nr_corners);
-}
-
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_feature_detection.h b/jni_mosaic/feature_stab/db_vlvm/db_feature_detection.h
deleted file mode 100644
index 68ffcc9..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_feature_detection.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/*$Id: db_feature_detection.h,v 1.3 2011/06/17 14:03:30 mbansal Exp $*/
-
-#ifndef DB_FEATURE_DETECTION_H
-#define DB_FEATURE_DETECTION_H
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup FeatureDetection Feature Detection
- */
-#include "db_utilities.h"
-#include "db_utilities_constants.h"
-#include <stdlib.h> //for NULL
-
-/*!
- * \class db_CornerDetector_f
- * \ingroup FeatureDetection
- * \brief Harris corner detector for float images.
- *
- * This class performs Harris corner extraction on *float* images managed
- * with functions in \ref LMImageBasicUtilities.
- */
-class DB_API db_CornerDetector_f
-{
-public:
- db_CornerDetector_f();
- ~db_CornerDetector_f();
-
- /*!
- * Set parameters and pre-allocate memory. Return an upper bound
- * on the number of corners detected in one frame.
- * \param im_width width
- * \param im_height height
- * \param target_nr_corners
- * \param nr_horizontal_blocks
- * \param nr_vertical_blocks
- * \param absolute_threshold
- * \param relative_threshold
- */
- unsigned long Init(int im_width,int im_height,
- int target_nr_corners=DB_DEFAULT_TARGET_NR_CORNERS,
- int nr_horizontal_blocks=DB_DEFAULT_NR_FEATURE_BLOCKS,
- int nr_vertical_blocks=DB_DEFAULT_NR_FEATURE_BLOCKS,
- double absolute_threshold=DB_DEFAULT_ABS_CORNER_THRESHOLD,
- double relative_threshold=DB_DEFAULT_REL_CORNER_THRESHOLD);
-
- /*!
- * Detect the corners.
- * x_coord and y_coord should be pre-allocated arrays of length returned by Init().
- * \param img row array pointer
- * \param x_coord corner locations
- * \param y_coord corner locations
- * \param nr_corners actual number of corners computed
- */
- void DetectCorners(const float * const *img,double *x_coord,double *y_coord,int *nr_corners) const;
- void SetAbsoluteThreshold(double a_thresh) { m_a_thresh = a_thresh; };
- void SetRelativeThreshold(double r_thresh) { m_r_thresh = r_thresh; };
-protected:
- void Clean();
- unsigned long Start(int im_width,int im_height,
- int block_width,int block_height,unsigned long area_factor,
- double absolute_threshold,double relative_threshold,int chunkwidth);
-
- int m_w,m_h,m_cw,m_bw,m_bh;
- /*Area factor holds the maximum number of corners to detect
- per 10000 pixels*/
- unsigned long m_area_factor,m_max_nr;
- double m_a_thresh,m_r_thresh;
- float *m_temp_f;
- double *m_temp_d;
- float **m_strength,*m_strength_mem;
-};
-/*!
- * \class db_CornerDetector_u
- * \ingroup FeatureDetection
- * \brief Harris corner detector for byte images.
- *
- * This class performs Harris corner extraction on *byte* images managed
- * with functions in \ref LMImageBasicUtilities.
- */
-class DB_API db_CornerDetector_u
-{
-public:
- db_CornerDetector_u();
- virtual ~db_CornerDetector_u();
-
- /*!
- Copy ctor duplicates settings.
- Memory is not copied.
- */
- db_CornerDetector_u(const db_CornerDetector_u& cd);
- /*!
- Assignment optor duplicates settings.
- Memory not copied.
- */
- db_CornerDetector_u& operator=(const db_CornerDetector_u& cd);
-
- /*!
- * Set parameters and pre-allocate memory. Return an upper bound
- * on the number of corners detected in one frame
- */
- virtual unsigned long Init(int im_width,int im_height,
- int target_nr_corners=DB_DEFAULT_TARGET_NR_CORNERS,
- int nr_horizontal_blocks=DB_DEFAULT_NR_FEATURE_BLOCKS,
- int nr_vertical_blocks=DB_DEFAULT_NR_FEATURE_BLOCKS,
- double absolute_threshold=DB_DEFAULT_ABS_CORNER_THRESHOLD,
- double relative_threshold=DB_DEFAULT_REL_CORNER_THRESHOLD);
-
- /*!
- * Detect the corners.
- * Observe that the image should be overallocated by at least 256 bytes
- * at the end.
- * x_coord and y_coord should be pre-allocated arrays of length returned by Init().
- * Specifying image mask will restrict corner output to foreground regions.
- * Foreground value can be specified using fgnd. By default any >0 mask value
- * is considered to be foreground
- * \param img row array pointer
- * \param x_coord corner locations
- * \param y_coord corner locations
- * \param nr_corners actual number of corners computed
- * \param msk row array pointer to mask image
- * \param fgnd foreground value in the mask
- */
- virtual void DetectCorners(const unsigned char * const *img,double *x_coord,double *y_coord,int *nr_corners,
- const unsigned char * const * msk=NULL, unsigned char fgnd=255) const;
-
- /*!
- Set absolute feature threshold
- */
- virtual void SetAbsoluteThreshold(double a_thresh) { m_a_thresh = a_thresh; };
- /*!
- Set relative feature threshold
- */
- virtual void SetRelativeThreshold(double r_thresh) { m_r_thresh = r_thresh; };
-
- /*!
- Extract corners from a pre-computed strength image.
- \param strength Harris strength image
- \param x_coord corner locations
- \param y_coord corner locations
- \param nr_corners actual number of corners computed
- */
- virtual void ExtractCorners(float ** strength, double *x_coord, double *y_coord, int *nr_corners);
-protected:
- virtual void Clean();
- /*The absolute threshold to this function should be 16.0 times
- normal*/
- unsigned long Start(int im_width,int im_height,
- int block_width,int block_height,unsigned long area_factor,
- double absolute_threshold,double relative_threshold);
-
- int m_w,m_h,m_bw,m_bh;
- /*Area factor holds the maximum number of corners to detect
- per 10000 pixels*/
- unsigned long m_area_factor,m_max_nr;
- double m_a_thresh,m_r_thresh;
- int *m_temp_i;
- double *m_temp_d;
- float **m_strength,*m_strength_mem;
-};
-
-#endif /*DB_FEATURE_DETECTION_H*/
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_feature_matching.cpp b/jni_mosaic/feature_stab/db_vlvm/db_feature_matching.cpp
deleted file mode 100644
index d278d0c..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_feature_matching.cpp
+++ /dev/null
@@ -1,3410 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/*$Id: db_feature_matching.cpp,v 1.4 2011/06/17 14:03:30 mbansal Exp $*/
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-#include "db_utilities.h"
-#include "db_feature_matching.h"
-#ifdef _VERBOSE_
-#include <iostream>
-#endif
-
-
-int AffineWarpPoint_NN_LUT_x[11][11];
-int AffineWarpPoint_NN_LUT_y[11][11];
-
-float AffineWarpPoint_BL_LUT_x[11][11];
-float AffineWarpPoint_BL_LUT_y[11][11];
-
-
-inline float db_SignedSquareNormCorr7x7_u(unsigned char **f_img,unsigned char **g_img,int x_f,int y_f,int x_g,int y_g)
-{
- unsigned char *pf,*pg;
- float f,g,fgsum,f2sum,g2sum,fsum,gsum,fg_corr,den;
- int xm_f,xm_g;
-
- xm_f=x_f-3;
- xm_g=x_g-3;
- fgsum=0.0; f2sum=0.0; g2sum=0.0; fsum=0.0; gsum=0.0;
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- fg_corr=49.0f*fgsum-fsum*gsum;
- den=(49.0f*f2sum-fsum*fsum)*(49.0f*g2sum-gsum*gsum);
- if(den!=0.0)
- {
- if(fg_corr>=0.0) return(fg_corr*fg_corr/den);
- return(-fg_corr*fg_corr/den);
- }
- return(0.0);
-}
-
-inline float db_SignedSquareNormCorr9x9_u(unsigned char **f_img,unsigned char **g_img,int x_f,int y_f,int x_g,int y_g)
-{
- unsigned char *pf,*pg;
- float f,g,fgsum,f2sum,g2sum,fsum,gsum,fg_corr,den;
- int xm_f,xm_g;
-
- xm_f=x_f-4;
- xm_g=x_g-4;
- fgsum=0.0; f2sum=0.0; g2sum=0.0; fsum=0.0; gsum=0.0;
-
- pf=f_img[y_f-4]+xm_f; pg=g_img[y_g-4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+4]+xm_f; pg=g_img[y_g+4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- fg_corr=81.0f*fgsum-fsum*gsum;
- den=(81.0f*f2sum-fsum*fsum)*(81.0f*g2sum-gsum*gsum);
- if(den!=0.0)
- {
- if(fg_corr>=0.0) return(fg_corr*fg_corr/den);
- return(-fg_corr*fg_corr/den);
- }
- return(0.0);
-}
-
-inline float db_SignedSquareNormCorr11x11_u(unsigned char **f_img,unsigned char **g_img,int x_f,int y_f,int x_g,int y_g)
-{
- unsigned char *pf,*pg;
- float f,g,fgsum,f2sum,g2sum,fsum,gsum,fg_corr,den;
- int xm_f,xm_g;
-
- xm_f=x_f-5;
- xm_g=x_g-5;
- fgsum=0.0; f2sum=0.0; g2sum=0.0; fsum=0.0; gsum=0.0;
-
- pf=f_img[y_f-5]+xm_f; pg=g_img[y_g-5]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-4]+xm_f; pg=g_img[y_g-4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+4]+xm_f; pg=g_img[y_g+4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+5]+xm_f; pg=g_img[y_g+5]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- fg_corr=121.0f*fgsum-fsum*gsum;
- den=(121.0f*f2sum-fsum*fsum)*(121.0f*g2sum-gsum*gsum);
- if(den!=0.0)
- {
- if(fg_corr>=0.0) return(fg_corr*fg_corr/den);
- return(-fg_corr*fg_corr/den);
- }
- return(0.0);
-}
-
-inline void db_SignedSquareNormCorr11x11_Pre_u(unsigned char **f_img,int x_f,int y_f,float *sum,float *recip)
-{
- unsigned char *pf;
- float den;
- int f,f2sum,fsum;
- int xm_f;
-
- xm_f=x_f-5;
-
- pf=f_img[y_f-5]+xm_f;
- f= *pf++; f2sum=f*f; fsum=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f-4]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f-3]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f-2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f-1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+3]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+4]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+5]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- *sum= (float) fsum;
- den=(121.0f*f2sum-fsum*fsum);
- *recip=(float)(((den!=0.0)?1.0/den:0.0));
-}
-
-inline void db_SignedSquareNormCorr5x5_PreAlign_u(short *patch,const unsigned char * const *f_img,int x_f,int y_f,float *sum,float *recip)
-{
- float den;
- int f2sum,fsum;
- int xm_f=x_f-2;
-
-#ifndef DB_USE_SSE2
- const unsigned char *pf;
- short f;
-
- pf=f_img[y_f-2]+xm_f;
- f= *pf++; f2sum=f*f; fsum=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
- //int xwi;
- //int ywi;
- //f2sum=0;
- //fsum=0;
- //for (int r=-5;r<=5;r++){
- // ywi=y_f+r;
- // for (int c=-5;c<=5;c++){
- // xwi=x_f+c;
- // f=f_img[ywi][xwi];
- // f2sum+=f*f;
- // fsum+=f;
- // (*patch++)=f;
- // }
- //}
- (*patch++)=0; (*patch++)=0; (*patch++)=0; (*patch++)=0; (*patch++)=0;
- (*patch++)=0; (*patch++)=0;
-#endif /* DB_USE_SSE2 */
-
- *sum= (float) fsum;
- den=(25.0f*f2sum-fsum*fsum);
- *recip= (float)((den!=0.0)?1.0/den:0.0);
-}
-
-inline void db_SignedSquareNormCorr21x21_PreAlign_u(short *patch,const unsigned char * const *f_img,int x_f,int y_f,float *sum,float *recip)
-{
- float den;
- int f2sum,fsum;
- int xm_f=x_f-10;
- short f;
-
- int xwi;
- int ywi;
- f2sum=0;
- fsum=0;
- for (int r=-10;r<=10;r++){
- ywi=y_f+r;
- for (int c=-10;c<=10;c++){
- xwi=x_f+c;
- f=f_img[ywi][xwi];
- f2sum+=f*f;
- fsum+=f;
- (*patch++)=f;
- }
- }
-
- for(int i=442; i<512; i++)
- (*patch++)=0;
-
- *sum= (float) fsum;
- den=(441.0f*f2sum-fsum*fsum);
- *recip= (float)((den!=0.0)?1.0/den:0.0);
-
-
-}
-
-/* Lay out the image in the patch, computing norm and
-*/
-inline void db_SignedSquareNormCorr11x11_PreAlign_u(short *patch,const unsigned char * const *f_img,int x_f,int y_f,float *sum,float *recip)
-{
- float den;
- int f2sum,fsum;
- int xm_f=x_f-5;
-
-#ifndef DB_USE_SSE2
- const unsigned char *pf;
- short f;
-
- pf=f_img[y_f-5]+xm_f;
- f= *pf++; f2sum=f*f; fsum=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-4]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-3]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+3]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+4]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+5]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- //int xwi;
- //int ywi;
- //f2sum=0;
- //fsum=0;
- //for (int r=-5;r<=5;r++){
- // ywi=y_f+r;
- // for (int c=-5;c<=5;c++){
- // xwi=x_f+c;
- // f=f_img[ywi][xwi];
- // f2sum+=f*f;
- // fsum+=f;
- // (*patch++)=f;
- // }
- //}
-
- (*patch++)=0; (*patch++)=0; (*patch++)=0; (*patch++)=0; (*patch++)=0;
- (*patch++)=0; (*patch++)=0;
-#else
- const unsigned char *pf0 =f_img[y_f-5]+xm_f;
- const unsigned char *pf1 =f_img[y_f-4]+xm_f;
- const unsigned char *pf2 =f_img[y_f-3]+xm_f;
- const unsigned char *pf3 =f_img[y_f-2]+xm_f;
- const unsigned char *pf4 =f_img[y_f-1]+xm_f;
- const unsigned char *pf5 =f_img[y_f ]+xm_f;
- const unsigned char *pf6 =f_img[y_f+1]+xm_f;
- const unsigned char *pf7 =f_img[y_f+2]+xm_f;
- const unsigned char *pf8 =f_img[y_f+3]+xm_f;
- const unsigned char *pf9 =f_img[y_f+4]+xm_f;
- const unsigned char *pf10=f_img[y_f+5]+xm_f;
-
- /* pixel mask */
- const unsigned char pm[16] = {
- 0xFF,0xFF,
- 0xFF,0xFF,
- 0xFF,0xFF,
- 0,0,0,0,0,
- 0,0,0,0,0};
- const unsigned char * pm_p = pm;
-
- _asm
- {
- mov ecx,patch /* load patch pointer */
- mov ebx, pm_p /* load pixel mask pointer */
- movdqu xmm1,[ebx] /* load pixel mask */
-
- pxor xmm5,xmm5 /* set xmm5 to 0 accumulator for sum squares */
- pxor xmm4,xmm4 /* set xmm4 to 0 accumulator for sum */
- pxor xmm0,xmm0 /* set xmm0 to 0 */
-
- /* row 0 */
- mov eax,pf0 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqa [ecx+0*22],xmm7 /* move short values to patch */
- movdqa [ecx+0*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 1 */
- mov eax,pf1 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+1*22],xmm7 /* move short values to patch */
- movdqu [ecx+1*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 2 */
- mov eax,pf2 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+2*22],xmm7 /* move short values to patch */
- movdqu [ecx+2*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 3 */
- mov eax,pf3 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+3*22],xmm7 /* move short values to patch */
- movdqu [ecx+3*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 4 */
- mov eax,pf4 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+4*22],xmm7 /* move short values to patch */
- movdqu [ecx+4*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 5 */
- mov eax,pf5 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+5*22],xmm7 /* move short values to patch */
- movdqu [ecx+5*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 6 */
- mov eax,pf6 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+6*22],xmm7 /* move short values to patch */
- movdqu [ecx+6*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 7 */
- mov eax,pf7 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+7*22],xmm7 /* move short values to patch */
- movdqu [ecx+7*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 8 */
- mov eax,pf8 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqa [ecx+8*22],xmm7 /* move short values to patch */
- movdqa [ecx+8*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 9 */
- mov eax,pf9 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+9*22],xmm7 /* move short values to patch */
- movdqu [ecx+9*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit uints into 16 bit uints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* row 10 */
- mov eax,pf10 /* load image pointer */
- movdqu xmm7,[eax] /* load 16 pixels */
- movdqa xmm6,xmm7
-
- punpcklbw xmm7,xmm0 /* unpack low pixels (first 8)*/
- punpckhbw xmm6,xmm0 /* unpack high pixels (last 8)*/
-
- pand xmm6,xmm1 /* mask out pixels 12-16 */
-
- movdqu [ecx+10*22],xmm7 /* move short values to patch */
- movdqu [ecx+10*22+16],xmm6 /* move short values to patch */
-
- paddusw xmm4,xmm7 /* accumulate sums */
- pmaddwd xmm7,xmm7 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm7 /* accumulate sum squares */
-
- paddw xmm4,xmm6 /* accumulate sums */
- pmaddwd xmm6,xmm6 /* multiply 16 bit ints and add into 32 bit ints */
- paddd xmm5,xmm6 /* accumulate sum squares */
-
- /* add up the sum squares */
- movhlps xmm0,xmm5 /* high half to low half */
- paddd xmm5,xmm0 /* add high to low */
- pshuflw xmm0,xmm5, 0xE /* reshuffle */
- paddd xmm5,xmm0 /* add remaining */
- movd f2sum,xmm5
-
- /* add up the sum */
- movhlps xmm0,xmm4
- paddw xmm4,xmm0 /* halves added */
- pshuflw xmm0,xmm4,0xE
- paddw xmm4,xmm0 /* quarters added */
- pshuflw xmm0,xmm4,0x1
- paddw xmm4,xmm0 /* eighth added */
- movd fsum, xmm4
-
- emms
- }
-
- fsum = fsum & 0xFFFF;
-
- patch[126] = 0;
- patch[127] = 0;
-#endif /* DB_USE_SSE2 */
-
- *sum= (float) fsum;
- den=(121.0f*f2sum-fsum*fsum);
- *recip= (float)((den!=0.0)?1.0/den:0.0);
-}
-
-void AffineWarpPointOffset(float &r_w,float &c_w,double Hinv[9],int r,int c)
-{
- r_w=(float)(Hinv[3]*c+Hinv[4]*r);
- c_w=(float)(Hinv[0]*c+Hinv[1]*r);
-}
-
-
-
-/*!
-Prewarp the patches with given affine transform. For a given homogeneous point "x", "H*x" is
-the warped point and for any displacement "d" in the warped image resulting in point "y", the
-corresponding point in the original image is given by "Hinv*y", which can be simplified for affine H.
-If "affine" is 1, then nearest neighbor method is used, else if it is 2, then
-bilinear method is used.
- */
-inline void db_SignedSquareNormCorr11x11_PreAlign_AffinePatchWarp_u(short *patch,const unsigned char * const *f_img,
- int xi,int yi,float *sum,float *recip,
- const double Hinv[9],int affine)
-{
- float den;
- short f;
- int f2sum,fsum;
-
- f2sum=0;
- fsum=0;
-
- if (affine==1)
- {
- for (int r=0;r<11;r++){
- for (int c=0;c<11;c++){
- f=f_img[yi+AffineWarpPoint_NN_LUT_y[r][c]][xi+AffineWarpPoint_NN_LUT_x[r][c]];
- f2sum+=f*f;
- fsum+=f;
- (*patch++)=f;
- }
- }
- }
- else if (affine==2)
- {
- for (int r=0;r<11;r++){
- for (int c=0;c<11;c++){
- f=db_BilinearInterpolation(yi+AffineWarpPoint_BL_LUT_y[r][c]
- ,xi+AffineWarpPoint_BL_LUT_x[r][c],f_img);
- f2sum+=f*f;
- fsum+=f;
- (*patch++)=f;
- }
- }
- }
-
-
-
- (*patch++)=0; (*patch++)=0; (*patch++)=0; (*patch++)=0; (*patch++)=0;
- (*patch++)=0; (*patch++)=0;
-
- *sum= (float) fsum;
- den=(121.0f*f2sum-fsum*fsum);
- *recip= (float)((den!=0.0)?1.0/den:0.0);
-}
-
-
-inline float db_SignedSquareNormCorr11x11_Post_u(unsigned char **f_img,unsigned char **g_img,int x_f,int y_f,int x_g,int y_g,
- float fsum_gsum,float f_recip_g_recip)
-{
- unsigned char *pf,*pg;
- int fgsum;
- float fg_corr;
- int xm_f,xm_g;
-
- xm_f=x_f-5;
- xm_g=x_g-5;
-
- pf=f_img[y_f-5]+xm_f; pg=g_img[y_g-5]+xm_g;
- fgsum=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f-4]+xm_f; pg=g_img[y_g-4]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+4]+xm_f; pg=g_img[y_g+4]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+5]+xm_f; pg=g_img[y_g+5]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- fg_corr=121.0f*fgsum-fsum_gsum;
- if(fg_corr>=0.0) return(fg_corr*fg_corr*f_recip_g_recip);
- return(-fg_corr*fg_corr*f_recip_g_recip);
-}
-
-float db_SignedSquareNormCorr21x21Aligned_Post_s(const short *f_patch,const short *g_patch,float fsum_gsum,float f_recip_g_recip)
-{
- float fgsum,fg_corr;
-
- fgsum= (float) db_ScalarProduct512_s(f_patch,g_patch);
-
- fg_corr=441.0f*fgsum-fsum_gsum;
- if(fg_corr>=0.0) return(fg_corr*fg_corr*f_recip_g_recip);
- return(-fg_corr*fg_corr*f_recip_g_recip);
-}
-
-
-float db_SignedSquareNormCorr11x11Aligned_Post_s(const short *f_patch,const short *g_patch,float fsum_gsum,float f_recip_g_recip)
-{
- float fgsum,fg_corr;
-
- fgsum= (float) db_ScalarProduct128_s(f_patch,g_patch);
-
- fg_corr=121.0f*fgsum-fsum_gsum;
- if(fg_corr>=0.0) return(fg_corr*fg_corr*f_recip_g_recip);
- return(-fg_corr*fg_corr*f_recip_g_recip);
-}
-
-float db_SignedSquareNormCorr5x5Aligned_Post_s(const short *f_patch,const short *g_patch,float fsum_gsum,float f_recip_g_recip)
-{
- float fgsum,fg_corr;
-
- fgsum= (float) db_ScalarProduct32_s(f_patch,g_patch);
-
- fg_corr=25.0f*fgsum-fsum_gsum;
- if(fg_corr>=0.0) return(fg_corr*fg_corr*f_recip_g_recip);
- return(-fg_corr*fg_corr*f_recip_g_recip);
-}
-
-
-inline float db_SignedSquareNormCorr15x15_u(unsigned char **f_img,unsigned char **g_img,int x_f,int y_f,int x_g,int y_g)
-{
- unsigned char *pf,*pg;
- float f,g,fgsum,f2sum,g2sum,fsum,gsum,fg_corr,den;
- int xm_f,xm_g;
-
- xm_f=x_f-7;
- xm_g=x_g-7;
- fgsum=0.0; f2sum=0.0; g2sum=0.0; fsum=0.0; gsum=0.0;
-
- pf=f_img[y_f-7]+xm_f; pg=g_img[y_g-7]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-6]+xm_f; pg=g_img[y_g-6]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-5]+xm_f; pg=g_img[y_g-5]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-4]+xm_f; pg=g_img[y_g-4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+4]+xm_f; pg=g_img[y_g+4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+5]+xm_f; pg=g_img[y_g+5]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+6]+xm_f; pg=g_img[y_g+6]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+7]+xm_f; pg=g_img[y_g+7]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- fg_corr=225.0f*fgsum-fsum*gsum;
- den=(225.0f*f2sum-fsum*fsum)*(225.0f*g2sum-gsum*gsum);
- if(den!=0.0)
- {
- if(fg_corr>=0.0) return(fg_corr*fg_corr/den);
- return(-fg_corr*fg_corr/den);
- }
- return(0.0);
-}
-
-inline float db_SignedSquareNormCorr7x7_f(float **f_img,float **g_img,int x_f,int y_f,int x_g,int y_g)
-{
- float f,g,*pf,*pg,fgsum,f2sum,g2sum,fsum,gsum,fg_corr,den;
- int xm_f,xm_g;
-
- xm_f=x_f-3;
- xm_g=x_g-3;
- fgsum=0.0; f2sum=0.0; g2sum=0.0; fsum=0.0; gsum=0.0;
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- fg_corr=49.0f*fgsum-fsum*gsum;
- den=(49.0f*f2sum-fsum*fsum)*(49.0f*g2sum-gsum*gsum);
- if(den!=0.0)
- {
- if(fg_corr>=0.0) return(fg_corr*fg_corr/den);
- return(-fg_corr*fg_corr/den);
- }
- return(0.0);
-}
-
-inline float db_SignedSquareNormCorr9x9_f(float **f_img,float **g_img,int x_f,int y_f,int x_g,int y_g)
-{
- float f,g,*pf,*pg,fgsum,f2sum,g2sum,fsum,gsum,fg_corr,den;
- int xm_f,xm_g;
-
- xm_f=x_f-4;
- xm_g=x_g-4;
- fgsum=0.0; f2sum=0.0; g2sum=0.0; fsum=0.0; gsum=0.0;
-
- pf=f_img[y_f-4]+xm_f; pg=g_img[y_g-4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+4]+xm_f; pg=g_img[y_g+4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- fg_corr=81.0f*fgsum-fsum*gsum;
- den=(81.0f*f2sum-fsum*fsum)*(81.0f*g2sum-gsum*gsum);
- if(den!=0.0)
- {
- if(fg_corr>=0.0) return(fg_corr*fg_corr/den);
- return(-fg_corr*fg_corr/den);
- }
- return(0.0);
-}
-
-inline float db_SignedSquareNormCorr11x11_f(float **f_img,float **g_img,int x_f,int y_f,int x_g,int y_g)
-{
- float *pf,*pg;
- float f,g,fgsum,f2sum,g2sum,fsum,gsum,fg_corr,den;
- int xm_f,xm_g;
-
- xm_f=x_f-5;
- xm_g=x_g-5;
- fgsum=0.0; f2sum=0.0; g2sum=0.0; fsum=0.0; gsum=0.0;
-
- pf=f_img[y_f-5]+xm_f; pg=g_img[y_g-5]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-4]+xm_f; pg=g_img[y_g-4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+4]+xm_f; pg=g_img[y_g+4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+5]+xm_f; pg=g_img[y_g+5]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- fg_corr=121.0f*fgsum-fsum*gsum;
- den=(121.0f*f2sum-fsum*fsum)*(121.0f*g2sum-gsum*gsum);
- if(den!=0.0)
- {
- if(fg_corr>=0.0) return(fg_corr*fg_corr/den);
- return(-fg_corr*fg_corr/den);
- }
- return(0.0);
-}
-
-inline void db_SignedSquareNormCorr11x11_Pre_f(float **f_img,int x_f,int y_f,float *sum,float *recip)
-{
- float *pf,den;
- float f,f2sum,fsum;
- int xm_f;
-
- xm_f=x_f-5;
-
- pf=f_img[y_f-5]+xm_f;
- f= *pf++; f2sum=f*f; fsum=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f-4]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f-3]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f-2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f-1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+3]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+4]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- pf=f_img[y_f+5]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf++; f2sum+=f*f; fsum+=f;
- f= *pf; f2sum+=f*f; fsum+=f;
-
- *sum=fsum;
- den=(121.0f*f2sum-fsum*fsum);
- *recip= (float) ((den!=0.0)?1.0/den:0.0);
-}
-
-inline void db_SignedSquareNormCorr11x11_PreAlign_f(float *patch,const float * const *f_img,int x_f,int y_f,float *sum,float *recip)
-{
- const float *pf;
- float den,f,f2sum,fsum;
- int xm_f;
-
- xm_f=x_f-5;
-
- pf=f_img[y_f-5]+xm_f;
- f= *pf++; f2sum=f*f; fsum=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-4]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-3]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f-1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+1]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+2]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+3]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+4]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- pf=f_img[y_f+5]+xm_f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf++; f2sum+=f*f; fsum+=f; (*patch++)=f;
- f= *pf; f2sum+=f*f; fsum+=f; (*patch++)=f;
-
- (*patch++)=0.0; (*patch++)=0.0; (*patch++)=0.0; (*patch++)=0.0; (*patch++)=0.0;
- (*patch++)=0.0; (*patch++)=0.0;
-
- *sum=fsum;
- den=(121.0f*f2sum-fsum*fsum);
- *recip= (float) ((den!=0.0)?1.0/den:0.0);
-}
-
-inline float db_SignedSquareNormCorr11x11_Post_f(float **f_img,float **g_img,int x_f,int y_f,int x_g,int y_g,
- float fsum_gsum,float f_recip_g_recip)
-{
- float *pf,*pg;
- float fgsum,fg_corr;
- int xm_f,xm_g;
-
- xm_f=x_f-5;
- xm_g=x_g-5;
-
- pf=f_img[y_f-5]+xm_f; pg=g_img[y_g-5]+xm_g;
- fgsum=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f-4]+xm_f; pg=g_img[y_g-4]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+4]+xm_f; pg=g_img[y_g+4]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- pf=f_img[y_f+5]+xm_f; pg=g_img[y_g+5]+xm_g;
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++); fgsum+=(*pf++)*(*pg++);
- fgsum+=(*pf++)*(*pg++); fgsum+=(*pf)*(*pg);
-
- fg_corr=121.0f*fgsum-fsum_gsum;
- if(fg_corr>=0.0) return(fg_corr*fg_corr*f_recip_g_recip);
- return(-fg_corr*fg_corr*f_recip_g_recip);
-}
-
-inline float db_SignedSquareNormCorr11x11Aligned_Post_f(const float *f_patch,const float *g_patch,float fsum_gsum,float f_recip_g_recip)
-{
- float fgsum,fg_corr;
-
- fgsum=db_ScalarProduct128Aligned16_f(f_patch,g_patch);
-
- fg_corr=121.0f*fgsum-fsum_gsum;
- if(fg_corr>=0.0) return(fg_corr*fg_corr*f_recip_g_recip);
- return(-fg_corr*fg_corr*f_recip_g_recip);
-}
-
-inline float db_SignedSquareNormCorr15x15_f(float **f_img,float **g_img,int x_f,int y_f,int x_g,int y_g)
-{
- float *pf,*pg;
- float f,g,fgsum,f2sum,g2sum,fsum,gsum,fg_corr,den;
- int xm_f,xm_g;
-
- xm_f=x_f-7;
- xm_g=x_g-7;
- fgsum=0.0; f2sum=0.0; g2sum=0.0; fsum=0.0; gsum=0.0;
-
- pf=f_img[y_f-7]+xm_f; pg=g_img[y_g-7]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-6]+xm_f; pg=g_img[y_g-6]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-5]+xm_f; pg=g_img[y_g-5]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-4]+xm_f; pg=g_img[y_g-4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-3]+xm_f; pg=g_img[y_g-3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-2]+xm_f; pg=g_img[y_g-2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f-1]+xm_f; pg=g_img[y_g-1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f]+xm_f; pg=g_img[y_g]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+1]+xm_f; pg=g_img[y_g+1]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+2]+xm_f; pg=g_img[y_g+2]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+3]+xm_f; pg=g_img[y_g+3]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+4]+xm_f; pg=g_img[y_g+4]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+5]+xm_f; pg=g_img[y_g+5]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+6]+xm_f; pg=g_img[y_g+6]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- pf=f_img[y_f+7]+xm_f; pg=g_img[y_g+7]+xm_g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf++; g= *pg++; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
- f= *pf; g= *pg; fgsum+=f*g; f2sum+=f*f; g2sum+=g*g; fsum+=f; gsum+=g;
-
- fg_corr=225.0f*fgsum-fsum*gsum;
- den=(225.0f*f2sum-fsum*fsum)*(225.0f*g2sum-gsum*gsum);
- if(den!=0.0)
- {
- if(fg_corr>=0.0) return(fg_corr*fg_corr/den);
- return(-fg_corr*fg_corr/den);
- }
- return(0.0);
-}
-
-db_Bucket_f** db_AllocBuckets_f(int nr_h,int nr_v,int bd)
-{
- int i,j;
- db_Bucket_f **bp,*b;
-
- b=new db_Bucket_f [(nr_h+2)*(nr_v+2)];
- bp=new db_Bucket_f* [(nr_v+2)];
- bp=bp+1;
- for(i= -1;i<=nr_v;i++)
- {
- bp[i]=b+1+(nr_h+2)*(i+1);
- for(j= -1;j<=nr_h;j++)
- {
- bp[i][j].ptr=new db_PointInfo_f [bd];
- }
- }
-
- return(bp);
-}
-
-db_Bucket_u** db_AllocBuckets_u(int nr_h,int nr_v,int bd)
-{
- int i,j;
- db_Bucket_u **bp,*b;
-
- b=new db_Bucket_u [(nr_h+2)*(nr_v+2)];
- bp=new db_Bucket_u* [(nr_v+2)];
- bp=bp+1;
- for(i= -1;i<=nr_v;i++)
- {
- bp[i]=b+1+(nr_h+2)*(i+1);
- for(j= -1;j<=nr_h;j++)
- {
- bp[i][j].ptr=new db_PointInfo_u [bd];
- }
- }
-
- return(bp);
-}
-
-void db_FreeBuckets_f(db_Bucket_f **bp,int nr_h,int nr_v)
-{
- int i,j;
-
- for(i= -1;i<=nr_v;i++) for(j= -1;j<=nr_h;j++)
- {
- delete [] bp[i][j].ptr;
- }
- delete [] (bp[-1]-1);
- delete [] (bp-1);
-}
-
-void db_FreeBuckets_u(db_Bucket_u **bp,int nr_h,int nr_v)
-{
- int i,j;
-
- for(i= -1;i<=nr_v;i++) for(j= -1;j<=nr_h;j++)
- {
- delete [] bp[i][j].ptr;
- }
- delete [] (bp[-1]-1);
- delete [] (bp-1);
-}
-
-void db_EmptyBuckets_f(db_Bucket_f **bp,int nr_h,int nr_v)
-{
- int i,j;
- for(i= -1;i<=nr_v;i++) for(j= -1;j<=nr_h;j++) bp[i][j].nr=0;
-}
-
-void db_EmptyBuckets_u(db_Bucket_u **bp,int nr_h,int nr_v)
-{
- int i,j;
- for(i= -1;i<=nr_v;i++) for(j= -1;j<=nr_h;j++) bp[i][j].nr=0;
-}
-
-float* db_FillBuckets_f(float *patch_space,const float * const *f_img,db_Bucket_f **bp,int bw,int bh,int nr_h,int nr_v,int bd,const double *x,const double *y,int nr_corners)
-{
- int i,xi,yi,xpos,ypos,nr;
- db_Bucket_f *br;
- db_PointInfo_f *pir;
-
- db_EmptyBuckets_f(bp,nr_h,nr_v);
- for(i=0;i<nr_corners;i++)
- {
- xi=(int) x[i];
- yi=(int) y[i];
- xpos=xi/bw;
- ypos=yi/bh;
- if(xpos>=0 && xpos<nr_h && ypos>=0 && ypos<nr_v)
- {
- br=&bp[ypos][xpos];
- nr=br->nr;
- if(nr<bd)
- {
- pir=&(br->ptr[nr]);
- pir->x=xi;
- pir->y=yi;
- pir->id=i;
- pir->pir=0;
- pir->patch=patch_space;
- br->nr=nr+1;
-
- db_SignedSquareNormCorr11x11_PreAlign_f(patch_space,f_img,xi,yi,&(pir->sum),&(pir->recip));
- patch_space+=128;
- }
- }
- }
- return(patch_space);
-}
-
-short* db_FillBuckets_u(short *patch_space,const unsigned char * const *f_img,db_Bucket_u **bp,int bw,int bh,int nr_h,int nr_v,int bd,const double *x,const double *y,int nr_corners,int use_smaller_matching_window, int use_21)
-{
- int i,xi,yi,xpos,ypos,nr;
- db_Bucket_u *br;
- db_PointInfo_u *pir;
-
- db_EmptyBuckets_u(bp,nr_h,nr_v);
- for(i=0;i<nr_corners;i++)
- {
- xi=(int)db_roundi(x[i]);
- yi=(int)db_roundi(y[i]);
- xpos=xi/bw;
- ypos=yi/bh;
- if(xpos>=0 && xpos<nr_h && ypos>=0 && ypos<nr_v)
- {
- br=&bp[ypos][xpos];
- nr=br->nr;
- if(nr<bd)
- {
- pir=&(br->ptr[nr]);
- pir->x=xi;
- pir->y=yi;
- pir->id=i;
- pir->pir=0;
- pir->patch=patch_space;
- br->nr=nr+1;
-
- if(use_21)
- {
- db_SignedSquareNormCorr21x21_PreAlign_u(patch_space,f_img,xi,yi,&(pir->sum),&(pir->recip));
- patch_space+=512;
- }
- else
- {
- if(!use_smaller_matching_window)
- {
- db_SignedSquareNormCorr11x11_PreAlign_u(patch_space,f_img,xi,yi,&(pir->sum),&(pir->recip));
- patch_space+=128;
- }
- else
- {
- db_SignedSquareNormCorr5x5_PreAlign_u(patch_space,f_img,xi,yi,&(pir->sum),&(pir->recip));
- patch_space+=32;
- }
- }
- }
- }
- }
- return(patch_space);
-}
-
-
-
-float* db_FillBucketsPrewarped_f(float *patch_space,const float *const *f_img,db_Bucket_f **bp,int bw,int bh,int nr_h,int nr_v,int bd,const double *x,const double *y,int nr_corners,const double H[9])
-{
- int i,xi,yi,xpos,ypos,nr,wxi,wyi;
- db_Bucket_f *br;
- db_PointInfo_f *pir;
- double xd[2],wx[2];
-
- db_EmptyBuckets_f(bp,nr_h,nr_v);
- for(i=0;i<nr_corners;i++)
- {
- xd[0]=x[i];
- xd[1]=y[i];
- xi=(int) xd[0];
- yi=(int) xd[1];
- db_ImageHomographyInhomogenous(wx,H,xd);
- wxi=(int) wx[0];
- wyi=(int) wx[1];
-
- xpos=((wxi+bw)/bw)-1;
- ypos=((wyi+bh)/bh)-1;
- if(xpos>= -1 && xpos<=nr_h && ypos>= -1 && ypos<=nr_v)
- {
- br=&bp[ypos][xpos];
- nr=br->nr;
- if(nr<bd)
- {
- pir=&(br->ptr[nr]);
- pir->x=wxi;
- pir->y=wyi;
- pir->id=i;
- pir->pir=0;
- pir->patch=patch_space;
- br->nr=nr+1;
-
- db_SignedSquareNormCorr11x11_PreAlign_f(patch_space,f_img,xi,yi,&(pir->sum),&(pir->recip));
- patch_space+=128;
- }
- }
- }
- return(patch_space);
-}
-
-short* db_FillBucketsPrewarped_u(short *patch_space,const unsigned char * const *f_img,db_Bucket_u **bp,
- int bw,int bh,int nr_h,int nr_v,int bd,const double *x,const double *y,
- int nr_corners,const double H[9])
-{
- int i,xi,yi,xpos,ypos,nr,wxi,wyi;
- db_Bucket_u *br;
- db_PointInfo_u *pir;
- double xd[2],wx[2];
-
- db_EmptyBuckets_u(bp,nr_h,nr_v);
- for(i=0;i<nr_corners;i++)
- {
- xd[0]=x[i];
- xd[1]=y[i];
- xi=(int) db_roundi(xd[0]);
- yi=(int) db_roundi(xd[1]);
- db_ImageHomographyInhomogenous(wx,H,xd);
- wxi=(int) wx[0];
- wyi=(int) wx[1];
-
- xpos=((wxi+bw)/bw)-1;
- ypos=((wyi+bh)/bh)-1;
- if(xpos>= -1 && xpos<=nr_h && ypos>= -1 && ypos<=nr_v)
- {
- br=&bp[ypos][xpos];
- nr=br->nr;
- if(nr<bd)
- {
- pir=&(br->ptr[nr]);
- pir->x=wxi;
- pir->y=wyi;
- pir->id=i;
- pir->pir=0;
- pir->patch=patch_space;
- br->nr=nr+1;
-
- db_SignedSquareNormCorr11x11_PreAlign_u(patch_space,f_img,xi,yi,&(pir->sum),&(pir->recip));
- patch_space+=128;
- }
- }
- }
- return(patch_space);
-}
-
-
-
-short* db_FillBucketsPrewarpedAffine_u(short *patch_space,const unsigned char * const *f_img,db_Bucket_u **bp,
- int bw,int bh,int nr_h,int nr_v,int bd,const double *x,const double *y,
- int nr_corners,const double H[9],const double Hinv[9],const int warpboundsp[4],
- int affine)
-{
- int i,xi,yi,xpos,ypos,nr,wxi,wyi;
- db_Bucket_u *br;
- db_PointInfo_u *pir;
- double xd[2],wx[2];
-
- db_EmptyBuckets_u(bp,nr_h,nr_v);
- for(i=0;i<nr_corners;i++)
- {
- xd[0]=x[i];
- xd[1]=y[i];
- xi=(int) db_roundi(xd[0]);
- yi=(int) db_roundi(xd[1]);
- db_ImageHomographyInhomogenous(wx,H,xd);
- wxi=(int) wx[0];
- wyi=(int) wx[1];
-
- xpos=((wxi+bw)/bw)-1;
- ypos=((wyi+bh)/bh)-1;
-
-
- if (xpos>= -1 && xpos<=nr_h && ypos>= -1 && ypos<=nr_v)
- {
- if( xi>warpboundsp[0] && xi<warpboundsp[1] && yi>warpboundsp[2] && yi<warpboundsp[3])
- {
-
- br=&bp[ypos][xpos];
- nr=br->nr;
- if(nr<bd)
- {
- pir=&(br->ptr[nr]);
- pir->x=wxi;
- pir->y=wyi;
- pir->id=i;
- pir->pir=0;
- pir->patch=patch_space;
- br->nr=nr+1;
-
- db_SignedSquareNormCorr11x11_PreAlign_AffinePatchWarp_u(patch_space,f_img,xi,yi,&(pir->sum),&(pir->recip),Hinv,affine);
- patch_space+=128;
- }
- }
- }
- }
- return(patch_space);
-}
-
-
-
-inline void db_MatchPointPair_f(db_PointInfo_f *pir_l,db_PointInfo_f *pir_r,
- unsigned long kA,unsigned long kB)
-{
- int x_l,y_l,x_r,y_r,xm,ym;
- double score;
-
- x_l=pir_l->x;
- y_l=pir_l->y;
- x_r=pir_r->x;
- y_r=pir_r->y;
- xm=x_l-x_r;
- ym=y_l-y_r;
- /*Check if disparity is within the maximum disparity
- with the formula xm^2*256+ym^2*kA<kB
- where kA=256*w^2/h^2
- and kB=256*max_disp^2*w^2*/
- if(((xm*xm)<<8)+ym*ym*kA<kB)
- {
- /*Correlate*/
- score=db_SignedSquareNormCorr11x11Aligned_Post_f(pir_l->patch,pir_r->patch,
- (pir_l->sum)*(pir_r->sum),
- (pir_l->recip)*(pir_r->recip));
-
- if((!(pir_l->pir)) || (score>pir_l->s))
- {
- /*Update left corner*/
- pir_l->s=score;
- pir_l->pir=pir_r;
- }
- if((!(pir_r->pir)) || (score>pir_r->s))
- {
- /*Update right corner*/
- pir_r->s=score;
- pir_r->pir=pir_l;
- }
- }
-}
-
-inline void db_MatchPointPair_u(db_PointInfo_u *pir_l,db_PointInfo_u *pir_r,
- unsigned long kA,unsigned long kB, unsigned int rect_window,bool use_smaller_matching_window, int use_21)
-{
- int xm,ym;
- double score;
- bool compute_score;
-
-
- if( rect_window )
- compute_score = ((unsigned)db_absi(pir_l->x - pir_r->x)<kA && (unsigned)db_absi(pir_l->y - pir_r->y)<kB);
- else
- { /*Check if disparity is within the maximum disparity
- with the formula xm^2*256+ym^2*kA<kB
- where kA=256*w^2/h^2
- and kB=256*max_disp^2*w^2*/
- xm= pir_l->x - pir_r->x;
- ym= pir_l->y - pir_r->y;
- compute_score = ((xm*xm)<<8)+ym*ym*kA < kB;
- }
-
- if ( compute_score )
- {
- if(use_21)
- {
- score=db_SignedSquareNormCorr21x21Aligned_Post_s(pir_l->patch,pir_r->patch,
- (pir_l->sum)*(pir_r->sum),
- (pir_l->recip)*(pir_r->recip));
- }
- else
- {
- /*Correlate*/
- if(!use_smaller_matching_window)
- {
- score=db_SignedSquareNormCorr11x11Aligned_Post_s(pir_l->patch,pir_r->patch,
- (pir_l->sum)*(pir_r->sum),
- (pir_l->recip)*(pir_r->recip));
- }
- else
- {
- score=db_SignedSquareNormCorr5x5Aligned_Post_s(pir_l->patch,pir_r->patch,
- (pir_l->sum)*(pir_r->sum),
- (pir_l->recip)*(pir_r->recip));
- }
- }
-
- if((!(pir_l->pir)) || (score>pir_l->s))
- {
- /*Update left corner*/
- pir_l->s=score;
- pir_l->pir=pir_r;
- }
- if((!(pir_r->pir)) || (score>pir_r->s))
- {
- /*Update right corner*/
- pir_r->s=score;
- pir_r->pir=pir_l;
- }
- }
-}
-
-inline void db_MatchPointAgainstBucket_f(db_PointInfo_f *pir_l,db_Bucket_f *b_r,
- unsigned long kA,unsigned long kB)
-{
- int p_r,nr;
- db_PointInfo_f *pir_r;
-
- nr=b_r->nr;
- pir_r=b_r->ptr;
- for(p_r=0;p_r<nr;p_r++) db_MatchPointPair_f(pir_l,pir_r+p_r,kA,kB);
-}
-
-inline void db_MatchPointAgainstBucket_u(db_PointInfo_u *pir_l,db_Bucket_u *b_r,
- unsigned long kA,unsigned long kB,int rect_window, bool use_smaller_matching_window, int use_21)
-{
- int p_r,nr;
- db_PointInfo_u *pir_r;
-
- nr=b_r->nr;
- pir_r=b_r->ptr;
-
- for(p_r=0;p_r<nr;p_r++) db_MatchPointPair_u(pir_l,pir_r+p_r,kA,kB, rect_window, use_smaller_matching_window, use_21);
-
-}
-
-void db_MatchBuckets_f(db_Bucket_f **bp_l,db_Bucket_f **bp_r,int nr_h,int nr_v,
- unsigned long kA,unsigned long kB)
-{
- int i,j,k,a,b,br_nr;
- db_Bucket_f *br;
- db_PointInfo_f *pir_l;
-
- /*For all buckets*/
- for(i=0;i<nr_v;i++) for(j=0;j<nr_h;j++)
- {
- br=&bp_l[i][j];
- br_nr=br->nr;
- /*For all points in bucket*/
- for(k=0;k<br_nr;k++)
- {
- pir_l=br->ptr+k;
- for(a=i-1;a<=i+1;a++)
- {
- for(b=j-1;b<=j+1;b++)
- {
- db_MatchPointAgainstBucket_f(pir_l,&bp_r[a][b],kA,kB);
- }
- }
- }
- }
-}
-
-void db_MatchBuckets_u(db_Bucket_u **bp_l,db_Bucket_u **bp_r,int nr_h,int nr_v,
- unsigned long kA,unsigned long kB,int rect_window,bool use_smaller_matching_window, int use_21)
-{
- int i,j,k,a,b,br_nr;
- db_Bucket_u *br;
- db_PointInfo_u *pir_l;
-
- /*For all buckets*/
- for(i=0;i<nr_v;i++) for(j=0;j<nr_h;j++)
- {
- br=&bp_l[i][j];
- br_nr=br->nr;
- /*For all points in bucket*/
- for(k=0;k<br_nr;k++)
- {
- pir_l=br->ptr+k;
- for(a=i-1;a<=i+1;a++)
- {
- for(b=j-1;b<=j+1;b++)
- {
- db_MatchPointAgainstBucket_u(pir_l,&bp_r[a][b],kA,kB,rect_window,use_smaller_matching_window, use_21);
- }
- }
- }
- }
-}
-
-void db_CollectMatches_f(db_Bucket_f **bp_l,int nr_h,int nr_v,unsigned long target,int *id_l,int *id_r,int *nr_matches)
-{
- int i,j,k,br_nr;
- unsigned long count;
- db_Bucket_f *br;
- db_PointInfo_f *pir,*pir2;
-
- count=0;
- /*For all buckets*/
- for(i=0;i<nr_v;i++) for(j=0;j<nr_h;j++)
- {
- br=&bp_l[i][j];
- br_nr=br->nr;
- /*For all points in bucket*/
- for(k=0;k<br_nr;k++)
- {
- pir=br->ptr+k;
- pir2=pir->pir;
- if(pir2)
- {
- /*This point has a best match*/
- if((pir2->pir)==pir)
- {
- /*We have a mutually consistent match*/
- if(count<target)
- {
- id_l[count]=pir->id;
- id_r[count]=pir2->id;
- count++;
- }
- }
- }
- }
- }
- *nr_matches=count;
-}
-
-void db_CollectMatches_u(db_Bucket_u **bp_l,int nr_h,int nr_v,unsigned long target,int *id_l,int *id_r,int *nr_matches)
-{
- int i,j,k,br_nr;
- unsigned long count;
- db_Bucket_u *br;
- db_PointInfo_u *pir,*pir2;
-
- count=0;
- /*For all buckets*/
- for(i=0;i<nr_v;i++) for(j=0;j<nr_h;j++)
- {
- br=&bp_l[i][j];
- br_nr=br->nr;
- /*For all points in bucket*/
- for(k=0;k<br_nr;k++)
- {
- pir=br->ptr+k;
- pir2=pir->pir;
- if(pir2)
- {
- /*This point has a best match*/
- if((pir2->pir)==pir)
- {
- /*We have a mutually consistent match*/
- if(count<target)
- {
- id_l[count]=pir->id;
- id_r[count]=pir2->id;
- count++;
- }
- }
- }
- }
- }
- *nr_matches=count;
-}
-
-db_Matcher_f::db_Matcher_f()
-{
- m_w=0; m_h=0;
-}
-
-db_Matcher_f::~db_Matcher_f()
-{
- Clean();
-}
-
-void db_Matcher_f::Clean()
-{
- if(m_w)
- {
- /*Free buckets*/
- db_FreeBuckets_f(m_bp_l,m_nr_h,m_nr_v);
- db_FreeBuckets_f(m_bp_r,m_nr_h,m_nr_v);
- /*Free space for patch layouts*/
- delete [] m_patch_space;
- }
- m_w=0; m_h=0;
-}
-
-unsigned long db_Matcher_f::Init(int im_width,int im_height,double max_disparity,int target_nr_corners)
-{
- Clean();
- m_w=im_width;
- m_h=im_height;
- m_bw=db_maxi(1,(int) (max_disparity*((double)im_width)));
- m_bh=db_maxi(1,(int) (max_disparity*((double)im_height)));
- m_nr_h=1+(im_width-1)/m_bw;
- m_nr_v=1+(im_height-1)/m_bh;
- m_bd=db_maxi(1,(int)(((double)target_nr_corners)*
- max_disparity*max_disparity));
- m_target=target_nr_corners;
- m_kA=(long)(256.0*((double)(m_w*m_w))/((double)(m_h*m_h)));
- m_kB=(long)(256.0*max_disparity*max_disparity*((double)(m_w*m_w)));
-
- /*Alloc bucket structure*/
- m_bp_l=db_AllocBuckets_f(m_nr_h,m_nr_v,m_bd);
- m_bp_r=db_AllocBuckets_f(m_nr_h,m_nr_v,m_bd);
-
- /*Alloc 16byte-aligned space for patch layouts*/
- m_patch_space=new float [2*(m_nr_h+2)*(m_nr_v+2)*m_bd*128+16];
- m_aligned_patch_space=db_AlignPointer_f(m_patch_space,16);
-
- return(m_target);
-}
-
-void db_Matcher_f::Match(const float * const *l_img,const float * const *r_img,
- const double *x_l,const double *y_l,int nr_l,const double *x_r,const double *y_r,int nr_r,
- int *id_l,int *id_r,int *nr_matches,const double H[9])
-{
- float *ps;
-
- /*Insert the corners into bucket structure*/
- ps=db_FillBuckets_f(m_aligned_patch_space,l_img,m_bp_l,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,x_l,y_l,nr_l);
- if(H==0) db_FillBuckets_f(ps,r_img,m_bp_r,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,x_r,y_r,nr_r);
- else db_FillBucketsPrewarped_f(ps,r_img,m_bp_r,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,x_r,y_r,nr_r,H);
-
- /*Compute all the necessary match scores*/
- db_MatchBuckets_f(m_bp_l,m_bp_r,m_nr_h,m_nr_v,m_kA,m_kB);
-
- /*Collect the correspondences*/
- db_CollectMatches_f(m_bp_l,m_nr_h,m_nr_v,m_target,id_l,id_r,nr_matches);
-}
-
-db_Matcher_u::db_Matcher_u()
-{
- m_w=0; m_h=0;
- m_rect_window = 0;
- m_bw=m_bh=m_nr_h=m_nr_v=m_bd=m_target=0;
- m_bp_l=m_bp_r=0;
- m_patch_space=m_aligned_patch_space=0;
-}
-
-db_Matcher_u::db_Matcher_u(const db_Matcher_u& cm)
-{
- Init(cm.m_w, cm.m_h, cm.m_max_disparity, cm.m_target, cm.m_max_disparity_v);
-}
-
-db_Matcher_u& db_Matcher_u::operator= (const db_Matcher_u& cm)
-{
- if ( this == &cm ) return *this;
- Init(cm.m_w, cm.m_h, cm.m_max_disparity, cm.m_target, cm.m_max_disparity_v);
- return *this;
-}
-
-
-db_Matcher_u::~db_Matcher_u()
-{
- Clean();
-}
-
-void db_Matcher_u::Clean()
-{
- if(m_w)
- {
- /*Free buckets*/
- db_FreeBuckets_u(m_bp_l,m_nr_h,m_nr_v);
- db_FreeBuckets_u(m_bp_r,m_nr_h,m_nr_v);
- /*Free space for patch layouts*/
- delete [] m_patch_space;
- }
- m_w=0; m_h=0;
-}
-
-
-unsigned long db_Matcher_u::Init(int im_width,int im_height,double max_disparity,int target_nr_corners,
- double max_disparity_v, bool use_smaller_matching_window, int use_21)
-{
- Clean();
- m_w=im_width;
- m_h=im_height;
- m_max_disparity=max_disparity;
- m_max_disparity_v=max_disparity_v;
-
- if ( max_disparity_v != DB_DEFAULT_NO_DISPARITY )
- {
- m_rect_window = 1;
-
- m_bw=db_maxi(1,(int)(max_disparity*((double)im_width)));
- m_bh=db_maxi(1,(int)(max_disparity_v*((double)im_height)));
-
- m_bd=db_maxi(1,(int)(((double)target_nr_corners)*max_disparity*max_disparity_v));
-
- m_kA=(int)(max_disparity*m_w);
- m_kB=(int)(max_disparity_v*m_h);
-
- } else
- {
- m_bw=(int)db_maxi(1,(int)(max_disparity*((double)im_width)));
- m_bh=(int)db_maxi(1,(int)(max_disparity*((double)im_height)));
-
- m_bd=db_maxi(1,(int)(((double)target_nr_corners)*max_disparity*max_disparity));
-
- m_kA=(long)(256.0*((double)(m_w*m_w))/((double)(m_h*m_h)));
- m_kB=(long)(256.0*max_disparity*max_disparity*((double)(m_w*m_w)));
- }
-
- m_nr_h=1+(im_width-1)/m_bw;
- m_nr_v=1+(im_height-1)/m_bh;
-
- m_target=target_nr_corners;
-
- /*Alloc bucket structure*/
- m_bp_l=db_AllocBuckets_u(m_nr_h,m_nr_v,m_bd);
- m_bp_r=db_AllocBuckets_u(m_nr_h,m_nr_v,m_bd);
-
- m_use_smaller_matching_window = use_smaller_matching_window;
- m_use_21 = use_21;
-
- if(m_use_21)
- {
- /*Alloc 64byte-aligned space for patch layouts*/
- m_patch_space=new short [2*(m_nr_h+2)*(m_nr_v+2)*m_bd*512+64];
- m_aligned_patch_space=db_AlignPointer_s(m_patch_space,64);
- }
- else
- {
- if(!m_use_smaller_matching_window)
- {
- /*Alloc 16byte-aligned space for patch layouts*/
- m_patch_space=new short [2*(m_nr_h+2)*(m_nr_v+2)*m_bd*128+16];
- m_aligned_patch_space=db_AlignPointer_s(m_patch_space,16);
- }
- else
- {
- /*Alloc 4byte-aligned space for patch layouts*/
- m_patch_space=new short [2*(m_nr_h+2)*(m_nr_v+2)*m_bd*32+4];
- m_aligned_patch_space=db_AlignPointer_s(m_patch_space,4);
- }
- }
-
- return(m_target);
-}
-
-void db_Matcher_u::Match(const unsigned char * const *l_img,const unsigned char * const *r_img,
- const double *x_l,const double *y_l,int nr_l,const double *x_r,const double *y_r,int nr_r,
- int *id_l,int *id_r,int *nr_matches,const double H[9],int affine)
-{
- short *ps;
-
- /*Insert the corners into bucket structure*/
- ps=db_FillBuckets_u(m_aligned_patch_space,l_img,m_bp_l,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,x_l,y_l,nr_l,m_use_smaller_matching_window,m_use_21);
- if(H==0)
- db_FillBuckets_u(ps,r_img,m_bp_r,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,x_r,y_r,nr_r,m_use_smaller_matching_window,m_use_21);
- else
- {
- if (affine)
- {
- double Hinv[9];
- db_InvertAffineTransform(Hinv,H);
- float r_w, c_w;
- float stretch_x[2];
- float stretch_y[2];
- AffineWarpPointOffset(r_w,c_w,Hinv, 5,5);
- stretch_x[0]=db_absf(c_w);stretch_y[0]=db_absf(r_w);
- AffineWarpPointOffset(r_w,c_w,Hinv, 5,-5);
- stretch_x[1]=db_absf(c_w);stretch_y[1]=db_absf(r_w);
- int max_stretxh_x=(int) (db_maxd(stretch_x[0],stretch_x[1]));
- int max_stretxh_y=(int) (db_maxd(stretch_y[0],stretch_y[1]));
- int warpbounds[4]={max_stretxh_x,m_w-1-max_stretxh_x,max_stretxh_y,m_h-1-max_stretxh_y};
-
- for (int r=-5;r<=5;r++){
- for (int c=-5;c<=5;c++){
- AffineWarpPointOffset(r_w,c_w,Hinv,r,c);
- AffineWarpPoint_BL_LUT_y[r+5][c+5]=r_w;
- AffineWarpPoint_BL_LUT_x[r+5][c+5]=c_w;
-
- AffineWarpPoint_NN_LUT_y[r+5][c+5]=db_roundi(r_w);
- AffineWarpPoint_NN_LUT_x[r+5][c+5]=db_roundi(c_w);
-
- }
- }
-
- db_FillBucketsPrewarpedAffine_u(ps,r_img,m_bp_r,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,
- x_r,y_r,nr_r,H,Hinv,warpbounds,affine);
- }
- else
- db_FillBucketsPrewarped_u(ps,r_img,m_bp_r,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,x_r,y_r,nr_r,H);
- }
-
-
- /*Compute all the necessary match scores*/
- db_MatchBuckets_u(m_bp_l,m_bp_r,m_nr_h,m_nr_v,m_kA,m_kB, m_rect_window,m_use_smaller_matching_window,m_use_21);
-
- /*Collect the correspondences*/
- db_CollectMatches_u(m_bp_l,m_nr_h,m_nr_v,m_target,id_l,id_r,nr_matches);
-}
-
-int db_Matcher_u::IsAllocated()
-{
- return (int)(m_w != 0);
-}
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_feature_matching.h b/jni_mosaic/feature_stab/db_vlvm/db_feature_matching.h
deleted file mode 100644
index 6c056b9..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_feature_matching.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/*$Id: db_feature_matching.h,v 1.3 2011/06/17 14:03:30 mbansal Exp $*/
-
-#ifndef DB_FEATURE_MATCHING_H
-#define DB_FEATURE_MATCHING_H
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup FeatureMatching Feature Matching
- */
-#include "db_utilities.h"
-#include "db_utilities_constants.h"
-
-DB_API void db_SignedSquareNormCorr21x21_PreAlign_u(short *patch,const unsigned char * const *f_img,int x_f,int y_f,float *sum,float *recip);
-DB_API void db_SignedSquareNormCorr11x11_PreAlign_u(short *patch,const unsigned char * const *f_img,int x_f,int y_f,float *sum,float *recip);
-float db_SignedSquareNormCorr21x21Aligned_Post_s(const short *f_patch,const short *g_patch,float fsum_gsum,float f_recip_g_recip);
-float db_SignedSquareNormCorr11x11Aligned_Post_s(const short *f_patch,const short *g_patch,float fsum_gsum,float f_recip_g_recip);
-
-class db_PointInfo_f
-{
-public:
- /*Coordinates of point*/
- int x;
- int y;
- /*Id nr of point*/
- int id;
- /*Best match score*/
- double s;
- /*Best match candidate*/
- db_PointInfo_f *pir;
- /*Precomputed coefficients
- of image patch*/
- float sum;
- float recip;
- /*Pointer to patch layout*/
- const float *patch;
-};
-
-class db_Bucket_f
-{
-public:
- db_PointInfo_f *ptr;
- int nr;
-};
-
-class db_PointInfo_u
-{
-public:
- /*Coordinates of point*/
- int x;
- int y;
- /*Id nr of point*/
- int id;
- /*Best match score*/
- double s;
- /*Best match candidate*/
- db_PointInfo_u *pir;
- /*Precomputed coefficients
- of image patch*/
- float sum;
- float recip;
- /*Pointer to patch layout*/
- const short *patch;
-};
-
-class db_Bucket_u
-{
-public:
- db_PointInfo_u *ptr;
- int nr;
-};
-/*!
- * \class db_Matcher_f
- * \ingroup FeatureMatching
- * \brief Feature matcher for float images.
- *
- * Normalized correlation feature matcher for <b>float</b> images.
- * Correlation window size is constant and set to 11x11.
- * See \ref FeatureDetection to detect Harris corners.
- * Images are managed with functions in \ref LMImageBasicUtilities.
- */
-class DB_API db_Matcher_f
-{
-public:
- db_Matcher_f();
- ~db_Matcher_f();
-
- /*!
- * Set parameters and pre-allocate memory. Return an upper bound
- * on the number of matches.
- * \param im_width width
- * \param im_height height
- * \param max_disparity maximum distance (as fraction of image size) between matches
- * \param target_nr_corners maximum number of matches
- * \return maximum number of matches
- */
- unsigned long Init(int im_width,int im_height,
- double max_disparity=DB_DEFAULT_MAX_DISPARITY,
- int target_nr_corners=DB_DEFAULT_TARGET_NR_CORNERS);
-
- /*!
- * Match two sets of features.
- * If the prewarp H is not NULL it will be applied to the features
- * in the right image before matching.
- * Parameters id_l and id_r must point to arrays of size target_nr_corners
- * (returned by Init()).
- * The results of matching are in id_l and id_r.
- * Interpretaqtion of results: if id_l[i] = m and id_r[i] = n,
- * feature at (x_l[m],y_l[m]) matched to (x_r[n],y_r[n]).
- * \param l_img left image
- * \param r_img right image
- * \param x_l left x coordinates of features
- * \param y_l left y coordinates of features
- * \param nr_l number of features in left image
- * \param x_r right x coordinates of features
- * \param y_r right y coordinates of features
- * \param nr_r number of features in right image
- * \param id_l indices of left features that matched
- * \param id_r indices of right features that matched
- * \param nr_matches number of features actually matched
- * \param H image homography (prewarp) to be applied to right image features
- */
- void Match(const float * const *l_img,const float * const *r_img,
- const double *x_l,const double *y_l,int nr_l,const double *x_r,const double *y_r,int nr_r,
- int *id_l,int *id_r,int *nr_matches,const double H[9]=0);
-
-protected:
- void Clean();
-
- int m_w,m_h,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,m_target;
- unsigned long m_kA,m_kB;
- db_Bucket_f **m_bp_l;
- db_Bucket_f **m_bp_r;
- float *m_patch_space,*m_aligned_patch_space;
-};
-/*!
- * \class db_Matcher_u
- * \ingroup FeatureMatching
- * \brief Feature matcher for byte images.
- *
- * Normalized correlation feature matcher for <b>byte</b> images.
- * Correlation window size is constant and set to 11x11.
- * See \ref FeatureDetection to detect Harris corners.
- * Images are managed with functions in \ref LMImageBasicUtilities.
- *
- * If the prewarp matrix H is supplied, the feature coordinates are warped by H before being placed in
- * appropriate buckets. If H is an affine transform and the "affine" parameter is set to 1 or 2,
- * then the correlation patches themselves are warped before being placed in the patch space.
- */
-class DB_API db_Matcher_u
-{
-public:
- db_Matcher_u();
-
- int GetPatchSize(){return 11;};
-
- virtual ~db_Matcher_u();
-
- /*!
- Copy ctor duplicates settings.
- Memory not copied.
- */
- db_Matcher_u(const db_Matcher_u& cm);
-
- /*!
- Assignment optor duplicates settings
- Memory not copied.
- */
- db_Matcher_u& operator= (const db_Matcher_u& cm);
-
- /*!
- * Set parameters and pre-allocate memory. Return an upper bound
- * on the number of matches.
- * If max_disparity_v is DB_DEFAULT_NO_DISPARITY, look for matches
- * in a ellipse around a feature of radius max_disparity*im_width by max_disparity*im_height.
- * If max_disparity_v is specified, use a rectangle max_disparity*im_width by max_disparity_v*im_height.
- * \param im_width width
- * \param im_height height
- * \param max_disparity maximum distance (as fraction of image size) between matches
- * \param target_nr_corners maximum number of matches
- * \param max_disparity_v maximum vertical disparity (distance between matches)
- * \param use_smaller_matching_window if set to true, uses a correlation window of 5x5 instead of the default 11x11
- * \return maximum number of matches
- */
- virtual unsigned long Init(int im_width,int im_height,
- double max_disparity=DB_DEFAULT_MAX_DISPARITY,
- int target_nr_corners=DB_DEFAULT_TARGET_NR_CORNERS,
- double max_disparity_v=DB_DEFAULT_NO_DISPARITY,
- bool use_smaller_matching_window=false, int use_21=0);
-
- /*!
- * Match two sets of features.
- * If the prewarp H is not NULL it will be applied to the features
- * in the right image before matching.
- * Parameters id_l and id_r must point to arrays of size target_nr_corners
- * (returned by Init()).
- * The results of matching are in id_l and id_r.
- * Interpretaqtion of results: if id_l[i] = m and id_r[i] = n,
- * feature at (x_l[m],y_l[m]) matched to (x_r[n],y_r[n]).
- * \param l_img left image
- * \param r_img right image
- * \param x_l left x coordinates of features
- * \param y_l left y coordinates of features
- * \param nr_l number of features in left image
- * \param x_r right x coordinates of features
- * \param y_r right y coordinates of features
- * \param nr_r number of features in right image
- * \param id_l indices of left features that matched
- * \param id_r indices of right features that matched
- * \param nr_matches number of features actually matched
- * \param H image homography (prewarp) to be applied to right image features
- * \param affine prewarp the 11x11 patches by given affine transform. 0 means no warping,
- 1 means nearest neighbor, 2 means bilinear warping.
- */
- virtual void Match(const unsigned char * const *l_img,const unsigned char * const *r_img,
- const double *x_l,const double *y_l,int nr_l,const double *x_r,const double *y_r,int nr_r,
- int *id_l,int *id_r,int *nr_matches,const double H[9]=0,int affine=0);
-
- /*!
- * Checks if Init() was called.
- * \return 1 if Init() was called, 0 otherwise.
- */
- int IsAllocated();
-
-protected:
- virtual void Clean();
-
-
- int m_w,m_h,m_bw,m_bh,m_nr_h,m_nr_v,m_bd,m_target;
- unsigned long m_kA,m_kB;
- db_Bucket_u **m_bp_l;
- db_Bucket_u **m_bp_r;
- short *m_patch_space,*m_aligned_patch_space;
-
- double m_max_disparity, m_max_disparity_v;
- int m_rect_window;
- bool m_use_smaller_matching_window;
- int m_use_21;
-};
-
-
-
-#endif /*DB_FEATURE_MATCHING_H*/
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_framestitching.cpp b/jni_mosaic/feature_stab/db_vlvm/db_framestitching.cpp
deleted file mode 100644
index b574f7a..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_framestitching.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_framestitching.cpp,v 1.2 2011/06/17 14:03:30 mbansal Exp $ */
-
-#include "db_utilities.h"
-#include "db_framestitching.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-inline void db_RotationFromMOuterProductSum(double R[9],double *score,double M[9])
-{
- double N[16],q[4],lambda[4],lambda_max;
- double y[4];
- int nr_roots;
-
- N[0]= M[0]+M[4]+M[8];
- N[5]= M[0]-M[4]-M[8];
- N[10]= -M[0]+M[4]-M[8];
- N[15]= -M[0]-M[4]+M[8];
- N[1] =N[4] =M[5]-M[7];
- N[2] =N[8] =M[6]-M[2];
- N[3] =N[12]=M[1]-M[3];
- N[6] =N[9] =M[1]+M[3];
- N[7] =N[13]=M[6]+M[2];
- N[11]=N[14]=M[5]+M[7];
-
- /*get the quaternion representing the rotation
- by finding the eigenvector corresponding to the most
- positive eigenvalue. Force eigenvalue solutions, since the matrix
- is symmetric and solutions might otherwise be lost
- when the data is planar*/
- db_RealEigenvalues4x4(lambda,&nr_roots,N,1);
- if(nr_roots)
- {
- lambda_max=lambda[0];
- if(nr_roots>=2)
- {
- if(lambda[1]>lambda_max) lambda_max=lambda[1];
- if(nr_roots>=3)
- {
- if(lambda[2]>lambda_max) lambda_max=lambda[2];
- {
- if(nr_roots>=4) if(lambda[3]>lambda_max) lambda_max=lambda[3];
- }
- }
- }
- }
- else lambda_max=1.0;
- db_EigenVector4x4(q,lambda_max,N);
-
- /*Compute the rotation matrix*/
- db_QuaternionToRotation(R,q);
-
- if(score)
- {
- /*Compute score=transpose(q)*N*q */
- db_Multiply4x4_4x1(y,N,q);
- *score=db_ScalarProduct4(q,y);
- }
-}
-
-void db_StitchSimilarity3DRaw(double *scale,double R[9],double t[3],
- double **Xp,double **X,int nr_points,int orientation_preserving,
- int allow_scaling,int allow_rotation,int allow_translation)
-{
- int i;
- double c[3],cp[3],r[3],rp[3],M[9],s,sp,sc;
- double Rr[9],score_p,score_r;
- double *temp,*temp_p;
-
- if(allow_translation)
- {
- db_PointCentroid3D(c,X,nr_points);
- db_PointCentroid3D(cp,Xp,nr_points);
- }
- else
- {
- db_Zero3(c);
- db_Zero3(cp);
- }
-
- db_Zero9(M);
- s=sp=0;
- for(i=0;i<nr_points;i++)
- {
- temp= *X++;
- temp_p= *Xp++;
- r[0]=(*temp++)-c[0];
- r[1]=(*temp++)-c[1];
- r[2]=(*temp++)-c[2];
- rp[0]=(*temp_p++)-cp[0];
- rp[1]=(*temp_p++)-cp[1];
- rp[2]=(*temp_p++)-cp[2];
-
- M[0]+=r[0]*rp[0];
- M[1]+=r[0]*rp[1];
- M[2]+=r[0]*rp[2];
- M[3]+=r[1]*rp[0];
- M[4]+=r[1]*rp[1];
- M[5]+=r[1]*rp[2];
- M[6]+=r[2]*rp[0];
- M[7]+=r[2]*rp[1];
- M[8]+=r[2]*rp[2];
-
- s+=db_sqr(r[0])+db_sqr(r[1])+db_sqr(r[2]);
- sp+=db_sqr(rp[0])+db_sqr(rp[1])+db_sqr(rp[2]);
- }
-
- /*Compute scale*/
- if(allow_scaling) sc=sqrt(db_SafeDivision(sp,s));
- else sc=1.0;
- *scale=sc;
-
- /*Compute rotation*/
- if(allow_rotation)
- {
- if(orientation_preserving)
- {
- db_RotationFromMOuterProductSum(R,0,M);
- }
- else
- {
- /*Try preserving*/
- db_RotationFromMOuterProductSum(R,&score_p,M);
- /*Try reversing*/
- M[6]= -M[6];
- M[7]= -M[7];
- M[8]= -M[8];
- db_RotationFromMOuterProductSum(Rr,&score_r,M);
- if(score_r>score_p)
- {
- /*Reverse is better*/
- R[0]=Rr[0]; R[1]=Rr[1]; R[2]= -Rr[2];
- R[3]=Rr[3]; R[4]=Rr[4]; R[5]= -Rr[5];
- R[6]=Rr[6]; R[7]=Rr[7]; R[8]= -Rr[8];
- }
- }
- }
- else db_Identity3x3(R);
-
- /*Compute translation*/
- if(allow_translation)
- {
- t[0]=cp[0]-sc*(R[0]*c[0]+R[1]*c[1]+R[2]*c[2]);
- t[1]=cp[1]-sc*(R[3]*c[0]+R[4]*c[1]+R[5]*c[2]);
- t[2]=cp[2]-sc*(R[6]*c[0]+R[7]*c[1]+R[8]*c[2]);
- }
- else db_Zero3(t);
-}
-
-
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_framestitching.h b/jni_mosaic/feature_stab/db_vlvm/db_framestitching.h
deleted file mode 100644
index 5fef5f3..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_framestitching.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_framestitching.h,v 1.2 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_FRAMESTITCHING_H
-#define DB_FRAMESTITCHING_H
-/*!
- * \defgroup FrameStitching Frame Stitching (2D and 3D homography estimation)
- */
-/*\{*/
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMFrameStitching (LM) Frame Stitching (2D and 3D homography estimation)
- */
-/*\{*/
-
-/*!
-Find scale, rotation and translation of the similarity that
-takes the nr_points inhomogenous 3D points X to Xp
-(left to right according to Horn), i.e. for the homogenous equivalents
-Xp and X we would have
-\code
- Xp~
- [sR t]*X
- [0 1]
-\endcode
-If orientation_preserving is true, R is restricted such that det(R)>0.
-allow_scaling, allow_rotation and allow_translation allow s,R and t
-to differ from 1,Identity and 0
-
-Full similarity takes the following on 550MHz:
-\code
-4.5 microseconds with 3 points
-4.7 microseconds with 4 points
-5.0 microseconds with 5 points
-5.2 microseconds with 6 points
-5.8 microseconds with 10 points
-20 microseconds with 100 points
-205 microseconds with 1000 points
-2.9 milliseconds with 10000 points
-50 milliseconds with 100000 points
-0.5 seconds with 1000000 points
-\endcode
-Without orientation_preserving:
-\code
-4 points is minimal for (s,R,t) (R,t)
-3 points is minimal for (s,R) (R)
-2 points is minimal for (s,t)
-1 point is minimal for (s) (t)
-\endcode
-With orientation_preserving:
-\code
-3 points is minimal for (s,R,t) (R,t)
-2 points is minimal for (s,R) (s,t) (R)
-1 point is minimal for (s) (t)
-\endcode
-
-\param scale scale
-\param R rotation
-\param t translation
-\param Xp inhomogenouse 3D points in first coordinate system
-\param X inhomogenouse 3D points in second coordinate system
-\param nr_points number of points
-\param orientation_preserving if true, R is restricted such that det(R)>0.
-\param allow_scaling estimate scale
-\param allow_rotation estimate rotation
-\param allow_translation estimate translation
-*/
-DB_API void db_StitchSimilarity3DRaw(double *scale,double R[9],double t[3],
- double **Xp,double **X,int nr_points,int orientation_preserving=1,
- int allow_scaling=1,int allow_rotation=1,int allow_translation=1);
-
-
-/*\}*/
-
-#endif /* DB_FRAMESTITCHING_H */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_image_homography.cpp b/jni_mosaic/feature_stab/db_vlvm/db_image_homography.cpp
deleted file mode 100644
index aaad7f8..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_image_homography.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_image_homography.cpp,v 1.2 2011/06/17 14:03:31 mbansal Exp $ */
-
-#include "db_utilities.h"
-#include "db_image_homography.h"
-#include "db_framestitching.h"
-#include "db_metrics.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-/*Compute the linear constraint on H obtained by requiring that the
-ratio between coordinate i_num and i_den of xp is equal to the ratio
-between coordinate i_num and i_den of Hx. i_zero should be set to
-the coordinate not equal to i_num or i_den. No normalization is used*/
-inline void db_SProjImagePointPointConstraint(double c[9],int i_num,int i_den,int i_zero,
- double xp[3],double x[3])
-{
- db_MultiplyScalarCopy3(c+3*i_den,x, xp[i_num]);
- db_MultiplyScalarCopy3(c+3*i_num,x, -xp[i_den]);
- db_Zero3(c+3*i_zero);
-}
-
-/*Compute two constraints on H generated by the correspondence (Xp,X),
-assuming that Xp ~= H*X. No normalization is used*/
-inline void db_SProjImagePointPointConstraints(double c1[9],double c2[9],double xp[3],double x[3])
-{
- int ma_ind;
-
- /*Find index of coordinate of Xp with largest absolute value*/
- ma_ind=db_MaxAbsIndex3(xp);
-
- /*Generate 2 constraints,
- each constraint is generated by considering the ratio between a
- coordinate and the largest absolute value coordinate*/
- switch(ma_ind)
- {
- case 0:
- db_SProjImagePointPointConstraint(c1,1,0,2,xp,x);
- db_SProjImagePointPointConstraint(c2,2,0,1,xp,x);
- break;
- case 1:
- db_SProjImagePointPointConstraint(c1,0,1,2,xp,x);
- db_SProjImagePointPointConstraint(c2,2,1,0,xp,x);
- break;
- default:
- db_SProjImagePointPointConstraint(c1,0,2,1,xp,x);
- db_SProjImagePointPointConstraint(c2,1,2,0,xp,x);
- }
-}
-
-inline void db_SAffineImagePointPointConstraints(double c1[7],double c2[7],double xp[3],double x[3])
-{
- double ct1[9],ct2[9];
-
- db_SProjImagePointPointConstraints(ct1,ct2,xp,x);
- db_Copy6(c1,ct1); c1[6]=ct1[8];
- db_Copy6(c2,ct2); c2[6]=ct2[8];
-}
-
-void db_StitchProjective2D_4Points(double H[9],
- double x1[3],double x2[3],double x3[3],double x4[3],
- double xp1[3],double xp2[3],double xp3[3],double xp4[3])
-{
- double c[72];
-
- /*Collect the constraints*/
- db_SProjImagePointPointConstraints(c ,c+9 ,xp1,x1);
- db_SProjImagePointPointConstraints(c+18,c+27,xp2,x2);
- db_SProjImagePointPointConstraints(c+36,c+45,xp3,x3);
- db_SProjImagePointPointConstraints(c+54,c+63,xp4,x4);
- /*Solve for the nullvector*/
- db_NullVector8x9Destructive(H,c);
-}
-
-void db_StitchAffine2D_3Points(double H[9],
- double x1[3],double x2[3],double x3[3],
- double xp1[3],double xp2[3],double xp3[3])
-{
- double c[42];
-
- /*Collect the constraints*/
- db_SAffineImagePointPointConstraints(c ,c+7 ,xp1,x1);
- db_SAffineImagePointPointConstraints(c+14,c+21,xp2,x2);
- db_SAffineImagePointPointConstraints(c+28,c+35,xp3,x3);
- /*Solve for the nullvector*/
- db_NullVector6x7Destructive(H,c);
- db_MultiplyScalar6(H,db_SafeReciprocal(H[6]));
- H[6]=H[7]=0; H[8]=1.0;
-}
-
-/*Compute up to three solutions for the focal length given two point correspondences
-generated by a rotation with a common unknown focal length. No specific normalization
-of the input points is required. If signed_disambiguation is true, the points are
-required to be in front of the camera*/
-inline void db_CommonFocalLengthFromRotation_2Point(double fsol[3],int *nr_sols,double x1[3],double x2[3],double xp1[3],double xp2[3],int signed_disambiguation=1)
-{
- double m,ax,ay,apx,apy,bx,by,bpx,bpy;
- double p1[2],p2[2],p3[2],p4[2],p5[2],p6[2];
- double p7[3],p8[4],p9[5],p10[3],p11[4];
- double roots[3];
- int nr_roots,i,j;
-
- /*Solve for focal length using the equation
- <a,b>^2*<ap,ap><bp,bp>=<ap,bp>^2*<a,a><b,b>
- where a and ap are the homogenous vectors in the first image
- after focal length scaling and b,bp are the vectors in the
- second image*/
-
- /*Normalize homogenous coordinates so that last coordinate is one*/
- m=db_SafeReciprocal(x1[2]);
- ax=x1[0]*m;
- ay=x1[1]*m;
- m=db_SafeReciprocal(xp1[2]);
- apx=xp1[0]*m;
- apy=xp1[1]*m;
- m=db_SafeReciprocal(x2[2]);
- bx=x2[0]*m;
- by=x2[1]*m;
- m=db_SafeReciprocal(xp2[2]);
- bpx=xp2[0]*m;
- bpy=xp2[1]*m;
-
- /*Compute cubic in l=1/(f^2)
- by dividing out the root l=0 from the equation
- (l(ax*bx+ay*by)+1)^2*(l(apx^2+apy^2)+1)*(l(bpx^2+bpy^2)+1)=
- (l(apx*bpx+apy*bpy)+1)^2*(l(ax^2+ay^2)+1)*(l(bx^2+by^2)+1)*/
- p1[1]=ax*bx+ay*by;
- p2[1]=db_sqr(apx)+db_sqr(apy);
- p3[1]=db_sqr(bpx)+db_sqr(bpy);
- p4[1]=apx*bpx+apy*bpy;
- p5[1]=db_sqr(ax)+db_sqr(ay);
- p6[1]=db_sqr(bx)+db_sqr(by);
- p1[0]=p2[0]=p3[0]=p4[0]=p5[0]=p6[0]=1;
-
- db_MultiplyPoly1_1(p7,p1,p1);
- db_MultiplyPoly1_2(p8,p2,p7);
- db_MultiplyPoly1_3(p9,p3,p8);
-
- db_MultiplyPoly1_1(p10,p4,p4);
- db_MultiplyPoly1_2(p11,p5,p10);
- db_SubtractPolyProduct1_3(p9,p6,p11);
- /*Cubic starts at p9[1]*/
- db_SolveCubic(roots,&nr_roots,p9[4],p9[3],p9[2],p9[1]);
-
- for(j=0,i=0;i<nr_roots;i++)
- {
- if(roots[i]>0)
- {
- if((!signed_disambiguation) || (db_PolyEval1(p1,roots[i])*db_PolyEval1(p4,roots[i])>0))
- {
- fsol[j++]=db_SafeSqrtReciprocal(roots[i]);
- }
- }
- }
- *nr_sols=j;
-}
-
-int db_StitchRotationCommonFocalLength_3Points(double H[9],double x1[3],double x2[3],double x3[3],double xp1[3],double xp2[3],double xp3[3],double *f,int signed_disambiguation)
-{
- double fsol[3];
- int nr_sols,i,best_sol,done;
- double cost,best_cost;
- double m,hyp[27],x1_temp[3],x2_temp[3],xp1_temp[3],xp2_temp[3];
- double *hyp_point,ft;
- double y[2];
-
- db_CommonFocalLengthFromRotation_2Point(fsol,&nr_sols,x1,x2,xp1,xp2,signed_disambiguation);
- if(nr_sols)
- {
- db_DeHomogenizeImagePoint(y,xp3);
- done=0;
- for(i=0;i<nr_sols;i++)
- {
- ft=fsol[i];
- m=db_SafeReciprocal(ft);
- x1_temp[0]=x1[0]*m;
- x1_temp[1]=x1[1]*m;
- x1_temp[2]=x1[2];
- x2_temp[0]=x2[0]*m;
- x2_temp[1]=x2[1]*m;
- x2_temp[2]=x2[2];
- xp1_temp[0]=xp1[0]*m;
- xp1_temp[1]=xp1[1]*m;
- xp1_temp[2]=xp1[2];
- xp2_temp[0]=xp2[0]*m;
- xp2_temp[1]=xp2[1]*m;
- xp2_temp[2]=xp2[2];
-
- hyp_point=hyp+9*i;
- db_StitchCameraRotation_2Points(hyp_point,x1_temp,x2_temp,xp1_temp,xp2_temp);
- hyp_point[2]*=ft;
- hyp_point[5]*=ft;
- hyp_point[6]*=m;
- hyp_point[7]*=m;
- cost=db_SquaredReprojectionErrorHomography(y,hyp_point,x3);
-
- if(!done || cost<best_cost)
- {
- done=1;
- best_cost=cost;
- best_sol=i;
- }
- }
-
- if(f) *f=fsol[best_sol];
- db_Copy9(H,hyp+9*best_sol);
- return(1);
- }
- else
- {
- db_Identity3x3(H);
- if(f) *f=1.0;
- return(0);
- }
-}
-
-void db_StitchSimilarity2DRaw(double *scale,double R[4],double t[2],
- double **Xp,double **X,int nr_points,int orientation_preserving,
- int allow_scaling,int allow_rotation,int allow_translation)
-{
- int i;
- double c[2],cp[2],r[2],rp[2],M[4],s,sp,sc;
- double *temp,*temp_p;
- double Aacc,Bacc,Aacc2,Bacc2,divisor,divisor2,m,Am,Bm;
-
- if(allow_translation)
- {
- db_PointCentroid2D(c,X,nr_points);
- db_PointCentroid2D(cp,Xp,nr_points);
- }
- else
- {
- db_Zero2(c);
- db_Zero2(cp);
- }
-
- db_Zero4(M);
- s=sp=0;
- for(i=0;i<nr_points;i++)
- {
- temp= *X++;
- temp_p= *Xp++;
- r[0]=(*temp++)-c[0];
- r[1]=(*temp++)-c[1];
- rp[0]=(*temp_p++)-cp[0];
- rp[1]=(*temp_p++)-cp[1];
-
- M[0]+=r[0]*rp[0];
- M[1]+=r[0]*rp[1];
- M[2]+=r[1]*rp[0];
- M[3]+=r[1]*rp[1];
-
- s+=db_sqr(r[0])+db_sqr(r[1]);
- sp+=db_sqr(rp[0])+db_sqr(rp[1]);
- }
-
- /*Compute scale*/
- if(allow_scaling) sc=sqrt(db_SafeDivision(sp,s));
- else sc=1.0;
- *scale=sc;
-
- /*Compute rotation*/
- if(allow_rotation)
- {
- /*orientation preserving*/
- Aacc=M[0]+M[3];
- Bacc=M[2]-M[1];
- /*orientation reversing*/
- Aacc2=M[0]-M[3];
- Bacc2=M[2]+M[1];
- if(Aacc!=0.0 || Bacc!=0.0)
- {
- divisor=sqrt(Aacc*Aacc+Bacc*Bacc);
- m=db_SafeReciprocal(divisor);
- Am=Aacc*m;
- Bm=Bacc*m;
- R[0]= Am;
- R[1]= Bm;
- R[2]= -Bm;
- R[3]= Am;
- }
- else
- {
- db_Identity2x2(R);
- divisor=0.0;
- }
- if(!orientation_preserving && (Aacc2!=0.0 || Bacc2!=0.0))
- {
- divisor2=sqrt(Aacc2*Aacc2+Bacc2*Bacc2);
- if(divisor2>divisor)
- {
- m=db_SafeReciprocal(divisor2);
- Am=Aacc2*m;
- Bm=Bacc2*m;
- R[0]= Am;
- R[1]= Bm;
- R[2]= Bm;
- R[3]= -Am;
- }
- }
- }
- else db_Identity2x2(R);
-
- /*Compute translation*/
- if(allow_translation)
- {
- t[0]=cp[0]-sc*(R[0]*c[0]+R[1]*c[1]);
- t[1]=cp[1]-sc*(R[2]*c[0]+R[3]*c[1]);
- }
- else db_Zero2(t);
-}
-
-
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_image_homography.h b/jni_mosaic/feature_stab/db_vlvm/db_image_homography.h
deleted file mode 100644
index 165447d..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_image_homography.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_image_homography.h,v 1.2 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_IMAGE_HOMOGRAPHY
-#define DB_IMAGE_HOMOGRAPHY
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-#include "db_framestitching.h"
-/*!
- * \defgroup LMImageHomography (LM) Image Homography Estimation (feature based)
- */
-/*\{*/
-/*!
-Solve for projective H such that xp~Hx. Prior normalization is not necessary,
-although desirable for numerical conditioning
-\param H image projective (out)
-\param x1 image 1 point 1
-\param x2 image 1 point 2
-\param x3 image 1 point 3
-\param x4 image 1 point 4
-\param xp1 image 2 point 1
-\param xp2 image 2 point 2
-\param xp3 image 2 point 3
-\param xp4 image 2 point 4
-*/
-DB_API void db_StitchProjective2D_4Points(double H[9],
- double x1[3],double x2[3],double x3[3],double x4[3],
- double xp1[3],double xp2[3],double xp3[3],double xp4[3]);
-
-/*!
-Solve for affine H such that xp~Hx. Prior normalization is not necessary,
-although desirable for numerical conditioning
-\param H image projective (out)
-\param x1 image 1 point 1
-\param x2 image 1 point 2
-\param x3 image 1 point 3
-\param xp1 image 2 point 1
-\param xp2 image 2 point 2
-\param xp3 image 2 point 3
-*/
-DB_API void db_StitchAffine2D_3Points(double H[9],
- double x1[3],double x2[3],double x3[3],
- double xp1[3],double xp2[3],double xp3[3]);
-
-/*!
-Solve for rotation R such that xp~Rx.
-Image points have to be of unit norm for the least squares to be meaningful.
-\param R image rotation (out)
-\param x1 image 1 point 1
-\param x2 image 1 point 2
-\param xp1 image 2 point 1
-\param xp2 image 2 point 2
-*/
-inline void db_StitchCameraRotation_2Points(double R[9],
- /*Image points have to be of unit norm
- for the least squares to be meaningful*/
- double x1[3],double x2[3],
- double xp1[3],double xp2[3])
-{
- double* x[2];
- double* xp[2];
- double scale,t[3];
-
- x[0]=x1;
- x[1]=x2;
- xp[0]=xp1;
- xp[1]=xp2;
- db_StitchSimilarity3DRaw(&scale,R,t,xp,x,2,1,0,1,0);
-}
-
-/*!
-Solve for a homography H generated by a rotation R with a common unknown focal length f, i.e.
-H=diag(f,f,1)*R*diag(1/f,1/f,1) such that xp~Hx.
-If signed_disambiguation is true, the points are
-required to be in front of the camera. No specific normalization of the homogenous points
-is required, although it could be desirable to keep x1,x2,xp1 and xp2 of reasonable magnitude.
-If a solution is obtained the function returns 1, otherwise 0. If the focal length is desired
-a valid pointer should be passed in f
-*/
-DB_API int db_StitchRotationCommonFocalLength_3Points(double H[9],double x1[3],double x2[3],double x3[3],
- double xp1[3],double xp2[3],double xp3[3],double *f=0,int signed_disambiguation=1);
-
-/*!
-Find scale, rotation and translation of the similarity that
-takes the nr_points inhomogenous 2D points X to Xp,
-i.e. for the homogenous equivalents
-Xp and X we would have
-\code
-Xp~
-[sR t]*X
-[0 1]
-\endcode
-If orientation_preserving is true, R is restricted such that det(R)>0.
-allow_scaling, allow_rotation and allow_translation allow s,R and t
-to differ from 1,Identity and 0
-
-Full similarity takes the following on 550MHz:
-\code
-0.9 microseconds with 2 points
-1.0 microseconds with 3 points
-1.1 microseconds with 4 points
-1.3 microseconds with 5 points
-1.4 microseconds with 6 points
-1.7 microseconds with 10 points
-9 microseconds with 100 points
-130 microseconds with 1000 points
-1.3 milliseconds with 10000 points
-35 milliseconds with 100000 points
-350 milliseconds with 1000000 points
-\endcode
-
-Without orientation_preserving:
-\code
-3 points is minimal for (s,R,t) (R,t)
-2 points is minimal for (s,t) (s,R) (R)
-1 point is minimal for (s) (t)
-\endcode
-
-With orientation_preserving:
-\code
-2 points is minimal for (s,R,t) (R,t) (s,t)
-1 point is minimal for (s,R) (R) (s) (t)
-\endcode
-\param scale (out)
-\param R 2D rotation (out)
-\param t 2D translation (out)
-\param Xp (nr_points x 2) pointer to array of image points
-\param X (nr_points x 2 ) pointer to array of image points
-\param nr_points number of points
-\param orientation_preserving
-\param allow_scaling compute scale (if 0, scale=1)
-\param allow_rotation compute rotation (if 0, R=[I])
-\param allow_translation compute translation (if 0 t = [0,0]')
-*/
-DB_API void db_StitchSimilarity2DRaw(double *scale,double R[4],double t[2],
- double **Xp,double **X,int nr_points,int orientation_preserving=1,
- int allow_scaling=1,int allow_rotation=1,int allow_translation=1);
-/*!
-See db_StitchRotationCommonFocalLength_3Points().
-\param H Image similarity transformation (out)
-\param Xp (nr_points x 2) pointer to array of image points
-\param X (nr_points x 2) pointer to array of image points
-\param nr_points number of points
-\param orientation_preserving
-\param allow_scaling compute scale (if 0, scale=1)
-\param allow_rotation compute rotation (if 0, R=[I])
-\param allow_translation compute translation (if 0 t = [0,0]')
-*/
-inline void db_StitchSimilarity2D(double H[9],double **Xp,double **X,int nr_points,int orientation_preserving=1,
- int allow_scaling=1,int allow_rotation=1,int allow_translation=1)
-{
- double s,R[4],t[2];
-
- db_StitchSimilarity2DRaw(&s,R,t,Xp,X,nr_points,orientation_preserving,
- allow_scaling,allow_rotation,allow_translation);
-
- H[0]=s*R[0]; H[1]=s*R[1]; H[2]=t[0];
- H[3]=s*R[2]; H[4]=s*R[3]; H[5]=t[1];
- db_Zero2(H+6);
- H[8]=1.0;
-}
-/*\}*/
-#endif /* DB_IMAGE_HOMOGRAPHY */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_metrics.h b/jni_mosaic/feature_stab/db_vlvm/db_metrics.h
deleted file mode 100644
index 6b95458..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_metrics.h
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_metrics.h,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_METRICS
-#define DB_METRICS
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-#include "db_utilities.h"
-/*!
- * \defgroup LMMetrics (LM) Metrics
- */
-/*\{*/
-
-
-
-
-/*!
-Compute function value fp and Jacobian J of robustifier given input value f*/
-inline void db_CauchyDerivative(double J[4],double fp[2],const double f[2],double one_over_scale2)
-{
- double x2,y2,r,r2,r2s,one_over_r2,fu,r_fu,one_over_r_fu;
- double one_plus_r2s,half_dfu_dx,half_dfu_dy,coeff,coeff2,coeff3;
- int at_zero;
-
- /*The robustifier takes the input (x,y) and makes a new
- vector (xp,yp) where
- xp=sqrt(log(1+(x^2+y^2)*one_over_scale2))*x/sqrt(x^2+y^2)
- yp=sqrt(log(1+(x^2+y^2)*one_over_scale2))*y/sqrt(x^2+y^2)
- The new vector has the property
- xp^2+yp^2=log(1+(x^2+y^2)*one_over_scale2)
- i.e. when it is square-summed it gives the robust
- reprojection error
- Define
- r2=(x^2+y^2) and
- r2s=r2*one_over_scale2
- fu=log(1+r2s)/r2
- then
- xp=sqrt(fu)*x
- yp=sqrt(fu)*y
- and
- d(r2)/dx=2x
- d(r2)/dy=2y
- and
- dfu/dx=d(r2)/dx*(r2s/(1+r2s)-log(1+r2s))/(r2*r2)
- dfu/dy=d(r2)/dy*(r2s/(1+r2s)-log(1+r2s))/(r2*r2)
- and
- d(xp)/dx=1/(2sqrt(fu))*(dfu/dx)*x+sqrt(fu)
- d(xp)/dy=1/(2sqrt(fu))*(dfu/dy)*x
- d(yp)/dx=1/(2sqrt(fu))*(dfu/dx)*y
- d(yp)/dy=1/(2sqrt(fu))*(dfu/dy)*y+sqrt(fu)
- */
-
- x2=db_sqr(f[0]);
- y2=db_sqr(f[1]);
- r2=x2+y2;
- r=sqrt(r2);
-
- if(r2<=0.0) at_zero=1;
- else
- {
- one_over_r2=1.0/r2;
- r2s=r2*one_over_scale2;
- one_plus_r2s=1.0+r2s;
- fu=log(one_plus_r2s)*one_over_r2;
- r_fu=sqrt(fu);
- if(r_fu<=0.0) at_zero=1;
- else
- {
- one_over_r_fu=1.0/r_fu;
- fp[0]=r_fu*f[0];
- fp[1]=r_fu*f[1];
- /*r2s is always >= 0*/
- coeff=(r2s/one_plus_r2s*one_over_r2-fu)*one_over_r2;
- half_dfu_dx=f[0]*coeff;
- half_dfu_dy=f[1]*coeff;
- coeff2=one_over_r_fu*half_dfu_dx;
- coeff3=one_over_r_fu*half_dfu_dy;
-
- J[0]=coeff2*f[0]+r_fu;
- J[1]=coeff3*f[0];
- J[2]=coeff2*f[1];
- J[3]=coeff3*f[1]+r_fu;
- at_zero=0;
- }
- }
- if(at_zero)
- {
- /*Close to zero the robustifying mapping
- becomes identity*sqrt(one_over_scale2)*/
- fp[0]=0.0;
- fp[1]=0.0;
- J[0]=sqrt(one_over_scale2);
- J[1]=0.0;
- J[2]=0.0;
- J[3]=J[0];
- }
-}
-
-inline double db_SquaredReprojectionErrorHomography(const double y[2],const double H[9],const double x[3])
-{
- double x0,x1,x2,mult;
- double sd;
-
- x0=H[0]*x[0]+H[1]*x[1]+H[2]*x[2];
- x1=H[3]*x[0]+H[4]*x[1]+H[5]*x[2];
- x2=H[6]*x[0]+H[7]*x[1]+H[8]*x[2];
- mult=1.0/((x2!=0.0)?x2:1.0);
- sd=db_sqr((y[0]-x0*mult))+db_sqr((y[1]-x1*mult));
-
- return(sd);
-}
-
-inline double db_SquaredInhomogenousHomographyError(const double y[2],const double H[9],const double x[2])
-{
- double x0,x1,x2,mult;
- double sd;
-
- x0=H[0]*x[0]+H[1]*x[1]+H[2];
- x1=H[3]*x[0]+H[4]*x[1]+H[5];
- x2=H[6]*x[0]+H[7]*x[1]+H[8];
- mult=1.0/((x2!=0.0)?x2:1.0);
- sd=db_sqr((y[0]-x0*mult))+db_sqr((y[1]-x1*mult));
-
- return(sd);
-}
-
-/*!
-Return a constant divided by likelihood of a Cauchy distributed
-reprojection error given the image point y, homography H, image point
-point x and the squared scale coefficient one_over_scale2=1.0/(scale*scale)
-where scale is the half width at half maximum (hWahM) of the
-Cauchy distribution*/
-inline double db_ExpCauchyInhomogenousHomographyError(const double y[2],const double H[9],const double x[2],
- double one_over_scale2)
-{
- double sd;
- sd=db_SquaredInhomogenousHomographyError(y,H,x);
- return(1.0+sd*one_over_scale2);
-}
-
-/*!
-Compute residual vector f between image point y and homography Hx of
-image point x. Also compute Jacobian of f with respect
-to an update dx of H*/
-inline void db_DerivativeInhomHomographyError(double Jf_dx[18],double f[2],const double y[2],const double H[9],
- const double x[2])
-{
- double xh,yh,zh,mult,mult2,xh_mult2,yh_mult2;
- /*The Jacobian of the inhomogenous coordinates with respect to
- the homogenous is
- [1/zh 0 -xh/(zh*zh)]
- [ 0 1/zh -yh/(zh*zh)]
- The Jacobian of the homogenous coordinates with respect to dH is
- [x0 x1 1 0 0 0 0 0 0]
- [ 0 0 0 x0 x1 1 0 0 0]
- [ 0 0 0 0 0 0 x0 x1 1]
- The output Jacobian is minus their product, i.e.
- [-x0/zh -x1/zh -1/zh 0 0 0 x0*xh/(zh*zh) x1*xh/(zh*zh) xh/(zh*zh)]
- [ 0 0 0 -x0/zh -x1/zh -1/zh x0*yh/(zh*zh) x1*yh/(zh*zh) yh/(zh*zh)]*/
-
- /*Compute warped point, which is the same as
- homogenous coordinates of reprojection*/
- xh=H[0]*x[0]+H[1]*x[1]+H[2];
- yh=H[3]*x[0]+H[4]*x[1]+H[5];
- zh=H[6]*x[0]+H[7]*x[1]+H[8];
- mult=1.0/((zh!=0.0)?zh:1.0);
- /*Compute inhomogenous residual*/
- f[0]=y[0]-xh*mult;
- f[1]=y[1]-yh*mult;
- /*Compute Jacobian*/
- mult2=mult*mult;
- xh_mult2=xh*mult2;
- yh_mult2=yh*mult2;
- Jf_dx[0]= -x[0]*mult;
- Jf_dx[1]= -x[1]*mult;
- Jf_dx[2]= -mult;
- Jf_dx[3]=0;
- Jf_dx[4]=0;
- Jf_dx[5]=0;
- Jf_dx[6]=x[0]*xh_mult2;
- Jf_dx[7]=x[1]*xh_mult2;
- Jf_dx[8]=xh_mult2;
- Jf_dx[9]=0;
- Jf_dx[10]=0;
- Jf_dx[11]=0;
- Jf_dx[12]=Jf_dx[0];
- Jf_dx[13]=Jf_dx[1];
- Jf_dx[14]=Jf_dx[2];
- Jf_dx[15]=x[0]*yh_mult2;
- Jf_dx[16]=x[1]*yh_mult2;
- Jf_dx[17]=yh_mult2;
-}
-
-/*!
-Compute robust residual vector f between image point y and homography Hx of
-image point x. Also compute Jacobian of f with respect
-to an update dH of H*/
-inline void db_DerivativeCauchyInhomHomographyReprojection(double Jf_dx[18],double f[2],const double y[2],const double H[9],
- const double x[2],double one_over_scale2)
-{
- double Jf_dx_loc[18],f_loc[2];
- double J[4],J0,J1,J2,J3;
-
- /*Compute reprojection Jacobian*/
- db_DerivativeInhomHomographyError(Jf_dx_loc,f_loc,y,H,x);
- /*Compute robustifier Jacobian*/
- db_CauchyDerivative(J,f,f_loc,one_over_scale2);
-
- /*Multiply the robustifier Jacobian with
- the reprojection Jacobian*/
- J0=J[0];J1=J[1];J2=J[2];J3=J[3];
- Jf_dx[0]=J0*Jf_dx_loc[0];
- Jf_dx[1]=J0*Jf_dx_loc[1];
- Jf_dx[2]=J0*Jf_dx_loc[2];
- Jf_dx[3]= J1*Jf_dx_loc[12];
- Jf_dx[4]= J1*Jf_dx_loc[13];
- Jf_dx[5]= J1*Jf_dx_loc[14];
- Jf_dx[6]=J0*Jf_dx_loc[6]+J1*Jf_dx_loc[15];
- Jf_dx[7]=J0*Jf_dx_loc[7]+J1*Jf_dx_loc[16];
- Jf_dx[8]=J0*Jf_dx_loc[8]+J1*Jf_dx_loc[17];
- Jf_dx[9]= J2*Jf_dx_loc[0];
- Jf_dx[10]=J2*Jf_dx_loc[1];
- Jf_dx[11]=J2*Jf_dx_loc[2];
- Jf_dx[12]= J3*Jf_dx_loc[12];
- Jf_dx[13]= J3*Jf_dx_loc[13];
- Jf_dx[14]= J3*Jf_dx_loc[14];
- Jf_dx[15]=J2*Jf_dx_loc[6]+J3*Jf_dx_loc[15];
- Jf_dx[16]=J2*Jf_dx_loc[7]+J3*Jf_dx_loc[16];
- Jf_dx[17]=J2*Jf_dx_loc[8]+J3*Jf_dx_loc[17];
-}
-/*!
-Compute residual vector f between image point y and rotation of
-image point x by R. Also compute Jacobian of f with respect
-to an update dx of R*/
-inline void db_DerivativeInhomRotationReprojection(double Jf_dx[6],double f[2],const double y[2],const double R[9],
- const double x[2])
-{
- double xh,yh,zh,mult,mult2,xh_mult2,yh_mult2;
- /*The Jacobian of the inhomogenous coordinates with respect to
- the homogenous is
- [1/zh 0 -xh/(zh*zh)]
- [ 0 1/zh -yh/(zh*zh)]
- The Jacobian at zero of the homogenous coordinates with respect to
- [sin(phi) sin(ohm) sin(kap)] is
- [-rx2 0 rx1 ]
- [ 0 rx2 -rx0 ]
- [ rx0 -rx1 0 ]
- The output Jacobian is minus their product, i.e.
- [1+xh*xh/(zh*zh) -xh*yh/(zh*zh) -yh/zh]
- [xh*yh/(zh*zh) -1-yh*yh/(zh*zh) xh/zh]*/
-
- /*Compute rotated point, which is the same as
- homogenous coordinates of reprojection*/
- xh=R[0]*x[0]+R[1]*x[1]+R[2];
- yh=R[3]*x[0]+R[4]*x[1]+R[5];
- zh=R[6]*x[0]+R[7]*x[1]+R[8];
- mult=1.0/((zh!=0.0)?zh:1.0);
- /*Compute inhomogenous residual*/
- f[0]=y[0]-xh*mult;
- f[1]=y[1]-yh*mult;
- /*Compute Jacobian*/
- mult2=mult*mult;
- xh_mult2=xh*mult2;
- yh_mult2=yh*mult2;
- Jf_dx[0]= 1.0+xh*xh_mult2;
- Jf_dx[1]= -yh*xh_mult2;
- Jf_dx[2]= -yh*mult;
- Jf_dx[3]= -Jf_dx[1];
- Jf_dx[4]= -1-yh*yh_mult2;
- Jf_dx[5]= xh*mult;
-}
-
-/*!
-Compute robust residual vector f between image point y and rotation of
-image point x by R. Also compute Jacobian of f with respect
-to an update dx of R*/
-inline void db_DerivativeCauchyInhomRotationReprojection(double Jf_dx[6],double f[2],const double y[2],const double R[9],
- const double x[2],double one_over_scale2)
-{
- double Jf_dx_loc[6],f_loc[2];
- double J[4],J0,J1,J2,J3;
-
- /*Compute reprojection Jacobian*/
- db_DerivativeInhomRotationReprojection(Jf_dx_loc,f_loc,y,R,x);
- /*Compute robustifier Jacobian*/
- db_CauchyDerivative(J,f,f_loc,one_over_scale2);
-
- /*Multiply the robustifier Jacobian with
- the reprojection Jacobian*/
- J0=J[0];J1=J[1];J2=J[2];J3=J[3];
- Jf_dx[0]=J0*Jf_dx_loc[0]+J1*Jf_dx_loc[3];
- Jf_dx[1]=J0*Jf_dx_loc[1]+J1*Jf_dx_loc[4];
- Jf_dx[2]=J0*Jf_dx_loc[2]+J1*Jf_dx_loc[5];
- Jf_dx[3]=J2*Jf_dx_loc[0]+J3*Jf_dx_loc[3];
- Jf_dx[4]=J2*Jf_dx_loc[1]+J3*Jf_dx_loc[4];
- Jf_dx[5]=J2*Jf_dx_loc[2]+J3*Jf_dx_loc[5];
-}
-
-
-
-/*!
-// remove the outliers whose projection error is larger than pre-defined
-*/
-inline int db_RemoveOutliers_Homography(const double H[9], double *x_i,double *xp_i, double *wp,double *im, double *im_p, double *im_r, double *im_raw,double *im_raw_p,int point_count,double scale, double thresh=DB_OUTLIER_THRESHOLD)
-{
- double temp_valueE, t2;
- int c;
- int k1=0;
- int k2=0;
- int k3=0;
- int numinliers=0;
- int ind1;
- int ind2;
- int ind3;
- int isinlier;
-
- // experimentally determined
- t2=1.0/(thresh*thresh*thresh*thresh);
-
- // count the inliers
- for(c=0;c<point_count;c++)
- {
- ind1=c<<1;
- ind2=c<<2;
- ind3=3*c;
-
- temp_valueE=db_SquaredInhomogenousHomographyError(im_p+ind3,H,im+ind3);
-
- isinlier=((temp_valueE<=t2)?1:0);
-
- // if it is inlier, then copy the 3d and 2d correspondences
- if (isinlier)
- {
- numinliers++;
-
- x_i[k1]=x_i[ind1];
- x_i[k1+1]=x_i[ind1+1];
-
- xp_i[k1]=xp_i[ind1];
- xp_i[k1+1]=xp_i[ind1+1];
-
- k1=k1+2;
-
- // original normalized pixel coordinates
- im[k3]=im[ind3];
- im[k3+1]=im[ind3+1];
- im[k3+2]=im[ind3+2];
-
- im_r[k3]=im_r[ind3];
- im_r[k3+1]=im_r[ind3+1];
- im_r[k3+2]=im_r[ind3+2];
-
- im_p[k3]=im_p[ind3];
- im_p[k3+1]=im_p[ind3+1];
- im_p[k3+2]=im_p[ind3+2];
-
- // left and right raw pixel coordinates
- im_raw[k3] = im_raw[ind3];
- im_raw[k3+1] = im_raw[ind3+1];
- im_raw[k3+2] = im_raw[ind3+2]; // the index
-
- im_raw_p[k3] = im_raw_p[ind3];
- im_raw_p[k3+1] = im_raw_p[ind3+1];
- im_raw_p[k3+2] = im_raw_p[ind3+2]; // the index
-
- k3=k3+3;
-
- // 3D coordinates
- wp[k2]=wp[ind2];
- wp[k2+1]=wp[ind2+1];
- wp[k2+2]=wp[ind2+2];
- wp[k2+3]=wp[ind2+3];
-
- k2=k2+4;
-
- }
- }
-
- return numinliers;
-}
-
-
-
-
-
-/*\}*/
-
-#endif /* DB_METRICS */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_rob_image_homography.cpp b/jni_mosaic/feature_stab/db_vlvm/db_rob_image_homography.cpp
deleted file mode 100644
index 82dec0c..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_rob_image_homography.cpp
+++ /dev/null
@@ -1,1082 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_rob_image_homography.cpp,v 1.2 2011/06/17 14:03:31 mbansal Exp $ */
-
-#include "db_utilities.h"
-#include "db_rob_image_homography.h"
-#include "db_bundle.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-#include "db_image_homography.h"
-
-#ifdef _VERBOSE_
-#include <iostream>
-using namespace std;
-#endif /*VERBOSE*/
-
-inline double db_RobImageHomography_Cost(double H[9],int point_count,double *x_i,double *xp_i,double one_over_scale2)
-{
- int c;
- double back,acc,*x_i_temp,*xp_i_temp;
-
- for(back=0.0,c=0;c<point_count;)
- {
- /*Take log of product of ten reprojection
- errors to reduce nr of expensive log operations*/
- if(c+9<point_count)
- {
- x_i_temp=x_i+(c<<1);
- xp_i_temp=xp_i+(c<<1);
-
- acc=db_ExpCauchyInhomogenousHomographyError(xp_i_temp,H,x_i_temp,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+2,H,x_i_temp+2,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+4,H,x_i_temp+4,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+6,H,x_i_temp+6,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+8,H,x_i_temp+8,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+10,H,x_i_temp+10,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+12,H,x_i_temp+12,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+14,H,x_i_temp+14,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+16,H,x_i_temp+16,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+18,H,x_i_temp+18,one_over_scale2);
- c+=10;
- }
- else
- {
- for(acc=1.0;c<point_count;c++)
- {
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i+(c<<1),H,x_i+(c<<1),one_over_scale2);
- }
- }
- back+=log(acc);
- }
- return(back);
-}
-
-inline double db_RobImageHomography_Statistics(double H[9],int point_count,double *x_i,double *xp_i,double one_over_scale2,db_Statistics *stat,double thresh=DB_OUTLIER_THRESHOLD)
-{
- int c,i;
- double t2,frac;
-
- t2=thresh*thresh;
- for(i=0,c=0;c<point_count;c++)
- {
- i+=(db_SquaredInhomogenousHomographyError(xp_i+(c<<1),H,x_i+(c<<1))*one_over_scale2<=t2)?1:0;
- }
- frac=((double)i)/((double)(db_maxi(point_count,1)));
-
-#ifdef _VERBOSE_
- std::cout << "Inlier Percentage RobImageHomography: " << frac*100.0 << "% out of " << point_count << " constraints" << std::endl;
-#endif /*_VERBOSE_*/
-
- if(stat)
- {
- stat->nr_points=point_count;
- stat->one_over_scale2=one_over_scale2;
- stat->nr_inliers=i;
- stat->inlier_fraction=frac;
-
- stat->cost=db_RobImageHomography_Cost(H,point_count,x_i,xp_i,one_over_scale2);
- stat->model_dimension=0;
- /*stat->nr_parameters=;*/
-
- stat->lambda1=log(4.0);
- stat->lambda2=log(4.0*((double)db_maxi(1,stat->nr_points)));
- stat->lambda3=10.0;
- stat->gric=stat->cost+stat->lambda1*stat->model_dimension*((double)stat->nr_points)+stat->lambda2*((double)stat->nr_parameters);
- stat->inlier_evidence=((double)stat->nr_inliers)-stat->lambda3*((double)stat->nr_parameters);
- }
-
- return(frac);
-}
-
-/*Compute min_Jtf and upper right of JtJ. Return cost.*/
-inline double db_RobImageHomography_Jacobians(double JtJ[81],double min_Jtf[9],double H[9],int point_count,double *x_i,double *xp_i,double one_over_scale2)
-{
- double back,Jf_dx[18],f[2],temp,temp2;
- int i;
-
- db_Zero(JtJ,81);
- db_Zero(min_Jtf,9);
- for(back=0.0,i=0;i<point_count;i++)
- {
- /*Compute reprojection error vector and its Jacobian
- for this point*/
- db_DerivativeCauchyInhomHomographyReprojection(Jf_dx,f,xp_i+(i<<1),H,x_i+(i<<1),one_over_scale2);
- /*Perform
- min_Jtf-=Jf_dx*f[0] and
- min_Jtf-=(Jf_dx+9)*f[1] to accumulate -Jt%f*/
- db_RowOperation9(min_Jtf,Jf_dx,f[0]);
- db_RowOperation9(min_Jtf,Jf_dx+9,f[1]);
- /*Accumulate upper right of JtJ with outer product*/
- temp=Jf_dx[0]; temp2=Jf_dx[9];
- JtJ[0]+=temp*Jf_dx[0]+temp2*Jf_dx[9];
- JtJ[1]+=temp*Jf_dx[1]+temp2*Jf_dx[10];
- JtJ[2]+=temp*Jf_dx[2]+temp2*Jf_dx[11];
- JtJ[3]+=temp*Jf_dx[3]+temp2*Jf_dx[12];
- JtJ[4]+=temp*Jf_dx[4]+temp2*Jf_dx[13];
- JtJ[5]+=temp*Jf_dx[5]+temp2*Jf_dx[14];
- JtJ[6]+=temp*Jf_dx[6]+temp2*Jf_dx[15];
- JtJ[7]+=temp*Jf_dx[7]+temp2*Jf_dx[16];
- JtJ[8]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
- temp=Jf_dx[1]; temp2=Jf_dx[10];
- JtJ[10]+=temp*Jf_dx[1]+temp2*Jf_dx[10];
- JtJ[11]+=temp*Jf_dx[2]+temp2*Jf_dx[11];
- JtJ[12]+=temp*Jf_dx[3]+temp2*Jf_dx[12];
- JtJ[13]+=temp*Jf_dx[4]+temp2*Jf_dx[13];
- JtJ[14]+=temp*Jf_dx[5]+temp2*Jf_dx[14];
- JtJ[15]+=temp*Jf_dx[6]+temp2*Jf_dx[15];
- JtJ[16]+=temp*Jf_dx[7]+temp2*Jf_dx[16];
- JtJ[17]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
- temp=Jf_dx[2]; temp2=Jf_dx[11];
- JtJ[20]+=temp*Jf_dx[2]+temp2*Jf_dx[11];
- JtJ[21]+=temp*Jf_dx[3]+temp2*Jf_dx[12];
- JtJ[22]+=temp*Jf_dx[4]+temp2*Jf_dx[13];
- JtJ[23]+=temp*Jf_dx[5]+temp2*Jf_dx[14];
- JtJ[24]+=temp*Jf_dx[6]+temp2*Jf_dx[15];
- JtJ[25]+=temp*Jf_dx[7]+temp2*Jf_dx[16];
- JtJ[26]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
- temp=Jf_dx[3]; temp2=Jf_dx[12];
- JtJ[30]+=temp*Jf_dx[3]+temp2*Jf_dx[12];
- JtJ[31]+=temp*Jf_dx[4]+temp2*Jf_dx[13];
- JtJ[32]+=temp*Jf_dx[5]+temp2*Jf_dx[14];
- JtJ[33]+=temp*Jf_dx[6]+temp2*Jf_dx[15];
- JtJ[34]+=temp*Jf_dx[7]+temp2*Jf_dx[16];
- JtJ[35]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
- temp=Jf_dx[4]; temp2=Jf_dx[13];
- JtJ[40]+=temp*Jf_dx[4]+temp2*Jf_dx[13];
- JtJ[41]+=temp*Jf_dx[5]+temp2*Jf_dx[14];
- JtJ[42]+=temp*Jf_dx[6]+temp2*Jf_dx[15];
- JtJ[43]+=temp*Jf_dx[7]+temp2*Jf_dx[16];
- JtJ[44]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
- temp=Jf_dx[5]; temp2=Jf_dx[14];
- JtJ[50]+=temp*Jf_dx[5]+temp2*Jf_dx[14];
- JtJ[51]+=temp*Jf_dx[6]+temp2*Jf_dx[15];
- JtJ[52]+=temp*Jf_dx[7]+temp2*Jf_dx[16];
- JtJ[53]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
- temp=Jf_dx[6]; temp2=Jf_dx[15];
- JtJ[60]+=temp*Jf_dx[6]+temp2*Jf_dx[15];
- JtJ[61]+=temp*Jf_dx[7]+temp2*Jf_dx[16];
- JtJ[62]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
- temp=Jf_dx[7]; temp2=Jf_dx[16];
- JtJ[70]+=temp*Jf_dx[7]+temp2*Jf_dx[16];
- JtJ[71]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
- temp=Jf_dx[8]; temp2=Jf_dx[17];
- JtJ[80]+=temp*Jf_dx[8]+temp2*Jf_dx[17];
-
- /*Add square-sum to cost*/
- back+=db_sqr(f[0])+db_sqr(f[1]);
- }
-
- return(back);
-}
-
-/*Compute min_Jtf and upper right of JtJ. Return cost*/
-inline double db_RobCamRotation_Jacobians(double JtJ[9],double min_Jtf[3],double H[9],int point_count,double *x_i,double *xp_i,double one_over_scale2)
-{
- double back,Jf_dx[6],f[2];
- int i,j;
-
- db_Zero(JtJ,9);
- db_Zero(min_Jtf,3);
- for(back=0.0,i=0;i<point_count;i++)
- {
- /*Compute reprojection error vector and its Jacobian
- for this point*/
- j=(i<<1);
- db_DerivativeCauchyInhomRotationReprojection(Jf_dx,f,xp_i+j,H,x_i+j,one_over_scale2);
- /*Perform
- min_Jtf-=Jf_dx*f[0] and
- min_Jtf-=(Jf_dx+3)*f[1] to accumulate -Jt%f*/
- db_RowOperation3(min_Jtf,Jf_dx,f[0]);
- db_RowOperation3(min_Jtf,Jf_dx+3,f[1]);
- /*Accumulate upper right of JtJ with outer product*/
- JtJ[0]+=Jf_dx[0]*Jf_dx[0]+Jf_dx[3]*Jf_dx[3];
- JtJ[1]+=Jf_dx[0]*Jf_dx[1]+Jf_dx[3]*Jf_dx[4];
- JtJ[2]+=Jf_dx[0]*Jf_dx[2]+Jf_dx[3]*Jf_dx[5];
- JtJ[4]+=Jf_dx[1]*Jf_dx[1]+Jf_dx[4]*Jf_dx[4];
- JtJ[5]+=Jf_dx[1]*Jf_dx[2]+Jf_dx[4]*Jf_dx[5];
- JtJ[8]+=Jf_dx[2]*Jf_dx[2]+Jf_dx[5]*Jf_dx[5];
-
- /*Add square-sum to cost*/
- back+=db_sqr(f[0])+db_sqr(f[1]);
- }
-
- return(back);
-}
-
-void db_RobCamRotation_Polish(double H[9],int point_count,double *x_i,double *xp_i,double one_over_scale2,
- int max_iterations,double improvement_requirement)
-{
- int i,update,stop;
- double lambda,cost,current_cost;
- double JtJ[9],min_Jtf[3],dx[3],H_p_dx[9];
-
- lambda=0.001;
- for(update=1,stop=0,i=0;(stop<2) && (i<max_iterations);i++)
- {
- /*if first time since improvement, compute Jacobian and residual*/
- if(update)
- {
- current_cost=db_RobCamRotation_Jacobians(JtJ,min_Jtf,H,point_count,x_i,xp_i,one_over_scale2);
- update=0;
- }
-
-#ifdef _VERBOSE_
- /*std::cout << "Cost:" << current_cost << " ";*/
-#endif /*_VERBOSE_*/
-
- /*Come up with a hypothesis dx
- based on the current lambda*/
- db_Compute_dx_3x3(dx,JtJ,min_Jtf,lambda);
-
- /*Compute Cost(x+dx)*/
- db_UpdateRotation(H_p_dx,H,dx);
- cost=db_RobImageHomography_Cost(H_p_dx,point_count,x_i,xp_i,one_over_scale2);
-
- /*Is there an improvement?*/
- if(cost<current_cost)
- {
- /*improvement*/
- if(current_cost-cost<current_cost*improvement_requirement) stop++;
- else stop=0;
- lambda*=0.1;
- /*Move to the hypothesised position x+dx*/
- current_cost=cost;
- db_Copy9(H,H_p_dx);
- db_OrthonormalizeRotation(H);
- update=1;
-
-#ifdef _VERBOSE_
- std::cout << "Step" << i << "Imp,Lambda=" << lambda << "Cost:" << current_cost << std::endl;
-#endif /*_VERBOSE_*/
- }
- else
- {
- /*no improvement*/
- lambda*=10.0;
- stop=0;
- }
- }
-}
-
-inline void db_RobImageHomographyFetchJacobian(double **JtJ_ref,double *min_Jtf,double **JtJ_temp_ref,double *min_Jtf_temp,int n,int *fetch_vector)
-{
- int i,j,t;
- double *t1,*t2;
-
- for(i=0;i<n;i++)
- {
- t=fetch_vector[i];
- min_Jtf[i]=min_Jtf_temp[t];
- t1=JtJ_ref[i];
- t2=JtJ_temp_ref[t];
- for(j=i;j<n;j++)
- {
- t1[j]=t2[fetch_vector[j]];
- }
- }
-}
-
-inline void db_RobImageHomographyMultiplyJacobian(double **JtJ_ref,double *min_Jtf,double **JtJ_temp_ref,double *min_Jtf_temp,double **JE_dx_ref,int n)
-{
- double JtJ_JE[72],*JtJ_JE_ref[9];
-
- db_SetupMatrixRefs(JtJ_JE_ref,9,8,JtJ_JE);
-
- db_SymmetricExtendUpperToLower(JtJ_temp_ref,9,9);
- db_MultiplyMatricesAB(JtJ_JE_ref,JtJ_temp_ref,JE_dx_ref,9,9,n);
- db_UpperMultiplyMatricesAtB(JtJ_ref,JE_dx_ref,JtJ_JE_ref,n,9,n);
- db_MultiplyMatrixVectorAtb(min_Jtf,JE_dx_ref,min_Jtf_temp,n,9);
-}
-
-inline void db_RobImageHomographyJH_Js(double **JE_dx_ref,int j,double H[9])
-{
- /*Update of upper 2x2 is multiplication by
- [s 0][ cos(theta) sin(theta)]
- [0 s][-sin(theta) cos(theta)]*/
- JE_dx_ref[0][j]=H[0];
- JE_dx_ref[1][j]=H[1];
- JE_dx_ref[2][j]=0;
- JE_dx_ref[3][j]=H[2];
- JE_dx_ref[4][j]=H[3];
- JE_dx_ref[5][j]=0;
- JE_dx_ref[6][j]=0;
- JE_dx_ref[7][j]=0;
- JE_dx_ref[8][j]=0;
-}
-
-inline void db_RobImageHomographyJH_JR(double **JE_dx_ref,int j,double H[9])
-{
- /*Update of upper 2x2 is multiplication by
- [s 0][ cos(theta) sin(theta)]
- [0 s][-sin(theta) cos(theta)]*/
- JE_dx_ref[0][j]= H[3];
- JE_dx_ref[1][j]= H[4];
- JE_dx_ref[2][j]=0;
- JE_dx_ref[3][j]= -H[0];
- JE_dx_ref[4][j]= -H[1];
- JE_dx_ref[5][j]=0;
- JE_dx_ref[6][j]=0;
- JE_dx_ref[7][j]=0;
- JE_dx_ref[8][j]=0;
-}
-
-inline void db_RobImageHomographyJH_Jt(double **JE_dx_ref,int j,int k,double H[9])
-{
- JE_dx_ref[0][j]=0;
- JE_dx_ref[1][j]=0;
- JE_dx_ref[2][j]=1.0;
- JE_dx_ref[3][j]=0;
- JE_dx_ref[4][j]=0;
- JE_dx_ref[5][j]=0;
- JE_dx_ref[6][j]=0;
- JE_dx_ref[7][j]=0;
- JE_dx_ref[8][j]=0;
-
- JE_dx_ref[0][k]=0;
- JE_dx_ref[1][k]=0;
- JE_dx_ref[2][k]=0;
- JE_dx_ref[3][k]=0;
- JE_dx_ref[4][k]=0;
- JE_dx_ref[5][k]=1.0;
- JE_dx_ref[6][k]=0;
- JE_dx_ref[7][k]=0;
- JE_dx_ref[8][k]=0;
-}
-
-inline void db_RobImageHomographyJH_dRotFocal(double **JE_dx_ref,int j,int k,int l,int m,double H[9])
-{
- double f,fi,fi2;
- double R[9],J[9];
-
- /*Updated matrix is diag(f+df,f+df)*dR*R*diag(1/(f+df),1/(f+df),1)*/
- f=db_FocalAndRotFromCamRotFocalHomography(R,H);
- fi=db_SafeReciprocal(f);
- fi2=db_sqr(fi);
- db_JacobianOfRotatedPointStride(J,R,3);
- JE_dx_ref[0][j]= J[0];
- JE_dx_ref[1][j]= J[1];
- JE_dx_ref[2][j]=f* J[2];
- JE_dx_ref[3][j]= J[3];
- JE_dx_ref[4][j]= J[4];
- JE_dx_ref[5][j]=f* J[5];
- JE_dx_ref[6][j]=fi*J[6];
- JE_dx_ref[7][j]=fi*J[7];
- JE_dx_ref[8][j]= J[8];
- db_JacobianOfRotatedPointStride(J,R+1,3);
- JE_dx_ref[0][k]= J[0];
- JE_dx_ref[1][k]= J[1];
- JE_dx_ref[2][k]=f* J[2];
- JE_dx_ref[3][k]= J[3];
- JE_dx_ref[4][k]= J[4];
- JE_dx_ref[5][k]=f* J[5];
- JE_dx_ref[6][k]=fi*J[6];
- JE_dx_ref[7][k]=fi*J[7];
- JE_dx_ref[8][k]= J[8];
- db_JacobianOfRotatedPointStride(J,R+2,3);
- JE_dx_ref[0][l]= J[0];
- JE_dx_ref[1][l]= J[1];
- JE_dx_ref[2][l]=f* J[2];
- JE_dx_ref[3][l]= J[3];
- JE_dx_ref[4][l]= J[4];
- JE_dx_ref[5][l]=f* J[5];
- JE_dx_ref[6][l]=fi*J[6];
- JE_dx_ref[7][l]=fi*J[7];
- JE_dx_ref[8][l]= J[8];
-
- JE_dx_ref[0][m]=0;
- JE_dx_ref[1][m]=0;
- JE_dx_ref[2][m]=H[2];
- JE_dx_ref[3][m]=0;
- JE_dx_ref[4][m]=0;
- JE_dx_ref[5][m]=H[5];
- JE_dx_ref[6][m]= -fi2*H[6];
- JE_dx_ref[7][m]= -fi2*H[7];
- JE_dx_ref[8][m]=0;
-}
-
-inline double db_RobImageHomography_Jacobians_Generic(double *JtJ_ref[8],double min_Jtf[8],int *num_param,int *frozen_coord,double H[9],int point_count,double *x_i,double *xp_i,int homography_type,double one_over_scale2)
-{
- double back;
- int i,j,fetch_vector[8],n;
- double JtJ_temp[81],min_Jtf_temp[9],JE_dx[72];
- double *JE_dx_ref[9],*JtJ_temp_ref[9];
-
- /*Compute cost and JtJ,min_Jtf with respect to H*/
- back=db_RobImageHomography_Jacobians(JtJ_temp,min_Jtf_temp,H,point_count,x_i,xp_i,one_over_scale2);
-
- /*Compute JtJ,min_Jtf with respect to the right parameters
- The formulas are
- JtJ=transpose(JE_dx)*JtJ*JE_dx and
- min_Jtf=transpose(JE_dx)*min_Jtf,
- where the 9xN matrix JE_dx is the Jacobian of H with respect
- to the update*/
- db_SetupMatrixRefs(JtJ_temp_ref,9,9,JtJ_temp);
- db_SetupMatrixRefs(JE_dx_ref,9,8,JE_dx);
- switch(homography_type)
- {
- case DB_HOMOGRAPHY_TYPE_SIMILARITY:
- case DB_HOMOGRAPHY_TYPE_SIMILARITY_U:
- n=4;
- db_RobImageHomographyJH_Js(JE_dx_ref,0,H);
- db_RobImageHomographyJH_JR(JE_dx_ref,1,H);
- db_RobImageHomographyJH_Jt(JE_dx_ref,2,3,H);
- db_RobImageHomographyMultiplyJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,JE_dx_ref,n);
- break;
- case DB_HOMOGRAPHY_TYPE_ROTATION:
- case DB_HOMOGRAPHY_TYPE_ROTATION_U:
- n=1;
- db_RobImageHomographyJH_JR(JE_dx_ref,0,H);
- db_RobImageHomographyMultiplyJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,JE_dx_ref,n);
- break;
- case DB_HOMOGRAPHY_TYPE_SCALING:
- n=1;
- db_RobImageHomographyJH_Js(JE_dx_ref,0,H);
- db_RobImageHomographyMultiplyJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,JE_dx_ref,n);
- break;
- case DB_HOMOGRAPHY_TYPE_S_T:
- n=3;
- db_RobImageHomographyJH_Js(JE_dx_ref,0,H);
- db_RobImageHomographyJH_Jt(JE_dx_ref,1,2,H);
- db_RobImageHomographyMultiplyJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,JE_dx_ref,n);
- break;
- case DB_HOMOGRAPHY_TYPE_R_T:
- n=3;
- db_RobImageHomographyJH_JR(JE_dx_ref,0,H);
- db_RobImageHomographyJH_Jt(JE_dx_ref,1,2,H);
- db_RobImageHomographyMultiplyJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,JE_dx_ref,n);
- break;
- case DB_HOMOGRAPHY_TYPE_R_S:
- n=2;
- db_RobImageHomographyJH_Js(JE_dx_ref,0,H);
- db_RobImageHomographyJH_JR(JE_dx_ref,1,H);
- db_RobImageHomographyMultiplyJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,JE_dx_ref,n);
- break;
-
- case DB_HOMOGRAPHY_TYPE_TRANSLATION:
- n=2;
- fetch_vector[0]=2;
- fetch_vector[1]=5;
- db_RobImageHomographyFetchJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,n,fetch_vector);
- break;
- case DB_HOMOGRAPHY_TYPE_AFFINE:
- n=6;
- fetch_vector[0]=0;
- fetch_vector[1]=1;
- fetch_vector[2]=2;
- fetch_vector[3]=3;
- fetch_vector[4]=4;
- fetch_vector[5]=5;
- db_RobImageHomographyFetchJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,n,fetch_vector);
- break;
- case DB_HOMOGRAPHY_TYPE_PROJECTIVE:
- n=8;
- *frozen_coord=db_MaxAbsIndex9(H);
- for(j=0,i=0;i<9;i++) if(i!=(*frozen_coord))
- {
- fetch_vector[j]=i;
- j++;
- }
- db_RobImageHomographyFetchJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,n,fetch_vector);
- break;
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F:
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F_UD:
- n=4;
- db_RobImageHomographyJH_dRotFocal(JE_dx_ref,0,1,2,3,H);
- db_RobImageHomographyMultiplyJacobian(JtJ_ref,min_Jtf,JtJ_temp_ref,min_Jtf_temp,JE_dx_ref,n);
- break;
- }
- *num_param=n;
-
- return(back);
-}
-
-inline void db_ImageHomographyUpdateGeneric(double H_p_dx[9],double H[9],double *dx,int homography_type,int frozen_coord)
-{
- switch(homography_type)
- {
- case DB_HOMOGRAPHY_TYPE_SIMILARITY:
- case DB_HOMOGRAPHY_TYPE_SIMILARITY_U:
- db_Copy9(H_p_dx,H);
- db_MultiplyScaleOntoImageHomography(H,1.0+dx[0]);
- db_MultiplyRotationOntoImageHomography(H,dx[1]);
- H_p_dx[2]+=dx[2];
- H_p_dx[5]+=dx[3];
- break;
- case DB_HOMOGRAPHY_TYPE_ROTATION:
- case DB_HOMOGRAPHY_TYPE_ROTATION_U:
- db_MultiplyRotationOntoImageHomography(H,dx[0]);
- break;
- case DB_HOMOGRAPHY_TYPE_SCALING:
- db_MultiplyScaleOntoImageHomography(H,1.0+dx[0]);
- break;
- case DB_HOMOGRAPHY_TYPE_S_T:
- db_Copy9(H_p_dx,H);
- db_MultiplyScaleOntoImageHomography(H,1.0+dx[0]);
- H_p_dx[2]+=dx[1];
- H_p_dx[5]+=dx[2];
- break;
- case DB_HOMOGRAPHY_TYPE_R_T:
- db_Copy9(H_p_dx,H);
- db_MultiplyRotationOntoImageHomography(H,dx[0]);
- H_p_dx[2]+=dx[1];
- H_p_dx[5]+=dx[2];
- break;
- case DB_HOMOGRAPHY_TYPE_R_S:
- db_Copy9(H_p_dx,H);
- db_MultiplyScaleOntoImageHomography(H,1.0+dx[0]);
- db_MultiplyRotationOntoImageHomography(H,dx[1]);
- break;
- case DB_HOMOGRAPHY_TYPE_TRANSLATION:
- db_Copy9(H_p_dx,H);
- H_p_dx[2]+=dx[0];
- H_p_dx[5]+=dx[1];
- break;
- case DB_HOMOGRAPHY_TYPE_AFFINE:
- db_UpdateImageHomographyAffine(H_p_dx,H,dx);
- break;
- case DB_HOMOGRAPHY_TYPE_PROJECTIVE:
- db_UpdateImageHomographyProjective(H_p_dx,H,dx,frozen_coord);
- break;
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F:
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F_UD:
- db_UpdateRotFocalHomography(H_p_dx,H,dx);
- break;
- }
-}
-
-void db_RobCamRotation_Polish_Generic(double H[9],int point_count,int homography_type,double *x_i,double *xp_i,double one_over_scale2,
- int max_iterations,double improvement_requirement)
-{
- int i,update,stop,n;
- int frozen_coord = 0;
- double lambda,cost,current_cost;
- double JtJ[72],min_Jtf[9],dx[8],H_p_dx[9];
- double *JtJ_ref[9],d[8];
-
- lambda=0.001;
- for(update=1,stop=0,i=0;(stop<2) && (i<max_iterations);i++)
- {
- /*if first time since improvement, compute Jacobian and residual*/
- if(update)
- {
- db_SetupMatrixRefs(JtJ_ref,9,8,JtJ);
- current_cost=db_RobImageHomography_Jacobians_Generic(JtJ_ref,min_Jtf,&n,&frozen_coord,H,point_count,x_i,xp_i,homography_type,one_over_scale2);
- update=0;
- }
-
-#ifdef _VERBOSE_
- /*std::cout << "Cost:" << current_cost << " ";*/
-#endif /*_VERBOSE_*/
-
- /*Come up with a hypothesis dx
- based on the current lambda*/
- db_Compute_dx(dx,JtJ_ref,min_Jtf,lambda,d,n);
-
- /*Compute Cost(x+dx)*/
- db_ImageHomographyUpdateGeneric(H_p_dx,H,dx,homography_type,frozen_coord);
- cost=db_RobImageHomography_Cost(H_p_dx,point_count,x_i,xp_i,one_over_scale2);
-
- /*Is there an improvement?*/
- if(cost<current_cost)
- {
- /*improvement*/
- if(current_cost-cost<current_cost*improvement_requirement) stop++;
- else stop=0;
- lambda*=0.1;
- /*Move to the hypothesised position x+dx*/
- current_cost=cost;
- db_Copy9(H,H_p_dx);
- update=1;
-
-#ifdef _VERBOSE_
- std::cout << "Step" << i << "Imp,Lambda=" << lambda << "Cost:" << current_cost << std::endl;
-#endif /*_VERBOSE_*/
- }
- else
- {
- /*no improvement*/
- lambda*=10.0;
- stop=0;
- }
- }
-}
-void db_RobImageHomography(
- /*Best homography*/
- double H[9],
- /*2DPoint to 2DPoint constraints
- Points are assumed to be given in
- homogenous coordinates*/
- double *im, double *im_p,
- /*Nr of points in total*/
- int nr_points,
- /*Calibration matrices
- used to normalize the points*/
- double K[9],
- double Kp[9],
- /*Pre-allocated space temp_d
- should point to at least
- 12*nr_samples+10*nr_points
- allocated positions*/
- double *temp_d,
- /*Pre-allocated space temp_i
- should point to at least
- max(nr_samples,nr_points)
- allocated positions*/
- int *temp_i,
- int homography_type,
- db_Statistics *stat,
- int max_iterations,
- int max_points,
- double scale,
- int nr_samples,
- int chunk_size,
- /////////////////////////////////////////////
- // regular use: set outlierremoveflagE =0;
- // flag for the outlier removal
- int outlierremoveflagE,
- // if flag is 1, then the following variables
- // need the input
- //////////////////////////////////////
- // 3D coordinates
- double *wp,
- // its corresponding stereo pair's points
- double *im_r,
- // raw image coordinates
- double *im_raw, double *im_raw_p,
- // final matches
- int *finalNumE)
-{
- /*Random seed*/
- int r_seed;
-
- int point_count_new;
- /*Counters*/
- int i,j,c,point_count,hyp_count;
- int last_hyp,new_last_hyp,last_corr;
- int pos,point_pos,last_point;
- /*Accumulator*/
- double acc;
- /*Hypothesis pointer*/
- double *hyp_point;
- /*Random sample*/
- int s[4];
- /*Pivot for hypothesis pruning*/
- double pivot;
- /*Best hypothesis position*/
- int best_pos;
- /*Best score*/
- double lowest_cost;
- /*One over the squared scale of
- Cauchy distribution*/
- double one_over_scale2;
- /*temporary pointers*/
- double *x_i_temp,*xp_i_temp;
- /*Temporary space for inverse calibration matrices*/
- double K_inv[9];
- double Kp_inv[9];
- /*Temporary space for homography*/
- double H_temp[9],H_temp2[9];
- /*Pointers to homogenous coordinates*/
- double *x_h_point,*xp_h_point;
- /*Array of pointers to inhomogenous coordinates*/
- double *X[3],*Xp[3];
- /*Similarity parameters*/
- int orientation_preserving,allow_scaling,allow_rotation,allow_translation,sample_size;
-
- /*Homogenous coordinates of image points in first image*/
- double *x_h;
- /*Homogenous coordinates of image points in second image*/
- double *xp_h;
- /*Inhomogenous coordinates of image points in first image*/
- double *x_i;
- /*Inhomogenous coordinates of image points in second image*/
- double *xp_i;
- /*Homography hypotheses*/
- double *hyp_H_array;
- /*Cost array*/
- double *hyp_cost_array;
- /*Permutation of the hypotheses*/
- int *hyp_perm;
- /*Sample of the points*/
- int *point_perm;
- /*Temporary space for quick-select
- 2*nr_samples*/
- double *temp_select;
-
- /*Get inverse calibration matrices*/
- db_InvertCalibrationMatrix(K_inv,K);
- db_InvertCalibrationMatrix(Kp_inv,Kp);
- /*Compute scale coefficient*/
- one_over_scale2=1.0/(scale*scale);
- /*Initialize random seed*/
- r_seed=12345;
- /*Set pointers to pre-allocated space*/
- hyp_cost_array=temp_d;
- hyp_H_array=temp_d+nr_samples;
- temp_select=temp_d+10*nr_samples;
- x_h=temp_d+12*nr_samples;
- xp_h=temp_d+12*nr_samples+3*nr_points;
- x_i=temp_d+12*nr_samples+6*nr_points;
- xp_i=temp_d+12*nr_samples+8*nr_points;
- hyp_perm=temp_i;
- point_perm=temp_i;
-
- /*Prepare a randomly permuted subset of size
- point_count from the input points*/
-
- point_count=db_mini(nr_points,(int)(chunk_size*log((double)nr_samples)/DB_LN2));
-
- point_count_new = point_count;
-
- for(i=0;i<nr_points;i++) point_perm[i]=i;
-
- for(last_point=nr_points-1,i=0;i<point_count;i++,last_point--)
- {
- pos=db_RandomInt(r_seed,last_point);
- point_pos=point_perm[pos];
- point_perm[pos]=point_perm[last_point];
-
- /*Normalize image points with calibration
- matrices and move them to x_h and xp_h*/
- c=3*point_pos;
- j=3*i;
- x_h_point=x_h+j;
- xp_h_point=xp_h+j;
- db_Multiply3x3_3x1(x_h_point,K_inv,im+c);
- db_Multiply3x3_3x1(xp_h_point,Kp_inv,im_p+c);
-
- db_HomogenousNormalize3(x_h_point);
- db_HomogenousNormalize3(xp_h_point);
-
- /*Dehomogenize image points and move them
- to x_i and xp_i*/
- c=(i<<1);
- db_DeHomogenizeImagePoint(x_i+c,x_h_point); // 2-dimension
- db_DeHomogenizeImagePoint(xp_i+c,xp_h_point); //2-dimension
- }
-
-
- /*Generate Hypotheses*/
- hyp_count=0;
- switch(homography_type)
- {
- case DB_HOMOGRAPHY_TYPE_SIMILARITY:
- case DB_HOMOGRAPHY_TYPE_SIMILARITY_U:
- case DB_HOMOGRAPHY_TYPE_TRANSLATION:
- case DB_HOMOGRAPHY_TYPE_ROTATION:
- case DB_HOMOGRAPHY_TYPE_ROTATION_U:
- case DB_HOMOGRAPHY_TYPE_SCALING:
- case DB_HOMOGRAPHY_TYPE_S_T:
- case DB_HOMOGRAPHY_TYPE_R_T:
- case DB_HOMOGRAPHY_TYPE_R_S:
-
- switch(homography_type)
- {
- case DB_HOMOGRAPHY_TYPE_SIMILARITY:
- orientation_preserving=1;
- allow_scaling=1;
- allow_rotation=1;
- allow_translation=1;
- sample_size=2;
- break;
- case DB_HOMOGRAPHY_TYPE_SIMILARITY_U:
- orientation_preserving=0;
- allow_scaling=1;
- allow_rotation=1;
- allow_translation=1;
- sample_size=3;
- break;
- case DB_HOMOGRAPHY_TYPE_TRANSLATION:
- orientation_preserving=1;
- allow_scaling=0;
- allow_rotation=0;
- allow_translation=1;
- sample_size=1;
- break;
- case DB_HOMOGRAPHY_TYPE_ROTATION:
- orientation_preserving=1;
- allow_scaling=0;
- allow_rotation=1;
- allow_translation=0;
- sample_size=1;
- break;
- case DB_HOMOGRAPHY_TYPE_ROTATION_U:
- orientation_preserving=0;
- allow_scaling=0;
- allow_rotation=1;
- allow_translation=0;
- sample_size=2;
- break;
- case DB_HOMOGRAPHY_TYPE_SCALING:
- orientation_preserving=1;
- allow_scaling=1;
- allow_rotation=0;
- allow_translation=0;
- sample_size=1;
- break;
- case DB_HOMOGRAPHY_TYPE_S_T:
- orientation_preserving=1;
- allow_scaling=1;
- allow_rotation=0;
- allow_translation=1;
- sample_size=2;
- break;
- case DB_HOMOGRAPHY_TYPE_R_T:
- orientation_preserving=1;
- allow_scaling=0;
- allow_rotation=1;
- allow_translation=1;
- sample_size=2;
- break;
- case DB_HOMOGRAPHY_TYPE_R_S:
- orientation_preserving=1;
- allow_scaling=1;
- allow_rotation=0;
- allow_translation=0;
- sample_size=1;
- break;
- }
-
- if(point_count>=sample_size) for(i=0;i<nr_samples;i++)
- {
- db_RandomSample(s,3,point_count,r_seed);
- X[0]= &x_i[s[0]<<1];
- X[1]= &x_i[s[1]<<1];
- X[2]= &x_i[s[2]<<1];
- Xp[0]= &xp_i[s[0]<<1];
- Xp[1]= &xp_i[s[1]<<1];
- Xp[2]= &xp_i[s[2]<<1];
- db_StitchSimilarity2D(&hyp_H_array[9*hyp_count],Xp,X,sample_size,orientation_preserving,
- allow_scaling,allow_rotation,allow_translation);
- hyp_count++;
- }
- break;
-
- case DB_HOMOGRAPHY_TYPE_CAMROTATION:
- if(point_count>=2) for(i=0;i<nr_samples;i++)
- {
- db_RandomSample(s,2,point_count,r_seed);
- db_StitchCameraRotation_2Points(&hyp_H_array[9*hyp_count],
- &x_h[3*s[0]],&x_h[3*s[1]],
- &xp_h[3*s[0]],&xp_h[3*s[1]]);
- hyp_count++;
- }
- break;
-
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F:
- if(point_count>=3) for(i=0;i<nr_samples;i++)
- {
- db_RandomSample(s,3,point_count,r_seed);
- hyp_count+=db_StitchRotationCommonFocalLength_3Points(&hyp_H_array[9*hyp_count],
- &x_h[3*s[0]],&x_h[3*s[1]],&x_h[3*s[2]],
- &xp_h[3*s[0]],&xp_h[3*s[1]],&xp_h[3*s[2]]);
- }
- break;
-
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F_UD:
- if(point_count>=3) for(i=0;i<nr_samples;i++)
- {
- db_RandomSample(s,3,point_count,r_seed);
- hyp_count+=db_StitchRotationCommonFocalLength_3Points(&hyp_H_array[9*hyp_count],
- &x_h[3*s[0]],&x_h[3*s[1]],&x_h[3*s[2]],
- &xp_h[3*s[0]],&xp_h[3*s[1]],&xp_h[3*s[2]],NULL,0);
- }
- break;
-
- case DB_HOMOGRAPHY_TYPE_AFFINE:
- if(point_count>=3) for(i=0;i<nr_samples;i++)
- {
- db_RandomSample(s,3,point_count,r_seed);
- db_StitchAffine2D_3Points(&hyp_H_array[9*hyp_count],
- &x_h[3*s[0]],&x_h[3*s[1]],&x_h[3*s[2]],
- &xp_h[3*s[0]],&xp_h[3*s[1]],&xp_h[3*s[2]]);
- hyp_count++;
- }
- break;
-
- case DB_HOMOGRAPHY_TYPE_PROJECTIVE:
- default:
- if(point_count>=4) for(i=0;i<nr_samples;i++)
- {
- db_RandomSample(s,4,point_count,r_seed);
- db_StitchProjective2D_4Points(&hyp_H_array[9*hyp_count],
- &x_h[3*s[0]],&x_h[3*s[1]],&x_h[3*s[2]],&x_h[3*s[3]],
- &xp_h[3*s[0]],&xp_h[3*s[1]],&xp_h[3*s[2]],&xp_h[3*s[3]]);
- hyp_count++;
- }
- }
-
- if(hyp_count)
- {
- /*Count cost in chunks and decimate hypotheses
- until only one remains or the correspondences are
- exhausted*/
- for(i=0;i<hyp_count;i++)
- {
- hyp_perm[i]=i;
- hyp_cost_array[i]=0.0;
- }
- for(i=0,last_hyp=hyp_count-1;(last_hyp>0) && (i<point_count);i+=chunk_size)
- {
- /*Update cost with the next chunk*/
- last_corr=db_mini(i+chunk_size-1,point_count-1);
- for(j=0;j<=last_hyp;j++)
- {
- hyp_point=hyp_H_array+9*hyp_perm[j];
- for(c=i;c<=last_corr;)
- {
- /*Take log of product of ten reprojection
- errors to reduce nr of expensive log operations*/
- if(c+9<=last_corr)
- {
- x_i_temp=x_i+(c<<1);
- xp_i_temp=xp_i+(c<<1);
-
- acc=db_ExpCauchyInhomogenousHomographyError(xp_i_temp,hyp_point,x_i_temp,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+2,hyp_point,x_i_temp+2,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+4,hyp_point,x_i_temp+4,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+6,hyp_point,x_i_temp+6,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+8,hyp_point,x_i_temp+8,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+10,hyp_point,x_i_temp+10,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+12,hyp_point,x_i_temp+12,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+14,hyp_point,x_i_temp+14,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+16,hyp_point,x_i_temp+16,one_over_scale2);
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i_temp+18,hyp_point,x_i_temp+18,one_over_scale2);
- c+=10;
- }
- else
- {
- for(acc=1.0;c<=last_corr;c++)
- {
- acc*=db_ExpCauchyInhomogenousHomographyError(xp_i+(c<<1),hyp_point,x_i+(c<<1),one_over_scale2);
- }
- }
- hyp_cost_array[j]+=log(acc);
- }
- }
- if (chunk_size<point_count){
- /*Prune out half of the hypotheses*/
- new_last_hyp=(last_hyp+1)/2-1;
- pivot=db_LeanQuickSelect(hyp_cost_array,last_hyp+1,new_last_hyp,temp_select);
- for(j=0,c=0;(j<=last_hyp) && (c<=new_last_hyp);j++)
- {
- if(hyp_cost_array[j]<=pivot)
- {
- hyp_cost_array[c]=hyp_cost_array[j];
- hyp_perm[c]=hyp_perm[j];
- c++;
- }
- }
- last_hyp=new_last_hyp;
- }
- }
- /*Find the best hypothesis*/
- lowest_cost=hyp_cost_array[0];
- best_pos=0;
- for(j=1;j<=last_hyp;j++)
- {
- if(hyp_cost_array[j]<lowest_cost)
- {
- lowest_cost=hyp_cost_array[j];
- best_pos=j;
- }
- }
-
- /*Move the best hypothesis*/
- db_Copy9(H_temp,hyp_H_array+9*hyp_perm[best_pos]);
-
- // outlier removal
- if (outlierremoveflagE) // no polishment needed
- {
- point_count_new = db_RemoveOutliers_Homography(H_temp,x_i,xp_i,wp,im,im_p,im_r,im_raw,im_raw_p,point_count,one_over_scale2);
- }
- else
- {
- /*Polish*/
- switch(homography_type)
- {
- case DB_HOMOGRAPHY_TYPE_SIMILARITY:
- case DB_HOMOGRAPHY_TYPE_SIMILARITY_U:
- case DB_HOMOGRAPHY_TYPE_TRANSLATION:
- case DB_HOMOGRAPHY_TYPE_ROTATION:
- case DB_HOMOGRAPHY_TYPE_ROTATION_U:
- case DB_HOMOGRAPHY_TYPE_SCALING:
- case DB_HOMOGRAPHY_TYPE_S_T:
- case DB_HOMOGRAPHY_TYPE_R_T:
- case DB_HOMOGRAPHY_TYPE_R_S:
- case DB_HOMOGRAPHY_TYPE_AFFINE:
- case DB_HOMOGRAPHY_TYPE_PROJECTIVE:
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F:
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F_UD:
- db_RobCamRotation_Polish_Generic(H_temp,db_mini(point_count,max_points),homography_type,x_i,xp_i,one_over_scale2,max_iterations);
- break;
- case DB_HOMOGRAPHY_TYPE_CAMROTATION:
- db_RobCamRotation_Polish(H_temp,db_mini(point_count,max_points),x_i,xp_i,one_over_scale2,max_iterations);
- break;
- }
-
- }
-
- }
- else db_Identity3x3(H_temp);
-
- switch(homography_type)
- {
- case DB_HOMOGRAPHY_TYPE_PROJECTIVE:
- if(stat) stat->nr_parameters=8;
- break;
- case DB_HOMOGRAPHY_TYPE_AFFINE:
- if(stat) stat->nr_parameters=6;
- break;
- case DB_HOMOGRAPHY_TYPE_SIMILARITY:
- case DB_HOMOGRAPHY_TYPE_SIMILARITY_U:
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F:
- case DB_HOMOGRAPHY_TYPE_CAMROTATION_F_UD:
- if(stat) stat->nr_parameters=4;
- break;
- case DB_HOMOGRAPHY_TYPE_CAMROTATION:
- if(stat) stat->nr_parameters=3;
- break;
- case DB_HOMOGRAPHY_TYPE_TRANSLATION:
- case DB_HOMOGRAPHY_TYPE_S_T:
- case DB_HOMOGRAPHY_TYPE_R_T:
- case DB_HOMOGRAPHY_TYPE_R_S:
- if(stat) stat->nr_parameters=2;
- break;
- case DB_HOMOGRAPHY_TYPE_ROTATION:
- case DB_HOMOGRAPHY_TYPE_ROTATION_U:
- case DB_HOMOGRAPHY_TYPE_SCALING:
- if(stat) stat->nr_parameters=1;
- break;
- }
-
- db_RobImageHomography_Statistics(H_temp,db_mini(point_count,max_points),x_i,xp_i,one_over_scale2,stat);
-
- /*Put on the calibration matrices*/
- db_Multiply3x3_3x3(H_temp2,H_temp,K_inv);
- db_Multiply3x3_3x3(H,Kp,H_temp2);
-
- if (finalNumE)
- *finalNumE = point_count_new;
-
-}
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_rob_image_homography.h b/jni_mosaic/feature_stab/db_vlvm/db_rob_image_homography.h
deleted file mode 100644
index 59cde7d..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_rob_image_homography.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_rob_image_homography.h,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_ROB_IMAGE_HOMOGRAPHY
-#define DB_ROB_IMAGE_HOMOGRAPHY
-
-#include "db_utilities.h"
-#include "db_robust.h"
-#include "db_metrics.h"
-
-#include <stdlib.h> // for NULL
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMRobImageHomography (LM) Robust Image Homography
- */
-/*\{*/
-
-#define DB_HOMOGRAPHY_TYPE_DEFAULT 0
-#define DB_HOMOGRAPHY_TYPE_PROJECTIVE 0
-#define DB_HOMOGRAPHY_TYPE_AFFINE 1
-#define DB_HOMOGRAPHY_TYPE_SIMILARITY 2
-#define DB_HOMOGRAPHY_TYPE_SIMILARITY_U 3
-#define DB_HOMOGRAPHY_TYPE_TRANSLATION 4
-#define DB_HOMOGRAPHY_TYPE_ROTATION 5
-#define DB_HOMOGRAPHY_TYPE_ROTATION_U 6
-#define DB_HOMOGRAPHY_TYPE_SCALING 7
-#define DB_HOMOGRAPHY_TYPE_S_T 8
-#define DB_HOMOGRAPHY_TYPE_R_T 9
-#define DB_HOMOGRAPHY_TYPE_R_S 10
-#define DB_HOMOGRAPHY_TYPE_CAMROTATION 11
-#define DB_HOMOGRAPHY_TYPE_CAMROTATION_F 12
-#define DB_HOMOGRAPHY_TYPE_CAMROTATION_F_UD 13
-
-/*!
-Solve for homography H such that xp~Hx
-\param H best homography
-
-2D point to 2D point constraints:
-
-\param im first image points
-\param im_p second image points
-\param nr_points number of points
-
-Calibration matrices:
-
-\param K first camera
-\param Kp second camera
-
- Temporary space:
-
- \param temp_d pre-allocated space of size 12*nr_samples+10*nr_points doubles
- \param temp_i pre-allocated space of size max(nr_samples,nr_points) ints
-
- Statistics for this estimation
-
- \param stat NULL - do not compute
-
- \param homography_type see DB_HOMOGRAPHY_TYPE_* definitions above
-
- Estimation parameters:
-
- \param max_iterations max number of polishing steps
- \param max_points only use this many points
- \param scale Cauchy scale coefficient (see db_ExpCauchyReprojectionError() )
- \param nr_samples number of times to compute a hypothesis
- \param chunk_size size of cost chunks
-*/
-DB_API void db_RobImageHomography(
- /*Best homography*/
- double H[9],
- /*2DPoint to 2DPoint constraints
- Points are assumed to be given in
- homogenous coordinates*/
- double *im,double *im_p,
- /*Nr of points in total*/
- int nr_points,
- /*Calibration matrices
- used to normalize the points*/
- double K[9],
- double Kp[9],
- /*Pre-allocated space temp_d
- should point to at least
- 12*nr_samples+10*nr_points
- allocated positions*/
- double *temp_d,
- /*Pre-allocated space temp_i
- should point to at least
- max(nr_samples,nr_points)
- allocated positions*/
- int *temp_i,
- int homography_type=DB_HOMOGRAPHY_TYPE_DEFAULT,
- db_Statistics *stat=NULL,
- int max_iterations=DB_DEFAULT_MAX_ITERATIONS,
- int max_points=DB_DEFAULT_MAX_POINTS,
- double scale=DB_POINT_STANDARDDEV,
- int nr_samples=DB_DEFAULT_NR_SAMPLES,
- int chunk_size=DB_DEFAULT_CHUNK_SIZE,
- ///////////////////////////////////////////////////
- // flag for the outlier removal
- int outlierremoveflagE = 0,
- // if flag is 1, then the following variables
- // need to input
- ///////////////////////////////////////////////////
- // 3D coordinates
- double *wp=NULL,
- // its corresponding stereo pair's points
- double *im_r=NULL,
- // raw image coordinates
- double *im_raw=NULL, double *im_raw_p=NULL,
- // final matches
- int *final_NumE=0);
-
-DB_API double db_RobImageHomography_Cost(double H[9],int point_count,double *x_i,
- double *xp_i,double one_over_scale2);
-
-
-DB_API void db_RobCamRotation_Polish(double H[9],int point_count,double *x_i,
- double *xp_i, double one_over_scale2,
- int max_iterations=DB_DEFAULT_MAX_ITERATIONS,
- double improvement_requirement=DB_DEFAULT_IMP_REQ);
-
-
-DB_API void db_RobCamRotation_Polish_Generic(double H[9],int point_count,int homography_type,
- double *x_i,double *xp_i,double one_over_scale2,
- int max_iterations=DB_DEFAULT_MAX_ITERATIONS,
- double improvement_requirement=DB_DEFAULT_IMP_REQ);
-
-
-#endif /* DB_ROB_IMAGE_HOMOGRAPHY */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_robust.h b/jni_mosaic/feature_stab/db_vlvm/db_robust.h
deleted file mode 100644
index be0794c..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_robust.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_robust.h,v 1.4 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_ROBUST
-#define DB_ROBUST
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMRobust (LM) Robust Estimation
- */
-
-/*!
- \struct db_Statistics
- \ingroup LMRobust
- \brief (LnM) Sampling problem statistics
- \date Mon Sep 10 10:28:08 EDT 2007
- \par Copyright: 2007 Sarnoff Corporation. All Rights Reserved
- */
- struct db_stat_struct
- {
- int nr_points;
- int nr_inliers;
- double inlier_fraction;
- double cost;
- double one_over_scale2;
- double lambda1;
- double lambda2;
- double lambda3;
- int nr_parameters;
- int model_dimension;
- double gric;
- double inlier_evidence;
- double posestd[6];
- double rotationvecCov[9];
- double translationvecCov[9];
- int posecov_inliercount;
- int posecovready;
- double median_reprojection_error;
- };
- typedef db_stat_struct db_Statistics;
-
-#endif /* DB_ROBUST */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities.cpp b/jni_mosaic/feature_stab/db_vlvm/db_utilities.cpp
deleted file mode 100644
index ce2093b..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities.cpp,v 1.4 2011/06/17 14:03:31 mbansal Exp $ */
-
-#include "db_utilities.h"
-#include <string.h>
-#include <stdio.h>
-
-float** db_SetupImageReferences_f(float *im,int w,int h)
-{
- int i;
- float **img;
- assert(im);
- img=new float* [h];
- for(i=0;i<h;i++)
- {
- img[i]=im+w*i;
- }
- return(img);
-}
-
-unsigned char** db_SetupImageReferences_u(unsigned char *im,int w,int h)
-{
- int i;
- unsigned char **img;
-
- assert(im);
-
- img=new unsigned char* [h];
- for(i=0;i<h;i++)
- {
- img[i]=im+w*i;
- }
- return(img);
-}
-float** db_AllocImage_f(int w,int h,int over_allocation)
-{
- float **img,*im;
-
- im=new float [w*h+over_allocation];
- img=db_SetupImageReferences_f(im,w,h);
-
- return(img);
-}
-
-unsigned char** db_AllocImage_u(int w,int h,int over_allocation)
-{
- unsigned char **img,*im;
-
- im=new unsigned char [w*h+over_allocation];
- img=db_SetupImageReferences_u(im,w,h);
-
- return(img);
-}
-
-void db_FreeImage_f(float **img,int h)
-{
- delete [] (img[0]);
- delete [] img;
-}
-
-void db_FreeImage_u(unsigned char **img,int h)
-{
- delete [] (img[0]);
- delete [] img;
-}
-
-// ----------------------------------------------------------------------------------------------------------- ;
-//
-// copy image (source to destination)
-// ---> must be a 2D image array with the same image size
-// ---> the size of the input and output images must be same
-//
-// ------------------------------------------------------------------------------------------------------------ ;
-void db_CopyImage_u(unsigned char **d,const unsigned char * const *s, int w, int h, int over_allocation)
-{
- int i;
-
- for (i=0;i<h;i++)
- {
- memcpy(d[i],s[i],w*sizeof(unsigned char));
- }
-
- memcpy(&d[h],&d[h],over_allocation);
-
-}
-
-inline void db_WarpImageLutFast_u(const unsigned char * const * src, unsigned char ** dst, int w, int h,
- const float * const * lut_x, const float * const * lut_y)
-{
- assert(src && dst);
- int xd=0, yd=0;
-
- for ( int i = 0; i < w; ++i )
- for ( int j = 0; j < h; ++j )
- {
- //xd = static_cast<unsigned int>(lut_x[j][i]);
- //yd = static_cast<unsigned int>(lut_y[j][i]);
- xd = (unsigned int)(lut_x[j][i]);
- yd = (unsigned int)(lut_y[j][i]);
- if ( xd >= w || yd >= h ||
- xd < 0 || yd < 0)
- dst[j][i] = 0;
- else
- dst[j][i] = src[yd][xd];
- }
-}
-
-inline void db_WarpImageLutBilinear_u(const unsigned char * const * src, unsigned char ** dst, int w, int h,
- const float * const * lut_x,const float * const* lut_y)
-{
- assert(src && dst);
- double xd=0.0, yd=0.0;
-
- for ( int i = 0; i < w; ++i )
- for ( int j = 0; j < h; ++j )
- {
- xd = static_cast<double>(lut_x[j][i]);
- yd = static_cast<double>(lut_y[j][i]);
- if ( xd > w || yd > h ||
- xd < 0.0 || yd < 0.0)
- dst[j][i] = 0;
- else
- dst[j][i] = db_BilinearInterpolation(yd, xd, src);
- }
-}
-
-
-void db_WarpImageLut_u(const unsigned char * const * src, unsigned char ** dst, int w, int h,
- const float * const * lut_x,const float * const * lut_y, int type)
-{
- switch (type)
- {
- case DB_WARP_FAST:
- db_WarpImageLutFast_u(src,dst,w,h,lut_x,lut_y);
- break;
- case DB_WARP_BILINEAR:
- db_WarpImageLutBilinear_u(src,dst,w,h,lut_x,lut_y);
- break;
- default:
- break;
- }
-}
-
-
-void db_PrintDoubleVector(double *a,long size)
-{
- printf("[ ");
- for(long i=0;i<size;i++) printf("%lf ",a[i]);
- printf("]");
-}
-
-void db_PrintDoubleMatrix(double *a,long rows,long cols)
-{
- printf("[\n");
- for(long i=0;i<rows;i++)
- {
- for(long j=0;j<cols;j++) printf("%lf ",a[i*cols+j]);
- printf("\n");
- }
- printf("]");
-}
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities.h
deleted file mode 100644
index fa9c877..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities.h
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities.h,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_UTILITIES_H
-#define DB_UTILITIES_H
-
-
-#ifdef _WIN32
-#pragma warning(disable: 4275)
-#pragma warning(disable: 4251)
-#pragma warning(disable: 4786)
-#pragma warning(disable: 4800)
-#pragma warning(disable: 4018) /* signed-unsigned mismatch */
-#endif /* _WIN32 */
-
-#ifdef _WIN32
- #ifdef DBDYNAMIC_EXPORTS
- #define DB_API __declspec(dllexport)
- #else
- #ifdef DBDYNAMIC_IMPORTS
- #define DB_API __declspec(dllimport)
- #else
- #define DB_API
- #endif
- #endif
-#else
- #define DB_API
-#endif /* _WIN32 */
-
-#ifdef _VERBOSE_
-#include <iostream>
-#endif
-
-#include <math.h>
-
-#include <assert.h>
-#include "db_utilities_constants.h"
-/*!
- * \defgroup LMBasicUtilities (LM) Utility Functions (basic math, linear algebra and array manipulations)
- */
-/*\{*/
-
-/*!
- * Round double into int using fld and fistp instructions.
- */
-inline int db_roundi (double x) {
-#ifdef WIN32_ASM
- int n;
- __asm
- {
- fld x;
- fistp n;
- }
- return n;
-#else
- return static_cast<int>(floor(x+0.5));
-#endif
-}
-
-/*!
- * Square a double.
- */
-inline double db_sqr(double a)
-{
- return(a*a);
-}
-
-/*!
- * Square a long.
- */
-inline long db_sqr(long a)
-{
- return(a*a);
-}
-
-/*!
- * Square an int.
- */
-inline long db_sqr(int a)
-{
- return(a*a);
-}
-
-/*!
- * Maximum of two doubles.
- */
-inline double db_maxd(double a,double b)
-{
- if(b>a) return(b);
- else return(a);
-}
-/*!
- * Minumum of two doubles.
- */
-inline double db_mind(double a,double b)
-{
- if(b<a) return(b);
- else return(a);
-}
-
-
-/*!
- * Maximum of two ints.
- */
-inline int db_maxi(int a,int b)
-{
- if(b>a) return(b);
- else return(a);
-}
-
-/*!
- * Minimum of two numbers.
- */
-inline int db_mini(int a,int b)
-{
- if(b<a) return(b);
- else return(a);
-}
-/*!
- * Maximum of two numbers.
- */
-inline long db_maxl(long a,long b)
-{
- if(b>a) return(b);
- else return(a);
-}
-
-/*!
- * Minimum of two numbers.
- */
-inline long db_minl(long a,long b)
-{
- if(b<a) return(b);
- else return(a);
-}
-
-/*!
- * Sign of a number.
- * \return -1.0 if negative, 1.0 if positive.
- */
-inline double db_sign(double x)
-{
- if(x>=0.0) return(1.0);
- else return(-1.0);
-}
-/*!
- * Absolute value.
- */
-inline int db_absi(int a)
-{
- if(a<0) return(-a);
- else return(a);
-}
-/*!
- * Absolute value.
- */
-inline float db_absf(float a)
-{
- if(a<0) return(-a);
- else return(a);
-}
-
-/*!
- * Absolute value.
- */
-inline double db_absd(double a)
-{
- if(a<0) return(-a);
- else return(a);
-}
-
-/*!
- * Reciprocal (1/a). Prevents divide by 0.
- * \return 1/a if a != 0. 1.0 otherwise.
- */
-inline double db_SafeReciprocal(double a)
-{
- return((a!=0.0)?(1.0/a):1.0);
-}
-
-/*!
- * Division. Prevents divide by 0.
- * \return a/b if b!=0. a otherwise.
- */
-inline double db_SafeDivision(double a,double b)
-{
- return((b!=0.0)?(a/b):a);
-}
-
-/*!
- * Square root. Prevents imaginary output.
- * \return sqrt(a) if a > 0.0. 0.0 otherewise.
- */
-inline double db_SafeSqrt(double a)
-{
- return((a>=0.0)?(sqrt(a)):0.0);
-}
-
-/*!
- * Square root of a reciprocal. Prevents divide by 0 and imaginary output.
- * \return sqrt(1/a) if a > 0.0. 1.0 otherewise.
- */
-inline double db_SafeSqrtReciprocal(double a)
-{
- return((a>0.0)?(sqrt(1.0/a)):1.0);
-}
-/*!
- * Cube root.
- */
-inline double db_CubRoot(double x)
-{
- if(x>=0.0) return(pow(x,1.0/3.0));
- else return(-pow(-x,1.0/3.0));
-}
-/*!
- * Sum of squares of elements of x.
- */
-inline double db_SquareSum3(const double x[3])
-{
- return(db_sqr(x[0])+db_sqr(x[1])+db_sqr(x[2]));
-}
-/*!
- * Sum of squares of elements of x.
- */
-inline double db_SquareSum7(double x[7])
-{
- return(db_sqr(x[0])+db_sqr(x[1])+db_sqr(x[2])+
- db_sqr(x[3])+db_sqr(x[4])+db_sqr(x[5])+
- db_sqr(x[6]));
-}
-/*!
- * Sum of squares of elements of x.
- */
-inline double db_SquareSum9(double x[9])
-{
- return(db_sqr(x[0])+db_sqr(x[1])+db_sqr(x[2])+
- db_sqr(x[3])+db_sqr(x[4])+db_sqr(x[5])+
- db_sqr(x[6])+db_sqr(x[7])+db_sqr(x[8]));
-}
-/*!
- * Copy a vector.
- * \param xd destination
- * \param xs source
- */
-void inline db_Copy3(double xd[3],const double xs[3])
-{
- xd[0]=xs[0];xd[1]=xs[1];xd[2]=xs[2];
-}
-/*!
- * Copy a vector.
- * \param xd destination
- * \param xs source
- */
-void inline db_Copy6(double xd[6],const double xs[6])
-{
- xd[0]=xs[0];xd[1]=xs[1];xd[2]=xs[2];
- xd[3]=xs[3];xd[4]=xs[4];xd[5]=xs[5];
-}
-/*!
- * Copy a vector.
- * \param xd destination
- * \param xs source
- */
-void inline db_Copy9(double xd[9],const double xs[9])
-{
- xd[0]=xs[0];xd[1]=xs[1];xd[2]=xs[2];
- xd[3]=xs[3];xd[4]=xs[4];xd[5]=xs[5];
- xd[6]=xs[6];xd[7]=xs[7];xd[8]=xs[8];
-}
-
-/*!
- * Scalar product: Transpose(A)*B.
- */
-inline double db_ScalarProduct4(const double A[4],const double B[4])
-{
- return(A[0]*B[0]+A[1]*B[1]+A[2]*B[2]+A[3]*B[3]);
-}
-/*!
- * Scalar product: Transpose(A)*B.
- */
-inline double db_ScalarProduct7(const double A[7],const double B[7])
-{
- return(A[0]*B[0]+A[1]*B[1]+A[2]*B[2]+
- A[3]*B[3]+A[4]*B[4]+A[5]*B[5]+
- A[6]*B[6]);
-}
-/*!
- * Scalar product: Transpose(A)*B.
- */
-inline double db_ScalarProduct9(const double A[9],const double B[9])
-{
- return(A[0]*B[0]+A[1]*B[1]+A[2]*B[2]+
- A[3]*B[3]+A[4]*B[4]+A[5]*B[5]+
- A[6]*B[6]+A[7]*B[7]+A[8]*B[8]);
-}
-/*!
- * Vector addition: S=A+B.
- */
-inline void db_AddVectors6(double S[6],const double A[6],const double B[6])
-{
- S[0]=A[0]+B[0]; S[1]=A[1]+B[1]; S[2]=A[2]+B[2]; S[3]=A[3]+B[3]; S[4]=A[4]+B[4];
- S[5]=A[5]+B[5];
-}
-/*!
- * Multiplication: C(3x1)=A(3x3)*B(3x1).
- */
-inline void db_Multiply3x3_3x1(double y[3],const double A[9],const double x[3])
-{
- y[0]=A[0]*x[0]+A[1]*x[1]+A[2]*x[2];
- y[1]=A[3]*x[0]+A[4]*x[1]+A[5]*x[2];
- y[2]=A[6]*x[0]+A[7]*x[1]+A[8]*x[2];
-}
-inline void db_Multiply3x3_3x3(double C[9], const double A[9],const double B[9])
-{
- C[0]=A[0]*B[0]+A[1]*B[3]+A[2]*B[6];
- C[1]=A[0]*B[1]+A[1]*B[4]+A[2]*B[7];
- C[2]=A[0]*B[2]+A[1]*B[5]+A[2]*B[8];
-
- C[3]=A[3]*B[0]+A[4]*B[3]+A[5]*B[6];
- C[4]=A[3]*B[1]+A[4]*B[4]+A[5]*B[7];
- C[5]=A[3]*B[2]+A[4]*B[5]+A[5]*B[8];
-
- C[6]=A[6]*B[0]+A[7]*B[3]+A[8]*B[6];
- C[7]=A[6]*B[1]+A[7]*B[4]+A[8]*B[7];
- C[8]=A[6]*B[2]+A[7]*B[5]+A[8]*B[8];
-}
-/*!
- * Multiplication: C(4x1)=A(4x4)*B(4x1).
- */
-inline void db_Multiply4x4_4x1(double y[4],const double A[16],const double x[4])
-{
- y[0]=A[0]*x[0]+A[1]*x[1]+A[2]*x[2]+A[3]*x[3];
- y[1]=A[4]*x[0]+A[5]*x[1]+A[6]*x[2]+A[7]*x[3];
- y[2]=A[8]*x[0]+A[9]*x[1]+A[10]*x[2]+A[11]*x[3];
- y[3]=A[12]*x[0]+A[13]*x[1]+A[14]*x[2]+A[15]*x[3];
-}
-/*!
- * Scalar multiplication in place: A(3)=mult*A(3).
- */
-inline void db_MultiplyScalar3(double *A,double mult)
-{
- (*A++) *= mult; (*A++) *= mult; (*A++) *= mult;
-}
-
-/*!
- * Scalar multiplication: A(3)=mult*B(3).
- */
-inline void db_MultiplyScalarCopy3(double *A,const double *B,double mult)
-{
- (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult;
-}
-
-/*!
- * Scalar multiplication: A(4)=mult*B(4).
- */
-inline void db_MultiplyScalarCopy4(double *A,const double *B,double mult)
-{
- (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult;
-}
-/*!
- * Scalar multiplication: A(7)=mult*B(7).
- */
-inline void db_MultiplyScalarCopy7(double *A,const double *B,double mult)
-{
- (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult;
- (*A++)=(*B++)*mult; (*A++)=(*B++)*mult;
-}
-/*!
- * Scalar multiplication: A(9)=mult*B(9).
- */
-inline void db_MultiplyScalarCopy9(double *A,const double *B,double mult)
-{
- (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult;
- (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult; (*A++)=(*B++)*mult;
-}
-
-/*!
- * \defgroup LMImageBasicUtilities (LM) Basic Image Utility Functions
-
- Images in db are simply 2D arrays of unsigned char or float types.
- Only the very basic operations are supported: allocation/deallocation,
-copying, simple pyramid construction and LUT warping. These images are used
-by db_CornerDetector_u and db_Matcher_u. The db_Image class is an attempt
-to wrap these images. It has not been tested well.
-
- */
-/*\{*/
-/*!
- * Given a float image array, allocates and returns the set of row poiners.
- * \param im image pointer
- * \param w image width
- * \param h image height
- */
-DB_API float** db_SetupImageReferences_f(float *im,int w,int h);
-/*!
- * Allocate a float image.
- * Note: for feature detection images must be overallocated by 256 bytes.
- * \param w width
- * \param h height
- * \param over_allocation allocate this many extra bytes at the end
- * \return row array pointer
- */
-DB_API float** db_AllocImage_f(int w,int h,int over_allocation=256);
-/*!
- * Free a float image
- * \param img row array pointer
- * \param h image height (number of rows)
- */
-DB_API void db_FreeImage_f(float **img,int h);
-/*!
- * Given an unsigned char image array, allocates and returns the set of row poiners.
- * \param im image pointer
- * \param w image width
- * \param h image height
- */
-DB_API unsigned char** db_SetupImageReferences_u(unsigned char *im,int w,int h);
-/*!
- * Allocate an unsigned char image.
- * Note: for feature detection images must be overallocated by 256 bytes.
- * \param w width
- * \param h height
- * \param over_allocation allocate this many extra bytes at the end
- * \return row array pointer
- */
-DB_API unsigned char** db_AllocImage_u(int w,int h,int over_allocation=256);
-/*!
- * Free an unsigned char image
- * \param img row array pointer
- * \param h image height (number of rows)
- */
-DB_API void db_FreeImage_u(unsigned char **img,int h);
-
-/*!
- Copy an image from s to d. Both s and d must be pre-allocated at of the same size.
- Copy is done row by row.
- \param s source
- \param d destination
- \param w width
- \param h height
- \param over_allocation copy this many bytes after the end of the last line
- */
-DB_API void db_CopyImage_u(unsigned char **d,const unsigned char * const *s,int w,int h,int over_allocation=0);
-
-DB_API inline unsigned char db_BilinearInterpolation(double y, double x, const unsigned char * const * v)
-{
- int floor_x=(int) x;
- int floor_y=(int) y;
-
- int ceil_x=floor_x+1;
- int ceil_y=floor_y+1;
-
- unsigned char f00 = v[floor_y][floor_x];
- unsigned char f01 = v[floor_y][ceil_x];
- unsigned char f10 = v[ceil_y][floor_x];
- unsigned char f11 = v[ceil_y][ceil_x];
-
- double xl = x-floor_x;
- double yl = y-floor_y;
-
- return (unsigned char)(f00*(1-yl)*(1-xl) + f10*yl*(1-xl) + f01*(1-yl)*xl + f11*yl*xl);
-}
-/*\}*/
-/*!
- * \ingroup LMRotation
- * Compute an incremental rotation matrix using the update dx=[sin(phi) sin(ohm) sin(kap)]
- */
-inline void db_IncrementalRotationMatrix(double R[9],const double dx[3])
-{
- double sp,so,sk,om_sp2,om_so2,om_sk2,cp,co,ck,sp_so,cp_so;
-
- /*Store sines*/
- sp=dx[0]; so=dx[1]; sk=dx[2];
- om_sp2=1.0-sp*sp;
- om_so2=1.0-so*so;
- om_sk2=1.0-sk*sk;
- /*Compute cosines*/
- cp=(om_sp2>=0.0)?sqrt(om_sp2):1.0;
- co=(om_so2>=0.0)?sqrt(om_so2):1.0;
- ck=(om_sk2>=0.0)?sqrt(om_sk2):1.0;
- /*Compute matrix*/
- sp_so=sp*so;
- cp_so=cp*so;
- R[0]=sp_so*sk+cp*ck; R[1]=co*sk; R[2]=cp_so*sk-sp*ck;
- R[3]=sp_so*ck-cp*sk; R[4]=co*ck; R[5]=cp_so*ck+sp*sk;
- R[6]=sp*co; R[7]= -so; R[8]=cp*co;
-}
-/*!
- * Zero out 2 vector in place.
- */
-void inline db_Zero2(double x[2])
-{
- x[0]=x[1]=0;
-}
-/*!
- * Zero out 3 vector in place.
- */
-void inline db_Zero3(double x[3])
-{
- x[0]=x[1]=x[2]=0;
-}
-/*!
- * Zero out 4 vector in place.
- */
-void inline db_Zero4(double x[4])
-{
- x[0]=x[1]=x[2]=x[3]=0;
-}
-/*!
- * Zero out 9 vector in place.
- */
-void inline db_Zero9(double x[9])
-{
- x[0]=x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=0;
-}
-
-#define DB_WARP_FAST 0
-#define DB_WARP_BILINEAR 1
-
-/*!
- * Perform a look-up table warp.
- * The LUTs must be float images of the same size as source image.
- * The source value x_s is determined from destination (x_d,y_d) through lut_x
- * and y_s is determined from lut_y:
- \code
- x_s = lut_x[y_d][x_d];
- y_s = lut_y[y_d][x_d];
- \endcode
-
- * \param src source image
- * \param dst destination image
- * \param w width
- * \param h height
- * \param lut_x LUT for x
- * \param lut_y LUT for y
- * \param type warp type (DB_WARP_FAST or DB_WARP_BILINEAR)
- */
-DB_API void db_WarpImageLut_u(const unsigned char * const * src,unsigned char ** dst, int w, int h,
- const float * const * lut_x, const float * const * lut_y, int type=DB_WARP_BILINEAR);
-
-DB_API void db_PrintDoubleVector(double *a,long size);
-DB_API void db_PrintDoubleMatrix(double *a,long rows,long cols);
-
-#include "db_utilities_constants.h"
-#include "db_utilities_algebra.h"
-#include "db_utilities_indexing.h"
-#include "db_utilities_linalg.h"
-#include "db_utilities_poly.h"
-#include "db_utilities_geometry.h"
-#include "db_utilities_random.h"
-#include "db_utilities_rotation.h"
-#include "db_utilities_camera.h"
-
-#define DB_INVALID (-1)
-
-
-#endif /* DB_UTILITIES_H */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_algebra.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_algebra.h
deleted file mode 100644
index 2aedd74..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_algebra.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_algebra.h,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_UTILITIES_ALGEBRA
-#define DB_UTILITIES_ALGEBRA
-
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMAlgebra (LM) Algebra utilities
- */
-/*\{*/
-
-inline void db_HomogenousNormalize3(double *x)
-{
- db_MultiplyScalar3(x,db_SafeSqrtReciprocal(db_SquareSum3(x)));
-}
-
-/*\}*/
-
-#endif /* DB_UTILITIES_ALGEBRA */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_camera.cpp b/jni_mosaic/feature_stab/db_vlvm/db_utilities_camera.cpp
deleted file mode 100644
index dceba9b..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_camera.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_camera.cpp,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#include "db_utilities_camera.h"
-#include "db_utilities.h"
-#include <assert.h>
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-void db_Approx3DCalMat(double K[9],double Kinv[9],int im_width,int im_height,double f_correction,int field)
-{
- double iw,ih,av_size,field_fact;
-
- if(field) field_fact=2.0;
- else field_fact=1.0;
-
- iw=(double)im_width;
- ih=(double)(im_height*field_fact);
- av_size=(iw+ih)/2.0;
- K[0]=f_correction*av_size;
- K[1]=0;
- K[2]=iw/2.0;
- K[3]=0;
- K[4]=f_correction*av_size/field_fact;
- K[5]=ih/2.0/field_fact;
- K[6]=0;
- K[7]=0;
- K[8]=1;
-
- db_InvertCalibrationMatrix(Kinv,K);
-}
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_camera.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_camera.h
deleted file mode 100644
index 26ba442..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_camera.h
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_camera.h,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_UTILITIES_CAMERA
-#define DB_UTILITIES_CAMERA
-
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMCamera (LM) Camera Utilities
- */
-/*\{*/
-
-#include "db_utilities.h"
-
-#define DB_RADDISTMODE_BOUGEUT 4
-#define DB_RADDISTMODE_2NDORDER 5
-#define DB_RADDISTMODE_IDENTITY 6
-
-/*!
-Give reasonable guess of the calibration matrix for normalization purposes.
-Use real K matrix when doing real geometry.
-focal length = (w+h)/2.0*f_correction.
-\param K calibration matrix (out)
-\param Kinv inverse of K (out)
-\param im_width image width
-\param im_height image height
-\param f_correction focal length correction factor
-\param field set to 1 if this is a field image (fy = fx/2)
-\return K(3x3) intrinsic calibration matrix
-*/
-DB_API void db_Approx3DCalMat(double K[9],double Kinv[9],int im_width,int im_height,double f_correction=1.0,int field=0);
-
-/*!
- Make a 2x2 identity matrix
- */
-void inline db_Identity2x2(double A[4])
-{
- A[0]=1;A[1]=0;
- A[2]=0;A[3]=1;
-}
-/*!
- Make a 3x3 identity matrix
- */
-void inline db_Identity3x3(double A[9])
-{
- A[0]=1;A[1]=0;A[2]=0;
- A[3]=0;A[4]=1;A[5]=0;
- A[6]=0;A[7]=0;A[8]=1;
-}
-/*!
- Invert intrinsic calibration matrix K(3x3)
- If fx or fy is 0, I is returned.
- */
-void inline db_InvertCalibrationMatrix(double Kinv[9],const double K[9])
-{
- double a,b,c,d,e,f,ainv,dinv,adinv;
-
- a=K[0];b=K[1];c=K[2];d=K[4];e=K[5];f=K[8];
- if((a==0.0)||(d==0.0)) db_Identity3x3(Kinv);
- else
- {
- Kinv[3]=0.0;
- Kinv[6]=0.0;
- Kinv[7]=0.0;
- Kinv[8]=1.0;
-
- ainv=1.0/a;
- dinv=1.0/d;
- adinv=ainv*dinv;
- Kinv[0]=f*ainv;
- Kinv[1]= -b*f*adinv;
- Kinv[2]=(b*e-c*d)*adinv;
- Kinv[4]=f*dinv;
- Kinv[5]= -e*dinv;
- }
-}
-/*!
- De-homogenize image point: xd(1:2) = xs(1:2)/xs(3).
- If xs(3) is 0, xd will become 0
- \param xd destination point
- \param xs source point
- */
-void inline db_DeHomogenizeImagePoint(double xd[2],const double xs[3])
-{
- double temp,div;
-
- temp=xs[2];
- if(temp!=0)
- {
- div=1.0/temp;
- xd[0]=xs[0]*div;xd[1]=xs[1]*div;
- }
- else
- {
- xd[0]=0.0;xd[1]=0.0;
- }
-}
-
-
-/*!
- Orthonormalize 3D rotation R
- */
-inline void db_OrthonormalizeRotation(double R[9])
-{
- double s,mult;
- /*Normalize first vector*/
- s=db_sqr(R[0])+db_sqr(R[1])+db_sqr(R[2]);
- mult=sqrt(1.0/(s?s:1));
- R[0]*=mult; R[1]*=mult; R[2]*=mult;
- /*Subtract scalar product from second vector*/
- s=R[0]*R[3]+R[1]*R[4]+R[2]*R[5];
- R[3]-=s*R[0]; R[4]-=s*R[1]; R[5]-=s*R[2];
- /*Normalize second vector*/
- s=db_sqr(R[3])+db_sqr(R[4])+db_sqr(R[5]);
- mult=sqrt(1.0/(s?s:1));
- R[3]*=mult; R[4]*=mult; R[5]*=mult;
- /*Get third vector by vector product*/
- R[6]=R[1]*R[5]-R[4]*R[2];
- R[7]=R[2]*R[3]-R[5]*R[0];
- R[8]=R[0]*R[4]-R[3]*R[1];
-}
-/*!
-Update a rotation with the update dx=[sin(phi) sin(ohm) sin(kap)]
-*/
-inline void db_UpdateRotation(double R_p_dx[9],double R[9],const double dx[3])
-{
- double R_temp[9];
- /*Update rotation*/
- db_IncrementalRotationMatrix(R_temp,dx);
- db_Multiply3x3_3x3(R_p_dx,R_temp,R);
-}
-/*!
- Compute xp = Hx for inhomogenous image points.
- */
-inline void db_ImageHomographyInhomogenous(double xp[2],const double H[9],const double x[2])
-{
- double x3,m;
-
- x3=H[6]*x[0]+H[7]*x[1]+H[8];
- if(x3!=0.0)
- {
- m=1.0/x3;
- xp[0]=m*(H[0]*x[0]+H[1]*x[1]+H[2]);
- xp[1]=m*(H[3]*x[0]+H[4]*x[1]+H[5]);
- }
- else
- {
- xp[0]=xp[1]=0.0;
- }
-}
-inline double db_FocalFromCamRotFocalHomography(const double H[9])
-{
- double k1,k2;
-
- k1=db_sqr(H[2])+db_sqr(H[5]);
- k2=db_sqr(H[6])+db_sqr(H[7]);
- if(k1>=k2)
- {
- return(db_SafeSqrt(db_SafeDivision(k1,1.0-db_sqr(H[8]))));
- }
- else
- {
- return(db_SafeSqrt(db_SafeDivision(1.0-db_sqr(H[8]),k2)));
- }
-}
-
-inline double db_FocalAndRotFromCamRotFocalHomography(double R[9],const double H[9])
-{
- double back,fi;
-
- back=db_FocalFromCamRotFocalHomography(H);
- fi=db_SafeReciprocal(back);
- R[0]=H[0]; R[1]=H[1]; R[2]=fi*H[2];
- R[3]=H[3]; R[4]=H[4]; R[5]=fi*H[5];
- R[6]=back*H[6]; R[7]=back*H[7]; R[8]=H[8];
- return(back);
-}
-/*!
-Compute Jacobian at zero of three coordinates dR*x with
-respect to the update dR([sin(phi) sin(ohm) sin(kap)]) given x.
-
-The Jacobian at zero of the homogenous coordinates with respect to
- [sin(phi) sin(ohm) sin(kap)] is
-\code
- [-rx2 0 rx1 ]
- [ 0 rx2 -rx0 ]
- [ rx0 -rx1 0 ].
-\endcode
-
-*/
-inline void db_JacobianOfRotatedPointStride(double J[9],const double x[3],int stride)
-{
- /*The Jacobian at zero of the homogenous coordinates with respect to
- [sin(phi) sin(ohm) sin(kap)] is
- [-rx2 0 rx1 ]
- [ 0 rx2 -rx0 ]
- [ rx0 -rx1 0 ]*/
-
- J[0]= -x[stride<<1];
- J[1]=0;
- J[2]= x[stride];
- J[3]=0;
- J[4]= x[stride<<1];
- J[5]= -x[0];
- J[6]= x[0];
- J[7]= -x[stride];
- J[8]=0;
-}
-/*!
- Invert an affine (if possible)
- \param Hinv inverted matrix
- \param H input matrix
- \return true if success and false if matrix is ill-conditioned (det < 1e-7)
- */
-inline bool db_InvertAffineTransform(double Hinv[9],const double H[9])
-{
- double det=H[0]*H[4]-H[3]*H[1];
- if (det<1e-7)
- {
- db_Copy9(Hinv,H);
- return false;
- }
- else
- {
- Hinv[0]=H[4]/det;
- Hinv[1]=-H[1]/det;
- Hinv[3]=-H[3]/det;
- Hinv[4]=H[0]/det;
- Hinv[2]= -Hinv[0]*H[2]-Hinv[1]*H[5];
- Hinv[5]= -Hinv[3]*H[2]-Hinv[4]*H[5];
- }
- return true;
-}
-
-/*!
-Update of upper 2x2 is multiplication by
-\code
-[s 0][ cos(theta) sin(theta)]
-[0 s][-sin(theta) cos(theta)]
-\endcode
-*/
-inline void db_MultiplyScaleOntoImageHomography(double H[9],double s)
-{
-
- H[0]*=s;
- H[1]*=s;
- H[3]*=s;
- H[4]*=s;
-}
-/*!
-Update of upper 2x2 is multiplication by
-\code
-[s 0][ cos(theta) sin(theta)]
-[0 s][-sin(theta) cos(theta)]
-\endcode
-*/
-inline void db_MultiplyRotationOntoImageHomography(double H[9],double theta)
-{
- double c,s,H0,H1;
-
-
- c=cos(theta);
- s=db_SafeSqrt(1.0-db_sqr(c));
- H0= c*H[0]+s*H[3];
- H[3]= -s*H[0]+c*H[3];
- H[0]=H0;
- H1=c*H[1]+s*H[4];
- H[4]= -s*H[1]+c*H[4];
- H[1]=H1;
-}
-
-inline void db_UpdateImageHomographyAffine(double H_p_dx[9],const double H[9],const double dx[6])
-{
- db_AddVectors6(H_p_dx,H,dx);
- db_Copy3(H_p_dx+6,H+6);
-}
-
-inline void db_UpdateImageHomographyProjective(double H_p_dx[9],const double H[9],const double dx[8],int frozen_coord)
-{
- int i,j;
-
- for(j=0,i=0;i<9;i++)
- {
- if(i!=frozen_coord)
- {
- H_p_dx[i]=H[i]+dx[j];
- j++;
- }
- else H_p_dx[i]=H[i];
- }
-}
-
-inline void db_UpdateRotFocalHomography(double H_p_dx[9],const double H[9],const double dx[4])
-{
- double f,fp,fpi;
- double R[9],dR[9];
-
- /*Updated matrix is diag(f+df,f+df)*dR*R*diag(1/(f+df),1/(f+df),1)*/
- f=db_FocalAndRotFromCamRotFocalHomography(R,H);
- db_IncrementalRotationMatrix(dR,dx);
- db_Multiply3x3_3x3(H_p_dx,dR,R);
- fp=f+dx[3];
- fpi=db_SafeReciprocal(fp);
- H_p_dx[2]*=fp;
- H_p_dx[5]*=fp;
- H_p_dx[6]*=fpi;
- H_p_dx[7]*=fpi;
-}
-
-/*\}*/
-#endif /* DB_UTILITIES_CAMERA */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_constants.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_constants.h
deleted file mode 100644
index 07565ef..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_constants.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_constants.h,v 1.2 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_UTILITIES_CONSTANTS
-#define DB_UTILITIES_CONSTANTS
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-/****************Constants********************/
-#define DB_E 2.7182818284590452354
-#define DB_LOG2E 1.4426950408889634074
-#define DB_LOG10E 0.43429448190325182765
-#define DB_LN2 0.69314718055994530942
-#define DB_LN10 2.30258509299404568402
-#define DB_PI 3.1415926535897932384626433832795
-#define DB_PI_2 1.57079632679489661923
-#define DB_PI_4 0.78539816339744830962
-#define DB_1_PI 0.31830988618379067154
-#define DB_2_PI 0.63661977236758134308
-#define DB_SQRTPI 1.7724538509055160272981674833411
-#define DB_SQRT_2PI 2.506628274631000502415765284811
-#define DB_2_SQRTPI 1.12837916709551257390
-#define DB_SQRT2 1.41421356237309504880
-#define DB_SQRT3 1.7320508075688772935274463415059
-#define DB_SQRT1_2 0.70710678118654752440
-#define DB_EPS 2.220446049250313e-016 /* for 32 bit double */
-
-/****************Default Parameters********************/
-/*Preemptive ransac parameters*/
-#define DB_DEFAULT_NR_SAMPLES 500
-#define DB_DEFAULT_CHUNK_SIZE 100
-#define DB_DEFAULT_GROUP_SIZE 10
-
-/*Optimisation parameters*/
-#define DB_DEFAULT_MAX_POINTS 1000
-#define DB_DEFAULT_MAX_ITERATIONS 25
-#define DB_DEFAULT_IMP_REQ 0.001
-
-/*Feature standard deviation parameters*/
-#define DB_POINT_STANDARDDEV (1.0/(826.0)) /*1 pixel for CIF (fraction of (image width+image height)/2)*/
-#define DB_OUTLIER_THRESHOLD 3.0 /*In number of DB_POINT_STANDARDDEV's*/
-#define DB_WORST_CASE 50.0 /*In number of DB_POINT_STANDARDDEV's*/
-
-/*Front-end parameters*/
-#define DB_DEFAULT_TARGET_NR_CORNERS 5000
-#define DB_DEFAULT_NR_FEATURE_BLOCKS 10
-#define DB_DEFAULT_ABS_CORNER_THRESHOLD 50000000.0
-#define DB_DEFAULT_REL_CORNER_THRESHOLD 0.00005
-#define DB_DEFAULT_MAX_DISPARITY 0.1
-#define DB_DEFAULT_NO_DISPARITY -1.0
-#define DB_DEFAULT_MAX_TRACK_LENGTH 300
-
-#define DB_DEFAULT_MAX_NR_CAMERAS 1000
-
-#define DB_DEFAULT_TRIPLE_STEP 2
-#define DB_DEFAULT_DOUBLE_STEP 2
-#define DB_DEFAULT_SINGLE_STEP 1
-#define DB_DEFAULT_NR_SINGLES 10
-#define DB_DEFAULT_NR_DOUBLES 1
-#define DB_DEFAULT_NR_TRIPLES 1
-
-#define DB_DEFAULT_TRIFOCAL_FOUR_STEPS 40
-
-#define DB_DEFAULT_EPIPOLAR_ERROR 1 /*in pixels*/
-
-////////////////////////// DOXYGEN /////////////////////
-
-/*!
- * \def DB_DEFAULT_GROUP_SIZE
- * \ingroup LMRobust
- * \brief Default group size for db_PreemptiveRansac class.
- * Group size is the number of observation costs multiplied together
- * before a log of the product is added to the total cost.
-*/
-
-/*!
- * \def DB_DEFAULT_TARGET_NR_CORNERS
- * \ingroup FeatureDetection
- * \brief Default target number of corners
-*/
-/*!
- * \def DB_DEFAULT_NR_FEATURE_BLOCKS
- * \ingroup FeatureDetection
- * \brief Default number of regions (horizontal or vertical) that are considered separately
- * for feature detection. The greater the number, the more uniform the distribution of
- * detected features.
-*/
-/*!
- * \def DB_DEFAULT_ABS_CORNER_THRESHOLD
- * \ingroup FeatureDetection
- * \brief Absolute feature strength threshold.
-*/
-/*!
- * \def DB_DEFAULT_REL_CORNER_THRESHOLD
- * \ingroup FeatureDetection
- * \brief Relative feature strength threshold.
-*/
-/*!
- * \def DB_DEFAULT_MAX_DISPARITY
- * \ingroup FeatureMatching
- * \brief Maximum disparity (as fraction of image size) allowed in feature matching
-*/
- /*!
- * \def DB_DEFAULT_NO_DISPARITY
- * \ingroup FeatureMatching
- * \brief Indicates that vertical disparity is the same as horizontal disparity.
-*/
-///////////////////////////////////////////////////////////////////////////////////
- /*!
- * \def DB_E
- * \ingroup LMBasicUtilities
- * \brief e
-*/
- /*!
- * \def DB_LOG2E
- * \ingroup LMBasicUtilities
- * \brief log2(e)
-*/
- /*!
- * \def DB_LOG10E
- * \ingroup LMBasicUtilities
- * \brief log10(e)
-*/
- /*!
- * \def DB_LOG10E
- * \ingroup LMBasicUtilities
- * \brief log10(e)
-*/
-/*!
- * \def DB_LN2
- * \ingroup LMBasicUtilities
- * \brief ln(2)
-*/
-/*!
- * \def DB_LN10
- * \ingroup LMBasicUtilities
- * \brief ln(10)
-*/
-/*!
- * \def DB_PI
- * \ingroup LMBasicUtilities
- * \brief Pi
-*/
-/*!
- * \def DB_PI_2
- * \ingroup LMBasicUtilities
- * \brief Pi/2
-*/
-/*!
- * \def DB_PI_4
- * \ingroup LMBasicUtilities
- * \brief Pi/4
-*/
-/*!
- * \def DB_1_PI
- * \ingroup LMBasicUtilities
- * \brief 1/Pi
-*/
-/*!
- * \def DB_2_PI
- * \ingroup LMBasicUtilities
- * \brief 2/Pi
-*/
-/*!
- * \def DB_SQRTPI
- * \ingroup LMBasicUtilities
- * \brief sqrt(Pi)
-*/
-/*!
- * \def DB_SQRT_2PI
- * \ingroup LMBasicUtilities
- * \brief sqrt(2*Pi)
-*/
-/*!
- * \def DB_SQRT2
- * \ingroup LMBasicUtilities
- * \brief sqrt(2)
-*/
-/*!
- * \def DB_SQRT3
- * \ingroup LMBasicUtilities
- * \brief sqrt(3)
-*/
-/*!
- * \def DB_SQRT1_2
- * \ingroup LMBasicUtilities
- * \brief sqrt(1/2)
-*/
-#endif /* DB_UTILITIES_CONSTANTS */
-
-
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_geometry.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_geometry.h
deleted file mode 100644
index f215584..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_geometry.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_geometry.h,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_UTILITIES_GEOMETRY_H
-#define DB_UTILITIES_GEOMETRY_H
-
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*! Get the inhomogenous 2D-point centroid of nr_point inhomogenous
-points in X*/
-inline void db_PointCentroid2D(double c[2],const double *X,int nr_points)
-{
- int i;
- double cx,cy,m;
-
- cx=0;cy=0;
- for(i=0;i<nr_points;i++)
- {
- cx+= *X++;
- cy+= *X++;
- }
- if(nr_points)
- {
- m=1.0/((double)nr_points);
- c[0]=cx*m;
- c[1]=cy*m;
- }
- else c[0]=c[1]=0;
-}
-
-inline void db_PointCentroid2D(double c[2],const double * const *X,int nr_points)
-{
- int i;
- double cx,cy,m;
- const double *temp;
-
- cx=0;cy=0;
- for(i=0;i<nr_points;i++)
- {
- temp= *X++;
- cx+=temp[0];
- cy+=temp[1];
- }
- if(nr_points)
- {
- m=1.0/((double)nr_points);
- c[0]=cx*m;
- c[1]=cy*m;
- }
- else c[0]=c[1]=0;
-}
-
-/*! Get the inhomogenous 3D-point centroid of nr_point inhomogenous
-points in X*/
-inline void db_PointCentroid3D(double c[3],const double *X,int nr_points)
-{
- int i;
- double cx,cy,cz,m;
-
- cx=0;cy=0;cz=0;
- for(i=0;i<nr_points;i++)
- {
- cx+= *X++;
- cy+= *X++;
- cz+= *X++;
- }
- if(nr_points)
- {
- m=1.0/((double)nr_points);
- c[0]=cx*m;
- c[1]=cy*m;
- c[2]=cz*m;
- }
- else c[0]=c[1]=c[2]=0;
-}
-
-inline void db_PointCentroid3D(double c[3],const double * const *X,int nr_points)
-{
- int i;
- double cx,cy,cz,m;
- const double *temp;
-
- cx=0;cy=0;cz=0;
- for(i=0;i<nr_points;i++)
- {
- temp= *X++;
- cx+=temp[0];
- cy+=temp[1];
- cz+=temp[2];
- }
- if(nr_points)
- {
- m=1.0/((double)nr_points);
- c[0]=cx*m;
- c[1]=cy*m;
- c[2]=cz*m;
- }
- else c[0]=c[1]=c[2]=0;
-}
-
-#endif /* DB_UTILITIES_GEOMETRY_H */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_indexing.cpp b/jni_mosaic/feature_stab/db_vlvm/db_utilities_indexing.cpp
deleted file mode 100644
index 30ce03a..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_indexing.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_indexing.cpp,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#include "db_utilities_indexing.h"
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-void db_Zero(double *d,long nr)
-{
- long i;
- for(i=0;i<nr;i++) d[i]=0.0;
-}
-
-/*This routine breaks number in source into values smaller and larger than
-a pivot element. Values equal to the pivot are ignored*/
-void db_LeanPartitionOnPivot(double pivot,double *dest,const double *source,long first,long last,long *first_equal,long *last_equal)
-{
- double temp;
- const double *s_point;
- const double *s_top;
- double *d_bottom;
- double *d_top;
-
- s_point=source+first;
- s_top=source+last;
- d_bottom=dest+first;
- d_top=dest+last;
-
- for(;s_point<=s_top;)
- {
- temp= *(s_point++);
- if(temp<pivot) *(d_bottom++)=temp;
- else if(temp>pivot) *(d_top--)=temp;
- }
- *first_equal=d_bottom-dest;
- *last_equal=d_top-dest;
-}
-
-double db_LeanQuickSelect(const double *s,long nr_elements,long pos,double *temp)
-{
- long first=0;
- long last=nr_elements-1;
- double pivot;
- long first_equal,last_equal;
- double *tempA;
- double *tempB;
- double *tempC;
- const double *source;
- double *dest;
-
- tempA=temp;
- tempB=temp+nr_elements;
- source=s;
- dest=tempA;
-
- for(;last-first>2;)
- {
- pivot=db_TripleMedian(source[first],source[last],source[(first+last)/2]);
- db_LeanPartitionOnPivot(pivot,dest,source,first,last,&first_equal,&last_equal);
-
- if(first_equal>pos) last=first_equal-1;
- else if(last_equal<pos) first=last_equal+1;
- else
- {
- return(pivot);
- }
-
- /*Swap pointers*/
- tempC=tempA;
- tempA=tempB;
- tempB=tempC;
- source=tempB;
- dest=tempA;
- }
- pivot=db_TripleMedian(source[first],source[last],source[(first+last)/2]);
-
- return(pivot);
-}
-
-float* db_AlignPointer_f(float *p,unsigned long nr_bytes)
-{
- float *ap;
- unsigned long m;
-
- m=((unsigned long)p)%nr_bytes;
- if(m) ap=(float*) (((unsigned long)p)-m+nr_bytes);
- else ap=p;
- return(ap);
-}
-
-short* db_AlignPointer_s(short *p,unsigned long nr_bytes)
-{
- short *ap;
- unsigned long m;
-
- m=((unsigned long)p)%nr_bytes;
- if(m) ap=(short*) (((unsigned long)p)-m+nr_bytes);
- else ap=p;
- return(ap);
-}
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_indexing.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_indexing.h
deleted file mode 100644
index 01eeb9e..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_indexing.h
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_indexing.h,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_UTILITIES_INDEXING
-#define DB_UTILITIES_INDEXING
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-#include "db_utilities.h"
-
-/*!
- * \defgroup LMIndexing (LM) Indexing Utilities (Order Statistics, Matrix Operations)
- */
-/*\{*/
-
-inline void db_SetupMatrixRefs(double **ar,long rows,long cols,double *a)
-{
- long i;
- for(i=0;i<rows;i++) ar[i]=&a[i*cols];
-}
-
-inline void db_SymmetricExtendUpperToLower(double **A,int rows,int cols)
-{
- int i,j;
- for(i=1;i<rows;i++) for(j=0;j<i;j++) A[i][j]=A[j][i];
-}
-
-void inline db_MultiplyMatrixVectorAtb(double *c,const double * const *At,const double *b,int arows,int acols)
-{
- int i,j;
- double acc;
-
- for(i=0;i<arows;i++)
- {
- acc=0;
- for(j=0;j<acols;j++) acc+=At[j][i]*b[j];
- c[i]=acc;
- }
-}
-
-inline void db_MultiplyMatricesAB(double **C,const double * const *A,const double * const *B,int arows,int acols,int bcols)
-{
- int i,j,k;
- double acc;
-
- for(i=0;i<arows;i++) for(j=0;j<bcols;j++)
- {
- acc=0;
- for(k=0;k<acols;k++) acc+=A[i][k]*B[k][j];
- C[i][j]=acc;
- }
-}
-
-inline void db_UpperMultiplyMatricesAtB(double **Cu,const double * const *At,const double * const *B,int arows,int acols,int bcols)
-{
- int i,j,k;
- double acc;
-
- for(i=0;i<arows;i++) for(j=i;j<bcols;j++)
- {
- acc=0;
- for(k=0;k<acols;k++) acc+=At[k][i]*B[k][j];
- Cu[i][j]=acc;
- }
-}
-
-DB_API void db_Zero(double *d,long nr);
-
-inline int db_MaxIndex2(double s[2])
-{
- if(s[0]>=s[1]) return(0);
- return(1);
-}
-
-inline int db_MaxIndex3(const double s[3])
-{
- double best;
- int pos;
-
- best=s[0];pos=0;
- if(s[1]>best){best=s[1];pos=1;}
- if(s[2]>best){best=s[2];pos=2;}
- return(pos);
-}
-
-inline int db_MaxIndex4(const double s[4])
-{
- double best;
- int pos;
-
- best=s[0];pos=0;
- if(s[1]>best){best=s[1];pos=1;}
- if(s[2]>best){best=s[2];pos=2;}
- if(s[3]>best){best=s[3];pos=3;}
- return(pos);
-}
-
-inline int db_MaxIndex5(const double s[5])
-{
- double best;
- int pos;
-
- best=s[0];pos=0;
- if(s[1]>best){best=s[1];pos=1;}
- if(s[2]>best){best=s[2];pos=2;}
- if(s[3]>best){best=s[3];pos=3;}
- if(s[4]>best){best=s[4];pos=4;}
- return(pos);
-}
-
-inline int db_MaxIndex6(const double s[6])
-{
- double best;
- int pos;
-
- best=s[0];pos=0;
- if(s[1]>best){best=s[1];pos=1;}
- if(s[2]>best){best=s[2];pos=2;}
- if(s[3]>best){best=s[3];pos=3;}
- if(s[4]>best){best=s[4];pos=4;}
- if(s[5]>best){best=s[5];pos=5;}
- return(pos);
-}
-
-inline int db_MaxIndex7(const double s[7])
-{
- double best;
- int pos;
-
- best=s[0];pos=0;
- if(s[1]>best){best=s[1];pos=1;}
- if(s[2]>best){best=s[2];pos=2;}
- if(s[3]>best){best=s[3];pos=3;}
- if(s[4]>best){best=s[4];pos=4;}
- if(s[5]>best){best=s[5];pos=5;}
- if(s[6]>best){best=s[6];pos=6;}
- return(pos);
-}
-
-inline int db_MinIndex7(const double s[7])
-{
- double best;
- int pos;
-
- best=s[0];pos=0;
- if(s[1]<best){best=s[1];pos=1;}
- if(s[2]<best){best=s[2];pos=2;}
- if(s[3]<best){best=s[3];pos=3;}
- if(s[4]<best){best=s[4];pos=4;}
- if(s[5]<best){best=s[5];pos=5;}
- if(s[6]<best){best=s[6];pos=6;}
- return(pos);
-}
-
-inline int db_MinIndex9(const double s[9])
-{
- double best;
- int pos;
-
- best=s[0];pos=0;
- if(s[1]<best){best=s[1];pos=1;}
- if(s[2]<best){best=s[2];pos=2;}
- if(s[3]<best){best=s[3];pos=3;}
- if(s[4]<best){best=s[4];pos=4;}
- if(s[5]<best){best=s[5];pos=5;}
- if(s[6]<best){best=s[6];pos=6;}
- if(s[7]<best){best=s[7];pos=7;}
- if(s[8]<best){best=s[8];pos=8;}
- return(pos);
-}
-
-inline int db_MaxAbsIndex3(const double *s)
-{
- double t,best;
- int pos;
-
- best=fabs(s[0]);pos=0;
- t=fabs(s[1]);if(t>best){best=t;pos=1;}
- t=fabs(s[2]);if(t>best){pos=2;}
- return(pos);
-}
-
-inline int db_MaxAbsIndex9(const double *s)
-{
- double t,best;
- int pos;
-
- best=fabs(s[0]);pos=0;
- t=fabs(s[1]);if(t>best){best=t;pos=1;}
- t=fabs(s[2]);if(t>best){best=t;pos=2;}
- t=fabs(s[3]);if(t>best){best=t;pos=3;}
- t=fabs(s[4]);if(t>best){best=t;pos=4;}
- t=fabs(s[5]);if(t>best){best=t;pos=5;}
- t=fabs(s[6]);if(t>best){best=t;pos=6;}
- t=fabs(s[7]);if(t>best){best=t;pos=7;}
- t=fabs(s[8]);if(t>best){best=t;pos=8;}
- return(pos);
-}
-
-
-/*!
-Select ordinal pos (zero based) out of nr_elements in s.
-temp should point to alloced memory of at least nr_elements*2
-Optimized runtimes on 450MHz:
-\code
- 30 with 3 microsecs
- 100 with 11 microsecs
- 300 with 30 microsecs
- 500 with 40 microsecs
-1000 with 100 microsecs
-5000 with 540 microsecs
-\endcode
-so the expected runtime is around
-(nr_elements/10) microseconds
-The total quickselect cost of splitting 500 hypotheses recursively
-is thus around 100 microseconds
-
-Does the same operation as std::nth_element().
-*/
-DB_API double db_LeanQuickSelect(const double *s,long nr_elements,long pos,double *temp);
-
-/*!
- Median of 3 doubles
- */
-inline double db_TripleMedian(double a,double b,double c)
-{
- if(a>b)
- {
- if(c>a) return(a);
- else if(c>b) return(c);
- else return(b);
- }
- else
- {
- if(c>b) return(b);
- else if(c>a) return(c);
- else return(a);
- }
-}
-
-/*!
-Align float pointer to nr_bytes by moving forward
-*/
-DB_API float* db_AlignPointer_f(float *p,unsigned long nr_bytes);
-
-/*!
-Align short pointer to nr_bytes by moving forward
-*/
-DB_API short* db_AlignPointer_s(short *p,unsigned long nr_bytes);
-
-#endif /* DB_UTILITIES_INDEXING */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_linalg.cpp b/jni_mosaic/feature_stab/db_vlvm/db_utilities_linalg.cpp
deleted file mode 100644
index 8f68b30..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_linalg.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_linalg.cpp,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
-
-#include "db_utilities_linalg.h"
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-/*Cholesky-factorize symmetric positive definite 6 x 6 matrix A. Upper
-part of A is used from the input. The Cholesky factor is output as
-subdiagonal part in A and diagonal in d, which is 6-dimensional*/
-void db_CholeskyDecomp6x6(double A[36],double d[6])
-{
- double s,temp;
-
- /*[50 mult 35 add 6sqrt=85flops 6func]*/
- /*i=0*/
- s=A[0];
- d[0]=((s>0.0)?sqrt(s):1.0);
- temp=db_SafeReciprocal(d[0]);
- A[6]=A[1]*temp;
- A[12]=A[2]*temp;
- A[18]=A[3]*temp;
- A[24]=A[4]*temp;
- A[30]=A[5]*temp;
- /*i=1*/
- s=A[7]-A[6]*A[6];
- d[1]=((s>0.0)?sqrt(s):1.0);
- temp=db_SafeReciprocal(d[1]);
- A[13]=(A[8]-A[6]*A[12])*temp;
- A[19]=(A[9]-A[6]*A[18])*temp;
- A[25]=(A[10]-A[6]*A[24])*temp;
- A[31]=(A[11]-A[6]*A[30])*temp;
- /*i=2*/
- s=A[14]-A[12]*A[12]-A[13]*A[13];
- d[2]=((s>0.0)?sqrt(s):1.0);
- temp=db_SafeReciprocal(d[2]);
- A[20]=(A[15]-A[12]*A[18]-A[13]*A[19])*temp;
- A[26]=(A[16]-A[12]*A[24]-A[13]*A[25])*temp;
- A[32]=(A[17]-A[12]*A[30]-A[13]*A[31])*temp;
- /*i=3*/
- s=A[21]-A[18]*A[18]-A[19]*A[19]-A[20]*A[20];
- d[3]=((s>0.0)?sqrt(s):1.0);
- temp=db_SafeReciprocal(d[3]);
- A[27]=(A[22]-A[18]*A[24]-A[19]*A[25]-A[20]*A[26])*temp;
- A[33]=(A[23]-A[18]*A[30]-A[19]*A[31]-A[20]*A[32])*temp;
- /*i=4*/
- s=A[28]-A[24]*A[24]-A[25]*A[25]-A[26]*A[26]-A[27]*A[27];
- d[4]=((s>0.0)?sqrt(s):1.0);
- temp=db_SafeReciprocal(d[4]);
- A[34]=(A[29]-A[24]*A[30]-A[25]*A[31]-A[26]*A[32]-A[27]*A[33])*temp;
- /*i=5*/
- s=A[35]-A[30]*A[30]-A[31]*A[31]-A[32]*A[32]-A[33]*A[33]-A[34]*A[34];
- d[5]=((s>0.0)?sqrt(s):1.0);
-}
-
-/*Cholesky-factorize symmetric positive definite n x n matrix A.Part
-above diagonal of A is used from the input, diagonal of A is assumed to
-be stored in d. The Cholesky factor is output as
-subdiagonal part in A and diagonal in d, which is n-dimensional*/
-void db_CholeskyDecompSeparateDiagonal(double **A,double *d,int n)
-{
- int i,j,k;
- double s;
- double temp = 0.0;
-
- for(i=0;i<n;i++) for(j=i;j<n;j++)
- {
- if(i==j) s=d[i];
- else s=A[i][j];
- for(k=i-1;k>=0;k--) s-=A[i][k]*A[j][k];
- if(i==j)
- {
- d[i]=((s>0.0)?sqrt(s):1.0);
- temp=db_SafeReciprocal(d[i]);
- }
- else A[j][i]=s*temp;
- }
-}
-
-/*Backsubstitute L%transpose(L)*x=b for x given the Cholesky decomposition
-of an n x n matrix and the right hand side b. The vector b is unchanged*/
-void db_CholeskyBacksub(double *x,const double * const *A,const double *d,int n,const double *b)
-{
- int i,k;
- double s;
-
- for(i=0;i<n;i++)
- {
- for(s=b[i],k=i-1;k>=0;k--) s-=A[i][k]*x[k];
- x[i]=db_SafeDivision(s,d[i]);
- }
- for(i=n-1;i>=0;i--)
- {
- for(s=x[i],k=i+1;k<n;k++) s-=A[k][i]*x[k];
- x[i]=db_SafeDivision(s,d[i]);
- }
-}
-
-/*Cholesky-factorize symmetric positive definite 3 x 3 matrix A. Part
-above diagonal of A is used from the input, diagonal of A is assumed to
-be stored in d. The Cholesky factor is output as subdiagonal part in A
-and diagonal in d, which is 3-dimensional*/
-void db_CholeskyDecomp3x3SeparateDiagonal(double A[9],double d[3])
-{
- double s,temp;
-
- /*i=0*/
- s=d[0];
- d[0]=((s>0.0)?sqrt(s):1.0);
- temp=db_SafeReciprocal(d[0]);
- A[3]=A[1]*temp;
- A[6]=A[2]*temp;
- /*i=1*/
- s=d[1]-A[3]*A[3];
- d[1]=((s>0.0)?sqrt(s):1.0);
- temp=db_SafeReciprocal(d[1]);
- A[7]=(A[5]-A[3]*A[6])*temp;
- /*i=2*/
- s=d[2]-A[6]*A[6]-A[7]*A[7];
- d[2]=((s>0.0)?sqrt(s):1.0);
-}
-
-/*Backsubstitute L%transpose(L)*x=b for x given the Cholesky decomposition
-of a 3 x 3 matrix and the right hand side b. The vector b is unchanged*/
-void db_CholeskyBacksub3x3(double x[3],const double A[9],const double d[3],const double b[3])
-{
- /*[42 mult 30 add=72flops]*/
- x[0]=db_SafeDivision(b[0],d[0]);
- x[1]=db_SafeDivision((b[1]-A[3]*x[0]),d[1]);
- x[2]=db_SafeDivision((b[2]-A[6]*x[0]-A[7]*x[1]),d[2]);
- x[2]=db_SafeDivision(x[2],d[2]);
- x[1]=db_SafeDivision((x[1]-A[7]*x[2]),d[1]);
- x[0]=db_SafeDivision((x[0]-A[6]*x[2]-A[3]*x[1]),d[0]);
-}
-
-/*Backsubstitute L%transpose(L)*x=b for x given the Cholesky decomposition
-of a 6 x 6 matrix and the right hand side b. The vector b is unchanged*/
-void db_CholeskyBacksub6x6(double x[6],const double A[36],const double d[6],const double b[6])
-{
- /*[42 mult 30 add=72flops]*/
- x[0]=db_SafeDivision(b[0],d[0]);
- x[1]=db_SafeDivision((b[1]-A[6]*x[0]),d[1]);
- x[2]=db_SafeDivision((b[2]-A[12]*x[0]-A[13]*x[1]),d[2]);
- x[3]=db_SafeDivision((b[3]-A[18]*x[0]-A[19]*x[1]-A[20]*x[2]),d[3]);
- x[4]=db_SafeDivision((b[4]-A[24]*x[0]-A[25]*x[1]-A[26]*x[2]-A[27]*x[3]),d[4]);
- x[5]=db_SafeDivision((b[5]-A[30]*x[0]-A[31]*x[1]-A[32]*x[2]-A[33]*x[3]-A[34]*x[4]),d[5]);
- x[5]=db_SafeDivision(x[5],d[5]);
- x[4]=db_SafeDivision((x[4]-A[34]*x[5]),d[4]);
- x[3]=db_SafeDivision((x[3]-A[33]*x[5]-A[27]*x[4]),d[3]);
- x[2]=db_SafeDivision((x[2]-A[32]*x[5]-A[26]*x[4]-A[20]*x[3]),d[2]);
- x[1]=db_SafeDivision((x[1]-A[31]*x[5]-A[25]*x[4]-A[19]*x[3]-A[13]*x[2]),d[1]);
- x[0]=db_SafeDivision((x[0]-A[30]*x[5]-A[24]*x[4]-A[18]*x[3]-A[12]*x[2]-A[6]*x[1]),d[0]);
-}
-
-
-void db_Orthogonalize6x7(double A[42],int orthonormalize)
-{
- int i;
- double ss[6];
-
- /*Compute square sums of rows*/
- ss[0]=db_SquareSum7(A);
- ss[1]=db_SquareSum7(A+7);
- ss[2]=db_SquareSum7(A+14);
- ss[3]=db_SquareSum7(A+21);
- ss[4]=db_SquareSum7(A+28);
- ss[5]=db_SquareSum7(A+35);
-
- ss[1]-=db_OrthogonalizePair7(A+7 ,A,ss[0]);
- ss[2]-=db_OrthogonalizePair7(A+14,A,ss[0]);
- ss[3]-=db_OrthogonalizePair7(A+21,A,ss[0]);
- ss[4]-=db_OrthogonalizePair7(A+28,A,ss[0]);
- ss[5]-=db_OrthogonalizePair7(A+35,A,ss[0]);
-
- /*Pivot on largest ss (could also be done on ss/(original_ss))*/
- i=db_MaxIndex5(ss+1);
- db_OrthogonalizationSwap7(A+7,i,ss+1);
-
- ss[2]-=db_OrthogonalizePair7(A+14,A+7,ss[1]);
- ss[3]-=db_OrthogonalizePair7(A+21,A+7,ss[1]);
- ss[4]-=db_OrthogonalizePair7(A+28,A+7,ss[1]);
- ss[5]-=db_OrthogonalizePair7(A+35,A+7,ss[1]);
-
- i=db_MaxIndex4(ss+2);
- db_OrthogonalizationSwap7(A+14,i,ss+2);
-
- ss[3]-=db_OrthogonalizePair7(A+21,A+14,ss[2]);
- ss[4]-=db_OrthogonalizePair7(A+28,A+14,ss[2]);
- ss[5]-=db_OrthogonalizePair7(A+35,A+14,ss[2]);
-
- i=db_MaxIndex3(ss+3);
- db_OrthogonalizationSwap7(A+21,i,ss+3);
-
- ss[4]-=db_OrthogonalizePair7(A+28,A+21,ss[3]);
- ss[5]-=db_OrthogonalizePair7(A+35,A+21,ss[3]);
-
- i=db_MaxIndex2(ss+4);
- db_OrthogonalizationSwap7(A+28,i,ss+4);
-
- ss[5]-=db_OrthogonalizePair7(A+35,A+28,ss[4]);
-
- if(orthonormalize)
- {
- db_MultiplyScalar7(A ,db_SafeSqrtReciprocal(ss[0]));
- db_MultiplyScalar7(A+7 ,db_SafeSqrtReciprocal(ss[1]));
- db_MultiplyScalar7(A+14,db_SafeSqrtReciprocal(ss[2]));
- db_MultiplyScalar7(A+21,db_SafeSqrtReciprocal(ss[3]));
- db_MultiplyScalar7(A+28,db_SafeSqrtReciprocal(ss[4]));
- db_MultiplyScalar7(A+35,db_SafeSqrtReciprocal(ss[5]));
- }
-}
-
-void db_Orthogonalize8x9(double A[72],int orthonormalize)
-{
- int i;
- double ss[8];
-
- /*Compute square sums of rows*/
- ss[0]=db_SquareSum9(A);
- ss[1]=db_SquareSum9(A+9);
- ss[2]=db_SquareSum9(A+18);
- ss[3]=db_SquareSum9(A+27);
- ss[4]=db_SquareSum9(A+36);
- ss[5]=db_SquareSum9(A+45);
- ss[6]=db_SquareSum9(A+54);
- ss[7]=db_SquareSum9(A+63);
-
- ss[1]-=db_OrthogonalizePair9(A+9 ,A,ss[0]);
- ss[2]-=db_OrthogonalizePair9(A+18,A,ss[0]);
- ss[3]-=db_OrthogonalizePair9(A+27,A,ss[0]);
- ss[4]-=db_OrthogonalizePair9(A+36,A,ss[0]);
- ss[5]-=db_OrthogonalizePair9(A+45,A,ss[0]);
- ss[6]-=db_OrthogonalizePair9(A+54,A,ss[0]);
- ss[7]-=db_OrthogonalizePair9(A+63,A,ss[0]);
-
- /*Pivot on largest ss (could also be done on ss/(original_ss))*/
- i=db_MaxIndex7(ss+1);
- db_OrthogonalizationSwap9(A+9,i,ss+1);
-
- ss[2]-=db_OrthogonalizePair9(A+18,A+9,ss[1]);
- ss[3]-=db_OrthogonalizePair9(A+27,A+9,ss[1]);
- ss[4]-=db_OrthogonalizePair9(A+36,A+9,ss[1]);
- ss[5]-=db_OrthogonalizePair9(A+45,A+9,ss[1]);
- ss[6]-=db_OrthogonalizePair9(A+54,A+9,ss[1]);
- ss[7]-=db_OrthogonalizePair9(A+63,A+9,ss[1]);
-
- i=db_MaxIndex6(ss+2);
- db_OrthogonalizationSwap9(A+18,i,ss+2);
-
- ss[3]-=db_OrthogonalizePair9(A+27,A+18,ss[2]);
- ss[4]-=db_OrthogonalizePair9(A+36,A+18,ss[2]);
- ss[5]-=db_OrthogonalizePair9(A+45,A+18,ss[2]);
- ss[6]-=db_OrthogonalizePair9(A+54,A+18,ss[2]);
- ss[7]-=db_OrthogonalizePair9(A+63,A+18,ss[2]);
-
- i=db_MaxIndex5(ss+3);
- db_OrthogonalizationSwap9(A+27,i,ss+3);
-
- ss[4]-=db_OrthogonalizePair9(A+36,A+27,ss[3]);
- ss[5]-=db_OrthogonalizePair9(A+45,A+27,ss[3]);
- ss[6]-=db_OrthogonalizePair9(A+54,A+27,ss[3]);
- ss[7]-=db_OrthogonalizePair9(A+63,A+27,ss[3]);
-
- i=db_MaxIndex4(ss+4);
- db_OrthogonalizationSwap9(A+36,i,ss+4);
-
- ss[5]-=db_OrthogonalizePair9(A+45,A+36,ss[4]);
- ss[6]-=db_OrthogonalizePair9(A+54,A+36,ss[4]);
- ss[7]-=db_OrthogonalizePair9(A+63,A+36,ss[4]);
-
- i=db_MaxIndex3(ss+5);
- db_OrthogonalizationSwap9(A+45,i,ss+5);
-
- ss[6]-=db_OrthogonalizePair9(A+54,A+45,ss[5]);
- ss[7]-=db_OrthogonalizePair9(A+63,A+45,ss[5]);
-
- i=db_MaxIndex2(ss+6);
- db_OrthogonalizationSwap9(A+54,i,ss+6);
-
- ss[7]-=db_OrthogonalizePair9(A+63,A+54,ss[6]);
-
- if(orthonormalize)
- {
- db_MultiplyScalar9(A ,db_SafeSqrtReciprocal(ss[0]));
- db_MultiplyScalar9(A+9 ,db_SafeSqrtReciprocal(ss[1]));
- db_MultiplyScalar9(A+18,db_SafeSqrtReciprocal(ss[2]));
- db_MultiplyScalar9(A+27,db_SafeSqrtReciprocal(ss[3]));
- db_MultiplyScalar9(A+36,db_SafeSqrtReciprocal(ss[4]));
- db_MultiplyScalar9(A+45,db_SafeSqrtReciprocal(ss[5]));
- db_MultiplyScalar9(A+54,db_SafeSqrtReciprocal(ss[6]));
- db_MultiplyScalar9(A+63,db_SafeSqrtReciprocal(ss[7]));
- }
-}
-
-void db_NullVectorOrthonormal6x7(double x[7],const double A[42])
-{
- int i;
- double omss[7];
- const double *B;
-
- /*Pivot by choosing row of the identity matrix
- (the one corresponding to column of A with smallest square sum)*/
- omss[0]=db_SquareSum6Stride7(A);
- omss[1]=db_SquareSum6Stride7(A+1);
- omss[2]=db_SquareSum6Stride7(A+2);
- omss[3]=db_SquareSum6Stride7(A+3);
- omss[4]=db_SquareSum6Stride7(A+4);
- omss[5]=db_SquareSum6Stride7(A+5);
- omss[6]=db_SquareSum6Stride7(A+6);
- i=db_MinIndex7(omss);
- /*orthogonalize that row against all previous rows
- and normalize it*/
- B=A+i;
- db_MultiplyScalarCopy7(x,A,-B[0]);
- db_RowOperation7(x,A+7 ,B[7]);
- db_RowOperation7(x,A+14,B[14]);
- db_RowOperation7(x,A+21,B[21]);
- db_RowOperation7(x,A+28,B[28]);
- db_RowOperation7(x,A+35,B[35]);
- x[i]+=1.0;
- db_MultiplyScalar7(x,db_SafeSqrtReciprocal(1.0-omss[i]));
-}
-
-void db_NullVectorOrthonormal8x9(double x[9],const double A[72])
-{
- int i;
- double omss[9];
- const double *B;
-
- /*Pivot by choosing row of the identity matrix
- (the one corresponding to column of A with smallest square sum)*/
- omss[0]=db_SquareSum8Stride9(A);
- omss[1]=db_SquareSum8Stride9(A+1);
- omss[2]=db_SquareSum8Stride9(A+2);
- omss[3]=db_SquareSum8Stride9(A+3);
- omss[4]=db_SquareSum8Stride9(A+4);
- omss[5]=db_SquareSum8Stride9(A+5);
- omss[6]=db_SquareSum8Stride9(A+6);
- omss[7]=db_SquareSum8Stride9(A+7);
- omss[8]=db_SquareSum8Stride9(A+8);
- i=db_MinIndex9(omss);
- /*orthogonalize that row against all previous rows
- and normalize it*/
- B=A+i;
- db_MultiplyScalarCopy9(x,A,-B[0]);
- db_RowOperation9(x,A+9 ,B[9]);
- db_RowOperation9(x,A+18,B[18]);
- db_RowOperation9(x,A+27,B[27]);
- db_RowOperation9(x,A+36,B[36]);
- db_RowOperation9(x,A+45,B[45]);
- db_RowOperation9(x,A+54,B[54]);
- db_RowOperation9(x,A+63,B[63]);
- x[i]+=1.0;
- db_MultiplyScalar9(x,db_SafeSqrtReciprocal(1.0-omss[i]));
-}
-
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_linalg.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_linalg.h
deleted file mode 100644
index 1f63d4e..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_linalg.h
+++ /dev/null
@@ -1,802 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_linalg.h,v 1.5 2011/06/17 14:03:31 mbansal Exp $ */
-
-#ifndef DB_UTILITIES_LINALG
-#define DB_UTILITIES_LINALG
-
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMLinAlg (LM) Linear Algebra Utilities (QR factorization, orthogonal basis, etc.)
- */
-
-/*!
- \ingroup LMBasicUtilities
- */
-inline void db_MultiplyScalar6(double A[6],double mult)
-{
- (*A++) *= mult; (*A++) *= mult; (*A++) *= mult; (*A++) *= mult; (*A++) *= mult;
- (*A++) *= mult;
-}
-/*!
- \ingroup LMBasicUtilities
- */
-inline void db_MultiplyScalar7(double A[7],double mult)
-{
- (*A++) *= mult; (*A++) *= mult; (*A++) *= mult; (*A++) *= mult; (*A++) *= mult;
- (*A++) *= mult; (*A++) *= mult;
-}
-/*!
- \ingroup LMBasicUtilities
- */
-inline void db_MultiplyScalar9(double A[9],double mult)
-{
- (*A++) *= mult; (*A++) *= mult; (*A++) *= mult; (*A++) *= mult; (*A++) *= mult;
- (*A++) *= mult; (*A++) *= mult; (*A++) *= mult; (*A++) *= mult;
-}
-
-/*!
- \ingroup LMBasicUtilities
- */
-inline double db_SquareSum6Stride7(const double *x)
-{
- return(db_sqr(x[0])+db_sqr(x[7])+db_sqr(x[14])+
- db_sqr(x[21])+db_sqr(x[28])+db_sqr(x[35]));
-}
-
-/*!
- \ingroup LMBasicUtilities
- */
-inline double db_SquareSum8Stride9(const double *x)
-{
- return(db_sqr(x[0])+db_sqr(x[9])+db_sqr(x[18])+
- db_sqr(x[27])+db_sqr(x[36])+db_sqr(x[45])+
- db_sqr(x[54])+db_sqr(x[63]));
-}
-
-/*!
- \ingroup LMLinAlg
- Cholesky-factorize symmetric positive definite 6 x 6 matrix A. Upper
-part of A is used from the input. The Cholesky factor is output as
-subdiagonal part in A and diagonal in d, which is 6-dimensional
-1.9 microseconds on 450MHz*/
-DB_API void db_CholeskyDecomp6x6(double A[36],double d[6]);
-
-/*!
- \ingroup LMLinAlg
- Backsubstitute L%transpose(L)*x=b for x given the Cholesky decomposition
-of a 6 x 6 matrix and the right hand side b. The vector b is unchanged
-1.3 microseconds on 450MHz*/
-DB_API void db_CholeskyBacksub6x6(double x[6],const double A[36],const double d[6],const double b[6]);
-
-/*!
- \ingroup LMLinAlg
- Cholesky-factorize symmetric positive definite n x n matrix A.Part
-above diagonal of A is used from the input, diagonal of A is assumed to
-be stored in d. The Cholesky factor is output as
-subdiagonal part in A and diagonal in d, which is n-dimensional*/
-DB_API void db_CholeskyDecompSeparateDiagonal(double **A,double *d,int n);
-
-/*!
- \ingroup LMLinAlg
- Backsubstitute L%transpose(L)*x=b for x given the Cholesky decomposition
-of an n x n matrix and the right hand side b. The vector b is unchanged*/
-DB_API void db_CholeskyBacksub(double *x,const double * const *A,const double *d,int n,const double *b);
-
-/*!
- \ingroup LMLinAlg
- Cholesky-factorize symmetric positive definite 3 x 3 matrix A. Part
-above diagonal of A is used from the input, diagonal of A is assumed to
-be stored in d. The Cholesky factor is output as subdiagonal part in A
-and diagonal in d, which is 3-dimensional*/
-DB_API void db_CholeskyDecomp3x3SeparateDiagonal(double A[9],double d[3]);
-
-/*!
- \ingroup LMLinAlg
- Backsubstitute L%transpose(L)*x=b for x given the Cholesky decomposition
-of a 3 x 3 matrix and the right hand side b. The vector b is unchanged*/
-DB_API void db_CholeskyBacksub3x3(double x[3],const double A[9],const double d[3],const double b[3]);
-
-/*!
- \ingroup LMLinAlg
- perform A-=B*mult*/
-inline void db_RowOperation3(double A[3],const double B[3],double mult)
-{
- *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++);
-}
-
-/*!
- \ingroup LMLinAlg
- */
-inline void db_RowOperation7(double A[7],const double B[7],double mult)
-{
- *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++);
- *A++ -= mult*(*B++); *A++ -= mult*(*B++);
-}
-
-/*!
- \ingroup LMLinAlg
- */
-inline void db_RowOperation9(double A[9],const double B[9],double mult)
-{
- *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++);
- *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++); *A++ -= mult*(*B++);
-}
-
-/*!
- \ingroup LMBasicUtilities
- Swap values of A[7] and B[7]
- */
-inline void db_Swap7(double A[7],double B[7])
-{
- double temp;
- temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp;
- temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp;
- temp= *A; *A++ = *B; *B++ =temp;
-}
-
-/*!
- \ingroup LMBasicUtilities
- Swap values of A[9] and B[9]
- */
-inline void db_Swap9(double A[9],double B[9])
-{
- double temp;
- temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp;
- temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp;
- temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp; temp= *A; *A++ = *B; *B++ =temp;
-}
-
-
-/*!
- \ingroup LMLinAlg
- */
-DB_API void db_Orthogonalize6x7(double A[42],int orthonormalize=0);
-
-/*!
- \ingroup LMLinAlg
- */
-DB_API void db_Orthogonalize8x9(double A[72],int orthonormalize=0);
-
-/*!
- \ingroup LMLinAlg
- */
-inline double db_OrthogonalizePair7(double *x,const double *v,double ssv)
-{
- double m,sp,sp_m;
-
- m=db_SafeReciprocal(ssv);
- sp=db_ScalarProduct7(x,v);
- sp_m=sp*m;
- db_RowOperation7(x,v,sp_m);
- return(sp*sp_m);
-}
-
-/*!
- \ingroup LMLinAlg
- */
-inline double db_OrthogonalizePair9(double *x,const double *v,double ssv)
-{
- double m,sp,sp_m;
-
- m=db_SafeReciprocal(ssv);
- sp=db_ScalarProduct9(x,v);
- sp_m=sp*m;
- db_RowOperation9(x,v,sp_m);
- return(sp*sp_m);
-}
-
-/*!
- \ingroup LMLinAlg
- */
-inline void db_OrthogonalizationSwap7(double *A,int i,double *ss)
-{
- double temp;
-
- db_Swap7(A,A+7*i);
- temp=ss[0]; ss[0]=ss[i]; ss[i]=temp;
-}
-/*!
- \ingroup LMLinAlg
- */
-inline void db_OrthogonalizationSwap9(double *A,int i,double *ss)
-{
- double temp;
-
- db_Swap9(A,A+9*i);
- temp=ss[0]; ss[0]=ss[i]; ss[i]=temp;
-}
-
-/*!
- \ingroup LMLinAlg
- */
-DB_API void db_NullVectorOrthonormal6x7(double x[7],const double A[42]);
-/*!
- \ingroup LMLinAlg
- */
-DB_API void db_NullVectorOrthonormal8x9(double x[9],const double A[72]);
-
-/*!
- \ingroup LMLinAlg
- */
-inline void db_NullVector6x7Destructive(double x[7],double A[42])
-{
- db_Orthogonalize6x7(A,1);
- db_NullVectorOrthonormal6x7(x,A);
-}
-
-/*!
- \ingroup LMLinAlg
- */
-inline void db_NullVector8x9Destructive(double x[9],double A[72])
-{
- db_Orthogonalize8x9(A,1);
- db_NullVectorOrthonormal8x9(x,A);
-}
-
-inline int db_ScalarProduct512_s(const short *f,const short *g)
-{
-#ifndef DB_USE_MMX
- int back;
- back=0;
- for(int i=1; i<=512; i++)
- back+=(*f++)*(*g++);
-
- return(back);
-#endif
-}
-
-
-inline int db_ScalarProduct32_s(const short *f,const short *g)
-{
-#ifndef DB_USE_MMX
- int back;
- back=0;
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++);
-
- return(back);
-#endif
-}
-
-/*!
- \ingroup LMLinAlg
- Scalar product of 128-vectors (short)
- Compile-time control: MMX, SSE2 or standard C
- */
-inline int db_ScalarProduct128_s(const short *f,const short *g)
-{
-#ifndef DB_USE_MMX
- int back;
- back=0;
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
-
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
-
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
-
- return(back);
-#else
-#ifdef DB_USE_SSE2
- int back;
-
- _asm
- {
- mov eax,f
- mov ecx,g
- /*First iteration************************************/
- movdqa xmm0,[eax]
- pxor xmm7,xmm7 /*Set xmm7 to zero*/
- pmaddwd xmm0,[ecx]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm2,[eax+16]
- paddd xmm7,xmm0
- pmaddwd xmm2,[ecx+16]
- /*Stall*/
- movdqa xmm1,[eax+32]
- paddd xmm7,xmm2
- pmaddwd xmm1,[ecx+32]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm0,[eax+48]
- paddd xmm7,xmm1
- pmaddwd xmm0,[ecx+48]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm2,[eax+64]
- paddd xmm7,xmm0
- pmaddwd xmm2,[ecx+64]
- /*Stall*/
- movdqa xmm1,[eax+80]
- paddd xmm7,xmm2
- pmaddwd xmm1,[ecx+80]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm0,[eax+96]
- paddd xmm7,xmm1
- pmaddwd xmm0,[ecx+96]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm2,[eax+112]
- paddd xmm7,xmm0
- pmaddwd xmm2,[ecx+112]
- /*Stall*/
- movdqa xmm1,[eax+128]
- paddd xmm7,xmm2
- pmaddwd xmm1,[ecx+128]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm0,[eax+144]
- paddd xmm7,xmm1
- pmaddwd xmm0,[ecx+144]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm2,[eax+160]
- paddd xmm7,xmm0
- pmaddwd xmm2,[ecx+160]
- /*Stall*/
- movdqa xmm1,[eax+176]
- paddd xmm7,xmm2
- pmaddwd xmm1,[ecx+176]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm0,[eax+192]
- paddd xmm7,xmm1
- pmaddwd xmm0,[ecx+192]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm2,[eax+208]
- paddd xmm7,xmm0
- pmaddwd xmm2,[ecx+208]
- /*Stall*/
- movdqa xmm1,[eax+224]
- paddd xmm7,xmm2
- pmaddwd xmm1,[ecx+224]
- /*Stall*/
- /*Standard iteration************************************/
- movdqa xmm0,[eax+240]
- paddd xmm7,xmm1
- pmaddwd xmm0,[ecx+240]
- /*Stall*/
- /*Rest iteration************************************/
- paddd xmm7,xmm0
-
- /* add up the sum squares */
- movhlps xmm0,xmm7 /* high half to low half */
- paddd xmm7,xmm0 /* add high to low */
- pshuflw xmm0,xmm7, 0xE /* reshuffle */
- paddd xmm7,xmm0 /* add remaining */
- movd back,xmm7
-
- emms
- }
-
- return(back);
-#else
- int back;
-
- _asm
- {
- mov eax,f
- mov ecx,g
- /*First iteration************************************/
- movq mm0,[eax]
- pxor mm7,mm7 /*Set mm7 to zero*/
- pmaddwd mm0,[ecx]
- /*Stall*/
- movq mm1,[eax+8]
- /*Stall*/
- pmaddwd mm1,[ecx+8]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+16]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+16]
- /*Stall*/
- movq mm0,[eax+24]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+24]
- /*Stall*/
- movq mm1,[eax+32]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+32]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+40]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+40]
- /*Stall*/
- movq mm0,[eax+48]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+48]
- /*Stall*/
- movq mm1,[eax+56]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+56]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+64]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+64]
- /*Stall*/
- movq mm0,[eax+72]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+72]
- /*Stall*/
- movq mm1,[eax+80]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+80]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+88]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+88]
- /*Stall*/
- movq mm0,[eax+96]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+96]
- /*Stall*/
- movq mm1,[eax+104]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+104]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+112]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+112]
- /*Stall*/
- movq mm0,[eax+120]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+120]
- /*Stall*/
- movq mm1,[eax+128]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+128]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+136]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+136]
- /*Stall*/
- movq mm0,[eax+144]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+144]
- /*Stall*/
- movq mm1,[eax+152]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+152]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+160]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+160]
- /*Stall*/
- movq mm0,[eax+168]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+168]
- /*Stall*/
- movq mm1,[eax+176]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+176]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+184]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+184]
- /*Stall*/
- movq mm0,[eax+192]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+192]
- /*Stall*/
- movq mm1,[eax+200]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+200]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+208]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+208]
- /*Stall*/
- movq mm0,[eax+216]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+216]
- /*Stall*/
- movq mm1,[eax+224]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+224]
- /*Stall*/
- /*Standard iteration************************************/
- movq mm2,[eax+232]
- paddd mm7,mm0
- pmaddwd mm2,[ecx+232]
- /*Stall*/
- movq mm0,[eax+240]
- paddd mm7,mm1
- pmaddwd mm0,[ecx+240]
- /*Stall*/
- movq mm1,[eax+248]
- paddd mm7,mm2
- pmaddwd mm1,[ecx+248]
- /*Stall*/
- /*Rest iteration************************************/
- paddd mm7,mm0
- /*Stall*/
- /*Stall*/
- /*Stall*/
- paddd mm7,mm1
- /*Stall*/
- movq mm0,mm7
- psrlq mm7,32
- paddd mm0,mm7
- /*Stall*/
- /*Stall*/
- /*Stall*/
- movd back,mm0
- emms
- }
-
- return(back);
-#endif
-#endif /*DB_USE_MMX*/
-}
-
-/*!
- \ingroup LMLinAlg
- Scalar product of 16 byte aligned 128-vectors (float).
- Compile-time control: SIMD (SSE) or standard C.
- */
-inline float db_ScalarProduct128Aligned16_f(const float *f,const float *g)
-{
-#ifndef DB_USE_SIMD
- float back;
- back=0.0;
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
-
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
-
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
- back+=(*f++)*(*g++); back+=(*f++)*(*g++); back+=(*f++)*(*g++);
-
- return(back);
-#else
- float back;
-
- _asm
- {
- mov eax,f
- mov ecx,g
- /*First iteration************************************/
- movaps xmm0,[eax]
- xorps xmm7,xmm7 /*Set mm7 to zero*/
- mulps xmm0,[ecx]
- /*Stall*/
- movaps xmm1,[eax+16]
- /*Stall*/
- mulps xmm1,[ecx+16]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+32]
- addps xmm7,xmm0
- mulps xmm2,[ecx+32]
- /*Stall*/
- movaps xmm0,[eax+48]
- addps xmm7,xmm1
- mulps xmm0,[ecx+48]
- /*Stall*/
- movaps xmm1,[eax+64]
- addps xmm7,xmm2
- mulps xmm1,[ecx+64]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+80]
- addps xmm7,xmm0
- mulps xmm2,[ecx+80]
- /*Stall*/
- movaps xmm0,[eax+96]
- addps xmm7,xmm1
- mulps xmm0,[ecx+96]
- /*Stall*/
- movaps xmm1,[eax+112]
- addps xmm7,xmm2
- mulps xmm1,[ecx+112]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+128]
- addps xmm7,xmm0
- mulps xmm2,[ecx+128]
- /*Stall*/
- movaps xmm0,[eax+144]
- addps xmm7,xmm1
- mulps xmm0,[ecx+144]
- /*Stall*/
- movaps xmm1,[eax+160]
- addps xmm7,xmm2
- mulps xmm1,[ecx+160]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+176]
- addps xmm7,xmm0
- mulps xmm2,[ecx+176]
- /*Stall*/
- movaps xmm0,[eax+192]
- addps xmm7,xmm1
- mulps xmm0,[ecx+192]
- /*Stall*/
- movaps xmm1,[eax+208]
- addps xmm7,xmm2
- mulps xmm1,[ecx+208]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+224]
- addps xmm7,xmm0
- mulps xmm2,[ecx+224]
- /*Stall*/
- movaps xmm0,[eax+240]
- addps xmm7,xmm1
- mulps xmm0,[ecx+240]
- /*Stall*/
- movaps xmm1,[eax+256]
- addps xmm7,xmm2
- mulps xmm1,[ecx+256]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+272]
- addps xmm7,xmm0
- mulps xmm2,[ecx+272]
- /*Stall*/
- movaps xmm0,[eax+288]
- addps xmm7,xmm1
- mulps xmm0,[ecx+288]
- /*Stall*/
- movaps xmm1,[eax+304]
- addps xmm7,xmm2
- mulps xmm1,[ecx+304]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+320]
- addps xmm7,xmm0
- mulps xmm2,[ecx+320]
- /*Stall*/
- movaps xmm0,[eax+336]
- addps xmm7,xmm1
- mulps xmm0,[ecx+336]
- /*Stall*/
- movaps xmm1,[eax+352]
- addps xmm7,xmm2
- mulps xmm1,[ecx+352]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+368]
- addps xmm7,xmm0
- mulps xmm2,[ecx+368]
- /*Stall*/
- movaps xmm0,[eax+384]
- addps xmm7,xmm1
- mulps xmm0,[ecx+384]
- /*Stall*/
- movaps xmm1,[eax+400]
- addps xmm7,xmm2
- mulps xmm1,[ecx+400]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+416]
- addps xmm7,xmm0
- mulps xmm2,[ecx+416]
- /*Stall*/
- movaps xmm0,[eax+432]
- addps xmm7,xmm1
- mulps xmm0,[ecx+432]
- /*Stall*/
- movaps xmm1,[eax+448]
- addps xmm7,xmm2
- mulps xmm1,[ecx+448]
- /*Stall*/
- /*Standard iteration************************************/
- movaps xmm2,[eax+464]
- addps xmm7,xmm0
- mulps xmm2,[ecx+464]
- /*Stall*/
- movaps xmm0,[eax+480]
- addps xmm7,xmm1
- mulps xmm0,[ecx+480]
- /*Stall*/
- movaps xmm1,[eax+496]
- addps xmm7,xmm2
- mulps xmm1,[ecx+496]
- /*Stall*/
- /*Rest iteration************************************/
- addps xmm7,xmm0
- /*Stall*/
- addps xmm7,xmm1
- /*Stall*/
- movaps xmm6,xmm7
- /*Stall*/
- shufps xmm6,xmm6,4Eh
- /*Stall*/
- addps xmm7,xmm6
- /*Stall*/
- movaps xmm6,xmm7
- /*Stall*/
- shufps xmm6,xmm6,11h
- /*Stall*/
- addps xmm7,xmm6
- /*Stall*/
- movss back,xmm7
- }
-
- return(back);
-#endif /*DB_USE_SIMD*/
-}
-
-#endif /* DB_UTILITIES_LINALG */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_poly.cpp b/jni_mosaic/feature_stab/db_vlvm/db_utilities_poly.cpp
deleted file mode 100644
index 013ac72..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_poly.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_poly.cpp,v 1.2 2010/09/03 12:00:10 bsouthall Exp $ */
-
-#include "db_utilities_poly.h"
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-
-void db_SolveCubic(double *roots,int *nr_roots,double a,double b,double c,double d)
-{
- double bp,bp2,cp,dp,q,r,srq;
- double r2_min_q3,theta,bp_through3,theta_through3;
- double cos_theta_through3,sin_theta_through3,min2_cos_theta_plu,min2_cos_theta_min;
- double si_r_srq,A;
-
- /*For nondegenerate cubics with three roots
- [24 mult 9 add 2sqrt 1acos 1cos=33flops 4func]
- For nondegenerate cubics with one root
- [16 mult 6 add 1sqrt 1qbrt=24flops 3func]*/
-
- if(a==0.0) db_SolveQuadratic(roots,nr_roots,b,c,d);
- else
- {
- bp=b/a;
- bp2=bp*bp;
- cp=c/a;
- dp=d/a;
-
- q=(bp2-3.0*cp)/9.0;
- r=(2.0*bp2*bp-9.0*bp*cp+27.0*dp)/54.0;
- r2_min_q3=r*r-q*q*q;
- if(r2_min_q3<0.0)
- {
- *nr_roots=3;
- /*q has to be > 0*/
- srq=sqrt(q);
- theta=acos(db_maxd(-1.0,db_mind(1.0,r/(q*srq))));
- bp_through3=bp/3.0;
- theta_through3=theta/3.0;
- cos_theta_through3=cos(theta_through3);
- sin_theta_through3=sqrt(db_maxd(0.0,1.0-cos_theta_through3*cos_theta_through3));
-
- /*cos(theta_through3+2*pi/3)=cos_theta_through3*cos(2*pi/3)-sin_theta_through3*sin(2*pi/3)
- = -0.5*cos_theta_through3-sqrt(3)/2.0*sin_theta_through3
- = -0.5*(cos_theta_through3+sqrt(3)*sin_theta_through3)*/
- min2_cos_theta_plu=cos_theta_through3+DB_SQRT3*sin_theta_through3;
- min2_cos_theta_min=cos_theta_through3-DB_SQRT3*sin_theta_through3;
-
- roots[0]= -2.0*srq*cos_theta_through3-bp_through3;
- roots[1]=srq*min2_cos_theta_plu-bp_through3;
- roots[2]=srq*min2_cos_theta_min-bp_through3;
- }
- else if(r2_min_q3>0.0)
- {
- *nr_roots=1;
- A= -db_sign(r)*db_CubRoot(db_absd(r)+sqrt(r2_min_q3));
- bp_through3=bp/3.0;
- if(A!=0.0) roots[0]=A+q/A-bp_through3;
- else roots[0]= -bp_through3;
- }
- else
- {
- *nr_roots=2;
- bp_through3=bp/3.0;
- /*q has to be >= 0*/
- si_r_srq=db_sign(r)*sqrt(q);
- /*Single root*/
- roots[0]= -2.0*si_r_srq-bp_through3;
- /*Double root*/
- roots[1]=si_r_srq-bp_through3;
- }
- }
-}
-
-void db_SolveQuartic(double *roots,int *nr_roots,double a,double b,double c,double d,double e)
-{
- /*Normalized coefficients*/
- double c0,c1,c2,c3;
- /*Temporary coefficients*/
- double c3through2,c3through4,c3c3through4_min_c2,min4_c0;
- double lz,ms,ns,mn,m,n,lz_through2;
- /*Cubic polynomial roots, nr of roots and coefficients*/
- double c_roots[3];
- int nr_c_roots;
- double k0,k1;
- /*nr additional roots from second quadratic*/
- int addroots;
-
- /*For nondegenerate quartics
- [16mult 11add 2sqrt 1cubic 2quadratic=74flops 8funcs]*/
-
- if(a==0.0) db_SolveCubic(roots,nr_roots,b,c,d,e);
- else if(e==0.0)
- {
- db_SolveCubic(roots,nr_roots,a,b,c,d);
- roots[*nr_roots]=0.0;
- *nr_roots+=1;
- }
- else
- {
- /*Compute normalized coefficients*/
- c3=b/a;
- c2=c/a;
- c1=d/a;
- c0=e/a;
- /*Compute temporary coefficients*/
- c3through2=c3/2.0;
- c3through4=c3/4.0;
- c3c3through4_min_c2=c3*c3through4-c2;
- min4_c0= -4.0*c0;
- /*Compute coefficients of cubic*/
- k0=min4_c0*c3c3through4_min_c2-c1*c1;
- k1=c1*c3+min4_c0;
- /*k2= -c2*/
- /*k3=1.0*/
-
- /*Solve it for roots*/
- db_SolveCubic(c_roots,&nr_c_roots,1.0,-c2,k1,k0);
-
- if(nr_c_roots>0)
- {
- lz=c_roots[0];
- lz_through2=lz/2.0;
- ms=lz+c3c3through4_min_c2;
- ns=lz_through2*lz_through2-c0;
- mn=lz*c3through4-c1/2.0;
-
- if((ms>=0.0)&&(ns>=0.0))
- {
- m=sqrt(ms);
- n=sqrt(ns)*db_sign(mn);
-
- db_SolveQuadratic(roots,nr_roots,
- 1.0,c3through2+m,lz_through2+n);
-
- db_SolveQuadratic(&roots[*nr_roots],&addroots,
- 1.0,c3through2-m,lz_through2-n);
-
- *nr_roots+=addroots;
- }
- else *nr_roots=0;
- }
- else *nr_roots=0;
- }
-}
-
-void db_SolveQuarticForced(double *roots,int *nr_roots,double a,double b,double c,double d,double e)
-{
- /*Normalized coefficients*/
- double c0,c1,c2,c3;
- /*Temporary coefficients*/
- double c3through2,c3through4,c3c3through4_min_c2,min4_c0;
- double lz,ms,ns,mn,m,n,lz_through2;
- /*Cubic polynomial roots, nr of roots and coefficients*/
- double c_roots[3];
- int nr_c_roots;
- double k0,k1;
- /*nr additional roots from second quadratic*/
- int addroots;
-
- /*For nondegenerate quartics
- [16mult 11add 2sqrt 1cubic 2quadratic=74flops 8funcs]*/
-
- if(a==0.0) db_SolveCubic(roots,nr_roots,b,c,d,e);
- else if(e==0.0)
- {
- db_SolveCubic(roots,nr_roots,a,b,c,d);
- roots[*nr_roots]=0.0;
- *nr_roots+=1;
- }
- else
- {
- /*Compute normalized coefficients*/
- c3=b/a;
- c2=c/a;
- c1=d/a;
- c0=e/a;
- /*Compute temporary coefficients*/
- c3through2=c3/2.0;
- c3through4=c3/4.0;
- c3c3through4_min_c2=c3*c3through4-c2;
- min4_c0= -4.0*c0;
- /*Compute coefficients of cubic*/
- k0=min4_c0*c3c3through4_min_c2-c1*c1;
- k1=c1*c3+min4_c0;
- /*k2= -c2*/
- /*k3=1.0*/
-
- /*Solve it for roots*/
- db_SolveCubic(c_roots,&nr_c_roots,1.0,-c2,k1,k0);
-
- if(nr_c_roots>0)
- {
- lz=c_roots[0];
- lz_through2=lz/2.0;
- ms=lz+c3c3through4_min_c2;
- ns=lz_through2*lz_through2-c0;
- mn=lz*c3through4-c1/2.0;
-
- if(ms<0.0) ms=0.0;
- if(ns<0.0) ns=0.0;
-
- m=sqrt(ms);
- n=sqrt(ns)*db_sign(mn);
-
- db_SolveQuadratic(roots,nr_roots,
- 1.0,c3through2+m,lz_through2+n);
-
- db_SolveQuadratic(&roots[*nr_roots],&addroots,
- 1.0,c3through2-m,lz_through2-n);
-
- *nr_roots+=addroots;
- }
- else *nr_roots=0;
- }
-}
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_poly.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_poly.h
deleted file mode 100644
index 1f87890..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_poly.h
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_poly.h,v 1.2 2010/09/03 12:00:11 bsouthall Exp $ */
-
-#ifndef DB_UTILITIES_POLY
-#define DB_UTILITIES_POLY
-
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMPolynomial (LM) Polynomial utilities (solvers, arithmetic, evaluation, etc.)
- */
-/*\{*/
-
-/*!
-In debug mode closed form quadratic solving takes on the order of 15 microseconds
-while eig of the companion matrix takes about 1.1 milliseconds
-Speed-optimized code in release mode solves a quadratic in 0.3 microseconds on 450MHz
-*/
-inline void db_SolveQuadratic(double *roots,int *nr_roots,double a,double b,double c)
-{
- double rs,srs,q;
-
- /*For non-degenerate quadratics
- [5 mult 2 add 1 sqrt=7flops 1func]*/
- if(a==0.0)
- {
- if(b==0.0) *nr_roots=0;
- else
- {
- roots[0]= -c/b;
- *nr_roots=1;
- }
- }
- else
- {
- rs=b*b-4.0*a*c;
- if(rs>=0.0)
- {
- *nr_roots=2;
- srs=sqrt(rs);
- q= -0.5*(b+db_sign(b)*srs);
- roots[0]=q/a;
- /*If b is zero db_sign(b) returns 1,
- so q is only zero when b=0 and c=0*/
- if(q==0.0) *nr_roots=1;
- else roots[1]=c/q;
- }
- else *nr_roots=0;
- }
-}
-
-/*!
-In debug mode closed form cubic solving takes on the order of 45 microseconds
-while eig of the companion matrix takes about 1.3 milliseconds
-Speed-optimized code in release mode solves a cubic in 1.5 microseconds on 450MHz
-For a non-degenerate cubic with two roots, the first root is the single root and
-the second root is the double root
-*/
-DB_API void db_SolveCubic(double *roots,int *nr_roots,double a,double b,double c,double d);
-/*!
-In debug mode closed form quartic solving takes on the order of 0.1 milliseconds
-while eig of the companion matrix takes about 1.5 milliseconds
-Speed-optimized code in release mode solves a quartic in 2.6 microseconds on 450MHz*/
-DB_API void db_SolveQuartic(double *roots,int *nr_roots,double a,double b,double c,double d,double e);
-/*!
-Quartic solving where a solution is forced when splitting into quadratics, which
-can be good if the quartic is sometimes in fact a quadratic, such as in absolute orientation
-when the data is planar*/
-DB_API void db_SolveQuarticForced(double *roots,int *nr_roots,double a,double b,double c,double d,double e);
-
-inline double db_PolyEval1(const double p[2],double x)
-{
- return(p[0]+x*p[1]);
-}
-
-inline void db_MultiplyPoly1_1(double *d,const double *a,const double *b)
-{
- double a0,a1;
- double b0,b1;
- a0=a[0];a1=a[1];
- b0=b[0];b1=b[1];
-
- d[0]=a0*b0;
- d[1]=a0*b1+a1*b0;
- d[2]= a1*b1;
-}
-
-inline void db_MultiplyPoly0_2(double *d,const double *a,const double *b)
-{
- double a0;
- double b0,b1,b2;
- a0=a[0];
- b0=b[0];b1=b[1];b2=b[2];
-
- d[0]=a0*b0;
- d[1]=a0*b1;
- d[2]=a0*b2;
-}
-
-inline void db_MultiplyPoly1_2(double *d,const double *a,const double *b)
-{
- double a0,a1;
- double b0,b1,b2;
- a0=a[0];a1=a[1];
- b0=b[0];b1=b[1];b2=b[2];
-
- d[0]=a0*b0;
- d[1]=a0*b1+a1*b0;
- d[2]=a0*b2+a1*b1;
- d[3]= a1*b2;
-}
-
-
-inline void db_MultiplyPoly1_3(double *d,const double *a,const double *b)
-{
- double a0,a1;
- double b0,b1,b2,b3;
- a0=a[0];a1=a[1];
- b0=b[0];b1=b[1];b2=b[2];b3=b[3];
-
- d[0]=a0*b0;
- d[1]=a0*b1+a1*b0;
- d[2]=a0*b2+a1*b1;
- d[3]=a0*b3+a1*b2;
- d[4]= a1*b3;
-}
-/*!
-Multiply d=a*b where a is one degree and b is two degree*/
-inline void db_AddPolyProduct0_1(double *d,const double *a,const double *b)
-{
- double a0;
- double b0,b1;
- a0=a[0];
- b0=b[0];b1=b[1];
-
- d[0]+=a0*b0;
- d[1]+=a0*b1;
-}
-inline void db_AddPolyProduct0_2(double *d,const double *a,const double *b)
-{
- double a0;
- double b0,b1,b2;
- a0=a[0];
- b0=b[0];b1=b[1];b2=b[2];
-
- d[0]+=a0*b0;
- d[1]+=a0*b1;
- d[2]+=a0*b2;
-}
-/*!
-Multiply d=a*b where a is one degree and b is two degree*/
-inline void db_SubtractPolyProduct0_0(double *d,const double *a,const double *b)
-{
- double a0;
- double b0;
- a0=a[0];
- b0=b[0];
-
- d[0]-=a0*b0;
-}
-
-inline void db_SubtractPolyProduct0_1(double *d,const double *a,const double *b)
-{
- double a0;
- double b0,b1;
- a0=a[0];
- b0=b[0];b1=b[1];
-
- d[0]-=a0*b0;
- d[1]-=a0*b1;
-}
-
-inline void db_SubtractPolyProduct0_2(double *d,const double *a,const double *b)
-{
- double a0;
- double b0,b1,b2;
- a0=a[0];
- b0=b[0];b1=b[1];b2=b[2];
-
- d[0]-=a0*b0;
- d[1]-=a0*b1;
- d[2]-=a0*b2;
-}
-
-inline void db_SubtractPolyProduct1_3(double *d,const double *a,const double *b)
-{
- double a0,a1;
- double b0,b1,b2,b3;
- a0=a[0];a1=a[1];
- b0=b[0];b1=b[1];b2=b[2];b3=b[3];
-
- d[0]-=a0*b0;
- d[1]-=a0*b1+a1*b0;
- d[2]-=a0*b2+a1*b1;
- d[3]-=a0*b3+a1*b2;
- d[4]-= a1*b3;
-}
-
-inline void db_CharacteristicPolynomial4x4(double p[5],const double A[16])
-{
- /*All two by two determinants of the first two rows*/
- double two01[3],two02[3],two03[3],two12[3],two13[3],two23[3];
- /*Polynomials representing third and fourth row of A*/
- double P0[2],P1[2],P2[2],P3[2];
- double P4[2],P5[2],P6[2],P7[2];
- /*All three by three determinants of the first three rows*/
- double neg_three0[4],neg_three1[4],three2[4],three3[4];
-
- /*Compute 2x2 determinants*/
- two01[0]=A[0]*A[5]-A[1]*A[4];
- two01[1]= -(A[0]+A[5]);
- two01[2]=1.0;
-
- two02[0]=A[0]*A[6]-A[2]*A[4];
- two02[1]= -A[6];
-
- two03[0]=A[0]*A[7]-A[3]*A[4];
- two03[1]= -A[7];
-
- two12[0]=A[1]*A[6]-A[2]*A[5];
- two12[1]=A[2];
-
- two13[0]=A[1]*A[7]-A[3]*A[5];
- two13[1]=A[3];
-
- two23[0]=A[2]*A[7]-A[3]*A[6];
-
- P0[0]=A[8];
- P1[0]=A[9];
- P2[0]=A[10];P2[1]= -1.0;
- P3[0]=A[11];
-
- P4[0]=A[12];
- P5[0]=A[13];
- P6[0]=A[14];
- P7[0]=A[15];P7[1]= -1.0;
-
- /*Compute 3x3 determinants.Note that the highest
- degree polynomial goes first and the smaller ones
- are added or subtracted from it*/
- db_MultiplyPoly1_1( neg_three0,P2,two13);
- db_SubtractPolyProduct0_0(neg_three0,P1,two23);
- db_SubtractPolyProduct0_1(neg_three0,P3,two12);
-
- db_MultiplyPoly1_1( neg_three1,P2,two03);
- db_SubtractPolyProduct0_1(neg_three1,P3,two02);
- db_SubtractPolyProduct0_0(neg_three1,P0,two23);
-
- db_MultiplyPoly0_2( three2,P3,two01);
- db_AddPolyProduct0_1( three2,P0,two13);
- db_SubtractPolyProduct0_1(three2,P1,two03);
-
- db_MultiplyPoly1_2( three3,P2,two01);
- db_AddPolyProduct0_1( three3,P0,two12);
- db_SubtractPolyProduct0_1(three3,P1,two02);
-
- /*Compute 4x4 determinants*/
- db_MultiplyPoly1_3( p,P7,three3);
- db_AddPolyProduct0_2( p,P4,neg_three0);
- db_SubtractPolyProduct0_2(p,P5,neg_three1);
- db_SubtractPolyProduct0_2(p,P6,three2);
-}
-
-inline void db_RealEigenvalues4x4(double lambda[4],int *nr_roots,const double A[16],int forced=0)
-{
- double p[5];
-
- db_CharacteristicPolynomial4x4(p,A);
- if(forced) db_SolveQuarticForced(lambda,nr_roots,p[4],p[3],p[2],p[1],p[0]);
- else db_SolveQuartic(lambda,nr_roots,p[4],p[3],p[2],p[1],p[0]);
-}
-
-/*!
-Compute the unit norm eigenvector v of the matrix A corresponding
-to the eigenvalue lambda
-[96mult 60add 1sqrt=156flops 1sqrt]*/
-inline void db_EigenVector4x4(double v[4],double lambda,const double A[16])
-{
- double a0,a5,a10,a15;
- double d01,d02,d03,d12,d13,d23;
- double e01,e02,e03,e12,e13,e23;
- double C[16],n0,n1,n2,n3,m;
-
- /*Compute diagonal
- [4add=4flops]*/
- a0=A[0]-lambda;
- a5=A[5]-lambda;
- a10=A[10]-lambda;
- a15=A[15]-lambda;
-
- /*Compute 2x2 determinants of rows 1,2 and 3,4
- [24mult 12add=36flops]*/
- d01=a0*a5 -A[1]*A[4];
- d02=a0*A[6] -A[2]*A[4];
- d03=a0*A[7] -A[3]*A[4];
- d12=A[1]*A[6]-A[2]*a5;
- d13=A[1]*A[7]-A[3]*a5;
- d23=A[2]*A[7]-A[3]*A[6];
-
- e01=A[8]*A[13]-A[9] *A[12];
- e02=A[8]*A[14]-a10 *A[12];
- e03=A[8]*a15 -A[11]*A[12];
- e12=A[9]*A[14]-a10 *A[13];
- e13=A[9]*a15 -A[11]*A[13];
- e23=a10 *a15 -A[11]*A[14];
-
- /*Compute matrix of cofactors
- [48mult 32 add=80flops*/
- C[0]= (a5 *e23-A[6]*e13+A[7]*e12);
- C[1]= -(A[4]*e23-A[6]*e03+A[7]*e02);
- C[2]= (A[4]*e13-a5 *e03+A[7]*e01);
- C[3]= -(A[4]*e12-a5 *e02+A[6]*e01);
-
- C[4]= -(A[1]*e23-A[2]*e13+A[3]*e12);
- C[5]= (a0 *e23-A[2]*e03+A[3]*e02);
- C[6]= -(a0 *e13-A[1]*e03+A[3]*e01);
- C[7]= (a0 *e12-A[1]*e02+A[2]*e01);
-
- C[8]= (A[13]*d23-A[14]*d13+a15 *d12);
- C[9]= -(A[12]*d23-A[14]*d03+a15 *d02);
- C[10]= (A[12]*d13-A[13]*d03+a15 *d01);
- C[11]= -(A[12]*d12-A[13]*d02+A[14]*d01);
-
- C[12]= -(A[9]*d23-a10 *d13+A[11]*d12);
- C[13]= (A[8]*d23-a10 *d03+A[11]*d02);
- C[14]= -(A[8]*d13-A[9]*d03+A[11]*d01);
- C[15]= (A[8]*d12-A[9]*d02+a10 *d01);
-
- /*Compute square sums of rows
- [16mult 12add=28flops*/
- n0=db_sqr(C[0]) +db_sqr(C[1]) +db_sqr(C[2]) +db_sqr(C[3]);
- n1=db_sqr(C[4]) +db_sqr(C[5]) +db_sqr(C[6]) +db_sqr(C[7]);
- n2=db_sqr(C[8]) +db_sqr(C[9]) +db_sqr(C[10])+db_sqr(C[11]);
- n3=db_sqr(C[12])+db_sqr(C[13])+db_sqr(C[14])+db_sqr(C[15]);
-
- /*Take the largest norm row and normalize
- [4mult 1 sqrt=4flops 1sqrt]*/
- if(n0>=n1 && n0>=n2 && n0>=n3)
- {
- m=db_SafeReciprocal(sqrt(n0));
- db_MultiplyScalarCopy4(v,C,m);
- }
- else if(n1>=n2 && n1>=n3)
- {
- m=db_SafeReciprocal(sqrt(n1));
- db_MultiplyScalarCopy4(v,&(C[4]),m);
- }
- else if(n2>=n3)
- {
- m=db_SafeReciprocal(sqrt(n2));
- db_MultiplyScalarCopy4(v,&(C[8]),m);
- }
- else
- {
- m=db_SafeReciprocal(sqrt(n3));
- db_MultiplyScalarCopy4(v,&(C[12]),m);
- }
-}
-
-
-
-/*\}*/
-#endif /* DB_UTILITIES_POLY */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_random.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_random.h
deleted file mode 100644
index ef24039..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_random.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_random.h,v 1.1 2010/08/19 18:09:20 bsouthall Exp $ */
-
-#ifndef DB_UTILITIES_RANDOM
-#define DB_UTILITIES_RANDOM
-
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMRandom (LM) Random numbers, random sampling
- */
-/*\{*/
-/*!
- Random Number generator. Initialize with non-zero
-integer value r. A double between zero and one is
-returned.
-\param r seed
-\return random double
-*/
-inline double db_QuickRandomDouble(int &r)
-{
- int c;
- c=r/127773;
- r=16807*(r-c*127773)-2836*c;
- if(r<0) r+=2147483647;
- return((1.0/((double)2147483647))*r);
- //return (((double)rand())/(double)RAND_MAX);
-}
-
-/*!
-Random Number generator. Initialize with non-zero
-integer value r. An int between and including 0 and max
- \param r seed
- \param max upped limit
- \return random int
-*/
-inline int db_RandomInt(int &r,int max)
-{
- double dtemp;
- int itemp;
- dtemp=db_QuickRandomDouble(r)*(max+1);
- itemp=(int) dtemp;
- if(itemp<=0) return(0);
- if(itemp>=max) return(max);
- return(itemp);
-}
-
-/*!
- Generate a random sample indexing into [0..pool_size-1].
- \param s sample (out) pre-allocated array of size sample_size
- \param sample_size size of sample
- \param pool_size upper limit on item index
- \param r_seed random number generator seed
- */
-inline void db_RandomSample(int *s,int sample_size,int pool_size,int &r_seed)
-{
- int temp,temp2,i,j;
-
- for(i=0;i<sample_size;i++)
- {
- temp=db_RandomInt(r_seed,pool_size-1-i);
-
- for(j=0;j<i;j++)
- {
- if(s[j]<=temp) temp++;
- else
- {
- /*swap*/
- temp2=temp;
- temp=s[j];
- s[j]=temp2;
- }
- }
- s[i]=temp;
- }
-}
-/*\}*/
-#endif /* DB_UTILITIES_RANDOM */
diff --git a/jni_mosaic/feature_stab/db_vlvm/db_utilities_rotation.h b/jni_mosaic/feature_stab/db_vlvm/db_utilities_rotation.h
deleted file mode 100644
index 7f5f937..0000000
--- a/jni_mosaic/feature_stab/db_vlvm/db_utilities_rotation.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/* $Id: db_utilities_rotation.h,v 1.2 2010/09/03 12:00:11 bsouthall Exp $ */
-
-#ifndef DB_UTILITIES_ROTATION
-#define DB_UTILITIES_ROTATION
-
-#include "db_utilities.h"
-
-
-
-/*****************************************************************
-* Lean and mean begins here *
-*****************************************************************/
-/*!
- * \defgroup LMRotation (LM) Rotation Utilities (quaternions, orthonormal)
- */
-/*\{*/
-/*!
- Takes a unit quaternion and gives its corresponding rotation matrix.
- \param R rotation matrix (out)
- \param q quaternion
- */
-inline void db_QuaternionToRotation(double R[9],const double q[4])
-{
- double q0q0,q0qx,q0qy,q0qz,qxqx,qxqy,qxqz,qyqy,qyqz,qzqz;
-
- q0q0=q[0]*q[0];
- q0qx=q[0]*q[1];
- q0qy=q[0]*q[2];
- q0qz=q[0]*q[3];
- qxqx=q[1]*q[1];
- qxqy=q[1]*q[2];
- qxqz=q[1]*q[3];
- qyqy=q[2]*q[2];
- qyqz=q[2]*q[3];
- qzqz=q[3]*q[3];
-
- R[0]=q0q0+qxqx-qyqy-qzqz; R[1]=2.0*(qxqy-q0qz); R[2]=2.0*(qxqz+q0qy);
- R[3]=2.0*(qxqy+q0qz); R[4]=q0q0-qxqx+qyqy-qzqz; R[5]=2.0*(qyqz-q0qx);
- R[6]=2.0*(qxqz-q0qy); R[7]=2.0*(qyqz+q0qx); R[8]=q0q0-qxqx-qyqy+qzqz;
-}
-
-/*\}*/
-#endif /* DB_UTILITIES_ROTATION */
diff --git a/jni_mosaic/feature_stab/doc/Readme.txt b/jni_mosaic/feature_stab/doc/Readme.txt
deleted file mode 100644
index fcd7c38..0000000
--- a/jni_mosaic/feature_stab/doc/Readme.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-To generate the html docs, execute
-doxygen dbreg_API_doxyfile
-
diff --git a/jni_mosaic/feature_stab/doc/dbreg_API_doxyfile b/jni_mosaic/feature_stab/doc/dbreg_API_doxyfile
deleted file mode 100755
index dc61a9c..0000000
--- a/jni_mosaic/feature_stab/doc/dbreg_API_doxyfile
+++ /dev/null
@@ -1,1557 +0,0 @@
-# Doxyfile 1.6.1
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all
-# text before the first occurrence of this tag. Doxygen uses libiconv (or the
-# iconv built into libc) for the transcoding. See
-# http://www.gnu.org/software/libiconv for the list of possible encodings.
-
-DOXYFILE_ENCODING = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME =
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER =
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY = .
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of
-# source files, where putting all generated files in the same directory would
-# otherwise cause performance problems for the file system.
-
-CREATE_SUBDIRS = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
-# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
-# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
-# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
-# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
-
-OUTPUT_LANGUAGE = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is
-# used as the annotated text. Otherwise, the brief description is used as-is.
-# If left blank, the following values are used ("$name" is automatically
-# replaced with the name of the entity): "The $name class" "The $name widget"
-# "The $name file" "is" "provides" "specifies" "contains"
-# "represents" "a" "an" "the"
-
-ABBREVIATE_BRIEF = "The $name class" \
- "The $name widget" \
- "The $name file" \
- is \
- provides \
- specifies \
- contains \
- represents \
- a \
- an \
- the
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-
-INLINE_INHERITED_MEMB = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip.
-
-STRIP_FROM_PATH = /Users/dimitri/doxygen/mail/1.5.7/doxywizard/
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
-
-STRIP_FROM_INC_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like regular Qt-style comments
-# (thus requiring an explicit @brief command for a brief description.)
-
-JAVADOC_AUTOBRIEF = NO
-
-# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
-# interpret the first line (until the first dot) of a Qt-style
-# comment as the brief description. If set to NO, the comments
-# will behave just like regular Qt-style comments (thus requiring
-# an explicit \brief command for a brief description.)
-
-QT_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
-
-INHERIT_DOCS = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
-# a new page for each member. If set to NO, the documentation of a member will
-# be part of the file/class/namespace that contains it.
-
-SEPARATE_MEMBER_PAGES = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE = 8
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
-# sources only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C = NO
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
-# sources only. Doxygen will then generate output that is more tailored for
-# Java. For instance, namespaces will be presented as packages, qualified
-# scopes will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
-# sources only. Doxygen will then generate output that is more tailored for
-# Fortran.
-
-OPTIMIZE_FOR_FORTRAN = NO
-
-# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
-# sources. Doxygen will then generate output that is tailored for
-# VHDL.
-
-OPTIMIZE_OUTPUT_VHDL = NO
-
-# Doxygen selects the parser to use depending on the extension of the files it parses.
-# With this tag you can assign which parser to use for a given extension.
-# Doxygen has a built-in mapping, but you can override or extend it using this tag.
-# The format is ext=language, where ext is a file extension, and language is one of
-# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
-# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
-# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
-# use: inc=Fortran f=C. Note that for custom extensions you also need to set
-# FILE_PATTERNS otherwise the files are not read by doxygen.
-
-EXTENSION_MAPPING =
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
-# to include (a tag file for) the STL sources as input, then you should
-# set this tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-
-BUILTIN_STL_SUPPORT = NO
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
-# enable parsing support.
-
-CPP_CLI_SUPPORT = NO
-
-# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
-# Doxygen will parse them like normal C++ but will assume all classes use public
-# instead of private inheritance when no explicit protection keyword is present.
-
-SIP_SUPPORT = NO
-
-# For Microsoft's IDL there are propget and propput attributes to indicate getter
-# and setter methods for a property. Setting this option to YES (the default)
-# will make doxygen to replace the get and set methods by a property in the
-# documentation. This will only work if the methods are indeed getting or
-# setting a simple type. If this is not the case, or you want to show the
-# methods anyway, you should set this option to NO.
-
-IDL_PROPERTY_SUPPORT = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING = YES
-
-# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
-# is documented as struct, union, or enum with the name of the typedef. So
-# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
-# with name TypeT. When disabled the typedef will appear as a member of a file,
-# namespace, or class. And the struct will be named TypeS. This can typically
-# be useful for C code in case the coding convention dictates that all compound
-# types are typedef'ed and only the typedef is referenced, never the tag name.
-
-TYPEDEF_HIDES_STRUCT = NO
-
-# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
-# determine which symbols to keep in memory and which to flush to disk.
-# When the cache is full, less often used symbols will be written to disk.
-# For small to medium size projects (<1000 input files) the default value is
-# probably good enough. For larger projects a too small cache size can cause
-# doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penality.
-# If the system has enough physical memory increasing the cache will improve the
-# performance by keeping more symbols in memory. Note that the value works on
-# a logarithmic scale so increasing the size by one will rougly double the
-# memory usage. The cache size is given by this formula:
-# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols
-
-SYMBOL_CACHE_SIZE = 0
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL = NO
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE = NO
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC = NO
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES = YES
-
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
-
-EXTRACT_LOCAL_METHODS = NO
-
-# If this flag is set to YES, the members of anonymous namespaces will be
-# extracted and appear in the documentation as a namespace called
-# 'anonymous_namespace{file}', where file will be replaced with the base
-# name of the file that contains the anonymous namespace. By default
-# anonymous namespace are hidden.
-
-EXTRACT_ANON_NSPACES = NO
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES = NO
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
-
-SORT_BRIEF_DOCS = NO
-
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
-# will sort the (brief and detailed) documentation of class members so that
-# constructors and destructors are listed first. If set to NO (the default)
-# the constructors will appear in the respective orders defined by
-# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
-# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
-# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
-
-SORT_MEMBERS_CTORS_1ST = NO
-
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
-# hierarchy of group names into alphabetical order. If set to NO (the default)
-# the group names will appear in their defined order.
-
-SORT_GROUP_NAMES = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
-
-SORT_BY_SCOPE_NAME = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES = YES
-
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES = NO
-
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
-# This will remove the Files entry from the Quick Index and from the
-# Folder Tree View (if specified). The default is YES.
-
-SHOW_FILES = YES
-
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
-# Namespaces page. This will remove the Namespaces entry from the Quick Index
-# and from the Folder Tree View (if specified). The default is YES.
-
-SHOW_NAMESPACES = YES
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from
-# the version control system). Doxygen will invoke the program by executing (via
-# popen()) the command <command> <input-file>, where <command> is the value of
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
-# provided by doxygen. Whatever the program writes to standard output
-# is used as the file version. See the manual for examples.
-
-FILE_VERSION_FILTER =
-
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
-# doxygen. The layout file controls the global structure of the generated output files
-# in an output format independent way. The create the layout file that represents
-# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
-# file name after the option, if omitted DoxygenLayout.xml will be used as the name
-# of the layout file.
-
-LAYOUT_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET = NO
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR = YES
-
-# This WARN_NO_PARAMDOC option can be abled to get warnings for
-# functions that are documented, but have no documentation for their parameters
-# or return value. If set to NO (the default) doxygen will only warn about
-# wrong or incomplete parameter documentation, but not about the absence of
-# documentation.
-
-WARN_NO_PARAMDOC = NO
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text. Optionally the format may contain
-# $version, which will be replaced by the version of the file (if it could
-# be obtained via FILE_VERSION_FILTER)
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT = ../src/dbreg/dbreg.h
-
-# This tag can be used to specify the character encoding of the source files
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
-# also the default input encoding. Doxygen uses libiconv (or the iconv built
-# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
-# the list of possible encodings.
-
-INPUT_ENCODING = UTF-8
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-
-FILE_PATTERNS = *.c \
- *.cc \
- *.cxx \
- *.cpp \
- *.c++ \
- *.d \
- *.java \
- *.ii \
- *.ixx \
- *.ipp \
- *.i++ \
- *.inl \
- *.h \
- *.hh \
- *.hxx \
- *.hpp \
- *.h++ \
- *.idl \
- *.odl \
- *.cs \
- *.php \
- *.php3 \
- *.inc \
- *.m \
- *.mm \
- *.dox \
- *.py \
- *.f90 \
- *.f \
- *.vhd \
- *.vhdl
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE =
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
-# from the input.
-
-EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories. Note that the wildcards are matched
-# against the file with absolute path, so to exclude all test directories
-# for example use the pattern */test/*
-
-EXCLUDE_PATTERNS =
-
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
-# (namespaces, classes, functions, etc.) that should be excluded from the
-# output. The symbol name can be a fully qualified name, a word, or if the
-# wildcard * is used, a substring. Examples: ANamespace, AClass,
-# AClass::ANamespace, ANamespace::*Test
-
-EXCLUDE_SYMBOLS =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS = *
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output. If FILTER_PATTERNS is specified, this tag will be
-# ignored.
-
-INPUT_FILTER =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis. Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match. The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
-
-FILTER_PATTERNS =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
-
-SOURCE_BROWSER = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = NO
-
-# If the REFERENCES_RELATION tag is set to YES
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION = NO
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code. Otherwise they will link to the documentation.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code
-# will point to the HTML generated by the htags(1) tool instead of doxygen
-# built-in source browser. The htags tool is part of GNU's global source
-# tagging system (see http://www.gnu.org/software/global/global.html). You
-# will need version 4.8.6 or higher.
-
-USE_HTAGS = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX = NO
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER =
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet. Note that doxygen will try to copy
-# the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET =
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS = YES
-
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
-# documentation will contain sections that can be hidden and shown after the
-# page has loaded. For this to work a browser that supports
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
-
-HTML_DYNAMIC_SECTIONS = NO
-
-# If the GENERATE_DOCSET tag is set to YES, additional index files
-# will be generated that can be used as input for Apple's Xcode 3
-# integrated development environment, introduced with OSX 10.5 (Leopard).
-# To create a documentation set, doxygen will generate a Makefile in the
-# HTML output directory. Running make will produce the docset in that
-# directory and running "make install" will install the docset in
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
-# it at startup.
-# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
-
-GENERATE_DOCSET = NO
-
-# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
-# feed. A documentation feed provides an umbrella under which multiple
-# documentation sets from a single provider (such as a company or product suite)
-# can be grouped.
-
-DOCSET_FEEDNAME = "Doxygen generated docs"
-
-# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
-# should uniquely identify the documentation set bundle. This should be a
-# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
-# will append .docset to the name.
-
-DOCSET_BUNDLE_ID = org.doxygen.Project
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output directory.
-
-CHM_FILE =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
-# is used to encode HtmlHelp index (hhk), content (hhc) and project file
-# content.
-
-CHM_INDEX_ENCODING =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND = NO
-
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
-# are set, an additional index file will be generated that can be used as input for
-# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
-# HTML documentation.
-
-GENERATE_QHP = NO
-
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
-# be used to specify the file name of the resulting .qch file.
-# The path specified is relative to the HTML output folder.
-
-QCH_FILE =
-
-# The QHP_NAMESPACE tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#namespace
-
-QHP_NAMESPACE =
-
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#virtual-folders
-
-QHP_VIRTUAL_FOLDER = doc
-
-# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
-# For more information please see
-# http://doc.trolltech.com/qthelpproject.html#custom-filters
-
-QHP_CUST_FILTER_NAME =
-
-# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
-# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
-
-QHP_CUST_FILTER_ATTRS =
-
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
-# filter section matches.
-# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
-
-QHP_SECT_FILTER_ATTRS =
-
-# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
-# be used to specify the location of Qt's qhelpgenerator.
-# If non-empty doxygen will try to run qhelpgenerator on the generated
-# .qhp file.
-
-QHG_LOCATION =
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE = 4
-
-# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
-# structure should be generated to display hierarchical information.
-# If the tag value is set to YES, a side panel will be generated
-# containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
-# Windows users are probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW = NO
-
-# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
-# and Class Hierarchy pages using a tree view instead of an ordered list.
-
-USE_INLINE_TREES = NO
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH = 250
-
-# Use this tag to change the font size of Latex formulas included
-# as images in the HTML documentation. The default is 10. Note that
-# when you change the font size after a successful doxygen run you need
-# to manually remove any form_*.png images from the HTML output directory
-# to force them to be regenerated.
-
-FORMULA_FONTSIZE = 10
-
-# When the SEARCHENGINE tag is enable doxygen will generate a search box
-# for the HTML output. The underlying search engine uses javascript
-# and DHTML and should work on any modern browser. Note that when using
-# HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP)
-# there is already a search function so this one should typically
-# be disabled.
-
-SEARCHENGINE = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-
-LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS = YES
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX = YES
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES = NO
-
-# If LATEX_SOURCE_CODE is set to YES then doxygen will include
-# source code with syntax highlighting in the LaTeX output.
-# Note that which sources are shown also depends on other settings
-# such as SOURCE_BROWSER.
-
-LATEX_SOURCE_CODE = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
-
-XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader. This is useful
-# if you want to understand what is going on. On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_DEFINED tags.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed. To prevent a macro definition from being
-# undefined via #undef or recursively expanded use the := operator
-# instead of the = operator.
-
-PREDEFINED =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
-# or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option is superseded by the HAVE_DOT option below. This is only a
-# fallback. It is recommended to install and use dot, since it yields more
-# powerful graphs.
-
-CLASS_DIAGRAMS = YES
-
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see
-# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT = NO
-
-# By default doxygen will write a font called FreeSans.ttf to the output
-# directory and reference it in all dot files that doxygen generates. This
-# font does not include all possible unicode characters however, so when you need
-# these (or just want a differently looking font) you can specify the font name
-# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
-# which can be done by putting it in a standard location or by setting the
-# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
-# containing the font.
-
-DOT_FONTNAME = FreeSans
-
-# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
-# The default size is 10pt.
-
-DOT_FONTSIZE = 10
-
-# By default doxygen will tell dot to use the output directory to look for the
-# FreeSans.ttf font (which doxygen will put there itself). If you specify a
-# different font using DOT_FONTNAME you can set the path where dot
-# can find it using this tag.
-
-DOT_FONTPATH =
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH = YES
-
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for groups, showing the direct groups dependencies
-
-GROUP_GRAPHS = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH and HAVE_DOT options are set to YES then
-# doxygen will generate a call dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable call graphs
-# for selected functions only using the \callgraph command.
-
-CALL_GRAPH = NO
-
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
-# doxygen will generate a caller dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable caller
-# graphs for selected functions only using the \callergraph command.
-
-CALLER_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
-# then doxygen will show the dependencies a directory has on other directories
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
-
-DIRECTORY_GRAPH = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-
-DOT_PATH =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS =
-
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
-# nodes that will be shown in the graph. If the number of nodes in a graph
-# becomes larger than this value, doxygen will truncate the graph, which is
-# visualized by representing a node as a red box. Note that doxygen if the
-# number of direct children of the root node in a graph is already larger than
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
-# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
-
-DOT_GRAPH_MAX_NODES = 50
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes
-# that lay further from the root node will be omitted. Note that setting this
-# option to 1 or 2 may greatly reduce the computation time needed for large
-# code bases. Also note that the size of a graph can be further restricted by
-# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
-
-MAX_DOT_GRAPH_DEPTH = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, because dot on Windows does not
-# seem to support this out of the box. Warning: Depending on the platform used,
-# enabling this option may lead to badly anti-aliased labels on the edges of
-# a graph (i.e. they become hard to read).
-
-DOT_TRANSPARENT = NO
-
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10)
-# support this, this feature is disabled by default.
-
-DOT_MULTI_TARGETS = NO
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP = YES
diff --git a/jni_mosaic/feature_stab/src/dbreg/dbreg.cpp b/jni_mosaic/feature_stab/src/dbreg/dbreg.cpp
deleted file mode 100644
index da06aa2..0000000
--- a/jni_mosaic/feature_stab/src/dbreg/dbreg.cpp
+++ /dev/null
@@ -1,794 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// $Id: dbreg.cpp,v 1.31 2011/06/17 14:04:32 mbansal Exp $
-#include "dbreg.h"
-#include <string.h>
-#include <stdio.h>
-
-
-#if PROFILE
-#endif
-
-//#include <iostream>
-
-db_FrameToReferenceRegistration::db_FrameToReferenceRegistration() :
- m_initialized(false),m_nr_matches(0),m_over_allocation(256),m_nr_bins(20),m_max_cost_pix(30), m_quarter_resolution(false)
-{
- m_reference_image = NULL;
- m_aligned_ins_image = NULL;
-
- m_quarter_res_image = NULL;
- m_horz_smooth_subsample_image = NULL;
-
- m_x_corners_ref = NULL;
- m_y_corners_ref = NULL;
-
- m_x_corners_ins = NULL;
- m_y_corners_ins = NULL;
-
- m_match_index_ref = NULL;
- m_match_index_ins = NULL;
-
- m_inlier_indices = NULL;
-
- m_num_inlier_indices = 0;
-
- m_temp_double = NULL;
- m_temp_int = NULL;
-
- m_corners_ref = NULL;
- m_corners_ins = NULL;
-
- m_sq_cost = NULL;
- m_cost_histogram = NULL;
-
- profile_string = NULL;
-
- db_Identity3x3(m_K);
- db_Identity3x3(m_H_ref_to_ins);
- db_Identity3x3(m_H_dref_to_ref);
-
- m_sq_cost_computed = false;
- m_reference_set = false;
-
- m_reference_update_period = 0;
- m_nr_frames_processed = 0;
-
- return;
-}
-
-db_FrameToReferenceRegistration::~db_FrameToReferenceRegistration()
-{
- Clean();
-}
-
-void db_FrameToReferenceRegistration::Clean()
-{
- if ( m_reference_image )
- db_FreeImage_u(m_reference_image,m_im_height);
-
- if ( m_aligned_ins_image )
- db_FreeImage_u(m_aligned_ins_image,m_im_height);
-
- if ( m_quarter_res_image )
- {
- db_FreeImage_u(m_quarter_res_image, m_im_height);
- }
-
- if ( m_horz_smooth_subsample_image )
- {
- db_FreeImage_u(m_horz_smooth_subsample_image, m_im_height*2);
- }
-
- delete [] m_x_corners_ref;
- delete [] m_y_corners_ref;
-
- delete [] m_x_corners_ins;
- delete [] m_y_corners_ins;
-
- delete [] m_match_index_ref;
- delete [] m_match_index_ins;
-
- delete [] m_temp_double;
- delete [] m_temp_int;
-
- delete [] m_corners_ref;
- delete [] m_corners_ins;
-
- delete [] m_sq_cost;
- delete [] m_cost_histogram;
-
- delete [] m_inlier_indices;
-
- if(profile_string)
- delete [] profile_string;
-
- m_reference_image = NULL;
- m_aligned_ins_image = NULL;
-
- m_quarter_res_image = NULL;
- m_horz_smooth_subsample_image = NULL;
-
- m_x_corners_ref = NULL;
- m_y_corners_ref = NULL;
-
- m_x_corners_ins = NULL;
- m_y_corners_ins = NULL;
-
- m_match_index_ref = NULL;
- m_match_index_ins = NULL;
-
- m_inlier_indices = NULL;
-
- m_temp_double = NULL;
- m_temp_int = NULL;
-
- m_corners_ref = NULL;
- m_corners_ins = NULL;
-
- m_sq_cost = NULL;
- m_cost_histogram = NULL;
-}
-
-void db_FrameToReferenceRegistration::Init(int width, int height,
- int homography_type,
- int max_iterations,
- bool linear_polish,
- bool quarter_resolution,
- double scale,
- unsigned int reference_update_period,
- bool do_motion_smoothing,
- double motion_smoothing_gain,
- int nr_samples,
- int chunk_size,
- int cd_target_nr_corners,
- double cm_max_disparity,
- bool cm_use_smaller_matching_window,
- int cd_nr_horz_blocks,
- int cd_nr_vert_blocks
- )
-{
- Clean();
-
- m_reference_update_period = reference_update_period;
- m_nr_frames_processed = 0;
-
- m_do_motion_smoothing = do_motion_smoothing;
- m_motion_smoothing_gain = motion_smoothing_gain;
-
- m_stab_smoother.setSmoothingFactor(m_motion_smoothing_gain);
-
- m_quarter_resolution = quarter_resolution;
-
- profile_string = new char[10240];
-
- if (m_quarter_resolution == true)
- {
- width = width/2;
- height = height/2;
-
- m_horz_smooth_subsample_image = db_AllocImage_u(width,height*2,m_over_allocation);
- m_quarter_res_image = db_AllocImage_u(width,height,m_over_allocation);
- }
-
- m_im_width = width;
- m_im_height = height;
-
- double temp[9];
- db_Approx3DCalMat(m_K,temp,m_im_width,m_im_height);
-
- m_homography_type = homography_type;
- m_max_iterations = max_iterations;
- m_scale = 2/(m_K[0]+m_K[4]);
- m_nr_samples = nr_samples;
- m_chunk_size = chunk_size;
-
- double outlier_t1 = 5.0;
-
- m_outlier_t2 = outlier_t1*outlier_t1;//*m_scale*m_scale;
-
- m_current_is_reference = false;
-
- m_linear_polish = linear_polish;
-
- m_reference_image = db_AllocImage_u(m_im_width,m_im_height,m_over_allocation);
- m_aligned_ins_image = db_AllocImage_u(m_im_width,m_im_height,m_over_allocation);
-
- // initialize feature detection and matching:
- //m_max_nr_corners = m_cd.Init(m_im_width,m_im_height,cd_target_nr_corners,cd_nr_horz_blocks,cd_nr_vert_blocks,0.0,0.0);
- m_max_nr_corners = m_cd.Init(m_im_width,m_im_height,cd_target_nr_corners,cd_nr_horz_blocks,cd_nr_vert_blocks,DB_DEFAULT_ABS_CORNER_THRESHOLD/500.0,0.0);
-
- int use_21 = 0;
- m_max_nr_matches = m_cm.Init(m_im_width,m_im_height,cm_max_disparity,m_max_nr_corners,DB_DEFAULT_NO_DISPARITY,cm_use_smaller_matching_window,use_21);
-
- // allocate space for corner feature locations for reference and inspection images:
- m_x_corners_ref = new double [m_max_nr_corners];
- m_y_corners_ref = new double [m_max_nr_corners];
-
- m_x_corners_ins = new double [m_max_nr_corners];
- m_y_corners_ins = new double [m_max_nr_corners];
-
- // allocate space for match indices:
- m_match_index_ref = new int [m_max_nr_matches];
- m_match_index_ins = new int [m_max_nr_matches];
-
- m_temp_double = new double [12*DB_DEFAULT_NR_SAMPLES+10*m_max_nr_matches];
- m_temp_int = new int [db_maxi(DB_DEFAULT_NR_SAMPLES,m_max_nr_matches)];
-
- // allocate space for homogenous image points:
- m_corners_ref = new double [3*m_max_nr_corners];
- m_corners_ins = new double [3*m_max_nr_corners];
-
- // allocate cost array and histogram:
- m_sq_cost = new double [m_max_nr_matches];
- m_cost_histogram = new int [m_nr_bins];
-
- // reserve array:
- //m_inlier_indices.reserve(m_max_nr_matches);
- m_inlier_indices = new int[m_max_nr_matches];
-
- m_initialized = true;
-
- m_max_inlier_count = 0;
-}
-
-
-#define MB 0
-// Save the reference image, detect features and update the dref-to-ref transformation
-int db_FrameToReferenceRegistration::UpdateReference(const unsigned char * const * im, bool subsample, bool detect_corners)
-{
- double temp[9];
- db_Multiply3x3_3x3(temp,m_H_dref_to_ref,m_H_ref_to_ins);
- db_Copy9(m_H_dref_to_ref,temp);
-
- const unsigned char * const * imptr = im;
-
- if (m_quarter_resolution && subsample)
- {
- GenerateQuarterResImage(im);
- imptr = m_quarter_res_image;
- }
-
- // save the reference image, detect features and quit
- db_CopyImage_u(m_reference_image,imptr,m_im_width,m_im_height,m_over_allocation);
-
- if(detect_corners)
- {
- #if MB
- m_cd.DetectCorners(imptr, m_x_corners_ref,m_y_corners_ref,&m_nr_corners_ref);
- int nr = 0;
- for(int k=0; k<m_nr_corners_ref; k++)
- {
- if(m_x_corners_ref[k]>m_im_width/3)
- {
- m_x_corners_ref[nr] = m_x_corners_ref[k];
- m_y_corners_ref[nr] = m_y_corners_ref[k];
- nr++;
- }
-
- }
- m_nr_corners_ref = nr;
- #else
- m_cd.DetectCorners(imptr, m_x_corners_ref,m_y_corners_ref,&m_nr_corners_ref);
- #endif
- }
- else
- {
- m_nr_corners_ref = m_nr_corners_ins;
-
- for(int k=0; k<m_nr_corners_ins; k++)
- {
- m_x_corners_ref[k] = m_x_corners_ins[k];
- m_y_corners_ref[k] = m_y_corners_ins[k];
- }
-
- }
-
- db_Identity3x3(m_H_ref_to_ins);
-
- m_max_inlier_count = 0; // Reset to 0 as no inliers seen until now
- m_sq_cost_computed = false;
- m_reference_set = true;
- m_current_is_reference = true;
- return 1;
-}
-
-void db_FrameToReferenceRegistration::Get_H_dref_to_ref(double H[9])
-{
- db_Copy9(H,m_H_dref_to_ref);
-}
-
-void db_FrameToReferenceRegistration::Get_H_dref_to_ins(double H[9])
-{
- db_Multiply3x3_3x3(H,m_H_dref_to_ref,m_H_ref_to_ins);
-}
-
-void db_FrameToReferenceRegistration::Set_H_dref_to_ins(double H[9])
-{
- double H_ins_to_ref[9];
-
- db_Identity3x3(H_ins_to_ref); // Ensure it has proper values
- db_InvertAffineTransform(H_ins_to_ref,m_H_ref_to_ins); // Invert to get ins to ref
- db_Multiply3x3_3x3(m_H_dref_to_ref,H,H_ins_to_ref); // Update dref to ref using the input H from dref to ins
-}
-
-
-void db_FrameToReferenceRegistration::ResetDisplayReference()
-{
- db_Identity3x3(m_H_dref_to_ref);
-}
-
-bool db_FrameToReferenceRegistration::NeedReferenceUpdate()
-{
- // If less than 50% of the starting number of inliers left, then its time to update the reference.
- if(m_max_inlier_count>0 && float(m_num_inlier_indices)/float(m_max_inlier_count)<0.5)
- return true;
- else
- return false;
-}
-
-int db_FrameToReferenceRegistration::AddFrame(const unsigned char * const * im, double H[9],bool force_reference,bool prewarp)
-{
- m_current_is_reference = false;
- if(!m_reference_set || force_reference)
- {
- db_Identity3x3(m_H_ref_to_ins);
- db_Copy9(H,m_H_ref_to_ins);
-
- UpdateReference(im,true,true);
- return 0;
- }
-
- const unsigned char * const * imptr = im;
-
- if (m_quarter_resolution)
- {
- if (m_quarter_res_image)
- {
- GenerateQuarterResImage(im);
- }
-
- imptr = (const unsigned char * const* )m_quarter_res_image;
- }
-
- double H_last[9];
- db_Copy9(H_last,m_H_ref_to_ins);
- db_Identity3x3(m_H_ref_to_ins);
-
- m_sq_cost_computed = false;
-
- // detect corners on inspection image and match to reference image features:s
-
- // @jke - Adding code to time the functions. TODO: Remove after test
-#if PROFILE
- double iTimer1, iTimer2;
- char str[255];
- strcpy(profile_string,"\n");
- sprintf(str,"[%dx%d] %p\n",m_im_width,m_im_height,im);
- strcat(profile_string, str);
-#endif
-
- // @jke - Adding code to time the functions. TODO: Remove after test
-#if PROFILE
- iTimer1 = now_ms();
-#endif
- m_cd.DetectCorners(imptr, m_x_corners_ins,m_y_corners_ins,&m_nr_corners_ins);
- // @jke - Adding code to time the functions. TODO: Remove after test
-# if PROFILE
- iTimer2 = now_ms();
- double elapsedTimeCorner = iTimer2 - iTimer1;
- sprintf(str,"Corner Detection [%d corners] = %g ms\n",m_nr_corners_ins, elapsedTimeCorner);
- strcat(profile_string, str);
-#endif
-
- // @jke - Adding code to time the functions. TODO: Remove after test
-#if PROFILE
- iTimer1 = now_ms();
-#endif
- if(prewarp)
- m_cm.Match(m_reference_image,imptr,m_x_corners_ref,m_y_corners_ref,m_nr_corners_ref,
- m_x_corners_ins,m_y_corners_ins,m_nr_corners_ins,
- m_match_index_ref,m_match_index_ins,&m_nr_matches,H,0);
- else
- m_cm.Match(m_reference_image,imptr,m_x_corners_ref,m_y_corners_ref,m_nr_corners_ref,
- m_x_corners_ins,m_y_corners_ins,m_nr_corners_ins,
- m_match_index_ref,m_match_index_ins,&m_nr_matches);
- // @jke - Adding code to time the functions. TODO: Remove after test
-# if PROFILE
- iTimer2 = now_ms();
- double elapsedTimeMatch = iTimer2 - iTimer1;
- sprintf(str,"Matching [%d] = %g ms\n",m_nr_matches,elapsedTimeMatch);
- strcat(profile_string, str);
-#endif
-
-
- // copy out matching features:
- for ( int i = 0; i < m_nr_matches; ++i )
- {
- int offset = 3*i;
- m_corners_ref[offset ] = m_x_corners_ref[m_match_index_ref[i]];
- m_corners_ref[offset+1] = m_y_corners_ref[m_match_index_ref[i]];
- m_corners_ref[offset+2] = 1.0;
-
- m_corners_ins[offset ] = m_x_corners_ins[m_match_index_ins[i]];
- m_corners_ins[offset+1] = m_y_corners_ins[m_match_index_ins[i]];
- m_corners_ins[offset+2] = 1.0;
- }
-
- // @jke - Adding code to time the functions. TODO: Remove after test
-#if PROFILE
- iTimer1 = now_ms();
-#endif
- // perform the alignment:
- db_RobImageHomography(m_H_ref_to_ins, m_corners_ref, m_corners_ins, m_nr_matches, m_K, m_K, m_temp_double, m_temp_int,
- m_homography_type,NULL,m_max_iterations,m_max_nr_matches,m_scale,
- m_nr_samples, m_chunk_size);
- // @jke - Adding code to time the functions. TODO: Remove after test
-# if PROFILE
- iTimer2 = now_ms();
- double elapsedTimeHomography = iTimer2 - iTimer1;
- sprintf(str,"Homography = %g ms\n",elapsedTimeHomography);
- strcat(profile_string, str);
-#endif
-
-
- SetOutlierThreshold();
-
- // Compute the inliers for the db compute m_H_ref_to_ins
- ComputeInliers(m_H_ref_to_ins);
-
- // Update the max inlier count
- m_max_inlier_count = (m_max_inlier_count > m_num_inlier_indices)?m_max_inlier_count:m_num_inlier_indices;
-
- // Fit a least-squares model to just the inliers and put it in m_H_ref_to_ins
- if(m_linear_polish)
- Polish(m_inlier_indices, m_num_inlier_indices);
-
- if (m_quarter_resolution)
- {
- m_H_ref_to_ins[2] *= 2.0;
- m_H_ref_to_ins[5] *= 2.0;
- }
-
-#if PROFILE
- sprintf(str,"#Inliers = %d \n",m_num_inlier_indices);
- strcat(profile_string, str);
-#endif
-/*
- ///// CHECK IF CURRENT TRANSFORMATION GOOD OR BAD ////
- ///// IF BAD, then update reference to the last correctly aligned inspection frame;
- if(m_num_inlier_indices<5)//0.9*m_nr_matches || m_nr_matches < 20)
- {
- db_Copy9(m_H_ref_to_ins,H_last);
- UpdateReference(imptr,false);
-// UpdateReference(m_aligned_ins_image,false);
- }
- else
- {
- ///// IF GOOD, then update the last correctly aligned inspection frame to be this;
- //db_CopyImage_u(m_aligned_ins_image,imptr,m_im_width,m_im_height,m_over_allocation);
-*/
- if(m_do_motion_smoothing)
- SmoothMotion();
-
- // Disable debug printing
- // db_PrintDoubleMatrix(m_H_ref_to_ins,3,3);
-
- db_Copy9(H, m_H_ref_to_ins);
-
- m_nr_frames_processed++;
-{
- if ( (m_nr_frames_processed % m_reference_update_period) == 0 )
- {
- //UpdateReference(imptr,false, false);
-
- #if MB
- UpdateReference(imptr,false, true);
- #else
- UpdateReference(imptr,false, false);
- #endif
- }
-
-
- }
-
-
-
- return 1;
-}
-
-//void db_FrameToReferenceRegistration::ComputeInliers(double H[9],std::vector<int> &inlier_indices)
-void db_FrameToReferenceRegistration::ComputeInliers(double H[9])
-{
- double totnummatches = m_nr_matches;
- int inliercount=0;
-
- m_num_inlier_indices = 0;
-// inlier_indices.clear();
-
- for(int c=0; c < totnummatches; c++ )
- {
- if (m_sq_cost[c] <= m_outlier_t2)
- {
- m_inlier_indices[inliercount] = c;
- inliercount++;
- }
- }
-
- m_num_inlier_indices = inliercount;
- double frac=inliercount/totnummatches;
-}
-
-//void db_FrameToReferenceRegistration::Polish(std::vector<int> &inlier_indices)
-void db_FrameToReferenceRegistration::Polish(int *inlier_indices, int &num_inlier_indices)
-{
- db_Zero(m_polish_C,36);
- db_Zero(m_polish_D,6);
- for (int i=0;i<num_inlier_indices;i++)
- {
- int j = 3*inlier_indices[i];
- m_polish_C[0]+=m_corners_ref[j]*m_corners_ref[j];
- m_polish_C[1]+=m_corners_ref[j]*m_corners_ref[j+1];
- m_polish_C[2]+=m_corners_ref[j];
- m_polish_C[7]+=m_corners_ref[j+1]*m_corners_ref[j+1];
- m_polish_C[8]+=m_corners_ref[j+1];
- m_polish_C[14]+=1;
- m_polish_D[0]+=m_corners_ref[j]*m_corners_ins[j];
- m_polish_D[1]+=m_corners_ref[j+1]*m_corners_ins[j];
- m_polish_D[2]+=m_corners_ins[j];
- m_polish_D[3]+=m_corners_ref[j]*m_corners_ins[j+1];
- m_polish_D[4]+=m_corners_ref[j+1]*m_corners_ins[j+1];
- m_polish_D[5]+=m_corners_ins[j+1];
- }
-
- double a=db_maxd(m_polish_C[0],m_polish_C[7]);
- m_polish_C[0]/=a; m_polish_C[1]/=a; m_polish_C[2]/=a;
- m_polish_C[7]/=a; m_polish_C[8]/=a; m_polish_C[14]/=a;
-
- m_polish_D[0]/=a; m_polish_D[1]/=a; m_polish_D[2]/=a;
- m_polish_D[3]/=a; m_polish_D[4]/=a; m_polish_D[5]/=a;
-
-
- m_polish_C[6]=m_polish_C[1];
- m_polish_C[12]=m_polish_C[2];
- m_polish_C[13]=m_polish_C[8];
-
- m_polish_C[21]=m_polish_C[0]; m_polish_C[22]=m_polish_C[1]; m_polish_C[23]=m_polish_C[2];
- m_polish_C[28]=m_polish_C[7]; m_polish_C[29]=m_polish_C[8];
- m_polish_C[35]=m_polish_C[14];
-
-
- double d[6];
- db_CholeskyDecomp6x6(m_polish_C,d);
- db_CholeskyBacksub6x6(m_H_ref_to_ins,m_polish_C,d,m_polish_D);
-}
-
-void db_FrameToReferenceRegistration::EstimateSecondaryModel(double H[9])
-{
- /* if ( m_current_is_reference )
- {
- db_Identity3x3(H);
- return;
- }
- */
-
- // select the outliers of the current model:
- SelectOutliers();
-
- // perform the alignment:
- db_RobImageHomography(m_H_ref_to_ins, m_corners_ref, m_corners_ins, m_nr_matches, m_K, m_K, m_temp_double, m_temp_int,
- m_homography_type,NULL,m_max_iterations,m_max_nr_matches,m_scale,
- m_nr_samples, m_chunk_size);
-
- db_Copy9(H,m_H_ref_to_ins);
-}
-
-void db_FrameToReferenceRegistration::ComputeCostArray()
-{
- if ( m_sq_cost_computed ) return;
-
- for( int c=0, k=0 ;c < m_nr_matches; c++, k=k+3)
- {
- m_sq_cost[c] = SquaredInhomogenousHomographyError(m_corners_ins+k,m_H_ref_to_ins,m_corners_ref+k);
- }
-
- m_sq_cost_computed = true;
-}
-
-void db_FrameToReferenceRegistration::SelectOutliers()
-{
- int nr_outliers=0;
-
- ComputeCostArray();
-
- for(int c=0, k=0 ;c<m_nr_matches;c++,k=k+3)
- {
- if (m_sq_cost[c] > m_outlier_t2)
- {
- int offset = 3*nr_outliers++;
- db_Copy3(m_corners_ref+offset,m_corners_ref+k);
- db_Copy3(m_corners_ins+offset,m_corners_ins+k);
- }
- }
-
- m_nr_matches = nr_outliers;
-}
-
-void db_FrameToReferenceRegistration::ComputeCostHistogram()
-{
- ComputeCostArray();
-
- for ( int b = 0; b < m_nr_bins; ++b )
- m_cost_histogram[b] = 0;
-
- for(int c = 0; c < m_nr_matches; c++)
- {
- double error = db_SafeSqrt(m_sq_cost[c]);
- int bin = (int)(error/m_max_cost_pix*m_nr_bins);
- if ( bin < m_nr_bins )
- m_cost_histogram[bin]++;
- else
- m_cost_histogram[m_nr_bins-1]++;
- }
-
-/*
- for ( int i = 0; i < m_nr_bins; ++i )
- std::cout << m_cost_histogram[i] << " ";
- std::cout << std::endl;
-*/
-}
-
-void db_FrameToReferenceRegistration::SetOutlierThreshold()
-{
- ComputeCostHistogram();
-
- int i = 0, last=0;
- for (; i < m_nr_bins-1; ++i )
- {
- if ( last > m_cost_histogram[i] )
- break;
- last = m_cost_histogram[i];
- }
-
- //std::cout << "I " << i << std::endl;
-
- int max = m_cost_histogram[i];
-
- for (; i < m_nr_bins-1; ++i )
- {
- if ( m_cost_histogram[i] < (int)(0.1*max) )
- //if ( last < m_cost_histogram[i] )
- break;
- last = m_cost_histogram[i];
- }
- //std::cout << "J " << i << std::endl;
-
- m_outlier_t2 = db_sqr(i*m_max_cost_pix/m_nr_bins);
-
- //std::cout << "m_outlier_t2 " << m_outlier_t2 << std::endl;
-}
-
-void db_FrameToReferenceRegistration::SmoothMotion(void)
-{
- VP_MOTION inmot,outmot;
-
- double H[9];
-
- Get_H_dref_to_ins(H);
-
- MXX(inmot) = H[0];
- MXY(inmot) = H[1];
- MXZ(inmot) = H[2];
- MXW(inmot) = 0.0;
-
- MYX(inmot) = H[3];
- MYY(inmot) = H[4];
- MYZ(inmot) = H[5];
- MYW(inmot) = 0.0;
-
- MZX(inmot) = H[6];
- MZY(inmot) = H[7];
- MZZ(inmot) = H[8];
- MZW(inmot) = 0.0;
-
- MWX(inmot) = 0.0;
- MWY(inmot) = 0.0;
- MWZ(inmot) = 0.0;
- MWW(inmot) = 1.0;
-
- inmot.type = VP_MOTION_AFFINE;
-
- int w = m_im_width;
- int h = m_im_height;
-
- if(m_quarter_resolution)
- {
- w = w*2;
- h = h*2;
- }
-
-#if 0
- m_stab_smoother.smoothMotionAdaptive(w,h,&inmot,&outmot);
-#else
- m_stab_smoother.smoothMotion(&inmot,&outmot);
-#endif
-
- H[0] = MXX(outmot);
- H[1] = MXY(outmot);
- H[2] = MXZ(outmot);
-
- H[3] = MYX(outmot);
- H[4] = MYY(outmot);
- H[5] = MYZ(outmot);
-
- H[6] = MZX(outmot);
- H[7] = MZY(outmot);
- H[8] = MZZ(outmot);
-
- Set_H_dref_to_ins(H);
-}
-
-void db_FrameToReferenceRegistration::GenerateQuarterResImage(const unsigned char* const* im)
-{
- int input_h = m_im_height*2;
- int input_w = m_im_width*2;
-
- for (int j = 0; j < input_h; j++)
- {
- const unsigned char* in_row_ptr = im[j];
- unsigned char* out_row_ptr = m_horz_smooth_subsample_image[j]+1;
-
- for (int i = 2; i < input_w-2; i += 2)
- {
- int smooth_val = (
- 6*in_row_ptr[i] +
- ((in_row_ptr[i-1]+in_row_ptr[i+1])<<2) +
- in_row_ptr[i-2]+in_row_ptr[i+2]
- ) >> 4;
- *out_row_ptr++ = (unsigned char) smooth_val;
-
- if ( (smooth_val < 0) || (smooth_val > 255))
- {
- return;
- }
-
- }
- }
-
- for (int j = 2; j < input_h-2; j+=2)
- {
-
- unsigned char* in_row_ptr = m_horz_smooth_subsample_image[j];
- unsigned char* out_row_ptr = m_quarter_res_image[j/2];
-
- for (int i = 1; i < m_im_width-1; i++)
- {
- int smooth_val = (
- 6*in_row_ptr[i] +
- ((in_row_ptr[i-m_im_width]+in_row_ptr[i+m_im_width]) << 2)+
- in_row_ptr[i-2*m_im_width]+in_row_ptr[i+2*m_im_width]
- ) >> 4;
- *out_row_ptr++ = (unsigned char)smooth_val;
-
- if ( (smooth_val < 0) || (smooth_val > 255))
- {
- return;
- }
-
- }
- }
-}
diff --git a/jni_mosaic/feature_stab/src/dbreg/dbreg.h b/jni_mosaic/feature_stab/src/dbreg/dbreg.h
deleted file mode 100644
index 4eb2444..0000000
--- a/jni_mosaic/feature_stab/src/dbreg/dbreg.h
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-
-#pragma once
-
-#ifdef _WIN32
-#ifdef DBREG_EXPORTS
-#define DBREG_API __declspec(dllexport)
-#else
-#define DBREG_API __declspec(dllimport)
-#endif
-#else
-#define DBREG_API
-#endif
-
-// @jke - the next few lines are for extracting timing data. TODO: Remove after test
-#define PROFILE 0
-
-#include "dbstabsmooth.h"
-
-#include <db_feature_detection.h>
-#include <db_feature_matching.h>
-#include <db_rob_image_homography.h>
-
-#if PROFILE
- #include <sys/time.h>
-#endif
-
-/*! \mainpage db_FrameToReferenceRegistration
-
- \section intro Introduction
-
- db_FrameToReferenceRegistration provides a simple interface to a set of sophisticated algorithms for stabilizing
- video sequences. As its name suggests, the class is used to compute parameters that will allow us to warp incoming video
- frames and register them with respect to a so-called <i>reference</i> frame. The reference frame is simply the first
- frame of a sequence; the registration process is that of estimating the parameters of a warp that can be applied to
- subsequent frames to make those frames align with the reference. A video made up of these warped frames will be more
- stable than the input video.
-
- For more technical information on the internal structure of the algorithms used within the db_FrameToRegistration class,
- please follow this <a href="../Sarnoff image registration.docx">link</a>.
-
- \section usage Usage
- In addition to the class constructor, there are two main functions of db_FrameToReferenceRegistration that are of
- interest to the programmer. db_FrameToReferenceRegistration::Init(...) is used to initialize the parameters of the
- registration algorithm. db_FrameToReferenceRegistration::AddFrame(...) is the method by which each new video frame
- is introduced to the registration algorithm, and produces the estimated registration warp parameters.
-
- The following example illustrates how the major methods of the class db_FrameToReferenceRegistration can be used together
- to calculate the registration parameters for an image sequence. In the example, the calls to the methods of
- db_FrameToReferenceRegistration match those found in the API, but supporting code should be considered pseudo-code.
- For a more complete example, please consult the source code for dbregtest.
-
-
- \code
- // feature-based image registration class:
- db_FrameToReferenceRegistration reg;
-
- // Image data
- const unsigned char * const * image_storage;
-
- // The 3x3 frame to reference registration parameters
- double frame_to_ref_homography[9];
-
- // a counter to count the number of frames processed.
- unsigned long frame_counter;
- // ...
-
- // main loop - keep going while there are images to process.
- while (ImagesAreAvailable)
- {
- // Call functions to place latest data into image_storage
- // ...
-
- // if the registration object is not yet initialized, then do so
- // The arguments to this function are explained in the accompanying
- // html API documentation
- if (!reg.Initialized())
- {
- reg.Init(w,h,motion_model_type,25,linear_polish,quarter_resolution,
- DB_POINT_STANDARDDEV,reference_update_period,
- do_motion_smoothing,motion_smoothing_gain,
- DB_DEFAULT_NR_SAMPLES,DB_DEFAULT_CHUNK_SIZE,
- nr_corners,max_disparity);
- }
-
- // Present the new image data to the registration algorithm,
- // with the result being stored in the frame_to_ref_homography
- // variable.
- reg.AddFrame(image_storage,frame_to_ref_homography);
-
- // frame_to_ref_homography now contains the stabilizing transform
- // use this to warp the latest image for display, etc.
-
- // if this is the first frame, we need to tell the registration
- // class to store the image as its reference. Otherwise, AddFrame
- // takes care of that.
- if (frame_counter == 0)
- {
- reg.UpdateReference(image_storage);
- }
-
- // increment the frame counter
- frame_counter++;
- }
-
- \endcode
-
- */
-
-/*!
- * Performs feature-based frame to reference image registration.
- */
-class DBREG_API db_FrameToReferenceRegistration
-{
-public:
- db_FrameToReferenceRegistration(void);
- ~db_FrameToReferenceRegistration();
-
- /*!
- * Set parameters and allocate memory. Note: The default values of these parameters have been set to the values used for the android implementation (i.e. the demo APK).
- * \param width image width
- * \param height image height
- * \param homography_type see definitions in \ref LMRobImageHomography
- * \param max_iterations max number of polishing steps
- * \param linear_polish whether to perform a linear polishing step after RANSAC
- * \param quarter_resolution whether to process input images at quarter resolution (for computational efficiency)
- * \param scale Cauchy scale coefficient (see db_ExpCauchyReprojectionError() )
- * \param reference_update_period how often to update the alignment reference (in units of number of frames)
- * \param do_motion_smoothing whether to perform display reference smoothing
- * \param motion_smoothing_gain weight factor to reflect how fast the display reference must follow the current frame if motion smoothing is enabled
- * \param nr_samples number of times to compute a hypothesis
- * \param chunk_size size of cost chunks
- * \param cd_target_nr_corners target number of corners for corner detector
- * \param cm_max_disparity maximum disparity search range for corner matcher (in units of ratio of image width)
- * \param cm_use_smaller_matching_window if set to true, uses a correlation window of 5x5 instead of the default 11x11
- * \param cd_nr_horz_blocks the number of horizontal blocks for the corner detector to partition the image
- * \param cd_nr_vert_blocks the number of vertical blocks for the corner detector to partition the image
- */
- void Init(int width, int height,
- int homography_type = DB_HOMOGRAPHY_TYPE_DEFAULT,
- int max_iterations = DB_DEFAULT_MAX_ITERATIONS,
- bool linear_polish = false,
- bool quarter_resolution = true,
- double scale = DB_POINT_STANDARDDEV,
- unsigned int reference_update_period = 3,
- bool do_motion_smoothing = false,
- double motion_smoothing_gain = 0.75,
- int nr_samples = DB_DEFAULT_NR_SAMPLES,
- int chunk_size = DB_DEFAULT_CHUNK_SIZE,
- int cd_target_nr_corners = 500,
- double cm_max_disparity = 0.2,
- bool cm_use_smaller_matching_window = false,
- int cd_nr_horz_blocks = 5,
- int cd_nr_vert_blocks = 5);
-
- /*!
- * Reset the transformation type that is being use to perform alignment. Use this to change the alignment type at run time.
- * \param homography_type the type of transformation to use for performing alignment (see definitions in \ref LMRobImageHomography)
- */
- void ResetHomographyType(int homography_type) { m_homography_type = homography_type; }
-
- /*!
- * Enable/Disable motion smoothing. Use this to turn motion smoothing on/off at run time.
- * \param enable flag indicating whether to turn the motion smoothing on or off.
- */
- void ResetSmoothing(bool enable) { m_do_motion_smoothing = enable; }
-
- /*!
- * Align an inspection image to an existing reference image, update the reference image if due and perform motion smoothing if enabled.
- * \param im new inspection image
- * \param H computed transformation from reference to inspection coordinate frame. Identity is returned if no reference frame was set.
- * \param force_reference make this the new reference image
- */
- int AddFrame(const unsigned char * const * im, double H[9], bool force_reference=false, bool prewarp=false);
-
- /*!
- * Returns true if Init() was run.
- */
- bool Initialized() const { return m_initialized; }
-
- /*!
- * Returns true if the current frame is being used as the alignment reference.
- */
- bool IsCurrentReference() const { return m_current_is_reference; }
-
- /*!
- * Returns true if we need to call UpdateReference now.
- */
- bool NeedReferenceUpdate();
-
- /*!
- * Returns the pointer reference to the alignment reference image data
- */
- unsigned char ** GetReferenceImage() { return m_reference_image; }
-
- /*!
- * Returns the pointer reference to the double array containing the homogeneous coordinates for the matched reference image corners.
- */
- double * GetRefCorners() { return m_corners_ref; }
- /*!
- * Returns the pointer reference to the double array containing the homogeneous coordinates for the matched inspection image corners.
- */
- double * GetInsCorners() { return m_corners_ins; }
- /*!
- * Returns the number of correspondences between the reference and inspection images.
- */
- int GetNrMatches() { return m_nr_matches; }
-
- /*!
- * Returns the number of corners detected in the current reference image.
- */
- int GetNrRefCorners() { return m_nr_corners_ref; }
-
- /*!
- * Returns the pointer to an array of indices that were found to be RANSAC inliers from the matched corner lists.
- */
- int* GetInliers() { return m_inlier_indices; }
-
- /*!
- * Returns the number of inliers from the RANSAC matching step.
- */
- int GetNrInliers() { return m_num_inlier_indices; }
-
- //std::vector<int>& GetInliers();
- //void Polish(std::vector<int> &inlier_indices);
-
- /*!
- * Perform a linear polishing step by re-estimating the alignment transformation using the RANSAC inliers.
- * \param inlier_indices pointer to an array of indices that were found to be RANSAC inliers from the matched corner lists.
- * \param num_inlier_indices number of inliers i.e. the length of the array passed as the first argument.
- */
- void Polish(int *inlier_indices, int &num_inlier_indices);
-
- /*!
- * Reset the motion smoothing parameters to their initial values.
- */
- void ResetMotionSmoothingParameters() { m_stab_smoother.Init(); }
-
- /*!
- * Update the alignment reference image to the specified image.
- * \param im pointer to the image data to be used as the new alignment reference.
- * \param subsample boolean flag to control whether the function should internally subsample the provided image to the size provided in the Init() function.
- */
- int UpdateReference(const unsigned char * const * im, bool subsample = true, bool detect_corners = true);
-
- /*!
- * Returns the transformation from the display reference to the alignment reference frame
- */
- void Get_H_dref_to_ref(double H[9]);
- /*!
- * Returns the transformation from the display reference to the inspection reference frame
- */
- void Get_H_dref_to_ins(double H[9]);
- /*!
- * Set the transformation from the display reference to the inspection reference frame
- * \param H the transformation to set
- */
- void Set_H_dref_to_ins(double H[9]);
-
- /*!
- * Reset the display reference to the current frame.
- */
- void ResetDisplayReference();
-
- /*!
- * Estimate a secondary motion model starting from the specified transformation.
- * \param H the primary motion model to start from
- */
- void EstimateSecondaryModel(double H[9]);
-
- /*!
- *
- */
- void SelectOutliers();
-
- char *profile_string;
-
-protected:
- void Clean();
- void GenerateQuarterResImage(const unsigned char* const * im);
-
- int m_im_width;
- int m_im_height;
-
- // RANSAC and refinement parameters:
- int m_homography_type;
- int m_max_iterations;
- double m_scale;
- int m_nr_samples;
- int m_chunk_size;
- double m_outlier_t2;
-
- // Whether to fit a linear model to just the inliers at the end
- bool m_linear_polish;
- double m_polish_C[36];
- double m_polish_D[6];
-
- // local state
- bool m_current_is_reference;
- bool m_initialized;
-
- // inspection to reference homography:
- double m_H_ref_to_ins[9];
- double m_H_dref_to_ref[9];
-
- // feature extraction and matching:
- db_CornerDetector_u m_cd;
- db_Matcher_u m_cm;
-
- // length of corner arrays:
- unsigned long m_max_nr_corners;
-
- // corner locations of reference image features:
- double * m_x_corners_ref;
- double * m_y_corners_ref;
- int m_nr_corners_ref;
-
- // corner locations of inspection image features:
- double * m_x_corners_ins;
- double * m_y_corners_ins;
- int m_nr_corners_ins;
-
- // length of match index arrays:
- unsigned long m_max_nr_matches;
-
- // match indices:
- int * m_match_index_ref;
- int * m_match_index_ins;
- int m_nr_matches;
-
- // pointer to internal copy of the reference image:
- unsigned char ** m_reference_image;
-
- // pointer to internal copy of last aligned inspection image:
- unsigned char ** m_aligned_ins_image;
-
- // pointer to quarter resolution image, if used.
- unsigned char** m_quarter_res_image;
-
- // temporary storage for the quarter resolution image processing
- unsigned char** m_horz_smooth_subsample_image;
-
- // temporary space for homography computation:
- double * m_temp_double;
- int * m_temp_int;
-
- // homogenous image point arrays:
- double * m_corners_ref;
- double * m_corners_ins;
-
- // Indices of the points within the match lists
- int * m_inlier_indices;
- int m_num_inlier_indices;
-
- //void ComputeInliers(double H[9], std::vector<int> &inlier_indices);
- void ComputeInliers(double H[9]);
-
- // cost arrays:
- void ComputeCostArray();
- bool m_sq_cost_computed;
- double * m_sq_cost;
-
- // cost histogram:
- void ComputeCostHistogram();
- int *m_cost_histogram;
-
- void SetOutlierThreshold();
-
- // utility function for smoothing the motion parameters.
- void SmoothMotion(void);
-
-private:
- double m_K[9];
- const int m_over_allocation;
-
- bool m_reference_set;
-
- // Maximum number of inliers seen until now w.r.t the current reference frame
- int m_max_inlier_count;
-
- // Number of cost histogram bins:
- int m_nr_bins;
- // All costs above this threshold get put into the last bin:
- int m_max_cost_pix;
-
- // whether to quarter the image resolution for processing, or not
- bool m_quarter_resolution;
-
- // the period (in number of frames) for reference update.
- unsigned int m_reference_update_period;
-
- // the number of frames processed so far.
- unsigned int m_nr_frames_processed;
-
- // smoother for motion transformations
- db_StabilizationSmoother m_stab_smoother;
-
- // boolean to control whether motion smoothing occurs (or not)
- bool m_do_motion_smoothing;
-
- // double to set the gain for motion smoothing
- double m_motion_smoothing_gain;
-};
-/*!
- Create look-up tables to undistort images. Only Bougeut (Matlab toolkit)
- is currently supported. Can be used with db_WarpImageLut_u().
- \code
- xd = H*xs;
- xd = xd/xd(3);
- \endcode
- \param lut_x pre-allocated float image
- \param lut_y pre-allocated float image
- \param w width
- \param h height
- \param H image homography from source to destination
- */
-inline void db_GenerateHomographyLut(float ** lut_x,float ** lut_y,int w,int h,const double H[9])
-{
- assert(lut_x && lut_y);
- double x[3] = {0.0,0.0,1.0};
- double xb[3];
-
-/*
- double xl[3];
-
- // Determine the output coordinate system ROI
- double Hinv[9];
- db_InvertAffineTransform(Hinv,H);
- db_Multiply3x3_3x1(xl, Hinv, x);
- xl[0] = db_SafeDivision(xl[0],xl[2]);
- xl[1] = db_SafeDivision(xl[1],xl[2]);
-*/
-
- for ( int i = 0; i < w; ++i )
- for ( int j = 0; j < h; ++j )
- {
- x[0] = double(i);
- x[1] = double(j);
- db_Multiply3x3_3x1(xb, H, x);
- xb[0] = db_SafeDivision(xb[0],xb[2]);
- xb[1] = db_SafeDivision(xb[1],xb[2]);
-
- lut_x[j][i] = float(xb[0]);
- lut_y[j][i] = float(xb[1]);
- }
-}
-
-/*!
- * Perform a look-up table warp for packed RGB ([rgbrgbrgb...]) images.
- * The LUTs must be float images of the same size as source image.
- * The source value x_s is determined from destination (x_d,y_d) through lut_x
- * and y_s is determined from lut_y:
- \code
- x_s = lut_x[y_d][x_d];
- y_s = lut_y[y_d][x_d];
- \endcode
-
- * \param src source image (w*3 by h)
- * \param dst destination image (w*3 by h)
- * \param w width
- * \param h height
- * \param lut_x LUT for x
- * \param lut_y LUT for y
- */
-inline void db_WarpImageLutFast_rgb(const unsigned char * const * src, unsigned char ** dst, int w, int h,
- const float * const * lut_x, const float * const * lut_y)
-{
- assert(src && dst);
- int xd=0, yd=0;
-
- for ( int i = 0; i < w; ++i )
- for ( int j = 0; j < h; ++j )
- {
- xd = static_cast<unsigned int>(lut_x[j][i]);
- yd = static_cast<unsigned int>(lut_y[j][i]);
- if ( xd >= w || yd >= h ||
- xd < 0 || yd < 0)
- {
- dst[j][3*i ] = 0;
- dst[j][3*i+1] = 0;
- dst[j][3*i+2] = 0;
- }
- else
- {
- dst[j][3*i ] = src[yd][3*xd ];
- dst[j][3*i+1] = src[yd][3*xd+1];
- dst[j][3*i+2] = src[yd][3*xd+2];
- }
- }
-}
-
-inline unsigned char db_BilinearInterpolationRGB(double y, double x, const unsigned char * const * v, int offset)
-{
- int floor_x=(int) x;
- int floor_y=(int) y;
-
- int ceil_x=floor_x+1;
- int ceil_y=floor_y+1;
-
- unsigned char f00 = v[floor_y][3*floor_x+offset];
- unsigned char f01 = v[floor_y][3*ceil_x+offset];
- unsigned char f10 = v[ceil_y][3*floor_x+offset];
- unsigned char f11 = v[ceil_y][3*ceil_x+offset];
-
- double xl = x-floor_x;
- double yl = y-floor_y;
-
- return (unsigned char)(f00*(1-yl)*(1-xl) + f10*yl*(1-xl) + f01*(1-yl)*xl + f11*yl*xl);
-}
-
-inline void db_WarpImageLutBilinear_rgb(const unsigned char * const * src, unsigned char ** dst, int w, int h,
- const float * const * lut_x, const float * const * lut_y)
-{
- assert(src && dst);
- double xd=0.0, yd=0.0;
-
- for ( int i = 0; i < w; ++i )
- for ( int j = 0; j < h; ++j )
- {
- xd = static_cast<double>(lut_x[j][i]);
- yd = static_cast<double>(lut_y[j][i]);
- if ( xd > w-2 || yd > h-2 ||
- xd < 0.0 || yd < 0.0)
- {
- dst[j][3*i ] = 0;
- dst[j][3*i+1] = 0;
- dst[j][3*i+2] = 0;
- }
- else
- {
- dst[j][3*i ] = db_BilinearInterpolationRGB(yd,xd,src,0);
- dst[j][3*i+1] = db_BilinearInterpolationRGB(yd,xd,src,1);
- dst[j][3*i+2] = db_BilinearInterpolationRGB(yd,xd,src,2);
- }
- }
-}
-
-inline double SquaredInhomogenousHomographyError(double y[3],double H[9],double x[3]){
- double x0,x1,x2,mult;
- double sd;
-
- x0=H[0]*x[0]+H[1]*x[1]+H[2];
- x1=H[3]*x[0]+H[4]*x[1]+H[5];
- x2=H[6]*x[0]+H[7]*x[1]+H[8];
- mult=1.0/((x2!=0.0)?x2:1.0);
- sd=(y[0]-x0*mult)*(y[0]-x0*mult)+(y[1]-x1*mult)*(y[1]-x1*mult);
-
- return(sd);
-}
-
-
-// functions related to profiling
-#if PROFILE
-
-/* return current time in milliseconds */
-static double
-now_ms(void)
-{
- //struct timespec res;
- struct timeval res;
- //clock_gettime(CLOCK_REALTIME, &res);
- gettimeofday(&res, NULL);
- return 1000.0*res.tv_sec + (double)res.tv_usec/1e3;
-}
-
-#endif
diff --git a/jni_mosaic/feature_stab/src/dbreg/dbstabsmooth.cpp b/jni_mosaic/feature_stab/src/dbreg/dbstabsmooth.cpp
deleted file mode 100644
index dffff8a..0000000
--- a/jni_mosaic/feature_stab/src/dbreg/dbstabsmooth.cpp
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include <stdlib.h>
-#include "dbstabsmooth.h"
-
-///// TODO TODO ////////// Replace this with the actual definition from Jayan's reply /////////////
-#define vp_copy_motion_no_id vp_copy_motion
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-static bool vpmotion_add(VP_MOTION *in1, VP_MOTION *in2, VP_MOTION *out);
-static bool vpmotion_multiply(VP_MOTION *in1, double factor, VP_MOTION *out);
-
-db_StabilizationSmoother::db_StabilizationSmoother()
-{
- Init();
-}
-
-void db_StabilizationSmoother::Init()
-{
- f_smoothOn = true;
- f_smoothReset = false;
- f_smoothFactor = 1.0f;
- f_minDampingFactor = 0.2f;
- f_zoom = 1.0f;
- VP_MOTION_ID(f_motLF);
- VP_MOTION_ID(f_imotLF);
- f_hsize = 0;
- f_vsize = 0;
-
- VP_MOTION_ID(f_disp_mot);
- VP_MOTION_ID(f_src_mot);
- VP_MOTION_ID(f_diff_avg);
-
- for( int i = 0; i < MOTION_ARRAY-1; i++) {
- VP_MOTION_ID(f_hist_mot_speed[i]);
- VP_MOTION_ID(f_hist_mot[i]);
- VP_MOTION_ID(f_hist_diff_mot[i]);
- }
- VP_MOTION_ID(f_hist_mot[MOTION_ARRAY-1]);
-
-}
-
-db_StabilizationSmoother::~db_StabilizationSmoother()
-{}
-
-
-bool db_StabilizationSmoother::smoothMotion(VP_MOTION *inmot, VP_MOTION *outmot)
-{
- VP_MOTION_ID(f_motLF);
- VP_MOTION_ID(f_imotLF);
- f_motLF.insid = inmot->refid;
- f_motLF.refid = inmot->insid;
-
- if(f_smoothOn) {
- if(!f_smoothReset) {
- MXX(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MXX(f_motLF) + (1.0-f_smoothFactor)* (double) MXX(*inmot));
- MXY(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MXY(f_motLF) + (1.0-f_smoothFactor)* (double) MXY(*inmot));
- MXZ(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MXZ(f_motLF) + (1.0-f_smoothFactor)* (double) MXZ(*inmot));
- MXW(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MXW(f_motLF) + (1.0-f_smoothFactor)* (double) MXW(*inmot));
-
- MYX(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MYX(f_motLF) + (1.0-f_smoothFactor)* (double) MYX(*inmot));
- MYY(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MYY(f_motLF) + (1.0-f_smoothFactor)* (double) MYY(*inmot));
- MYZ(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MYZ(f_motLF) + (1.0-f_smoothFactor)* (double) MYZ(*inmot));
- MYW(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MYW(f_motLF) + (1.0-f_smoothFactor)* (double) MYW(*inmot));
-
- MZX(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MZX(f_motLF) + (1.0-f_smoothFactor)* (double) MZX(*inmot));
- MZY(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MZY(f_motLF) + (1.0-f_smoothFactor)* (double) MZY(*inmot));
- MZZ(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MZZ(f_motLF) + (1.0-f_smoothFactor)* (double) MZZ(*inmot));
- MZW(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MZW(f_motLF) + (1.0-f_smoothFactor)* (double) MZW(*inmot));
-
- MWX(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MWX(f_motLF) + (1.0-f_smoothFactor)* (double) MWX(*inmot));
- MWY(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MWY(f_motLF) + (1.0-f_smoothFactor)* (double) MWY(*inmot));
- MWZ(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MWZ(f_motLF) + (1.0-f_smoothFactor)* (double) MWZ(*inmot));
- MWW(f_motLF) = (VP_PAR) (f_smoothFactor*(double) MWW(f_motLF) + (1.0-f_smoothFactor)* (double) MWW(*inmot));
- }
- else
- vp_copy_motion_no_id(inmot, &f_motLF); // f_smoothFactor = 0.0
-
- // Only allow LF motion to be compensated. Remove HF motion from
- // the output transformation
- if(!vp_invert_motion(&f_motLF, &f_imotLF))
- return false;
-
- if(!vp_cascade_motion(&f_imotLF, inmot, outmot))
- return false;
- }
- else {
- vp_copy_motion_no_id(inmot, outmot);
- }
-
- return true;
-}
-
-bool db_StabilizationSmoother::smoothMotionAdaptive(/*VP_BIMG *bimg,*/int hsize, int vsize, VP_MOTION *inmot, VP_MOTION *outmot)
-{
- VP_MOTION tmpMotion, testMotion;
- VP_PAR p1x, p2x, p3x, p4x;
- VP_PAR p1y, p2y, p3y, p4y;
- double smoothFactor;
- double minSmoothFactor = f_minDampingFactor;
-
-// int hsize = bimg->w;
-// int vsize = bimg->h;
- double border_factor = 0.01;//0.2;
- double border_x = border_factor * hsize;
- double border_y = border_factor * vsize;
-
- VP_MOTION_ID(f_motLF);
- VP_MOTION_ID(f_imotLF);
- VP_MOTION_ID(testMotion);
- VP_MOTION_ID(tmpMotion);
-
- if (f_smoothOn) {
- VP_MOTION identityMotion;
- VP_MOTION_ID(identityMotion); // initialize the motion
- vp_copy_motion(inmot/*in*/, &testMotion/*out*/);
- VP_PAR delta = vp_motion_cornerdiff(&testMotion, &identityMotion, 0, 0,(int)hsize, (int)vsize);
-
- smoothFactor = 0.99 - 0.0015 * delta;
-
- if(smoothFactor < minSmoothFactor)
- smoothFactor = minSmoothFactor;
-
- // Find the amount of motion that must be compensated so that no "border" pixels are seen in the stable video
- for (smoothFactor = smoothFactor; smoothFactor >= minSmoothFactor; smoothFactor -= 0.01) {
- // Compute the smoothed motion
- if(!smoothMotion(inmot, &tmpMotion, smoothFactor))
- break;
-
- // TmpMotion, or Qsi where s is the smoothed display reference and i is the
- // current image, tells us how points in the S co-ordinate system map to
- // points in the I CS. We would like to check whether the four corners of the
- // warped and smoothed display reference lies entirely within the I co-ordinate
- // system. If yes, then the amount of smoothing is sufficient so that NO
- // border pixels are seen at the output. We test for f_smoothFactor terms
- // between 0.9 and 1.0, in steps of 0.01, and between 0.5 ands 0.9 in steps of 0.1
-
- (void) vp_zoom_motion2d(&tmpMotion, &testMotion, 1, hsize, vsize, (double)f_zoom); // needs to return bool
-
- VP_WARP_POINT_2D(0, 0, testMotion, p1x, p1y);
- VP_WARP_POINT_2D(hsize - 1, 0, testMotion, p2x, p2y);
- VP_WARP_POINT_2D(hsize - 1, vsize - 1, testMotion, p3x, p3y);
- VP_WARP_POINT_2D(0, vsize - 1, testMotion, p4x, p4y);
-
- if (!is_point_in_rect((double)p1x,(double)p1y,-border_x,-border_y,(double)(hsize+2.0*border_x),(double)(vsize+2.0*border_y))) {
- continue;
- }
- if (!is_point_in_rect((double)p2x, (double)p2y,-border_x,-border_y,(double)(hsize+2.0*border_x),(double)(vsize+2.0*border_y))) {
- continue;
- }
- if (!is_point_in_rect((double)p3x,(double)p3y,-border_x,-border_y,(double)(hsize+2.0*border_x),(double)(vsize+2.0*border_y))) {
- continue;
- }
- if (!is_point_in_rect((double)p4x, (double)p4y,-border_x,-border_y,(double)(hsize+2.0*border_x),(double)(vsize+2.0*border_y))) {
- continue;
- }
-
- // If we get here, then all the points are in the rectangle.
- // Therefore, break out of this loop
- break;
- }
-
- // if we get here and f_smoothFactor <= fMinDampingFactor, reset the stab reference
- if (smoothFactor < f_minDampingFactor)
- smoothFactor = f_minDampingFactor;
-
- // use the smoothed motion for stabilization
- vp_copy_motion_no_id(&tmpMotion/*in*/, outmot/*out*/);
- }
- else
- {
- vp_copy_motion_no_id(inmot, outmot);
- }
-
- return true;
-}
-
-bool db_StabilizationSmoother::smoothMotion(VP_MOTION *inmot, VP_MOTION *outmot, double smooth_factor)
-{
- f_motLF.insid = inmot->refid;
- f_motLF.refid = inmot->insid;
-
- if(f_smoothOn) {
- if(!f_smoothReset) {
- MXX(f_motLF) = (VP_PAR) (smooth_factor*(double) MXX(f_motLF) + (1.0-smooth_factor)* (double) MXX(*inmot));
- MXY(f_motLF) = (VP_PAR) (smooth_factor*(double) MXY(f_motLF) + (1.0-smooth_factor)* (double) MXY(*inmot));
- MXZ(f_motLF) = (VP_PAR) (smooth_factor*(double) MXZ(f_motLF) + (1.0-smooth_factor)* (double) MXZ(*inmot));
- MXW(f_motLF) = (VP_PAR) (smooth_factor*(double) MXW(f_motLF) + (1.0-smooth_factor)* (double) MXW(*inmot));
-
- MYX(f_motLF) = (VP_PAR) (smooth_factor*(double) MYX(f_motLF) + (1.0-smooth_factor)* (double) MYX(*inmot));
- MYY(f_motLF) = (VP_PAR) (smooth_factor*(double) MYY(f_motLF) + (1.0-smooth_factor)* (double) MYY(*inmot));
- MYZ(f_motLF) = (VP_PAR) (smooth_factor*(double) MYZ(f_motLF) + (1.0-smooth_factor)* (double) MYZ(*inmot));
- MYW(f_motLF) = (VP_PAR) (smooth_factor*(double) MYW(f_motLF) + (1.0-smooth_factor)* (double) MYW(*inmot));
-
- MZX(f_motLF) = (VP_PAR) (smooth_factor*(double) MZX(f_motLF) + (1.0-smooth_factor)* (double) MZX(*inmot));
- MZY(f_motLF) = (VP_PAR) (smooth_factor*(double) MZY(f_motLF) + (1.0-smooth_factor)* (double) MZY(*inmot));
- MZZ(f_motLF) = (VP_PAR) (smooth_factor*(double) MZZ(f_motLF) + (1.0-smooth_factor)* (double) MZZ(*inmot));
- MZW(f_motLF) = (VP_PAR) (smooth_factor*(double) MZW(f_motLF) + (1.0-smooth_factor)* (double) MZW(*inmot));
-
- MWX(f_motLF) = (VP_PAR) (smooth_factor*(double) MWX(f_motLF) + (1.0-smooth_factor)* (double) MWX(*inmot));
- MWY(f_motLF) = (VP_PAR) (smooth_factor*(double) MWY(f_motLF) + (1.0-smooth_factor)* (double) MWY(*inmot));
- MWZ(f_motLF) = (VP_PAR) (smooth_factor*(double) MWZ(f_motLF) + (1.0-smooth_factor)* (double) MWZ(*inmot));
- MWW(f_motLF) = (VP_PAR) (smooth_factor*(double) MWW(f_motLF) + (1.0-smooth_factor)* (double) MWW(*inmot));
- }
- else
- vp_copy_motion_no_id(inmot, &f_motLF); // smooth_factor = 0.0
-
- // Only allow LF motion to be compensated. Remove HF motion from
- // the output transformation
- if(!vp_invert_motion(&f_motLF, &f_imotLF))
- return false;
-
- if(!vp_cascade_motion(&f_imotLF, inmot, outmot))
- return false;
- }
- else {
- vp_copy_motion_no_id(inmot, outmot);
- }
-
- return true;
-}
-
-//! Overloaded smoother function that takes in user-specidied smoothing factor
-bool
-db_StabilizationSmoother::smoothMotion1(VP_MOTION *inmot, VP_MOTION *outmot, VP_MOTION *motLF, VP_MOTION *imotLF, double factor)
-{
-
- if(!f_smoothOn) {
- vp_copy_motion(inmot, outmot);
- return true;
- }
- else {
- if(!f_smoothReset) {
- MXX(*motLF) = (VP_PAR) (factor*(double) MXX(*motLF) + (1.0-factor)* (double) MXX(*inmot));
- MXY(*motLF) = (VP_PAR) (factor*(double) MXY(*motLF) + (1.0-factor)* (double) MXY(*inmot));
- MXZ(*motLF) = (VP_PAR) (factor*(double) MXZ(*motLF) + (1.0-factor)* (double) MXZ(*inmot));
- MXW(*motLF) = (VP_PAR) (factor*(double) MXW(*motLF) + (1.0-factor)* (double) MXW(*inmot));
-
- MYX(*motLF) = (VP_PAR) (factor*(double) MYX(*motLF) + (1.0-factor)* (double) MYX(*inmot));
- MYY(*motLF) = (VP_PAR) (factor*(double) MYY(*motLF) + (1.0-factor)* (double) MYY(*inmot));
- MYZ(*motLF) = (VP_PAR) (factor*(double) MYZ(*motLF) + (1.0-factor)* (double) MYZ(*inmot));
- MYW(*motLF) = (VP_PAR) (factor*(double) MYW(*motLF) + (1.0-factor)* (double) MYW(*inmot));
-
- MZX(*motLF) = (VP_PAR) (factor*(double) MZX(*motLF) + (1.0-factor)* (double) MZX(*inmot));
- MZY(*motLF) = (VP_PAR) (factor*(double) MZY(*motLF) + (1.0-factor)* (double) MZY(*inmot));
- MZZ(*motLF) = (VP_PAR) (factor*(double) MZZ(*motLF) + (1.0-factor)* (double) MZZ(*inmot));
- MZW(*motLF) = (VP_PAR) (factor*(double) MZW(*motLF) + (1.0-factor)* (double) MZW(*inmot));
-
- MWX(*motLF) = (VP_PAR) (factor*(double) MWX(*motLF) + (1.0-factor)* (double) MWX(*inmot));
- MWY(*motLF) = (VP_PAR) (factor*(double) MWY(*motLF) + (1.0-factor)* (double) MWY(*inmot));
- MWZ(*motLF) = (VP_PAR) (factor*(double) MWZ(*motLF) + (1.0-factor)* (double) MWZ(*inmot));
- MWW(*motLF) = (VP_PAR) (factor*(double) MWW(*motLF) + (1.0-factor)* (double) MWW(*inmot));
- }
- else {
- vp_copy_motion(inmot, motLF);
- }
- // Only allow LF motion to be compensated. Remove HF motion from the output transformation
- if(!vp_invert_motion(motLF, imotLF)) {
-#if DEBUG_PRINT
- printfOS("Invert failed \n");
-#endif
- return false;
- }
- if(!vp_cascade_motion(imotLF, inmot, outmot)) {
-#if DEBUG_PRINT
- printfOS("cascade failed \n");
-#endif
- return false;
- }
- }
- return true;
-}
-
-
-
-
-bool db_StabilizationSmoother::is_point_in_rect(double px, double py, double rx, double ry, double w, double h)
-{
- if (px < rx)
- return(false);
- if (px >= rx + w)
- return(false);
- if (py < ry)
- return(false);
- if (py >= ry + h)
- return(false);
-
- return(true);
-}
-
-
-
-static bool vpmotion_add(VP_MOTION *in1, VP_MOTION *in2, VP_MOTION *out)
-{
- int i;
- if(in1 == NULL || in2 == NULL || out == NULL)
- return false;
-
- for(i = 0; i < VP_MAX_MOTION_PAR; i++)
- out->par[i] = in1->par[i] + in2->par[i];
-
- return true;
-}
-
-static bool vpmotion_multiply(VP_MOTION *in1, double factor, VP_MOTION *out)
-{
- int i;
- if(in1 == NULL || out == NULL)
- return false;
-
- for(i = 0; i < VP_MAX_MOTION_PAR; i++)
- out->par[i] = in1->par[i] * factor;
-
- return true;
-}
-
diff --git a/jni_mosaic/feature_stab/src/dbreg/dbstabsmooth.h b/jni_mosaic/feature_stab/src/dbreg/dbstabsmooth.h
deleted file mode 100644
index f03546e..0000000
--- a/jni_mosaic/feature_stab/src/dbreg/dbstabsmooth.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma once
-
-
-#ifdef _WIN32
-#ifdef DBREG_EXPORTS
-#define DBREG_API __declspec(dllexport)
-#else
-#define DBREG_API __declspec(dllimport)
-#endif
-#else
-#define DBREG_API
-#endif
-
-extern "C" {
-#include "vp_motionmodel.h"
-}
-
-#define MOTION_ARRAY 5
-
-
-/*!
- * Performs smoothing on the motion estimate from feature_stab.
- */
-class DBREG_API db_StabilizationSmoother
-{
-public:
- db_StabilizationSmoother();
- ~db_StabilizationSmoother();
-
- /*!
- * Initialize parameters for stab-smoother.
- */
- void Init();
-
- //! Smothing type
- typedef enum {
- SimpleSmooth = 0, //!< simple smooth
- AdaptSmooth = 1, //!< adaptive smooth
- PanSmooth = 2 //!< pan motion smooth
- } SmoothType;
-
- /*!
- * Smooth-motion is to do a weight-average between the current affine and
- * motLF. The way to change the affine is only for the display purpose.
- * It removes the high frequency motion and keep the low frequency motion
- * to the display. IIR implmentation.
- * \param inmot input motion parameters
- * \param outmot smoothed output motion parameters
- */
- bool smoothMotion(VP_MOTION *inmot, VP_MOTION *outmot);
-
- /*!
- * The adaptive smoothing version of the above fixed smoothing function.
- * \param hsize width of the image being aligned
- * \param vsize height of the image being aligned
- * \param inmot input motion parameters
- * \param outmot smoothed output motion parameters
- */
- bool smoothMotionAdaptive(/*VP_BIMG *bimg,*/int hsize, int vsize, VP_MOTION *inmot, VP_MOTION *outmot);
- bool smoothPanMotion_1(VP_MOTION *inmot, VP_MOTION *outmot);
- bool smoothPanMotion_2(VP_MOTION *inmot, VP_MOTION *outmot);
-
- /*!
- * Set the smoothing factor for the stab-smoother.
- * \param factor the factor value to set
- */
- inline void setSmoothingFactor(float factor) { f_smoothFactor = factor; }
-
- /*!
- * Reset smoothing
- */
- inline void resetSmoothing(bool flag) { f_smoothReset = flag; }
- /*!
- * Set the zoom factor value.
- * \param zoom the value to set to
- */
- inline void setZoomFactor(float zoom) { f_zoom = zoom; }
- /*!
- * Set the minimum damping factor value.
- * \param factor the value to set to
- */
- inline void setminDampingFactor(float factor) { f_minDampingFactor = factor; }
-
- /*!
- * Returns the current smoothing factor.
- */
- inline float getSmoothingFactor(void) { return f_smoothFactor; }
- /*!
- * Returns the current zoom factor.
- */
- inline float getZoomFactor(void) { return f_zoom; }
- /*!
- * Returns the current minimum damping factor.
- */
- inline float getminDampingFactor(void) { return f_minDampingFactor; }
- /*!
- * Returns the current state of the smoothing reset flag.
- */
- inline bool getSmoothReset(void) { return f_smoothReset; }
- /*!
- * Returns the current low frequency motion parameters.
- */
- inline VP_MOTION getMotLF(void) { return f_motLF; }
- /*!
- * Returns the inverse of the current low frequency motion parameters.
- */
- inline VP_MOTION getImotLF(void) { return f_imotLF; }
- /*!
- * Set the dimensions of the alignment image.
- * \param hsize width of the image
- * \param vsize height of the image
- */
- inline void setSize(int hsize, int vsize) { f_hsize = hsize; f_vsize = vsize; }
-
-protected:
-
- bool smoothMotion(VP_MOTION *inmot, VP_MOTION *outmot, double smooth_factor);
- bool smoothMotion1(VP_MOTION *inmot, VP_MOTION *outmot, VP_MOTION *motLF, VP_MOTION *imotLF, double smooth_factor);
- void iterativeSmooth(VP_MOTION *input, VP_MOTION *output, double border_factor);
- bool is_point_in_rect(double px, double py, double rx, double ry, double w, double h);
-
-
-private:
- int f_hsize;
- int f_vsize;
- bool f_smoothOn;
- bool f_smoothReset;
- float f_smoothFactor;
- float f_minDampingFactor;
- float f_zoom;
- VP_MOTION f_motLF;
- VP_MOTION f_imotLF;
- VP_MOTION f_hist_mot[MOTION_ARRAY];
- VP_MOTION f_hist_mot_speed[MOTION_ARRAY-1];
- VP_MOTION f_hist_diff_mot[MOTION_ARRAY-1];
- VP_MOTION f_disp_mot;
- VP_MOTION f_src_mot;
- VP_MOTION f_diff_avg;
-
-};
-
diff --git a/jni_mosaic/feature_stab/src/dbreg/targetver.h b/jni_mosaic/feature_stab/src/dbreg/targetver.h
deleted file mode 100644
index 3ca3e87..0000000
--- a/jni_mosaic/feature_stab/src/dbreg/targetver.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma once
-
-// The following macros define the minimum required platform. The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
-// your application. The macros work by enabling all features available on platform versions up to and
-// including the version specified.
-
-// Modify the following defines if you have to target a platform prior to the ones specified below.
-// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
-#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
-#endif
-
-#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
-#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
-#endif
-
-#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
-#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
-#endif
-
-#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
-#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
-#endif
diff --git a/jni_mosaic/feature_stab/src/dbreg/vp_motionmodel.c b/jni_mosaic/feature_stab/src/dbreg/vp_motionmodel.c
deleted file mode 100644
index 1f6af15..0000000
--- a/jni_mosaic/feature_stab/src/dbreg/vp_motionmodel.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/*
-#sourcefile vpmotion/vp_motionmodel.c
-#category motion-model
-*
-* Copyright 1998 Sarnoff Corporation
-* All Rights Reserved
-*
-* Modification History
-* Date: 02/14/98
-* Author: supuns
-* Shop Order: 17xxx
-* @(#) $Id: vp_motionmodel.c,v 1.4 2011/06/17 14:04:33 mbansal Exp $
-*/
-
-/*
-* ===================================================================
-* Include Files
-*/
-
-#include <string.h> /* memmove */
-#include <math.h>
-#include "vp_motionmodel.h"
-
-/* Static Functions */
-static
-double Det3(double m[3][3])
-{
- double result;
-
- result =
- m[0][0]*m[1][1]*m[2][2] + m[0][1]*m[1][2]*m[2][0] +
- m[0][2]*m[1][0]*m[2][1] - m[0][2]*m[1][1]*m[2][0] -
- m[0][0]*m[1][2]*m[2][1] - m[0][1]*m[1][0]*m[2][2];
-
- return(result);
-}
-
-typedef double MATRIX[4][4];
-
-static
-double Det4(MATRIX m)
-{
- /* ==> This is a poor implementation of determinant.
- Writing the formula out in closed form is unnecessarily complicated
- and mistakes are easy to make. */
- double result;
-
- result=
- m[0][3] *m[1][2] *m[2][1] *m[3][0] - m[0][2] *m[1][3] *m[2][1] *m[3][0] - m[0][3] *m[1][1] *m[2][2] *m[3][0] +
- m[0][1] *m[1][3] *m[2][2] *m[3][0] + m[0][2] *m[1][1] *m[2][3] *m[3][0] - m[0][1] *m[1][2] *m[2][3] *m[3][0] - m[0][3] *m[1][2] *m[2][0] *m[3][1] +
- m[0][2] *m[1][3] *m[2][0] *m[3][1] + m[0][3] *m[1][0] *m[2][2] *m[3][1] - m[0][0] *m[1][3] *m[2][2] *m[3][1] - m[0][2] *m[1][0] *m[2][3] *m[3][1] +
- m[0][0] *m[1][2] *m[2][3] *m[3][1] + m[0][3] *m[1][1] *m[2][0] *m[3][2] - m[0][1] *m[1][3] *m[2][0] *m[3][2] - m[0][3] *m[1][0] *m[2][1] *m[3][2] +
- m[0][0] *m[1][3] *m[2][1] *m[3][2] + m[0][1] *m[1][0] *m[2][3] *m[3][2] - m[0][0] *m[1][1] *m[2][3] *m[3][2] - m[0][2] *m[1][1] *m[2][0] *m[3][3] +
- m[0][1] *m[1][2] *m[2][0] *m[3][3] + m[0][2] *m[1][0] *m[2][1] *m[3][3] - m[0][0] *m[1][2] *m[2][1] *m[3][3] - m[0][1] *m[1][0] *m[2][2] *m[3][3] +
- m[0][0] *m[1][1] *m[2][2] *m[3][3];
- /*
- m[0][0]*m[1][1]*m[2][2]*m[3][3]-m[0][1]*m[1][0]*m[2][2]*m[3][3]+
- m[0][1]*m[1][2]*m[2][0]*m[3][3]-m[0][2]*m[1][1]*m[2][0]*m[3][3]+
- m[0][2]*m[1][0]*m[2][1]*m[3][3]-m[0][0]*m[1][2]*m[2][1]*m[3][3]+
- m[0][0]*m[1][2]*m[2][3]*m[3][1]-m[0][2]*m[1][0]*m[2][3]*m[3][1]+
- m[0][2]*m[1][3]*m[2][0]*m[3][1]-m[0][3]*m[1][2]*m[2][0]*m[3][1]+
- m[0][3]*m[1][0]*m[2][2]*m[3][1]-m[0][0]*m[1][3]*m[2][2]*m[3][1]+
- m[0][0]*m[1][3]*m[2][1]*m[3][2]-m[0][3]*m[1][0]*m[2][3]*m[3][2]+
- m[0][1]*m[1][0]*m[2][3]*m[3][2]-m[0][0]*m[1][1]*m[2][0]*m[3][2]+
- m[0][3]*m[1][1]*m[2][0]*m[3][2]-m[0][1]*m[1][3]*m[2][1]*m[3][2]+
- m[0][1]*m[1][3]*m[2][2]*m[3][0]-m[0][3]*m[1][1]*m[2][2]*m[3][0]+
- m[0][2]*m[1][1]*m[2][3]*m[3][0]-m[0][1]*m[1][2]*m[2][3]*m[3][0]+
- m[0][3]*m[1][2]*m[2][1]*m[3][0]-m[0][2]*m[1][3]*m[2][1]*m[3][0];
- */
- return(result);
-}
-
-static
-int inv4Mat(const VP_MOTION* in, VP_MOTION* out)
-{
- /* ==> This is a poor implementation of inversion. The determinant
- method is O(N^4), i.e. unnecessarily slow, and not numerically accurate.
- The real complexity of inversion is O(N^3), and is best done using
- LU decomposition. */
-
- MATRIX inmat,outmat;
- int i, j, k, l, m, n,ntemp;
- double mat[3][3], indet, temp;
-
- /* check for non-empty structures structure */
- if (((VP_MOTION *) NULL == in) || ((VP_MOTION *) NULL == out)) {
- return 1;
- }
-
- for(k=0,i=0;i<4;i++)
- for(j=0;j<4;j++,k++)
- inmat[i][j]=(double)in->par[k];
-
- indet = Det4(inmat);
- if (indet==0) return(-1);
-
- for (i=0;i<4;i++) {
- for (j=0;j<4;j++) {
- m = 0;
- for (k=0;k<4;k++) {
- if (i != k) {
- n = 0;
- for (l=0;l<4;l++)
- if (j != l) {
- mat[m][n] = inmat[k][l];
- n++;
- }
- m++;
- }
- }
-
- temp = -1.;
- ntemp = (i +j ) %2;
- if( ntemp == 0) temp = 1.;
-
- outmat[j][i] = temp * Det3(mat)/indet;
- }
- }
-
- for(k=0,i=0;i<4;i++)
- for(j=0;j<4;j++,k++)
- out->par[k]=(VP_PAR)outmat[i][j]; /*lint !e771*/
-
- return(0);
-}
-
-/*
-* ===================================================================
-* Public Functions
-#htmlstart
-*/
-
-/*
- * ===================================================================
-#fn vp_invert_motion
-#ft invert a motion
-#fd DEFINITION
- Bool
- vp_invert_motion(const VP_MOTION* in,VP_MOTION* out)
-#fd PURPOSE
- This inverts the motion given in 'in'.
- All motion models upto VP_MOTION_SEMI_PROJ_3D are supported.
- It is assumed that the all 16 parameters are properly
- initialized although you may not be using them. You could
- use the VP_KEEP_ macro's defined in vp_motionmodel.h to set
- the un-initialized parameters. This uses a 4x4 matrix invertion
- function internally.
- It is SAFE to pass the same pointer as both the 'in' and 'out'
- parameters.
-#fd INPUTS
- in - input motion
-#fd OUTPUTS
- out - output inverted motion. If singular matrix uninitialized.
- if MWW(in) is non-zero it is also normalized.
-#fd RETURNS
- FALSE - matrix is singular or motion model not supported
- TRUE - otherwise
-#fd SIDE EFFECTS
- None
-#endfn
-*/
-
-int vp_invert_motion(const VP_MOTION* in,VP_MOTION* out)
-{
- int refid;
-
- /* check for non-empty structures structure */
- if (((VP_MOTION *) NULL == in) || ((VP_MOTION *) NULL == out)) {
- return FALSE;
- }
-
- if (in->type>VP_MOTION_SEMI_PROJ_3D) {
- return FALSE;
- }
-
- if (inv4Mat(in,out)<0)
- return FALSE;
-
- /*VP_NORMALIZE(*out);*/
- out->type = in->type;
- refid=in->refid;
- out->refid=in->insid;
- out->insid=refid;
- return TRUE;
-}
-
-/*
-* ===================================================================
-#fn vp_cascade_motion
-#ft Cascade two motion transforms
-#fd DEFINITION
- Bool
- vp_cascade_motion(const VP_MOTION* InAB,const VP_MOTION* InBC,VP_MOTION* OutAC)
-#fd PURPOSE
- Given Motion Transforms A->B and B->C, this function will
- generate a New Motion that describes the transformation
- from A->C.
- More specifically, OutAC = InBC * InAC.
- This function works ok if InAB,InBC and OutAC are the same pointer.
-#fd INPUTS
- InAB - First Motion Transform
- InBC - Second Motion Tranform
-#fd OUTPUTS
- OutAC - Cascaded Motion
-#fd RETURNS
- FALSE - motion model not supported
- TRUE - otherwise
-#fd SIDE EFFECTS
- None
-#endfn
-*/
-
-int vp_cascade_motion(const VP_MOTION* InA, const VP_MOTION* InB,VP_MOTION* Out)
-{
- /* ==> This is a poor implementation of matrix multiplication.
- Writing the formula out in closed form is unnecessarily complicated
- and mistakes are easy to make. */
- VP_PAR mxx,mxy,mxz,mxw;
- VP_PAR myx,myy,myz,myw;
- VP_PAR mzx,mzy,mzz,mzw;
- VP_PAR mwx,mwy,mwz,mww;
-
- /* check for non-empty structures structure */
- if (((VP_MOTION *) NULL == InA) || ((VP_MOTION *) NULL == InB) ||
- ((VP_MOTION *) NULL == Out)) {
- return FALSE;
- }
-
- if (InA->type>VP_MOTION_PROJ_3D) {
- return FALSE;
- }
-
- if (InB->type>VP_MOTION_PROJ_3D) {
- return FALSE;
- }
-
- mxx = MXX(*InB)*MXX(*InA)+MXY(*InB)*MYX(*InA)+MXZ(*InB)*MZX(*InA)+MXW(*InB)*MWX(*InA);
- mxy = MXX(*InB)*MXY(*InA)+MXY(*InB)*MYY(*InA)+MXZ(*InB)*MZY(*InA)+MXW(*InB)*MWY(*InA);
- mxz = MXX(*InB)*MXZ(*InA)+MXY(*InB)*MYZ(*InA)+MXZ(*InB)*MZZ(*InA)+MXW(*InB)*MWZ(*InA);
- mxw = MXX(*InB)*MXW(*InA)+MXY(*InB)*MYW(*InA)+MXZ(*InB)*MZW(*InA)+MXW(*InB)*MWW(*InA);
- myx = MYX(*InB)*MXX(*InA)+MYY(*InB)*MYX(*InA)+MYZ(*InB)*MZX(*InA)+MYW(*InB)*MWX(*InA);
- myy = MYX(*InB)*MXY(*InA)+MYY(*InB)*MYY(*InA)+MYZ(*InB)*MZY(*InA)+MYW(*InB)*MWY(*InA);
- myz = MYX(*InB)*MXZ(*InA)+MYY(*InB)*MYZ(*InA)+MYZ(*InB)*MZZ(*InA)+MYW(*InB)*MWZ(*InA);
- myw = MYX(*InB)*MXW(*InA)+MYY(*InB)*MYW(*InA)+MYZ(*InB)*MZW(*InA)+MYW(*InB)*MWW(*InA);
- mzx = MZX(*InB)*MXX(*InA)+MZY(*InB)*MYX(*InA)+MZZ(*InB)*MZX(*InA)+MZW(*InB)*MWX(*InA);
- mzy = MZX(*InB)*MXY(*InA)+MZY(*InB)*MYY(*InA)+MZZ(*InB)*MZY(*InA)+MZW(*InB)*MWY(*InA);
- mzz = MZX(*InB)*MXZ(*InA)+MZY(*InB)*MYZ(*InA)+MZZ(*InB)*MZZ(*InA)+MZW(*InB)*MWZ(*InA);
- mzw = MZX(*InB)*MXW(*InA)+MZY(*InB)*MYW(*InA)+MZZ(*InB)*MZW(*InA)+MZW(*InB)*MWW(*InA);
- mwx = MWX(*InB)*MXX(*InA)+MWY(*InB)*MYX(*InA)+MWZ(*InB)*MZX(*InA)+MWW(*InB)*MWX(*InA);
- mwy = MWX(*InB)*MXY(*InA)+MWY(*InB)*MYY(*InA)+MWZ(*InB)*MZY(*InA)+MWW(*InB)*MWY(*InA);
- mwz = MWX(*InB)*MXZ(*InA)+MWY(*InB)*MYZ(*InA)+MWZ(*InB)*MZZ(*InA)+MWW(*InB)*MWZ(*InA);
- mww = MWX(*InB)*MXW(*InA)+MWY(*InB)*MYW(*InA)+MWZ(*InB)*MZW(*InA)+MWW(*InB)*MWW(*InA);
-
- MXX(*Out)=mxx; MXY(*Out)=mxy; MXZ(*Out)=mxz; MXW(*Out)=mxw;
- MYX(*Out)=myx; MYY(*Out)=myy; MYZ(*Out)=myz; MYW(*Out)=myw;
- MZX(*Out)=mzx; MZY(*Out)=mzy; MZZ(*Out)=mzz; MZW(*Out)=mzw;
- MWX(*Out)=mwx; MWY(*Out)=mwy; MWZ(*Out)=mwz; MWW(*Out)=mww;
- /* VP_NORMALIZE(*Out); */
- Out->type= (InA->type > InB->type) ? InA->type : InB->type;
- Out->refid=InA->refid;
- Out->insid=InB->insid;
-
- return TRUE;
-}
-
-/*
-* ===================================================================
-#fn vp_copy_motion
-#ft Copies the source motion to the destination motion.
-#fd DEFINITION
- void
- vp_copy_motion (const VP_MOTION *src, VP_MOTION *dst)
-#fd PURPOSE
- Copies the source motion to the destination motion.
- It is OK if src == dst.
- NOTE THAT THE SOURCE IS THE FIRST ARGUMENT.
- This is different from some of the other VP
- copy functions.
-#fd INPUTS
- src is the source motion
- dst is the destination motion
-#fd RETURNS
- void
-#endfn
-*/
-void vp_copy_motion (const VP_MOTION *src, VP_MOTION *dst)
-{
- /* Use memmove rather than memcpy because it handles overlapping memory
- OK. */
- memmove(dst, src, sizeof(VP_MOTION));
- return;
-} /* vp_copy_motion() */
-
-#define VP_SQR(x) ( (x)*(x) )
-double vp_motion_cornerdiff(const VP_MOTION *mot_a, const VP_MOTION *mot_b,
- int xo, int yo, int w, int h)
-{
- double ax1, ay1, ax2, ay2, ax3, ay3, ax4, ay4;
- double bx1, by1, bx2, by2, bx3, by3, bx4, by4;
- double err;
-
- /*lint -e639 -e632 -e633 */
- VP_WARP_POINT_2D(xo, yo, *mot_a, ax1, ay1);
- VP_WARP_POINT_2D(xo+w-1, yo, *mot_a, ax2, ay2);
- VP_WARP_POINT_2D(xo+w-1, yo+h-1, *mot_a, ax3, ay3);
- VP_WARP_POINT_2D(xo, yo+h-1, *mot_a, ax4, ay4);
- VP_WARP_POINT_2D(xo, yo, *mot_b, bx1, by1);
- VP_WARP_POINT_2D(xo+w-1, yo, *mot_b, bx2, by2);
- VP_WARP_POINT_2D(xo+w-1, yo+h-1, *mot_b, bx3, by3);
- VP_WARP_POINT_2D(xo, yo+h-1, *mot_b, bx4, by4);
- /*lint +e639 +e632 +e633 */
-
- err = 0;
- err += (VP_SQR(ax1 - bx1) + VP_SQR(ay1 - by1));
- err += (VP_SQR(ax2 - bx2) + VP_SQR(ay2 - by2));
- err += (VP_SQR(ax3 - bx3) + VP_SQR(ay3 - by3));
- err += (VP_SQR(ax4 - bx4) + VP_SQR(ay4 - by4));
-
- return(sqrt(err));
-}
-
-int vp_zoom_motion2d(VP_MOTION* in, VP_MOTION* out,
- int n, int w, int h, double zoom)
-{
- int ii;
- VP_PAR inv_zoom;
- VP_PAR cx, cy;
- VP_MOTION R2r,R2f;
- VP_MOTION *res;
-
- /* check for non-empty structures structure */
- if (((VP_MOTION *) NULL == in)||(zoom <= 0.0)||(w <= 0)||(h <= 0)) {
- return FALSE;
- }
-
- /* ==> Not sure why the special case of out=NULL is necessary. Why couldn't
- the caller just pass the same pointer for both in and out? */
- res = ((VP_MOTION *) NULL == out)?in:out;
-
- cx = (VP_PAR) (w/2.0);
- cy = (VP_PAR) (h/2.0);
-
- VP_MOTION_ID(R2r);
- inv_zoom = (VP_PAR)(1.0/zoom);
- MXX(R2r) = inv_zoom;
- MYY(R2r) = inv_zoom;
- MXW(R2r)=cx*(((VP_PAR)1.0) - inv_zoom);
- MYW(R2r)=cy*(((VP_PAR)1.0) - inv_zoom);
-
- VP_KEEP_AFFINE_2D(R2r);
-
- for(ii=0;ii<n;ii++) {
- (void) vp_cascade_motion(&R2r,in+ii,&R2f);
- res[ii]=R2f;
- }
-
- return TRUE;
-} /* vp_zoom_motion2d() */
-
-/* =================================================================== */
-/* end vp_motionmodel.c */
diff --git a/jni_mosaic/feature_stab/src/dbreg/vp_motionmodel.h b/jni_mosaic/feature_stab/src/dbreg/vp_motionmodel.h
deleted file mode 100644
index a63ac00..0000000
--- a/jni_mosaic/feature_stab/src/dbreg/vp_motionmodel.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-/*
-#sourcefile vp_motionmodel.h
-#category warp
-#description general motion model for tranlation/affine/projective
-#title motion-model
-#parentlink hindex.html
-*
-* Copyright 1998 Sarnoff Corporation
-* All Rights Reserved
-*
-* Modification History
-* Date: 02/13/98
-* Author: supuns
-* Shop Order: 15491 001
-* @(#) $Id: vp_motionmodel.h,v 1.4 2011/06/17 14:04:33 mbansal Exp $
-*/
-
-#ifndef VP_MOTIONMODEL_H
-#define VP_MOTIONMODEL_H
-#include <stdio.h>
-
-#define FALSE 0
-#define TRUE 1
-
-#if 0 /* Moved mottomat.c and mattomot_d.c from vpmotion.h to vpcompat.h
- in order to remove otherwise unnecessary dependency of vpmotion,
- vpwarp, and newvpio on vpmath */
-#ifndef VPMATH_H
-#include "vpmath.h"
-#endif
-#endif
-
-#if 0
-#ifndef VP_WARP_H
-#include "vp_warp.h"
-#endif
-#endif
-/*
-
-#htmlstart
-# ===================================================================
-#h 1 Introduction
-
- This defines a motion model that can describe translation,
- affine, and projective projective 3d and 3d view transforms.
-
- The main structure VP_MOTION contains a 16 parameter array (That
- can be considered as elements of a 4x4 matrix) and a type field
- which can be one of VP_MOTION_NONE,VP_MOTION_TRANSLATION,
- VP_MOTION_AFFINE, VP_MOTION_PROJECTIVE,VP_MOTION_PROJ_3D or
- VP_MOTION_VIEW_3D. (These are defined using enums with gaps of 10
- so that subsets of these motions that are still consistant can be
- added in between. Motion models that are inconsistant with this set
- should be added at the end so the routines can hadle them
- independently.
-
- The transformation VP_MOTION_NONE,VP_MOTION_TRANSLATION,
- VP_MOTION_AFFINE, VP_MOTION_PROJECTIVE, VP_MOTION_PROJ_3D and
- VP_MOTION_SEMI_PROJ_3D would map a point P={x,y,z,w} to a new point
- P'={x',y',z',w'} using a motion model M such that P'= M.par * P.
- Where M.par is thought of as elements of a 4x4 matrix ordered row
- by row. The interpretation of all models except VP_MOTION_SEMI_PROJ_3D
- is taken to be mapping of a 3d point P"={x",y",z"} which is obtained
- from the normalization {x'/w',y'/w',z'/w'}. In the VP_MOTION_SEMI_PROJ_3D
- the mapping to a point P"={x",y",z"} is obtained from the normalization
- {x'/w',y'/w',z'}. All these motion models have the property that they
- can be inverted using 4x4 matrices. Except for the VP_MOTION_SEMI_PROJ_3D all
- other types can also be cascaded using 4x4 matrices.
-
- Specific macros and functions have been provided to handle 2d instances
- of these functions. As the parameter interpretations can change when adding
- new motion models it is HIGHLY RECOMMENDED that you use the macros MXX,MXY..
- ect. to interpret each motion component.
-#pre
-*/
-
-/*
-#endpre
-# ===================================================================
-#h 1 Typedef and Struct Declarations
-#pre
-*/
-
-#define VP_MAX_MOTION_PAR 16
-
-typedef double VP_PAR;
-typedef VP_PAR VP_TRS[VP_MAX_MOTION_PAR];
-
-/* Do not add any motion models before VP_MOTION_PROJECTIVE */
-/* The order is assumed in vp functions */
-enum VP_MOTION_MODEL {
- VP_MOTION_NONE=0,
- VP_MOTION_TRANSLATION=10,
- VP_MOTION_SCALE=11,
- VP_MOTION_ROTATE=12,
- VP_MOTION_X_SHEAR=13,
- VP_MOTION_Y_SHEAR=14,
- VP_MOTION_SIMILARITY=15,
- VP_MOTION_AFFINE=20,
- VP_MOTION_PROJECTIVE=30,
- VP_MOTION_PROJ_3D=40,
- VP_MOTION_SEMI_PROJ_3D=80,
- VP_SIMILARITY=100,
- VP_VFE_AFFINE=120
-};
-
-#define VP_REFID -1 /* Default ID used for reference frame */
-
-typedef struct {
- VP_TRS par; /* Contains the motion paramerers.
- For the standard motion types this is
- represented as 16 number that refer
- to a 4x4 matrix */
- enum VP_MOTION_MODEL type;
- int refid; /* Reference frame ( takes a point in refid frame
- and moves it by the par to get a point in insid
- frame ) */
- int insid; /* Inspection frame */
-} VP_MOTION;
-
-//typedef VP_LIST VP_MOTION_LIST;
-/*
-#endpre
-# ===================================================================
-#h 1 Constant Declarations
-*/
-
-/* Macros related to the 4x4 matrix parameters */
-#define MXX(m) (m).par[0]
-#define MXY(m) (m).par[1]
-#define MXZ(m) (m).par[2]
-#define MXW(m) (m).par[3]
-#define MYX(m) (m).par[4]
-#define MYY(m) (m).par[5]
-#define MYZ(m) (m).par[6]
-#define MYW(m) (m).par[7]
-#define MZX(m) (m).par[8]
-#define MZY(m) (m).par[9]
-#define MZZ(m) (m).par[10]
-#define MZW(m) (m).par[11]
-#define MWX(m) (m).par[12]
-#define MWY(m) (m).par[13]
-#define MWZ(m) (m).par[14]
-#define MWW(m) (m).par[15]
-
-/* The do {...} while (0) technique creates a statement that can be used legally
- in an if-else statement. See "Swallowing the semicolon",
- http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC23 */
-/* Initialize the Motion to be Identity */
-#define VP_MOTION_ID(m) do {\
- MXX(m)=MYY(m)=MZZ(m)=MWW(m)=(VP_PAR)1.0; \
- MXY(m)=MXZ(m)=MXW(m)=(VP_PAR)0.0; \
- MYX(m)=MYZ(m)=MYW(m)=(VP_PAR)0.0; \
- MZX(m)=MZY(m)=MZW(m)=(VP_PAR)0.0; \
- MWX(m)=MWY(m)=MWZ(m)=(VP_PAR)0.0; \
-(m).type = VP_MOTION_TRANSLATION; } while (0)
-
-/* Initialize without altering the translation components */
-#define VP_KEEP_TRANSLATION_3D(m) do {\
- MXX(m)=MYY(m)=MZZ(m)=MWW(m)=(VP_PAR)1.0; \
- MXY(m)=MXZ(m)=(VP_PAR)0.0; \
- MYX(m)=MYZ(m)=(VP_PAR)0.0; \
- MZX(m)=MZY(m)=(VP_PAR)0.0; \
- MWX(m)=MWY(m)=MWZ(m)=(VP_PAR)0.0; \
- (m).type = VP_MOTION_PROJ_3D; } while (0)
-
-/* Initialize without altering the 2d translation components */
-#define VP_KEEP_TRANSLATION_2D(m) do {\
- VP_KEEP_TRANSLATION_3D(m); MZW(m)=(VP_PAR)0.0; (m).type= VP_MOTION_TRANSLATION;} while (0)
-
-/* Initialize without altering the affine & translation components */
-#define VP_KEEP_AFFINE_3D(m) do {\
- MWX(m)=MWY(m)=MWZ(m)=(VP_PAR)0.0; MWW(m)=(VP_PAR)1.0; \
- (m).type = VP_MOTION_PROJ_3D; } while (0)
-
-/* Initialize without altering the 2d affine & translation components */
-#define VP_KEEP_AFFINE_2D(m) do {\
- VP_KEEP_AFFINE_3D(m); \
- MXZ(m)=MYZ(m)=(VP_PAR)0.0; MZZ(m)=(VP_PAR)1.0; \
- MZX(m)=MZY(m)=MZW(m)=(VP_PAR)0.0; \
- (m).type = VP_MOTION_AFFINE; } while (0)
-
-/* Initialize without altering the 2d projective parameters */
-#define VP_KEEP_PROJECTIVE_2D(m) do {\
- MXZ(m)=MYZ(m)=(VP_PAR)0.0; MZZ(m)=(VP_PAR)1.0; \
- MZX(m)=MZY(m)=MZW(m)=MWZ(m)=(VP_PAR)0.0; \
- (m).type = VP_MOTION_PROJECTIVE; } while (0)
-
-/* Warp a 2d point (assuming the z component is zero) */
-#define VP_WARP_POINT_2D(inx,iny,m,outx,outy) do {\
- VP_PAR vpTmpWarpPnt___= MWX(m)*(inx)+MWY(m)*(iny)+MWW(m); \
- outx = (MXX(m)*((VP_PAR)inx)+MXY(m)*((VP_PAR)iny)+MXW(m))/vpTmpWarpPnt___; \
- outy = (MYX(m)*((VP_PAR)inx)+MYY(m)*((VP_PAR)iny)+MYW(m))/vpTmpWarpPnt___; } while (0)
-
-/* Warp a 3d point */
-#define VP_WARP_POINT_3D(inx,iny,inz,m,outx,outy,outz) do {\
- VP_PAR vpTmpWarpPnt___= MWX(m)*(inx)+MWY(m)*(iny)+MWZ(m)*((VP_PAR)inz)+MWW(m); \
- outx = (MXX(m)*((VP_PAR)inx)+MXY(m)*((VP_PAR)iny)+MXZ(m)*((VP_PAR)inz)+MXW(m))/vpTmpWarpPnt___; \
- outy = (MYX(m)*((VP_PAR)inx)+MYY(m)*((VP_PAR)iny)+MYZ(m)*((VP_PAR)inz)+MYW(m))/vpTmpWarpPnt___; \
- outz = MZX(m)*((VP_PAR)inx)+MZY(m)*((VP_PAR)iny)+MZZ(m)*((VP_PAR)inz)+MZW(m); \
- if ((m).type==VP_MOTION_PROJ_3D) outz/=vpTmpWarpPnt___; } while (0)
-
-/* Projections of each component */
-#define VP_PROJW_3D(m,x,y,z,f) ( MWX(m)*(x)+MWY(m)*(y)+MWZ(m)*(z)+MWW(m) )
-#define VP_PROJX_3D(m,x,y,z,f,w) ((MXX(m)*(x)+MXY(m)*(y)+MXZ(m)*(z)+MXW(m))/(w))
-#define VP_PROJY_3D(m,x,y,z,f,w) ((MYX(m)*(x)+MYY(m)*(y)+MYZ(m)*(z)+MYW(m))/(w))
-#define VP_PROJZ_3D(m,x,y,z,f,w) ((MZX(m)*(x)+MZY(m)*(y)+MZZ(m)*(z)+MZW(m))/(w))
-
-/* Scale Down a matrix by Sfactor */
-#define VP_SCALEDOWN(m,Sfactor) do { \
- MXW(m) /= (VP_PAR)Sfactor; MWX(m) *= (VP_PAR)Sfactor; \
- MYW(m) /= (VP_PAR)Sfactor; MWY(m) *= (VP_PAR)Sfactor; \
- MZW(m) /= (VP_PAR)Sfactor; MWZ(m) *= (VP_PAR)Sfactor; } while (0)
-
-/* Scale Up a matrix by Sfactor */
-#define VP_SCALEUP(m,Sfactor) do { \
- MXW(m) *= (VP_PAR)Sfactor; MWX(m) /= (VP_PAR)Sfactor; \
- MYW(m) *= (VP_PAR)Sfactor; MWY(m) /= (VP_PAR)Sfactor; \
- MZW(m) *= (VP_PAR)Sfactor; MWZ(m) /= (VP_PAR)Sfactor; } while (0)
-
-/* Normalize the transformation matrix so that MWW is 1 */
-#define VP_NORMALIZE(m) if (MWW(m)!=(VP_PAR)0.0) do { \
- MXX(m)/=MWW(m); MXY(m)/=MWW(m); MXZ(m)/=MWW(m); MXW(m)/= MWW(m); \
- MYX(m)/=MWW(m); MYY(m)/=MWW(m); MYZ(m)/=MWW(m); MYW(m)/= MWW(m); \
- MZX(m)/=MWW(m); MZY(m)/=MWW(m); MZZ(m)/=MWW(m); MZW(m)/= MWW(m); \
- MWX(m)/=MWW(m); MWY(m)/=MWW(m); MWZ(m)/=MWW(m); MWW(m) = (VP_PAR)1.0; } while (0)
-
-#define VP_PRINT_TRANS(msg,b) do { \
- fprintf(stderr, \
- "%s\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n", \
- msg, \
- MXX(b),MXY(b),MXZ(b),MXW(b), \
- MYX(b),MYY(b),MYZ(b),MYW(b), \
- MZX(b),MZY(b),MZZ(b),MZW(b), \
- MWX(b),MWY(b),MWZ(b),MWW(b)); \
-} while (0)
-
-/* w' projection given a point x,y,0,f */
-#define VP_PROJZ(m,x,y,f) ( \
- MWX(m)*((VP_PAR)x)+MWY(m)*((VP_PAR)y)+MWW(m)*((VP_PAR)f))
-
-/* X Projection given a point x,y,0,f and w' */
-#define VP_PROJX(m,x,y,w,f) (\
- (MXX(m)*((VP_PAR)x)+MXY(m)*((VP_PAR)y)+MXW(m)*((VP_PAR)f))/((VP_PAR)w))
-
-/* Y Projection given a point x,y,0,f and the w' */
-#define VP_PROJY(m,x,y,w,f) (\
- (MYX(m)*((VP_PAR)x)+MYY(m)*((VP_PAR)y)+MYW(m)*((VP_PAR)f))/((VP_PAR)w))
-
-/* Set the reference id for a motion */
-#define VP_SET_REFID(m,id) do { (m).refid=id; } while (0)
-
-/* Set the inspection id for a motion */
-#define VP_SET_INSID(m,id) do { (m).insid=id; } while (0)
-
-void vp_copy_motion (const VP_MOTION *src, VP_MOTION *dst);
-int vp_invert_motion(const VP_MOTION* in,VP_MOTION* out);
-int vp_cascade_motion(const VP_MOTION* InAB, const VP_MOTION* InBC,VP_MOTION* OutAC);
-int vp_zoom_motion2d(VP_MOTION* in, VP_MOTION* out,
- int n, int w, int h, double zoom);
-double vp_motion_cornerdiff(const VP_MOTION *mot_a, const VP_MOTION *mot_b,
- int xo, int yo, int w, int h);
-
-#endif /* VP_MOTIONMODEL_H */
-/* =================================================================== */
-/* end vp_motionmodel.h */
diff --git a/jni_mosaic/feature_stab/src/dbregtest/PgmImage.cpp b/jni_mosaic/feature_stab/src/dbregtest/PgmImage.cpp
deleted file mode 100644
index 0891cfd..0000000
--- a/jni_mosaic/feature_stab/src/dbregtest/PgmImage.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include "PgmImage.h"
-#include <cassert>
-
-using namespace std;
-
-PgmImage::PgmImage(std::string filename) :
-m_w(0),m_h(0),m_colors(255),m_format(PGM_BINARY_GRAYMAP),m_over_allocation(256)
-{
- if ( !ReadPGM(filename) )
- return;
-}
-
-PgmImage::PgmImage(int w, int h, int format) :
-m_colors(255),m_w(w),m_h(h),m_format(format),m_over_allocation(256)
-{
- SetFormat(format);
-}
-
-PgmImage::PgmImage(unsigned char *data, int w, int h) :
-m_colors(255),m_w(w),m_h(h),m_format(PGM_BINARY_GRAYMAP),m_over_allocation(256)
-{
- SetData(data);
-}
-
-PgmImage::PgmImage(std::vector<unsigned char> &data, int w, int h) :
-m_colors(255),m_w(w),m_h(h),m_format(PGM_BINARY_GRAYMAP),m_over_allocation(256)
-{
- if ( data.size() == w*h )
- SetData(&data[0]);
- else
- //throw (std::exception("Size of data is not w*h."));
- throw (std::exception());
-}
-
-PgmImage::PgmImage(const PgmImage &im) :
-m_colors(255),m_w(0),m_h(0),m_format(PGM_BINARY_GRAYMAP),m_over_allocation(256)
-{
- DeepCopy(im, *this);
-}
-
-PgmImage& PgmImage::operator= (const PgmImage &im)
-{
- if (this == &im) return *this;
- DeepCopy(im, *this);
- return *this;
-}
-
-void PgmImage::DeepCopy(const PgmImage& src, PgmImage& dst)
-{
- dst.m_data = src.m_data;
-
- // PGM data
- dst.m_w = src.m_w;
- dst.m_h = src.m_h;
- dst.m_format = src.m_format;
- dst.m_colors = src.m_colors;
-
- dst.m_comment = src.m_comment;
- SetupRowPointers();
-}
-
-PgmImage::~PgmImage()
-{
-
-}
-
-void PgmImage::SetFormat(int format)
-{
- m_format = format;
-
- switch (format)
- {
- case PGM_BINARY_GRAYMAP:
- m_data.resize(m_w*m_h+m_over_allocation);
- break;
- case PGM_BINARY_PIXMAP:
- m_data.resize(m_w*m_h*3+m_over_allocation);
- break;
- default:
- return;
- break;
- }
- SetupRowPointers();
-}
-
-void PgmImage::SetData(const unsigned char * data)
-{
- m_data.resize(m_w*m_h+m_over_allocation);
- memcpy(&m_data[0],data,m_w*m_h);
- SetupRowPointers();
-}
-
-bool PgmImage::ReadPGM(const std::string filename)
-{
- ifstream in(filename.c_str(),std::ios::in | std::ios::binary);
- if ( !in.is_open() )
- return false;
-
- // read the header:
- string format_header,size_header,colors_header;
-
- getline(in,format_header);
- stringstream s;
- s << format_header;
-
- s >> format_header >> m_w >> m_h >> m_colors;
- s.clear();
-
- if ( m_w == 0 )
- {
- while ( in.peek() == '#' )
- getline(in,m_comment);
-
- getline(in,size_header);
-
- while ( in.peek() == '#' )
- getline(in,m_comment);
-
- m_colors = 0;
-
- // parse header
- s << size_header;
- s >> m_w >> m_h >> m_colors;
- s.clear();
-
- if ( m_colors == 0 )
- {
- getline(in,colors_header);
- s << colors_header;
- s >> m_colors;
- }
- }
-
- if ( format_header == "P5" )
- m_format = PGM_BINARY_GRAYMAP;
- else if (format_header == "P6" )
- m_format = PGM_BINARY_PIXMAP;
- else
- m_format = PGM_FORMAT_INVALID;
-
- switch(m_format)
- {
- case(PGM_BINARY_GRAYMAP):
- m_data.resize(m_w*m_h+m_over_allocation);
- in.read((char *)(&m_data[0]),m_data.size());
- break;
- case(PGM_BINARY_PIXMAP):
- m_data.resize(m_w*m_h*3+m_over_allocation);
- in.read((char *)(&m_data[0]),m_data.size());
- break;
- default:
- return false;
- break;
- }
- in.close();
-
- SetupRowPointers();
-
- return true;
-}
-
-bool PgmImage::WritePGM(const std::string filename, const std::string comment)
-{
- string format_header;
-
- switch(m_format)
- {
- case PGM_BINARY_GRAYMAP:
- format_header = "P5\n";
- break;
- case PGM_BINARY_PIXMAP:
- format_header = "P6\n";
- break;
- default:
- return false;
- break;
- }
-
- ofstream out(filename.c_str(),std::ios::out |ios::binary);
- out << format_header << "# " << comment << '\n' << m_w << " " << m_h << '\n' << m_colors << '\n';
-
- out.write((char *)(&m_data[0]), m_data.size());
-
- out.close();
-
- return true;
-}
-
-void PgmImage::SetupRowPointers()
-{
- int i;
- m_rows.resize(m_h);
-
- switch (m_format)
- {
- case PGM_BINARY_GRAYMAP:
- for(i=0;i<m_h;i++)
- {
- m_rows[i]=&m_data[m_w*i];
- }
- break;
- case PGM_BINARY_PIXMAP:
- for(i=0;i<m_h;i++)
- {
- m_rows[i]=&m_data[(m_w*3)*i];
- }
- break;
- }
-}
-
-void PgmImage::ConvertToGray()
-{
- if ( m_format != PGM_BINARY_PIXMAP ) return;
-
- // Y = 0.3*R + 0.59*G + 0.11*B;
- for ( int i = 0; i < m_w*m_h; ++i )
- m_data[i] = (unsigned char)(0.3*m_data[3*i]+0.59*m_data[3*i+1]+0.11*m_data[3*i+2]);
-
- m_data.resize(m_w*m_h+m_over_allocation);
- m_format = PGM_BINARY_GRAYMAP;
-
- SetupRowPointers();
-}
-
-std::ostream& operator<< (std::ostream& o, const PgmImage& im)
-{
- o << "PGM Image Info:\n";
- o << "Size: " << im.m_w << " x " << im.m_h << "\n";
- o << "Comment: " << im.m_comment << "\n";
- switch (im.m_format)
- {
- case PgmImage::PGM_BINARY_PIXMAP:
- o << "Format: RGB binary pixmap";
- break;
- case PgmImage::PGM_BINARY_GRAYMAP:
- o << "Format: PPM binary graymap";
- break;
- default:
- o << "Format: Invalid";
- break;
- }
- o << endl;
- return o;
-}
diff --git a/jni_mosaic/feature_stab/src/dbregtest/PgmImage.h b/jni_mosaic/feature_stab/src/dbregtest/PgmImage.h
deleted file mode 100644
index d4d1eeb..0000000
--- a/jni_mosaic/feature_stab/src/dbregtest/PgmImage.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma once
-
-#include <vector>
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <memory.h>
-
-/*!
- * Simple class to manipulate PGM/PPM images. Not suitable for heavy lifting.
- */
-class PgmImage
-{
- friend std::ostream& operator<< (std::ostream& o, const PgmImage& im);
-public:
- enum {PGM_BINARY_GRAYMAP,PGM_BINARY_PIXMAP,PGM_FORMAT_INVALID};
- /*!
- * Constructor from a PGM file name.
- */
- PgmImage(std::string filename);
- /*!
- * Constructor to allocate an image of given size and type.
- */
- PgmImage(int w, int h, int format = PGM_BINARY_GRAYMAP);
- /*!
- * Constructor to allocate an image of given size and copy the data in.
- */
- PgmImage(unsigned char *data, int w, int h);
- /*!
- * Constructor to allocate an image of given size and copy the data in.
- */
- PgmImage(std::vector<unsigned char> &data, int w, int h);
-
- PgmImage(const PgmImage &im);
-
- PgmImage& operator= (const PgmImage &im);
- ~PgmImage();
-
- int GetHeight() const { return m_h; }
- int GetWidth() const { return m_w; }
-
- //! Copy pixels from data pointer
- void SetData(const unsigned char * data);
-
- //! Get a data pointer to unaligned memory area
- unsigned char * GetDataPointer() { if ( m_data.size() > 0 ) return &m_data[0]; else return NULL; }
- unsigned char ** GetRowPointers() { if ( m_rows.size() == m_h ) return &m_rows[0]; else return NULL; }
-
- //! Read a PGM file from disk
- bool ReadPGM(const std::string filename);
- //! Write a PGM file to disk
- bool WritePGM(const std::string filename, const std::string comment="");
-
- //! Get image format (returns PGM_BINARY_GRAYMAP, PGM_BINARY_PIXMAP or PGM_FORMAT_INVALID)
- int GetFormat() const { return m_format; }
-
- //! Set image format (returns PGM_BINARY_GRAYMAP, PGM_BINARY_PIXMAP). Image data becomes invalid.
- void SetFormat(int format);
-
- //! If the image is PGM_BINARY_PIXMAP, convert it to PGM_BINARY_GRAYMAP via Y = 0.3*R + 0.59*G + 0.11*B.
- void ConvertToGray();
-protected:
- // Generic functions:
- void DeepCopy(const PgmImage& src, PgmImage& dst);
- void SetupRowPointers();
-
- // PGM data
- int m_w;
- int m_h;
- int m_format;
- int m_colors;
- int m_over_allocation;
- std::vector<unsigned char> m_data;
- std::string m_comment;
-
- std::vector<unsigned char *> m_rows;
-};
-
-std::ostream& operator<< (std::ostream& o, const PgmImage& im);
diff --git a/jni_mosaic/feature_stab/src/dbregtest/dbregtest.cpp b/jni_mosaic/feature_stab/src/dbregtest/dbregtest.cpp
deleted file mode 100644
index 5087362..0000000
--- a/jni_mosaic/feature_stab/src/dbregtest/dbregtest.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// $Id: dbregtest.cpp,v 1.24 2011/06/17 14:04:33 mbansal Exp $
-#include "stdafx.h"
-#include "PgmImage.h"
-#include "../dbreg/dbreg.h"
-#include "../dbreg/dbstabsmooth.h"
-#include <db_utilities_camera.h>
-
-#include <iostream>
-#include <iomanip>
-
-#if PROFILE
- #include <sys/time.h>
-#endif
-
-
-using namespace std;
-
-const int DEFAULT_NR_CORNERS=500;
-const double DEFAULT_MAX_DISPARITY=0.2;
-const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_AFFINE;
-//const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_R_T;
-//const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_TRANSLATION;
-const bool DEFAULT_QUARTER_RESOLUTION=false;
-const unsigned int DEFAULT_REFERENCE_UPDATE_PERIOD=3;
-const bool DEFAULT_DO_MOTION_SMOOTHING = false;
-const double DEFAULT_MOTION_SMOOTHING_GAIN = 0.75;
-const bool DEFAULT_LINEAR_POLISH = false;
-const int DEFAULT_MAX_ITERATIONS = 10;
-
-void usage(string name) {
-
- const char *helpmsg[] = {
- "Function: point-based frame to reference registration.",
- " -m [rt,a,p] : motion model, rt = rotation+translation, a = affine (default = affine).",
- " -c <int> : number of corners (default 1000).",
- " -d <double>: search disparity as portion of image size (default 0.1).",
- " -q : quarter the image resolution (i.e. half of each dimension) (default on)",
- " -r <int> : the period (in nr of frames) for reference frame updates (default = 5)",
- " -s <0/1> : motion smoothing (1 activates motion smoothing, 0 turns it off - default value = 1)",
- " -g <double>: motion smoothing gain, only used if smoothing is on (default value =0.75)",
- NULL
- };
-
- cerr << "Usage: " << name << " [options] image_list.txt" << endl;
-
- const char **p = helpmsg;
-
- while (*p)
- {
- cerr << *p++ << endl;
- }
-}
-
-void parse_cmd_line(stringstream& cmdline,
- const int argc,
- const string& progname,
- string& image_list_file_name,
- int& nr_corners,
- double& max_disparity,
- int& motion_model_type,
- bool& quarter_resolution,
- unsigned int& reference_update_period,
- bool& do_motion_smoothing,
- double& motion_smoothing_gain
- );
-
-int main(int argc, char* argv[])
-{
- int nr_corners = DEFAULT_NR_CORNERS;
- double max_disparity = DEFAULT_MAX_DISPARITY;
- int motion_model_type = DEFAULT_MOTION_MODEL;
- bool quarter_resolution = DEFAULT_QUARTER_RESOLUTION;
-
- unsigned int reference_update_period = DEFAULT_REFERENCE_UPDATE_PERIOD;
-
- bool do_motion_smoothing = DEFAULT_DO_MOTION_SMOOTHING;
- double motion_smoothing_gain = DEFAULT_MOTION_SMOOTHING_GAIN;
- const bool DEFAULT_USE_SMALLER_MATCHING_WINDOW = true;
-
- int default_nr_samples = DB_DEFAULT_NR_SAMPLES/5;
-
- bool use_smaller_matching_window = DEFAULT_USE_SMALLER_MATCHING_WINDOW;
-
-
- bool linear_polish = DEFAULT_LINEAR_POLISH;
-
- if (argc < 2) {
- usage(argv[0]);
- exit(1);
- }
-
- stringstream cmdline;
- string progname(argv[0]);
- string image_list_file_name;
-
-#if PROFILE
- timeval ts1, ts2, ts3, ts4;
-#endif
-
- // put the options and image list file name into the cmdline stringstream
- for (int c = 1; c < argc; c++)
- {
- cmdline << argv[c] << " ";
- }
-
- parse_cmd_line(cmdline, argc, progname, image_list_file_name, nr_corners, max_disparity, motion_model_type,quarter_resolution,reference_update_period,do_motion_smoothing,motion_smoothing_gain);
-
- ifstream in(image_list_file_name.c_str(),ios::in);
-
- if ( !in.is_open() )
- {
- cerr << "Could not open file " << image_list_file_name << ". Exiting" << endl;
-
- return false;
- }
-
- // feature-based image registration class:
- db_FrameToReferenceRegistration reg;
-// db_StabilizationSmoother stab_smoother;
-
- // input file name:
- string file_name;
-
- // look-up tables for image warping:
- float ** lut_x = NULL, **lut_y = NULL;
-
- // if the images are color, the input is saved in color_ref:
- PgmImage color_ref(0,0);
-
- // image width, height:
- int w,h;
-
- int frame_number = 0;
-
- while ( !in.eof() )
- {
- getline(in,file_name);
-
- PgmImage ref(file_name);
-
- if ( ref.GetDataPointer() == NULL )
- {
- cerr << "Could not open image" << file_name << ". Exiting." << endl;
- return -1;
- }
-
- cout << ref << endl;
-
- // color format:
- int format = ref.GetFormat();
-
- // is the input image color?:
- bool color = format == PgmImage::PGM_BINARY_PIXMAP;
-
- w = ref.GetWidth();
- h = ref.GetHeight();
-
- if ( !reg.Initialized() )
- {
- reg.Init(w,h,motion_model_type,DEFAULT_MAX_ITERATIONS,linear_polish,quarter_resolution,DB_POINT_STANDARDDEV,reference_update_period,do_motion_smoothing,motion_smoothing_gain,default_nr_samples,DB_DEFAULT_CHUNK_SIZE,nr_corners,max_disparity,use_smaller_matching_window);
- lut_x = db_AllocImage_f(w,h);
- lut_y = db_AllocImage_f(w,h);
-
- }
-
- if ( color )
- {
- // save the color image:
- color_ref = ref;
- }
-
- // make a grayscale image:
- ref.ConvertToGray();
-
- // compute the homography:
- double H[9],Hinv[9];
- db_Identity3x3(Hinv);
- db_Identity3x3(H);
-
- bool force_reference = false;
-
-#if PROFILE
- gettimeofday(&ts1, NULL);
-#endif
-
- reg.AddFrame(ref.GetRowPointers(),H,false,false);
- cout << reg.profile_string << std::endl;
-
-#if PROFILE
- gettimeofday(&ts2, NULL);
-
- double elapsedTime = (ts2.tv_sec - ts1.tv_sec)*1000.0; // sec to ms
- elapsedTime += (ts2.tv_usec - ts1.tv_usec)/1000.0; // us to ms
- cout <<"\nelapsedTime for Reg<< "<<elapsedTime<<" ms >>>>>>>>>>>>>\n";
-#endif
-
- if (frame_number == 0)
- {
- reg.UpdateReference(ref.GetRowPointers());
- }
-
-
- //std::vector<int> &inlier_indices = reg.GetInliers();
- int *inlier_indices = reg.GetInliers();
- int num_inlier_indices = reg.GetNrInliers();
- printf("[%d] #Inliers = %d\n",frame_number,num_inlier_indices);
-
- reg.Get_H_dref_to_ins(H);
-
- db_GenerateHomographyLut(lut_x,lut_y,w,h,H);
-
- // create a new image and warp:
- PgmImage warped(w,h,format);
-
-#if PROFILE
- gettimeofday(&ts3, NULL);
-#endif
-
- if ( color )
- db_WarpImageLutBilinear_rgb(color_ref.GetRowPointers(),warped.GetRowPointers(),w,h,lut_x,lut_y);
- else
- db_WarpImageLut_u(ref.GetRowPointers(),warped.GetRowPointers(),w,h,lut_x,lut_y,DB_WARP_FAST);
-
-#if PROFILE
- gettimeofday(&ts4, NULL);
- elapsedTime = (ts4.tv_sec - ts3.tv_sec)*1000.0; // sec to ms
- elapsedTime += (ts4.tv_usec - ts3.tv_usec)/1000.0; // us to ms
- cout <<"\nelapsedTime for Warp <<"<<elapsedTime<<" ms >>>>>>>>>>>>>\n";
-#endif
-
- // write aligned image: name is aligned_<corresponding input file name>
- stringstream s;
- s << "aligned_" << file_name;
- warped.WritePGM(s.str());
-
- /*
- // Get the reference and inspection corners to write to file
- double *ref_corners = reg.GetRefCorners();
- double *ins_corners = reg.GetInsCorners();
-
- // get the image file name (without extension), so we
- // can generate the corresponding filenames for matches
- // and inliers
- string file_name_root(file_name.substr(0,file_name.rfind(".")));
-
- // write matches to file
- s.str(string(""));
- s << "Matches_" << file_name_root << ".txt";
-
- ofstream match_file(s.str().c_str());
-
- for (int i = 0; i < reg.GetNrMatches(); i++)
- {
- match_file << ref_corners[3*i] << " " << ref_corners[3*i+1] << " " << ins_corners[3*i] << " " << ins_corners[3*i+1] << endl;
- }
-
- match_file.close();
-
- // write the inlier matches to file
- s.str(string(""));
- s << "InlierMatches_" << file_name_root << ".txt";
-
- ofstream inlier_match_file(s.str().c_str());
-
- for(int i=0; i<num_inlier_indices; i++)
- {
- int k = inlier_indices[i];
- inlier_match_file << ref_corners[3*k] << " "
- << ref_corners[3*k+1] << " "
- << ins_corners[3*k] << " "
- << ins_corners[3*k+1] << endl;
- }
- inlier_match_file.close();
- */
-
- frame_number++;
- }
-
- if ( reg.Initialized() )
- {
- db_FreeImage_f(lut_x,h);
- db_FreeImage_f(lut_y,h);
- }
-
- return 0;
-}
-
-void parse_cmd_line(stringstream& cmdline,
- const int argc,
- const string& progname,
- string& image_list_file_name,
- int& nr_corners,
- double& max_disparity,
- int& motion_model_type,
- bool& quarter_resolution,
- unsigned int& reference_update_period,
- bool& do_motion_smoothing,
- double& motion_smoothing_gain)
-{
- // for counting down the parsed arguments.
- int c = argc;
-
- // a holder
- string token;
-
- while (cmdline >> token)
- {
- --c;
-
- int pos = token.find("-");
-
- if (pos == 0)
- {
- switch (token[1])
- {
- case 'm':
- --c; cmdline >> token;
- if (token.compare("rt") == 0)
- {
- motion_model_type = DB_HOMOGRAPHY_TYPE_R_T;
- }
- else if (token.compare("a") == 0)
- {
- motion_model_type = DB_HOMOGRAPHY_TYPE_AFFINE;
- }
- else if (token.compare("p") == 0)
- {
- motion_model_type = DB_HOMOGRAPHY_TYPE_PROJECTIVE;
- }
- else
- {
- usage(progname);
- exit(1);
- }
- break;
- case 'c':
- --c; cmdline >> nr_corners;
- break;
- case 'd':
- --c; cmdline >> max_disparity;
- break;
- case 'q':
- quarter_resolution = true;
- break;
- case 'r':
- --c; cmdline >> reference_update_period;
- break;
- case 's':
- --c; cmdline >> do_motion_smoothing;
- break;
- case 'g':
- --c; cmdline >> motion_smoothing_gain;
- break;
- default:
- cerr << progname << "illegal option " << token << endl;
- case 'h':
- usage(progname);
- exit(1);
- break;
- }
- }
- else
- {
- if (c != 1)
- {
- usage(progname);
- exit(1);
- }
- else
- {
- --c;
- image_list_file_name = token;
- }
- }
- }
-
- if (c != 0)
- {
- usage(progname);
- exit(1);
- }
-}
-
diff --git a/jni_mosaic/feature_stab/src/dbregtest/stdafx.cpp b/jni_mosaic/feature_stab/src/dbregtest/stdafx.cpp
deleted file mode 100644
index 0c703e2..0000000
--- a/jni_mosaic/feature_stab/src/dbregtest/stdafx.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// stdafx.cpp : source file that includes just the standard includes
-// dbregtest.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/jni_mosaic/feature_stab/src/dbregtest/stdafx.h b/jni_mosaic/feature_stab/src/dbregtest/stdafx.h
deleted file mode 100644
index 9bc06ea..0000000
--- a/jni_mosaic/feature_stab/src/dbregtest/stdafx.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-#include "targetver.h"
-
-#include <stdio.h>
-
-// TODO: reference additional headers your program requires here
diff --git a/jni_mosaic/feature_stab/src/dbregtest/targetver.h b/jni_mosaic/feature_stab/src/dbregtest/targetver.h
deleted file mode 100644
index 9272b0d..0000000
--- a/jni_mosaic/feature_stab/src/dbregtest/targetver.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma once
-
-// The following macros define the minimum required platform. The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
-// your application. The macros work by enabling all features available on platform versions up to and
-// including the version specified.
-
-// Modify the following defines if you have to target a platform prior to the ones specified below.
-// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
-#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
-#endif
-
diff --git a/jni_mosaic/mosaic_renderer_jni.cpp b/jni_mosaic/mosaic_renderer_jni.cpp
deleted file mode 100644
index 36f8064..0000000
--- a/jni_mosaic/mosaic_renderer_jni.cpp
+++ /dev/null
@@ -1,804 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <jni.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "db_utilities_camera.h"
-#include "mosaic/ImageUtils.h"
-#include "mosaic_renderer/FrameBuffer.h"
-#include "mosaic_renderer/WarpRenderer.h"
-#include "mosaic_renderer/SurfaceTextureRenderer.h"
-#include "mosaic_renderer/YVURenderer.h"
-
-#include "mosaic/Log.h"
-#define LOG_TAG "MosaicRenderer"
-
-#include "mosaic_renderer_jni.h"
-
-// Texture handle
-GLuint gSurfaceTextureID[1];
-
-bool gWarpImage = true;
-
-// Low-Res input image frame in YUVA format for preview rendering and processing
-// and high-res YUVA input image for processing.
-unsigned char* gPreviewImage[NR];
-// Low-Res & high-res preview image width
-int gPreviewImageWidth[NR];
-// Low-Res & high-res preview image height
-int gPreviewImageHeight[NR];
-
-// Semaphore to protect simultaneous read/writes from gPreviewImage
-sem_t gPreviewImage_semaphore;
-
-// Off-screen preview FBO width (large enough to store the entire
-// preview mosaic). FBO is frame buffer object.
-int gPreviewFBOWidth;
-// Off-screen preview FBO height (large enough to store the entire
-// preview mosaic).
-int gPreviewFBOHeight;
-
-// gK is the transformation to map the canonical {-1,1} vertex coordinate system
-// to the {0,gPreviewImageWidth[LR]} input image frame coordinate system before
-// applying the given affine transformation trs. gKm is the corresponding
-// transformation for going to the {0,gPreviewFBOWidth}.
-double gK[9];
-double gKinv[9];
-double gKm[9];
-double gKminv[9];
-
-// Shader to copy input SurfaceTexture into and RGBA FBO. The two shaders
-// render to the textures with dimensions corresponding to the low-res and
-// high-res image frames.
-SurfaceTextureRenderer gSurfTexRenderer[NR];
-// Off-screen FBOs to store the low-res and high-res RGBA copied out from
-// the SurfaceTexture by the gSurfTexRenderers.
-FrameBuffer gBufferInput[NR];
-
-// Shader to convert RGBA textures into YVU textures for processing
-YVURenderer gYVURenderer[NR];
-// Off-screen FBOs to store the low-res and high-res YVU textures for processing
-FrameBuffer gBufferInputYVU[NR];
-
-// Shader to translate the flip-flop FBO - gBuffer[1-current] -> gBuffer[current]
-WarpRenderer gWarper1;
-// Shader to add warped current frame to the flip-flop FBO - gBuffer[current]
-WarpRenderer gWarper2;
-// Off-screen FBOs (flip-flop) to store the result of gWarper1 & gWarper2
-FrameBuffer gBuffer[2];
-
-// Shader to warp and render the preview FBO to the screen
-WarpRenderer gPreview;
-
-// Index of the gBuffer FBO gWarper1 is going to write into
-int gCurrentFBOIndex = 0;
-
-// 3x3 Matrices holding the transformation of this frame (gThisH1t) and of
-// the last frame (gLastH1t) w.r.t the first frame.
-double gThisH1t[9];
-double gLastH1t[9];
-
-// Variables to represent the fixed position of the top-left corner of the
-// current frame in the previewFBO
-double gCenterOffsetX = 0.0f;
-double gCenterOffsetY = 0.0f;
-
-// X-Offset of the viewfinder (current frame) w.r.t
-// (gCenterOffsetX, gCenterOffsetY). This offset varies with time and is
-// used to pan the viewfinder across the UI layout.
-double gPanOffset = 0.0f;
-
-// Variables tracking the translation value for the current frame and the
-// last frame (both w.r.t the first frame). The difference between these
-// values is used to control the panning speed of the viewfinder display
-// on the UI screen.
-double gThisTx = 0.0f;
-double gLastTx = 0.0f;
-
-// These are the scale factors used by the gPreview shader to ensure that
-// the image frame is correctly scaled to the full UI layout height while
-// maintaining its aspect ratio
-double gUILayoutScalingX = 1.0f;
-double gUILayoutScalingY = 1.0f;
-
-// Whether the view that we will render preview FBO onto is in landscape or portrait
-// orientation.
-bool gIsLandscapeOrientation = true;
-
-// State of the viewfinder. Set to false when the viewfinder hits the UI edge.
-bool gPanViewfinder = true;
-
-// Affine transformation in GL 4x4 format (column-major) to warp the
-// last frame mosaic into the current frame coordinate system.
-GLfloat g_dAffinetransGL[16];
-double g_dAffinetrans[16];
-
-// Affine transformation in GL 4x4 format (column-major) to translate the
-// preview FBO across the screen (viewfinder panning).
-GLfloat g_dAffinetransPanGL[16];
-double g_dAffinetransPan[16];
-
-// XY translation in GL 4x4 format (column-major) to center the current
-// preview mosaic in the preview FBO
-GLfloat g_dTranslationToFBOCenterGL[16];
-double g_dTranslationToFBOCenter[16];
-
-// GL 4x4 Identity transformation
-GLfloat g_dAffinetransIdentGL[] = {
- 1., 0., 0., 0.,
- 0., 1., 0., 0.,
- 0., 0., 1., 0.,
- 0., 0., 0., 1.};
-
-// GL 4x4 Rotation transformation (column-majored): 90 degree
-GLfloat g_dAffinetransRotation90GL[] = {
- 0., 1., 0., 0.,
- -1., 0., 0., 0.,
- 0., 0., 1., 0.,
- 0., 0., 0., 1.};
-
-// 3x3 Rotation transformation (row-majored): 90 degree
-double gRotation90[] = {
- 0., -1., 0.,
- 1., 0., 0.,
- 0., 0., 1.,};
-
-
-float g_dIdent3x3[] = {
- 1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- 0.0, 0.0, 1.0};
-
-const int GL_TEXTURE_EXTERNAL_OES_ENUM = 0x8D65;
-
-static void printGLString(const char *name, GLenum s) {
- const char *v = (const char *) glGetString(s);
- LOGI("GL %s = %s", name, v);
-}
-
-void checkFramebufferStatus(const char* name) {
- GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- if (status == 0) {
- LOGE("Checking completeness of Framebuffer:%s", name);
- checkGlError("checkFramebufferStatus (is the target \"GL_FRAMEBUFFER\"?)");
- } else if (status != GL_FRAMEBUFFER_COMPLETE) {
- const char* msg = "not listed";
- switch (status) {
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: msg = "attachment"; break;
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: msg = "dimensions"; break;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: msg = "missing attachment"; break;
- case GL_FRAMEBUFFER_UNSUPPORTED: msg = "unsupported"; break;
- }
- LOGE("Framebuffer: %s is INCOMPLETE: %s, %x", name, msg, status);
- }
-}
-
-// @return false if there was an error
-bool checkGLErrorDetail(const char* file, int line, const char* op) {
- GLint error = glGetError();
- const char* err_msg = "NOT_LISTED";
- if (error != 0) {
- switch (error) {
- case GL_INVALID_VALUE: err_msg = "NOT_LISTED_YET"; break;
- case GL_INVALID_OPERATION: err_msg = "INVALID_OPERATION"; break;
- case GL_INVALID_ENUM: err_msg = "INVALID_ENUM"; break;
- }
- LOGE("Error after %s(). glError: %s (0x%x) in line %d of %s", op, err_msg, error, line, file);
- return false;
- }
- return true;
-}
-
-void bindSurfaceTexture(GLuint texId)
-{
- glBindTexture(GL_TEXTURE_EXTERNAL_OES_ENUM, texId);
-
- // Can't do mipmapping with camera source
- glTexParameterf(GL_TEXTURE_EXTERNAL_OES_ENUM, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR);
- glTexParameterf(GL_TEXTURE_EXTERNAL_OES_ENUM, GL_TEXTURE_MAG_FILTER,
- GL_LINEAR);
- // Clamp to edge is the only option
- glTexParameteri(GL_TEXTURE_EXTERNAL_OES_ENUM, GL_TEXTURE_WRAP_S,
- GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_EXTERNAL_OES_ENUM, GL_TEXTURE_WRAP_T,
- GL_CLAMP_TO_EDGE);
-}
-
-void ClearPreviewImage(int mID)
-{
- unsigned char* ptr = gPreviewImage[mID];
- for(int j = 0, i = 0;
- j < gPreviewImageWidth[mID] * gPreviewImageHeight[mID] * 4;
- j += 4)
- {
- ptr[i++] = 0;
- ptr[i++] = 0;
- ptr[i++] = 0;
- ptr[i++] = 255;
- }
-
-}
-
-void ConvertAffine3x3toGL4x4(double *matGL44, double *mat33)
-{
- matGL44[0] = mat33[0];
- matGL44[1] = mat33[3];
- matGL44[2] = 0.0;
- matGL44[3] = mat33[6];
-
- matGL44[4] = mat33[1];
- matGL44[5] = mat33[4];
- matGL44[6] = 0.0;
- matGL44[7] = mat33[7];
-
- matGL44[8] = 0;
- matGL44[9] = 0;
- matGL44[10] = 1.0;
- matGL44[11] = 0.0;
-
- matGL44[12] = mat33[2];
- matGL44[13] = mat33[5];
- matGL44[14] = 0.0;
- matGL44[15] = mat33[8];
-}
-
-bool continuePanningFBO(double panOffset) {
- double normalizedScreenLimitLeft = -1.0 + VIEWPORT_BORDER_FACTOR_HORZ * 2.0;
- double normalizedScreenLimitRight = 1.0 - VIEWPORT_BORDER_FACTOR_HORZ * 2.0;
- double normalizedXPositionOnScreenLeft;
- double normalizedXPositionOnScreenRight;
-
- // Compute the position of the current frame in the screen coordinate system
- if (gIsLandscapeOrientation) {
- normalizedXPositionOnScreenLeft = (2.0 *
- (gCenterOffsetX + panOffset) / gPreviewFBOWidth - 1.0) *
- gUILayoutScalingX;
- normalizedXPositionOnScreenRight = (2.0 *
- ((gCenterOffsetX + panOffset) + gPreviewImageWidth[HR]) /
- gPreviewFBOWidth - 1.0) * gUILayoutScalingX;
- } else {
- normalizedXPositionOnScreenLeft = (2.0 *
- (gCenterOffsetX + panOffset) / gPreviewFBOWidth - 1.0) *
- gUILayoutScalingY;
- normalizedXPositionOnScreenRight = (2.0 *
- ((gCenterOffsetX + panOffset) + gPreviewImageWidth[HR]) /
- gPreviewFBOWidth - 1.0) * gUILayoutScalingY;
- }
-
- // Stop the viewfinder panning if we hit the maximum border allowed for
- // this UI layout
- if (normalizedXPositionOnScreenRight > normalizedScreenLimitRight ||
- normalizedXPositionOnScreenLeft < normalizedScreenLimitLeft) {
- return false;
- } else {
- return true;
- }
-}
-
-// This function computes fills the 4x4 matrices g_dAffinetrans,
-// and g_dAffinetransPan using the specified 3x3 affine
-// transformation between the first captured frame and the current frame.
-// The computed g_dAffinetrans is such that it warps the preview mosaic in
-// the last frame's coordinate system into the coordinate system of the
-// current frame. Thus, applying this transformation will create the current
-// frame mosaic but with the current frame missing. This frame will then be
-// pasted in by gWarper2 after translating it by g_dTranslationToFBOCenter.
-// The computed g_dAffinetransPan is such that it offsets the computed preview
-// mosaic horizontally to make the viewfinder pan within the UI layout.
-void UpdateWarpTransformation(float *trs)
-{
- double H[9], Hp[9], Htemp1[9], Htemp2[9], T[9];
-
- for(int i = 0; i < 9; i++)
- {
- gThisH1t[i] = trs[i];
- }
-
- // Alignment is done based on low-res data.
- // To render the preview mosaic, the translation of the high-res mosaic is estimated to
- // H2L_FACTOR x low-res-based tranlation.
- gThisH1t[2] *= H2L_FACTOR;
- gThisH1t[5] *= H2L_FACTOR;
-
- db_Identity3x3(T);
- T[2] = -gCenterOffsetX;
- T[5] = -gCenterOffsetY;
-
- // H = ( inv(gThisH1t) * gLastH1t ) * T
- db_Identity3x3(Htemp1);
- db_Identity3x3(Htemp2);
- db_Identity3x3(H);
- db_InvertAffineTransform(Htemp1, gThisH1t);
- db_Multiply3x3_3x3(Htemp2, Htemp1, gLastH1t);
- db_Multiply3x3_3x3(H, Htemp2, T);
-
- for(int i = 0; i < 9; i++)
- {
- gLastH1t[i] = gThisH1t[i];
- }
-
- // Move the origin such that the frame is centered in the previewFBO
- // i.e. H = inv(T) * H
- H[2] += gCenterOffsetX;
- H[5] += gCenterOffsetY;
-
- // Hp = inv(Km) * H * Km
- // Km moves the coordinate system from openGL to image pixels so
- // that the alignment transform H can be applied to them.
- // inv(Km) moves the coordinate system back to openGL normalized
- // coordinates so that the shader can correctly render it.
- db_Identity3x3(Htemp1);
- db_Multiply3x3_3x3(Htemp1, H, gKm);
- db_Multiply3x3_3x3(Hp, gKminv, Htemp1);
-
- ConvertAffine3x3toGL4x4(g_dAffinetrans, Hp);
-
- ////////////////////////////////////////////////
- ////// Compute g_dAffinetransPan now... //////
- ////////////////////////////////////////////////
-
- gThisTx = trs[2];
-
- if(gPanViewfinder)
- {
- gPanOffset += (gThisTx - gLastTx) * VIEWFINDER_PAN_FACTOR_HORZ;
- }
-
- gLastTx = gThisTx;
- gPanViewfinder = continuePanningFBO(gPanOffset);
-
- db_Identity3x3(H);
- H[2] = gPanOffset;
-
- // Hp = inv(Km) * H * Km
- db_Identity3x3(Htemp1);
- db_Multiply3x3_3x3(Htemp1, H, gKm);
- db_Multiply3x3_3x3(Hp, gKminv, Htemp1);
-
- if (gIsLandscapeOrientation) {
- ConvertAffine3x3toGL4x4(g_dAffinetransPan, Hp);
- } else {
- // rotate Hp by 90 degress.
- db_Multiply3x3_3x3(Htemp1, gRotation90, Hp);
- ConvertAffine3x3toGL4x4(g_dAffinetransPan, Htemp1);
- }
-}
-
-void AllocateTextureMemory(int widthHR, int heightHR, int widthLR, int heightLR)
-{
- gPreviewImageWidth[HR] = widthHR;
- gPreviewImageHeight[HR] = heightHR;
-
- gPreviewImageWidth[LR] = widthLR;
- gPreviewImageHeight[LR] = heightLR;
-
- sem_wait(&gPreviewImage_semaphore);
- gPreviewImage[LR] = ImageUtils::allocateImage(gPreviewImageWidth[LR],
- gPreviewImageHeight[LR], 4);
- gPreviewImage[HR] = ImageUtils::allocateImage(gPreviewImageWidth[HR],
- gPreviewImageHeight[HR], 4);
- sem_post(&gPreviewImage_semaphore);
-
- gPreviewFBOWidth = PREVIEW_FBO_WIDTH_SCALE * gPreviewImageWidth[HR];
- gPreviewFBOHeight = PREVIEW_FBO_HEIGHT_SCALE * gPreviewImageHeight[HR];
-
- // The origin is such that the current frame will sit with its center
- // at the center of the previewFBO
- gCenterOffsetX = (gPreviewFBOWidth / 2 - gPreviewImageWidth[HR] / 2);
- gCenterOffsetY = (gPreviewFBOHeight / 2 - gPreviewImageHeight[HR] / 2);
-
- gPanOffset = 0.0f;
-
- db_Identity3x3(gThisH1t);
- db_Identity3x3(gLastH1t);
-
- gPanViewfinder = true;
-
- int w = gPreviewImageWidth[HR];
- int h = gPreviewImageHeight[HR];
-
- int wm = gPreviewFBOWidth;
- int hm = gPreviewFBOHeight;
-
- // K is the transformation to map the canonical [-1,1] vertex coordinate
- // system to the [0,w] image coordinate system before applying the given
- // affine transformation trs.
- gKm[0] = wm / 2.0 - 0.5;
- gKm[1] = 0.0;
- gKm[2] = wm / 2.0 - 0.5;
- gKm[3] = 0.0;
- gKm[4] = hm / 2.0 - 0.5;
- gKm[5] = hm / 2.0 - 0.5;
- gKm[6] = 0.0;
- gKm[7] = 0.0;
- gKm[8] = 1.0;
-
- gK[0] = w / 2.0 - 0.5;
- gK[1] = 0.0;
- gK[2] = w / 2.0 - 0.5;
- gK[3] = 0.0;
- gK[4] = h / 2.0 - 0.5;
- gK[5] = h / 2.0 - 0.5;
- gK[6] = 0.0;
- gK[7] = 0.0;
- gK[8] = 1.0;
-
- db_Identity3x3(gKinv);
- db_InvertCalibrationMatrix(gKinv, gK);
-
- db_Identity3x3(gKminv);
- db_InvertCalibrationMatrix(gKminv, gKm);
-
- //////////////////////////////////////////
- ////// Compute g_Translation now... //////
- //////////////////////////////////////////
- double T[9], Tp[9], Ttemp[9];
-
- db_Identity3x3(T);
- T[2] = gCenterOffsetX;
- T[5] = gCenterOffsetY;
-
- // Tp = inv(K) * T * K
- db_Identity3x3(Ttemp);
- db_Multiply3x3_3x3(Ttemp, T, gK);
- db_Multiply3x3_3x3(Tp, gKinv, Ttemp);
-
- ConvertAffine3x3toGL4x4(g_dTranslationToFBOCenter, Tp);
-
- UpdateWarpTransformation(g_dIdent3x3);
-}
-
-void FreeTextureMemory()
-{
- sem_wait(&gPreviewImage_semaphore);
- ImageUtils::freeImage(gPreviewImage[LR]);
- ImageUtils::freeImage(gPreviewImage[HR]);
- sem_post(&gPreviewImage_semaphore);
-}
-
-extern "C"
-{
- JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved);
- JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved);
- JNIEXPORT jint JNICALL Java_com_android_camera_MosaicRenderer_init(
- JNIEnv * env, jobject obj);
- JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_reset(
- JNIEnv * env, jobject obj, jint width, jint height,
- jboolean isLandscapeOrientation);
- JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_preprocess(
- JNIEnv * env, jobject obj, jfloatArray stMatrix);
- JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_transferGPUtoCPU(
- JNIEnv * env, jobject obj);
- JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_step(
- JNIEnv * env, jobject obj);
- JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_updateMatrix(
- JNIEnv * env, jobject obj);
- JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_setWarping(
- JNIEnv * env, jobject obj, jboolean flag);
-};
-
-
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
-{
- sem_init(&gPreviewImage_semaphore, 0, 1);
-
- return JNI_VERSION_1_4;
-}
-
-
-JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved)
-{
- sem_destroy(&gPreviewImage_semaphore);
-}
-JNIEXPORT jint JNICALL Java_com_android_camera_MosaicRenderer_init(
- JNIEnv * env, jobject obj)
-{
- gSurfTexRenderer[LR].InitializeGLProgram();
- gSurfTexRenderer[HR].InitializeGLProgram();
- gYVURenderer[LR].InitializeGLProgram();
- gYVURenderer[HR].InitializeGLProgram();
- gWarper1.InitializeGLProgram();
- gWarper2.InitializeGLProgram();
- gPreview.InitializeGLProgram();
- gBuffer[0].InitializeGLContext();
- gBuffer[1].InitializeGLContext();
- gBufferInput[LR].InitializeGLContext();
- gBufferInput[HR].InitializeGLContext();
- gBufferInputYVU[LR].InitializeGLContext();
- gBufferInputYVU[HR].InitializeGLContext();
-
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
- glGenTextures(1, gSurfaceTextureID);
- // bind the surface texture
- bindSurfaceTexture(gSurfaceTextureID[0]);
-
- return (jint) gSurfaceTextureID[0];
-}
-
-// width: the width of the view
-// height: the height of the view
-// isLandscape: whether the device is in landscape or portrait. Android
-// Compatibility Definition Document specifies that the long side of the
-// camera aligns with the long side of the screen.
-void calculateUILayoutScaling(int width, int height, bool isLandscape) {
- if (isLandscape) {
- // __________ ________
- // | | => |________|
- // |__________| => (View)
- // (Preview FBO)
- //
- // Scale the preview FBO's height to the height of view and
- // maintain the aspect ratio of the current frame on the screen.
- gUILayoutScalingY = PREVIEW_FBO_HEIGHT_SCALE;
-
- // Note that OpenGL scales a texture to view's width and height automatically.
- // The "width / height" inverts the scaling, so as to maintain the aspect ratio
- // of the current frame.
- gUILayoutScalingX = ((float) gPreviewFBOWidth / gPreviewFBOHeight)
- / ((float) width / height) * PREVIEW_FBO_HEIGHT_SCALE;
- } else {
- // ___
- // __________ | | ______
- // | | => | | => |______|
- // |__________| => | | => (View)
- // (Preview FBO) | |
- // |___|
- //
- // Scale the preview FBO's height to the width of view and
- // maintain the aspect ratio of the current frame on the screen.
- // In preview, Java_com_android_camera_MosaicRenderer_step rotates the
- // preview FBO by 90 degrees. In capture, UpdateWarpTransformation
- // rotates the preview FBO.
- gUILayoutScalingY = PREVIEW_FBO_WIDTH_SCALE;
-
- // Note that OpenGL scales a texture to view's width and height automatically.
- // The "height / width" inverts the scaling, so as to maintain the aspect ratio
- // of the current frame.
- gUILayoutScalingX = ((float) gPreviewFBOHeight / gPreviewFBOWidth)
- / ((float) width / height) * PREVIEW_FBO_WIDTH_SCALE;
- }
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_reset(
- JNIEnv * env, jobject obj, jint width, jint height, jboolean isLandscapeOrientation)
-{
- gIsLandscapeOrientation = isLandscapeOrientation;
- calculateUILayoutScaling(width, height, gIsLandscapeOrientation);
-
- gBuffer[0].Init(gPreviewFBOWidth, gPreviewFBOHeight, GL_RGBA);
- gBuffer[1].Init(gPreviewFBOWidth, gPreviewFBOHeight, GL_RGBA);
-
- gBufferInput[LR].Init(gPreviewImageWidth[LR],
- gPreviewImageHeight[LR], GL_RGBA);
-
- gBufferInput[HR].Init(gPreviewImageWidth[HR],
- gPreviewImageHeight[HR], GL_RGBA);
-
- gBufferInputYVU[LR].Init(gPreviewImageWidth[LR],
- gPreviewImageHeight[LR], GL_RGBA);
-
- gBufferInputYVU[HR].Init(gPreviewImageWidth[HR],
- gPreviewImageHeight[HR], GL_RGBA);
-
- // bind the surface texture
- bindSurfaceTexture(gSurfaceTextureID[0]);
-
- // To speed up, there is no need to clear the destination buffers
- // (offscreen/screen buffers) of gSurfTexRenderer, gYVURenderer
- // and gPreview because we always fill the whole destination buffers
- // when we draw something to those offscreen/screen buffers.
- gSurfTexRenderer[LR].SetupGraphics(&gBufferInput[LR]);
- gSurfTexRenderer[LR].SetViewportMatrix(1, 1, 1, 1);
- gSurfTexRenderer[LR].SetScalingMatrix(1.0f, -1.0f);
- gSurfTexRenderer[LR].SetInputTextureName(gSurfaceTextureID[0]);
- gSurfTexRenderer[LR].SetInputTextureType(GL_TEXTURE_EXTERNAL_OES_ENUM);
-
- gSurfTexRenderer[HR].SetupGraphics(&gBufferInput[HR]);
- gSurfTexRenderer[HR].SetViewportMatrix(1, 1, 1, 1);
- gSurfTexRenderer[HR].SetScalingMatrix(1.0f, -1.0f);
- gSurfTexRenderer[HR].SetInputTextureName(gSurfaceTextureID[0]);
- gSurfTexRenderer[HR].SetInputTextureType(GL_TEXTURE_EXTERNAL_OES_ENUM);
-
- gYVURenderer[LR].SetupGraphics(&gBufferInputYVU[LR]);
- gYVURenderer[LR].SetInputTextureName(gBufferInput[LR].GetTextureName());
- gYVURenderer[LR].SetInputTextureType(GL_TEXTURE_2D);
-
- gYVURenderer[HR].SetupGraphics(&gBufferInputYVU[HR]);
- gYVURenderer[HR].SetInputTextureName(gBufferInput[HR].GetTextureName());
- gYVURenderer[HR].SetInputTextureType(GL_TEXTURE_2D);
-
- // gBuffer[1-gCurrentFBOIndex] --> gWarper1 --> gBuffer[gCurrentFBOIndex]
- gWarper1.SetupGraphics(&gBuffer[gCurrentFBOIndex]);
-
- // Clear the destination buffer of gWarper1.
- gWarper1.Clear(0.0, 0.0, 0.0, 1.0);
- gWarper1.SetViewportMatrix(1, 1, 1, 1);
- gWarper1.SetScalingMatrix(1.0f, 1.0f);
- gWarper1.SetInputTextureName(gBuffer[1 - gCurrentFBOIndex].GetTextureName());
- gWarper1.SetInputTextureType(GL_TEXTURE_2D);
-
- // gBufferInput[HR] --> gWarper2 --> gBuffer[gCurrentFBOIndex]
- gWarper2.SetupGraphics(&gBuffer[gCurrentFBOIndex]);
-
- // gWarp2's destination buffer is the same to gWarp1's. No need to clear it
- // again.
- gWarper2.SetViewportMatrix(gPreviewImageWidth[HR],
- gPreviewImageHeight[HR], gBuffer[gCurrentFBOIndex].GetWidth(),
- gBuffer[gCurrentFBOIndex].GetHeight());
- gWarper2.SetScalingMatrix(1.0f, 1.0f);
- gWarper2.SetInputTextureName(gBufferInput[HR].GetTextureName());
- gWarper2.SetInputTextureType(GL_TEXTURE_2D);
-
- // gBuffer[gCurrentFBOIndex] --> gPreview --> Screen
- gPreview.SetupGraphics(width, height);
- gPreview.SetViewportMatrix(1, 1, 1, 1);
-
- // Scale the previewFBO so that the viewfinder window fills the layout height
- // while maintaining the image aspect ratio
- gPreview.SetScalingMatrix(gUILayoutScalingX, -1.0f * gUILayoutScalingY);
- gPreview.SetInputTextureName(gBuffer[gCurrentFBOIndex].GetTextureName());
- gPreview.SetInputTextureType(GL_TEXTURE_2D);
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_preprocess(
- JNIEnv * env, jobject obj, jfloatArray stMatrix)
-{
- jfloat *stmat = env->GetFloatArrayElements(stMatrix, 0);
-
- gSurfTexRenderer[LR].SetSTMatrix((float*) stmat);
- gSurfTexRenderer[HR].SetSTMatrix((float*) stmat);
-
- env->ReleaseFloatArrayElements(stMatrix, stmat, 0);
-
- gSurfTexRenderer[LR].DrawTexture(g_dAffinetransIdentGL);
- gSurfTexRenderer[HR].DrawTexture(g_dAffinetransIdentGL);
-}
-
-#ifndef now_ms
-#include <time.h>
-static double
-now_ms(void)
-{
- //struct timespec res;
- struct timeval res;
- //clock_gettime(CLOCK_REALTIME, &res);
- gettimeofday(&res, NULL);
- return 1000.0*res.tv_sec + (double)res.tv_usec/1e3;
-}
-#endif
-
-
-
-JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_transferGPUtoCPU(
- JNIEnv * env, jobject obj)
-{
- double t0, t1, time_c;
-
- gYVURenderer[LR].DrawTexture();
- gYVURenderer[HR].DrawTexture();
-
- sem_wait(&gPreviewImage_semaphore);
- // Bind to the input LR FBO and read the Low-Res data from there...
- glBindFramebuffer(GL_FRAMEBUFFER, gBufferInputYVU[LR].GetFrameBufferName());
- t0 = now_ms();
- glReadPixels(0,
- 0,
- gBufferInput[LR].GetWidth(),
- gBufferInput[LR].GetHeight(),
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- gPreviewImage[LR]);
-
- checkGlError("glReadPixels LR (MosaicRenderer.transferGPUtoCPU())");
-
- // Bind to the input HR FBO and read the high-res data from there...
- glBindFramebuffer(GL_FRAMEBUFFER, gBufferInputYVU[HR].GetFrameBufferName());
- t0 = now_ms();
- glReadPixels(0,
- 0,
- gBufferInput[HR].GetWidth(),
- gBufferInput[HR].GetHeight(),
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- gPreviewImage[HR]);
-
- checkGlError("glReadPixels HR (MosaicRenderer.transferGPUtoCPU())");
-
- sem_post(&gPreviewImage_semaphore);
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_step(
- JNIEnv * env, jobject obj)
-{
- if(!gWarpImage) // ViewFinder
- {
- gWarper2.SetupGraphics(&gBuffer[gCurrentFBOIndex]);
- gPreview.SetInputTextureName(gBuffer[gCurrentFBOIndex].GetTextureName());
-
- gWarper2.DrawTexture(g_dTranslationToFBOCenterGL);
-
- if (gIsLandscapeOrientation) {
- gPreview.DrawTexture(g_dAffinetransIdentGL);
- } else {
- gPreview.DrawTexture(g_dAffinetransRotation90GL);
- }
- }
- else
- {
- gWarper1.SetupGraphics(&gBuffer[gCurrentFBOIndex]);
- // Clear the destination so that we can paint on it afresh
- gWarper1.Clear(0.0, 0.0, 0.0, 1.0);
- gWarper1.SetInputTextureName(
- gBuffer[1 - gCurrentFBOIndex].GetTextureName());
- gWarper2.SetupGraphics(&gBuffer[gCurrentFBOIndex]);
- gPreview.SetInputTextureName(gBuffer[gCurrentFBOIndex].GetTextureName());
-
- gWarper1.DrawTexture(g_dAffinetransGL);
- gWarper2.DrawTexture(g_dTranslationToFBOCenterGL);
- gPreview.DrawTexture(g_dAffinetransPanGL);
-
- gCurrentFBOIndex = 1 - gCurrentFBOIndex;
- }
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_setWarping(
- JNIEnv * env, jobject obj, jboolean flag)
-{
- // TODO: Review this logic
- if(gWarpImage != (bool) flag) //switching from viewfinder to capture or vice-versa
- {
- // Clear gBuffer[0]
- gWarper1.SetupGraphics(&gBuffer[0]);
- gWarper1.Clear(0.0, 0.0, 0.0, 1.0);
- // Clear gBuffer[1]
- gWarper1.SetupGraphics(&gBuffer[1]);
- gWarper1.Clear(0.0, 0.0, 0.0, 1.0);
- // Clear the screen to black.
- gPreview.Clear(0.0, 0.0, 0.0, 1.0);
-
- gLastTx = 0.0f;
- gPanOffset = 0.0f;
- gPanViewfinder = true;
-
- db_Identity3x3(gThisH1t);
- db_Identity3x3(gLastH1t);
- // Make sure g_dAffinetransGL and g_dAffinetransPanGL are updated.
- // Otherwise, the first frame after setting the flag to true will be
- // incorrectly drawn.
- if ((bool) flag) {
- UpdateWarpTransformation(g_dIdent3x3);
- }
- }
-
- gWarpImage = (bool)flag;
-}
-
-JNIEXPORT void JNICALL Java_com_android_camera_MosaicRenderer_updateMatrix(
- JNIEnv * env, jobject obj)
-{
- for(int i=0; i<16; i++)
- {
- g_dAffinetransGL[i] = g_dAffinetrans[i];
- g_dAffinetransPanGL[i] = g_dAffinetransPan[i];
- g_dTranslationToFBOCenterGL[i] = g_dTranslationToFBOCenter[i];
- }
-}
diff --git a/jni_mosaic/mosaic_renderer_jni.h b/jni_mosaic/mosaic_renderer_jni.h
deleted file mode 100644
index 7a1b878..0000000
--- a/jni_mosaic/mosaic_renderer_jni.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-#include <semaphore.h>
-
-// The Preview FBO dimensions are determined from the high-res
-// frame dimensions (gPreviewImageWidth, gPreviewImageHeight)
-// using the scale factors below.
-const int PREVIEW_FBO_WIDTH_SCALE = 2;
-const int PREVIEW_FBO_HEIGHT_SCALE = 2;
-
-// The factor below determines the (horizontal) speed at which the viewfinder
-// will pan across the UI during capture. A value of 0.0 will keep the viewfinder
-// static in the center of the screen and 1.0f will make it pan at the
-// same speed as the device.
-const float VIEWFINDER_PAN_FACTOR_HORZ = 0.0f;
-
-// What fraction of the screen viewport width has been allocated to show the
-// arrows on the direction of motion side.
-const float VIEWPORT_BORDER_FACTOR_HORZ = 0.1f;
-
-const int LR = 0; // Low-resolution mode
-const int HR = 1; // High-resolution mode
-const int NR = 2; // Number of resolution modes
-
-const int H2L_FACTOR = 4; // Can be 2
-
-extern "C" void AllocateTextureMemory(int widthHR, int heightHR,
- int widthLR, int heightLR);
-extern "C" void FreeTextureMemory();
-extern "C" void UpdateWarpTransformation(float *trs);
-
-extern unsigned char* gPreviewImage[NR];
-extern int gPreviewImageWidth[NR];
-extern int gPreviewImageHeight[NR];
-
-extern sem_t gPreviewImage_semaphore;
diff --git a/perftests/panorama/Android.mk b/perftests/panorama/Android.mk
deleted file mode 100755
index 17632df..0000000
--- a/perftests/panorama/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-local_target_dir := $(TARGET_OUT_DATA)/local/tmp
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/../../jni_mosaic/feature_mos/src \
- $(LOCAL_PATH)/../../jni_mosaic/feature_stab/src \
- $(LOCAL_PATH)/../../jni_mosaic/feature_stab/db_vlvm
-
-LOCAL_CFLAGS := -O3 -DNDEBUG
-
-LOCAL_SRC_FILES := benchmark.cpp
-
-LOCAL_SHARED_LIBRARIES := libjni_mosaic libGLESv2 libEGL
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_LDFLAGS := -llog -lGLESv2
-
-LOCAL_MODULE := panorama_bench
-
-LOCAL_MODULE_PATH := $(local_target_dir)
-
-include $(BUILD_EXECUTABLE)
diff --git a/perftests/panorama/README.txt b/perftests/panorama/README.txt
deleted file mode 100644
index cbfb35a..0000000
--- a/perftests/panorama/README.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-How to run and verify the benchmark:
-
-1) adb push input /data/panorama_input
-2) adb shell panorama_bench /data/panorama_input/test /data/panorama.ppm
-
-Sample output:
-
-38 frames loaded
-Iteration 0: 1454x330 moasic created: 4.33 seconds (2.05 + 2.28)
-Iteration 1: 1454x330 moasic created: 4.26 seconds (1.83 + 2.44)
-Iteration 2: 1454x330 moasic created: 5.57 seconds (2.73 + 2.84)
-Iteration 3: 1454x330 moasic created: 5.15 seconds (2.33 + 2.82)
-Iteration 4: 1454x330 moasic created: 6.22 seconds (2.05 + 4.16)
-Iteration 5: 1454x330 moasic created: 6.31 seconds (2.16 + 4.15)
-Iteration 6: 1454x330 moasic created: 5.04 seconds (2.03 + 3.01)
-Iteration 7: 1454x330 moasic created: 6.30 seconds (3.47 + 2.83)
-Iteration 8: 1454x330 moasic created: 6.57 seconds (1.83 + 4.73)
-Iteration 9: 1454x330 moasic created: 6.27 seconds (2.28 + 4.00)
-Total elapsed time: 56.02 seconds
-
-The first number in the parenthesis is the time to align the frames; the second
-number is the time to stitch them.
-
-The total elapsed time is the interesting number for benchmarking.
-
-3) adb pull /data/panorama.ppm .
-4) diff panorama.ppm output/golden.ppm
diff --git a/perftests/panorama/benchmark.cpp b/perftests/panorama/benchmark.cpp
deleted file mode 100755
index 2a6440f..0000000
--- a/perftests/panorama/benchmark.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.
- */
-
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "mosaic/Mosaic.h"
-#include "mosaic/ImageUtils.h"
-
-#define MAX_FRAMES 200
-#define KERNEL_ITERATIONS 10
-
-const int blendingType = Blend::BLEND_TYPE_HORZ;
-const int stripType = Blend::STRIP_TYPE_WIDE;
-
-ImageType yvuFrames[MAX_FRAMES];
-
-int loadImages(const char* basename, int &width, int &height)
-{
- char filename[512];
- struct stat filestat;
- int i;
-
- for (i = 0; i < MAX_FRAMES; i++) {
- sprintf(filename, "%s_%03d.ppm", basename, i + 1);
- if (stat(filename, &filestat) != 0) break;
- ImageType rgbFrame = ImageUtils::readBinaryPPM(filename, width, height);
- yvuFrames[i] = ImageUtils::allocateImage(width, height,
- ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
- ImageUtils::rgb2yvu(yvuFrames[i], rgbFrame, width, height);
- ImageUtils::freeImage(rgbFrame);
- }
- return i;
-}
-
-int main(int argc, char **argv)
-{
- struct timespec t1, t2, t3;
-
- int width, height;
- float totalElapsedTime = 0;
-
- const char *basename;
- const char *filename;
-
- if (argc != 3) {
- printf("Usage: %s input_dir output_filename\n", argv[0]);
- return 0;
- } else {
- basename = argv[1];
- filename = argv[2];
- }
-
- // Load the images outside the computational kernel
- int totalFrames = loadImages(basename, width, height);
-
- if (totalFrames == 0) {
- printf("Image files not found. Make sure %s exists.\n",
- basename);
- return 1;
- }
-
- printf("%d frames loaded\n", totalFrames);
-
-
- // Interesting stuff is here
- for (int iteration = 0; iteration < KERNEL_ITERATIONS; iteration++) {
- Mosaic mosaic;
-
- mosaic.initialize(blendingType, stripType, width, height, -1, false, 0);
-
- clock_gettime(CLOCK_MONOTONIC, &t1);
- for (int i = 0; i < totalFrames; i++) {
- mosaic.addFrame(yvuFrames[i]);
- }
- clock_gettime(CLOCK_MONOTONIC, &t2);
-
- float progress = 0.0;
- bool cancelComputation = false;
-
- mosaic.createMosaic(progress, cancelComputation);
-
- int mosaicWidth, mosaicHeight;
- ImageType resultYVU = mosaic.getMosaic(mosaicWidth, mosaicHeight);
-
- ImageType imageRGB = ImageUtils::allocateImage(
- mosaicWidth, mosaicHeight, ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
-
- clock_gettime(CLOCK_MONOTONIC, &t3);
-
- float elapsedTime =
- (t3.tv_sec - t1.tv_sec) + (t3.tv_nsec - t1.tv_nsec)/1e9;
- float addImageTime =
- (t2.tv_sec - t1.tv_sec) + (t2.tv_nsec - t1.tv_nsec)/1e9;
- float stitchImageTime =
- (t3.tv_sec - t2.tv_sec) + (t3.tv_nsec - t2.tv_nsec)/1e9;
-
- totalElapsedTime += elapsedTime;
-
- printf("Iteration %d: %dx%d moasic created: "
- "%.2f seconds (%.2f + %.2f)\n",
- iteration, mosaicWidth, mosaicHeight,
- elapsedTime, addImageTime, stitchImageTime);
-
- // Write the output only once for correctness check
- if (iteration == 0) {
- ImageUtils::yvu2rgb(imageRGB, resultYVU, mosaicWidth,
- mosaicHeight);
- ImageUtils::writeBinaryPPM(imageRGB, filename, mosaicWidth,
- mosaicHeight);
- }
- }
- printf("Total elapsed time: %.2f seconds\n", totalElapsedTime);
-
- return 0;
-}
diff --git a/perftests/panorama/input/test_001.ppm b/perftests/panorama/input/test_001.ppm
deleted file mode 100644
index e7218bf..0000000
--- a/perftests/panorama/input/test_001.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_002.ppm b/perftests/panorama/input/test_002.ppm
deleted file mode 100644
index 8975073..0000000
--- a/perftests/panorama/input/test_002.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_003.ppm b/perftests/panorama/input/test_003.ppm
deleted file mode 100644
index 58c9e34..0000000
--- a/perftests/panorama/input/test_003.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_004.ppm b/perftests/panorama/input/test_004.ppm
deleted file mode 100644
index 142c76b..0000000
--- a/perftests/panorama/input/test_004.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_005.ppm b/perftests/panorama/input/test_005.ppm
deleted file mode 100644
index ff229d3..0000000
--- a/perftests/panorama/input/test_005.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_006.ppm b/perftests/panorama/input/test_006.ppm
deleted file mode 100644
index 2fc5c09..0000000
--- a/perftests/panorama/input/test_006.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_007.ppm b/perftests/panorama/input/test_007.ppm
deleted file mode 100644
index d7f6a9a..0000000
--- a/perftests/panorama/input/test_007.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_008.ppm b/perftests/panorama/input/test_008.ppm
deleted file mode 100644
index 86d92b3..0000000
--- a/perftests/panorama/input/test_008.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_009.ppm b/perftests/panorama/input/test_009.ppm
deleted file mode 100644
index 72dd05f..0000000
--- a/perftests/panorama/input/test_009.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_010.ppm b/perftests/panorama/input/test_010.ppm
deleted file mode 100644
index a09a054..0000000
--- a/perftests/panorama/input/test_010.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_011.ppm b/perftests/panorama/input/test_011.ppm
deleted file mode 100644
index be7b61b..0000000
--- a/perftests/panorama/input/test_011.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_012.ppm b/perftests/panorama/input/test_012.ppm
deleted file mode 100644
index 67fad4a..0000000
--- a/perftests/panorama/input/test_012.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_013.ppm b/perftests/panorama/input/test_013.ppm
deleted file mode 100644
index 6d92fd1..0000000
--- a/perftests/panorama/input/test_013.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_014.ppm b/perftests/panorama/input/test_014.ppm
deleted file mode 100644
index 97aff41..0000000
--- a/perftests/panorama/input/test_014.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_015.ppm b/perftests/panorama/input/test_015.ppm
deleted file mode 100644
index d1de251..0000000
--- a/perftests/panorama/input/test_015.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_016.ppm b/perftests/panorama/input/test_016.ppm
deleted file mode 100644
index 70ea1f5..0000000
--- a/perftests/panorama/input/test_016.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_017.ppm b/perftests/panorama/input/test_017.ppm
deleted file mode 100644
index e075c9e..0000000
--- a/perftests/panorama/input/test_017.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_018.ppm b/perftests/panorama/input/test_018.ppm
deleted file mode 100644
index adf023b..0000000
--- a/perftests/panorama/input/test_018.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_019.ppm b/perftests/panorama/input/test_019.ppm
deleted file mode 100644
index 1f27d1d..0000000
--- a/perftests/panorama/input/test_019.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_020.ppm b/perftests/panorama/input/test_020.ppm
deleted file mode 100644
index fb95f52..0000000
--- a/perftests/panorama/input/test_020.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_021.ppm b/perftests/panorama/input/test_021.ppm
deleted file mode 100644
index 43baadf..0000000
--- a/perftests/panorama/input/test_021.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_022.ppm b/perftests/panorama/input/test_022.ppm
deleted file mode 100644
index f928c83..0000000
--- a/perftests/panorama/input/test_022.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_023.ppm b/perftests/panorama/input/test_023.ppm
deleted file mode 100644
index e21b275..0000000
--- a/perftests/panorama/input/test_023.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_024.ppm b/perftests/panorama/input/test_024.ppm
deleted file mode 100644
index 43ba0ba..0000000
--- a/perftests/panorama/input/test_024.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_025.ppm b/perftests/panorama/input/test_025.ppm
deleted file mode 100644
index b9f8892..0000000
--- a/perftests/panorama/input/test_025.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_026.ppm b/perftests/panorama/input/test_026.ppm
deleted file mode 100644
index 201615f..0000000
--- a/perftests/panorama/input/test_026.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_027.ppm b/perftests/panorama/input/test_027.ppm
deleted file mode 100644
index 07cf426..0000000
--- a/perftests/panorama/input/test_027.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_028.ppm b/perftests/panorama/input/test_028.ppm
deleted file mode 100644
index aedb023..0000000
--- a/perftests/panorama/input/test_028.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_029.ppm b/perftests/panorama/input/test_029.ppm
deleted file mode 100644
index 9a0d398..0000000
--- a/perftests/panorama/input/test_029.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_030.ppm b/perftests/panorama/input/test_030.ppm
deleted file mode 100644
index 26a8f53..0000000
--- a/perftests/panorama/input/test_030.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_031.ppm b/perftests/panorama/input/test_031.ppm
deleted file mode 100644
index 2300461..0000000
--- a/perftests/panorama/input/test_031.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_032.ppm b/perftests/panorama/input/test_032.ppm
deleted file mode 100644
index f5e93f8..0000000
--- a/perftests/panorama/input/test_032.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_033.ppm b/perftests/panorama/input/test_033.ppm
deleted file mode 100644
index c2f8ad9..0000000
--- a/perftests/panorama/input/test_033.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_034.ppm b/perftests/panorama/input/test_034.ppm
deleted file mode 100644
index de93b23..0000000
--- a/perftests/panorama/input/test_034.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_035.ppm b/perftests/panorama/input/test_035.ppm
deleted file mode 100644
index 62198de..0000000
--- a/perftests/panorama/input/test_035.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_036.ppm b/perftests/panorama/input/test_036.ppm
deleted file mode 100644
index bf252e4..0000000
--- a/perftests/panorama/input/test_036.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_037.ppm b/perftests/panorama/input/test_037.ppm
deleted file mode 100644
index 7cc7ace..0000000
--- a/perftests/panorama/input/test_037.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/input/test_038.ppm b/perftests/panorama/input/test_038.ppm
deleted file mode 100644
index d44e1f1..0000000
--- a/perftests/panorama/input/test_038.ppm
+++ /dev/null
Binary files differ
diff --git a/perftests/panorama/output/golden.ppm b/perftests/panorama/output/golden.ppm
deleted file mode 100644
index 5210933..0000000
--- a/perftests/panorama/output/golden.ppm
+++ /dev/null
Binary files differ
diff --git a/proguard.flags b/proguard.flags
index 8cb0486..65104ec 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -14,11 +14,6 @@
<init>(...);
}
--keep class com.android.camera.ActivityBase {
- public int getResultCode();
- public android.content.Intent getResultData();
-}
-
-keep class com.android.camera.CameraActivity {
public boolean isRecording();
public long getAutoFocusTime();
@@ -84,3 +79,8 @@
*** toArray(...);
}
-keep class com.android.gallery3d.util.ProfileData { *; }
+
+# - Required for running jpeg stream tests on userdebug
+-keep class com.android.gallery3d.jpegstream.JPEGOutputStream { *; }
+-keep class com.android.gallery3d.jpegstream.JPEGInputStream { *; }
+-keep class com.android.gallery3d.jpegstream.StreamUtils { *; }
diff --git a/res/drawable-hdpi-v19/grid_pressed.9.png b/res/drawable-hdpi-v19/grid_pressed.9.png
new file mode 100644
index 0000000..506c2c4
--- /dev/null
+++ b/res/drawable-hdpi-v19/grid_pressed.9.png
Binary files differ
diff --git a/res/drawable-hdpi-v19/list_pressed_holo_light.9.png b/res/drawable-hdpi-v19/list_pressed_holo_light.9.png
new file mode 100644
index 0000000..2054530
--- /dev/null
+++ b/res/drawable-hdpi-v19/list_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-hdpi/background_portrait.jpg b/res/drawable-hdpi/background_portrait.jpg
new file mode 100644
index 0000000..75309b4
--- /dev/null
+++ b/res/drawable-hdpi/background_portrait.jpg
Binary files differ
diff --git a/res/drawable-hdpi/btn_shutter_recording.png b/res/drawable-hdpi/btn_shutter_recording.png
deleted file mode 100644
index 4a2e452..0000000
--- a/res/drawable-hdpi/btn_shutter_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/btn_shutter_video_recording.png b/res/drawable-hdpi/btn_shutter_video_recording.png
deleted file mode 100644
index e9921d0..0000000
--- a/res/drawable-hdpi/btn_shutter_video_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/capture_thumbnail_shadow.9.png b/res/drawable-hdpi/capture_thumbnail_shadow.9.png
deleted file mode 100644
index f7a664e..0000000
--- a/res/drawable-hdpi/capture_thumbnail_shadow.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/filtershow_button_grad.png b/res/drawable-hdpi/filtershow_button_grad.png
new file mode 100644
index 0000000..7903ac7
--- /dev/null
+++ b/res/drawable-hdpi/filtershow_button_grad.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_action_overflow.png b/res/drawable-hdpi/ic_action_overflow.png
new file mode 100644
index 0000000..18bc4c5
--- /dev/null
+++ b/res/drawable-hdpi/ic_action_overflow.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_grad_add.png b/res/drawable-hdpi/ic_grad_add.png
new file mode 100644
index 0000000..4e0dc2b
--- /dev/null
+++ b/res/drawable-hdpi/ic_grad_add.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_grad_del.png b/res/drawable-hdpi/ic_grad_del.png
new file mode 100644
index 0000000..521541f
--- /dev/null
+++ b/res/drawable-hdpi/ic_grad_del.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_imagesize.png b/res/drawable-hdpi/ic_imagesize.png
deleted file mode 100644
index 126208b..0000000
--- a/res/drawable-hdpi/ic_imagesize.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_ev_n1.png b/res/drawable-hdpi/ic_indicator_ev_n1.png
deleted file mode 100644
index 56c5e60..0000000
--- a/res/drawable-hdpi/ic_indicator_ev_n1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_ev_n2.png b/res/drawable-hdpi/ic_indicator_ev_n2.png
deleted file mode 100644
index 72838de..0000000
--- a/res/drawable-hdpi/ic_indicator_ev_n2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_ev_n3.png b/res/drawable-hdpi/ic_indicator_ev_n3.png
deleted file mode 100644
index 1200d63..0000000
--- a/res/drawable-hdpi/ic_indicator_ev_n3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_ev_p1.png b/res/drawable-hdpi/ic_indicator_ev_p1.png
deleted file mode 100644
index 5497c86..0000000
--- a/res/drawable-hdpi/ic_indicator_ev_p1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_ev_p2.png b/res/drawable-hdpi/ic_indicator_ev_p2.png
deleted file mode 100644
index 25107fe..0000000
--- a/res/drawable-hdpi/ic_indicator_ev_p2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_ev_p3.png b/res/drawable-hdpi/ic_indicator_ev_p3.png
deleted file mode 100644
index 6d0c1e0..0000000
--- a/res/drawable-hdpi/ic_indicator_ev_p3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_flash_on.png b/res/drawable-hdpi/ic_indicator_flash_on.png
deleted file mode 100644
index ec3d1d5..0000000
--- a/res/drawable-hdpi/ic_indicator_flash_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_loc_off.png b/res/drawable-hdpi/ic_indicator_loc_off.png
deleted file mode 100644
index d5937e4..0000000
--- a/res/drawable-hdpi/ic_indicator_loc_off.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_sce_hdr.png b/res/drawable-hdpi/ic_indicator_sce_hdr.png
deleted file mode 100644
index 0b8fdfa..0000000
--- a/res/drawable-hdpi/ic_indicator_sce_hdr.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_sce_on.png b/res/drawable-hdpi/ic_indicator_sce_on.png
deleted file mode 100644
index ef0f56f..0000000
--- a/res/drawable-hdpi/ic_indicator_sce_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_indicator_timer_on.png b/res/drawable-hdpi/ic_indicator_timer_on.png
deleted file mode 100644
index 8ceade6..0000000
--- a/res/drawable-hdpi/ic_indicator_timer_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_settings_holo_light.png b/res/drawable-hdpi/ic_settings_holo_light.png
deleted file mode 100644
index 5d315a3..0000000
--- a/res/drawable-hdpi/ic_settings_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_switch_pan.png b/res/drawable-hdpi/ic_switch_pan.png
deleted file mode 100644
index c8161be..0000000
--- a/res/drawable-hdpi/ic_switch_pan.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_switch_photosphere.png b/res/drawable-hdpi/ic_switch_photosphere.png
deleted file mode 100644
index ea28eae..0000000
--- a/res/drawable-hdpi/ic_switch_photosphere.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_timer.png b/res/drawable-hdpi/ic_timer.png
deleted file mode 100644
index a3cec8d..0000000
--- a/res/drawable-hdpi/ic_timer.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-land-hdpi/switcher_bg.9.png b/res/drawable-land-hdpi/switcher_bg.9.png
deleted file mode 100644
index dad08d4..0000000
--- a/res/drawable-land-hdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-land-mdpi/switcher_bg.9.png b/res/drawable-land-mdpi/switcher_bg.9.png
deleted file mode 100644
index 2073686..0000000
--- a/res/drawable-land-mdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-land-xhdpi/switcher_bg.9.png b/res/drawable-land-xhdpi/switcher_bg.9.png
deleted file mode 100644
index a726dc8..0000000
--- a/res/drawable-land-xhdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi-v19/grid_pressed.9.png b/res/drawable-mdpi-v19/grid_pressed.9.png
new file mode 100644
index 0000000..388123d
--- /dev/null
+++ b/res/drawable-mdpi-v19/grid_pressed.9.png
Binary files differ
diff --git a/res/drawable-mdpi-v19/list_pressed_holo_light.9.png b/res/drawable-mdpi-v19/list_pressed_holo_light.9.png
new file mode 100644
index 0000000..061904c
--- /dev/null
+++ b/res/drawable-mdpi-v19/list_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-mdpi/background_portrait.jpg b/res/drawable-mdpi/background_portrait.jpg
new file mode 100644
index 0000000..75309b4
--- /dev/null
+++ b/res/drawable-mdpi/background_portrait.jpg
Binary files differ
diff --git a/res/drawable-mdpi/btn_shutter_recording.png b/res/drawable-mdpi/btn_shutter_recording.png
deleted file mode 100644
index 4906d70..0000000
--- a/res/drawable-mdpi/btn_shutter_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/btn_shutter_video_recording.png b/res/drawable-mdpi/btn_shutter_video_recording.png
deleted file mode 100644
index a170eba..0000000
--- a/res/drawable-mdpi/btn_shutter_video_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/capture_thumbnail_shadow.9.png b/res/drawable-mdpi/capture_thumbnail_shadow.9.png
deleted file mode 100644
index db0473d..0000000
--- a/res/drawable-mdpi/capture_thumbnail_shadow.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/filtershow_button_grad.png b/res/drawable-mdpi/filtershow_button_grad.png
new file mode 100644
index 0000000..284da5c
--- /dev/null
+++ b/res/drawable-mdpi/filtershow_button_grad.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_action_overflow.png b/res/drawable-mdpi/ic_action_overflow.png
new file mode 100644
index 0000000..b58b7c9
--- /dev/null
+++ b/res/drawable-mdpi/ic_action_overflow.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_grad_add.png b/res/drawable-mdpi/ic_grad_add.png
new file mode 100644
index 0000000..9465734
--- /dev/null
+++ b/res/drawable-mdpi/ic_grad_add.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_grad_del.png b/res/drawable-mdpi/ic_grad_del.png
new file mode 100644
index 0000000..b6221e6
--- /dev/null
+++ b/res/drawable-mdpi/ic_grad_del.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_imagesize.png b/res/drawable-mdpi/ic_imagesize.png
deleted file mode 100644
index d3f8b62..0000000
--- a/res/drawable-mdpi/ic_imagesize.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_ev_n1.png b/res/drawable-mdpi/ic_indicator_ev_n1.png
deleted file mode 100644
index 528ecd3..0000000
--- a/res/drawable-mdpi/ic_indicator_ev_n1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_ev_n2.png b/res/drawable-mdpi/ic_indicator_ev_n2.png
deleted file mode 100644
index db4deb1..0000000
--- a/res/drawable-mdpi/ic_indicator_ev_n2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_ev_n3.png b/res/drawable-mdpi/ic_indicator_ev_n3.png
deleted file mode 100644
index 6b01a56..0000000
--- a/res/drawable-mdpi/ic_indicator_ev_n3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_ev_p1.png b/res/drawable-mdpi/ic_indicator_ev_p1.png
deleted file mode 100644
index 9a1f6f3..0000000
--- a/res/drawable-mdpi/ic_indicator_ev_p1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_ev_p2.png b/res/drawable-mdpi/ic_indicator_ev_p2.png
deleted file mode 100644
index 712ded5..0000000
--- a/res/drawable-mdpi/ic_indicator_ev_p2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_ev_p3.png b/res/drawable-mdpi/ic_indicator_ev_p3.png
deleted file mode 100644
index d01c2c2..0000000
--- a/res/drawable-mdpi/ic_indicator_ev_p3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_flash_on.png b/res/drawable-mdpi/ic_indicator_flash_on.png
deleted file mode 100644
index 8427072..0000000
--- a/res/drawable-mdpi/ic_indicator_flash_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_loc_off.png b/res/drawable-mdpi/ic_indicator_loc_off.png
deleted file mode 100644
index 87841e3..0000000
--- a/res/drawable-mdpi/ic_indicator_loc_off.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_sce_hdr.png b/res/drawable-mdpi/ic_indicator_sce_hdr.png
deleted file mode 100644
index 7907f64..0000000
--- a/res/drawable-mdpi/ic_indicator_sce_hdr.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_sce_on.png b/res/drawable-mdpi/ic_indicator_sce_on.png
deleted file mode 100644
index 6ea6d77..0000000
--- a/res/drawable-mdpi/ic_indicator_sce_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_indicator_timer_on.png b/res/drawable-mdpi/ic_indicator_timer_on.png
deleted file mode 100644
index 03d6c1b..0000000
--- a/res/drawable-mdpi/ic_indicator_timer_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_settings_holo_light.png b/res/drawable-mdpi/ic_settings_holo_light.png
deleted file mode 100644
index 5b39398..0000000
--- a/res/drawable-mdpi/ic_settings_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_switch_pan.png b/res/drawable-mdpi/ic_switch_pan.png
deleted file mode 100644
index e63b8e9..0000000
--- a/res/drawable-mdpi/ic_switch_pan.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_switch_photosphere.png b/res/drawable-mdpi/ic_switch_photosphere.png
deleted file mode 100644
index 1b8db05..0000000
--- a/res/drawable-mdpi/ic_switch_photosphere.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_timer.png b/res/drawable-mdpi/ic_timer.png
deleted file mode 100644
index b55555f..0000000
--- a/res/drawable-mdpi/ic_timer.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-nodpi/brush_flat.png b/res/drawable-nodpi/brush_flat.png
new file mode 100644
index 0000000..441d847
--- /dev/null
+++ b/res/drawable-nodpi/brush_flat.png
Binary files differ
diff --git a/res/drawable-nodpi/brush_gauss.png b/res/drawable-nodpi/brush_gauss.png
new file mode 100644
index 0000000..6ccb53b
--- /dev/null
+++ b/res/drawable-nodpi/brush_gauss.png
Binary files differ
diff --git a/res/drawable-nodpi/brush_round.png b/res/drawable-nodpi/brush_round.png
new file mode 100644
index 0000000..dab7340
--- /dev/null
+++ b/res/drawable-nodpi/brush_round.png
Binary files differ
diff --git a/res/drawable-nodpi/geometry_shadow.9.png b/res/drawable-nodpi/geometry_shadow.9.png
index 2f7abdc..205e931 100644
--- a/res/drawable-nodpi/geometry_shadow.9.png
+++ b/res/drawable-nodpi/geometry_shadow.9.png
Binary files differ
diff --git a/res/drawable-nodpi/spot_mask.png b/res/drawable-nodpi/spot_mask.png
new file mode 100644
index 0000000..8953759
--- /dev/null
+++ b/res/drawable-nodpi/spot_mask.png
Binary files differ
diff --git a/res/drawable-port-hdpi/switcher_bg.9.png b/res/drawable-port-hdpi/switcher_bg.9.png
deleted file mode 100644
index e6b74a4..0000000
--- a/res/drawable-port-hdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-port-mdpi/switcher_bg.9.png b/res/drawable-port-mdpi/switcher_bg.9.png
deleted file mode 100644
index 6c87aa3..0000000
--- a/res/drawable-port-mdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-port-xhdpi/switcher_bg.9.png b/res/drawable-port-xhdpi/switcher_bg.9.png
deleted file mode 100644
index bbe21ba..0000000
--- a/res/drawable-port-xhdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-hdpi/btn_shutter_recording.png b/res/drawable-sw600dp-hdpi/btn_shutter_recording.png
deleted file mode 100644
index 80f04ff..0000000
--- a/res/drawable-sw600dp-hdpi/btn_shutter_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-hdpi/btn_shutter_video_recording.png b/res/drawable-sw600dp-hdpi/btn_shutter_video_recording.png
deleted file mode 100644
index 65d9879..0000000
--- a/res/drawable-sw600dp-hdpi/btn_shutter_video_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-land-hdpi/switcher_bg.9.png b/res/drawable-sw600dp-land-hdpi/switcher_bg.9.png
deleted file mode 100644
index 21375b1..0000000
--- a/res/drawable-sw600dp-land-hdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-land-mdpi/switcher_bg.9.png b/res/drawable-sw600dp-land-mdpi/switcher_bg.9.png
deleted file mode 100644
index bfd996a..0000000
--- a/res/drawable-sw600dp-land-mdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-land-xhdpi/switcher_bg.9.png b/res/drawable-sw600dp-land-xhdpi/switcher_bg.9.png
deleted file mode 100644
index 35a71db..0000000
--- a/res/drawable-sw600dp-land-xhdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-mdpi/btn_shutter_recording.png b/res/drawable-sw600dp-mdpi/btn_shutter_recording.png
deleted file mode 100644
index 5f56b49..0000000
--- a/res/drawable-sw600dp-mdpi/btn_shutter_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-mdpi/btn_shutter_video_recording.png b/res/drawable-sw600dp-mdpi/btn_shutter_video_recording.png
deleted file mode 100644
index ecf0276..0000000
--- a/res/drawable-sw600dp-mdpi/btn_shutter_video_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-port-hdpi/switcher_bg.9.png b/res/drawable-sw600dp-port-hdpi/switcher_bg.9.png
deleted file mode 100644
index 250276a..0000000
--- a/res/drawable-sw600dp-port-hdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-port-mdpi/switcher_bg.9.png b/res/drawable-sw600dp-port-mdpi/switcher_bg.9.png
deleted file mode 100644
index 9c4e293..0000000
--- a/res/drawable-sw600dp-port-mdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-port-xhdpi/switcher_bg.9.png b/res/drawable-sw600dp-port-xhdpi/switcher_bg.9.png
deleted file mode 100644
index 2d0171e..0000000
--- a/res/drawable-sw600dp-port-xhdpi/switcher_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xhdpi/btn_shutter_recording.png b/res/drawable-sw600dp-xhdpi/btn_shutter_recording.png
deleted file mode 100644
index 0a0e108..0000000
--- a/res/drawable-sw600dp-xhdpi/btn_shutter_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xhdpi/btn_shutter_video_recording.png b/res/drawable-sw600dp-xhdpi/btn_shutter_video_recording.png
deleted file mode 100644
index aa3a4bd..0000000
--- a/res/drawable-sw600dp-xhdpi/btn_shutter_video_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-v19/filtershow_button_background.xml b/res/drawable-v19/filtershow_button_background.xml
new file mode 100644
index 0000000..cef867b
--- /dev/null
+++ b/res/drawable-v19/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="@drawable/list_pressed_holo_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-v19/photopage_bottom_button_background.xml b/res/drawable-v19/photopage_bottom_button_background.xml
new file mode 100644
index 0000000..78571da
--- /dev/null
+++ b/res/drawable-v19/photopage_bottom_button_background.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/list_pressed_holo_light" android:state_pressed="true"/>
+ <item android:drawable="@color/button_dark_transparent_background" android:state_selected="false"/>
+</selector>
diff --git a/res/drawable-v19/transparent_button_background.xml b/res/drawable-v19/transparent_button_background.xml
new file mode 100644
index 0000000..26b1b7c
--- /dev/null
+++ b/res/drawable-v19/transparent_button_background.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/list_pressed_holo_light" android:state_pressed="true"/>
+ <item android:drawable="@drawable/list_pressed_holo_light" android:state_pressed="true"/>
+ <item android:drawable="@android:color/transparent" android:state_selected="false"/>
+</selector>
\ No newline at end of file
diff --git a/res/drawable-xhdpi-v19/grid_pressed.9.png b/res/drawable-xhdpi-v19/grid_pressed.9.png
new file mode 100644
index 0000000..e713a7b
--- /dev/null
+++ b/res/drawable-xhdpi-v19/grid_pressed.9.png
Binary files differ
diff --git a/res/drawable-xhdpi-v19/list_pressed_holo_light.9.png b/res/drawable-xhdpi-v19/list_pressed_holo_light.9.png
new file mode 100644
index 0000000..f4af926
--- /dev/null
+++ b/res/drawable-xhdpi-v19/list_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/btn_shutter_recording.png b/res/drawable-xhdpi/btn_shutter_recording.png
deleted file mode 100644
index 1bd1743..0000000
--- a/res/drawable-xhdpi/btn_shutter_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/btn_shutter_video_recording.png b/res/drawable-xhdpi/btn_shutter_video_recording.png
deleted file mode 100644
index ba1fb5c..0000000
--- a/res/drawable-xhdpi/btn_shutter_video_recording.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/capture_thumbnail_shadow.9.png b/res/drawable-xhdpi/capture_thumbnail_shadow.9.png
deleted file mode 100644
index 3d771f7..0000000
--- a/res/drawable-xhdpi/capture_thumbnail_shadow.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/filtershow_button_grad.png b/res/drawable-xhdpi/filtershow_button_grad.png
new file mode 100644
index 0000000..c5f7035
--- /dev/null
+++ b/res/drawable-xhdpi/filtershow_button_grad.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_action_overflow.png b/res/drawable-xhdpi/ic_action_overflow.png
new file mode 100644
index 0000000..799c35c
--- /dev/null
+++ b/res/drawable-xhdpi/ic_action_overflow.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_grad_add.png b/res/drawable-xhdpi/ic_grad_add.png
new file mode 100644
index 0000000..ca7b654
--- /dev/null
+++ b/res/drawable-xhdpi/ic_grad_add.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_grad_del.png b/res/drawable-xhdpi/ic_grad_del.png
new file mode 100644
index 0000000..9dfb392
--- /dev/null
+++ b/res/drawable-xhdpi/ic_grad_del.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_imagesize.png b/res/drawable-xhdpi/ic_imagesize.png
deleted file mode 100644
index 54fd008..0000000
--- a/res/drawable-xhdpi/ic_imagesize.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_ev_n1.png b/res/drawable-xhdpi/ic_indicator_ev_n1.png
deleted file mode 100644
index e99cc66..0000000
--- a/res/drawable-xhdpi/ic_indicator_ev_n1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_ev_n2.png b/res/drawable-xhdpi/ic_indicator_ev_n2.png
deleted file mode 100644
index aced71d..0000000
--- a/res/drawable-xhdpi/ic_indicator_ev_n2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_ev_n3.png b/res/drawable-xhdpi/ic_indicator_ev_n3.png
deleted file mode 100644
index 41b9f59..0000000
--- a/res/drawable-xhdpi/ic_indicator_ev_n3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_ev_p1.png b/res/drawable-xhdpi/ic_indicator_ev_p1.png
deleted file mode 100644
index 2850c95..0000000
--- a/res/drawable-xhdpi/ic_indicator_ev_p1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_ev_p2.png b/res/drawable-xhdpi/ic_indicator_ev_p2.png
deleted file mode 100644
index c6355b1..0000000
--- a/res/drawable-xhdpi/ic_indicator_ev_p2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_ev_p3.png b/res/drawable-xhdpi/ic_indicator_ev_p3.png
deleted file mode 100644
index 99b860d..0000000
--- a/res/drawable-xhdpi/ic_indicator_ev_p3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_flash_on.png b/res/drawable-xhdpi/ic_indicator_flash_on.png
deleted file mode 100644
index 7e05e15..0000000
--- a/res/drawable-xhdpi/ic_indicator_flash_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_loc_off.png b/res/drawable-xhdpi/ic_indicator_loc_off.png
deleted file mode 100644
index 966855c..0000000
--- a/res/drawable-xhdpi/ic_indicator_loc_off.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_sce_hdr.png b/res/drawable-xhdpi/ic_indicator_sce_hdr.png
deleted file mode 100644
index 318c8fa..0000000
--- a/res/drawable-xhdpi/ic_indicator_sce_hdr.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_sce_on.png b/res/drawable-xhdpi/ic_indicator_sce_on.png
deleted file mode 100644
index 8b2440c..0000000
--- a/res/drawable-xhdpi/ic_indicator_sce_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_indicator_timer_on.png b/res/drawable-xhdpi/ic_indicator_timer_on.png
deleted file mode 100644
index 07cef15..0000000
--- a/res/drawable-xhdpi/ic_indicator_timer_on.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_settings_holo_light.png b/res/drawable-xhdpi/ic_settings_holo_light.png
deleted file mode 100644
index 0da5b5e..0000000
--- a/res/drawable-xhdpi/ic_settings_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_switch_pan.png b/res/drawable-xhdpi/ic_switch_pan.png
deleted file mode 100644
index f17ce2f..0000000
--- a/res/drawable-xhdpi/ic_switch_pan.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_switch_photosphere.png b/res/drawable-xhdpi/ic_switch_photosphere.png
deleted file mode 100644
index 8ff60a3..0000000
--- a/res/drawable-xhdpi/ic_switch_photosphere.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_timer.png b/res/drawable-xhdpi/ic_timer.png
deleted file mode 100644
index 1764fdd..0000000
--- a/res/drawable-xhdpi/ic_timer.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi-v19/grid_pressed.9.png b/res/drawable-xxhdpi-v19/grid_pressed.9.png
new file mode 100644
index 0000000..ad32c46
--- /dev/null
+++ b/res/drawable-xxhdpi-v19/grid_pressed.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi-v19/list_pressed_holo_light.9.png b/res/drawable-xxhdpi-v19/list_pressed_holo_light.9.png
new file mode 100644
index 0000000..1352a17
--- /dev/null
+++ b/res/drawable-xxhdpi-v19/list_pressed_holo_light.9.png
Binary files differ
diff --git a/res/drawable/filtershow_add.png b/res/drawable/filtershow_add.png
new file mode 100644
index 0000000..d353763
--- /dev/null
+++ b/res/drawable/filtershow_add.png
Binary files differ
diff --git a/res/drawable/filtershow_background_new.png b/res/drawable/filtershow_background_new.png
new file mode 100644
index 0000000..a115389
--- /dev/null
+++ b/res/drawable/filtershow_background_new.png
Binary files differ
diff --git a/res/drawable/filtershow_border_film.png b/res/drawable/filtershow_border_film.png
new file mode 100755
index 0000000..9fbd637
--- /dev/null
+++ b/res/drawable/filtershow_border_film.png
Binary files differ
diff --git a/res/drawable/filtershow_button_border.png b/res/drawable/filtershow_button_border.png
new file mode 100644
index 0000000..69195a9
--- /dev/null
+++ b/res/drawable/filtershow_button_border.png
Binary files differ
diff --git a/res/drawable/filtershow_button_colors_contrast.png b/res/drawable/filtershow_button_colors_contrast.png
new file mode 100644
index 0000000..ccb2dc6
--- /dev/null
+++ b/res/drawable/filtershow_button_colors_contrast.png
Binary files differ
diff --git a/res/drawable/filtershow_button_colors_vignette.png b/res/drawable/filtershow_button_colors_vignette.png
new file mode 100644
index 0000000..ac3d53f
--- /dev/null
+++ b/res/drawable/filtershow_button_colors_vignette.png
Binary files differ
diff --git a/res/drawable/filtershow_button_current.png b/res/drawable/filtershow_button_current.png
new file mode 100644
index 0000000..8c4b379
--- /dev/null
+++ b/res/drawable/filtershow_button_current.png
Binary files differ
diff --git a/res/drawable/filtershow_button_fx.png b/res/drawable/filtershow_button_fx.png
new file mode 100644
index 0000000..c887fe4
--- /dev/null
+++ b/res/drawable/filtershow_button_fx.png
Binary files differ
diff --git a/res/drawable/filtershow_button_operations.png b/res/drawable/filtershow_button_operations.png
new file mode 100644
index 0000000..79e9a44
--- /dev/null
+++ b/res/drawable/filtershow_button_operations.png
Binary files differ
diff --git a/res/drawable/filtershow_button_origin.png b/res/drawable/filtershow_button_origin.png
new file mode 100644
index 0000000..0cd0bc2
--- /dev/null
+++ b/res/drawable/filtershow_button_origin.png
Binary files differ
diff --git a/res/drawable/filtershow_button_settings.png b/res/drawable/filtershow_button_settings.png
new file mode 100644
index 0000000..df3925a
--- /dev/null
+++ b/res/drawable/filtershow_button_settings.png
Binary files differ
diff --git a/res/drawable/filtershow_button_show_original.png b/res/drawable/filtershow_button_show_original.png
new file mode 100644
index 0000000..925954b
--- /dev/null
+++ b/res/drawable/filtershow_button_show_original.png
Binary files differ
diff --git a/res/drawable/filtershow_color_picker_circle.xml b/res/drawable/filtershow_color_picker_circle.xml
index 4444e0f..433df48 100644
--- a/res/drawable/filtershow_color_picker_circle.xml
+++ b/res/drawable/filtershow_color_picker_circle.xml
@@ -15,10 +15,12 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval" >
- <size android:width="20dp" android:height="20dp"/>
+ android:shape="rectangle" >
+ <size android:width="16dp" android:height="16dp"/>
<corners
- android:radius="10dp" />
+ android:radius="0dp" />
<solid android:color="@color/red"/>
+ <stroke android:width="0dp"
+ android:color="#ff000000"/>
</shape>
diff --git a/res/drawable/filtershow_delpoint.png b/res/drawable/filtershow_delpoint.png
new file mode 100644
index 0000000..84f2e5b
--- /dev/null
+++ b/res/drawable/filtershow_delpoint.png
Binary files differ
diff --git a/res/drawable/filtershow_grad_button.xml b/res/drawable/filtershow_grad_button.xml
new file mode 100644
index 0000000..4bf84c1
--- /dev/null
+++ b/res/drawable/filtershow_grad_button.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:state_checked="false" android:drawable="@android:color/transparent" />
+ <item android:state_checked="true" android:drawable="@android:color/holo_blue_light" />
+
+</selector>
\ No newline at end of file
diff --git a/res/drawable/filtershow_menu_marker.png b/res/drawable/filtershow_menu_marker.png
index 1537a71..cf720e1 100644
--- a/res/drawable/filtershow_menu_marker.png
+++ b/res/drawable/filtershow_menu_marker.png
Binary files differ
diff --git a/res/drawable/filtershow_menu_marker_rtl.xml b/res/drawable/filtershow_menu_marker_rtl.xml
new file mode 100644
index 0000000..1515004
--- /dev/null
+++ b/res/drawable/filtershow_menu_marker_rtl.xml
@@ -0,0 +1,4 @@
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/filtershow_menu_marker"
+ android:autoMirrored="true">
+</bitmap>
\ No newline at end of file
diff --git a/res/drawable/filtershow_tiled_background.xml b/res/drawable/filtershow_tiled_background.xml
index 055fbcd..dfc7592 100644
--- a/res/drawable/filtershow_tiled_background.xml
+++ b/res/drawable/filtershow_tiled_background.xml
@@ -16,6 +16,6 @@
-->
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/filtershow_background"
+ android:src="@drawable/filtershow_background_new"
android:tileMode="repeat"
android:dither="false" />
\ No newline at end of file
diff --git a/res/drawable/filtershow_versions_compare.png b/res/drawable/filtershow_versions_compare.png
new file mode 100644
index 0000000..bd0ab2b
--- /dev/null
+++ b/res/drawable/filtershow_versions_compare.png
Binary files differ
diff --git a/res/drawable/pano_direction_left_indicator.xml b/res/drawable/pano_direction_left_indicator.xml
deleted file mode 100644
index a0bfb0a..0000000
--- a/res/drawable/pano_direction_left_indicator.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:drawable="@drawable/ic_pan_left_indicator" />
- <item android:drawable="@drawable/ic_pan_left_indicator_fast" />
-</selector>
diff --git a/res/drawable/pano_direction_right_indicator.xml b/res/drawable/pano_direction_right_indicator.xml
deleted file mode 100644
index c3ce377..0000000
--- a/res/drawable/pano_direction_right_indicator.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false"
- android:drawable="@drawable/ic_pan_right_indicator" />
- <item android:drawable="@drawable/ic_pan_right_indicator_fast" />
-</selector>
diff --git a/res/layout-land/camera_controls.xml b/res/layout-land/camera_controls.xml
index 96f593a..d177240 100644
--- a/res/layout-land/camera_controls.xml
+++ b/res/layout-land/camera_controls.xml
@@ -21,6 +21,7 @@
<View
android:id="@+id/blocker"
+ android:clickable="true"
android:layout_height="match_parent"
android:layout_width="@dimen/switcher_size"
android:layout_gravity="right" />
@@ -58,11 +59,12 @@
android:scaleType="center"
android:src="@drawable/btn_new_shutter" />
- <View
+ <ImageView
android:id="@+id/preview_thumb"
android:visibility="invisible"
android:layout_width="@dimen/capture_size"
android:layout_height="@dimen/capture_size"
+ android:scaleType="centerInside"
android:layout_gravity="top|right" />
</com.android.camera.ui.CameraControls>
diff --git a/res/layout-land/filtershow_activity.xml b/res/layout-land/filtershow_activity.xml
index 4d098e6..f438012 100644
--- a/res/layout-land/filtershow_activity.xml
+++ b/res/layout-land/filtershow_activity.xml
@@ -27,59 +27,88 @@
android:orientation="horizontal"
android:animateLayoutChanges="true">
- <LinearLayout
- android:layout_weight="1"
+
+ <FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:orientation="horizontal">
+ android:layout_weight="1">
- <FrameLayout
- android:id="@+id/editorContainer"
- android:layout_width="match_parent"
+ <ProgressBar
+ android:id="@+id/loading"
+ style="@android:style/Widget.Holo.ProgressBar.Large"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1"/>
+ android:layout_gravity="center"
+ android:indeterminate="true"
+ android:indeterminateOnly="true"
+ android:background="@null"/>
- <com.android.gallery3d.filtershow.imageshow.ImageShow
- android:id="@+id/imageShow"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" />
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:orientation="vertical"
+ >
- </LinearLayout>
+ <LinearLayout
+ android:layout_weight="1"
+ android:layout_width="wrap_content"
+ android:layout_height="0dp"
+ android:orientation="horizontal">
+
+ <FrameLayout
+ android:id="@+id/central_panel_container"
+ android:layout_gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:visibility="gone"/>
+
+ <FrameLayout
+ android:id="@+id/editorContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <com.android.gallery3d.filtershow.imageshow.ImageShow
+ android:id="@+id/imageShow"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ </LinearLayout>
+
+ <FrameLayout
+ android:id="@+id/state_panel_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="visible"/>
+
+ </LinearLayout>
+
+ </FrameLayout>
<LinearLayout
android:id="@+id/mainPanel"
android:layout_width="350dip"
android:layout_height="match_parent"
android:orientation="vertical"
- android:animateLayoutChanges="true" >
-
- <FrameLayout android:id="@+id/main_panel_container"
- android:layout_width="350dip"
- android:layout_height="0dip"
- android:layout_weight="1" />
+ android:animateLayoutChanges="true">
<FrameLayout
- android:layout_gravity="bottom"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone">
-
-
- <ProgressBar
- android:id="@+id/loading"
- style="@android:style/Widget.Holo.ProgressBar.Large"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:indeterminate="true"
- android:indeterminateOnly="true"
- android:background="@color/background_screen"/>
-
- </FrameLayout>
+ android:id="@+id/main_panel_container"
+ android:layout_width="350dip"
+ android:layout_height="0dip"
+ android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
+ <com.android.gallery3d.filtershow.category.CategorySelected
+ android:layout_width="@dimen/category_panel_icon_size"
+ android:layout_height="@dimen/category_panel_icon_size"
+ android:id="@+id/categorySelectedIndicator"
+ android:visibility="invisible"/>
+
</FrameLayout>
diff --git a/res/layout-land/filtershow_category_panel_new.xml b/res/layout-land/filtershow_category_panel_new.xml
index 10a6c97..ad85f71 100644
--- a/res/layout-land/filtershow_category_panel_new.xml
+++ b/res/layout-land/filtershow_category_panel_new.xml
@@ -16,17 +16,24 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
+ android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
+ <com.android.gallery3d.filtershow.category.IconView
+ android:id="@+id/addButton"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/category_panel_height"
+ android:src="@drawable/filtershow_add"/>
+
<ListView
android:id="@+id/listItems"
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="0dp"
android:layout_margin="8dip"
android:divider="@android:color/transparent"
- android:dividerHeight="8dip" />
+ android:dividerHeight="8dip"
+ android:layout_weight="1"/>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-land/filtershow_color_border_ui.xml b/res/layout-land/filtershow_color_border_ui.xml
new file mode 100644
index 0000000..9945d9d
--- /dev/null
+++ b/res/layout-land/filtershow_color_border_ui.xml
@@ -0,0 +1,245 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/top"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:visibility="visible">
+
+ <FrameLayout
+ android:id="@+id/editorContainer"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="6"
+ android:layout_gravity="bottom">
+
+ <LinearLayout
+ android:id="@+id/controls"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:orientation="vertical"
+ android:visibility="visible">
+
+ <GridLayout
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:columnCount="2"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/controlName1"
+ android:layout_gravity="left"
+ android:layout_marginLeft="8dip"
+ android:text="@string/color_border_size"/>
+
+ <TextView
+ android:id="@+id/colorBorderSizeValue"
+ android:layout_gravity="right"
+ android:layout_marginRight="8dip"
+ android:textStyle="bold"/>
+
+ <SeekBar
+ android:id="@+id/colorBorderSizeSeekBar"
+ android:layout_width="match_parent"
+ android:layout_column="0"
+ android:layout_columnSpan="2"
+ android:layout_gravity="fill_horizontal"
+ style="@style/FilterShowSlider"/>
+ </GridLayout>
+
+ <GridLayout
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:columnCount="2"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/controlName2"
+ android:layout_gravity="left"
+ android:layout_marginLeft="8dip"
+ android:text="@string/color_border_corner_size"/>
+
+ <TextView
+ android:id="@+id/colorBorderCornerValue"
+ android:layout_gravity="right"
+ android:layout_marginRight="8dip"
+ android:textStyle="bold"/>
+
+ <SeekBar
+ android:id="@+id/colorBorderCornerSizeSeekBar"
+ android:layout_width="match_parent"
+ android:layout_column="0"
+ android:layout_columnSpan="2"
+ android:layout_gravity="fill_horizontal"
+ style="@style/FilterShowSlider"/>
+ </GridLayout>
+
+ <HorizontalScrollView
+ android:id="@+id/scrollList"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:scrollbars="none">
+
+ <LinearLayout
+ android:id="@+id/listStyles"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ </LinearLayout>
+ </HorizontalScrollView>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/colorPicker"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:visibility="gone">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/draw_color"
+ android:layout_marginLeft="8dip"
+ android:id="@+id/textView"/>
+
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorCompareView
+ android:id="@+id/btnSelect"
+ android:layout_width="match_parent"
+ android:layout_height="32dp"
+ android:layout_marginLeft="18dp"
+ android:layout_marginRight="18dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginBottom="0dp"
+ />
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorSVRectView
+ android:id="@+id/colorRectView"
+ android:layout_width="@dimen/draw_ui_width"
+ android:layout_height="@dimen/draw_ui_width"
+ android:layout_gravity="center"
+ android:layout_marginTop="8dp"
+ android:layout_marginRight="1dp"/>
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorHueView
+ android:id="@+id/ColorHueView"
+ android:layout_width="match_parent"
+ android:layout_marginTop="0dp"
+ android:layout_height="32dp" />
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorOpacityView
+ android:id="@+id/colorOpacityView"
+ android:layout_width="match_parent"
+ android:layout_marginTop="24dp"
+ android:layout_height="32dp" />
+ </LinearLayout>
+ </FrameLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_marginBottom="10dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginLeft="1dp"
+ android:layout_marginRight="1dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_marginBottom="10dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginLeft="1dp"
+ android:layout_marginRight="1dp">
+
+ <LinearLayout
+ android:id="@+id/listColors"
+ android:layout_weight="5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/draw_color_button01"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button02"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button03"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button04"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button05"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ </LinearLayout>
+ <FrameLayout
+ android:background="@color/background_main_toolbar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
+ <Button
+ android:id="@+id/draw_color_popupbutton"
+ android:layout_width="48dp"
+ android:layout_gravity="center"
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_action_overflow"
+ />
+ </FrameLayout>
+ </LinearLayout>
+
+
+
+ </LinearLayout>
+</LinearLayout>
diff --git a/res/layout-land/filtershow_draw_ui.xml b/res/layout-land/filtershow_draw_ui.xml
new file mode 100644
index 0000000..5e0a327
--- /dev/null
+++ b/res/layout-land/filtershow_draw_ui.xml
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/top"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:visibility="visible">
+
+ <FrameLayout
+ android:id="@+id/editorContainer"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="6"
+ android:layout_gravity="bottom">
+
+ <LinearLayout
+ android:id="@+id/controls"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:orientation="vertical"
+ android:visibility="visible">
+
+ <Button
+ android:id="@+id/clearButton"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:text="@string/draw_clear"
+ android:visibility="gone"/>
+
+ <GridLayout
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:columnCount="2"
+ android:layout_marginBottom="3dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/controlName1"
+ android:layout_gravity="left"
+ android:layout_marginLeft="8dip"
+ android:text="@string/draw_size"/>
+
+ <TextView
+ android:id="@+id/drawSizeValue"
+ android:layout_gravity="right"
+ android:layout_marginRight="8dip"
+ android:textStyle="bold"/>
+
+ <SeekBar
+ android:id="@+id/drawSizeSeekBar"
+ android:layout_width="match_parent"
+ android:layout_column="0"
+ android:progress="20"
+ android:layout_columnSpan="2"
+ android:layout_gravity="fill_horizontal"
+ style="@style/FilterShowSlider"/>
+ </GridLayout>
+
+ <HorizontalScrollView
+ android:id="@+id/scrollList"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:scrollbars="none">
+
+ <LinearLayout
+ android:id="@+id/listStyles"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ </LinearLayout>
+ </HorizontalScrollView>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/colorPicker"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_gravity="bottom"
+ android:layout_marginBottom="8dp"
+ android:visibility="gone">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/draw_color"
+ android:layout_marginLeft="8dip"
+ android:id="@+id/textView"
+ android:visibility="gone"/>
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorCompareView
+ android:id="@+id/btnSelect"
+ android:layout_width="match_parent"
+ android:layout_height="32dp"
+ android:layout_marginLeft="18dp"
+ android:layout_marginRight="18dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginBottom="0dp"
+ />
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorSVRectView
+ android:id="@+id/colorRectView"
+ android:layout_width="@dimen/draw_ui_width"
+ android:layout_height="@dimen/draw_ui_width"
+ android:layout_gravity="center"
+ android:layout_marginTop="8dp"
+ android:layout_marginRight="1dp"/>
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorHueView
+ android:id="@+id/ColorHueView"
+ android:layout_width="match_parent"
+ android:layout_marginTop="0dp"
+ android:layout_height="32dp" />
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorOpacityView
+ android:id="@+id/colorOpacityView"
+ android:layout_width="match_parent"
+ android:layout_marginTop="24dp"
+ android:layout_height="32dp" />
+
+ </LinearLayout>
+ </FrameLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_marginBottom="10dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginLeft="1dp"
+ android:layout_marginRight="1dp">
+
+
+ <LinearLayout
+ android:id="@+id/listColors"
+ android:layout_weight="5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/draw_color_button01"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button02"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button03"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button04"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button05"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ </LinearLayout>
+
+ <FrameLayout
+ android:background="@color/background_main_toolbar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
+ <Button
+ android:id="@+id/draw_color_popupbutton"
+ android:layout_width="48dp"
+ android:layout_gravity="center"
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_action_overflow"
+ />
+ </FrameLayout>
+ <!--@drawable/ic_action_overflow
+ @android:drawable/ic_menu_more-->
+ </LinearLayout>
+</LinearLayout>
diff --git a/res/layout-land/filtershow_editor_panel.xml b/res/layout-land/filtershow_editor_panel.xml
index 015fa26..f51dc14 100644
--- a/res/layout-land/filtershow_editor_panel.xml
+++ b/res/layout-land/filtershow_editor_panel.xml
@@ -22,51 +22,37 @@
android:orientation="vertical"
android:visibility="visible">
- <Button
- android:id="@+id/toggle_state"
+ <RelativeLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/imageState"
- android:background="@color/background_main_toolbar"
- />
+ android:layout_height="match_parent"
+ >
- <FrameLayout android:id="@+id/state_panel_container"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:visibility="visible"
- android:layout_gravity="top"
- android:layout_weight="1" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_gravity="bottom">
-
- <LinearLayout
- android:id="@+id/controlArea"
+ <Button
+ android:id="@+id/toggle_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_alignParentBottom="true"
- android:visibility="visible">
+ android:text="@string/imageState"
+ android:background="@color/background_main_toolbar"
+ android:layout_alignParentTop="true"
+ />
- <SeekBar
- android:id="@+id/primarySeekBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- style="@style/FilterShowSlider"/>
-
- </LinearLayout>
-
- <LinearLayout
+ <View
+ android:id="@+id/bottomControlLineBottom"
+ android:background="@color/toolbar_separation_line"
+ android:layout_height="1dip"
android:layout_width="match_parent"
- android:layout_height="56dip"
+ android:layout_alignParentBottom="true"
+ />
+ <LinearLayout
+ android:id="@+id/applyBar"
+ android:layout_width="match_parent"
+ android:layout_height="48dip"
android:background="@color/background_main_toolbar"
android:orientation="horizontal"
android:baselineAligned="false"
- android:visibility="visible">
+ android:visibility="visible"
+ android:layout_above="@id/bottomControlLineBottom"
+ >
<ImageButton
android:id="@+id/cancelFilter"
@@ -98,11 +84,10 @@
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="@android:color/transparent"
- android:gravity="center"
android:text="@string/apply_effect"
android:textSize="18dip"
- android:drawableRight="@drawable/filtershow_menu_marker"
- android:textAllCaps="true" />
+ android:drawableEnd="@drawable/filtershow_menu_marker_rtl"
+ android:textAllCaps="true"/>
</LinearLayout>
@@ -122,6 +107,33 @@
android:src="@drawable/ic_menu_done_holo_light"
android:textSize="18dip"/>
</LinearLayout>
- </LinearLayout>
+ <View
+ android:id="@+id/bottomControlLineTop"
+ android:background="@color/toolbar_separation_line"
+ android:layout_height="1dip"
+ android:layout_width="match_parent"
+ android:layout_above="@id/applyBar"
+ />
+ <LinearLayout
+ android:id="@+id/controlArea"
+ android:layout_width="match_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical"
+ android:layout_above="@id/bottomControlLineTop"
+ android:layout_below="@id/toggle_state"
+ android:gravity="bottom"
+ android:visibility="visible">
+
+ <SeekBar
+ android:id="@+id/primarySeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ style="@style/FilterShowSlider"
+ android:visibility="gone"/>
+
+ </LinearLayout>
+
+ </RelativeLayout>
</LinearLayout>
diff --git a/res/layout-land/filtershow_grad_ui.xml b/res/layout-land/filtershow_grad_ui.xml
new file mode 100644
index 0000000..fd09bee
--- /dev/null
+++ b/res/layout-land/filtershow_grad_ui.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/top"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="visible" >
+
+ <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:columnCount="2"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/controlName1"
+ android:layout_gravity="left"
+ android:layout_marginLeft="8dip"
+ android:text="@string/editor_grad_brightness" />
+
+ <TextView
+ android:id="@+id/gradBrightnessValue"
+ android:layout_gravity="right"
+ android:layout_marginRight="8dip"
+ android:textStyle="bold" />
+
+ <SeekBar
+ android:id="@+id/gradBrightnessSeekBar"
+ android:layout_width="match_parent"
+ android:layout_column="0"
+ android:layout_columnSpan="2"
+ android:layout_gravity="fill_horizontal"
+ style="@style/FilterShowSlider" />
+ </GridLayout>
+
+
+ <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:columnCount="2"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/controlName2"
+ android:layout_gravity="left"
+ android:layout_marginLeft="8dip"
+ android:text="@string/editor_grad_saturation"/>
+
+ <TextView
+ android:id="@+id/gradSaturationValue"
+ android:layout_gravity="right"
+ android:layout_marginRight="8dip"
+ android:textStyle="bold" />
+
+ <SeekBar
+ android:id="@+id/gradSaturationSeekBar"
+ android:layout_width="match_parent"
+ android:layout_column="0"
+ android:layout_columnSpan="2"
+ android:layout_gravity="fill_horizontal"
+ style="@style/FilterShowSlider" />
+ </GridLayout>
+ <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:columnCount="2"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/controlName3"
+ android:layout_gravity="left"
+ android:layout_marginLeft="8dip"
+ android:text="@string/editor_grad_contrast"/>
+
+ <TextView
+ android:id="@+id/gradContrastValue"
+ android:layout_gravity="right"
+ android:layout_marginRight="8dip"
+ android:textStyle="bold" />
+
+ <SeekBar
+ android:id="@+id/gradContrastSeekBar"
+ android:layout_width="match_parent"
+ android:layout_column="0"
+ android:layout_columnSpan="2"
+ android:layout_gravity="fill_horizontal"
+ style="@style/FilterShowSlider" />
+ </GridLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_marginTop="24dp">
+
+
+ <ImageButton
+ android:id="@+id/gradAddButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="start|center_vertical"
+ android:gravity="start"
+ android:scaleType="centerInside"
+ android:layout_weight="0"
+ android:background="@drawable/filtershow_button_background"
+ android:src="@drawable/filtershow_addpoint"
+ android:paddingBottom="8dp"
+ android:layout_marginLeft="48dp" />
+
+ <View
+ android:layout_width="wrap_content"
+ android:layout_height="8dp"
+ android:layout_weight="1"/>
+
+ <ImageButton
+ android:id="@+id/gradDelButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="end|center_vertical"
+ android:gravity="end"
+ android:scaleType="centerInside"
+ android:layout_weight="0"
+ android:background="@drawable/filtershow_button_background"
+ android:src="@drawable/ic_menu_trash_holo_light"
+ android:paddingBottom="8dp"
+ android:layout_marginRight="48dp" />
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/res/layout-land/filtershow_main_panel.xml b/res/layout-land/filtershow_main_panel.xml
index 705eb69..6a36de2 100644
--- a/res/layout-land/filtershow_main_panel.xml
+++ b/res/layout-land/filtershow_main_panel.xml
@@ -23,13 +23,6 @@
android:animateLayoutChanges="true"
android:visibility="visible" >
- <FrameLayout android:id="@+id/state_panel_container"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:visibility="visible"
- android:layout_gravity="top"
- android:layout_weight="1" />
-
<FrameLayout android:id="@+id/category_panel_container"
android:layout_width="match_parent"
android:layout_height="0dip"
@@ -95,4 +88,9 @@
</com.android.gallery3d.filtershow.CenteredLinearLayout>
+ <View
+ android:background="@color/toolbar_separation_line"
+ android:layout_height="1dip"
+ android:layout_width="match_parent"/>
+
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-land/filtershow_saturation_controls.xml b/res/layout-land/filtershow_saturation_controls.xml
new file mode 100644
index 0000000..f452a64
--- /dev/null
+++ b/res/layout-land/filtershow_saturation_controls.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:fadeScrollbars="false">
+
+ <GridLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:alignmentMode="alignBounds"
+ android:useDefaultMargins="true"
+ android:columnOrderPreserved="false"
+ android:columnCount="2">
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/editor_chan_sat_red"
+ android:textStyle="bold"
+ android:textColor="#ff8080"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/redValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/redSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/editor_chan_sat_yellow"
+ android:textStyle="bold"
+ android:textColor="#ffff80"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/yellowValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/yellowSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/editor_chan_sat_green"
+ android:textStyle="bold"
+ android:textColor="#80ff80"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/greenValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/greenSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/editor_chan_sat_cyan"
+ android:textStyle="bold"
+ android:textColor="#80ffff"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/cyanValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/cyanSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/editor_chan_sat_blue"
+ android:textStyle="bold"
+ android:textColor="#8080ff"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/blueValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/blueSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/editor_chan_sat_magenta"
+ android:textStyle="bold"
+ android:textColor="#ff80ff"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/magentaValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/magentaSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+ </GridLayout>
+ </ScrollView>
+
+ <GridLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="128dp"
+ android:alignmentMode="alignBounds"
+ android:useDefaultMargins="true"
+ android:columnOrderPreserved="false"
+ android:layout_weight="1"
+ android:columnCount="2">
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/editor_chan_sat_main"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/mainValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/mainSeekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+ </GridLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-land/filtershow_state_panel_new.xml b/res/layout-land/filtershow_state_panel_new.xml
deleted file mode 100644
index c83cd88..0000000
--- a/res/layout-land/filtershow_state_panel_new.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ScrollView
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1"
- android:scrollbars="none">
-
- <com.android.gallery3d.filtershow.state.StatePanelTrack
- android:id="@+id/listStates"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- custom:elemSize="72dip"
- custom:elemEndSize="32dip"
- android:layout_margin="8dip"
- android:animateLayoutChanges="true" />
-
- </ScrollView>
-
- <View
- android:background="@color/state_panel_separation_line"
- android:layout_height="6dip"
- android:layout_width="match_parent"
- android:paddingTop="8dip"/>
-
-</LinearLayout>
diff --git a/res/layout-land/filtershow_vignette_controls.xml b/res/layout-land/filtershow_vignette_controls.xml
new file mode 100644
index 0000000..9bfb29f
--- /dev/null
+++ b/res/layout-land/filtershow_vignette_controls.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:fadeScrollbars="false">
+
+ <GridLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:alignmentMode="alignBounds"
+ android:useDefaultMargins="true"
+ android:columnOrderPreserved="false"
+ android:columnCount="2">
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/vignette_exposure"
+ android:textStyle="bold"
+ android:layout_marginLeft="8dp"
+ android:visibility="gone"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/exposureValue"
+ android:layout_marginRight="16dp"
+ android:visibility="gone"/>
+ <SeekBar
+ android:id="@+id/exposureSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"
+ android:visibility="gone"/>
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/vignette_saturation"
+ android:textStyle="bold"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/saturationValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/saturationSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/vignette_contrast"
+ android:textStyle="bold"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/contrastValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/contrastSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/vignette_falloff"
+ android:textStyle="bold"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/falloffValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/falloffSeekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+
+ </GridLayout>
+ </ScrollView>
+
+ <GridLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="128dp"
+ android:alignmentMode="alignBounds"
+ android:useDefaultMargins="true"
+ android:columnOrderPreserved="false"
+ android:layout_weight="1"
+ android:columnCount="2">
+
+ <TextView
+ android:layout_gravity="left|center_vertical"
+ android:text="@string/vignette_main"
+ android:layout_marginLeft="8dp"/>
+ <TextView
+ android:layout_gravity="right|center_vertical"
+ android:id="@+id/mainVignetteValue"
+ android:layout_marginRight="16dp"/>
+ <SeekBar
+ android:id="@+id/mainVignetteSeekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/FilterShowSlider"
+ android:layout_columnSpan="2"/>
+ </GridLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-land/pano_module_capture.xml b/res/layout-land/pano_module_capture.xml
deleted file mode 100644
index 26cbfb1..0000000
--- a/res/layout-land/pano_module_capture.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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"
- android:id="@+id/camera_app"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:layout_gravity="center"
- android:orientation="horizontal">
-
- <include layout="@layout/preview_frame_pano" />
-
-</LinearLayout>
diff --git a/res/layout-land/pano_review.xml b/res/layout-land/pano_review.xml
deleted file mode 100644
index ea65c26..0000000
--- a/res/layout-land/pano_review.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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"
- android:id="@+id/pano_review_layout"
- android:visibility="gone"
- android:orientation="vertical"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
-
- <TextView style="@style/PanoViewHorizontalBar"
- android:text="@string/pano_review_rendering"
- android:textAppearance="?android:textAppearanceMedium"
- android:gravity="center" />
-
- <ImageView android:id="@+id/pano_reviewarea"
- android:scaleType="fitCenter"
- android:layout_width="match_parent"
- android:layout_height="@dimen/pano_mosaic_surface_height" />
-
- <RelativeLayout style="@style/PanoViewHorizontalBar">
- <com.android.camera.ui.RotateLayout
- android:id="@+id/pano_saving_progress_bar_layout"
- android:layout_centerInParent="true"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content">
- <com.android.camera.PanoProgressBar
- android:id="@+id/pano_saving_progress_bar"
- android:src="@drawable/ic_pan_progression"
- android:layout_centerInParent="true"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content" />
- </com.android.camera.ui.RotateLayout>
-
- <com.android.camera.ui.RotateImageView android:id="@+id/pano_review_cancel_button"
- style="@style/ReviewControlIcon"
- android:contentDescription="@string/accessibility_review_cancel"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:layout_centerHorizontal="false"
- android:src="@drawable/ic_menu_cancel_holo_light" />
- </RelativeLayout>
-</LinearLayout>
diff --git a/res/layout-land/preview_frame_pano.xml b/res/layout-land/preview_frame_pano.xml
deleted file mode 100644
index bd05f9a..0000000
--- a/res/layout-land/preview_frame_pano.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<?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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/frame_layout"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1">
-
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <!-- The top bar with capture indication -->
- <FrameLayout style="@style/PanoViewHorizontalBar">
- <TextView android:id="@+id/pano_capture_indicator"
- android:text="@string/pano_capture_indication"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_gravity="center"
- android:visibility="gone"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </FrameLayout>
-
- <com.android.camera.ui.LayoutNotifyView
- android:id="@+id/pano_preview_area"
- android:visibility="invisible"
- android:background="@drawable/ic_pan_border_fast"
- android:layout_gravity="center"
- android:layout_weight="5"
- android:layout_width="match_parent"
- android:layout_height="0dp" />
-
- <!-- The bottom bar with progress bar and direction indicators -->
- <RelativeLayout style="@style/PanoViewHorizontalBar">
-
- <com.android.camera.ui.RotateLayout
- android:id="@+id/pano_pan_progress_bar_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true">
- <com.android.camera.PanoProgressBar
- android:id="@+id/pano_pan_progress_bar"
- android:visibility="gone"
- android:src="@drawable/ic_pan_progression"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </com.android.camera.ui.RotateLayout>
- <ImageView
- android:id="@+id/pano_pan_left_indicator"
- android:src="@drawable/pano_direction_left_indicator"
- android:visibility="gone"
- android:layout_marginRight="5dp"
- android:layout_toLeftOf="@id/pano_pan_progress_bar_layout"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/pano_pan_right_indicator"
- android:src="@drawable/pano_direction_right_indicator"
- android:visibility="gone"
- android:layout_marginLeft="5dp"
- android:layout_toRightOf="@id/pano_pan_progress_bar_layout"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </RelativeLayout>
-
- </LinearLayout>
-
- <!-- The hint for "Too fast" text view -->
- <com.android.camera.ui.RotateLayout
- android:id="@+id/pano_capture_too_fast_textview_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true">
- <TextView android:id="@+id/pano_capture_too_fast_textview"
- android:text="@string/pano_too_fast_prompt"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone" />
- </com.android.camera.ui.RotateLayout>
-</RelativeLayout>
diff --git a/res/layout-port/camera_controls.xml b/res/layout-port/camera_controls.xml
index ebbdf26..5f89830 100644
--- a/res/layout-port/camera_controls.xml
+++ b/res/layout-port/camera_controls.xml
@@ -21,6 +21,7 @@
<View
android:id="@+id/blocker"
+ android:clickable="true"
android:layout_width="match_parent"
android:layout_height="@dimen/switcher_size"
android:layout_gravity="bottom" />
@@ -58,11 +59,12 @@
android:scaleType="center"
android:src="@drawable/btn_new_shutter" />
- <View
+ <ImageView
android:id="@+id/preview_thumb"
android:visibility="invisible"
android:layout_width="@dimen/capture_size"
android:layout_height="@dimen/capture_size"
+ android:scaleType="centerInside"
android:layout_gravity="top|right" />
</com.android.camera.ui.CameraControls>
\ No newline at end of file
diff --git a/res/layout-port/pano_module_capture.xml b/res/layout-port/pano_module_capture.xml
deleted file mode 100644
index d9c9877..0000000
--- a/res/layout-port/pano_module_capture.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?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"
- android:id="@+id/camera_app"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:orientation="vertical">
-
- <include layout="@layout/preview_frame_pano" />
-
-</LinearLayout>
diff --git a/res/layout-port/pano_review.xml b/res/layout-port/pano_review.xml
deleted file mode 100644
index b2e3d8d..0000000
--- a/res/layout-port/pano_review.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/pano_review_layout"
- android:visibility="gone"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
-
- <LinearLayout
- android:orientation="vertical"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
- <TextView style="@style/PanoViewHorizontalBar"
- android:text="@string/pano_review_rendering"
- android:textAppearance="?android:textAppearanceMedium"
- android:gravity="center" />
-
- <com.android.camera.ui.RotateLayout
- android:id="@+id/pano_rotate_reviewarea"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1.5">
- <ImageView android:id="@+id/pano_reviewarea"
- android:scaleType="fitCenter"
- android:layout_height="match_parent"
- android:layout_width="match_parent" />
- </com.android.camera.ui.RotateLayout>
-
- <View style="@style/PanoViewHorizontalBar"/>
- </LinearLayout>
-
- <com.android.camera.ui.RotateLayout
- android:id="@+id/pano_saving_progress_bar_layout"
- android:layout_centerHorizontal="true"
- android:layout_above="@+id/shutter_button_placeholder"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
- <com.android.camera.PanoProgressBar
- android:id="@+id/pano_saving_progress_bar"
- android:src="@drawable/ic_pan_progression"
- android:layout_centerInParent="true"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content" />
- </com.android.camera.ui.RotateLayout>
-
- <ImageView android:id="@id/shutter_button_placeholder"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_alignParentBottom="true"
- android:layout_marginBottom="@dimen/shutter_offset"
- android:visibility="invisible"
- android:layout_gravity="center"
- android:src="@drawable/btn_shutter_default"/>
-
- <com.android.camera.ui.RotateImageView android:id="@id/pano_review_cancel_button"
- style="@style/ReviewControlIcon"
- android:contentDescription="@string/accessibility_review_cancel"
- android:layout_alignParentBottom="true"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="false"
- android:src="@drawable/ic_menu_cancel_holo_light" />
-</RelativeLayout>
diff --git a/res/layout-port/preview_frame_pano.xml b/res/layout-port/preview_frame_pano.xml
deleted file mode 100644
index 09d7899..0000000
--- a/res/layout-port/preview_frame_pano.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/frame_layout"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
-
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="false"
- android:orientation="vertical">
- <FrameLayout style="@style/PanoViewHorizontalBar">
- <TextView android:id="@+id/pano_capture_indicator"
- android:text="@string/pano_capture_indication"
- android:textAppearance="?android:textAppearanceMedium"
- android:visibility="gone"
- android:layout_gravity="center"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </FrameLayout>
-
- <com.android.camera.ui.LayoutNotifyView
- android:id="@+id/pano_preview_area"
- android:visibility="invisible"
- android:background="@drawable/ic_pan_border_fast"
- android:layout_gravity="center"
- android:layout_weight="2"
- android:layout_width="match_parent"
- android:layout_height="0dp" />
-
- <View style="@style/PanoViewHorizontalBar"/>
- </LinearLayout>
-
- <!-- The hint for "Too fast" text view -->
- <com.android.camera.ui.RotateLayout
- android:id="@+id/pano_capture_too_fast_textview_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true">
- <TextView android:id="@+id/pano_capture_too_fast_textview"
- android:text="@string/pano_too_fast_prompt"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone" />
- </com.android.camera.ui.RotateLayout>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_above="@+id/placeholder">
- <com.android.camera.ui.RotateLayout
- android:id="@+id/pano_pan_progress_bar_layout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true">
- <com.android.camera.PanoProgressBar
- android:id="@+id/pano_pan_progress_bar"
- android:visibility="gone"
- android:src="@drawable/ic_pan_progression"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </com.android.camera.ui.RotateLayout>
-
- <ImageView
- android:id="@+id/pano_pan_left_indicator"
- android:src="@drawable/pano_direction_left_indicator"
- android:visibility="gone"
- android:layout_marginRight="5dp"
- android:layout_toLeftOf="@id/pano_pan_progress_bar_layout"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/pano_pan_right_indicator"
- android:src="@drawable/pano_direction_right_indicator"
- android:visibility="gone"
- android:layout_marginLeft="5dp"
- android:layout_toRightOf="@id/pano_pan_progress_bar_layout"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </RelativeLayout>
-
- <ImageView
- android:id="@id/placeholder"
- android:visibility="invisible"
- android:layout_centerHorizontal="true"
- android:layout_alignParentBottom="true"
- android:layout_marginBottom="@dimen/shutter_offset"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/btn_shutter_default" />
-
-</RelativeLayout>
diff --git a/res/layout/camera.xml b/res/layout/camera.xml
new file mode 100644
index 0000000..9a3a01a
--- /dev/null
+++ b/res/layout/camera.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.camera.ui.CameraRootView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/camera_app_root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+</com.android.camera.ui.CameraRootView>
diff --git a/res/layout/camera_filmstrip.xml b/res/layout/camera_filmstrip.xml
new file mode 100644
index 0000000..d94a9d2
--- /dev/null
+++ b/res/layout/camera_filmstrip.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <com.android.camera.ui.FilmStripView
+ android:id="@+id/filmstrip_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <ImageButton
+ android:id="@+id/filmstrip_bottom_control_panorama"
+ android:layout_width="70dp"
+ android:layout_height="70dp"
+ android:layout_gravity="bottom|center_horizontal"
+ android:background="@drawable/transparent_button_background"
+ android:clickable="true"
+ android:paddingBottom="5dp"
+ android:paddingLeft="5dp"
+ android:paddingRight="5dp"
+ android:paddingTop="5dp"
+ android:visibility="gone"
+ android:src="@drawable/ic_view_photosphere" />
+
+ <LinearLayout
+ android:id="@+id/pano_stitching_progress_panel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|center_horizontal"
+ android:paddingBottom="52dp"
+ android:paddingLeft="5dp"
+ android:paddingRight="5dp"
+ android:paddingTop="5dp"
+ android:visibility="gone"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/pano_stitching_progress_text"
+ android:text="@string/pano_progress_text"
+ android:textColor="#ffffffff"
+ android:textSize="14dp"
+ android:shadowColor="#ff000000"
+ android:shadowDx="0"
+ android:shadowDy="0"
+ android:shadowRadius="2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:paddingBottom="8dp"
+ android:visibility="visible"
+ android:layout_gravity="right"/>
+
+ <ProgressBar
+ android:id="@+id/pano_stitching_progress_bar"
+ style="@android:style/Widget.Holo.Light.ProgressBar.Horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="visible"
+ android:layout_gravity="bottom|center_horizontal" />
+ </LinearLayout>
+
+</FrameLayout>
diff --git a/res/layout/camera_main.xml b/res/layout/camera_main.xml
deleted file mode 100644
index 99befc0..0000000
--- a/res/layout/camera_main.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?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.
--->
-<com.android.camera.ui.CameraRootView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/content"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <include layout="@layout/gl_root_group" />
-
- <FrameLayout
- android:id="@+id/camera_app_root"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <include layout="@layout/camera_controls" />
-
-</com.android.camera.ui.CameraRootView>
\ No newline at end of file
diff --git a/res/layout/crop_activity.xml b/res/layout/crop_activity.xml
index 9ff223f..0620cf4 100644
--- a/res/layout/crop_activity.xml
+++ b/res/layout/crop_activity.xml
@@ -18,8 +18,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:id="@+id/mainView"
- android:background="@drawable/filtershow_tiled_background">
+ android:id="@+id/mainView">
<LinearLayout
android:id="@+id/mainPanel"
diff --git a/res/layout/cropimage.xml b/res/layout/cropimage.xml
new file mode 100644
index 0000000..c434fb6
--- /dev/null
+++ b/res/layout/cropimage.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <include layout="@layout/gl_root_group"/>
+</FrameLayout>
diff --git a/res/layout/details.xml b/res/layout/details.xml
index dfda0ee..1fea0a0 100644
--- a/res/layout/details.xml
+++ b/res/layout/details.xml
@@ -19,5 +19,5 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="left"
+ android:gravity="start"
/>
diff --git a/res/layout/editor_grad_button.xml b/res/layout/editor_grad_button.xml
new file mode 100644
index 0000000..4d1b10b
--- /dev/null
+++ b/res/layout/editor_grad_button.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_alignParentTop="true"
+ android:layout_marginLeft="26dp"
+ android:layout_marginTop="21dp"
+ android:orientation="horizontal" >
+
+ <com.android.gallery3d.filtershow.ui.FramedTextButton
+ android:id="@+id/editorGradButton"
+ android:layout_width="84dip"
+ android:layout_height="84dip"
+ android:layout_gravity="center_vertical|left"
+ android:background="@drawable/filtershow_button_background"
+ android:scaleType="centerInside"
+ android:visibility="visible"
+ android:text="@string/editor_grad_style" />
+
+ <ToggleButton
+ android:id="@+id/editor_grad_new"
+ android:layout_width="84dip"
+ android:layout_height="84dip"
+ android:layout_gravity="center_vertical|left"
+ android:background="@drawable/filtershow_grad_button"
+ android:scaleType="centerInside"
+ android:visibility="visible"
+ android:textOff="@string/editor_grad_new"
+ android:textOn="@string/editor_grad_new" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtericonbutton.xml b/res/layout/filtericonbutton.xml
deleted file mode 100644
index 8fc98e3..0000000
--- a/res/layout/filtericonbutton.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?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.
--->
-<com.android.gallery3d.filtershow.ui.FilterIconButton
- style="@style/FilterIconButton" />
diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml
index f5684ff..79c315b 100644
--- a/res/layout/filtershow_activity.xml
+++ b/res/layout/filtershow_activity.xml
@@ -26,25 +26,51 @@
android:layout_height="match_parent"
android:orientation="vertical">
- <LinearLayout
- android:layout_weight="1"
+ <FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal">
+ android:layout_weight="1">
- <FrameLayout
- android:id="@+id/editorContainer"
+ <ProgressBar
+ android:id="@+id/loading"
+ style="@android:style/Widget.Holo.ProgressBar.Large"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:indeterminate="true"
+ android:indeterminateOnly="true"
+ android:background="@null"/>
+
+ <LinearLayout
+ android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"/>
+ android:orientation="horizontal">
- <com.android.gallery3d.filtershow.imageshow.ImageShow
- android:id="@+id/imageShow"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" />
+ <FrameLayout
+ android:id="@+id/central_panel_container"
+ android:layout_gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:visibility="gone"/>
- </LinearLayout>
+ <FrameLayout
+ android:id="@+id/editorContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <com.android.gallery3d.filtershow.imageshow.ImageShow
+ android:id="@+id/imageShow"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+
+ </LinearLayout>
+
+ </FrameLayout>
<com.android.gallery3d.filtershow.CenteredLinearLayout
xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d"
@@ -61,27 +87,14 @@
android:layout_height="0dip"
android:layout_weight="1" />
- <FrameLayout
- android:layout_gravity="bottom"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone">
-
-
- <ProgressBar
- android:id="@+id/loading"
- style="@android:style/Widget.Holo.ProgressBar.Large"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:indeterminate="true"
- android:indeterminateOnly="true"
- android:background="@color/background_screen"/>
-
- </FrameLayout>
-
</com.android.gallery3d.filtershow.CenteredLinearLayout>
</LinearLayout>
+ <com.android.gallery3d.filtershow.category.CategorySelected
+ android:layout_width="@dimen/category_panel_icon_size"
+ android:layout_height="@dimen/category_panel_icon_size"
+ android:id="@+id/categorySelectedIndicator"
+ android:visibility="invisible"/>
+
</FrameLayout>
diff --git a/res/layout/filtershow_brightness.xml b/res/layout/filtershow_brightness.xml
new file mode 100644
index 0000000..88c5d3a
--- /dev/null
+++ b/res/layout/filtershow_brightness.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/top"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="visible" >
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorBrightnessView
+ android:id="@+id/brightnessView"
+ android:layout_width="match_parent"
+ android:layout_height="90dp"
+ android:layout_above="@+id/btnSelect" />
+
+</LinearLayout>
diff --git a/res/layout/filtershow_category_panel.xml b/res/layout/filtershow_category_panel.xml
new file mode 100644
index 0000000..c1b8bbe
--- /dev/null
+++ b/res/layout/filtershow_category_panel.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="48dip"
+ android:background="@color/background_main_toolbar" >
+
+ <ImageButton
+ android:id="@+id/fxButton"
+ android:layout_width="@dimen/thumbnail_size"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@drawable/filtershow_button_background"
+ android:scaleType="centerInside"
+ android:src="@drawable/ic_photoeditor_effects" />
+
+ <ImageButton
+ android:id="@+id/borderButton"
+ android:layout_width="@dimen/thumbnail_size"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@drawable/filtershow_button_background"
+ android:padding="2dip"
+ android:scaleType="centerInside"
+ android:src="@drawable/ic_photoeditor_border" />
+
+ <ImageButton
+ android:id="@+id/geometryButton"
+ android:layout_width="@dimen/thumbnail_size"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@drawable/filtershow_button_background"
+ android:padding="2dip"
+ android:scaleType="centerInside"
+ android:src="@drawable/ic_photoeditor_fix" />
+
+ <ImageButton
+ android:id="@+id/colorsButton"
+ android:layout_width="@dimen/thumbnail_size"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@drawable/filtershow_button_background"
+ android:padding="2dip"
+ android:scaleType="centerInside"
+ android:src="@drawable/ic_photoeditor_color" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_category_panel_new.xml b/res/layout/filtershow_category_panel_new.xml
index 0dce498..8073f68 100644
--- a/res/layout/filtershow_category_panel_new.xml
+++ b/res/layout/filtershow_category_panel_new.xml
@@ -19,23 +19,30 @@
xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d"
android:orientation="horizontal"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:background="@color/filtershow_categoryview_background">
<HorizontalScrollView
- android:layout_width="match_parent"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
- android:scrollbars="none"
- android:background="@color/background_main_toolbar" >
+ android:layout_weight="1"
+ android:scrollbars="none" >
<com.android.gallery3d.filtershow.category.CategoryTrack
android:id="@+id/listItems"
android:layout_width="match_parent"
- android:layout_height="128dip"
- custom:iconSize="84dip"
+ android:layout_height="@dimen/category_panel_height"
+ custom:iconSize="@dimen/category_panel_icon_size"
android:divider="@android:color/transparent"
android:dividerPadding="8dip"
/>
</HorizontalScrollView>
+ <com.android.gallery3d.filtershow.category.IconView
+ android:id="@+id/addButton"
+ android:layout_width="@dimen/category_panel_height"
+ android:layout_height="@dimen/category_panel_height"
+ android:src="@drawable/filtershow_add"/>
+
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_color_picker.xml b/res/layout/filtershow_color_picker.xml
index fc49729..e56bc0d 100644
--- a/res/layout/filtershow_color_picker.xml
+++ b/res/layout/filtershow_color_picker.xml
@@ -14,45 +14,76 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/background_main_toolbar">
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/RelativeLayout1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/default_background"
- tools:context=".ColorPickerActivity" >
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:id="@+id/RelativeLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/background_main_toolbar">
- <com.android.gallery3d.filtershow.colorpicker.ColorRectView
- android:id="@+id/colorRectView"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_marginLeft="10dp"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="10dp"
- android:layout_marginRight="1dp"
- android:layout_above="@+id/colorOpacityView"
- android:layout_toLeftOf="@+id/colorValueView" />
+ <com.android.gallery3d.filtershow.colorpicker.ColorCompareView
+ android:id="@+id/btnSelect"
+ android:layout_width="match_parent"
+ android:layout_height="32dp"
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="20dp"
+ android:layout_marginTop="20dp"
+ android:layout_marginBottom="0dp"
+ />
+ <com.android.gallery3d.filtershow.colorpicker.ColorSVRectView
+ android:id="@+id/colorRectView"
+ android:layout_width="match_parent"
+ android:layout_height="256dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginRight="1dp"/>
- <com.android.gallery3d.filtershow.colorpicker.ColorValueView
- android:id="@+id/colorValueView"
- android:layout_width="90dp"
- android:layout_height="fill_parent"
- android:layout_alignParentRight = "true"
- android:layout_above="@+id/colorOpacityView" />
+ <com.android.gallery3d.filtershow.colorpicker.ColorHueView
+ android:id="@+id/ColorHueView"
+ android:layout_width="match_parent"
+ android:layout_marginTop="0dp"
+ android:layout_height="32dp" />
- <com.android.gallery3d.filtershow.colorpicker.ColorOpacityView
- android:id="@+id/colorOpacityView"
- android:layout_width="match_parent"
- android:layout_height="90dp"
- android:layout_above="@+id/btnSelect" />
+ <com.android.gallery3d.filtershow.colorpicker.ColorOpacityView
+ android:id="@+id/colorOpacityView"
+ android:layout_width="match_parent"
+ android:layout_marginTop="24dp"
+ android:layout_height="32dp" />
- <Button
- android:id="@+id/btnSelect"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/color_pick_select"
- android:layout_alignParentBottom = "true"
- />
+ <LinearLayout android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="4dp">
+ <ImageButton
+ android:id="@+id/cancelColorPick"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_gravity="left|center_vertical"
+ android:background="@android:color/transparent"
+ android:layout_weight=".1"
+ android:gravity="center"
+ android:src="@drawable/ic_menu_cancel_holo_light"
+ android:textSize="18dip"/>
-</RelativeLayout>
\ No newline at end of file
+ <ImageView
+ android:layout_width="2dp"
+ android:layout_height="fill_parent"
+ android:src="@drawable/filtershow_vertical_bar"/>
+ <ImageButton
+ android:id="@+id/applyColorPick"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_gravity="right|center_vertical"
+ android:layout_weight=".1"
+ android:background="@android:color/transparent"
+ android:gravity="center"
+ android:src="@drawable/ic_menu_done_holo_light"
+ android:textSize="18dip"/>
+ </LinearLayout>
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_control_action_slider.xml b/res/layout/filtershow_control_action_slider.xml
index a3ef3ed..34eac1e 100644
--- a/res/layout/filtershow_control_action_slider.xml
+++ b/res/layout/filtershow_control_action_slider.xml
@@ -25,7 +25,7 @@
android:id="@+id/leftActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="left|center_vertical"
+ android:layout_gravity="start|center_vertical"
android:scaleType="centerInside"
android:layout_weight="0"
android:background="@drawable/filtershow_button_background"
@@ -44,7 +44,7 @@
android:id="@+id/rightActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="left|center_vertical"
+ android:layout_gravity="end|center_vertical"
android:scaleType="centerInside"
android:layout_weight="0"
android:background="@drawable/filtershow_button_background"
diff --git a/res/layout/filtershow_control_color_chooser.xml b/res/layout/filtershow_control_color_chooser.xml
new file mode 100644
index 0000000..5bfe460
--- /dev/null
+++ b/res/layout/filtershow_control_color_chooser.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res/com.example.imagefilterharness"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+ <LinearLayout
+ android:id="@+id/listColors"
+ android:layout_weight="5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/draw_color_button01"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button02"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button03"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button04"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ <Button
+ android:id="@+id/draw_color_button05"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:background="@drawable/filtershow_color_picker_circle"
+ android:layout_marginRight="4dp"/>
+
+ </LinearLayout>
+
+ <FrameLayout
+ android:background="@color/background_main_toolbar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
+ <Button
+ android:id="@+id/draw_color_popupbutton"
+ android:layout_width="wrap_content"
+ android:layout_gravity="center"
+ android:layout_height="wrap_content"
+ android:background="@drawable/ic_action_overflow"
+ />
+ </FrameLayout>
+</LinearLayout>
+
diff --git a/res/layout/filtershow_control_style_chooser.xml b/res/layout/filtershow_control_style_chooser.xml
index a5bc984..9588ea2 100644
--- a/res/layout/filtershow_control_style_chooser.xml
+++ b/res/layout/filtershow_control_style_chooser.xml
@@ -18,12 +18,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.example.imagefilterharness"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="32dp"
android:orientation="horizontal" >
<HorizontalScrollView
android:id="@+id/scrollList"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:scrollbars="none" >
<LinearLayout
@@ -32,6 +32,7 @@
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
+
</HorizontalScrollView>
</LinearLayout>
diff --git a/res/layout/filtershow_cp_custom_title.xml b/res/layout/filtershow_cp_custom_title.xml
new file mode 100644
index 0000000..cef8b6c
--- /dev/null
+++ b/res/layout/filtershow_cp_custom_title.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/customTitle"
+ android:text="@string/color_pick_title"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="20dp" >
+</TextView>
\ No newline at end of file
diff --git a/res/layout/filtershow_crop_button.xml b/res/layout/filtershow_crop_button.xml
new file mode 100644
index 0000000..b42d6b6
--- /dev/null
+++ b/res/layout/filtershow_crop_button.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<com.android.gallery3d.filtershow.ui.FramedTextButton
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/cropUtilityButton"
+ android:layout_width="84dip"
+ android:layout_height="84dip"
+ android:layout_gravity="center_vertical|left"
+ android:background="@drawable/filtershow_button_background"
+ android:scaleType="centerInside"
+ android:visibility="gone"
+ android:text="@string/aspectNone_effect" />
\ No newline at end of file
diff --git a/res/layout/filtershow_curves_button.xml b/res/layout/filtershow_curves_button.xml
new file mode 100644
index 0000000..31e8aed
--- /dev/null
+++ b/res/layout/filtershow_curves_button.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<com.android.gallery3d.filtershow.ui.FramedTextButton
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/curvesUtilityButton"
+ android:layout_width="84dip"
+ android:layout_height="84dip"
+ android:layout_gravity="center_vertical|left"
+ android:background="@drawable/filtershow_button_background"
+ android:scaleType="centerInside"
+ android:visibility="gone"
+ android:text="@string/curves_channel_rgb" />
diff --git a/res/layout/filtershow_draw_button.xml b/res/layout/filtershow_draw_button.xml
new file mode 100644
index 0000000..dba8100
--- /dev/null
+++ b/res/layout/filtershow_draw_button.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<com.android.gallery3d.filtershow.ui.FramedTextButton
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawUtilityButton"
+ android:layout_width="84dip"
+ android:layout_height="84dip"
+ android:layout_gravity="center_vertical|left"
+ android:background="@drawable/filtershow_button_background"
+ android:scaleType="centerInside"
+ android:visibility="gone"
+ android:text="@string/draw_style" />
diff --git a/res/layout/filtershow_editor_panel.xml b/res/layout/filtershow_editor_panel.xml
index a6da46a..9953996 100644
--- a/res/layout/filtershow_editor_panel.xml
+++ b/res/layout/filtershow_editor_panel.xml
@@ -22,6 +22,11 @@
android:orientation="vertical"
android:visibility="visible" >
+ <View
+ android:background="@color/toolbar_separation_line"
+ android:layout_height="1dip"
+ android:layout_width="match_parent"/>
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -46,7 +51,7 @@
<LinearLayout
android:layout_width="match_parent"
- android:layout_height="56dip"
+ android:layout_height="48dip"
android:background="@color/background_main_toolbar"
android:orientation="horizontal"
android:baselineAligned="false"
@@ -82,11 +87,11 @@
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="@android:color/transparent"
- android:gravity="center"
android:text="@string/apply_effect"
android:textSize="18dip"
- android:drawableRight="@drawable/filtershow_menu_marker"
- android:textAllCaps="true" />
+ android:drawableEnd="@drawable/filtershow_menu_marker_rtl"
+ android:textAllCaps="true"
+ />
</LinearLayout>
diff --git a/res/layout/filtershow_export_dialog.xml b/res/layout/filtershow_export_dialog.xml
new file mode 100644
index 0000000..4e13f39
--- /dev/null
+++ b/res/layout/filtershow_export_dialog.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:divider="?android:dividerVertical"
+ android:showDividers="middle">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal|center_vertical"
+ android:layout_margin="7dp"
+ android:text="@string/select_output_settings"/>
+
+ <GridLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:alignmentMode="alignBounds"
+ android:useDefaultMargins="true"
+ android:columnOrderPreserved="false"
+ android:columnCount="5">
+
+ <TextView
+ android:text="@string/size"
+ android:layout_marginLeft="8dp"
+ android:layout_gravity="start|center_vertical"/>
+
+ <EditText
+ android:id="@+id/editableWidth"
+ android:layout_gravity="right|center_vertical"
+ android:layout_width="100dp"
+ android:inputType="number"/>
+
+ <TextView
+ android:text="@string/x"
+ android:layout_gravity="center"/>
+
+ <EditText
+ android:id="@+id/editableHeight"
+ android:layout_gravity="left|center_vertical"
+ android:layout_width="100dp"
+ android:inputType="number"/>
+
+ <TextView
+ android:id="@+id/estimadedSize"
+ android:layout_marginRight="8dp"
+ android:layout_gravity="end|center_vertical"/>
+
+ <LinearLayout
+ android:layout_columnSpan="5"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:text="@string/quality"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_margin="8dp" />
+
+ <SeekBar
+ android:id="@+id/qualitySeekBar"
+ android:layout_margin="8dp"
+ android:layout_gravity="center"
+ android:max="100"
+ android:progress="100"
+ android:layout_height="wrap_content"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_columnSpan="3"
+ android:minWidth="250dp" />
+
+ <TextView
+ android:id="@+id/qualityTextView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"
+ android:layout_gravity="end|center_vertical" />
+
+ </LinearLayout>
+
+
+ </GridLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ style="?android:attr/buttonBarStyle">
+
+ <Button
+ android:id="@+id/cancel"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@string/cancel"
+ style="?android:attr/buttonBarButtonStyle" />
+
+ <Button
+ android:id="@+id/done"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@string/done"
+ style="?android:attr/buttonBarButtonStyle"/>
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/res/layout/filtershow_grad_editor.xml b/res/layout/filtershow_grad_editor.xml
new file mode 100644
index 0000000..6c4721e
--- /dev/null
+++ b/res/layout/filtershow_grad_editor.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/gradEditor"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" >
+
+ <com.android.gallery3d.filtershow.imageshow.ImageGrad
+ android:id="@+id/imageShow"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ </FrameLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_history_panel.xml b/res/layout/filtershow_history_panel.xml
new file mode 100644
index 0000000..392e39c
--- /dev/null
+++ b/res/layout/filtershow_history_panel.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/historyPanel"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_weight="1"
+ android:visibility="gone" >
+
+ <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"
+ android:padding="10dip"
+ android:divider="@android:color/transparent"
+ android:dividerHeight="10dip" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/resetOperationsButton"
+ style="@style/FilterShowHistoryButton"
+ android:gravity="center"
+ android:text="@string/reset" />
+
+ <Button
+ android:id="@+id/saveOperationsButton"
+ style="@style/FilterShowHistoryButton"
+ android:text="@string/save"
+ android:visibility="gone" />
+ </LinearLayout>
+</LinearLayout>
diff --git a/res/layout/filtershow_hue.xml b/res/layout/filtershow_hue.xml
new file mode 100644
index 0000000..48d955e
--- /dev/null
+++ b/res/layout/filtershow_hue.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/top"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="visible" >
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorHueView
+ android:id="@+id/hueView"
+ android:layout_width="match_parent"
+ android:layout_height="90dp"
+ android:layout_above="@+id/btnSelect" />
+
+</LinearLayout>
diff --git a/res/layout/filtershow_info_panel.xml b/res/layout/filtershow_info_panel.xml
new file mode 100644
index 0000000..43878b6
--- /dev/null
+++ b/res/layout/filtershow_info_panel.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:minWidth="340dp"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:background="@color/background_main_toolbar"
+ android:padding="16dp">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ >
+
+ <TextView
+ android:id="@+id/imageName"
+ style="?android:textAppearanceSmall"
+ android:textStyle="bold"
+ android:textColor="#80ffffff"
+ android:layout_gravity="start"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="start"/>
+
+ <TextView
+ android:id="@+id/imageSize"
+ style="?android:textAppearanceSmall"
+ android:textAllCaps="true"
+ android:textColor="#80ffffff"
+ android:textStyle="bold"
+ android:layout_gravity="end"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="end"/>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ >
+
+ <ImageView
+ android:id="@+id/imageThumbnail"
+ android:layout_weight="0.3"
+ android:layout_width="0dp"
+ android:layout_height="196dp"
+ android:scaleType="centerCrop"
+ android:layout_marginRight="16dp"
+ android:background="@null"
+
+ />
+
+ <com.android.gallery3d.filtershow.info.HistogramView
+ android:id="@+id/histogramView"
+ android:layout_weight="0.7"
+ android:layout_width="0dp"
+ android:layout_height="196dp"
+ android:layout_margin="0dp"/>
+ </LinearLayout>
+
+ <TextView
+ style="?android:textAppearanceLarge"
+ android:id="@+id/exifLabel"
+ android:textStyle="bold"
+ android:textColor="#fff"
+ android:layout_marginTop="16dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="start"
+ android:text="@string/filtershow_show_info_panel_exif"/>
+
+ <TextView
+ android:id="@+id/exifData"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ android:layout_gravity="start"
+ />
+ </LinearLayout>
+ </ScrollView>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_main_panel.xml b/res/layout/filtershow_main_panel.xml
index 53691d3..d3400fa 100644
--- a/res/layout/filtershow_main_panel.xml
+++ b/res/layout/filtershow_main_panel.xml
@@ -32,7 +32,7 @@
android:layout_weight="1" />
<FrameLayout android:id="@+id/category_panel_container"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:visibility="visible"
android:layout_height="0dip"
android:layout_gravity="center"
diff --git a/res/layout/filtershow_opacity.xml b/res/layout/filtershow_opacity.xml
new file mode 100644
index 0000000..8bdc429
--- /dev/null
+++ b/res/layout/filtershow_opacity.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/top"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="visible" >
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorOpacityView
+ android:id="@+id/opacityView"
+ android:layout_width="match_parent"
+ android:layout_height="90dp"
+ android:layout_above="@+id/btnSelect" />
+
+</LinearLayout>
diff --git a/res/layout/filtershow_presets_management_dialog.xml b/res/layout/filtershow_presets_management_dialog.xml
new file mode 100644
index 0000000..68754e2
--- /dev/null
+++ b/res/layout/filtershow_presets_management_dialog.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:divider="?android:dividerVertical"
+ android:showDividers="middle">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_margin="8dip">
+
+ <TextView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/filtershow_preset_name"
+ android:layout_margin="8dp"
+ />
+
+ <EditText
+ android:id="@+id/editView"
+ android:gravity="center"
+ android:textSize="18sp"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:focusable="true"
+ android:imeOptions="actionDone"
+ android:singleLine="true"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ style="?android:attr/buttonBarStyle">
+
+ <Button
+ android:id="@+id/cancel"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@string/cancel"
+ style="?android:attr/buttonBarButtonStyle" />
+
+ <Button
+ android:id="@+id/ok"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@string/ok"
+ style="?android:attr/buttonBarButtonStyle"/>
+
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_presets_management_row.xml b/res/layout/filtershow_presets_management_row.xml
new file mode 100644
index 0000000..bd3e479
--- /dev/null
+++ b/res/layout/filtershow_presets_management_row.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_weight=".1"
+ android:layout_width="80dip"
+ android:layout_height="80dip"
+ android:scaleType="fitCenter"
+ android:layout_gravity="left|center_vertical"/>
+
+ <EditText
+ android:id="@+id/editView"
+ android:gravity="center"
+ android:textSize="18sp"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:focusable="true"
+ android:imeOptions="actionDone"
+ android:singleLine="true"/>
+
+ <ImageButton
+ android:id="@+id/deleteUserPreset"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="right|center_vertical"
+ android:background="@android:color/transparent"
+ android:layout_weight=".1"
+ android:gravity="center"
+ android:src="@drawable/ic_menu_trash_holo_light"
+ android:visibility="gone"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_saturation.xml b/res/layout/filtershow_saturation.xml
new file mode 100644
index 0000000..79a00c1
--- /dev/null
+++ b/res/layout/filtershow_saturation.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/top"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="visible" >
+
+ <com.android.gallery3d.filtershow.colorpicker.ColorSaturationView
+ android:id="@+id/saturationView"
+ android:layout_width="match_parent"
+ android:layout_height="90dp"
+ android:layout_above="@+id/btnSelect" />
+
+</LinearLayout>
diff --git a/res/layout/filtershow_seekbar.xml b/res/layout/filtershow_seekbar.xml
index 6463ca8..54a874d 100644
--- a/res/layout/filtershow_seekbar.xml
+++ b/res/layout/filtershow_seekbar.xml
@@ -26,6 +26,7 @@
android:id="@+id/primarySeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/FilterShowSlider" />
+ style="@style/FilterShowSlider"
+ android:visibility="gone" />
</LinearLayout>
diff --git a/res/layout/filtershow_splashscreen.xml b/res/layout/filtershow_splashscreen.xml
new file mode 100644
index 0000000..06958ca
--- /dev/null
+++ b/res/layout/filtershow_splashscreen.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical"
+ android:gravity="center_horizontal|center_vertical"
+ android:padding="10dip">
+
+<ProgressBar android:id="@+id/progress_bar"
+ android:layout_alignParentRight="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:visibility="visible"
+ android:paddingBottom="144dp" />
+
+</LinearLayout>
diff --git a/res/layout/filtershow_state_panel.xml b/res/layout/filtershow_state_panel.xml
new file mode 100644
index 0000000..1f9f970
--- /dev/null
+++ b/res/layout/filtershow_state_panel.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/imageStatePanel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_weight="1"
+ android:visibility="visible" >
+
+ <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/imageState"
+ android:textColor="@android:color/white"
+ android:textSize="24sp"
+ android:textStyle="bold" />
+
+ <ListView
+ android:id="@+id/imageStateList"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" >
+ </ListView>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/filtershow_state_panel_new.xml b/res/layout/filtershow_state_panel_new.xml
index d2d59ab..b199695 100644
--- a/res/layout/filtershow_state_panel_new.xml
+++ b/res/layout/filtershow_state_panel_new.xml
@@ -12,9 +12,14 @@
android:layout_height="1dip"
android:layout_width="match_parent"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
<HorizontalScrollView
- android:layout_width="match_parent"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
+ android:layout_weight="1"
android:scrollbars="none">
<com.android.gallery3d.filtershow.state.StatePanelTrack
@@ -24,9 +29,24 @@
android:layout_height="48dip"
custom:elemEndSize="128dip"
custom:elemSize="128dip"
- android:layout_margin="8dip"
+ android:layout_margin="0dip"
android:animateLayoutChanges="true" />
</HorizontalScrollView>
+ <ImageButton
+ android:id="@+id/toggleVersionsPanel"
+ android:layout_width="wrap_content"
+ android:layout_height="48dip"
+ android:src="@drawable/filtershow_versions_compare"
+ style="?android:attr/borderlessButtonStyle"
+ android:layout_gravity="center"/>
+
+ </LinearLayout>
+
+ <View
+ android:background="@color/toolbar_separation_line"
+ android:layout_height="1dip"
+ android:layout_width="match_parent"/>
+
</LinearLayout>
diff --git a/res/layout/panorama_module.xml b/res/layout/panorama_module.xml
deleted file mode 100644
index 9ecbd07..0000000
--- a/res/layout/panorama_module.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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.
--->
-
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/pano_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <include layout="@layout/pano_module_capture" />
- <include layout="@layout/pano_review" />
-</merge>
diff --git a/res/layout/photo_module.xml b/res/layout/photo_module.xml
index abf094e..390863a 100644
--- a/res/layout/photo_module.xml
+++ b/res/layout/photo_module.xml
@@ -24,8 +24,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
- <include layout="@layout/count_down_to_capture"/>
-
+ <TextureView
+ android:id="@+id/preview_content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ <View
+ android:id="@+id/flash_overlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/white"
+ android:visibility="gone"
+ android:alpha="0" />
<ViewStub android:id="@+id/face_view_stub"
android:inflatedId="@+id/face_view"
android:layout="@layout/face_view"
@@ -36,4 +45,7 @@
android:id="@+id/render_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+ <include layout="@layout/camera_controls"
+ android:layout_gravity="center"
+ style="@style/CameraControls"/>
</merge>
\ No newline at end of file
diff --git a/res/layout/secure_album_placeholder.xml b/res/layout/secure_album_placeholder.xml
new file mode 100644
index 0000000..8d9a229
--- /dev/null
+++ b/res/layout/secure_album_placeholder.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:background="@color/photo_placeholder"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:scaleType="center"
+ android:src="@drawable/placeholder_locked"
+/>
diff --git a/res/layout/undo_bar.xml b/res/layout/undo_bar.xml
new file mode 100644
index 0000000..33ec91d
--- /dev/null
+++ b/res/layout/undo_bar.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<!-- This layout is shared by phone and tablet in portrait or landscape orientation. -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ style="@style/UndoBar">
+ <TextView android:text="@string/deleted"
+ style="@style/UndoBarTextAppearance"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="left|center_vertical" />
+ <View style="@style/UndoBarSeparator" />
+ <TextView android:id="@+id/undo_button"
+ style="@style/UndoButton"
+ android:text="@string/undo"
+ android:drawableLeft="@drawable/ic_menu_revert_holo_dark"/>
+</LinearLayout>
diff --git a/res/layout/video_module.xml b/res/layout/video_module.xml
index 790f3eb..2df1adc 100644
--- a/res/layout/video_module.xml
+++ b/res/layout/video_module.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- 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.
@@ -15,43 +15,46 @@
-->
<!-- This layout is shared by phone and tablet in landscape orientation. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/camera_app_root"
android:layout_height="match_parent"
android:layout_width="match_parent">
- <com.android.camera.PreviewFrameLayout android:id="@+id/frame"
+ <TextureView
+ android:id="@+id/preview_content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ <View
+ android:id="@+id/flash_overlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/white"
+ android:visibility="gone"
+ android:alpha="0" />
+ <FrameLayout android:id="@+id/preview_border"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone"
+ android:background="@drawable/ic_snapshot_border" />
+ <com.android.camera.ui.RenderOverlay
+ android:id="@+id/render_overlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ <com.android.camera.ui.RotateLayout android:id="@+id/recording_time_rect"
+ style="@style/ViewfinderLabelLayout">
+ <include layout="@layout/viewfinder_labels_video" android:id="@+id/labels" />
+ </com.android.camera.ui.RotateLayout>
+ <ImageView android:id="@+id/review_image"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:layout_gravity="center">
- <com.android.camera.ui.PreviewSurfaceView
- android:id="@+id/preview_surface_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone"/>
- <FrameLayout android:id="@+id/preview_border"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone"
- android:background="@drawable/ic_snapshot_border" />
- <com.android.camera.ui.RenderOverlay
- android:id="@+id/render_overlay"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- <com.android.camera.ui.RotateLayout android:id="@+id/recording_time_rect"
- style="@style/ViewfinderLabelLayout">
- <include layout="@layout/viewfinder_labels_video" android:id="@+id/labels" />
- </com.android.camera.ui.RotateLayout>
- <ImageView android:id="@+id/review_image"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:visibility="gone"
- android:background="@android:color/black"/>
- <ImageView
- android:id="@+id/btn_play"
- style="@style/ReviewControlIcon"
- android:layout_centerInParent="true"
- android:src="@drawable/ic_gallery_play_big"
- android:visibility="gone"
- android:onClick="onReviewPlayClicked"/>
- </com.android.camera.PreviewFrameLayout>
+ android:visibility="gone"
+ android:background="@android:color/black"/>
+ <ImageView
+ android:id="@+id/btn_play"
+ style="@style/ReviewControlIcon"
+ android:layout_centerInParent="true"
+ android:src="@drawable/ic_gallery_play_big"
+ android:visibility="gone"
+ android:onClick="onReviewPlayClicked"/>
+ <include layout="@layout/camera_controls"
+ android:layout_gravity="center"
+ style="@style/CameraControls"/>
</merge>
diff --git a/res/menu/filtershow_activity_menu.xml b/res/menu/filtershow_activity_menu.xml
index 0a8f4e9..bb0b094 100644
--- a/res/menu/filtershow_activity_menu.xml
+++ b/res/menu/filtershow_activity_menu.xml
@@ -20,8 +20,28 @@
android:id="@+id/resetHistoryButton"
android:title="@string/reset"/>
<item
+ android:id="@+id/showInfoPanel"
+ android:showAsAction="never"
+ android:visible="true"
+ android:title="@string/filtershow_show_info_panel" />
+ <item
android:id="@+id/showImageStateButton"
android:showAsAction="never"
android:visible="true"
android:title="@string/show_imagestate_panel" />
+ <item
+ android:id="@+id/manageUserPresets"
+ android:showAsAction="never"
+ android:visible="false"
+ android:title="@string/filtershow_manage_preset" />
+ <item
+ android:id="@+id/exportFlattenButton"
+ android:showAsAction="never"
+ android:visible="true"
+ android:title="@string/export_image" />
+ <item
+ android:id="@+id/printButton"
+ android:showAsAction="never"
+ android:visible="true"
+ android:title="@string/print_image"/>
</menu>
diff --git a/res/menu/filtershow_menu_chan_sat.xml b/res/menu/filtershow_menu_chan_sat.xml
new file mode 100644
index 0000000..eae559d
--- /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/menu/filtershow_menu_color_border.xml b/res/menu/filtershow_menu_color_border.xml
new file mode 100644
index 0000000..7d27504
--- /dev/null
+++ b/res/menu/filtershow_menu_color_border.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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/curves_popupmenu">
+ <item
+ android:id="@+id/color_border_menu_corner_size"
+ android:title="@string/color_border_corner_size"/>
+ <item
+ android:id="@+id/color_border_menu_size"
+ android:title="@string/color_border_size"/>
+ <item
+ android:id="@+id/color_border_menu_color"
+ android:title="@string/color_border_color"/>
+ <item
+ android:id="@+id/color_border_menu_clear"
+ android:title="@string/color_border_clear"/>
+ </group>
+
+</menu>
\ No newline at end of file
diff --git a/res/menu/filtershow_menu_draw.xml b/res/menu/filtershow_menu_draw.xml
index 2960c1f..205111d 100644
--- a/res/menu/filtershow_menu_draw.xml
+++ b/res/menu/filtershow_menu_draw.xml
@@ -15,27 +15,21 @@
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <group android:id="@+id/curves_popupmenu" >
+ <group android:id="@+id/curves_popupmenu">
<item
- android:id="@+id/draw_menu_style_line"
- android:title="@string/draw_style_line" />
- <item
- android:id="@+id/draw_menu_style_brush_marker"
- android:title="@string/draw_style_brush_marker"/>
- <item
- android:id="@+id/draw_menu_style_brush_spatter"
- android:title="@string/draw_style_brush_spatter"/>
- <item
- android:id="@+id/draw_menu_size"
- android:title="@string/draw_size" />
+ android:id="@+id/draw_menu_style"
+ android:title="@string/draw_style"/>
<item
- android:id="@+id/draw_menu_color"
- android:title="@string/draw_color"/>
+ android:id="@+id/draw_menu_size"
+ android:title="@string/draw_size"/>
<item
- android:id="@+id/draw_menu_clear"
- android:title="@string/draw_clear"/>
+ android:id="@+id/draw_menu_color"
+ android:title="@string/draw_color"/>
+ <item
+ android:id="@+id/draw_menu_clear"
+ android:title="@string/draw_clear"/>
</group>
</menu>
\ No newline at end of file
diff --git a/res/menu/filtershow_menu_grad.xml b/res/menu/filtershow_menu_grad.xml
new file mode 100644
index 0000000..1dee7e0
--- /dev/null
+++ b/res/menu/filtershow_menu_grad.xml
@@ -0,0 +1,27 @@
+<!--
+ 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" >
+ <item
+ android:id="@+id/editor_grad_brightness"
+ android:title="@string/editor_grad_brightness"/>
+ <item
+ android:id="@+id/editor_grad_saturation"
+ android:title="@string/editor_grad_saturation"/>
+ <item
+ android:id="@+id/editor_grad_contrast"
+ android:title="@string/editor_grad_contrast"/>
+</menu>
diff --git a/res/menu/filtershow_menu_vignette.xml b/res/menu/filtershow_menu_vignette.xml
new file mode 100644
index 0000000..2b32424
--- /dev/null
+++ b/res/menu/filtershow_menu_vignette.xml
@@ -0,0 +1,38 @@
+<!--
+ 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_vignette_main"
+ android:title="@string/vignette_main"/>
+ <item
+ android:id="@+id/editor_vignette_falloff"
+ android:title="@string/vignette_falloff"/>
+ <item
+ android:id="@+id/editor_vignette_contrast"
+ android:title="@string/vignette_contrast"/>
+ <item
+ android:id="@+id/editor_vignette_saturation"
+ android:title="@string/vignette_saturation"/>
+ <item
+ android:id="@+id/editor_vignette_exposure"
+ android:title="@string/vignette_exposure"
+ android:visible= "false"/>
+ </group>
+
+</menu>
\ No newline at end of file
diff --git a/res/menu/photo.xml b/res/menu/photo.xml
index 48742d1..bcd452e 100644
--- a/res/menu/photo.xml
+++ b/res/menu/photo.xml
@@ -75,4 +75,7 @@
<item android:id="@+id/action_show_on_map"
android:title="@string/show_on_map"
android:showAsAction="never" />
+ <item android:id="@+id/print"
+ android:title="@string/print_image"
+ android:showAsAction="never" />
</menu>
diff --git a/res/mipmap-hdpi/ic_launcher_camera.png b/res/mipmap-hdpi/ic_launcher_camera.png
index 7b9d090..c1ebe77 100644
--- a/res/mipmap-hdpi/ic_launcher_camera.png
+++ b/res/mipmap-hdpi/ic_launcher_camera.png
Binary files differ
diff --git a/res/mipmap-hdpi/ic_launcher_video_camera.png b/res/mipmap-hdpi/ic_launcher_video_camera.png
deleted file mode 100644
index d242657..0000000
--- a/res/mipmap-hdpi/ic_launcher_video_camera.png
+++ /dev/null
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_camera.png b/res/mipmap-mdpi/ic_launcher_camera.png
index 9d24f4e..20f1499 100644
--- a/res/mipmap-mdpi/ic_launcher_camera.png
+++ b/res/mipmap-mdpi/ic_launcher_camera.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_video_camera.png b/res/mipmap-mdpi/ic_launcher_video_camera.png
deleted file mode 100644
index 19f0e64..0000000
--- a/res/mipmap-mdpi/ic_launcher_video_camera.png
+++ /dev/null
Binary files differ
diff --git a/res/mipmap-xhdpi/ic_launcher_camera.png b/res/mipmap-xhdpi/ic_launcher_camera.png
index 824161a..972ee40 100644
--- a/res/mipmap-xhdpi/ic_launcher_camera.png
+++ b/res/mipmap-xhdpi/ic_launcher_camera.png
Binary files differ
diff --git a/res/mipmap-xxhdpi/ic_launcher_camera.png b/res/mipmap-xxhdpi/ic_launcher_camera.png
index 1e09a6b..4cc58ee 100644
--- a/res/mipmap-xxhdpi/ic_launcher_camera.png
+++ b/res/mipmap-xxhdpi/ic_launcher_camera.png
Binary files differ
diff --git a/res/mipmap-xxxhdpi/ic_launcher_camera.png b/res/mipmap-xxxhdpi/ic_launcher_camera.png
new file mode 100644
index 0000000..00de613
--- /dev/null
+++ b/res/mipmap-xxxhdpi/ic_launcher_camera.png
Binary files differ
diff --git a/res/values-af/filtershow_strings.xml b/res/values-af/filtershow_strings.xml
index 2092e10..65aa0d2 100644
--- a/res/values-af/filtershow_strings.xml
+++ b/res/values-af/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Stel muurpapier"</string>
- <string name="download_failure" msgid="5923323939788582895">"Kon nie foto aflaai nie. Netwerk nie beskikbaar nie."</string>
<string name="original" msgid="3524493791230430897">"Oorspronklike"</string>
<string name="borders" msgid="2067345080568684614">"Grense"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Ontdoen"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Herdoen"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Wys toegepaste effekte"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Versteek toegepaste effekte"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Wys geskiedenis"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Versteek geskiedenis"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Wys prenttoestand"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Versteek prenttoestand"</string>
<string name="menu_settings" msgid="6428291655769260831">"Instellings"</string>
<string name="unsaved" msgid="8704442449002374375">"Daar is ongestoorde veranderinge aan hierdie prent."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Wil jy stoor voor jy uitgaan?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Kies kleur"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Kies grootte"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Oorspronklike"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultaat"</string>
</resources>
diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml
index 4a9d63c..bf72c67 100644
--- a/res/values-af/strings.xml
+++ b/res/values-af/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Draai na regs"</string>
<string name="no_such_item" msgid="5315144556325243400">"Kon nie die item vind nie."</string>
<string name="edit" msgid="1502273844748580847">"Redigeer"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Eenvoudige redigeer"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Verwerk kasversoeke"</string>
<string name="caching_label" msgid="4521059045896269095">"Kas tans..."</string>
<string name="crop_action" msgid="3427470284074377001">"Snoei"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Terug"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Voorkant"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Stoor ligging"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LIGGING"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Aftel-tydhouer"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 sekonde"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kamera-instellings"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Videokamera-instellings"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Prentgrootte"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M pixels"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M pixels"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M pixels"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 M pieksels"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M pixels"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M pixels"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 M pieksels (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3M pixels"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M pixels"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Outo"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Oneindig"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"OUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"ONEINDIG"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Flits-modus"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"FLITS-MODUS"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Outo"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Aan"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Af"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"OUTO-FLITS"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLITS AAN"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLITS AF"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Witbalans"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"WITBALANS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Outo"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Gloeiend"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Daglig"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluoresserend"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Bewolk"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"OUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"GLOEIEND"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DAGLIG"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESSEREND"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"BEWOLK"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Toneel-modus"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Outo"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nag"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Sonsondergang"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Partytjie"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"GEEN"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"HANDELING"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NAG"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SONSONDERGANG"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"PARTYTJIE"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"AFTEL-TYDHOUER"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TYDHOUER AF"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKONDE"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKONDES"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKONDES"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKONDES"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Kan nie in toneelmodus gekies word nie."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Beligting"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"BELIGTING"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"VOORSTE KAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"AGTERSTE KAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Jou USB-berging se stoorspasie raak min. Verander die gehalte-instelling of vee \'n paar prente of ander lêers uit."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Jou SD-kaart raak vol. Verander die gehalte-instelling of vee \'n paar prente of ander lêers uit."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Kanselleer hersiening"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Voltooi hersiening"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Hersien neem weer"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Speel video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Laat video wag"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Herlaai video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Video-speler se tydbalk"</string>
<string name="capital_on" msgid="5491353494964003567">"AAN"</string>
<string name="capital_off" msgid="7231052688467970897">"AF"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Af"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Soek"</string>
<string name="tab_photos" msgid="9110813680630313419">"Foto\'s"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albums"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"NOG OPSIES"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"INSTELLINGS"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d foto\'s"</item>
diff --git a/res/values-am/filtershow_strings.xml b/res/values-am/filtershow_strings.xml
index 04fb893..f644d1f 100644
--- a/res/values-am/filtershow_strings.xml
+++ b/res/values-am/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"ልጥፍ በማዘጋጀት ላይ"</string>
- <string name="download_failure" msgid="5923323939788582895">"ፎቶን ማውረድ አልተቻለም። አውታረ መረብ አይገኝም።"</string>
<string name="original" msgid="3524493791230430897">"የመጀመሪያው"</string>
<string name="borders" msgid="2067345080568684614">"ድንበሮች"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"ቀልብስ"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"ድገም"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"የተተገበሩ ተጽዕኖዎችን አሳይ"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"የተተገበሩ ተጽዕኖዎችን ደብቅ"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"ታሪክ አሳይ"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"ታሪክ ደብቅ"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"የምስል ሁኔታን አሳይ"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"የምስል ሁኔታን ደብቅ"</string>
<string name="menu_settings" msgid="6428291655769260831">"ቅንብሮች"</string>
<string name="unsaved" msgid="8704442449002374375">"በዚህ ምስል ላይ"</string>
<string name="save_before_exit" msgid="2680660633675916712">"ከመውጣትዎ በፊት ማስቀመጥ ይፈልጋሉ?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"ቀለም ይምረጡ"</string>
<string name="draw_size_title" msgid="3121649039610273977">"መጠን ይምረጡ"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"እሺ"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"የመጀመሪያው"</string>
- <string name="state_panel_result" msgid="318640531123298676">"ውጤት"</string>
</resources>
diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml
index 1d9fab6..68f44c3 100644
--- a/res/values-am/strings.xml
+++ b/res/values-am/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"ወደ ቀኝ አሽከርክር"</string>
<string name="no_such_item" msgid="5315144556325243400">"ሊገኙ አልተቻለም::"</string>
<string name="edit" msgid="1502273844748580847">"አርትዕ"</string>
- <string name="simple_edit" msgid="2792835918347498211">"ቀላል አርትዖት"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"መሸጎጫ ጥየቃዎች ሂደት"</string>
<string name="caching_label" msgid="4521059045896269095">"በመሸጎጥ ላይ..."</string>
<string name="crop_action" msgid="3427470284074377001">"ከርክም"</string>
@@ -116,7 +115,7 @@
<string name="no_albums_alert" msgid="4111744447491690896">"ምንም አልበሞች አልተገኙም::"</string>
<string name="empty_album" msgid="4542880442593595494">"O ምስሎች/ ቪዲዮዎች ማግኘት ይቻላል::"</string>
<string name="picasa_posts" msgid="1497721615718760613">"ልጥፎች"</string>
- <string name="make_available_offline" msgid="5157950985488297112">"ከመስመር ውጪ እንዲገኝ አድርግ"</string>
+ <string name="make_available_offline" msgid="5157950985488297112">"ከመስመር ውጪ እንዲገኝአድርግ"</string>
<string name="sync_picasa_albums" msgid="8522572542111169872">"አድስ"</string>
<string name="done" msgid="217672440064436595">"ተከናውኗል"</string>
<string name="sequence_in_set" msgid="7235465319919457488">"%1$d ከ%2$d አይነቶች:"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"ተመለስ"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"የፊት"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"ሥፍራ"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"አካባቢ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"ሰዓት ቆጣሪ"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 ሰከንድ"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"የካሜራ ቅንብሮች"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"የካምኮርድ ቅንብሮች"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"የምስል መጠን"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13ሚ ፒክሰሎች"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 ሜጋፒክሰል"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 ሜጋ ፒክሴል"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4ሚ ፒክሰሎች"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 ሜጋ ፒክሴል"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 ሜጋ ፒክሴል"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2ሚ ፒክሰሎች (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3 ሜጋ ፒክሴል"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 ሜጋ ፒክሴል"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"ራስ"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"ወሰን የሌለው"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"ማክሮ"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"ራስ-ሰር"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"የትየሌለ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"ማክሮ"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"የብልጭታ ሁነታ"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"የብልጭታ ሁነታ"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"ራስ"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"በ"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"ውጪ"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"ራስ-ብልጭታ"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"ብልጭታ በርቷል"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"ብልጭታ ጠፍቷል"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"ዝግጁ ምስል"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"የነጭ ምጥጥን"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"ራስ"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"ያለፈበት"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"የቀን ብርሃን"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"ፍሎረሰንት"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"ደመናማ"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"ራስ-ሰር"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"የሙቀት ብርሃን"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"የቀን ብርሃን"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ፍሎረሰንት"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ደመናማ"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"የእይታ ሁነታ"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"ራስ"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"ማታ"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"ፀሀይ ስትጠልቅ"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"ፓርቲ"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"ምንም"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"እርምጃ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"ማታ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ፀሀይ ስትጠልቅ"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ድግስ"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ሰዓት ቆጣሪ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ሰዓት ቆጣሪ ጠፍቷል"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 ሰከንድ"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 ሰከንዶች"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 ሰከንዶች"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 ሰከንዶች"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">" በትዕይንት ሁኔታ መመረጥ የሚችል አይደለም።"</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"የተጋለጠ"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ተጋላጭነት"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"ኤች ዲ አር"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"የፊት ካሜራ"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"የኋላ ካሜራ"</string>
<string name="dialog_ok" msgid="6263301364153382152">"እሺ"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"የUSB ማከማቻዎቦታ እየሞላበት ነው።የጥራት ቅንብር ይለውጡ ወይም አንዳንድ ምስሎችን ወይም ሌላ ፋይሎች ይሰርዙ።"</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"የSD ካርድዎ ቦታ እያለቀበት ነው። የጥራት ቅንብሩን ይልወጡ ወይም አንዳንድ ምስሎችንወይም ሌሎች ፋይሎችን ይሰርዙ።"</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"ግምገማ፣ ሰርዝ"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"ግምገማ፣ ተጠናቅቋል"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"ዳግም የተነሳውን ይገምግሙ"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"ቪዲዮ አጫውት"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"ቪዲዮ ለአፍታ አቁም"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"ቪዲዮ ዳግም ጫን"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"የቪዲዮ አጫዋች ሰዓት አሞሌ"</string>
<string name="capital_on" msgid="5491353494964003567">"በርቷል"</string>
<string name="capital_off" msgid="7231052688467970897">"ጠፍቷል"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"ጠፍቷል"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"ፍለጋ"</string>
<string name="tab_photos" msgid="9110813680630313419">"ፎቶዎች"</string>
<string name="tab_albums" msgid="8079449907770685691">"አልበሞች"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ተጨማሪ አማራጮች"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"ቅንብሮች"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d ፎቶ"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d ፎቶዎች"</item>
diff --git a/res/values-ar/filtershow_strings.xml b/res/values-ar/filtershow_strings.xml
index 926136e..7ccf388 100644
--- a/res/values-ar/filtershow_strings.xml
+++ b/res/values-ar/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"جارٍ تعيين الخلفية"</string>
- <string name="download_failure" msgid="5923323939788582895">"تعذر تنزيل الصورة. الشبكة غير متاحة."</string>
<string name="original" msgid="3524493791230430897">"أصلية"</string>
<string name="borders" msgid="2067345080568684614">"حدود"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"تراجع"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"إعادة"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"إظهار التأثيرات المطبقة"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"إخفاء التأثيرات المطبقة"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"عرض السجل"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"إخفاء السجل"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"عرض حالة الصورة"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"إخفاء حالة الصورة"</string>
<string name="menu_settings" msgid="6428291655769260831">"إعدادات"</string>
<string name="unsaved" msgid="8704442449002374375">"هناك تغييرات في هذه الصورة لم يتم حفظها."</string>
<string name="save_before_exit" msgid="2680660633675916712">"هل تريد الحفظ قبل الخروج؟"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"تحديد اللون"</string>
<string name="draw_size_title" msgid="3121649039610273977">"تحديد الحجم"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"موافق"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"أصلي"</string>
- <string name="state_panel_result" msgid="318640531123298676">"النتيجة"</string>
</resources>
diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml
index e39df49..d4f6d6b 100644
--- a/res/values-ar/strings.xml
+++ b/res/values-ar/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"تدوير لليمين"</string>
<string name="no_such_item" msgid="5315144556325243400">"تعذر العثور على العنصر."</string>
<string name="edit" msgid="1502273844748580847">"تعديل"</string>
- <string name="simple_edit" msgid="2792835918347498211">"تعديل بسيط"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"معالجة طلبات التخزين المؤقت"</string>
<string name="caching_label" msgid="4521059045896269095">"تخزين مؤقت..."</string>
<string name="crop_action" msgid="3427470284074377001">"اقتصاص"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"رجوع"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"الأمام"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"تخزين الموقع"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"الموقع"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"مؤقت العد التنازلي"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"ثانية واحدة"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"إعدادات الكاميرا"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"إعدادات كاميرا الفيديو"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"حجم الصورة"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 ميغابكسل"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 ميغا بكسل"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 ميغا بكسل"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 ميغا بكسل"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 ميغا بكسل"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 ميغا بكسل"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 ميغا بكسل (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3 ميغا بكسل"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 ميغا بكسل"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"تلقائي"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"بلا نهاية"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"ماكرو"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"تلقائي"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"بلا نهاية"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"ماكرو"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"وضع الفلاش"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"وضع الفلاش"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"تلقائي"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"تشغيل"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"إيقاف"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"الفلاش التلقائي"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"تشغيل الفلاش"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"إيقاف الفلاش"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"موازنة اللون الأبيض"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"توازن الأبيض"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"تلقائي"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"براق"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"نهاري"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"فلورسنت"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"غائم"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"تلقائي"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"براق"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"نهاري"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"فلورسنت"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"غائم"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"وضع المشهد"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"تلقائي"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"النطاق الديناميكي العالي"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"ليلي"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"الغروب"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"مجموعة"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"لا شيء"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"حركة"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"ليلاً"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"الغروب"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"حفلة"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"موقّت العد التنازلي"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"إيقاف الموقّت"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"ثانية واحدة"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 ثوانٍ"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 ثوانٍ"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 ثانية"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"لا يمكن تحديده في وضع المشهد."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"التعرض"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"التعرض للضوء"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"نطاق عالي الديناميكية"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"الكاميرا الأمامية"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"الكاميرا الخلفية"</string>
<string name="dialog_ok" msgid="6263301364153382152">"موافق"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"مساحة وحدة تخزين USB منخفضة. غيّر إعداد الجودة أو احذف بعض الصور أو الملفات الأخرى."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"مساحة بطاقة SD منخفضة. غيّر إعداد الجودة أو احذف بعض الصور أو الملفات الأخرى."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"مراجعة الإلغاء"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"تمت المراجعة"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"مراجعة: إعادة الالتقاط"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"تشغيل الفيديو"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"إيقاف الفيديو مؤقتًا"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"إعادة تحميل الفيديو"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"شريط الوقت لمشغّل الفيديو"</string>
<string name="capital_on" msgid="5491353494964003567">"تشغيل"</string>
<string name="capital_off" msgid="7231052688467970897">"إيقاف"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"تم الإيقاف"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"البحث"</string>
<string name="tab_photos" msgid="9110813680630313419">"الصور"</string>
<string name="tab_albums" msgid="8079449907770685691">"الألبومات"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"خيارات إضافية"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"إعدادات"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d صورة"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d من الصور"</item>
diff --git a/res/values-be/filtershow_strings.xml b/res/values-be/filtershow_strings.xml
index 049ba6e..66f4506 100644
--- a/res/values-be/filtershow_strings.xml
+++ b/res/values-be/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Усталёўка шпалер..."</string>
- <string name="download_failure" msgid="5923323939788582895">"Не атрымалася спампаваць фота. Сетка недаступная."</string>
<string name="original" msgid="3524493791230430897">"Арыгiнал"</string>
<string name="borders" msgid="2067345080568684614">"Межы"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Вярнуць"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Паўтарыць"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Паказваць прымененыя эфекты"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Хаваць прымененыя эфекты"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Паказаць гісторыю"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Схаваць гісторыю"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Паказаць статус малюнка"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Схаваць статус малюнка"</string>
<string name="menu_settings" msgid="6428291655769260831">"Налады"</string>
<string name="unsaved" msgid="8704442449002374375">"Існуюць незахаваныя змяненні ў гэтай выяве."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Жадаеце захавацца перад выхадам?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Выберыце колер"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Выберыце памер"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Арыгiнал"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Вынiк"</string>
</resources>
diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml
index 0974d2a..a8670de 100644
--- a/res/values-be/strings.xml
+++ b/res/values-be/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Павярнуць направа"</string>
<string name="no_such_item" msgid="5315144556325243400">"Элемент не знойдзены."</string>
<string name="edit" msgid="1502273844748580847">"Рэдагаваць"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Простае рэдагаванне"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Запыты на кэшаванне працэсу"</string>
<string name="caching_label" msgid="4521059045896269095">"Кэшаванне..."</string>
<string name="crop_action" msgid="3427470284074377001">"Абрэзаць"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Назад"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Перад"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Месцазнаходжанне крамы"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"МЕСЦАЗНАХОДЖАННЕ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Таймер зваротнага адлiку"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 секунда"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Налады камеры"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Налады відэакамеры"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Памер малюнка"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 млн. пікселяў"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 мегапікселяў"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 мегапiкселяў"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 мiльёны пікселяў"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 мегапiкселя"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 мегапiкселя"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 мiльёны пікселяў (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 мегапікселя"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 мегапiксель"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Аўтаматычна"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Бясконцасць"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Макра"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"АЎТАМАТЫЧНАЯ"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"БЯСКОНЦА"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"МАКРА"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Рэжым успышкі"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"РЭЖЫМ УСПЫШКI"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Аўтаматычна"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Уключана"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Адключана"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"АЎТАЎСПЫШКА"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"УСПЫШКА ЎКЛ."</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"УСПЫШ. ВЫКЛ"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Баланс белага"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"БАЛАНС БЕЛАГА"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Аўтаматычна"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Белы напал"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Дзённае святло"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Флюарэсцэнтны"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Пахмурна"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"АЎТАМАТЫЧНАЯ"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"БЕЛЫ НАПАЛ"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"ДЗЁННАЕ СВЯТЛО"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ФЛЮАРЭСЦЭНТНЫ"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ПАХМУРНА"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Рэжым здымкаў"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Аўтаматычна"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Ноч"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Заход"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Вечарына"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"НЯМА"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ДЗЕЯННЕ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"НОЧ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ЗАХОД"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ВЕЧАРЫНА"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ТАЙМЕР ЗВАРОТНАГА АДЛІКУ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ТАЙМЕР АДКЛЮЧАНЫ"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 СЕКУНДА"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 СЕКУНДЫ"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 СЕКУНД"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 СЕКУНД"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Немагчыма выбраць у рэжыме здымкi."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Экспазіцыя"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ЭКСПАЗIЦЫЯ"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ПЯРЭДНЯЯ КАМЕРА"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"ЗАДНЯЯ КАМЕРА"</string>
<string name="dialog_ok" msgid="6263301364153382152">"ОК"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Месца на вашым USB-назапашвальнiку заканчваецца. Змяніце параметры якасці або выдаліце некаторыя выявы цi іншыя файлы."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Месца на вашай SD-карце заканчваецца. Змяніце параметры якасці або выдаліце некаторыя выявы цi іншыя файлы."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Адмена агляда"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Агляд зроблены"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Пераробка агляда"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Прайграванне відэа"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Паўза прайгравання відэа"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Абнавіць відэа"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Радок часу прайгравання відэапрайгравальніка"</string>
<string name="capital_on" msgid="5491353494964003567">"УКЛ."</string>
<string name="capital_off" msgid="7231052688467970897">"АДКЛ."</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Адключана"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Пошук"</string>
<string name="tab_photos" msgid="9110813680630313419">"Фатаграфіі"</string>
<string name="tab_albums" msgid="8079449907770685691">"Альбомы"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ДАДАТКОВЫЯ ПАРАМЕТРЫ"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"НАЛАДЫ"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d фота"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d фота"</item>
diff --git a/res/values-bg/filtershow_strings.xml b/res/values-bg/filtershow_strings.xml
index cbba456..715692b 100644
--- a/res/values-bg/filtershow_strings.xml
+++ b/res/values-bg/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Тапетът се задава"</string>
- <string name="download_failure" msgid="5923323939788582895">"Снимката не можа да се изтегли. Мрежата не е налице."</string>
<string name="original" msgid="3524493791230430897">"Оригинал"</string>
<string name="borders" msgid="2067345080568684614">"Контури"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Отмяна"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Възстановяване"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Приложени ефекти: Показване"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Приложени ефекти: Скриване"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"История: Показване"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"История: Скриване"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Съст. на изобр.: Показване"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Съст. на изобр.: Скриване"</string>
<string name="menu_settings" msgid="6428291655769260831">"Настройки"</string>
<string name="unsaved" msgid="8704442449002374375">"В това изображение има незапазени промени."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Искате ли да запазите преди изход?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Избиране на цвят"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Избиране на размер"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Оригинал"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Резултат"</string>
</resources>
diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml
index 9ec6bcc..cf0a879 100644
--- a/res/values-bg/strings.xml
+++ b/res/values-bg/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Завъртане надясно"</string>
<string name="no_such_item" msgid="5315144556325243400">"Елементът не можа да бъде намерен."</string>
<string name="edit" msgid="1502273844748580847">"Редактиране"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Обикн. редактиране"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Заявките за кеширане се обработват"</string>
<string name="caching_label" msgid="4521059045896269095">"Кешира се..."</string>
<string name="crop_action" msgid="3427470284074377001">"Подрязване"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Задна"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Предна"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Място за съхранение"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"МЕСТОПОЛОЖЕНИЕ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Таймер за обратното отброяване"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 секунда"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Настройки на камера"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Настройки на видеокамера"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Размер на снимка"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 мегапиксела"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 мегапиксела"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 мегапиксела"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 мпкс"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 мегапиксела"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 мегапиксела"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 мпкс (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 мегапиксела"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 мегапиксел"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Автоматичен"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Безкрайност"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Макро"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"АВТОМАТИЧНО"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"БЕЗКРАЙНОСТ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"МАКРО"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Светкавица"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"РЕЖИМ НА СВЕТКАВИЦАТА"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Автоматичен"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Включена"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Изкл."</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"АВТОМАТИЧНА СВЕТКАВИЦА"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"СВЕТКАВИЦАТА Е ВКЛЮЧЕНА"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"СВЕТКАВИЦАТА Е ИЗКЛЮЧЕНА"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Баланс на бялото"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"БАЛАНС НА БЯЛОТО"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Автоматичен"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Изкуствена светлина"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Дневна светлина"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Флуоресцентна светлина"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Облачно"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"АВТОМАТИЧНО"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ИЗКУСТВЕНА СВЕТЛИНА"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"ДНЕВНА СВЕТЛИНА"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ФЛУОРЕСЦЕНТНА СВЕТЛИНА"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ОБЛАЧНО"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Сценичен режим"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Автоматичен"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Нощ"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Залез"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Празненство"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"БЕЗ"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ДЕЙСТВИЕ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"ПРЕЗ НОЩТА"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ЗАЛЕЗ"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ПАРТИ"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ТАЙМЕР ЗА ОБРАТНО ОТБРОЯВАНЕ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ТАЙМЕРЪТ Е ИЗКЛЮЧЕН"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 СЕКУНДА"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 СЕКУНДИ"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 СЕКУНДИ"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 СЕКУНДИ"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Не може да се избира в сценичен режим."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Eкспониране"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ЕКСПОНИРАНЕ"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ПРЕДНА КАМЕРА"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"ЗАДНА КАМЕРА"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Мястото на USB хранилището ви привършва. Променете настройките за качество или изтрийте някои изображения или други файлове."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Мястото на SD картата ви привършва. Променете настройките за качество или изтрийте някои изображения или други файлове."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Анулиране на прегледа"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Прегледът приключи"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Преглед на презаснетия елемент"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Пускане на видеоклипа"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Поставяне на видеоклипа на пауза"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Презареждане на видеоклипа"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Времева лента на видеоплейъра"</string>
<string name="capital_on" msgid="5491353494964003567">"ВКЛЮЧЕНО"</string>
<string name="capital_off" msgid="7231052688467970897">"ИЗКЛЮЧЕНО"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Изкл."</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Търсене"</string>
<string name="tab_photos" msgid="9110813680630313419">"Снимки"</string>
<string name="tab_albums" msgid="8079449907770685691">"Албуми"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ОЩЕ ОПЦИИ"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"НАСТРОЙКИ"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d снимка"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d снимки"</item>
diff --git a/res/values-ca/filtershow_strings.xml b/res/values-ca/filtershow_strings.xml
index 7da09b9..495947f 100644
--- a/res/values-ca/filtershow_strings.xml
+++ b/res/values-ca/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"S\'està establint el fons de pantalla"</string>
- <string name="download_failure" msgid="5923323939788582895">"No s\'ha pogut baixar la foto. La xarxa no està disponible."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Vores"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Desfés"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Refés"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Mostra els efectes aplicats"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Amaga els efectes aplicats"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Mostra l\'historial"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Amaga l\'historial"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Mostra estat imatge"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Amaga estat d\'imatge"</string>
<string name="menu_settings" msgid="6428291655769260831">"Configuració"</string>
<string name="unsaved" msgid="8704442449002374375">"Hi ha canvis sense desar en aquesta imatge."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Vols desar abans de sortir?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Selecció del color"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Selecció de la mida"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"D\'acord"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultat"</string>
</resources>
diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
index 514db19..333b3af 100644
--- a/res/values-ca/strings.xml
+++ b/res/values-ca/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Gira a la dreta"</string>
<string name="no_such_item" msgid="5315144556325243400">"No s\'ha trobat l\'element."</string>
<string name="edit" msgid="1502273844748580847">"Edita"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Edició simple"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"S\'estan processant les sol·licituds de memòria cau"</string>
<string name="caching_label" msgid="4521059045896269095">"S\'està desant a la memòria cau..."</string>
<string name="crop_action" msgid="3427470284074377001">"Retalla"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Enrere"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Frontal"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Emmagatzema la ubicació"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"UBICACIÓ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Temporitzador de compte enrere"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 segon"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Configuració de la càmera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Configuració de la càmera de vídeo"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Mida de la imatge"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapíxels"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapíxels"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapíxels"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapíxels"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapíxels"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapíxels"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 megapíxels (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapíxels"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapíxel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automàtic"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinit"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMÀTIC"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINIT"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Mode de flaix"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MODE DE FLAIX"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automàtic"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"A"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Desactivat"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLAIX AUTOMÀTIC"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLAIX ACTIVAT"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLAIX DESACTIVAT"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Balanç de blancs"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALANÇ DE BLANCS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automàtica"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Incandescent"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Llum de dia"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescent"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Ennuvolat"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMÀTIC"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENT"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"LLUM DE DIA"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENT"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ENNUVOLAT"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Mode d\'escena"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automàtic"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nocturn"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Posta del sol"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Festa"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"CAP"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACCIÓ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NIT"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"POSTA DE SOL"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FESTA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"TEMPORITZADOR DE COMPTE ENRERE"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TEMPORITZADOR DESACTIVAT"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEGON"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEGONS"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEGONS"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEGONS"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"No es pot seleccionar en mode d\'escena."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Exposició"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOSICIÓ"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CÀMERA FRONTAL"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CÀMERA POSTERIOR"</string>
<string name="dialog_ok" msgid="6263301364153382152">"D\'acord"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"L\'emmagatzematge USB s\'està quedant sense espai. Canvia la configuració de qualitat o bé suprimeix unes quantes imatges o altres fitxers."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"La targeta SD s\'està quedant sense espai. Canvia la configuració de qualitat o suprimeix unes quantes imatges o altres fitxers."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Cancel·la en mode de revisió"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Fet en mode de revisió"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Revisa la foto o el vídeo nou"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Reprodueix el vídeo"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Posa en pausa el vídeo"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Torna a carregar el vídeo"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Barra temporal del reproductor de vídeo"</string>
<string name="capital_on" msgid="5491353494964003567">"ACTIVAT"</string>
<string name="capital_off" msgid="7231052688467970897">"DESACTIVAT"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Desactivat"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Cerca"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Àlbums"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"MÉS OPCIONS"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"CONFIGURACIÓ"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotos"</item>
diff --git a/res/values-cs/filtershow_strings.xml b/res/values-cs/filtershow_strings.xml
index b5a2c18..e3889d0 100644
--- a/res/values-cs/filtershow_strings.xml
+++ b/res/values-cs/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Nastavování tapety"</string>
- <string name="download_failure" msgid="5923323939788582895">"Fotografii se nepodařilo stáhnout. Síť je nedostupná."</string>
<string name="original" msgid="3524493791230430897">"Původní"</string>
<string name="borders" msgid="2067345080568684614">"Okraje"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Vrátit zpět"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Opakovat"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Ukázat použité efekty"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Skrýt použité efekty"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Zobrazit historii"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Skrýt historii"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Ukázat stav obrázku"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Skrýt stav obrázku"</string>
<string name="menu_settings" msgid="6428291655769260831">"Nastavení"</string>
<string name="unsaved" msgid="8704442449002374375">"Obrázek obsahuje neuložené změny."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Chcete před ukončením uložit změny?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Vyberte barvu"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Vyberte velikost"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Původní"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Výsledek"</string>
</resources>
diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml
index ea46d50..b6265cc 100644
--- a/res/values-cs/strings.xml
+++ b/res/values-cs/strings.xml
@@ -45,7 +45,7 @@
<string name="select_item" msgid="2816923896202086390">"Vybrat položku"</string>
<string name="select_album" msgid="1557063764849434077">"Vybrat album"</string>
<string name="select_group" msgid="6744208543323307114">"Vybrat skupinu"</string>
- <string name="set_image" msgid="2331476809308010401">"Nastavit fotku jako"</string>
+ <string name="set_image" msgid="2331476809308010401">"Nastavit fotografii jako"</string>
<string name="set_wallpaper" msgid="8491121226190175017">"Nastavit tapetu"</string>
<string name="wallpaper" msgid="140165383777262070">"Nastavování tapety..."</string>
<string name="camera_setas_wallpaper" msgid="797463183863414289">"Tapeta"</string>
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Otočit doprava"</string>
<string name="no_such_item" msgid="5315144556325243400">"Položku nelze najít."</string>
<string name="edit" msgid="1502273844748580847">"Upravit"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Jednoduchá úprava"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Zpracování požadavků na uložení do mezipaměti"</string>
<string name="caching_label" msgid="4521059045896269095">"Ukládání do mezipaměti..."</string>
<string name="crop_action" msgid="3427470284074377001">"Oříznout"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Zadní"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Přední"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Úložiště"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"POLOHA"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Časovač odpočítávání"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 s"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Nastavení fotoaparátu"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Nastavení videokamery"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Velikost fotografií"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 Mpx"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapixelů"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 Mpx"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 Mpx"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 Mpx"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 Mpx"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 Mpx (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 Mpx"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 Mpx"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Auto"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Nekonečno"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"NEKONEČNO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Režim blesku"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"REŽIM BLESKU"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automaticky"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Zapnout"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Vypnout"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMATICKÝ BLESK"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLESK ZAPNUTÝ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"BLESK VYPNUTÝ"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Vyvážení bílé"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"VYVÁŽENÍ BÍLÉ"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automaticky"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Žárovka"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Denní světlo"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Zářivka"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Zataženo"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ŽÁROVKA"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DENNÍ SVĚTLO"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ZÁŘIVKA"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ZATAŽENO"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scénický režim"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automaticky"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Noc"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Západ slunce"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Párty"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"ŽÁDNÉ"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"AKCE"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOC"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ZÁPAD SLUNCE"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"VEČÍREK"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ČASOVAČ ODPOČÍTÁVÁNÍ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ČASOVAČ VYPNUT"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUNDA"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDY"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUND"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUND"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Tuto možnost nelze ve scénickém režimu vybrat."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Expozice"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOZICE"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"PŘEDNÍ FOTOAPARÁT"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"ZADNÍ FOTOAPARÁT"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"V úložišti USB je málo místa. Změňte nastavení kvality nebo smažte některé fotografie či jiné soubory."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Na kartě SD je málo místa. Změňte nastavení kvality nebo smažte některé obrázky či jiné soubory."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Zrušit"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Hotovo"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Pořídit další"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Přehrát video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pozastavit video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Znovu načíst video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Časová lišta přehrávače videa"</string>
<string name="capital_on" msgid="5491353494964003567">"ZAPNUTO"</string>
<string name="capital_off" msgid="7231052688467970897">"VYPNUTO"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Vypnuto"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Hledat"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotky"</string>
<string name="tab_albums" msgid="8079449907770685691">"Alba"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"DALŠÍ MOŽNOSTI"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"NASTAVENÍ"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d fotka"</item>
<item quantity="other" msgid="3813306834113858135">"Fotky: %1$d"</item>
diff --git a/res/values-da/filtershow_strings.xml b/res/values-da/filtershow_strings.xml
index 9fe1463..c120489 100644
--- a/res/values-da/filtershow_strings.xml
+++ b/res/values-da/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Angiver baggrund"</string>
- <string name="download_failure" msgid="5923323939788582895">"Kunne ikke downloade billede. Netværk utilgængeligt."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Rammer"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Fortryd"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Annuller fortryd"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Vis anvendte effekter"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Skjul anvendte effekter"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Vis historik"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Skjul historik"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Vis billedtilstand"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Skjul billedtilstand"</string>
<string name="menu_settings" msgid="6428291655769260831">"Indstillinger"</string>
<string name="unsaved" msgid="8704442449002374375">"Der er ændringer på dette billede, som ikke er gemt."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Vil du gemme, før du afslutter?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Vælg farve"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Vælg størrelse"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultat"</string>
</resources>
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index 9fde3de..c325b81 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Roter til højre"</string>
<string name="no_such_item" msgid="5315144556325243400">"Elementet blev ikke fundet."</string>
<string name="edit" msgid="1502273844748580847">"Rediger"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Simpel redigering"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Håndterer anmodninger om cachelagring"</string>
<string name="caching_label" msgid="4521059045896269095">"Cachelagrer..."</string>
<string name="crop_action" msgid="3427470284074377001">"Beskær"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Bagest"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Forrest"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Gem placering"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"PLACERING"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Nedtællingsur"</string>
<!-- String.format failed for translation -->
<!-- no translation found for pref_camera_timer_entry:other (6455381617076792481) -->
@@ -251,13 +249,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Indstillinger for kamera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Indstillinger for videokamera"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Billedstørrelse"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M pixels"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapixel"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapixel"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M pixels"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapixel"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapixel"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M pixels (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapixel"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -266,29 +261,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatisk"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Uendelighed"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMATISK"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"UENDELIGT"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Blitztilstand"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"BLITZTILSTAND"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatisk"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Til"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Fra"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMATISK BLITZ"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLITZ TIL"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"BLITZ FRA"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Hvidbalance"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"HVIDBALANCE"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatisk"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Blødt lys"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Dagslys"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Hårdt lys"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Overskyet"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMATISK"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"BLØDT LYS"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DAGSLYS"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"HÅRDT LYS"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"OVERSKYET"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scenetilstand"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatisk"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -296,25 +278,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nat"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Solnedgang"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Fest"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"INGEN"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"HANDLING"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NAT"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SOLNEDGANG"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FEST"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"NEDTÆLLINGSUR"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"SLÅ NEDTÆLLINGSUR FRA"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUND"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDER"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUNDER"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUNDER"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Kan ikke vælges i motivtilstand."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Eksponering"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EKSPONERING"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"FRONTKAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"BAGSIDEKAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Der er snart ikke mere plads i USB-lager. Rediger indstillingerne for kvalitet, eller slet nogle billeder eller andre filer."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Der er snart ikke mere plads på dit SD-kort. Rediger indstillingerne for kvalitet, eller slet nogle billeder eller andre filer."</string>
@@ -365,10 +332,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Annullering af gennemgang"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Gennemgang fuldført"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Lav foto/video til anmeldelsen om"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Afspil video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Sæt video på pause"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Genindlæs video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Tidsbjælke til videoafspiller"</string>
<string name="capital_on" msgid="5491353494964003567">"TIL"</string>
<string name="capital_off" msgid="7231052688467970897">"FRA"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Fra"</string>
@@ -428,8 +391,6 @@
<string name="menu_search" msgid="7580008232297437190">"Søg"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albummer"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"FLERE VALGMULIGHEDER"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"INDSTILLINGER"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d billede"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d billeder"</item>
diff --git a/res/values-de/filtershow_strings.xml b/res/values-de/filtershow_strings.xml
index 8018ca1..037abc2 100644
--- a/res/values-de/filtershow_strings.xml
+++ b/res/values-de/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Hintergrund wird festgelegt..."</string>
- <string name="download_failure" msgid="5923323939788582895">"Foto konnte nicht heruntergeladen werden. Netzwerk ist nicht verfügbar."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Rahmen"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Rückgängig machen"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Wiederholen"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Angewendete Effekte anzeigen"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Angewendete Effekte ausblenden"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Verlauf anzeigen"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Verlauf ausblenden"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Bildstatus anzeigen"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Bildstatus ausblenden"</string>
<string name="menu_settings" msgid="6428291655769260831">"Einstellungen"</string>
<string name="unsaved" msgid="8704442449002374375">"Dieses Bild weist nicht gespeicherte Änderungen auf."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Möchten Sie vor dem Schließen speichern?"</string>
@@ -73,7 +74,7 @@
<string name="rotate" msgid="2796802553793795371">"Drehen"</string>
<string name="mirror" msgid="5482518108154883096">"Spiegeln"</string>
<string name="negative" msgid="6998313764388022201">"Negativ"</string>
- <string name="none" msgid="6633966646410296520">"Kein Filter"</string>
+ <string name="none" msgid="6633966646410296520">"Keines"</string>
<string name="edge" msgid="7036064886242147551">"Kanten"</string>
<string name="kmeans" msgid="1630263230946107457">"Warhol"</string>
<string name="downsample" msgid="3552938534146980104">"Verkleinern"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Farbe auswählen"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Größe auswählen"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Ergebnis"</string>
</resources>
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index 264659a..e052719 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Nach rechts drehen"</string>
<string name="no_such_item" msgid="5315144556325243400">"Bild wurde nicht gefunden."</string>
<string name="edit" msgid="1502273844748580847">"Bearbeiten"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Einfache Bearbeitung"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Caching-Anfragen werden verarbeitet."</string>
<string name="caching_label" msgid="4521059045896269095">"Caching läuft..."</string>
<string name="crop_action" msgid="3427470284074377001">"Zuschneiden"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Rückseite"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Vorderseite"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Ort speichern"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"Standort"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Countdown-Timer"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 Sekunde"</item>
@@ -253,44 +251,28 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kameraeinstellungen"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Camcordereinstellungen"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Bildgröße"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 Megapixel"</string>
- <string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 MP"</string>
- <string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 MP"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 MP"</string>
- <string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 MP"</string>
- <string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 MP"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 MP (16:9)"</string>
- <string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 MP"</string>
- <string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 MP"</string>
+ <string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 Megapixel"</string>
+ <string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 Megapixel"</string>
+ <string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 Megapixel"</string>
+ <string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 Megapixel"</string>
+ <string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 Megapixel"</string>
+ <string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 Megapixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
<string name="pref_camera_picturesize_entry_qvga" msgid="8576186463069770133">"QVGA"</string>
<string name="pref_camera_focusmode_title" msgid="2877248921829329127">"Fokussierungsmodus"</string>
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatisch"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Unendlich"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"Automatisch"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"Unendlich"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"Makro"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Blitzmodus"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"Blitzmodus"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatisch"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"An"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Aus"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"Automatischer Blitz"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"Blitz an"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"Blitz aus"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Weißabgleich"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"Weißabgleich"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatisch"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Glühlampenlicht"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Tageslicht"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Neonlicht"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Bewölkt"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"Automatisch"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"Glühlampenlicht"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"Tageslicht"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"Neonlicht"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"Bewölkt"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Szenenmodus"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatisch"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nachtaufnahme"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Sonnenuntergang"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Party"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"Kein"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"Aktion"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"Nachts"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"Sonnenuntergang"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"Party"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"Countdown-Timer"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"Timer deaktiviert"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 Sekunde"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 Sekunden"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 Sekunden"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 Sekunden"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Diese Einstellung kann im Szenenmodus nicht ausgewählt werden."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Belichtung"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"Belichtung"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR; High Dynamic Range"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"Frontkamera"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"Kamera auf der Rückseite"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Ihr USB-Speicher bietet nicht mehr genug Speicherplatz. Ändern Sie die Qualitätseinstellung oder löschen Sie Bilder oder andere Dateien."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Auf Ihrer SD-Karte ist nicht mehr genügend Speicherplatz vorhanden. Ändern Sie die Qualitätseinstellung oder löschen Sie Bilder oder andere Dateien."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Überprüfung abbrechen"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Überprüfung abgeschlossen"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Überprüfen – erneut aufnehmen"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Video ansehen"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Video anhalten"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Video erneut laden"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Zeitleiste des Videoplayers"</string>
<string name="capital_on" msgid="5491353494964003567">"An"</string>
<string name="capital_off" msgid="7231052688467970897">"Aus"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Aus"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Suchen"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Alben"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"Weitere Optionen"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"Einstellungen"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d Foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d Fotos"</item>
diff --git a/res/values-el/filtershow_strings.xml b/res/values-el/filtershow_strings.xml
index bfbd589..76e3d2a 100644
--- a/res/values-el/filtershow_strings.xml
+++ b/res/values-el/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Ορισμός ταπετσαρίας…"</string>
- <string name="download_failure" msgid="5923323939788582895">"Δεν ήταν δυνατή η λήψη φωτογραφιών. Το δίκτυο δεν είναι διαθέσιμο."</string>
<string name="original" msgid="3524493791230430897">"Αρχική"</string>
<string name="borders" msgid="2067345080568684614">"Σύνορα"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Αναίρεση"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Επανάληψη"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Εμφάνιση εφαρμοσμένων εφέ"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Απόκρυψη εφαρμοσμένων εφέ"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Εμφάνιση ιστορικού"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Απόκρυψη ιστορικού"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Εμφ.κατάστ.εικόνας"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Απόκρ.κατάστ.εικόνας"</string>
<string name="menu_settings" msgid="6428291655769260831">"Ρυθμίσεις"</string>
<string name="unsaved" msgid="8704442449002374375">"Υπάρχουν μη αποθηκευμένες αλλαγές σε αυτήν την εικόνα."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Θέλετε να γίνει αποθήκευση πριν από την έξοδο;"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Επιλογή χρώματος"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Επιλογή μεγέθους"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"ΟΚ"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Αρχική"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Αποτέλεσμα"</string>
</resources>
diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml
index 26a5af5..98d425b 100644
--- a/res/values-el/strings.xml
+++ b/res/values-el/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Δεξιά περιστροφή"</string>
<string name="no_such_item" msgid="5315144556325243400">"Δεν ήταν δυνατή η εύρεση."</string>
<string name="edit" msgid="1502273844748580847">"Επεξεργασία"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Απλή επεξεργασία"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Επεξεργασία αιτημάτων προσωρινής αποθήκευσης"</string>
<string name="caching_label" msgid="4521059045896269095">"Προσωρ. αποθ..."</string>
<string name="crop_action" msgid="3427470284074377001">"Περικοπή"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Πίσω"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Μπροστά"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Αποθήκευση τοποθεσίας"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"ΤΟΠΟΘΕΣΙΑ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Χρονόμετρο αντίστροφης μέτρησης"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 δευτερόλεπτο"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Ρυθμίσεις φωτογραφικής μηχανής"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Ρυθμίσεις βιντεοκάμερας"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Μέγεθος εικόνας"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M εικονοστ."</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M εικονοστ."</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 M εικονοστ."</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M εικονοστ."</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M εικονοστ."</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M εικονοστ."</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M εικον.(16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3M εικονοστ."</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M εικονοστ."</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Αυτόματο"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Άπειρο"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Απόσταση"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"ΑΥΤΟΜΑΤΟ"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"ΑΠΕΙΡΟ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"ΜΑΚΡΟΦΩΤΟΓΡΑΦΙΑ"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Λειτουργία Flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"ΛΕΙΤΟΥΡΓΙΑ ΦΛΑΣ"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Αυτόματο"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Ενεργοποιημένο"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"ΑΠΕΝΕΡΓΟΠΟΙΗΜΕΝΟ"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"ΑΥΤΟΜΑΤΟ ΦΛΑΣ"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"ΕΝΕΡΓΟΠΟΙΗΣΗ ΦΛΑΣ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"ΑΠΕΝΕΡΓΟΠΟΙΗΣΗ ΦΛΑΣ"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Ισορροπία λευκού"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"ΙΣΟΡΡΟΠΙΑ ΛΕΥΚΟΥ"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Αυτόματο"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Λαμπτήρας πυρακτώσεως"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Φως ημέρας"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Λαμπτήρας φθορισμού"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Συννεφιά"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"ΑΥΤΟΜΑΤΟ"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ΛΑΜΠΤΗΡΑΣ ΠΥΡΑΚΤΩΣΕΩΣ"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"ΦΩΣ ΗΜΕΡΑΣ"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ΛΑΜΠΤΗΡΑΣ ΦΘΟΡΙΣΜΟΥ"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ΣΥΝΝΕΦΙΑ"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Λειτουργία σκηνής"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Αυτόματο"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Νύχτα"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Ηλιοβασίλεμα"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Πάρτι"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"ΚΑΜΙΑ"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ΔΡΑΣΗ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"ΝΥΧΤΑ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ΗΛΙΟΒΑΣΙΛΕΜΑ"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ΠΑΡΤΙ"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ΧΡΟΝΟΜΕΤΡΟ ΑΝΤΙΣΤΡΟΦΗΣ ΜΕΤΡΗΣΗΣ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ΑΝΕΝΕΡΓΟ ΧΡΟΝΟΜΕΤΡΟ"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 ΔΕΥΤΕΡΟΛΕΠΤΟ"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 ΔΕΥΤΕΡΟΛΕΠΤΑ"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 ΔΕΥΤΕΡΟΛΕΠΤΑ"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 ΔΕΥΤΕΡΟΛΕΠΤΑ"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Δεν υπάρχει δυνατότητα επιλογής στη λειτουργία σκηνής."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Έκθεση"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ΕΚΘΕΣΗ"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"Υψηλό δυναμικό εύρος (HDR)"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ΜΠΡΟΣΤΙΝΗ ΚΑΜΕΡΑ"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"ΠΙΣΩ ΚΑΜΕΡΑ"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Ο διαθέσιμος χώρος USB είναι ελάχιστος. Αλλάξτε τη ρύθμιση της ποιότητας ή διαγράψτε κάποιες εικόνες ή άλλα αρχεία."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Ο διαθέσιμος χώρος στην κάρτα SD είναι ελάχιστος. Αλλάξτε τη ρύθμιση ποιότητας ή διαγράψτε κάποιες εικόνες ή άλλα αρχεία."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Ακύρωση αναθεώρησης"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Ολοκλήρωση αναθεώρησης"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Έλεγχος νέας λήψης"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Αναπαραγωγή βίντεο"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Παύση βίντεο"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Επανάληψη φόρτωσης βίντεο"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Γραμμή χρόνου προγράμματος αναπαραγωγής βίντεο"</string>
<string name="capital_on" msgid="5491353494964003567">"ΕΝΕΡΓΟΠΟΙΗΣΗ"</string>
<string name="capital_off" msgid="7231052688467970897">"ΑΠΕΝΕΡΓΟΠΟΙΗΣΗ"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Απενεργοποιημένη"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Αναζήτηση"</string>
<string name="tab_photos" msgid="9110813680630313419">"Φωτογραφίες"</string>
<string name="tab_albums" msgid="8079449907770685691">"Λεύκωμα"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ΠΕΡΙΣΣΟΤΕΡΕΣ ΕΠΙΛΟΓΕΣ"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"ΡΥΘΜΙΣΕΙΣ"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d φωτογραφία"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d φωτογραφ."</item>
diff --git a/res/values-en-rGB/filtershow_strings.xml b/res/values-en-rGB/filtershow_strings.xml
index 19c4ac2..be9a85f 100644
--- a/res/values-en-rGB/filtershow_strings.xml
+++ b/res/values-en-rGB/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Setting wallpaper"</string>
- <string name="download_failure" msgid="5923323939788582895">"Could not download photo. Network unavailable."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Borders"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Undo"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Redo"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Show Applied Effects"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Hide Applied Effects"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Show history"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Hide history"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Show Image State"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Hide Image State"</string>
<string name="menu_settings" msgid="6428291655769260831">"Settings"</string>
<string name="unsaved" msgid="8704442449002374375">"There are unsaved changes to this image."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Do you want to save before exiting?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Select Colour"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Select Size"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Result"</string>
</resources>
diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml
index 6225326..788d170 100644
--- a/res/values-en-rGB/strings.xml
+++ b/res/values-en-rGB/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Rotate right"</string>
<string name="no_such_item" msgid="5315144556325243400">"Couldn\'t find item."</string>
<string name="edit" msgid="1502273844748580847">"Edit"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Simple Edit"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Process Caching Requests"</string>
<string name="caching_label" msgid="4521059045896269095">"Caching..."</string>
<string name="crop_action" msgid="3427470284074377001">"Crop"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Back"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Front"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Store location"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOCATION"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Countdown timer"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 second"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Camera settings"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Camcorder settings"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Picture size"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 M pixels"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M pixels"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 M pixels"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 M pixels"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 M pixels"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 M pixels"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 M pixels (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3 M pixels"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 M pixels"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Auto"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinity"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINITY"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Flash mode"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"FLASH MODE"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Auto"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"On"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Off"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH AUTO"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLASH ON"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLASH OFF"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"White balance"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"WHITE BALANCE"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Auto"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Incandescent"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Daylight"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescent"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Cloudy"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENT"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DAYLIGHT"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENT"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"CLOUDY"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scene mode"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Auto"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Night"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Sunset"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Party"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NONE"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACTION"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NIGHT"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SUNSET"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"PARTY"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"COUNTDOWN TIMER"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TIMER OFF"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SECOND"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SECONDS"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SECONDS"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SECONDS"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Not selectable in scene mode."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Exposure"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOSURE"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"FRONT CAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"BACK CAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Your USB storage is running out of space. Change the quality setting or delete some images or other files."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Your SD card is running out of space. Change the quality setting or delete some images or other files."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Review cancel"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Review done"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Review retake"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Play video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pause video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Reload video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Video player time bar"</string>
<string name="capital_on" msgid="5491353494964003567">"ON"</string>
<string name="capital_off" msgid="7231052688467970897">"OFF"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Off"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Search"</string>
<string name="tab_photos" msgid="9110813680630313419">"Photos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albums"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"More options"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"SETTINGS"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d photo"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d photos"</item>
diff --git a/res/values-es-rUS/filtershow_strings.xml b/res/values-es-rUS/filtershow_strings.xml
index 903b80b..d2f5080 100644
--- a/res/values-es-rUS/filtershow_strings.xml
+++ b/res/values-es-rUS/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Estableciendo fondo de pantalla..."</string>
- <string name="download_failure" msgid="5923323939788582895">"No se pudo descargar la foto. La red no está disponible."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Bordes"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Deshacer"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Rehacer"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Mostrar efectos aplicados"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Ocultar efectos aplicados"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Mostrar historial"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Ocultar historial"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Mostrar estado imag."</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Ocultar estado imag."</string>
<string name="menu_settings" msgid="6428291655769260831">"Configuración"</string>
<string name="unsaved" msgid="8704442449002374375">"Hay cambios sin guardar en esta imagen."</string>
<string name="save_before_exit" msgid="2680660633675916712">"¿Quieres guardar los cambios antes de salir?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Seleccionar color"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Seleccionar tamaño"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"Aceptar"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultado"</string>
</resources>
diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml
index ce9cdad..322196b 100644
--- a/res/values-es-rUS/strings.xml
+++ b/res/values-es-rUS/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Rotar hacia la derecha"</string>
<string name="no_such_item" msgid="5315144556325243400">"No se pudo encontrar el elemento."</string>
<string name="edit" msgid="1502273844748580847">"Editar"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Edición simple"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Procesando solicitudes de almacenamiento en caché"</string>
<string name="caching_label" msgid="4521059045896269095">"Alm en caché..."</string>
<string name="crop_action" msgid="3427470284074377001">"Recortar"</string>
@@ -131,7 +130,7 @@
<string name="duration" msgid="8160058911218541616">"Duración"</string>
<string name="mimetype" msgid="8024168704337990470">"Tipo de MIME"</string>
<string name="file_size" msgid="8486169301588318915">"Tamaño del archivo"</string>
- <string name="maker" msgid="7921835498034236197">"Fabricante"</string>
+ <string name="maker" msgid="7921835498034236197">"Creador"</string>
<string name="model" msgid="8240207064064337366">"Modelo"</string>
<string name="flash" msgid="2816779031261147723">"Flash"</string>
<string name="aperture" msgid="5920657630303915195">"Apertura"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Parte trasera"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Parte delantera"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Almacenar ubicación"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"UBICACIÓN"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Temp. de cuenta regresiva"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 segundo"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Configuración de cámara"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Configuración de videocámara"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Tamaño de imagen"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapíxeles"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 MP"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 MP"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 Mpx"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 MP"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 MP"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 Mpx (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 MP"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 MP"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automático"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinito"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMÁTICO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINITO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MODO DE FLASH"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automático"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Activado"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Desactivado"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH AUTOMÁTICO"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLASH ACTIVADO"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLASH DESACTIVADO"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Balance blancos"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALANCE DE BLANCOS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automático"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Incandescente"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Luz del día"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescente"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Nublado"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMÁTICO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENTE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"LUZ NATURAL"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENTE"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"NUBLADO"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Modo de preselección de escenas"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automático"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nocturno"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Atardecer"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Fiesta"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NINGUNO"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACCIÓN"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOCHE"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ATARDECER"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FIESTA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"TEMPORIZADOR DE CUENTA REGRESIVA"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TEMPORIZADOR DESACTIVADO"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEGUNDO"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEGUNDOS"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEGUNDOS"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEGUNDOS"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"No se puede seleccionar en el modo Escena."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Valor de exposición"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOSICIÓN"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CÁMARA FRONTAL"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CÁMARA POSTERIOR"</string>
<string name="dialog_ok" msgid="6263301364153382152">"Aceptar"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"El almacenamiento USB se está quedando sin espacio. Cambia la configuración de calidad o elimina algunas imágenes u otros archivos."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Tu tarjeta SD se está quedando sin espacio. Cambia la configuración de calidad o elimina algunas imágenes u otros archivos."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Cancelar"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Listo"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Revisar nueva toma"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Reproducir video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pausar video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Volver a cargar video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Barra de tiempo del reproductor de video"</string>
<string name="capital_on" msgid="5491353494964003567">"ACTIVADO"</string>
<string name="capital_off" msgid="7231052688467970897">"DESACTIVADO"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Apagado"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Búsqueda"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Álbumes"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"MÁS OPCIONES"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"CONFIGURACIÓN"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotos"</item>
diff --git a/res/values-es/filtershow_strings.xml b/res/values-es/filtershow_strings.xml
index 6c240dc..bf81a16 100644
--- a/res/values-es/filtershow_strings.xml
+++ b/res/values-es/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Estableciendo fondo de pantalla..."</string>
- <string name="download_failure" msgid="5923323939788582895">"No se ha podido descargar la foto porque la red no está disponible."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Margen"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Deshacer"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Rehacer"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Mostrar efectos aplicados"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Ocultar efectos aplicados"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Mostrar historial"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Ocultar historial"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Mostrar estado imagen"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Ocultar estado de la imagen"</string>
<string name="menu_settings" msgid="6428291655769260831">"Ajustes"</string>
<string name="unsaved" msgid="8704442449002374375">"Hay cambios sin guardar en esta imagen."</string>
<string name="save_before_exit" msgid="2680660633675916712">"¿Quieres guardar antes de salir?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Seleccionar color"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Seleccionar tamaño"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"Aceptar"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultado"</string>
</resources>
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index a737ace..6ce3e5c 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Girar a la derecha"</string>
<string name="no_such_item" msgid="5315144556325243400">"No se ha podido encontrar el elemento."</string>
<string name="edit" msgid="1502273844748580847">"Editar"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Edición simple"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Procesando solicitudes de almacenamiento en caché"</string>
<string name="caching_label" msgid="4521059045896269095">"Almacenando en caché..."</string>
<string name="crop_action" msgid="3427470284074377001">"Recortar"</string>
@@ -116,7 +115,7 @@
<string name="no_albums_alert" msgid="4111744447491690896">"No hay álbumes disponibles."</string>
<string name="empty_album" msgid="4542880442593595494">"No hay imágenes ni vídeos disponibles."</string>
<string name="picasa_posts" msgid="1497721615718760613">"Publicaciones"</string>
- <string name="make_available_offline" msgid="5157950985488297112">"Disponible sin conexión"</string>
+ <string name="make_available_offline" msgid="5157950985488297112">"Disponible sin conex."</string>
<string name="sync_picasa_albums" msgid="8522572542111169872">"Actualizar"</string>
<string name="done" msgid="217672440064436595">"Listo"</string>
<string name="sequence_in_set" msgid="7235465319919457488">"Elemento: %1$d de %2$d"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Trasera"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Delantera"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Añadir ubicación"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"UBICACIÓN"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Temporizador de cuenta atrás"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 segundo"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Ajustes de la cámara"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Configuración de videocámara"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Tamaño imagen"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 MP"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 MP"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 MP"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 MP"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 MP"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 MP"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 MP (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 MP"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 MP"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Auto"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinito"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMÁTICO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINITO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MODO FLASH"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automático"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Activado"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Desactivado"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH AUTOMÁTICO"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLASH ACTIVADO"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLASH DESACTIVADO"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Balance de blancos"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALANCE DE BLANCOS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automático"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Incandescente"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Luz natural"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescente"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Nublado"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMÁTICO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENTE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"LUZ NATURAL"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENTE"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"NUBLADO"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Modo de escena"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automático"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nocturno"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Atardecer"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Fiesta"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NINGUNO"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACCIÓN"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOCHE"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ATARDECER"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FIESTA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"TEMPORIZADOR DE CUENTA ATRÁS"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TEMPORIZADOR DESACTIVADO"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEGUNDO"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEGUNDOS"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEGUNDOS"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEGUNDOS"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"No se puede seleccionar en el modo de escena."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Exposición"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOSICIÓN"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"ARD"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CÁMARA FRONTAL"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CÁMARA TRASERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"Aceptar"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"No queda espacio en el almacenamiento USB. Cambia la configuración de calidad o elimina algunas imágenes u otros archivos."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"No queda espacio en la tarjeta SD. Cambia la configuración de calidad o elimina algunas imágenes u otros archivos."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Cancelar"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Listo"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Revisar repetición"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Ver un vídeo"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pausar vídeo"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Volver a cargar vídeo"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Barra de tiempo del reproductor de vídeo"</string>
<string name="capital_on" msgid="5491353494964003567">"SÍ"</string>
<string name="capital_off" msgid="7231052688467970897">"NO"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Desactivado"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Buscar"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Álbumes"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"MÁS OPCIONES"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"AJUSTES"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotos"</item>
diff --git a/res/values-et/filtershow_strings.xml b/res/values-et/filtershow_strings.xml
index 185608b..2d9ea29 100644
--- a/res/values-et/filtershow_strings.xml
+++ b/res/values-et/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Taustapildi määramine"</string>
- <string name="download_failure" msgid="5923323939788582895">"Fotot ei õnnestunud alla laadida, kuna võrk ei ole saadaval."</string>
<string name="original" msgid="3524493791230430897">"Originaal"</string>
<string name="borders" msgid="2067345080568684614">"Äärised"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Võta tagasi"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Tee uuesti"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Kuva rakendatud efektid"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Peida rakendatud efektid"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Kuva ajalugu"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Peida ajalugu"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Kuva pildi olek"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Peida pildi olek"</string>
<string name="menu_settings" msgid="6428291655769260831">"Seaded"</string>
<string name="unsaved" msgid="8704442449002374375">"Kujutisel on salvestamata muudatusi."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Kas soovite enne väljumist salvestada?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Värvi valimine"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Suuruse valimine"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Algne"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Tulemus"</string>
</resources>
diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml
index 5405607..7873ccd 100644
--- a/res/values-et/strings.xml
+++ b/res/values-et/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Pööra paremale"</string>
<string name="no_such_item" msgid="5315144556325243400">"Üksust ei leitud."</string>
<string name="edit" msgid="1502273844748580847">"Muuda"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Lihtne muutmine"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Vahemällu lisamise taotluste töötlemine"</string>
<string name="caching_label" msgid="4521059045896269095">"Vahemällu ..."</string>
<string name="crop_action" msgid="3427470284074377001">"Kärbi"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Tagasi"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Eestvaade"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Talletuse asukoht"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"ASUKOHT"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Iseavaja taimer"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 sekund"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kaamera seaded"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Videokaamera seaded"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Pildi suurus"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapikslit"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapikslit"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M pikslit"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapikslit"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M pikslit"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M pikslit"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 Mpiks. (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3M pikslit"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M pikslit"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automaatne"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Lõpmatus"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMAATNE"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"LÕPMATUS"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Välgurežiim"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"VÄLGUREŽIIM"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automaatne"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Sees"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Väljas"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMAATVÄLK"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"VÄLK ON SEES"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"VÄLK ON VÄLJAS"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Valge tasakaal"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"VALGE TASAKAAL"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automaatne"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Hõõglamp"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Päevavalgus"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Päevavalguslamp"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Pilves"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMAATNE"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"HÕÕGLAMP"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"PÄEVAVALGUS"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"PÄEVAVALGUSLAMP"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"PILVINE"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Stseenirežiim"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automaatne"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Öö"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Päikeseloojang"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Pidu"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"PUUDUB"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"TOIMING"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"ÖÖ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"PÄIKESELOOJANG"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"PIDU"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"PÖÖRDLOENDUSTAIMER"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TAIMER VÄLJA"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUND"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDIT"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUNDIT"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUNDIT"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Seda ei saa stseenirežiimis valida."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Säriaeg"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"SÄRIAEG"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ESIKAAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"TAGAKAAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Teie USB-mäluseadme ruum on otsa saamas. Muutke kvaliteediseadeid või kustutage kujutisi või teisi faile."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Teie SD-kaardi ruum on otsa saamas. Muutke kvaliteedi seadeid või kustutage kujutisi või teisi faile."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Arvustuse tühistamine"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Arvustus valmis"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Uue võtte ülevaade"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Esita videot"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Peata video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Laadi video uuesti"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Videomängija ajariba"</string>
<string name="capital_on" msgid="5491353494964003567">"SEES"</string>
<string name="capital_off" msgid="7231052688467970897">"VÄLJAS"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Väljas"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Otsing"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotod"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumid"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ROHKEM VALIKUID"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"SEADED"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotot"</item>
diff --git a/res/values-fa/filtershow_strings.xml b/res/values-fa/filtershow_strings.xml
index 4ac82a6..7c5872d 100644
--- a/res/values-fa/filtershow_strings.xml
+++ b/res/values-fa/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"تنظیم تصویر زمینه"</string>
- <string name="download_failure" msgid="5923323939788582895">"دانلود عکس انجام نشد. شبکه در دسترس نیست."</string>
<string name="original" msgid="3524493791230430897">"اصلی"</string>
<string name="borders" msgid="2067345080568684614">"حاشیهها"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"لغو عمل"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"انجام مجدد"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"نمایش جلوههای اعمال شده"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"پنهان کردن جلوههای اعمال شده"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"نمایش سابقه"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"پنهان کردن سابقه"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"نمایش وضعیت تصویر"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"پنهان کردن وضعیت تصویر"</string>
<string name="menu_settings" msgid="6428291655769260831">"تنظیمات"</string>
<string name="unsaved" msgid="8704442449002374375">"تغییرات ذخیره نشدهای در این تصویر وجود دارد."</string>
<string name="save_before_exit" msgid="2680660633675916712">"آیا میخواهید پیش از خروج تغییرات ذخیره شود؟"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"رنگ را انتخاب کنید"</string>
<string name="draw_size_title" msgid="3121649039610273977">"انتخاب اندازه"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"تأیید"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"اصلی"</string>
- <string name="state_panel_result" msgid="318640531123298676">"نتیجه"</string>
</resources>
diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml
index f9df9f8..200e41e 100644
--- a/res/values-fa/strings.xml
+++ b/res/values-fa/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"چرخش به راست"</string>
<string name="no_such_item" msgid="5315144556325243400">"مورد یافت نشد."</string>
<string name="edit" msgid="1502273844748580847">"ویرایش"</string>
- <string name="simple_edit" msgid="2792835918347498211">"ویرایش ساده"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"پردازش درخواستهای ذخیره در حافظهٔ پنهان"</string>
<string name="caching_label" msgid="4521059045896269095">"در حال ذخیره در حافظهٔ پنهان..."</string>
<string name="crop_action" msgid="3427470284074377001">"برش"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"برگشت"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"جلو"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"ذخیره موقعیت مکانی"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"موقعیت مکانی"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"تایمر شمارش معکوس"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"۱ ثانیه"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"تنظیمات دوربین"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"تنظیمات دوربین فیلمبرداری"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"اندازه تصویر"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"۱۳ مگا پیکسل"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"۸ مگاپیکسل"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"۵ مگاپیکسل"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"۴ مگاپیکسل"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"۳ مگاپیکسل"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"۲ مگاپیکسل"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"۲ مگاپیکسل (۱۶:۹)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"۱.۳ مگاپیکسل"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"۱ مگاپیکسل"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"خودکار"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"بی نهایت"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"ماکرو"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"خودکار"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"بینهایت"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"ماکرو"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"حالت فلاش"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"حالت فلاش"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"خودکار"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"روشن"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"خاموش"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"فلاش خودکار"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"فلاش روشن"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"فلاش خاموش"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"توازن سفیدی"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"توازن سفیدی"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"خودکار"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"تابان"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"روشنایی روز"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"فلورسنت"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"ابری"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"خودکار"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"تابان"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"روشنایی روز"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"فلورسنت"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ابری"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"حالت منظره"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"خودکار"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"شب"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"غروب آفتاب"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"طرف مقابل"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"هیچکدام"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"عملکرد"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"شب"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"غروب"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"مهمانی"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"تایمر شمارش معکوس"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"تایمر خاموش است"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"۱ ثانیه"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"۳ ثانیه"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"۱۰ ثانیه"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"۱۵ ثانیه"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"در حالت صحنه قابل انتخاب نیست."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"نوردهی"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"نوردهی"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"دوربین جلو"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"دوربین پشت"</string>
<string name="dialog_ok" msgid="6263301364153382152">"تأیید"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"حافظهٔ USB پر است. تنظیمات کیفیت را تغییر دهید یا برخی تصاویر یا سایر فایلها را حذف کنید."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"کارت SD شما پر شده است. تنظیمات کیفیت را تغییر دهید یا برخی تصاویر یا فایلهای دیگر را حذف کنید."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"لغو بازبینی"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"بازبینی انجام شد"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"بازبینی عکس مجدد"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"پخش ویدیو"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"توقف موقت ویدیو"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"تازهسازی ویدیو"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"نوار زمان پخشکننده ویدیو"</string>
<string name="capital_on" msgid="5491353494964003567">"روشن"</string>
<string name="capital_off" msgid="7231052688467970897">"خاموش"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"خاموش"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"جستجو"</string>
<string name="tab_photos" msgid="9110813680630313419">"عکسها"</string>
<string name="tab_albums" msgid="8079449907770685691">"آلبومها"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"گزینههای بیشتر"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"تنظیمات"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d عکس"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d عکس "</item>
diff --git a/res/values-fi/filtershow_strings.xml b/res/values-fi/filtershow_strings.xml
index 1a9c569..0ad3542 100644
--- a/res/values-fi/filtershow_strings.xml
+++ b/res/values-fi/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Asetetaan taustakuvaa"</string>
- <string name="download_failure" msgid="5923323939788582895">"Kuvan lataaminen epäonnistui. Verkkoon ei saada yhteyttä."</string>
<string name="original" msgid="3524493791230430897">"Alkuperäinen"</string>
<string name="borders" msgid="2067345080568684614">"Reunukset"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Kumoa"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Toista"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Näytä käytetyt tehosteet"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Piilota käytetyt tehosteet"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Näytä historia"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Piilota historia"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Näytä kuvan tila"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Piilota kuvan tila"</string>
<string name="menu_settings" msgid="6428291655769260831">"Asetukset"</string>
<string name="unsaved" msgid="8704442449002374375">"Tähän kuvaan on tehty muutoksia, joita ei ole tallennettu."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Haluatko tallentaa ennen sulkemista?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Valitse väri"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Valitse koko"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Alkuperäinen"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Tulos"</string>
</resources>
diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml
index e0d96f8..6617999 100644
--- a/res/values-fi/strings.xml
+++ b/res/values-fi/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Kierrä myötäpäivään"</string>
<string name="no_such_item" msgid="5315144556325243400">"Kohdetta ei löytynyt."</string>
<string name="edit" msgid="1502273844748580847">"Muokkaa"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Yksinkert. muokkaus"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Käsitellään välimuistipyyntöjä"</string>
<string name="caching_label" msgid="4521059045896269095">"Vie välimuist."</string>
<string name="crop_action" msgid="3427470284074377001">"Rajaa"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Takaisin"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Etupuoli"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Tallennussijainti"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"SIJAINTI"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Ajastin"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 sekunti"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kameran asetukset"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Videokameran asetukset"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Kuvan koko"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapikseliä"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapikseliä"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapikseliä"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapikseliä"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapikseliä"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapikseliä"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 megap. (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapiks."</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapikseli"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automaattinen"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Loputon"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMAATTINEN"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"LOPUTON"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Salaman tila"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"SALAMAN TILA"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automaattinen"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Käytössä"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Pois käytöstä"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMAATTINEN SALAMA"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"SALAMA PÄÄLLÄ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"SALAMA POIS"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Valkotasapaino"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"VALKOTASAPAINO"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automaattinen"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Hehkulamppuvalo"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Päivänvalo"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Loisteputkivalo"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Pilvinen"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMAATTINEN"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"HEHKULAMPPUVALO"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"PÄIVÄNVALO"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"LOISTEPUTKIVALO"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"PILVINEN"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Kuvaustila"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automaattinen"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Yö"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Auringonlasku"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Juhlat"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"EI MITÄÄN"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"TOIMINTA"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"YÖ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"AURINGONLASKU"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"JUHLAT"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"AJASTIN"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"AJASTIN EI OLE KÄYTÖSSÄ"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUNTI"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNTIA"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUNTIA"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUNTIA"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Ei valittavissa kuvaustilassa."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Valotus"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"VALOTUS"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ETUKAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"TAKAKAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"USB-tallennustilasi on vähissä. Vaihda laatuasetusta tai poista kuvia tai muita tiedostoja."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"SD-korttisi tila on vähissä. Vaihda laatuasetusta tai poista kuvia tai muita tiedostoja."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Peruuta"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Tarkistus valmis"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Kuvaa uudelleen"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Katso video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Keskeytä video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Lataa video uudelleen"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Videosoittimen aikapalkki"</string>
<string name="capital_on" msgid="5491353494964003567">"KÄYTÖSSÄ"</string>
<string name="capital_off" msgid="7231052688467970897">"POIS KÄYTÖSTÄ"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Pois käytöstä"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Haku"</string>
<string name="tab_photos" msgid="9110813680630313419">"Kuvat"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumit"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"LISÄÄ VAIHTOEHTOJA"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"ASETUKSET"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d valokuva"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d valokuvaa"</item>
diff --git a/res/values-fr/filtershow_strings.xml b/res/values-fr/filtershow_strings.xml
index 8face03..c77817c 100644
--- a/res/values-fr/filtershow_strings.xml
+++ b/res/values-fr/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Définition du fond d\'écran en cours…"</string>
- <string name="download_failure" msgid="5923323939788582895">"Impossible de télécharger la photo. Réseau indisponible."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Contours"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Annuler"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Rétablir"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Afficher les effets appliqués"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Masquer les effets appliqués"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Afficher historique"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Masquer l\'historique"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Afficher état image"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Masquer état image"</string>
<string name="menu_settings" msgid="6428291655769260831">"Paramètres"</string>
<string name="unsaved" msgid="8704442449002374375">"Certaines modifications apportées à l\'image n\'ont pas été enregistrées."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Souhaitez-vous enregistrer les modifications avant de fermer le programme ?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Sélectionner couleur"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Sélectionner la taille"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Image originale"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Résultat"</string>
</resources>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index b556466..d4e9132 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Faire pivoter à droite"</string>
<string name="no_such_item" msgid="5315144556325243400">"Impossible de trouver l\'élément."</string>
<string name="edit" msgid="1502273844748580847">"Retoucher"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Modification simple"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Demandes de mise en cache en cours de traitement"</string>
<string name="caching_label" msgid="4521059045896269095">"Mise en cache…"</string>
<string name="crop_action" msgid="3427470284074377001">"Rogner"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Arrière"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Avant"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Enregist. position"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"POSITION"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Compte à rebours"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 seconde"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Paramètres appareil photo"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Mode Caméra"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Taille d\'image"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 mégapixels"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 mégapixels"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 M pixels"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 Mpx"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 M pixels"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 M pixels"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 Mpx (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 M pixels"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 M pixels"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Auto"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infini"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMATIQUE"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINI"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Mode Flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MODE FLASH"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatique"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Activé"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Désactivé"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH AUTOMATIQUE"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLASH ACTIVÉ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLASH DÉSACTIVÉ"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Balance des blancs"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALANCE DES BLANCS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatique"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Incandescent"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Lumière du jour"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescent"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Nuageux"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMATIQUE"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENT"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"LUMIÈRE DU JOUR"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENT"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"NUAGEUX"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Mode Scène"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatique"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nuit"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Coucher de soleil"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Fête"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"AUCUN"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACTION"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NUIT"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"COUCHER DE SOLEIL"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FÊTE"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"COMPTE À REBOURS"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"MINUTEUR DÉSACTIVÉ"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SECONDE"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SECONDES"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SECONDES"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SECONDES"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Ce paramètre ne peut pas être sélectionné en mode Scène."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Exposition"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOSITION"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CAMÉRA FRONTALE"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CAMÉRA ARRIÈRE"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"La mémoire de stockage USB est pleine. Définissez la qualité sur une valeur plus basse ou supprimez des images ou d\'autres types de fichiers."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Votre carte SD est pleine. Modifiez le paramètre de qualité ou supprimez des images ou des fichiers."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Examen – Annuler"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Examen – OK"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Examiner la deuxième prise de la photo"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Lire la vidéo"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Interrompre la vidéo"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Revoir la vidéo"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Barre chronologique du lecteur vidéo"</string>
<string name="capital_on" msgid="5491353494964003567">"ACTIVÉ"</string>
<string name="capital_off" msgid="7231052688467970897">"DÉSACTIVÉ"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Désactivé"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Recherche"</string>
<string name="tab_photos" msgid="9110813680630313419">"Photos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albums"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"PLUS D\'OPTIONS"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"PARAMÈTRES"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d photo"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d photos"</item>
diff --git a/res/values-hi/filtershow_strings.xml b/res/values-hi/filtershow_strings.xml
index 2516a00..99d5e55 100644
--- a/res/values-hi/filtershow_strings.xml
+++ b/res/values-hi/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"वॉलपेपर सेट हो रहा है"</string>
- <string name="download_failure" msgid="5923323939788582895">"फ़ोटो डाउनलोड नहीं किया जा सका. नेटवर्क अनुपलब्ध है."</string>
<string name="original" msgid="3524493791230430897">"मूल"</string>
<string name="borders" msgid="2067345080568684614">"बॉर्डर"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"पूर्ववत करें"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"फिर से करें"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"लागू प्रभाव दिखाएं"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"लागू प्रभाव छिपाएं"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"इतिहास दिखाएं"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"इतिहास छिपाएं"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"चित्र स्थिति दिखाएं"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"चित्र स्थिति छिपाएं"</string>
<string name="menu_settings" msgid="6428291655769260831">"सेटिंग"</string>
<string name="unsaved" msgid="8704442449002374375">"इस चित्र में न सहेजे गए बदलाव हैं."</string>
<string name="save_before_exit" msgid="2680660633675916712">"क्या आप बाहर निकलने के पहले सहेजना चाहते हैं?"</string>
@@ -39,7 +40,7 @@
<skip />
<string name="imageState" msgid="8632586742752891968">"लागू किए गए प्रभाव"</string>
<string name="compare_original" msgid="8140838959007796977">"तुलना करें"</string>
- <string name="apply_effect" msgid="1218288221200568947">"*"</string>
+ <string name="apply_effect" msgid="1218288221200568947">"लागू करें"</string>
<string name="reset_effect" msgid="7712605581024929564">"रीसेट करें"</string>
<string name="aspect" msgid="4025244950820813059">"पहलू"</string>
<string name="aspect1to1_effect" msgid="1159104543795779123">"1:1"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"रंग चुनें"</string>
<string name="draw_size_title" msgid="3121649039610273977">"आकार चुनें"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"ठीक"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"मूल"</string>
- <string name="state_panel_result" msgid="318640531123298676">"परिणाम"</string>
</resources>
diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml
index e6325a3..3fdaf76 100644
--- a/res/values-hi/strings.xml
+++ b/res/values-hi/strings.xml
@@ -38,7 +38,7 @@
<string name="saving_image" msgid="7270334453636349407">"चित्र सहेज रहा है…"</string>
<string name="filtershow_saving_image" msgid="6659463980581993016">"चित्र <xliff:g id="ALBUM_NAME">%1$s</xliff:g> में सहेजा जा रहा है …"</string>
<string name="save_error" msgid="6857408774183654970">"काट-छांट की गई चित्र को नहीं सहेज सका."</string>
- <string name="crop_label" msgid="521114301871349328">"चित्र काट-छांट करें"</string>
+ <string name="crop_label" msgid="521114301871349328">"चित्र काटें"</string>
<string name="trim_label" msgid="274203231381209979">"वीडियो ट्रिम करें"</string>
<string name="select_image" msgid="7841406150484742140">"फ़ोटो को चुनें"</string>
<string name="select_video" msgid="4859510992798615076">"वीडियो को चुनें"</string>
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"दाएं घुमाएं"</string>
<string name="no_such_item" msgid="5315144556325243400">"आइटम नहीं ढूंढा जा सका."</string>
<string name="edit" msgid="1502273844748580847">"संपादित करें"</string>
- <string name="simple_edit" msgid="2792835918347498211">"सरल संपादन"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"संचय अनुरोध संसाधित कर रहा है"</string>
<string name="caching_label" msgid="4521059045896269095">"संचय कर रहा है..."</string>
<string name="crop_action" msgid="3427470284074377001">"काट-छांट करें"</string>
@@ -107,14 +106,14 @@
<string name="no_location" msgid="4043624857489331676">"कोई स्थान नहीं"</string>
<string name="no_connectivity" msgid="7164037617297293668">"नेटवर्क समस्याओं के कारण कुछ स्थानों को पहचाना नहीं जा सका."</string>
<string name="sync_album_error" msgid="1020688062900977530">"इस एल्बम के फ़ोटो डाउनलोड नहीं किए जा सके. बाद में पुन: प्रयास करें."</string>
- <string name="show_images_only" msgid="7263218480867672653">"केवल चित्र"</string>
+ <string name="show_images_only" msgid="7263218480867672653">"केवल छवियां"</string>
<string name="show_videos_only" msgid="3850394623678871697">"केवल वीडियो"</string>
- <string name="show_all" msgid="6963292714584735149">"चित्र और वीडियो"</string>
+ <string name="show_all" msgid="6963292714584735149">"छवियां और वीडियो"</string>
<string name="appwidget_title" msgid="6410561146863700411">"फ़ोटो गैलरी"</string>
<string name="appwidget_empty_text" msgid="1228925628357366957">"कोई फ़ोटो नहीं."</string>
<string name="crop_saved" msgid="1595985909779105158">"काट-छांट की गई चित्र को <xliff:g id="FOLDER_NAME">%s</xliff:g> में सहेजा गया."</string>
<string name="no_albums_alert" msgid="4111744447491690896">"कोई एल्बम उपलब्ध नहीं."</string>
- <string name="empty_album" msgid="4542880442593595494">"O चित्र/वीडियो उपलब्ध."</string>
+ <string name="empty_album" msgid="4542880442593595494">"O छवियां/वीडियो उपलब्ध."</string>
<string name="picasa_posts" msgid="1497721615718760613">"पोस्ट"</string>
<string name="make_available_offline" msgid="5157950985488297112">"ऑफ़लाइन उपलब्ध कराएं"</string>
<string name="sync_picasa_albums" msgid="8522572542111169872">"रीफ्रेश करें"</string>
@@ -177,7 +176,7 @@
<string name="widget_type_album" msgid="6013045393140135468">"कोई एल्बम चुनें"</string>
<string name="widget_type_shuffle" msgid="8594622705019763768">"सभी छवियों का क्रम बदलें"</string>
<string name="widget_type_photo" msgid="6267065337367795355">"कोई चित्र चुनें"</string>
- <string name="widget_type" msgid="1364653978966343448">"चित्र चुनें"</string>
+ <string name="widget_type" msgid="1364653978966343448">"छवियां चुनें"</string>
<string name="slideshow_dream_name" msgid="6915963319933437083">"स्लाइडशो"</string>
<string name="albums" msgid="7320787705180057947">"एल्बम"</string>
<string name="times" msgid="2023033894889499219">"इतने बार"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"वापस जाएं"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"सामने"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"संग्रह स्थान"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"स्थान"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"काउंटडाउन टाइमर"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 सेकंड"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"कैमरा सेटिंग"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"कैमकॉर्डर सेटिंग"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"चित्र आकार"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M पिक्सेल"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M पिक्सेल"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M पिक्सेल"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M पिक्सेल"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M पिक्सेल"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M पिक्सेल"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M पिक्सेल (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3M पिक्सेल"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M पिक्सेल"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"स्वत:"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"अनंत"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"मैक्रो"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"स्वत:"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"अनंत"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"मैक्रो"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"फ़्लैश मोड"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"फ़्लैश मोड"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"स्वत:"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"चालू"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"बंद"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"फ़्लैश स्वत:"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"फ़्लैश चालू"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"फ़्लैश बंद"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"श्वेत संतुलन"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"श्वेत संतुलन"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"स्वत:"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"अत्यधिक चमकीला"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"दिन का प्रकाश"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"फ़्लोरेसेंट"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"बदली"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"स्वत:"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"अत्यधिक चमकीला"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"दिन का प्रकाश"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"फ़्लोरेसेंट"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"बादलयुक्त"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"दृश्य मोड"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"स्वत:"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,28 +280,13 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"रात्रि"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"सूर्यास्त"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"पार्टी"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"कोई नहीं"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"कार्यवाही"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"रात"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"सूर्यास्त"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"पार्टी"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"काउंटडाउन टाइमर"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"टाइमर बंद"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 सेकंड"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 सेकंड"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 सेकंड"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 सेकंड"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"दृश्य मोड में चयन योग्य नहीं."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"एक्स्पोजर"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"एक्सपोज़र"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"सामने का कैमरा"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"पीछे का कैमरा"</string>
<string name="dialog_ok" msgid="6263301364153382152">"ठीक"</string>
- <string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"आपके USB संग्रहण में स्थान कम है. गुणवत्ता सेटिंग बदलें या कुछ चित्र या अन्य फ़ाइलें हटाएं."</string>
- <string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"आपके SD कार्ड में स्थान कम है. गुणवत्ता सेटिंग बदलें या कुछ चित्र या अन्य फ़ाइलें हटाएं."</string>
+ <string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"आपके USB संग्रहण में स्थान कम है. गुणवत्ता सेटिंग बदलें या कुछ छवियां या अन्य फ़ाइलें हटाएं."</string>
+ <string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"आपके SD कार्ड में स्थान कम है. गुणवत्ता सेटिंग बदलें या कुछ छवियां या अन्य फ़ाइलें हटाएं."</string>
<string name="video_reach_size_limit" msgid="6179877322015552390">"आकार सीमा पहुंची."</string>
<string name="pano_too_fast_prompt" msgid="2823839093291374709">"बहुत तेज़"</string>
<string name="pano_dialog_prepare_preview" msgid="4788441554128083543">"पैनोरामा तैयार हो रहा है"</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"समीक्षा रद्द कर दी गई"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"समीक्षा पूर्ण"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"समीक्षा रीटेक"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"वीडियो चलाएं"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"वीडियो पॉज़ करें"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"वीडियो पुन: लोड करें"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"वीडियो प्लेयर समय बार"</string>
<string name="capital_on" msgid="5491353494964003567">"चालू"</string>
<string name="capital_off" msgid="7231052688467970897">"बंद"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"बंद"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"खोज"</string>
<string name="tab_photos" msgid="9110813680630313419">"फ़ोटो"</string>
<string name="tab_albums" msgid="8079449907770685691">"एल्बम"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"अधिक विकल्प"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"सेटिंग"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d फ़ोटो"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d फ़ोटो"</item>
diff --git a/res/values-hr/filtershow_strings.xml b/res/values-hr/filtershow_strings.xml
index 100a785..7403dd8 100644
--- a/res/values-hr/filtershow_strings.xml
+++ b/res/values-hr/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Postavljanje pozadinske slike"</string>
- <string name="download_failure" msgid="5923323939788582895">"Fotografija nije preuzeta. Mreža nije dostupna."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Obrubi"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Poništi"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Ponovi"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Prikaži primijenjene efekte"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Sakrij primijenjene efekte"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Prikaži povijest"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Sakrij povijest"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Prikaži stanje slike"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Sakrij stanje slike"</string>
<string name="menu_settings" msgid="6428291655769260831">"Postavke"</string>
<string name="unsaved" msgid="8704442449002374375">"Neke promjene slike nisu spremljene."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Želite li spremiti prije nego što iziđete?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Odabir boje"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Odabir veličine"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"U redu"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Izvornik"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Rezultat"</string>
</resources>
diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml
index 2f489ee..3e3c33a 100644
--- a/res/values-hr/strings.xml
+++ b/res/values-hr/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Rotiraj udesno"</string>
<string name="no_such_item" msgid="5315144556325243400">"Nije moguće pronaći stavku."</string>
<string name="edit" msgid="1502273844748580847">"Uredi"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Osnovno uređivanje"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Obrada zahtjeva za predmemoriju"</string>
<string name="caching_label" msgid="4521059045896269095">"U predmemoriju…"</string>
<string name="crop_action" msgid="3427470284074377001">"Obreži"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Natrag"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Naprijed"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Lokacija pohranjivanja"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOKACIJA"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Timer za odbrojavanje"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 sekunda"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Postavke fotoaparata"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Postavke kamere"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Veličina slike"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapiksela"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapiksela"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapiksela"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapiksela"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapiksela"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapiksela"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 mpiks.(16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapiksela"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapiksel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatski"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Beskonačno"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMATSKI"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"BESKONAČNO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Način bljeskalice"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"NAČIN BLJESKALICE"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatski"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Uključeno"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Isključeno"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMATSKA BLJESKALICA"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLJESKALICA UKLJUČENA"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"BLJESKALICA ISKLJUČENA"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Balans bijele boje"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALANS BIJELE"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatski"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Svjetlosni izvor sa žarnom niti"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Dnevno svjetlo"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescentno"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Oblačno"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMATSKI"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"SVJETLOST ŽARULJE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DNEVNO SVJETLO"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENTNO"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"OBLAČNO"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Način scene"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatski"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Noć"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Zalazak sunca"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Zabava"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NIŠTA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"RADNJA"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOĆ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ZALAZAK SUNCA"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ZABAVA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"MJERAČ VREMENA ZA ODBROJAVANJE"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ODBROJAVANJE JE ISKLJUČENO"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUNDA"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDE"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUNDI"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUNDI"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"U načinu scene ne može se odabirati."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Ekspozicija"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EKSPOZICIJA"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"VDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"PREDNJI FOTOAPARAT"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"STRAŽNJI FOTOAPARAT"</string>
<string name="dialog_ok" msgid="6263301364153382152">"U redu"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Na vašoj USB memoriji ponestaje prostora. Primijenite postavku kvalitete ili izbrišite neke slike ili druge datoteke."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Na vašoj kartici SD ponestaje prostora. Primijenite postavku kvalitete ili izbrišite neke slike ili druge datoteke."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Odustani"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Završeno"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Ponovi snimanje u pregledu"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Reproduciraj videozapis"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pauziraj videozapis"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Ponovno učitaj videozapis"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Vremenska traka reprodukcije videozapisa"</string>
<string name="capital_on" msgid="5491353494964003567">"UKLJUČI"</string>
<string name="capital_off" msgid="7231052688467970897">"ISKLJUČI"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Isključeno"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Pretraživanje"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotografije"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumi"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"DODATNE OPCIJE"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"POSTAVKE"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d slika"</item>
<item quantity="other" msgid="3813306834113858135">"Br. slika: %1$d"</item>
diff --git a/res/values-hu/filtershow_strings.xml b/res/values-hu/filtershow_strings.xml
index 1674b2c..769c62b 100644
--- a/res/values-hu/filtershow_strings.xml
+++ b/res/values-hu/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Háttérkép beállítása"</string>
- <string name="download_failure" msgid="5923323939788582895">"A fénykép letöltése nem sikerült. A hálózat nem érhető el."</string>
<string name="original" msgid="3524493791230430897">"Eredeti"</string>
<string name="borders" msgid="2067345080568684614">"Szegélyek"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Visszavonás"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Ismétlés"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Alkalmazott effektek"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Alkalmazott effektek elrejtése"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Előzmények"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Előzmények elrejtése"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Képállapot"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Állapot elrejtés"</string>
<string name="menu_settings" msgid="6428291655769260831">"Beállítások"</string>
<string name="unsaved" msgid="8704442449002374375">"Nem mentett módosítások vannak a képen."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Szeretne menteni a kilépés előtt?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Szín kiválasztása"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Méret kiválasztása"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Eredeti"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Eredmény"</string>
</resources>
diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml
index 368f87d..b348679 100644
--- a/res/values-hu/strings.xml
+++ b/res/values-hu/strings.xml
@@ -40,7 +40,7 @@
<string name="save_error" msgid="6857408774183654970">"Nem lehet menteni a vágott képet."</string>
<string name="crop_label" msgid="521114301871349328">"Kép levágása"</string>
<string name="trim_label" msgid="274203231381209979">"Videó vágása"</string>
- <string name="select_image" msgid="7841406150484742140">"Fotó kiválasztása"</string>
+ <string name="select_image" msgid="7841406150484742140">"Fénykép kiválasztása"</string>
<string name="select_video" msgid="4859510992798615076">"Videó kiválasztása"</string>
<string name="select_item" msgid="2816923896202086390">"Elem kiválasztása"</string>
<string name="select_album" msgid="1557063764849434077">"Album kiválasztása"</string>
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Forgatás jobbra"</string>
<string name="no_such_item" msgid="5315144556325243400">"Nem található az elem."</string>
<string name="edit" msgid="1502273844748580847">"Szerkesztés"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Egyszerű szerkesztés"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Tárolási kérelmek feldolgozása"</string>
<string name="caching_label" msgid="4521059045896269095">"Gyorsítótárazás..."</string>
<string name="crop_action" msgid="3427470284074377001">"Körbevágás"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Vissza"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Előre néző"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Hely tárolása"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"HELY"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Visszaszámlálás-időzítő"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 másodperc"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kamera beállításai"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Videokamera beállításai"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Képméret"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapixel"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapixel"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapixel"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapixel"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapixel"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapixel"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 MP (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapixel"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatikus"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Végtelen"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makró"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMATIKUS"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"VÉGTELEN"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRÓ"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Vakumód"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"VAKU MÓD"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatikus"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Be"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Ki"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMATIKUS VAKU"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"VAKU BEKAPCSOLVA"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"VAKU KIKAPCSOLVA"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Fehéregyensúly"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"FEHÉREGYENSÚLY"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatikus"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Izzólámpa"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Nappali fény"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fénycső"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Felhős"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMATIKUS"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"IZZÓLÁMPA"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"NAPPALI FÉNY"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FÉNYCSŐ"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"FELHŐS"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Kép jellege"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatikus"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Éjszakai"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Napnyugta"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Buli"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"EGYIK SEM"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"AKCIÓ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"ÉJSZAKA"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"NAPNYUGTA"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"BULI"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"VISSZASZÁMLÁLÁS-IDŐZÍTŐ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"IDŐZÍTŐ KI"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 MÁSODPERC"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 MÁSODPERC"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 MÁSODPERC"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 MÁSODPERC"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Nem választható ebben a módban."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Megvilágítás"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPONÁLÁS"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ELÜLSŐ KAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"HÁTSÓ KAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Az USB-táron kezd elfogyni a hely. Módosítsa a minőségi beállításokat, vagy töröljön néhány képet vagy egyéb fájlt."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Az SD-kártyán kezd elfogyni a hely. Módosítsa a minőségi beállításokat, vagy töröljön néhány képet vagy egyéb fájlt."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Törlés"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Kész"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Ellenőrzés – új felvétel"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Videó lejátszása"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Videó szüneteltetése"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Videó újratöltése"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Videolejátszó idősávja"</string>
<string name="capital_on" msgid="5491353494964003567">"BE"</string>
<string name="capital_off" msgid="7231052688467970897">"KI"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Ki"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Keresés"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotók"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumok"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"TOVÁBBI LEHETŐSÉGEK"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"BEÁLLÍTÁSOK"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d fotó"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotó"</item>
diff --git a/res/values-in/filtershow_strings.xml b/res/values-in/filtershow_strings.xml
index 6e2ae2d..fe03370 100644
--- a/res/values-in/filtershow_strings.xml
+++ b/res/values-in/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Menyetel wallpaper"</string>
- <string name="download_failure" msgid="5923323939788582895">"Tidak dapat mengunduh foto. Jaringan tidak tersedia."</string>
<string name="original" msgid="3524493791230430897">"Asli"</string>
<string name="borders" msgid="2067345080568684614">"Batas"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Batalkan"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Ulangi"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Tampilkan Efek yang Diterapkan"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Sembunyikan Efek yang Diterapkan"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Tampilkan Riwayat"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Sembunyikan Riwayat"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Tampilkan Status"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Sembunyikan Status"</string>
<string name="menu_settings" msgid="6428291655769260831">"Setelan"</string>
<string name="unsaved" msgid="8704442449002374375">"Ada perubahan yang belum tersimpan pada gambar ini."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Ingin menyimpan sebelum keluar?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Pilih Warna"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Pilih Ukuran"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"Oke"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Asli"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Hasil"</string>
</resources>
diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml
index e7b86df..e282fbe 100644
--- a/res/values-in/strings.xml
+++ b/res/values-in/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Putar ke kanan"</string>
<string name="no_such_item" msgid="5315144556325243400">"Tidak dapat menemukan item."</string>
<string name="edit" msgid="1502273844748580847">"Edit"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Edit Sederhana"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Memproses permintaan menyimpan ke cache"</string>
<string name="caching_label" msgid="4521059045896269095">"Smpn ke tmbolok"</string>
<string name="crop_action" msgid="3427470284074377001">"Pangkas"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Belakang"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Depan"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Lokasi penyimpanan"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOKASI"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Penghitung mundur"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 detik"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Setelan kamera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Setelan perekam video"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Ukuran gambar"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M piksel"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M piksel"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 M piksel"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M piksel"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 M piksel"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 M piksel"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M piksel (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 M piksel"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 M piksel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Otomatis"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Ketakterbatasan"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"OTOMATIS"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"TAK TERBATAS"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Mode lampu kilat"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MODE LAMPU KILAT"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Otomatis"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Pada"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Mati"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"LAMPU KILAT OTOMATIS"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"LAMPU KILAT NYALA"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"LAMPU KILAT MATI"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Keseimbangan putih"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"KESEIMBANGAN PUTIH"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Otomatis"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Berpijar"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Siang Hari"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluoresens"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Berawan"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"OTOMATIS"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"BERPIJAR"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"SIANG HARI"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESENS"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"BERAWAN"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Mode adegan"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Otomatis"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Malam"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Matahari terbenam"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Pesta"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"TIDAK ADA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"TINDAKAN"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"MALAM"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"MATAHARI TERBENAM"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"PESTA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"PENGHITUNG WAKTU MUNDUR"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"PENGHITUNG WAKTU NONAKTIF"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 DETIK"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 DETIK"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 DETIK"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 DETIK"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Tidak dapat dipilih dalam mode adegan."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Pencahayaan"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"PENCAHAYAAN"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"KAMERA DEPAN"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"KAMERA BELAKANG"</string>
<string name="dialog_ok" msgid="6263301364153382152">"Oke"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Penyimpanan USB Anda kehabisan ruang kosong. Ubah setelan kualitas atau hapus beberapa gambar atau file lain."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Kartu SD Anda kehabisan ruang kosong. Ubah setelan kualitas atau hapus beberapa gambar atau file lain."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Tinjauan dibatalkan"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Tinjauan selesai"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Tinjau pengambilan ulang"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Putar video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Jeda video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Muat ulang video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Bilah waktu pemutar video"</string>
<string name="capital_on" msgid="5491353494964003567">"NYALA"</string>
<string name="capital_off" msgid="7231052688467970897">"MATI"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Nonaktif"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Telusuri"</string>
<string name="tab_photos" msgid="9110813680630313419">"Foto"</string>
<string name="tab_albums" msgid="8079449907770685691">"Album"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"OPSI LAINNYA"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"SETELAN"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d foto"</item>
diff --git a/res/values-it/filtershow_strings.xml b/res/values-it/filtershow_strings.xml
index 1336819..39edea7 100644
--- a/res/values-it/filtershow_strings.xml
+++ b/res/values-it/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Impostazione dello sfondo"</string>
- <string name="download_failure" msgid="5923323939788582895">"Impossibile scaricare la foto. Rete non disponibile."</string>
<string name="original" msgid="3524493791230430897">"Originale"</string>
<string name="borders" msgid="2067345080568684614">"Bordi"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Annulla"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Ripeti"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Mostra effetti applicati"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Nascondi effetti applicati"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Mostra cronologia"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Nascondi cronologia"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Mostra stato immagine"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Nascondi stato img"</string>
<string name="menu_settings" msgid="6428291655769260831">"Impostazioni"</string>
<string name="unsaved" msgid="8704442449002374375">"L\'immagine ha modifiche non salvate."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Vuoi salvare prima di uscire?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Seleziona colore"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Seleziona dimensioni"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Originale"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Risultato"</string>
</resources>
diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml
index 9345a45..a3cbf32 100644
--- a/res/values-it/strings.xml
+++ b/res/values-it/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Ruota a destra"</string>
<string name="no_such_item" msgid="5315144556325243400">"Impossibile trovare l\'elemento."</string>
<string name="edit" msgid="1502273844748580847">"Modifica"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Modifica semplice"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Elaborazione richieste memorizzazione cache"</string>
<string name="caching_label" msgid="4521059045896269095">"Memorizzazione..."</string>
<string name="crop_action" msgid="3427470284074377001">"Ritaglia"</string>
@@ -180,7 +179,7 @@
<string name="widget_type" msgid="1364653978966343448">"Scegli immagini"</string>
<string name="slideshow_dream_name" msgid="6915963319933437083">"Presentazione"</string>
<string name="albums" msgid="7320787705180057947">"Album"</string>
- <string name="times" msgid="2023033894889499219">"Data"</string>
+ <string name="times" msgid="2023033894889499219">"Volte"</string>
<string name="locations" msgid="6649297994083130305">"Luoghi"</string>
<string name="people" msgid="4114003823747292747">"Persone"</string>
<string name="tags" msgid="5539648765482935955">"Tag"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Posteriore"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Frontale"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Registra località"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOCALITÀ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Timer conto alla rovescia"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 secondo"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Impostazioni fotocamera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Impostazioni videocamera"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Dimensioni foto"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M pixel"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 MP"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 MP"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 Mpixel"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 MP"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 MP"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 Mpixel (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 MP"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 MP"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatica"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinito"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINITO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Modalità flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MODALITÀ FLASH"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatica"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Attiva"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Non attiva"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH AUTO"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLASH ATTIVO"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLASH DISATTIVATO"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Bilanciamento bianco"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BILANCIAMENTO DEL BIANCO"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatico"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Luce incandescenza"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Luce diurna"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Luce neon"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Nuvoloso"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"LUCE INCANDESCENZA"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"LUCE DIURNA"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"LUCE NEON"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"NUVOLOSO"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Modalità scena"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatica"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Notturna"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Tramonto"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Festa"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NESSUNA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"AZIONE"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOTTE"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"TRAMONTO"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FESTA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"TIMER CONTO ALLA ROVESCIA"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TIMER DISATTIVATO"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SECONDO"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SECONDI"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SECONDI"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SECONDI"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Non selezionabile in modalità scena."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Esposizione"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ESPOSIZIONE"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"FOTOCAMERA ANTERIORE"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"FOTOCAMERA POSTERIORE"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Lo spazio dell\'archivio USB si sta esaurendo. Cambia l\'impostazione di qualità o elimina alcune immagini o altri file."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Lo spazio della scheda SD si sta esaurendo. Cambia l\'impostazione di qualità o elimina alcune immagini o altri file."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Annulla verifica"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Verifica terminata"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Scatta/Riprendi di nuovo per recensione"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Riproduci video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Metti in pausa video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Ricarica video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Barra temporale del video player"</string>
<string name="capital_on" msgid="5491353494964003567">"ON"</string>
<string name="capital_off" msgid="7231052688467970897">"OFF"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Non attivo"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Cerca"</string>
<string name="tab_photos" msgid="9110813680630313419">"Foto"</string>
<string name="tab_albums" msgid="8079449907770685691">"Album"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ALTRE OPZIONI"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"IMPOSTAZIONI"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d foto"</item>
diff --git a/res/values-iw/filtershow_strings.xml b/res/values-iw/filtershow_strings.xml
index b584872..79075a5 100644
--- a/res/values-iw/filtershow_strings.xml
+++ b/res/values-iw/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"מגדיר טפט"</string>
- <string name="download_failure" msgid="5923323939788582895">"לא ניתן היה להוריד את התמונה. הרשת לא זמינה."</string>
<string name="original" msgid="3524493791230430897">"מקור"</string>
<string name="borders" msgid="2067345080568684614">"גבולות"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"בטל"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"בצע מחדש"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"הצג אפקטים שהוחלו"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"הסתר אפקטים שהוחלו"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"הצג היסטוריה"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"הסתר היסטוריה"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"הצג מצב תמונה"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"הסתר מצב תמונה"</string>
<string name="menu_settings" msgid="6428291655769260831">"הגדרות"</string>
<string name="unsaved" msgid="8704442449002374375">"יש בתמונה הזו שינויים שלא נשמרו."</string>
<string name="save_before_exit" msgid="2680660633675916712">"האם אתה רוצה לשמור לפני היציאה?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"בחר צבע"</string>
<string name="draw_size_title" msgid="3121649039610273977">"בחר גודל"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"אישור"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"מקור"</string>
- <string name="state_panel_result" msgid="318640531123298676">"תוצאה"</string>
</resources>
diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml
index f40e655..2a73e42 100644
--- a/res/values-iw/strings.xml
+++ b/res/values-iw/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"סובב ימינה"</string>
<string name="no_such_item" msgid="5315144556325243400">"הפריט לא נמצא."</string>
<string name="edit" msgid="1502273844748580847">"ערוך"</string>
- <string name="simple_edit" msgid="2792835918347498211">"עריכה פשוטה"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"מעבד בקשות העברה למטמון"</string>
<string name="caching_label" msgid="4521059045896269095">"מעביר למטמון..."</string>
<string name="crop_action" msgid="3427470284074377001">"חתוך"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"הקודם"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"חזיתית"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"מיקום אחסון"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"מיקום"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"טיימר לספירה לאחור"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"שנייה אחת"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"הגדרות מצלמה"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"הגדרות מצלמת וידאו"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"גודל תמונה"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 מגה פיקסל"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 מגה פיקסל"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 מגה פיקסלים"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 מגה פיקסל"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 מגה פיקסלים"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 מגה פיקסלים"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M פיקסל (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3 מגה פיקסלים"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"מגה פיקסל אחד"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"אוטומטי"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"אינסוף"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"מאקרו"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"אוטומטי"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"אינסוף"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"מאקרו"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"מצב Flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"מצב מבזק"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"אוטומטי"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"מופעל"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"כבוי"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"מבזק אוטומטי"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"מבזק פועל"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"מבזק כבוי"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"איזון לבן"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"איזון לבן"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"אוטומטי"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"זוהר"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"אור יום"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"פלואורסנט"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"מעונן"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"אוטומטי"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"זוהר"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"אור יום"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"פלואורסנט"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"מעונן"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"מצב נוף"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"אוטומטי"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"לילה"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"שקיעה"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"מסיבה"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"ללא"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"פעולה"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"לילה"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"שקיעה"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"מסיבה"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"טיימר לספירה לאחור"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"טיימר כבוי"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"שנייה אחת"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 שניות"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 שניות"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 שניות"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"לא ניתן לבחירה במצב נוף."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"חשיפה"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"חשיפה"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"מצלמה חזיתית"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"מצלמה אחורית"</string>
<string name="dialog_ok" msgid="6263301364153382152">"אישור"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"אוזל המקום באמצעי האחסון מסוג USB. שנה את הגדרת האיכות או מחק כמה תמונות או קבצים אחרים."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"השטח בכרטיס SD אוזל. שנה את הגדרת האיכות או מחק חלק מהתמונות או קבצים אחרים."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"ביטול בדיקה"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"בדיקה בוצעה"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"הצג צילום חוזר"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"הפעל סרטון"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"השהה סרטון"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"טען סרטון מחדש"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"סרגל הזמן של נגן הסרטונים"</string>
<string name="capital_on" msgid="5491353494964003567">"פועל"</string>
<string name="capital_off" msgid="7231052688467970897">"כבוי"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"כבוי"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"חיפוש"</string>
<string name="tab_photos" msgid="9110813680630313419">"תמונות"</string>
<string name="tab_albums" msgid="8079449907770685691">"אלבומים"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"אפשרויות נוספות"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"הגדרות"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"תמונה %1$d"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d תמונות"</item>
diff --git a/res/values-ja/filtershow_strings.xml b/res/values-ja/filtershow_strings.xml
index f7efe4a..447ca7a 100644
--- a/res/values-ja/filtershow_strings.xml
+++ b/res/values-ja/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"壁紙を設定しています"</string>
- <string name="download_failure" msgid="5923323939788582895">"画像をダウンロードできませんでした。ネットワークを使用できません。"</string>
<string name="original" msgid="3524493791230430897">"元の画像"</string>
<string name="borders" msgid="2067345080568684614">"境界"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"元に戻す"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"やり直し"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"適用済みの効果を表示"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"適用済みの効果を非表示"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"履歴を表示する"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"履歴を表示しない"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"画像ステータスを表示"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"画像ステータスを非表示"</string>
<string name="menu_settings" msgid="6428291655769260831">"設定"</string>
<string name="unsaved" msgid="8704442449002374375">"この画像には保存されていない変更があります。"</string>
<string name="save_before_exit" msgid="2680660633675916712">"終了する前に保存しますか?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"色の選択"</string>
<string name="draw_size_title" msgid="3121649039610273977">"サイズの選択"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"元の画像"</string>
- <string name="state_panel_result" msgid="318640531123298676">"結果"</string>
</resources>
diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml
index ab7ca84..c86d932 100644
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"右に回転"</string>
<string name="no_such_item" msgid="5315144556325243400">"アイテムが見つかりませんでした。"</string>
<string name="edit" msgid="1502273844748580847">"編集"</string>
- <string name="simple_edit" msgid="2792835918347498211">"シンプルな編集"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"キャッシュリクエストを処理しています"</string>
<string name="caching_label" msgid="4521059045896269095">"キャッシュ中..."</string>
<string name="crop_action" msgid="3427470284074377001">"トリミング"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"背面"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"前面"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"位置情報を記録する"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"現在地"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"カウントダウンタイマー"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1秒"</item>
@@ -243,7 +241,7 @@
</plurals>
<!-- no translation found for pref_camera_timer_sound_default (7066624532144402253) -->
<skip />
- <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"タイマー時にビープ音"</string>
+ <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"カウントダウン時にビープ音"</string>
<string name="setting_off" msgid="4480039384202951946">"OFF"</string>
<string name="setting_on" msgid="8602246224465348901">"ON"</string>
<string name="pref_video_quality_title" msgid="8245379279801096922">"動画の画質"</string>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"カメラ設定"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"ビデオ録画設定"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"画像サイズ"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13Mピクセル"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8Mピクセル"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5メガピクセル"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4Mピクセル"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3メガピクセル"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2メガピクセル"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2Mピクセル(16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3メガピクセル"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1メガピクセル"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"オート"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"無限遠"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"マクロ"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"オート"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"無限遠"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"マクロ"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"フラッシュモード"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"フラッシュモード"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"オート"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"ON"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"OFF"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"フラッシュオート"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"フラッシュON"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"フラッシュOFF"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"ホワイトバランス"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"ホワイトバランス"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"オート"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"白熱灯"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"昼光"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"蛍光灯"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"曇り"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"オート"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"白熱灯"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"昼光"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"蛍光灯"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"曇り"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"撮影モード"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"オート"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"夜景"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"夕焼け"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"パーティー"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"なし"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"スポーツ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"夜景"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"夕焼け"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"パーティー"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"カウントダウンタイマー"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"タイマーOFF"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1秒"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3秒"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10秒"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15秒"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"撮影モードでは選択できません。"</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"露出"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"露出"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"前面カメラ"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"背面カメラ"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"USBストレージの空き領域が少なくなっています。画質設定を変更するか、画像など一部のファイルを削除してください。"</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"SDカードの空き領域が少なくなっています。画質設定を変更するか、画像などのファイルを一部削除してください。"</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"レビュー - キャンセル"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"レビュー - 完了"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"撮り直しを確認"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"動画を再生"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"動画を一時停止"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"動画を再読み込み"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"動画プレーヤーのタイムバー"</string>
<string name="capital_on" msgid="5491353494964003567">"ON"</string>
<string name="capital_off" msgid="7231052688467970897">"OFF"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"OFF"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"検索"</string>
<string name="tab_photos" msgid="9110813680630313419">"写真"</string>
<string name="tab_albums" msgid="8079449907770685691">"アルバム"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"その他のオプション"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"設定"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d枚の画像"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d枚の画像"</item>
diff --git a/res/values-ko/filtershow_strings.xml b/res/values-ko/filtershow_strings.xml
index 933aa68..6e9f29b 100644
--- a/res/values-ko/filtershow_strings.xml
+++ b/res/values-ko/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"배경화면 설정 중"</string>
- <string name="download_failure" msgid="5923323939788582895">"네트워크를 사용할 수 없기 때문에 사진을 다운로드할 수 없습니다."</string>
<string name="original" msgid="3524493791230430897">"원본"</string>
<string name="borders" msgid="2067345080568684614">"테두리"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"실행취소"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"다시실행"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"적용된 효과 표시"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"적용된 효과 숨기기"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"기록 표시"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"기록 숨기기"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"이미지 상태 표시"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"이미지 상태 숨기기"</string>
<string name="menu_settings" msgid="6428291655769260831">"설정"</string>
<string name="unsaved" msgid="8704442449002374375">"이 이미지에 저장하지 않은 변경사항이 있습니다."</string>
<string name="save_before_exit" msgid="2680660633675916712">"저장하고 나서 종료하시겠습니까?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"색상 선택"</string>
<string name="draw_size_title" msgid="3121649039610273977">"크기 선택"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"확인"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"원본"</string>
- <string name="state_panel_result" msgid="318640531123298676">"결과"</string>
</resources>
diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml
index a60e71e..a6d4a5d 100644
--- a/res/values-ko/strings.xml
+++ b/res/values-ko/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"오른쪽으로 회전"</string>
<string name="no_such_item" msgid="5315144556325243400">"항목을 찾을 수 없습니다."</string>
<string name="edit" msgid="1502273844748580847">"수정"</string>
- <string name="simple_edit" msgid="2792835918347498211">"간편 수정"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"캐시 요청을 처리하는 중"</string>
<string name="caching_label" msgid="4521059045896269095">"캐시하는 중..."</string>
<string name="crop_action" msgid="3427470284074377001">"자르기"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"후방"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"전방"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"위치 저장"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"위치"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"카운트다운 타이머"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1초"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"카메라 설정"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"캠코더 설정"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"사진 크기"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"1300만 화소"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M 픽셀"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M 픽셀"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4백만 화소"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M 픽셀"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M 픽셀"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2백만 화소(16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3M 픽셀"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M 픽셀"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"자동"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"무한"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"매크로"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"자동"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"무한"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"매크로"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"플래시 모드"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"플래시 모드"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"자동"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"ON"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"OFF"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"자동 플래시"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"플래시 사용"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"플래시 사용 안함"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"화이트 밸런스"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"화이트 밸런스"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"자동"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"백열"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"일광"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"형광"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"흐림"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"자동"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"백열"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"일광"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"형광"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"흐림"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"장면 모드"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"자동"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"야간"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"일몰"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"파티"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"없음"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"작업"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"밤"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"일몰"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"파티"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"카운트다운 타이머"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"타이머 중지"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1초"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3초"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10초"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15초"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"장면 모드에서 선택할 수 없습니다."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"노출"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"노출"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"전방 카메라"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"후방 카메라"</string>
<string name="dialog_ok" msgid="6263301364153382152">"확인"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"USB 저장장치의 공간이 부족합니다. 화질 설정을 변경하거나 일부 이미지 또는 기타 파일을 삭제하세요."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"SD 카드의 공간이 부족합니다. 화질 설정을 변경하거나 일부 이미지 또는 기타 파일을 삭제하세요."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"리뷰 취소"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"리뷰 완료"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"다시 찍기 검토"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"동영상 재생"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"동영상 일지중지"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"동영상 새로고침"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"동영상 플레이어 시간 표시 막대"</string>
<string name="capital_on" msgid="5491353494964003567">"ON"</string>
<string name="capital_off" msgid="7231052688467970897">"OFF"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"사용 안함"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"검색"</string>
<string name="tab_photos" msgid="9110813680630313419">"사진"</string>
<string name="tab_albums" msgid="8079449907770685691">"앨범"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"옵션 더보기"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"설정"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"사진 %1$d장"</item>
<item quantity="other" msgid="3813306834113858135">"사진 %1$d장"</item>
diff --git a/res/values-large/filtershow_values.xml b/res/values-large/filtershow_values.xml
index 1098ee0..33b8642 100644
--- a/res/values-large/filtershow_values.xml
+++ b/res/values-large/filtershow_values.xml
@@ -17,4 +17,16 @@
<resources>
<!-- Specify the screen orientation -->
<bool name="only_use_portrait">false</bool>
+
+ <!-- Category Panel Height -->
+ <dimen name="category_panel_height">94dip</dimen>
+
+ <!-- Category Panel Icon Size -->
+ <dimen name="category_panel_icon_size">72dip</dimen>
+
+ <!-- Category Panel Text Size -->
+ <dimen name="category_panel_text_size">14dip</dimen>
+
+ <!-- Category Panel Text Size -->
+ <dimen name="category_panel_margin">4dip</dimen>
</resources>
\ No newline at end of file
diff --git a/res/values-lt/filtershow_strings.xml b/res/values-lt/filtershow_strings.xml
index d41d751..6a884b9 100644
--- a/res/values-lt/filtershow_strings.xml
+++ b/res/values-lt/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Nustatomas ekrano fonas"</string>
- <string name="download_failure" msgid="5923323939788582895">"Nepavyko atsisiųsti nuotraukos. Tinklas nepasiekiamas."</string>
<string name="original" msgid="3524493791230430897">"Originalas"</string>
<string name="borders" msgid="2067345080568684614">"Kraštinės"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Anuliuoti"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Grąžinti"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Rodyti pritaikytus efektus"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Slėpti pritaikytus efektus"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Rodyti istoriją"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Slėpti istoriją"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Rodyti vaizdo būseną"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Slėpti vaizdo būseną"</string>
<string name="menu_settings" msgid="6428291655769260831">"Nustatymai"</string>
<string name="unsaved" msgid="8704442449002374375">"Yra neišsaugotų šio vaizdo pakeitimų."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Ar norite išsaugoti prieš išeidami?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Pasirinkti spalvą"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Pasirinkti dydį"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"Gerai"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Originalus"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Rezultatas"</string>
</resources>
diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml
index 228aa63..b36c6e7 100644
--- a/res/values-lt/strings.xml
+++ b/res/values-lt/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Sukti į dešinę"</string>
<string name="no_such_item" msgid="5315144556325243400">"Nepavyko surasti elemento."</string>
<string name="edit" msgid="1502273844748580847">"Redaguoti"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Papr. redagavimas"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Talpinimo užklausų apdorojimas"</string>
<string name="caching_label" msgid="4521059045896269095">"Talpinama…"</string>
<string name="crop_action" msgid="3427470284074377001">"Apkarpyti"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Atgal"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Šriftas"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Išsaugoti vietą"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"VIETOVĖ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Atvirkštinis laikmatis"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 sek."</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Fotoaparato nustatymai"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Nešiojamosios vaizdo kameros ir magnetofono nustatymai"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Paveikslėlio dydis"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapiks."</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapiks."</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 mln. piks."</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapikseliai"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 mln. piks."</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 mln. piks."</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 megap. (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 mln. piks."</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 mln. piks."</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatiškai"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Begalybė"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makrokomanda"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMATINIS"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"BEGALYBĖ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKROKOMANDA"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"„Flash“ režimas"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"BLYKSTĖS REŽIMAS"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatiškai"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Įjungta"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Išjungta"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMATINĖ BLYKSTĖ"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLYKSTĖ ĮJUNGTA"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"BLYKSTĖ IŠJUNGTA"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Baltos spalvos balansas"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALTOS SPALVOS BALANSAS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatiškai"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Akinančiai skaistus"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Dienos šviesa"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescencinis"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Debesuota"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMATINIS"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"AKINANČIAI SKAISTUS"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DIENOS ŠVIESA"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENCINIS"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"DEBESUOTA"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scenų režimas"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatiškai"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Naktis"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Saulėlydis"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Vakarėlis"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NĖRA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"VEIKSMAS"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NAKTIS"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SAULĖLYDIS"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"VAKARĖLIS"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ATVIRKŠTINIS LAIKMATIS"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"IŠJUNGTI LAIKMATĮ"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEK."</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEK."</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEK."</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEK."</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Negalima pasirinkti, kai veikia scenos režimas."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Išlaikymas"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"IŠLAIKYMAS"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"PRIEKINIS FOTOAPARATAS"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"UŽPAKALINIS FOTOAPARATAS"</string>
<string name="dialog_ok" msgid="6263301364153382152">"Gerai"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"USB atmintinėje trūksta vietos. Pakeiskite kokybės nustatymą arba ištrinkite kelis vaizdus ar kitus failus."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"SD kortelėje trūksta vietos. Pakeiskite kokybės nustatymą arba ištrinkite kelis vaizdus ar kitus failus."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Atšaukimas peržiūros režimu"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Atlikta peržiūros režimu"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Peržiūrėti / fotografuoti arba filmuoti iš naujo"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Leisti vaizdo įrašą"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pristabdyti vaizdo įrašą"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Įkelti vaizdo įrašą iš naujo"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Vaizdo įrašų grotuvo laiko juosta"</string>
<string name="capital_on" msgid="5491353494964003567">"ĮJUNGTA"</string>
<string name="capital_off" msgid="7231052688467970897">"IŠJUNGTA"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Išj."</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Paieška"</string>
<string name="tab_photos" msgid="9110813680630313419">"Nuotraukos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumai"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"DAUGIAU PARINKČIŲ"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"NUSTATYMAI"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"Nuotraukų: %1$d"</item>
<item quantity="other" msgid="3813306834113858135">"Nuotraukų: %1$d"</item>
diff --git a/res/values-lv/filtershow_strings.xml b/res/values-lv/filtershow_strings.xml
index a8593d2..cf2ffc1 100644
--- a/res/values-lv/filtershow_strings.xml
+++ b/res/values-lv/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Notiek fona tapetes iestatīšana"</string>
- <string name="download_failure" msgid="5923323939788582895">"Nevarēja lejupielādēt fotoattēlu. Tīkls nav pieejams."</string>
<string name="original" msgid="3524493791230430897">"Oriģināls"</string>
<string name="borders" msgid="2067345080568684614">"Robežas"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Atsaukt"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Atcelt atsaukšanu"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Rādīt lietotos efektus"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Slēpt lietotos efektus"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Rādīt vēsturi"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Slēpt vēsturi"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Rādīt attēla statusu"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Slēpt attēla statusu"</string>
<string name="menu_settings" msgid="6428291655769260831">"Iestatījumi"</string>
<string name="unsaved" msgid="8704442449002374375">"Šajā attēlā ir veiktas izmaiņas, kas nav saglabātas."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Vai vēlaties saglabāt pirms iziešanas?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Krāsas atlase"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Izmēru atlase"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"Labi"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Sākotnējais"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Rezultāts"</string>
</resources>
diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml
index 25a9194..04385ba 100644
--- a/res/values-lv/strings.xml
+++ b/res/values-lv/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Pagriezt pa labi"</string>
<string name="no_such_item" msgid="5315144556325243400">"Nevarēja atrast vienumu."</string>
<string name="edit" msgid="1502273844748580847">"Rediģēt"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Parauga rediģēšana"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Tiek apstrādāti pieprasījumi rakstīšanai kešatmiņā"</string>
<string name="caching_label" msgid="4521059045896269095">"Glabā kešatm..."</string>
<string name="crop_action" msgid="3427470284074377001">"Apgriezt"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Atpakaļ"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Priekšpuse"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Saglabāt atrašanās vietu"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"ATRAŠANĀS VIETA"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Laika atskaites taimeris"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 sekunde"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kameras iestatījumi"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Videokameras iestatījumi"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Attēla izmērs"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapikseļi"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapikseļi"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapikseļi"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapikseļi"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapikseļi"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapikseļi"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 megap. (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapikseļi"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapikselis"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automātiski"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Bezgalība"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMĀTISKI"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"BEZGALĪBA"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Zibspuldzes režīms"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"ZIBSPULDZES REŽĪMS"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automātiski"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Ieslēgts"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Izslēgt"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMĀTISKĀ ZIBSPULDZE"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"IESLĒGTA ZIBSPULDZE"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"IZSLĒGTA ZIBSPULDZE"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Baltās krāsas balanss"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALTĀ BALANSS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automātiski"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Spožs"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Dienasgaisma"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescējošs"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Mākoņains"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMĀTISKI"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"KVĒLSPULDZE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DIENASGAISMA"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCĒJOŠS"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"MĀKOŅAINS"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Ainas režīms"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automātiski"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nakts"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Saulriets"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Viesības"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NAV"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"SPRAIGA DARBĪBA"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NAKTS"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SAULRIETS"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"BALLĪTE"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"LAIKA ATSKAITES TAIMERIS"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TAIMERIS IR IZSLĒGTS"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUNDE"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDES"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUNDES"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUNDES"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Nevar atlasīt ainavas režīmā."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Ekspozīcija"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EKSPOZĪCIJA"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"AUGSTS DINAMISKAIS DIAPAZONS"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"PRIEKŠĒJĀ KAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"AIZMUGURĒJĀ KAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"Labi"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"USB atmiņa drīz būs pilna. Mainiet kvalitātes iestatījumu vai dzēsiet dažus attēlus vai citus failus."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"SD karte drīz būs pilna. Mainiet kvalitātes iestatījumu vai dzēsiet dažus attēlus vai citus failus."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Atcelt pārskatīšanu"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Pabeigt pārskatīšanu"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Pārskatīt atkārtotu attēlu"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Atskaņot videoklipu"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pārtraukt videoklipa atskaņošanu"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Atkārtoti ielādēt videoklipu"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Videoklipu atskaņotāja laika josla"</string>
<string name="capital_on" msgid="5491353494964003567">"IESLĒGTS"</string>
<string name="capital_off" msgid="7231052688467970897">"IZSLĒGTS"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Beidzies"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Meklēt"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotoattēli"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumi"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"CITAS OPCIJAS"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"IESTATĪJUMI"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d fotoattēls"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotoattēli"</item>
diff --git a/res/values-ms/filtershow_strings.xml b/res/values-ms/filtershow_strings.xml
index cac3e7d..e41024f 100644
--- a/res/values-ms/filtershow_strings.xml
+++ b/res/values-ms/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Menetapkan kertas dinding"</string>
- <string name="download_failure" msgid="5923323939788582895">"Tidak dapat memuat turun foto. Rangkaian tidak tersedia."</string>
<string name="original" msgid="3524493791230430897">"Asli"</string>
<string name="borders" msgid="2067345080568684614">"Sempadan"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Buat asal"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Buat semula"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Tunjukkan Kesan Digunakan"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Sembunyikan Kesan Digunakan"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Tunjukkan Sejarah"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Sembunyikan Sejarah"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Tunjukkan Keadaan Imej"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Sembunyikan Keadaan Imej"</string>
<string name="menu_settings" msgid="6428291655769260831">"Tetapan"</string>
<string name="unsaved" msgid="8704442449002374375">"Terdapat perubahan kepada imej ini yang tidak disimpan."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Adakah anda ingin simpan sebelum keluar?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Pilih Warna"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Pilih Saiz"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Asal"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Hasil"</string>
</resources>
diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml
index e27eed3..b1ed9b3 100644
--- a/res/values-ms/strings.xml
+++ b/res/values-ms/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Putar ke kanan"</string>
<string name="no_such_item" msgid="5315144556325243400">"Tidak dapat mencari item."</string>
<string name="edit" msgid="1502273844748580847">"Edit"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Edit Ringkas"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Memproses permintaan cache"</string>
<string name="caching_label" msgid="4521059045896269095">"Mengcache..."</string>
<string name="crop_action" msgid="3427470284074377001">"Pangkas"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Belakang"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Depan"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Lokasi stor"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOKASI"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Pemasa hitung detik"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 saat"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Tetapan kamera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Tetapan kamkorder"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Saiz gambar"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M piksel"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"Piksel 8M"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M piksel"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M piksel"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M piksel"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M piksel"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M piksel (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3M piksel"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M piksel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Auto"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infiniti"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINITI"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Mod denyar"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MOD DENYAR"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Auto"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Hidup"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Mati"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTO DENYAR"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"HIDUPKAN DENYAR"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"MATIKAN DENYAR"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Imbangan putih"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"IMBANGAN PUTIH"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Auto"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Berpijar"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Siang hari"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Pendarfluor"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Mendung"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"PIJAR"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"SIANG HARI"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"PENDARFLUOR"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"MENDUNG"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Mod pemandangan"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Auto"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Malam"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Matahari Terbenam"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Parti"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"TIADA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"TINDAKAN"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"MALAM"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"MATAHARI TERBENAM"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"PARTI"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"PEMASA HITUNG DETIK"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"PEMASA DIMATIKAN"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SAAT"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SAAT"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SAAT"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SAAT"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Tidak boleh dipilih dalam mod pemandangan."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Dedahan"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"DEDAHAN"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"KAMERA DEPAN"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"KAMERA BELAKANG"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Storan USB anda kehabisan ruang. Tukar tetapan mutu atau padamkan beberapa imej atau fail lain."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Kad SD anda kehabisan ruang. Tukar tetapan mutu atau padamkan beberapa imej atau fail lain."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Semakan dibatalkan"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Semakan selesai"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Semak penggambaran semula"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Mainkan video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Jeda video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Muat semula video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Bar masa pemain video"</string>
<string name="capital_on" msgid="5491353494964003567">"HIDUPKAN"</string>
<string name="capital_off" msgid="7231052688467970897">"MATIKAN"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Dimatikan"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Cari"</string>
<string name="tab_photos" msgid="9110813680630313419">"Foto"</string>
<string name="tab_albums" msgid="8079449907770685691">"Album"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"LAGI PILIHAN"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"TETAPAN"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d foto"</item>
diff --git a/res/values-nb/filtershow_strings.xml b/res/values-nb/filtershow_strings.xml
index 2fe1324..82af248 100644
--- a/res/values-nb/filtershow_strings.xml
+++ b/res/values-nb/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Angir bakgrunn …"</string>
- <string name="download_failure" msgid="5923323939788582895">"Kunne ikke laste ned bildet. Nettverket er utilgjengelig."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Kantlinjer"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Angre"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Gjør om"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Vis brukte effekter"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Skjul brukte effekter"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Vis loggen"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Skjul loggen"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Vis bildetilstanden"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Skjul bildetilstanden"</string>
<string name="menu_settings" msgid="6428291655769260831">"Innstillinger"</string>
<string name="unsaved" msgid="8704442449002374375">"Det er ulagrede endringer i dette bildet."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Vil du lagre før du avslutter?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Velg farge"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Velg størrelse"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultat"</string>
</resources>
diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml
index d502497..9543f8a 100644
--- a/res/values-nb/strings.xml
+++ b/res/values-nb/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Roter mot høyre"</string>
<string name="no_such_item" msgid="5315144556325243400">"Finner ikke elementet."</string>
<string name="edit" msgid="1502273844748580847">"Rediger"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Enkel redigering"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Behandler forespørsler om bufring"</string>
<string name="caching_label" msgid="4521059045896269095">"Henter …"</string>
<string name="crop_action" msgid="3427470284074377001">"Beskjær"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Bakside"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Forside"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Lagre sted i bilder"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"POSISJON"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Nedtellingstidtaker"</string>
<!-- String.format failed for translation -->
<!-- no translation found for pref_camera_timer_entry:other (6455381617076792481) -->
@@ -251,13 +249,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kamerainnstillinger"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Videoinnstillinger"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Bildestørrelse"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 M piksler"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapiksler"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapiksler"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M piksler"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapiksler"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapiksler"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M piksler (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapiksler"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapiksel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -266,29 +261,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Autofokus"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Uendelig"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"UENDELIG"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Blitzmodus"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"BLITSMODUS"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatisk"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"På"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Av"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMATISK BLITS"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLITS PÅ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"BLITS AV"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Hvitbalanse"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"HVITBALANSE"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatisk"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Flamme"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Dagslys"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Lysstoffrør"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Overskyet"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"HVITGLØDENDE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DAGSLYS"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCERENDE"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"OVERSKYET"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Velg scenemodus"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatisk"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -296,25 +278,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Natt"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Solnedgang"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Fest"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"INGEN"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"HANDLING"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NATT"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SOLNEDGANG"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FEST"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"NEDTELLINGSTIDTAKER"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"NEDTELLINGSTIDTAKEREN ER AV"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUND"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDER"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUNDER"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUNDER"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Kan ikke velges i scenemodus."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Eksponering"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EKSPONERING"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"FRONTKAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"BAKRE KAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"USB-lagringsplass er snart oppbrukt. Endre kvalitetsinnstillingene, eller slett bilder eller andre filer."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Lagringsplassen på SD-kortet er snart oppbrukt. Endre kvalitetsinnstillingene, eller slett bilder eller andre filer."</string>
@@ -365,10 +332,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Avbryt redigering"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Redigering fullført"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Ta nytt bilde/video"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Spill av videoen"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Sett videoen på pause"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Last inn videoen på nytt"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Tidsrad for videoavspilleren"</string>
<string name="capital_on" msgid="5491353494964003567">"PÅ"</string>
<string name="capital_off" msgid="7231052688467970897">"AV"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Av"</string>
@@ -428,8 +391,6 @@
<string name="menu_search" msgid="7580008232297437190">"Søk"</string>
<string name="tab_photos" msgid="9110813680630313419">"Bilder"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumer"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"FLERE ALTERNATIVER"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"INNSTILLINGER"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d bilde"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d bilder"</item>
diff --git a/res/values-nl/filtershow_strings.xml b/res/values-nl/filtershow_strings.xml
index 89cfa6b8..4284f25 100644
--- a/res/values-nl/filtershow_strings.xml
+++ b/res/values-nl/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Achtergrond instellen"</string>
- <string name="download_failure" msgid="5923323939788582895">"Kan de foto niet downloaden. Het netwerk is niet beschikbaar."</string>
<string name="original" msgid="3524493791230430897">"Origineel"</string>
<string name="borders" msgid="2067345080568684614">"Randen"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Ongedaan maken"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Opnieuw"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Toegepaste effecten weergeven"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Toegepaste effecten verbergen"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Geschiedenis weerg."</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Geschiedenis verb."</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Afb.status weergeven"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Afb.status verbergen"</string>
<string name="menu_settings" msgid="6428291655769260831">"Instellingen"</string>
<string name="unsaved" msgid="8704442449002374375">"Er zijn niet-opgeslagen wijzigingen aangebracht in deze afbeelding."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Wilt u opslaan voordat u afsluit?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Kleur selecteren"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Formaat selecteren"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Oorspronkelijk"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultaat"</string>
</resources>
diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
index ed41cbd..b9b0544 100644
--- a/res/values-nl/strings.xml
+++ b/res/values-nl/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Rechtsom draaien"</string>
<string name="no_such_item" msgid="5315144556325243400">"Kan item niet vinden."</string>
<string name="edit" msgid="1502273844748580847">"Bewerken"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Eenvoudig bewerken"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Cacheverzoeken verwerken"</string>
<string name="caching_label" msgid="4521059045896269095">"In cache opslaan..."</string>
<string name="crop_action" msgid="3427470284074377001">"Bijsnijden"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Achterzijde"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Voorzijde"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Locatie opslaan"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOCATIE"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Afteltimer"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 seconde"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Camera-instellingen"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Camcorder-instellingen"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Grootte van foto"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M pixels"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapixels"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapixel"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M pixels"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapixel"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapixel"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M pixels (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapixel"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatisch"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Oneindig"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMATISCH"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"ONEINDIG"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Flitsmodus"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"FLITSMODUS"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatisch"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Aan"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Uit"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLITSER AUTOMATISCH"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLITSER AAN"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLITSER UIT"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Witbalans"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"WITBALANS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatisch"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Gloeilamp"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Daglicht"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescerend"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Bewolkt"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMATISCH"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"GLOEILAMP"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DAGLICHT"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCEREND"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"BEWOLKT"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scènemodus"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatisch"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nacht"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Zonsondergang"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Feest"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"GEEN"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACTIE"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NACHT"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ZONSONDERGANG"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FEEST"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"AFTELTIMER"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TIMER UIT"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SECONDE"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SECONDEN"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SECONDEN"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SECONDEN"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Kan niet worden geselecteerd in scènemodus."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Belichting"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"BELICHTING"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CAMERA AAN VOORZIJDE"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CAMERA AAN ACHTERZIJDE"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Uw USB-opslag is bijna vol. Wijzig de kwaliteitsinstelling of verwijder enkele afbeeldingen of andere bestanden."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Uw SD-kaart is bijna vol. Wijzig de kwaliteitsinstelling of verwijder enkele afbeeldingen of andere bestanden."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Beoordeling: annuleren"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Beoordeling: gereed"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Opnieuw maken na beoordeling"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Video afspelen"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Video onderbreken"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Video opnieuw laden"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Tijdbalk videospeler"</string>
<string name="capital_on" msgid="5491353494964003567">"AAN"</string>
<string name="capital_off" msgid="7231052688467970897">"UIT"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Uit"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Zoeken"</string>
<string name="tab_photos" msgid="9110813680630313419">"Foto\'s"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albums"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"MEER OPTIES"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"INSTELLINGEN"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d foto\'s"</item>
diff --git a/res/values-pl/filtershow_strings.xml b/res/values-pl/filtershow_strings.xml
index 2db5672..3166939 100644
--- a/res/values-pl/filtershow_strings.xml
+++ b/res/values-pl/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Ustawiam tapetę"</string>
- <string name="download_failure" msgid="5923323939788582895">"Nie można pobrać zdjęcia. Sieć jest niedostępna."</string>
<string name="original" msgid="3524493791230430897">"Oryginalny"</string>
<string name="borders" msgid="2067345080568684614">"Granice"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Cofnij"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Ponów"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Pokaż zastosowane efekty"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Ukryj zastosowane efekty"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Pokaż historię"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Ukryj historię"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Pokaż stan obrazu"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Ukryj stan obrazu"</string>
<string name="menu_settings" msgid="6428291655769260831">"Ustawienia"</string>
<string name="unsaved" msgid="8704442449002374375">"Ten obraz zawiera niezapisane zmiany."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Czy chcesz zapisać przed zamknięciem?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Wybierz kolor"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Wybierz rozmiar"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Oryginał"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Wynik"</string>
</resources>
diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml
index f55efc5..e2418aa 100644
--- a/res/values-pl/strings.xml
+++ b/res/values-pl/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Obróć w prawo"</string>
<string name="no_such_item" msgid="5315144556325243400">"Nie można znaleźć elementu."</string>
<string name="edit" msgid="1502273844748580847">"Edytuj"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Prosta edycja"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Przetwarzanie żądań dotyczących buforowania"</string>
<string name="caching_label" msgid="4521059045896269095">"Buforowanie…"</string>
<string name="crop_action" msgid="3427470284074377001">"Przytnij"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Tył"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Przód"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Zapis lokalizacji"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOKALIZACJA"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Samowyzwalacz"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 sekunda"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Ustawienia aparatu"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Ustawienia kamery"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Rozmiar zdjęcia"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapikseli"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapikseli"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 Mpix"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapiksele"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 Mpix"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 Mpix"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 megapiksele (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 Mpix"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 Mpix"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Auto"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Nieskończoność"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMATYCZNIE"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"NIESKOŃCZONOŚĆ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Lampa błyskowa"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"LAMPA BŁYSKOWA"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatyczna"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Włączona"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Wyłączona"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"LAMPA BŁYSKOWA AUTOMATYCZNIE"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"LAMPA BŁYSKOWA WŁĄCZONA"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"LAMPA BŁYSKOWA WYŁĄCZONA"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Balans bieli"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALANS BIELI"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Auto"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Światło żarowe"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Światło dzienne"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescencja"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Zachmurzenie"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMATYCZNY"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ŚWIATŁO ŻAROWE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"ŚWIATŁO DZIENNE"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENCJA"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ZACHMURZENIE"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Tryb scenerii"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Auto"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Noc"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Zachód słońca"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Impreza"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"BRAK"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"AKCJA"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOC"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ZACHÓD SŁOŃCA"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ZABAWA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"SAMOWYZWALACZ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"SAMOWYZWALACZ WYŁ."</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUNDA"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDY"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUND"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUND"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Opcja niedostępna w trybie scenerii."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Ekspozycja"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EKSPOZYCJA"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"PRZEDNI APARAT"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"TYLNY APARAT"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Na nośniku USB kończy się miejsce. Zmień ustawienie jakości bądź usuń niektóre zdjęcia lub inne pliki."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Na karcie SD kończy się miejsce. Zmień ustawienie jakości bądź usuń niektóre zdjęcia lub inne pliki."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Przegląd: anulowanie"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Przegląd: gotowe"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Przegląd – zrób zdjęcie/nagraj film ponownie"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Odtwórz film"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Wstrzymaj film"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Załaduj ponownie film"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Pasek czasu w odtwarzaczu wideo"</string>
<string name="capital_on" msgid="5491353494964003567">"WŁĄCZONY"</string>
<string name="capital_off" msgid="7231052688467970897">"WYŁĄCZONY"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Wył."</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Szukaj"</string>
<string name="tab_photos" msgid="9110813680630313419">"Zdjęcia"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumy"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"WIĘCEJ OPCJI"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"USTAWIENIA"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d zdjęcie"</item>
<item quantity="other" msgid="3813306834113858135">"Zdjęcia: %1$d"</item>
diff --git a/res/values-pt-rPT/filtershow_strings.xml b/res/values-pt-rPT/filtershow_strings.xml
index 4be20a5..1f144c0 100644
--- a/res/values-pt-rPT/filtershow_strings.xml
+++ b/res/values-pt-rPT/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"A definir imagem de fundo"</string>
- <string name="download_failure" msgid="5923323939788582895">"Não foi possível transferir a fotografia. Rede não disponível."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Limites"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Anular"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Refazer"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Mostrar Efeitos Aplicados"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Ocultar Efeitos Aplicados"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Mostrar Histórico"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Ocultar Histórico"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Ver Estado da Imagem"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Ocul. Estado Imagem"</string>
<string name="menu_settings" msgid="6428291655769260831">"Definições"</string>
<string name="unsaved" msgid="8704442449002374375">"Existem alterações a esta imagem não guardadas."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Pretende guardar antes de sair?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Selecionar a cor"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Selecionar Tamanho"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultado"</string>
</resources>
diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index 1825036..6bea992 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Rodar para a direita"</string>
<string name="no_such_item" msgid="5315144556325243400">"Não foi possível encontrar item."</string>
<string name="edit" msgid="1502273844748580847">"Editar"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Edição Simples"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"A processar pedidos de colocação em cache"</string>
<string name="caching_label" msgid="4521059045896269095">"A col. cache..."</string>
<string name="crop_action" msgid="3427470284074377001">"Recortar"</string>
@@ -230,12 +229,11 @@
<string name="access_sd_fail" product="default" msgid="1584968646870054352">"Não foi possível aceder ao cartão SD."</string>
<string name="review_cancel" msgid="8188009385853399254">"CANCELAR"</string>
<string name="review_ok" msgid="1156261588693116433">"CONCLUÍDO"</string>
- <string name="time_lapse_title" msgid="4360632427760662691">"Gravação com intervalo de tempo"</string>
+ <string name="time_lapse_title" msgid="4360632427760662691">"Gravação com lapso de tempo"</string>
<string name="pref_camera_id_title" msgid="4040791582294635851">"Escolher câmara"</string>
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Traseira"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Frontal"</string>
- <string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Incluir localização"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOCALIZAÇÃO"</string>
+ <string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Armazenar localização"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Temporizador de contagem decr."</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 segundo"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Definições da câmara"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Definições da câmara de vídeo"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Tamanho da imagem"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 MP"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 MP"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapíxeis"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 MP"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapíxeis"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapíxeis"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 MP (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapíxeis"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapíxel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automático"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinito"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMÁTICO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINITO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Modo flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MODO FLASH"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automático"</string>
- <string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Ativado"</string>
+ <string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Activado"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Desativado"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH AUTOMÁTICO"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLASH ATIVADO"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLASH DESATIVADO"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Equilíbrio dos brancos"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"EQUILÍBRIO DOS BRANCOS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automático"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Incandescente"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Luz do dia"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescente"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Nublado"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMÁTICO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENTE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"LUZ DO DIA"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENTE"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"NUBLADO"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Modo cenário"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automático"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Nocturno"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Ocaso"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Partido"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NENHUM"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"AÇÃO"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOITE"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"PÔR DO SOL"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FESTA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"TEMPORIZADOR DE CONTAGEM DECRESCENTE"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TEMPORIZADOR DESATIVADO"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEGUNDO"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEGUNDOS"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEGUNDOS"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEGUNDOS"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Não selecionável no modo de cena."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Exposição"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOSIÇÃO"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CÂMARA FRONTAL"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CÂMARA POSTERIOR"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Está a ficar sem espaço no armazenamento USB. Altere as definições de qualidade ou elimine algumas imagens ou outros ficheiros."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Está a ficar sem espaço no cartão SD. Altere as definições de qualidade ou elimine algumas imagens ou outros ficheiros."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Comentário cancelado."</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Reveja o que está concluído"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Retomar comentário"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Reproduzir vídeo"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Interromper vídeo"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Atualizar vídeo"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Barra de tempo do leitor de vídeo"</string>
<string name="capital_on" msgid="5491353494964003567">"ATIVADA"</string>
<string name="capital_off" msgid="7231052688467970897">"DESATIVADA"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Desativado"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Pesquisa"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotografias"</string>
<string name="tab_albums" msgid="8079449907770685691">"Álbuns"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"MAIS OPÇÕES"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"DEFINIÇÕES"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d fotografia"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotog."</item>
diff --git a/res/values-pt/filtershow_strings.xml b/res/values-pt/filtershow_strings.xml
index d54b040..bce7944 100644
--- a/res/values-pt/filtershow_strings.xml
+++ b/res/values-pt/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Definindo plano de fundo"</string>
- <string name="download_failure" msgid="5923323939788582895">"Não foi possível fazer o download da foto. Rede indisponível."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Bordas"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Desfazer"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Refazer"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Mostrar efeitos aplicados"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Ocultar efeitos aplicados"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Mostrar histórico"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Ocultar histórico"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Mostrar estado"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Ocultar estado"</string>
<string name="menu_settings" msgid="6428291655769260831">"Configurações"</string>
<string name="unsaved" msgid="8704442449002374375">"Existem alterações não salvas nesta imagem."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Deseja salvar antes de sair?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Selecionar cor"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Selecionar tamanho"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultado"</string>
</resources>
diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml
index 1c4acc7..27b418f 100644
--- a/res/values-pt/strings.xml
+++ b/res/values-pt/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Girar para a direita"</string>
<string name="no_such_item" msgid="5315144556325243400">"Não foi possível encontrar o item."</string>
<string name="edit" msgid="1502273844748580847">"Editar"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Edição simples"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Processando solicitações de armazenamento em cache"</string>
<string name="caching_label" msgid="4521059045896269095">"Cache..."</string>
<string name="crop_action" msgid="3427470284074377001">"Cortar"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Traseira"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Visão frontal"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Local de armazenamento"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOCAL"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Contagem regressiva"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"Um segundo"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Configurações da câmera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Configurações da filmadora"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Tamanho da imagem"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 MP"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 MP"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapixels"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 MP"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapixels"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapixels"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 MP (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapixels"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automático"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinito"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINITO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Modo de flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MODO DE FLASH"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automático"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Ativado"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Desativado"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH AUTO"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLASH LIGADO"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLASH DESLIGADO"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Balanço de branco"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALANÇO DE BRANCO"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automático"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Incandescente"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Luz do dia"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescente"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Nublado"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENTE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"LUZ DO DIA"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENTE"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"NUBLADO"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Modo de cena"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automático"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Cena noturna"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Pôr-do-sol"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Festa"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NENHUM"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"AÇÃO"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOITE"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"PÔR-DO-SOL"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FESTA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"CONTAGEM REGRESSIVA"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TEMPORIZADOR DESLIGADO"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEGUNDO"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEGUNDOS"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEGUNDOS"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEGUNDOS"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Não pode ser selecionado no modo de cena."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Exposição"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOSIÇÃO"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CÂMERA FRONTAL"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CÂMERA TRASEIRA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Seu armazenamento USB está sem espaço. Altere a configuração de qualidade ou exclua algumas imagens ou outros arquivos."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Seu cartão SD está sem espaço. Altere a configuração de qualidade ou exclua algumas imagens ou outros arquivos."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Cancelar"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Revisão concluída"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Repetir anexo"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Reproduzir vídeo"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pausar vídeo"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Atualizar vídeo"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Barra de tempo do player de vídeo"</string>
<string name="capital_on" msgid="5491353494964003567">"LIGADO"</string>
<string name="capital_off" msgid="7231052688467970897">"DESLIGADO"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Desligado"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Pesquisar"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotos"</string>
<string name="tab_albums" msgid="8079449907770685691">"Álbuns"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"MAIS OPÇÕES"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"CONFIGURAÇÕES"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotos"</item>
diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml
index dc98330..c022955 100644
--- a/res/values-rm/strings.xml
+++ b/res/values-rm/strings.xml
@@ -112,8 +112,6 @@
<skip />
<!-- no translation found for edit (1502273844748580847) -->
<skip />
- <!-- no translation found for simple_edit (2792835918347498211) -->
- <skip />
<!-- no translation found for process_caching_requests (8722939570307386071) -->
<skip />
<!-- no translation found for caching_label (4521059045896269095) -->
@@ -381,8 +379,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Enavos"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Frunt"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Memorisar la posiziun"</string>
- <!-- no translation found for pref_camera_location_label (2254270920298609161) -->
- <skip />
<!-- no translation found for pref_camera_timer_title (3105232208281893389) -->
<skip />
<!-- no translation found for pref_camera_timer_entry:one (1654523400981245448) -->
@@ -405,20 +401,14 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Parameters da la camera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Parameters da la camera da video"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Grondezza dal maletg"</string>
- <!-- no translation found for pref_camera_picturesize_entry_13mp (675309554194481780) -->
- <skip />
<!-- no translation found for pref_camera_picturesize_entry_8mp (259953780932849079) -->
<skip />
<!-- no translation found for pref_camera_picturesize_entry_5mp (2882928212030661159) -->
<skip />
- <!-- no translation found for pref_camera_picturesize_entry_4mp (933242108272469142) -->
- <skip />
<!-- no translation found for pref_camera_picturesize_entry_3mp (741415860337400696) -->
<skip />
<!-- no translation found for pref_camera_picturesize_entry_2mp (1753709802245460393) -->
<skip />
- <!-- no translation found for pref_camera_picturesize_entry_2mp_wide (5359490802026616612) -->
- <skip />
<!-- no translation found for pref_camera_picturesize_entry_1_3mp (829109608140747258) -->
<skip />
<!-- no translation found for pref_camera_picturesize_entry_1mp (1669725616780375066) -->
@@ -431,42 +421,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatic"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinit"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <!-- no translation found for pref_camera_focusmode_label_auto (8547956917516317183) -->
- <skip />
- <!-- no translation found for pref_camera_focusmode_label_infinity (4272904160062531778) -->
- <skip />
- <!-- no translation found for pref_camera_focusmode_label_macro (8749317592620908054) -->
- <skip />
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Modus da chametg (flash)"</string>
- <!-- no translation found for pref_camera_flashmode_label (7546741624882856171) -->
- <skip />
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatic"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Activà"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Deactivà"</string>
- <!-- no translation found for pref_camera_flashmode_label_auto (8854671890619026197) -->
- <skip />
- <!-- no translation found for pref_camera_flashmode_label_on (7347504762794840140) -->
- <skip />
- <!-- no translation found for pref_camera_flashmode_label_off (3541596735596053416) -->
- <skip />
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Equiliber da l\'alv"</string>
- <!-- no translation found for pref_camera_whitebalance_label (7467403405883190920) -->
- <skip />
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatic"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Pair electric"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Glisch dal di"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Glisch da neon"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Nivlus"</string>
- <!-- no translation found for pref_camera_whitebalance_label_auto (1479694362310491429) -->
- <skip />
- <!-- no translation found for pref_camera_whitebalance_label_incandescent (7427628260209908900) -->
- <skip />
- <!-- no translation found for pref_camera_whitebalance_label_daylight (1859710806141461399) -->
- <skip />
- <!-- no translation found for pref_camera_whitebalance_label_fluorescent (5173251749161337707) -->
- <skip />
- <!-- no translation found for pref_camera_whitebalance_label_cloudy (8230173517179285320) -->
- <skip />
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Modus da scena"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatic"</string>
<!-- no translation found for pref_camera_scenemode_entry_hdr (2923388802899511784) -->
@@ -476,41 +440,11 @@
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Rendida dal sulegl"</string>
<!-- no translation found for pref_camera_scenemode_entry_party (907053529286788253) -->
<skip />
- <!-- no translation found for pref_camera_scenemode_label_auto (4475096836397300237) -->
- <skip />
- <!-- no translation found for pref_camera_scenemode_label_action (964748409622151496) -->
- <skip />
- <!-- no translation found for pref_camera_scenemode_label_night (1269871886845854574) -->
- <skip />
- <!-- no translation found for pref_camera_scenemode_label_sunset (2802732082948866877) -->
- <skip />
- <!-- no translation found for pref_camera_scenemode_label_party (1409459091844374828) -->
- <skip />
- <!-- no translation found for pref_camera_countdown_label (7592784692450586126) -->
- <skip />
- <!-- no translation found for pref_camera_countdown_label_off (4987856883590176585) -->
- <skip />
- <!-- no translation found for pref_camera_countdown_label_one (1101814103087928898) -->
- <skip />
- <!-- no translation found for pref_camera_countdown_label_three (1047399297342955649) -->
- <skip />
- <!-- no translation found for pref_camera_countdown_label_ten (6274681535347260279) -->
- <skip />
- <!-- no translation found for pref_camera_countdown_label_fifteen (4544824246687597089) -->
- <skip />
<!-- no translation found for not_selectable_in_scene_mode (2970291701448555126) -->
<skip />
<string name="pref_exposure_title" msgid="1229093066434614811">"Exposiziun"</string>
- <!-- no translation found for pref_exposure_label (552624394642497940) -->
- <skip />
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <!-- no translation found for pref_camera_hdr_label (7217211253357027510) -->
- <skip />
- <!-- no translation found for pref_camera_id_label_back (8745553500400332333) -->
- <skip />
- <!-- no translation found for pref_camera_id_label_front (8699439330056996709) -->
- <skip />
<!-- no translation found for dialog_ok (6263301364153382152) -->
<skip />
<!-- no translation found for spaceIsLow_content (4401325203349203177) -->
@@ -610,14 +544,6 @@
<skip />
<!-- no translation found for accessibility_review_retake (659300290054705484) -->
<skip />
- <!-- no translation found for accessibility_play_video (7596298365794810207) -->
- <skip />
- <!-- no translation found for accessibility_pause_video (6526344477133046653) -->
- <skip />
- <!-- no translation found for accessibility_reload_video (3250335917598607232) -->
- <skip />
- <!-- no translation found for accessibility_time_bar (1414029843602604531) -->
- <skip />
<!-- no translation found for capital_on (5491353494964003567) -->
<skip />
<!-- no translation found for capital_off (7231052688467970897) -->
@@ -736,10 +662,6 @@
<skip />
<!-- no translation found for tab_albums (8079449907770685691) -->
<skip />
- <!-- no translation found for camera_menu_more_label (6868642182125198710) -->
- <skip />
- <!-- no translation found for camera_menu_settings_label (875454962069404723) -->
- <skip />
<!-- no translation found for number_of_photos:one (6949174783125614798) -->
<!-- no translation found for number_of_photos:other (3813306834113858135) -->
</resources>
diff --git a/res/values-ro/filtershow_strings.xml b/res/values-ro/filtershow_strings.xml
index 3798d44..1452123 100644
--- a/res/values-ro/filtershow_strings.xml
+++ b/res/values-ro/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Se setează imaginea de fundal"</string>
- <string name="download_failure" msgid="5923323939788582895">"Nu s-au putut descărca fotografiile. Rețea indisponibilă."</string>
<string name="original" msgid="3524493791230430897">"Originală"</string>
<string name="borders" msgid="2067345080568684614">"Chenar"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Anulaţi"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Repetaţi"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Afișați efectele aplicate"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Ascundeți efectele aplicate"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Afişaţi istoricul"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Ascundeţi istoricul"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Afişaţi stare foto."</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Ascundeţi stare foto"</string>
<string name="menu_settings" msgid="6428291655769260831">"Setări"</string>
<string name="unsaved" msgid="8704442449002374375">"Ați adus modificări imaginii pe care nu le-ați salvat."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Doriți să salvați înainte de a ieși?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Selectați culoarea"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Selectați dimensiunea"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Rezultat"</string>
</resources>
diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml
index 9794c3f..50c6af8 100644
--- a/res/values-ro/strings.xml
+++ b/res/values-ro/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Rotiţi spre dreapta"</string>
<string name="no_such_item" msgid="5315144556325243400">"Elementul nu a putut fi găsit."</string>
<string name="edit" msgid="1502273844748580847">"Editaţi"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Editare simplă"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Se proces. solicit. de stocare în memoria cache"</string>
<string name="caching_label" msgid="4521059045896269095">"Mem. cache..."</string>
<string name="crop_action" msgid="3427470284074377001">"Decupaţi"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Înapoi"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Frontal"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Stocaţi locaţia"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOCAȚIE"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Cronometru numărătoare inversă"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"O secundă"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Setările camerei foto"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Setările camerei video"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Dimensiune fotografie"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapixeli"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapixeli"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 MP"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 MP"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 MP"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 MP"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 MP (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 MP"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 MP"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automat"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Infinit"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTOMAT"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINIT"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Mod flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"MOD BLIȚ"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automat"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Activat"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Dezactivată"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"BLIȚ AUTOMAT"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLIȚ ACTIVAT"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"BLIȚ DEZACTIVAT"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Balanţă de alb"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BALANS DE ALB"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automat"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Incandescent"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Lumină de zi"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescent"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Înnorat"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTOMAT"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENT"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"LUMINĂ DE ZI"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENT"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ÎNNORAT"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Mod Scenă"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automat"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Noapte"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Apus de soare"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Petrecere"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"NICIUNA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACȚIUNE"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOAPTE"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"APUS DE SOARE"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"PETRECERE"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"CRONOMETRU NUMĂRARE INVERSĂ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TEMPORIZATOR DEZACTIVAT"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"O SECUNDĂ"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SECUNDE"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SECUNDE"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SECUNDE"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Nu este selectabil în modul scenă."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Expunere"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPUNERE"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CAMERA FOTO FRONTALĂ"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CAMERA FOTO SPATE"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Spaţiul de stocare USB este aproape ocupat. Editaţi setarea de calitate sau ştergeţi câteva imagini ori alte fişiere."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Cardul SD rămâne fără spaţiu de stocare. Editaţi setarea de calitate sau ştergeţi câteva imagini sau alte fişiere."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Anulaţi examinarea"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Terminaţi examinarea"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Refaceţi"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Redați videoclipul"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Întrerupeți videoclipul"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Reîncărcați videoclipul"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Bara temporală a playerului video"</string>
<string name="capital_on" msgid="5491353494964003567">"ACTIVAT"</string>
<string name="capital_off" msgid="7231052688467970897">"DEZACTIVAT"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Dezactivat"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Căutați"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotografii"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albume"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"MAI MULTE OPȚIUNI"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"SETĂRI"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d fotografie"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotografii"</item>
diff --git a/res/values-ru/filtershow_strings.xml b/res/values-ru/filtershow_strings.xml
index 9e8bc13..f20447f 100644
--- a/res/values-ru/filtershow_strings.xml
+++ b/res/values-ru/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Установка обоев…"</string>
- <string name="download_failure" msgid="5923323939788582895">"Не удалось скачать фото: сеть недоступна."</string>
<string name="original" msgid="3524493791230430897">"Оригинал"</string>
- <string name="borders" msgid="2067345080568684614">"Рамка"</string>
+ <string name="borders" msgid="2067345080568684614">"Границы"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Отмена"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Повторить"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Отобразить эффекты"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Скрыть эффекты"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Показать историю"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Скрыть историю"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Показать состояние"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Скрыть состояние"</string>
<string name="menu_settings" msgid="6428291655769260831">"Настройки"</string>
<string name="unsaved" msgid="8704442449002374375">"У вас есть несохраненные изменения."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Сохранить изменения?"</string>
@@ -39,7 +40,7 @@
<skip />
<string name="imageState" msgid="8632586742752891968">"Эффекты"</string>
<string name="compare_original" msgid="8140838959007796977">"Сравнить"</string>
- <string name="apply_effect" msgid="1218288221200568947"></string>
+ <string name="apply_effect" msgid="1218288221200568947">"Применить:"</string>
<string name="reset_effect" msgid="7712605581024929564">"Сброс"</string>
<string name="aspect" msgid="4025244950820813059">"Формат"</string>
<string name="aspect1to1_effect" msgid="1159104543795779123">"1:1"</string>
@@ -58,18 +59,18 @@
<string name="sharpness" msgid="6463103068318055412">"Резкость"</string>
<string name="contrast" msgid="2310908487756769019">"Контраст"</string>
<string name="vibrance" msgid="3326744578577835915">"Vibrance"</string>
- <string name="saturation" msgid="7026791551032438585">"Насыщенность"</string>
+ <string name="saturation" msgid="7026791551032438585">"Насыщ-сть"</string>
<string name="bwfilter" msgid="8927492494576933793">"Ч/Б"</string>
<string name="wbalance" msgid="6346581563387083613">"Авторежим"</string>
<string name="hue" msgid="6231252147971086030">"Оттенок"</string>
<string name="shadow_recovery" msgid="3928572915300287152">"Тени"</string>
<string name="highlight_recovery" msgid="8262208470735204243">"Блики"</string>
<string name="curvesRGB" msgid="915010781090477550">"Кривые"</string>
- <string name="vignette" msgid="934721068851885390">"Виньетирование"</string>
+ <string name="vignette" msgid="934721068851885390">"Виньет-ние"</string>
<string name="redeye" msgid="4508883127049472069">"Красные глаза"</string>
<string name="imageDraw" msgid="6918552177844486656">"Подмалевок"</string>
<string name="straighten" msgid="26025591664983528">"Выровнять"</string>
- <string name="crop" msgid="5781263790107850771">"Кадрировать"</string>
+ <string name="crop" msgid="5781263790107850771">"Кадрирование"</string>
<string name="rotate" msgid="2796802553793795371">"Повернуть"</string>
<string name="mirror" msgid="5482518108154883096">"Отразить"</string>
<string name="negative" msgid="6998313764388022201">"Негатив"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Выберите цвет"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Выберите размер"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"ОК"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Как в оригинале"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Результат"</string>
</resources>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index 6234d00..7bb107f 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Повернуть вправо"</string>
<string name="no_such_item" msgid="5315144556325243400">"Элемент не найден."</string>
<string name="edit" msgid="1502273844748580847">"Изменить"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Простая правка"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Обработка запросов на кэширование"</string>
<string name="caching_label" msgid="4521059045896269095">"Кэширование..."</string>
<string name="crop_action" msgid="3427470284074377001">"Кадрировать"</string>
@@ -235,15 +234,14 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Задняя"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Передняя"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Геотеги"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"МЕСТОПОЛОЖЕНИЕ"</string>
- <string name="pref_camera_timer_title" msgid="3105232208281893389">"Автоспуск"</string>
+ <string name="pref_camera_timer_title" msgid="3105232208281893389">"Таймер обратного отсчета"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 сек."</item>
<item quantity="other" msgid="6455381617076792481">"%d сек."</item>
</plurals>
<!-- no translation found for pref_camera_timer_sound_default (7066624532144402253) -->
<skip />
- <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"Звук таймера"</string>
+ <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"Сигнал"</string>
<string name="setting_off" msgid="4480039384202951946">"Выкл."</string>
<string name="setting_on" msgid="8602246224465348901">"Вкл."</string>
<string name="pref_video_quality_title" msgid="8245379279801096922">"Качество видео"</string>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Настройки камеры"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Настройки видеокамеры"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Размер фото"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 мегапикс."</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 Мпикс."</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 Мпикс."</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 Мпикс."</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 Мпикс."</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 Мпикс."</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 Мпикс. (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 Мпикс."</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 Мпикс."</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"640 х 480 пикс."</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Авто"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Бесконечность"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Макро"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"АВТО"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"БЕСКОНЕЧНОСТЬ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"МАКРОСЪЕМКА"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Режим вспышки"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"РЕЖИМ ВСПЫШКИ"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Авто"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Вкл."</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Выкл."</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"АВТО"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"ВКЛ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"ВЫКЛ"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Баланс белого"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"БАЛАНС БЕЛОГО"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Авто"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Лампа накаливания"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Солнечный свет"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Лампа дн. света"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Пасмурный день"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"АВТО"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ЛАМПА НАКАЛИВАНИЯ"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"ДНЕВНОЙ СВЕТ"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ЛАМПА ДНЕВНОГО СВЕТА"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ПАСМУРНО"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Режим съемки"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Авто"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"Эффект HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Ночь"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Закат"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Вечеринка"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"НЕТ"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"РАЗМЫТИЕ В ДВИЖЕНИИ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"НОЧЬ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ЗАКАТ"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ВЕЧЕРИНКА"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"АВТОСПУСК"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"АВТОСПУСК ОТКЛЮЧЕН"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 СЕКУНДА"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 СЕКУНДЫ"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 СЕКУНД"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 СЕКУНД"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Недоступно в режиме съемки"</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Экспозиция"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ЭКСПОЗИЦИЯ"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ФРОНТАЛЬНАЯ КАМЕРА"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"ОСНОВНАЯ КАМЕРА"</string>
<string name="dialog_ok" msgid="6263301364153382152">"ОК"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Место на USB-накопителе заканчивается. Измените настройки качества или удалите ненужные изображения и другие файлы."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Место на вашей SD-карте заканчивается. Измените настройки качества или удалите ненужные изображения и другие файлы."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Отмена"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Готово"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Ещё раз"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Воспроизвести видео"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Пауза"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Перезагрузить видео"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Полоса прокрутки видеоплеера"</string>
<string name="capital_on" msgid="5491353494964003567">"I"</string>
<string name="capital_off" msgid="7231052688467970897">"O"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Выкл."</string>
@@ -419,7 +382,7 @@
<string name="time_lapse_interval_set" msgid="2486386210951700943">"Готово"</string>
<string name="set_time_interval" msgid="2970567717633813771">"Задайте интервал"</string>
<string name="set_time_interval_help" msgid="6665849510484821483">"Сначала включите режим замедленной съемки."</string>
- <string name="set_timer_help" msgid="5007708849404589472">"Чтобы камера фотографировала с задержкой, включите эту функцию."</string>
+ <string name="set_timer_help" msgid="5007708849404589472">"Таймер обратного отсчета отключен. Включите его, чтобы сделать снимок с задержкой."</string>
<string name="set_duration" msgid="5578035312407161304">"Время"</string>
<string name="count_down_title_text" msgid="4976386810910453266">"Обратный отсчет перед съемкой"</string>
<string name="remember_location_title" msgid="9060472929006917810">"Сохранять место съемки?"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Поиск"</string>
<string name="tab_photos" msgid="9110813680630313419">"Фото"</string>
<string name="tab_albums" msgid="8079449907770685691">"Альбомы"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ЕЩЁ"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"НАСТРОЙКИ"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d фото"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d фото"</item>
diff --git a/res/values-sk/filtershow_strings.xml b/res/values-sk/filtershow_strings.xml
index 9bb7648..1e9c813 100644
--- a/res/values-sk/filtershow_strings.xml
+++ b/res/values-sk/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Prebieha nastavovanie tapety"</string>
- <string name="download_failure" msgid="5923323939788582895">"Fotografiu sa nepodarilo prevziať. Sieť nie je k dispozícii."</string>
<string name="original" msgid="3524493791230430897">"Pôvodné"</string>
<string name="borders" msgid="2067345080568684614">"Okraje"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Späť"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Znova"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Zobraziť použité efekty"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Skryť použité efekty"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Zobraziť históriu"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Skryť históriu"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Zobraz. stav obrázka"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Skryť stav obrázka"</string>
<string name="menu_settings" msgid="6428291655769260831">"Nastavenia"</string>
<string name="unsaved" msgid="8704442449002374375">"Niektoré zmeny obrázka nie sú uložené."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Chcete zmeny pred ukončením uložiť?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Vyberte farbu"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Vyberte veľkosť"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Pôvodné"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Výsledok"</string>
</resources>
diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml
index fdb228f..938c7ba 100644
--- a/res/values-sk/strings.xml
+++ b/res/values-sk/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Otočiť doprava"</string>
<string name="no_such_item" msgid="5315144556325243400">"Položku sa nepodarilo nájsť."</string>
<string name="edit" msgid="1502273844748580847">"Upraviť"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Jednoduchá úprava"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Spracovávanie žiadostí o ulož. do vyrovnáv. pamäte"</string>
<string name="caching_label" msgid="4521059045896269095">"Do pamäte..."</string>
<string name="crop_action" msgid="3427470284074377001">"Orezať"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Zozadu"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Spredu"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Úložné miesto"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"POLOHA"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Časovač odpočítavania"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 s"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Nastavenia fotoaparátu"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Nastavenie videokamery"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Veľkosť fotografie"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 Mpx"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapixelov"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapixlov"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 MP"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapixle"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapixle"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 MP (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapixlov"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Auto"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Nekonečno"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"NEKONEČNO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Režim blesku"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"REŽIM BLESKU"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Auto"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Zapnuté"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Vypnuté"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMATICKÝ BLESK"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLESK ZAPNUTÝ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"BLESK VYPNUTÝ"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Vyváženie bielej"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"VYVÁŽENIE BIELEJ"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Auto"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Žiariace"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Denné svetlo"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Svetielkujúce"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Zamračené"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ŽIAROVKA"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DENNÉ SVETLO"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ŽIARIVKA"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ZAMRAČENÉ"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scénický režim"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Auto"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Noc"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Západ slnka"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Strana"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"ŽIADNE"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"AKCIA"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NOC"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ZÁPAD SLNKA"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"VEČIEROK"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ČASOVAČ ODPOČÍTAVANIA"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ČASOVAČ VYPNUTÝ"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUNDA"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDY"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKÚND"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKÚND"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Nie je možné vybrať v scénickom režime."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Expozícia"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOZÍCIA"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"PREDNÝ FOTOAPARÁT"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"ZADNÝ FOTOAPARÁT"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"V ukladacom priestore USB je málo miesta. Zmeňte nastavenie kvality alebo odstráňte niektoré obrázky či iné súbory."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Na karte SD je málo miesta. Zmeňte nastavenie kvality alebo odstráňte niektoré obrázky či iné súbory."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Zrušiť"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Hotovo"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Nasnímať znova"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Prehrať video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pozastaviť video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Znova načítať video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Časový pruh prehrávača videí"</string>
<string name="capital_on" msgid="5491353494964003567">"ZAPNUTÉ"</string>
<string name="capital_off" msgid="7231052688467970897">"VYPNUTÉ"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Vypnuté"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Vyhľadávanie"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotografie"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumy"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ĎALŠIE MOŽNOSTI"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"NASTAVENIA"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d fotografia"</item>
<item quantity="other" msgid="3813306834113858135">"Fotografie: %1$d"</item>
diff --git a/res/values-sl/filtershow_strings.xml b/res/values-sl/filtershow_strings.xml
index cc65259..7b288e6 100644
--- a/res/values-sl/filtershow_strings.xml
+++ b/res/values-sl/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Nastavljanje ozadja"</string>
- <string name="download_failure" msgid="5923323939788582895">"Fotografije ni bilo mogoče prenesti. Omrežje ni na voljo."</string>
<string name="original" msgid="3524493791230430897">"Izvirnik"</string>
<string name="borders" msgid="2067345080568684614">"Obrobe"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Razveljavi"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Uveljavi"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Pokaži uporabljene učinke"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Skrij uporabljene učinke"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Pokaži zgodovino"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Skrij zgodovino"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Pokaži stanje slike"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Skrij stanje slike"</string>
<string name="menu_settings" msgid="6428291655769260831">"Nastavitve"</string>
<string name="unsaved" msgid="8704442449002374375">"Spremembe te slike niso shranjene."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Ali želite pred zapiranjem shraniti?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Izberite barvo"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Izberite velikost"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"V redu"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Izvirnik"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Rezultat"</string>
</resources>
diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml
index 7343a47..0d8a634 100644
--- a/res/values-sl/strings.xml
+++ b/res/values-sl/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Zasukaj desno"</string>
<string name="no_such_item" msgid="5315144556325243400">"Ni mogoče najti elementa."</string>
<string name="edit" msgid="1502273844748580847">"Urejanje"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Preprosto urejanje"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Obdelava zahtev za predpomnjenje"</string>
<string name="caching_label" msgid="4521059045896269095">"Predpomnjenje ..."</string>
<string name="crop_action" msgid="3427470284074377001">"Obrezovanje"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Nazaj"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Pred"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Shrani lokacijo"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOKACIJA"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Odštevalnik"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 s"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Nastavitve fotoaparata"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Nastavitve kamere"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Velikost slike"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 mio sl. pik"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 milijonov slikovnih pik"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 M sl. pik"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 M sl. pik"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 M sl. pik"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 M sl. pik"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 M pik (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 M sl. pik"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 M sl. pik"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Samodejno"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Neskončno"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"SAMODEJNO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"NESKONČNO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Način bliskavice"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"NAČIN BLISKAVICE"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Samodejno"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Vključeno"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Izključeno"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"SAMODEJNA BLISKAVICA"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLISKAVICA VKLOPLJENA"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"BLISKAVICA IZKLOPLJENA"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Izravnava beline"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"NASTAVITEV BELINE"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Samodejno"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Žareče"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Dnevna svetloba"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescenčno"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Oblačno"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"SAMODEJNO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ŽAREČE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DNEVNA SVETLOBA"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENČNO"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"OBLAČNO"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scenski način"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Samodejno"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Noč"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Sončni zahod"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Stranka"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"BREZ"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"DEJANJE"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"PONOČI"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SONČNI ZAHOD"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ZABAVA"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ODŠTEVALNIK"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"MERILNIK ČASA IZKLOPLJEN"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUNDA"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDE"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUND"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUND"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Ni mogoče izbrati v načinu prizora."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Osvetlitev"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"OSVETLITEV"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"FOTOAPARAT SPREDAJ"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"FOTOAPARAT ZADAJ"</string>
<string name="dialog_ok" msgid="6263301364153382152">"V redu"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Na vašem pomnilniku USB zmanjkuje prostora. Spremenite nastavitev kakovosti ali izbrišite nekaj slik ali drugih datotek."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Na kartici SD zmanjkuje prostora. Spremenite nastavitev kakovosti ali izbrišite nekaj slik ali drugih datotek."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Preklic pregleda"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Pregled opravljen"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Vnovični pregled posnetka"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Predvajaj videoposnetek"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Začasno ustavi videoposnetek"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Znova naloži videoposnetek"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Časovna vrstica videopredvajalnika"</string>
<string name="capital_on" msgid="5491353494964003567">"VKLOPLJENO"</string>
<string name="capital_off" msgid="7231052688467970897">"IZKLOPLJENO"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Izklopljeno"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Išči"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotografije"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albumi"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"VEČ MOŽNOSTI"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"NASTAVITVE"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d fotografija"</item>
<item quantity="other" msgid="3813306834113858135">"Št. fotografij: %1$d"</item>
diff --git a/res/values-sr/filtershow_strings.xml b/res/values-sr/filtershow_strings.xml
index 52f77b8..5b4d8f5 100644
--- a/res/values-sr/filtershow_strings.xml
+++ b/res/values-sr/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Подешавање позадине"</string>
- <string name="download_failure" msgid="5923323939788582895">"Није могуће преузети слику. Мрежа није доступна."</string>
<string name="original" msgid="3524493791230430897">"Оригинална"</string>
<string name="borders" msgid="2067345080568684614">"Ивице"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Опозови"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Понови"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Прикажи примењене ефекте"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Сакриј примењене ефекте"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Прикажи историју"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Сакриј историју"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Прикажи статус слике"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Сакриј статус слике"</string>
<string name="menu_settings" msgid="6428291655769260831">"Подешавања"</string>
<string name="unsaved" msgid="8704442449002374375">"Постоје несачуване измене ове слике."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Желите ли да сачувате пре него што изађете?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Избор боје"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Избор величине"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"Потврди"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Оригинална"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Резултат"</string>
</resources>
diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml
index 0f4a26f..4b20924 100644
--- a/res/values-sr/strings.xml
+++ b/res/values-sr/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Ротирај удесно"</string>
<string name="no_such_item" msgid="5315144556325243400">"Није могуће пронаћи ставку."</string>
<string name="edit" msgid="1502273844748580847">"Измени"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Једноставне измене"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Обрада захтева за кеширање"</string>
<string name="caching_label" msgid="4521059045896269095">"Кеширање..."</string>
<string name="crop_action" msgid="3427470284074377001">"Опсеци"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Назад"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Напред"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Чување локац."</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"ЛОКАЦИЈА"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Тајмер за одбројавање"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 секунда"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Подешавања камере"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Подешавања камкордера"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Величина слике"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 мегапиксела"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 мегапиксела"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 мегапиксела"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 мегапискела"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 мегапиксела"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 мегапиксела"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 мегапиксела (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 мегапиксела"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 мегапиксел"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Аутоматски"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Бесконачност"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Макро"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"АУТОМАТСКИ"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"БЕСКОНАЧНОСТ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"МАКРО"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Режим блица"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"РЕЖИМ БЛИЦА"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Аутоматски"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Укључено"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Искључено"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"АУТОМАТСКИ БЛИЦ"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"УКЉУЧИ БЛИЦ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"ИСКЉУЧИ БЛИЦ"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Баланс беле боје"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"БАЛАНС БЕЛЕ"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Аутоматски"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Усијано"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Дневна светлост"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Флуоресцентно"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Облачно"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"АУТОМАТСКИ"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"УСИЈАНО"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"ДНЕВНА СВЕТЛОСТ"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ФЛУОРЕСЦЕНТНО"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ОБЛАЧНО"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Режим сцене"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Аутоматски"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Ноћ"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Залазак сунца"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Журка"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"НИШТА"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"АКЦИЈА"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"НОЋ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ЗАЛАЗАК СУНЦА"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ЖУРКА"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ТАЈМЕР ЗА ОДБРОЈАВАЊЕ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ТАЈМЕР ЈЕ ИСКЉУЧЕН"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 СЕКУНДА"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 СЕКУНДЕ"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 СЕКУНДИ"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 СЕКУНДИ"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Ово не може да се изабере у режиму сцене."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Видљивост"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ЕКСПОЗИЦИЈА"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ПРЕДЊА КАМЕРА"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"ЗАДЊА КАМЕРА"</string>
<string name="dialog_ok" msgid="6263301364153382152">"Потврди"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"На вашој USB меморији понестаје места. Промените подешавања квалитета или избришите неке слике или друге датотеке."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"На вашој SD картици понестаје места. Промените поставке квалитета или избришите неке слике или друге датотеке."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Откажи у режиму прегледа"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Довршено у режиму прегледа"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Поново сними за преглед"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Пусти видео"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Паузирај видео"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Поново учитај видео"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Трака за време видео плејера"</string>
<string name="capital_on" msgid="5491353494964003567">"УКЉУЧEНO"</string>
<string name="capital_off" msgid="7231052688467970897">"ИСКЉУЧEНO"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Искључено"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Претражи"</string>
<string name="tab_photos" msgid="9110813680630313419">"Слике"</string>
<string name="tab_albums" msgid="8079449907770685691">"Албуми"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ЈОШ ОПЦИЈА"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"ПОДЕШАВАЊА"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d слика"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d слика"</item>
diff --git a/res/values-sv/filtershow_strings.xml b/res/values-sv/filtershow_strings.xml
index 3286e80..36e235b 100644
--- a/res/values-sv/filtershow_strings.xml
+++ b/res/values-sv/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Bakgrund anges"</string>
- <string name="download_failure" msgid="5923323939788582895">"Det gick inte att hämta fotot. Nätverket är inte tillgängligt."</string>
<string name="original" msgid="3524493791230430897">"Original"</string>
<string name="borders" msgid="2067345080568684614">"Ramar"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Ångra"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Gör om"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Visa tillämpade effekter"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Dölj tillämpade effekter"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Visa historik"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Dölj historik"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Visa bildläge"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Dölj bildläge"</string>
<string name="menu_settings" msgid="6428291655769260831">"Inställningar"</string>
<string name="unsaved" msgid="8704442449002374375">"Det finns ändringar i bilden som inte har sparats."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Vill du spara innan du avslutar?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Välj färg"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Välj storlek"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Original"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resultat"</string>
</resources>
diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml
index 5ad0485..6b73bed 100644
--- a/res/values-sv/strings.xml
+++ b/res/values-sv/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Rotera åt höger"</string>
<string name="no_such_item" msgid="5315144556325243400">"Det gick inte att hitta objektet."</string>
<string name="edit" msgid="1502273844748580847">"Redigera"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Enkel redigering"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Begäran om cachelagring bearbetas"</string>
<string name="caching_label" msgid="4521059045896269095">"Cachelagrar ..."</string>
<string name="crop_action" msgid="3427470284074377001">"Beskär"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Bakre"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Främre"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Spara plats"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"PLATS"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Nedräkningstimer"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 sekund"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kamerainställningar"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Videokamerainställningar"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Bildstorlek"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapixlar"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 megapixel"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 megapixlar"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 megapixlar"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 megapixlar"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 megapixlar"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 mp (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 megapixlar"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 megapixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Automatiskt"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Oändligt"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"OÄNDLIGT"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Blixtläge"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"BLIXTLÄGE"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Automatiskt"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"På"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Av"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"AUTOMATISK BLIXT"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BLIXT PÅ"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"AVSTÄNGD BLIXT"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Vitbalans"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"VITBALANS"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Automatiskt"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Självlysande"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Dagsljus"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescerande"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Molnigt"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"SJÄLVLYSANDE"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DAGSLJUS"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCERANDE"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"MOLNIGT"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scenläge"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Automatiskt"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Natt"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Solnedgång"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Fest"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"INGA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACTION"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NATT"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SOLNEDGÅNG"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"FEST"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"NEDRÄKNINGSTIMER"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TIMER AV"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEKUND"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEKUNDER"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEKUNDER"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEKUNDER"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Inte valbart i scenläget."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Exponering"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPONERING"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"FRÄMRE KAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"BAKRE KAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Din USB-lagringsenhet börjar bli full. Ändra kvalitetsinställningen eller ta bort några bilder eller andra filer."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Den delade lagringsenheten börjar bli full. Ändra inställningen för kvalitet eller ta bort några bilder eller andra filer."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Avbryt"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Klar"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Omtagning"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Spela upp videoklipp"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Pausa videoklippet"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Läs in video igen"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Videospelarens tidsindikator"</string>
<string name="capital_on" msgid="5491353494964003567">"PÅ"</string>
<string name="capital_off" msgid="7231052688467970897">"AV"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Av"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Sök"</string>
<string name="tab_photos" msgid="9110813680630313419">"Foton"</string>
<string name="tab_albums" msgid="8079449907770685691">"Album"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"FLER ALTERNATIV"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"INSTÄLLNINGAR"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d foton"</item>
diff --git a/res/values-sw/filtershow_strings.xml b/res/values-sw/filtershow_strings.xml
index 6909b26..11320cb 100644
--- a/res/values-sw/filtershow_strings.xml
+++ b/res/values-sw/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Inaweka mandhari"</string>
- <string name="download_failure" msgid="5923323939788582895">"Haikuweza kupakua picha. Mtandao haupatikani."</string>
<string name="original" msgid="3524493791230430897">"Asili"</string>
<string name="borders" msgid="2067345080568684614">"Kingo"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Tendua"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Rudia"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Onyesha Athari ambazo Zimetekelezwa"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Ficha Athari ambazo Zimetekelezwa"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Onyesha Historia"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Ficha Historia"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Onyesha Hali ya Picha"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Ficha Hali ya Picha"</string>
<string name="menu_settings" msgid="6428291655769260831">"Mipangilio"</string>
<string name="unsaved" msgid="8704442449002374375">"Kuna mabadiliko ambayo hayajahifadhiwa ya picha hii."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Je, unataka kuhifadhi kabla hujaondoka?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Chagua Rangi"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Chagua Ukubwa"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"SAWA"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Asili"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Matokeo"</string>
</resources>
diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml
index 6025bf8..5be0128 100644
--- a/res/values-sw/strings.xml
+++ b/res/values-sw/strings.xml
@@ -91,7 +91,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Zungusha kulia"</string>
<string name="no_such_item" msgid="5315144556325243400">"Hakuweza kupata kipengee."</string>
<string name="edit" msgid="1502273844748580847">"Hariri"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Kuhariri Rahisi"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Maombi ya kuakibisha michakato"</string>
<string name="caching_label" msgid="4521059045896269095">"Inaakibisha..."</string>
<string name="crop_action" msgid="3427470284074377001">"Punguza"</string>
@@ -183,7 +182,7 @@
<string name="widget_type" msgid="1364653978966343448">"Chagua picha"</string>
<string name="slideshow_dream_name" msgid="6915963319933437083">"Onyesho la slaidi"</string>
<string name="albums" msgid="7320787705180057947">"Albamu"</string>
- <string name="times" msgid="2023033894889499219">"Wakati"</string>
+ <string name="times" msgid="2023033894889499219">"Nyakati"</string>
<string name="locations" msgid="6649297994083130305">"Mahali"</string>
<string name="people" msgid="4114003823747292747">"Watu"</string>
<string name="tags" msgid="5539648765482935955">"Lebo"</string>
@@ -237,16 +236,15 @@
<string name="pref_camera_id_title" msgid="4040791582294635851">"Chagua kamera"</string>
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Nyuma"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Mbele"</string>
- <string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Rekodi mahali"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"MAHALI"</string>
- <string name="pref_camera_timer_title" msgid="3105232208281893389">"Kipima muda"</string>
+ <string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Mahali pa hifadhi"</string>
+ <string name="pref_camera_timer_title" msgid="3105232208281893389">"Kipima muda cha kuhesabu"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"Sekunde 1"</item>
<item quantity="other" msgid="6455381617076792481">"Sekunde %d"</item>
</plurals>
<!-- no translation found for pref_camera_timer_sound_default (7066624532144402253) -->
<skip />
- <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"Toa mlio inapohesabu"</string>
+ <string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"Toa mlio wakati wa kuhesabu"</string>
<string name="setting_off" msgid="4480039384202951946">"Imezimwa"</string>
<string name="setting_on" msgid="8602246224465348901">"Imewashwa"</string>
<string name="pref_video_quality_title" msgid="8245379279801096922">"Ubora wa video"</string>
@@ -256,13 +254,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Mipangilio ya kamera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Mipangilio ya kamkoda"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Ukubwa wa picha"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"Pikseli 13M"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"Pikseli 8M"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"Pikseli 5M"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"Pikseli za 4M"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"Pikseli 3M"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"Pikseli 2M"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"Pikseli za 2M (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"Pikseli 1.3M"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"Pikseli 1M"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -271,55 +266,27 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Otomatiki"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Pasipo mwisho"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"OTOMATIKI"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"PASIPO MWISHO"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Hali ya mweka"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"HALI YA MWEKO"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Otomatiki"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Washa"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Zima"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"MWEKA OTOMATIKI"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"MWAKO UMEWASHWA"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"MWAKO UMEZIMWA"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Usawazishaji wa weupe"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"USAWAZISHAJI WA WEUPE"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Kioto"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"King\'arishaji"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Mwangaza wa mchana"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Kiakisi mwanga"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Mawingu"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"OTOMATIKI"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"KING\'ARISHAJI"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"MCHANA"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"KIAKISI MWANGA"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"MAWINGU"</string>
- <string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Hali ya mandhari"</string>
+ <string name="pref_camera_scenemode_title" msgid="1420535844292504016">"gumzo ya mandhari"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Otomatiki"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
<string name="pref_camera_scenemode_entry_action" msgid="616748587566110484">"Kitendo"</string>
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Usiku"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Machweo"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Karamu"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"HAKUNA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"KITENDO"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"USIKU"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"MACHWEO"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"SHEREHE"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"KIPIMA MUDA"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"KIPIMA WAKATI KIMEZIMWA"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"SEKUNDE 1"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"SEKUNDE 3"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"SEKUNDE 10"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"SEKUNDE 15"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Haiwezi kuchaguliwa ikiwa katika hali ya mandhari."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Kiasi cha mwangaza"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"MFICHUO"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"KAMERA YA MBELE"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"KAMERA YA NYUMA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"SAWA"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Hifadhi yako ya USB inaishiwa na nafasi. Badilisha mipangilio ya ubora au futa baadhi ya picha au faili."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Nafasi ya kadi yako ya SD inaelekea kuisha. Badlisha mpangilio wa ubora au futa baadhi ya picha au faili zingine."</string>
@@ -372,10 +339,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Ukaguzi umeghairiwa"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Ukaguzi umekamilika"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Kagua ukaguzi"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Cheza video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Sitisha video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Pakia video upya"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Ubao wa muda wa kicheza video"</string>
<string name="capital_on" msgid="5491353494964003567">"IMEWASHWA"</string>
<string name="capital_off" msgid="7231052688467970897">"IMEZIMWA"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Imezimwa"</string>
@@ -424,7 +387,7 @@
<string name="time_lapse_interval_set" msgid="2486386210951700943">"Imekamilika"</string>
<string name="set_time_interval" msgid="2970567717633813771">"Weka Nafasi ya Muda"</string>
<string name="set_time_interval_help" msgid="6665849510484821483">"Kipengele cha muda kupita kimezimika. Kiwashe ili kuweka nafasi ya muda."</string>
- <string name="set_timer_help" msgid="5007708849404589472">"Kipima muda kimezimwa. Kiwashe ili kihesabu kabla ya kupiga picha."</string>
+ <string name="set_timer_help" msgid="5007708849404589472">"Kipima muda cha kuhesabu kimezimwa. Kiwashe ili kihesabu kabla ya kupiga picha."</string>
<string name="set_duration" msgid="5578035312407161304">"Weka muda katika sekunde"</string>
<string name="count_down_title_text" msgid="4976386810910453266">"Inahesabu ili kupiga picha"</string>
<string name="remember_location_title" msgid="9060472929006917810">"Kumbuka maeneo ya picha?"</string>
@@ -435,8 +398,6 @@
<string name="menu_search" msgid="7580008232297437190">"Tafuta"</string>
<string name="tab_photos" msgid="9110813680630313419">"Picha"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albamu"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"CHAGUO ZAIDI"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"MIPANGILIO"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"Picha %1$d"</item>
<item quantity="other" msgid="3813306834113858135">"Picha %1$d"</item>
diff --git a/res/values-th/filtershow_strings.xml b/res/values-th/filtershow_strings.xml
index 311e89e..0b98128 100644
--- a/res/values-th/filtershow_strings.xml
+++ b/res/values-th/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"กำลังตั้งค่าวอลเปเปอร์"</string>
- <string name="download_failure" msgid="5923323939788582895">"ไม่สามารถดาวน์โหลดภาพ เครือข่ายไม่พร้อมใช้งาน"</string>
<string name="original" msgid="3524493791230430897">"ต้นฉบับ"</string>
<string name="borders" msgid="2067345080568684614">"ขอบ"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"เลิกทำ"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"ทำซ้ำ"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"แสดงเอฟเฟ็กต์ที่ใช้"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"ซ่อนเอฟเฟ็กต์ที่ใช้"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"แสดงประวัติ"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"ซ่อนประวัติ"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"สถานะแสดงภาพ"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"สถานะซ่อนภาพ"</string>
<string name="menu_settings" msgid="6428291655769260831">"การตั้งค่า"</string>
<string name="unsaved" msgid="8704442449002374375">"มีการเปลี่ยนแปลงที่ไม่ได้บันทึกไปยังภาพนี้"</string>
<string name="save_before_exit" msgid="2680660633675916712">"คุณต้องการบันทึกก่อนที่จะออกหรือไม่"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"เลือกสี"</string>
<string name="draw_size_title" msgid="3121649039610273977">"เลือกขนาด"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"ตกลง"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"ต้นฉบับ"</string>
- <string name="state_panel_result" msgid="318640531123298676">"ผลลัพธ์"</string>
</resources>
diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml
index 3d4889b..b62c2f9 100644
--- a/res/values-th/strings.xml
+++ b/res/values-th/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"หมุนไปทางขวา"</string>
<string name="no_such_item" msgid="5315144556325243400">"ไม่พบรายการ"</string>
<string name="edit" msgid="1502273844748580847">"แก้ไข"</string>
- <string name="simple_edit" msgid="2792835918347498211">"แก้ไขแบบง่าย"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"กำลังประมวลผลคำขอให้แคช"</string>
<string name="caching_label" msgid="4521059045896269095">"กำลังแคช..."</string>
<string name="crop_action" msgid="3427470284074377001">"ตัด"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"ย้อนกลับ"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"ด้านหน้า"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"ตำแหน่งจัดเก็บ"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"ตำแหน่ง"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"ตัวจับเวลาถอยหลัง"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 วินาที"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"การตั้งค่ากล้องถ่ายรูป"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"การตั้งค่ากล้องวิดีโอ"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"ขนาดของภาพ"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 ล้านพิกเซล"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 ล้านพิกเซล"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 ล้านพิกเซล"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 ล้านพิกเซล"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 ล้านพิกเซล"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 ล้านพิกเซล"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M พิกเซล(16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3 ล้านพิกเซล"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 ล้านพิกเซล"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"อัตโนมัติ"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"อินฟินิตี"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"มาโคร"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"อัตโนมัติ"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"อินฟินิตี"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"มาโคร"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"โหมดแฟลช"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"โหมดแฟลช"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"อัตโนมัติ"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"เปิด"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"ปิด"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"แฟลชอัตโนมัติ"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"เปิดแฟลช"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"ปิดแฟลช"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"ไวต์บาลานซ์"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"ไวท์บาลานซ์"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"อัตโนมัติ"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"หลอดไส้"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"กลางวัน"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"ฟลูออเรสเซนต์"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"เมฆมาก"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"อัตโนมัติ"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"หลอดไส้"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"กลางวัน"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ฟลูออเรสเซนต์"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"เมฆมาก"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"โหมดสำเร็จรูป"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"อัตโนมัติ"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"กลางคืน"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"ดวงอาทิตย์ตก"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"งานเลี้ยง"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"ไม่มี"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"การทำงาน"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"กลางคืน"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ดวงอาทิตย์ตก"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ปาร์ตี้"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ตัวจับเวลาถอยหลัง"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ตัวจับเวลาปิด"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 วินาที"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 วินาที"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 วินาที"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 วินาที"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"ไม่สามารถเลือกได้ในโหมดสำเร็จรูป"</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"การรับแสง"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"การรับแสง"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"กล้องด้านหน้า"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"กล้องด้านหลัง"</string>
<string name="dialog_ok" msgid="6263301364153382152">"ตกลง"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"ที่เก็บข้อมูล USB ของคุณไม่มีพื้นที่เหลือ ให้เปลี่ยนการตั้งค่าคุณภาพหรือลบบางภาพหรือไฟล์อื่นๆ"</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"การ์ด SD ของคุณไม่มีพื้นที่เหลือ ให้เปลี่ยนการตั้งค่าคุณภาพหรือลบบางภาพหรือไฟล์อื่นๆ"</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"ไม่ผ่านการตรวจสอบ"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"ผ่านการตรวจสอบ"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"ตรวจสอบการถ่ายภาพ/วิดีโอใหม่"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"เล่นวิดีโอ"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"หยุดวิดีโอชั่วคราว"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"โหลดวิดีโอซ้ำ"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"แถบเวลาของโปรแกรมเล่นวิดีโอ"</string>
<string name="capital_on" msgid="5491353494964003567">"เปิด"</string>
<string name="capital_off" msgid="7231052688467970897">"ปิด"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"ปิด"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"ค้นหา"</string>
<string name="tab_photos" msgid="9110813680630313419">"รูปภาพ"</string>
<string name="tab_albums" msgid="8079449907770685691">"อัลบั้ม"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ตัวเลือกเพิ่มเติม"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"การตั้งค่า"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d ภาพ"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d ภาพ"</item>
diff --git a/res/values-tl/filtershow_strings.xml b/res/values-tl/filtershow_strings.xml
index e0d5b10..947db42 100644
--- a/res/values-tl/filtershow_strings.xml
+++ b/res/values-tl/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Itinatakda ang wallpaper"</string>
- <string name="download_failure" msgid="5923323939788582895">"Hindi ma-download ang larawan. Hindi available ang network."</string>
<string name="original" msgid="3524493791230430897">"Orihinal"</string>
<string name="borders" msgid="2067345080568684614">"Mga Border"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"I-undo"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"I-redo"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Ipakita Mga Inilapat na Effect"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Itago Mga Inilapat na Effect"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Ipakita Kasaysayan"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Kasaysayan Pagtago"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Ipakita Image State"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Itago Image State"</string>
<string name="menu_settings" msgid="6428291655769260831">"Mga Setting"</string>
<string name="unsaved" msgid="8704442449002374375">"May mga hindi naka-save na pagbabago sa larawang ito."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Gusto mo bang mag-save bago lumabas?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Pumili ng Kulay"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Pumili ng Laki"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Orihinal"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Resulta"</string>
</resources>
diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml
index ca5dfb8..82c2839 100644
--- a/res/values-tl/strings.xml
+++ b/res/values-tl/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"I-rotate pakanan"</string>
<string name="no_such_item" msgid="5315144556325243400">"Hindi mahanap ang item."</string>
<string name="edit" msgid="1502273844748580847">"I-edit"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Simpleng Pag-edit"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Pinoproseso ang mga kahilingan sa pag-cache"</string>
<string name="caching_label" msgid="4521059045896269095">"Nagka-cache…"</string>
<string name="crop_action" msgid="3427470284074377001">"I-crop"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Bumalik"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Harap"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Iimbak ang lokasyon"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"LOKASYON"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Timer ng countdown"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 segundo"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Mga setting ng kamera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Mga setting ng camcorder"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Laki ng larawan"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M pixels"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M pixels"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M pixels"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M pixels"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M pixels"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M pixels"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M pixel (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3M pixels"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M pixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Auto"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Walang Katapusan"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"AUTO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"INFINITY"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Flash mode"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"FLASH MODE"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Auto"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Naka-on"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Naka-off"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH AUTO"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"NAKA-ON ANG FLASH"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"NAKA-OFF ANG FLASH"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"White balance"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"WHITE BALANCE"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Auto"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Napakaliwanag"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Liwanag ng araw"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Fluorescent"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Maulap"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"AUTO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"INCANDESCENT"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"DAYLIGHT"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLUORESCENT"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"CLOUDY"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Scene mode"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Auto"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Gabi"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Paglubog ng araw"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Partido"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"WALA"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ACTION"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"NIGHT"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"SUNSET"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"PARTY"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"COUNTDOWN TIMER"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"NAKA-OFF ANG TIMER"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SEGUNDO"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SEGUNDO"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SEGUNDO"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SEGUNDO"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Hindi mapipili sa mode ng scene."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Pagkakalantad"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"EXPOSURE"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"CAMERA SA HARAP"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"CAMERA SA LIKOD"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Nauubusan na ng puwang ang iyong imbakan na USB. Baguhin ang setting ng kalidad o tanggalin ang ilan sa mga larawan o ibang mga file."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Nauubusan na ng puwang ang SD card. Baguhin ang setting ng kalidad o tanggalin ang ilan sa mga larawan o ibang mga file."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Suriin ang pagkansela"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Tapos na ang pagsusuri"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Suriin ang muling pagkuha"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"I-play ang video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"I-pause ang video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"I-reload ang video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Bar ng oras ng video player"</string>
<string name="capital_on" msgid="5491353494964003567">"I-ON"</string>
<string name="capital_off" msgid="7231052688467970897">"I-OFF"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Pag-off"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Maghanap"</string>
<string name="tab_photos" msgid="9110813680630313419">"Mga Larawan"</string>
<string name="tab_albums" msgid="8079449907770685691">"Mga Album"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"HIGIT PANG MGA PAGPIPILIAN"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"MGA SETTING"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d larawan"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d larawan"</item>
diff --git a/res/values-tr/filtershow_strings.xml b/res/values-tr/filtershow_strings.xml
index 585e789..b460ef6 100644
--- a/res/values-tr/filtershow_strings.xml
+++ b/res/values-tr/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Duvar kağıdı ayarlanıyor"</string>
- <string name="download_failure" msgid="5923323939788582895">"Fotoğraf indirilemedi. Ağ kullanılamıyor."</string>
<string name="original" msgid="3524493791230430897">"Orijinal"</string>
<string name="borders" msgid="2067345080568684614">"Kenarlıklar"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Geri al"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Yeniden yap"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Uygulanan Efektleri Göster"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Uygulanan Efektleri Gizle"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Geçmişi Göster"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Geçmişi Gizle"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Resim Durumunu Göster"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Resim Durumunu Gizle"</string>
<string name="menu_settings" msgid="6428291655769260831">"Ayarlar"</string>
<string name="unsaved" msgid="8704442449002374375">"Bu resimde kaydedilmemiş değişiklikler var."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Çıkmadan önce kaydetmek ister misiniz?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Renk Seçin"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Boyut Seçin"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"Tamam"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Orijinal"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Sonuç"</string>
</resources>
diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml
index 946688f..90407c0 100644
--- a/res/values-tr/strings.xml
+++ b/res/values-tr/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Sağa döndür"</string>
<string name="no_such_item" msgid="5315144556325243400">"Öğe bulunamadı."</string>
<string name="edit" msgid="1502273844748580847">"Düzenle"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Basit Düzenleme"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Önbelleğe alma istekleri işleniyor"</string>
<string name="caching_label" msgid="4521059045896269095">"Önbelleğe alınıyor..."</string>
<string name="crop_action" msgid="3427470284074377001">"Kırp"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Arka"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Ön"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Depo konumu"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"KONUM"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Zamanlayıcı"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 saniye"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Kamera ayarları"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Kamera ayarları"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Resim boyutu"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 megapiksel"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 M piksel"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M piksel"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 M piksel"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M piksel"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M piksel"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 M piksel (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3M piksel"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M piksel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Otomatik"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Sonsuz"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Makro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"OTOMATİK"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"SONSUZ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MAKRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Flaş modu"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"FLAŞ MODU"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Otomatik"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Açık"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Kapalı"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"OTOMATİK FLAŞ"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"FLAŞ AÇIK"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"FLAŞ KAPALI"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Beyaz dengesi"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"BEYAZ DENGESİ"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Otomatik"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Ampul"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Gün Işığı"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Floresan"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Bulutlu"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"OTOMATİK"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"AMPUL"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"GÜN IŞIĞI"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"FLORESAN"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"BULUTLU"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Sahne modu"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Otomatik"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Gece"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Gün batımı"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Parti"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"YOK"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"AKSİYON"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"GECE"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"GÜN BATIMI"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"PARTİ"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"GERİ SAYIM ZAMANLAYICI"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ZAMANLAYICI KAPALI"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 SANİYE"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 SANİYE"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 SANİYE"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 SANİYE"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Sahne modunda seçilemez."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Pozlama"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"POZLAMA"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"ÖN KAMERA"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"ARKA KAMERA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"Tamam"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"USB belleğinizde boş alan azaldı. Kalite ayarını değiştirin veya bazı resimleri ya da diğer dosyaları silin."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"SD kartınızda boş alan azaldı. Kalite ayarını değiştirin veya bazı resimleri ya da diğer dosyaları silin."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Yorumu iptal et"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Yorum tamamlandı"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"İncelemede tekrar çek"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Videoyu oynat"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Videoyu duraklat"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Videoyu yeniden yükle"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Video oynatıcı zaman çubuğu"</string>
<string name="capital_on" msgid="5491353494964003567">"AÇ"</string>
<string name="capital_off" msgid="7231052688467970897">"KAPAT"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Kapalı"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Ara"</string>
<string name="tab_photos" msgid="9110813680630313419">"Fotoğraflar"</string>
<string name="tab_albums" msgid="8079449907770685691">"Albümler"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"DİĞER SEÇENEKLER"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"AYARLAR"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d fotoğraf"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotoğraf"</item>
diff --git a/res/values-uk/filtershow_strings.xml b/res/values-uk/filtershow_strings.xml
index dcc2098..f35d760 100644
--- a/res/values-uk/filtershow_strings.xml
+++ b/res/values-uk/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Встановлення фонового малюнка"</string>
- <string name="download_failure" msgid="5923323939788582895">"Не вдалося завантажити фотографію. Мережа не доступна."</string>
<string name="original" msgid="3524493791230430897">"Оригінал"</string>
<string name="borders" msgid="2067345080568684614">"Облямівка"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Відмінити"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Повторити"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Показати застосовані ефекти"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Сховати застосовані ефекти"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Показати історію"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Сховати історію"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Показ. стан зображ."</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Сховати стан зображ."</string>
<string name="menu_settings" msgid="6428291655769260831">"Налаштування"</string>
<string name="unsaved" msgid="8704442449002374375">"У зображенні є незбережені зміни."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Зберегти перед виходом?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Вибрати колір"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Вибрати розмір"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"ОК"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Оригінал"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Результат"</string>
</resources>
diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml
index f894853..fc01c4a 100644
--- a/res/values-uk/strings.xml
+++ b/res/values-uk/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Поверн. вправо"</string>
<string name="no_such_item" msgid="5315144556325243400">"Не вдалося знайти елемент."</string>
<string name="edit" msgid="1502273844748580847">"Редагувати"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Просте редагування"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Виконується обробка запитів кешування"</string>
<string name="caching_label" msgid="4521059045896269095">"Кешування..."</string>
<string name="crop_action" msgid="3427470284074377001">"Обрізати"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Задня камера"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Передня камера"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Геотеги"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"МІСЦЕЗНАХОДЖЕННЯ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Таймер зворотного відліку"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 с"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Налаштування камери"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Налашт-ня відеокамери"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Розмір фото"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13 Мпікс."</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8 мегапікселів"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5 Мпікс"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4 Мпікс."</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3 Мпікс"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2 Мпікс"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2 Мпікс. (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3 Mпікс"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1 Мпікс"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Автом."</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Безкінечн."</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Макро"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"АВТО"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"БЕЗКІНЕЧНІСТЬ"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"МАКРО"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Режим спалаху"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"РЕЖИМ СПАЛАХУ"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Автом."</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Увімк."</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Вимк."</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"АВТОМАТИЧНИЙ СПАЛАХ"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"СПАЛАХ УВІМК."</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"СПАЛАХ ВИМК."</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Баланс білого"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"БАЛАНС БІЛОГО"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Автом."</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Лампа розжар."</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Сонячно"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Флуоресцентний"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Хмарно"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"АВТО"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ЛАМПА РОЗЖАРЮВАННЯ"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"СОНЯЧНО"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"ЛАМПА ДЕННОГО СВІТЛА"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"ХМАРНО"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Режим зйомки"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Автом."</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Ніч"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Захід сонця"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"У приміщенні"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"НЕМАЄ"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"СПОРТ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"НІЧ"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"ЗАХІД СОНЦЯ"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"ВЕЧІРКА"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ТАЙМЕР ЗВОРОТНОГО ВІДЛІКУ"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ТАЙМЕР ВИМКНЕНО"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 СЕКУНДА"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 СЕКУНДИ"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 СЕКУНД"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 СЕКУНД"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Неможливо вибрати в режимі зйомки."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Експозиція"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ЕКСПОЗИЦІЯ"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"КАМЕРА НА ПЕРЕДНІЙ ПАНЕЛІ"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"КАМЕРА НА ЗАДНІЙ ПАНЕЛІ"</string>
<string name="dialog_ok" msgid="6263301364153382152">"ОК"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"На носії USB недостатньо місця. Змініть налаштування якості чи видаліть зображення або інші файли."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"На карті SD недостатньо місця. Змініть налаштування якості чи видаліть зображення або інші файли."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Cкасувати перегляд"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Виконати перегляд"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Повторити в режимі перегляду"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Відтворити відео"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Призупинити відео"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Перезавантажити відео"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Панель часу відеопрогравача"</string>
<string name="capital_on" msgid="5491353494964003567">"УВІМКНЕНО"</string>
<string name="capital_off" msgid="7231052688467970897">"ВИМКНЕНО"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Вимкнено"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Пошук"</string>
<string name="tab_photos" msgid="9110813680630313419">"Фотографії"</string>
<string name="tab_albums" msgid="8079449907770685691">"Альбоми"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"ІНШІ ОПЦІЇ"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"НАЛАШТУВАННЯ"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d фото"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d фото"</item>
diff --git a/res/values-vi/filtershow_strings.xml b/res/values-vi/filtershow_strings.xml
index 01f81f2..60b2f03 100644
--- a/res/values-vi/filtershow_strings.xml
+++ b/res/values-vi/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Đang đặt hình nền"</string>
- <string name="download_failure" msgid="5923323939788582895">"Không thể tải xuống ảnh. Không có mạng."</string>
<string name="original" msgid="3524493791230430897">"Gốc"</string>
<string name="borders" msgid="2067345080568684614">"Đường viền"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Hoàn tác"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Làm lại"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Hiển thị các hiệu ứng được áp dụng"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Ẩn các hiệu ứng được áp dụng"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Hiển thị lịch sử"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Ẩn lịch sử"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Hiện tr.thái hình ảnh"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Ẩn tr.thái hình ảnh"</string>
<string name="menu_settings" msgid="6428291655769260831">"Cài đặt"</string>
<string name="unsaved" msgid="8704442449002374375">"Có các thay đổi chưa được lưu đối với hình ảnh này."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Bạn có muốn lưu trước khi thoát không?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Chọn màu"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Chọn kích thước"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"OK"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Gốc"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Kết quả"</string>
</resources>
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index aaea436..6672f13 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Xoay phải"</string>
<string name="no_such_item" msgid="5315144556325243400">"Không thể tìm thấy mục."</string>
<string name="edit" msgid="1502273844748580847">"Chỉnh sửa"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Chỉnh sửa đơn giản"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Đang xử lý yêu cầu lưu vào bộ nhớ cache"</string>
<string name="caching_label" msgid="4521059045896269095">"Lưu cache..."</string>
<string name="crop_action" msgid="3427470284074377001">"Cắt"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Quay lại"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Trước"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Vị trí lưu trữ"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"VỊ TRÍ"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Đồng hồ đếm ngược"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 giây"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Cài đặt máy ảnh"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Cài đặt máy quay video"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Kích thước ảnh"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M pixel"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M pixel"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M pixel"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M pixel"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M pixel"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M pixel"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M pixel (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1,3M pixel"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M pixel"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Tự động"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Vô cùng"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Macro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"TỰ ĐỘNG"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"VÔ CỰC"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"MACRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Chế độ flash"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"CHẾ ĐỘ FLASH"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Tự động"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Bật"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Tắt"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"FLASH TỰ ĐỘNG"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"BẬT FLASH"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"TẮT FLASH"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Cân bằng trắng"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"CÂN BẰNG TRẮNG"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Tự động"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Ánh sáng nóng"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Ánh sáng ban ngày"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Huỳnh quang"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Nhiều mây"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"TỰ ĐỘNG"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"ÁNH SÁNG NÓNG"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"ÁNH SÁNG BAN NGÀY"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"HUỲNH QUANG"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"NHIỀU MÂY"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Chế độ chụp cảnh"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Tự động"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Ban đêm"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Hoàng hôn"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Bữa tiệc"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"KHÔNG CÓ"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"TÁC VỤ"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"ĐÊM"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"HOÀNG HÔN"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"BỮA TIỆC"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ĐỒNG HỒ ĐẾM NGƯỢC"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"TẮT BỘ TÍNH GIỜ"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 GIÂY"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 GIÂY"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 GIÂY"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 GIÂY"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Không thể chọn trong chế độ cảnh."</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Phơi sáng"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"ĐỘ PHƠI SÁNG"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"MÁY ẢNH MẶT TRƯỚC"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"MÁY ẢNH MẶT SAU"</string>
<string name="dialog_ok" msgid="6263301364153382152">"OK"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Bộ nhớ USB của bạn sắp hết dung lượng. Thay đổi cài đặt chất lượng hoặc xóa một số ảnh hoặc tệp khác."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Thẻ SD của bạn sắp hết dung lượng. Thay đổi cài đặt chất lượng hoặc xóa một số ảnh hoặc tệp khác."</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Hủy bài đánh giá"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Đánh giá xong"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Xem lại ảnh chụp lại"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Phát video"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Tạm dừng video"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Tải lại video"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Thanh thời gian của trình phát video"</string>
<string name="capital_on" msgid="5491353494964003567">"BẬT"</string>
<string name="capital_off" msgid="7231052688467970897">"TẮT"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Tắt"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"Tìm kiếm"</string>
<string name="tab_photos" msgid="9110813680630313419">"Ảnh"</string>
<string name="tab_albums" msgid="8079449907770685691">"Album"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"TÙY CHỌN KHÁC"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"CÀI ĐẶT"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d ảnh"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d ảnh"</item>
diff --git a/res/values-xlarge/filtershow_values.xml b/res/values-xlarge/filtershow_values.xml
index 1098ee0..6d0906a 100644
--- a/res/values-xlarge/filtershow_values.xml
+++ b/res/values-xlarge/filtershow_values.xml
@@ -17,4 +17,19 @@
<resources>
<!-- Specify the screen orientation -->
<bool name="only_use_portrait">false</bool>
+
+ <!-- Category Panel Height -->
+ <dimen name="category_panel_height">106dip</dimen>
+
+ <!-- Category Panel Icon Size -->
+ <dimen name="category_panel_icon_size">84dip</dimen>
+
+ <!-- Category Panel Text Size -->
+ <dimen name="category_panel_text_size">14dip</dimen>
+
+ <!-- Category Panel Text Size -->
+ <dimen name="category_panel_margin">4dip</dimen>
+
+ <!-- draw check UI size -->
+ <dimen name="draw_ui_width">350dip</dimen>
</resources>
\ No newline at end of file
diff --git a/res/values-zh-rCN/filtershow_strings.xml b/res/values-zh-rCN/filtershow_strings.xml
index 1c17e79..ec5f099 100644
--- a/res/values-zh-rCN/filtershow_strings.xml
+++ b/res/values-zh-rCN/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"正在设置壁纸"</string>
- <string name="download_failure" msgid="5923323939788582895">"未连接到网络,因此无法下载照片。"</string>
<string name="original" msgid="3524493791230430897">"原图"</string>
<string name="borders" msgid="2067345080568684614">"边框"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"撤消"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"重做"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"显示应用的效果"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"隐藏应用的效果"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"显示历史记录"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"隐藏历史记录"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"显示图片状态"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"隐藏图片状态"</string>
<string name="menu_settings" msgid="6428291655769260831">"设置"</string>
<string name="unsaved" msgid="8704442449002374375">"此图片的更改尚未保存。"</string>
<string name="save_before_exit" msgid="2680660633675916712">"要在退出之前保存更改吗?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"选择颜色"</string>
<string name="draw_size_title" msgid="3121649039610273977">"选择大小"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"确定"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"原图"</string>
- <string name="state_panel_result" msgid="318640531123298676">"结果"</string>
</resources>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index c917828..cb89a4d 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"向右旋转"</string>
<string name="no_such_item" msgid="5315144556325243400">"找不到指定的项。"</string>
<string name="edit" msgid="1502273844748580847">"编辑"</string>
- <string name="simple_edit" msgid="2792835918347498211">"简单编辑"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"正在处理缓存请求"</string>
<string name="caching_label" msgid="4521059045896269095">"正在缓存..."</string>
<string name="crop_action" msgid="3427470284074377001">"修剪"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"背面相机"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"正面相机"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"保存所在位置"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"位置"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"倒计时器"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1秒"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"相机设置"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"摄像机设置"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"照片大小"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"1300万像素"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"800 万像素"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"500 万像素"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"400万像素"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"300 万像素"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"200 万像素"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"200万像素(16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"130 万像素"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"100 万像素"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"自动"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"无限远"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"微距"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"自动"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"无限远"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"微距"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"闪光模式"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"闪光灯模式"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"自动"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"开"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"关"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"自动闪光灯"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"打开闪光灯"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"关闭闪光灯"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"白平衡"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"白平衡"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"自动"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"白炽光"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"日光"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"荧光"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"阴天"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"自动"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"白炽光"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"日光"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"荧光"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"阴天"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"取景模式"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"自动"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"夜景"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"日落"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"派对"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"无"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"动作"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"夜晚"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"日落"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"聚会"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"倒计时器"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"关闭倒计时器"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1秒"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3秒"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10秒"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15秒"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"无法在取景模式下选择。"</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"曝光"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"曝光"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"前置摄像头"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"后置摄像头"</string>
<string name="dialog_ok" msgid="6263301364153382152">"确定"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"USB 存储设备空间不足,请更改照片品质设置,或删除某些照片或者其他文件。"</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"SD 卡空间不足,请更改照片品质设置,或删除某些照片或者其他文件。"</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"取消"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"完成"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"重拍"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"播放视频"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"暂停视频"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"重新加载视频"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"视频播放器时间栏"</string>
<string name="capital_on" msgid="5491353494964003567">"打开"</string>
<string name="capital_off" msgid="7231052688467970897">"关闭"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"关闭"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"搜索"</string>
<string name="tab_photos" msgid="9110813680630313419">"照片"</string>
<string name="tab_albums" msgid="8079449907770685691">"相册"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"更多选项"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"设置"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d张照片"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d张照片"</item>
diff --git a/res/values-zh-rTW/filtershow_strings.xml b/res/values-zh-rTW/filtershow_strings.xml
index 776b749..7bb6fb0 100644
--- a/res/values-zh-rTW/filtershow_strings.xml
+++ b/res/values-zh-rTW/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"正在設定桌布"</string>
- <string name="download_failure" msgid="5923323939788582895">"目前沒有網路連線,因此無法下載相片。"</string>
<string name="original" msgid="3524493791230430897">"原始"</string>
<string name="borders" msgid="2067345080568684614">"邊框"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"復原"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"重做"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"顯示套用的效果"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"隱藏套用的效果"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"顯示紀錄"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"隱藏紀錄"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"顯示圖片狀態"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"隱藏圖片狀態"</string>
<string name="menu_settings" msgid="6428291655769260831">"設定"</string>
<string name="unsaved" msgid="8704442449002374375">"這張圖片的變更尚未儲存。"</string>
<string name="save_before_exit" msgid="2680660633675916712">"您要在結束前儲存變更嗎?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"選擇顏色"</string>
<string name="draw_size_title" msgid="3121649039610273977">"選擇尺寸"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"確定"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"原始"</string>
- <string name="state_panel_result" msgid="318640531123298676">"結果"</string>
</resources>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index c2b8d83..079ea5d 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -88,7 +88,6 @@
<string name="rotate_right" msgid="6776325835923384839">"向右旋轉"</string>
<string name="no_such_item" msgid="5315144556325243400">"找不到項目。"</string>
<string name="edit" msgid="1502273844748580847">"編輯"</string>
- <string name="simple_edit" msgid="2792835918347498211">"簡易編輯"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"正在處理快取要求"</string>
<string name="caching_label" msgid="4521059045896269095">"快取中…"</string>
<string name="crop_action" msgid="3427470284074377001">"裁剪"</string>
@@ -235,7 +234,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"後置鏡頭"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"前置鏡頭"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"儲存位置"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"地點"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"倒數計時器"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 秒"</item>
@@ -253,13 +251,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"相機設定"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"攝錄影機設定"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"相片大小"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"1300 萬像素"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"800 萬像素"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"500 萬像素"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"400 萬像素"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"300 萬像素"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"200 萬像素"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"200 萬像素 (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"130 萬像素"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"100 萬像素"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -268,29 +263,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"自動"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"無限遠"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"微距"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"自動"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"無限遠"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"微距"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"閃光模式"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"閃光燈模式"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"自動"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"開啟"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"關閉"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"自動閃光燈"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"開啟閃光燈"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"關閉閃光燈"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"白平衡"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"白平衡"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"自動"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"鎢絲燈"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"日光"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"螢光燈"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"陰天"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"自動"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"鎢絲燈"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"日光"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"螢光燈"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"陰天"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"場景模式"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"自動"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"HDR"</string>
@@ -298,25 +280,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"夜景"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"黃昏"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"派對模式"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"無"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"動態"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"夜景"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"黃昏"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"派對"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"倒數計時器"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"計時器已關閉"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 秒"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 秒"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 秒"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 秒"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"在場景模式中無法選取。"</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"曝光"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"曝光"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"高動態範圍"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"前置鏡頭"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"後置鏡頭"</string>
<string name="dialog_ok" msgid="6263301364153382152">"確定"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"您的 USB 儲存裝置的空間即將用盡,請變更圖片的品質設定,或是刪除部分圖片或其他檔案。"</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"您 SD 卡的空間即將不足,請變更圖片的品質設定,或是刪除部分圖片或其他檔案。"</string>
@@ -367,10 +334,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"檢閱取消"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"檢閱完成"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"檢查重拍"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"播放影片"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"暫停影片"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"重新載入影片"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"影片播放器時間軸"</string>
<string name="capital_on" msgid="5491353494964003567">"開啟"</string>
<string name="capital_off" msgid="7231052688467970897">"關閉"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"關閉"</string>
@@ -419,7 +382,7 @@
<string name="time_lapse_interval_set" msgid="2486386210951700943">"完成"</string>
<string name="set_time_interval" msgid="2970567717633813771">"設定時間間隔"</string>
<string name="set_time_interval_help" msgid="6665849510484821483">"延時攝影功能已關閉,請開啟以設定時間間格。"</string>
- <string name="set_timer_help" msgid="5007708849404589472">"倒數計時器目前為關閉狀態,開啟即可在拍照前倒數計時。"</string>
+ <string name="set_timer_help" msgid="5007708849404589472">"倒數計時器目前為關閉狀態,開啓即可在拍照前倒數計時。"</string>
<string name="set_duration" msgid="5578035312407161304">"設定倒數時間 (以秒為單位)"</string>
<string name="count_down_title_text" msgid="4976386810910453266">"拍照倒數計時中"</string>
<string name="remember_location_title" msgid="9060472929006917810">"記錄拍攝地點?"</string>
@@ -430,8 +393,6 @@
<string name="menu_search" msgid="7580008232297437190">"搜尋"</string>
<string name="tab_photos" msgid="9110813680630313419">"相片"</string>
<string name="tab_albums" msgid="8079449907770685691">"相簿"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"更多選項"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"設定"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d 張相片"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d 張相片"</item>
diff --git a/res/values-zu/filtershow_strings.xml b/res/values-zu/filtershow_strings.xml
index 93e04d2..8bdcbf0 100644
--- a/res/values-zu/filtershow_strings.xml
+++ b/res/values-zu/filtershow_strings.xml
@@ -21,13 +21,14 @@
<!-- no translation found for original_picture_text (3076213290079909698) -->
<skip />
<string name="setting_wallpaper" msgid="4679087092300036632">"Isetha isithombe sangemuva"</string>
- <string name="download_failure" msgid="5923323939788582895">"Ayikwazanga ukulanda isithombe. Inethiwekhi ayitholakali."</string>
<string name="original" msgid="3524493791230430897">"Oluqobo"</string>
<string name="borders" msgid="2067345080568684614">"Imingcele"</string>
<string name="filtershow_undo" msgid="6781743189243585101">"Hlehlisa"</string>
<string name="filtershow_redo" msgid="4219489910543059747">"Yenza kabusha"</string>
- <string name="show_imagestate_panel" msgid="281932769701043015">"Bonisa imiphumela esetshenzisiwe"</string>
- <string name="hide_imagestate_panel" msgid="7207643485811695257">"Fihla imiphumela esetshenzisiwe"</string>
+ <string name="show_history_panel" msgid="7785810372502120090">"Bonisa umlando"</string>
+ <string name="hide_history_panel" msgid="2082672248771133871">"Fihla umlando"</string>
+ <string name="show_imagestate_panel" msgid="7132294085840948243">"Bonisa isimo sesithombe"</string>
+ <string name="hide_imagestate_panel" msgid="1135313661068111161">"Fihla isimo sesithombe"</string>
<string name="menu_settings" msgid="6428291655769260831">"Izilungiselelo"</string>
<string name="unsaved" msgid="8704442449002374375">"Kukhona ushintsho olungalondolozwanga kulesi sithombe."</string>
<string name="save_before_exit" msgid="2680660633675916712">"Ufuna ukulondoloza ngaphambi kokuphuma?"</string>
@@ -92,6 +93,4 @@
<string name="color_pick_title" msgid="6195567431995308876">"Khetha umbala"</string>
<string name="draw_size_title" msgid="3121649039610273977">"Khetha usayizi"</string>
<string name="draw_size_accept" msgid="6781529716526190028">"KULUNGILE"</string>
- <string name="state_panel_original" msgid="9069584409934164419">"Okwangempela"</string>
- <string name="state_panel_result" msgid="318640531123298676">"Umphumela"</string>
</resources>
diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml
index 030ab22..7e88404 100644
--- a/res/values-zu/strings.xml
+++ b/res/values-zu/strings.xml
@@ -90,7 +90,6 @@
<string name="rotate_right" msgid="6776325835923384839">"Phendukisela kwesokudla"</string>
<string name="no_such_item" msgid="5315144556325243400">"Yehlulekile ukuthola into yakho."</string>
<string name="edit" msgid="1502273844748580847">"Hlela"</string>
- <string name="simple_edit" msgid="2792835918347498211">"Ukuhlela okulula"</string>
<string name="process_caching_requests" msgid="8722939570307386071">"Ilungisa izicelo zokufaka kwinqolobane"</string>
<string name="caching_label" msgid="4521059045896269095">"Ukulondoloza isikhashana..."</string>
<string name="crop_action" msgid="3427470284074377001">"Khropha"</string>
@@ -237,7 +236,6 @@
<string name="pref_camera_id_entry_back" msgid="5142699735103692485">"Emuva"</string>
<string name="pref_camera_id_entry_front" msgid="5668958706828733669">"Phambili"</string>
<string name="pref_camera_recordlocation_title" msgid="371208839215448917">"Gcina indawo"</string>
- <string name="pref_camera_location_label" msgid="2254270920298609161">"INDAWO"</string>
<string name="pref_camera_timer_title" msgid="3105232208281893389">"Isikali sesikhathi esibala ngokwehla"</string>
<plurals name="pref_camera_timer_entry">
<item quantity="one" msgid="1654523400981245448">"1 isekhondi"</item>
@@ -247,7 +245,7 @@
<skip />
<string name="pref_camera_timer_sound_title" msgid="2469008631966169105">"Bhipha ngesikhathi sokubala ngokwehla"</string>
<string name="setting_off" msgid="4480039384202951946">"Kucishile"</string>
- <string name="setting_on" msgid="8602246224465348901">"Vuliwe"</string>
+ <string name="setting_on" msgid="8602246224465348901">"Kuyakhanya"</string>
<string name="pref_video_quality_title" msgid="8245379279801096922">"Ikhwalithi yevidiyo"</string>
<string name="pref_video_quality_entry_high" msgid="8664038216234805914">"Phezulu"</string>
<string name="pref_video_quality_entry_low" msgid="7258507152393173784">"Phansi"</string>
@@ -255,13 +253,10 @@
<string name="pref_camera_settings_category" msgid="2576236450859613120">"Izilungiselelo zekhamera"</string>
<string name="pref_camcorder_settings_category" msgid="460313486231965141">"Izilungiselelo zekhamera enerekhoda"</string>
<string name="pref_camera_picturesize_title" msgid="4333724936665883006">"Usayizi wesithombe"</string>
- <string name="pref_camera_picturesize_entry_13mp" msgid="675309554194481780">"13M amaphikiseli"</string>
<string name="pref_camera_picturesize_entry_8mp" msgid="259953780932849079">"8M amaphikseli"</string>
<string name="pref_camera_picturesize_entry_5mp" msgid="2882928212030661159">"5M amaphikseli"</string>
- <string name="pref_camera_picturesize_entry_4mp" msgid="933242108272469142">"4M amaphikiseli"</string>
<string name="pref_camera_picturesize_entry_3mp" msgid="741415860337400696">"3M amaphikseli"</string>
<string name="pref_camera_picturesize_entry_2mp" msgid="1753709802245460393">"2M amaphikseli"</string>
- <string name="pref_camera_picturesize_entry_2mp_wide" msgid="5359490802026616612">"2M amaphikiseli (16:9)"</string>
<string name="pref_camera_picturesize_entry_1_3mp" msgid="829109608140747258">"1.3M amaphikseli"</string>
<string name="pref_camera_picturesize_entry_1mp" msgid="1669725616780375066">"1M amaphikseli"</string>
<string name="pref_camera_picturesize_entry_vga" msgid="806934254162981919">"VGA"</string>
@@ -270,29 +265,16 @@
<string name="pref_camera_focusmode_entry_auto" msgid="7374820710300362457">"Okuzenzakalelayo"</string>
<string name="pref_camera_focusmode_entry_infinity" msgid="3413922419264967552">"Kwaphakade"</string>
<string name="pref_camera_focusmode_entry_macro" msgid="4424489110551866161">"Imakhro"</string>
- <string name="pref_camera_focusmode_label_auto" msgid="8547956917516317183">"OKUZENZAKALELAYO"</string>
- <string name="pref_camera_focusmode_label_infinity" msgid="4272904160062531778">"KWAPHAKADE"</string>
- <string name="pref_camera_focusmode_label_macro" msgid="8749317592620908054">"IMAKHRO"</string>
<string name="pref_camera_flashmode_title" msgid="2287362477238791017">"Imodi yokufulesh"</string>
- <string name="pref_camera_flashmode_label" msgid="7546741624882856171">"IMODI YEFLESHI"</string>
<string name="pref_camera_flashmode_entry_auto" msgid="7288383434237457709">"Okuzenzakalelayo"</string>
<string name="pref_camera_flashmode_entry_on" msgid="5330043918845197616">"Vuliwe"</string>
<string name="pref_camera_flashmode_entry_off" msgid="867242186958805761">"Valiwe"</string>
- <string name="pref_camera_flashmode_label_auto" msgid="8854671890619026197">"UKUZENZAKALELA KWEFLESHI"</string>
- <string name="pref_camera_flashmode_label_on" msgid="7347504762794840140">"IFLESHI IVULIWE"</string>
- <string name="pref_camera_flashmode_label_off" msgid="3541596735596053416">"IFLESHI IVALIWE"</string>
<string name="pref_camera_whitebalance_title" msgid="677420930596673340">"Bhalansa ubumhlophe"</string>
- <string name="pref_camera_whitebalance_label" msgid="7467403405883190920">"UKULINGANA KOKUMHLOPHE"</string>
<string name="pref_camera_whitebalance_entry_auto" msgid="6580665476983469293">"Okuzenzakalelayo"</string>
<string name="pref_camera_whitebalance_entry_incandescent" msgid="8856667786449549938">"Mhlophe komlilo"</string>
<string name="pref_camera_whitebalance_entry_daylight" msgid="2534757270149561027">"Emini"</string>
<string name="pref_camera_whitebalance_entry_fluorescent" msgid="2435332872847454032">"Ukukhanya okumibalabala"</string>
<string name="pref_camera_whitebalance_entry_cloudy" msgid="3531996716997959326">"Kunamafu"</string>
- <string name="pref_camera_whitebalance_label_auto" msgid="1479694362310491429">"OKUZENZAKALELAYO"</string>
- <string name="pref_camera_whitebalance_label_incandescent" msgid="7427628260209908900">"MHLOPHE KOMLILO"</string>
- <string name="pref_camera_whitebalance_label_daylight" msgid="1859710806141461399">"EMINI"</string>
- <string name="pref_camera_whitebalance_label_fluorescent" msgid="5173251749161337707">"UKUKHANYA OKUMIBALABALA"</string>
- <string name="pref_camera_whitebalance_label_cloudy" msgid="8230173517179285320">"KUNAMAFU"</string>
<string name="pref_camera_scenemode_title" msgid="1420535844292504016">"Imodi yesigcawu"</string>
<string name="pref_camera_scenemode_entry_auto" msgid="7113995286836658648">"Okuzenzakalelayo"</string>
<string name="pref_camera_scenemode_entry_hdr" msgid="2923388802899511784">"i-HDR"</string>
@@ -300,25 +282,10 @@
<string name="pref_camera_scenemode_entry_night" msgid="7606898503102476329">"Ebusuku"</string>
<string name="pref_camera_scenemode_entry_sunset" msgid="181661154611507212">"Ukushona kwelanga"</string>
<string name="pref_camera_scenemode_entry_party" msgid="907053529286788253">"Phathi"</string>
- <string name="pref_camera_scenemode_label_auto" msgid="4475096836397300237">"LUTHO"</string>
- <string name="pref_camera_scenemode_label_action" msgid="964748409622151496">"ISENZO"</string>
- <string name="pref_camera_scenemode_label_night" msgid="1269871886845854574">"EBUSUKU"</string>
- <string name="pref_camera_scenemode_label_sunset" msgid="2802732082948866877">"UKUSHONA KWELANGA"</string>
- <string name="pref_camera_scenemode_label_party" msgid="1409459091844374828">"IPHATHI"</string>
- <string name="pref_camera_countdown_label" msgid="7592784692450586126">"ISIBALI SESHIKHATHI ESIBALA NGOKWEHLA"</string>
- <string name="pref_camera_countdown_label_off" msgid="4987856883590176585">"ISIKALI SESIKHATHI SIVALIWE"</string>
- <string name="pref_camera_countdown_label_one" msgid="1101814103087928898">"1 ISEKHONDI"</string>
- <string name="pref_camera_countdown_label_three" msgid="1047399297342955649">"3 AMASEKHONDI"</string>
- <string name="pref_camera_countdown_label_ten" msgid="6274681535347260279">"10 AMASEKHONDI"</string>
- <string name="pref_camera_countdown_label_fifteen" msgid="4544824246687597089">"15 AMASEKHONDI"</string>
<string name="not_selectable_in_scene_mode" msgid="2970291701448555126">"Akukhetheki esimweni sokubuka"</string>
<string name="pref_exposure_title" msgid="1229093066434614811">"Isibonelelo"</string>
- <string name="pref_exposure_label" msgid="552624394642497940">"UKUBONISWA"</string>
<!-- no translation found for pref_camera_hdr_default (1336869406134365882) -->
<skip />
- <string name="pref_camera_hdr_label" msgid="7217211253357027510">"I-HDR"</string>
- <string name="pref_camera_id_label_back" msgid="8745553500400332333">"IKHAMERA EPHAMBILI"</string>
- <string name="pref_camera_id_label_front" msgid="8699439330056996709">"IKHAMERA ENGEMUVA"</string>
<string name="dialog_ok" msgid="6263301364153382152">"KULUNGILE"</string>
<string name="spaceIsLow_content" product="nosdcard" msgid="4401325203349203177">"Isitoreji se-USB yakho siphelelwa yisikhala. Shintsha ilungiselelo lekhwalithi noma susa ezinye izithombe noma amanye amafayela."</string>
<string name="spaceIsLow_content" product="default" msgid="1732882643101247179">"Ikhadi lakho le-SD liphelelwa isikhathi. Shintsha ilungiselelo lekhwalithi noma susa eminye imifanekiso noma amanye amafayela."</string>
@@ -369,10 +336,6 @@
<string name="accessibility_review_cancel" msgid="9070531914908644686">"Buyekeza ukukhansela"</string>
<string name="accessibility_review_ok" msgid="7793302834271343168">"Ukubuyekeza kuphelile"</string>
<string name="accessibility_review_retake" msgid="659300290054705484">"Ukuphindwa kuthathwe kwesibuyekezo"</string>
- <string name="accessibility_play_video" msgid="7596298365794810207">"Dlala ividiyo"</string>
- <string name="accessibility_pause_video" msgid="6526344477133046653">"Misa ividiyo okwesikhashana"</string>
- <string name="accessibility_reload_video" msgid="3250335917598607232">"Layisha kabusha ividiyo"</string>
- <string name="accessibility_time_bar" msgid="1414029843602604531">"Ibha yesikhathi sesidlali sevidiyo"</string>
<string name="capital_on" msgid="5491353494964003567">"KUVULIWE"</string>
<string name="capital_off" msgid="7231052688467970897">"KUCINYIWE"</string>
<string name="pref_video_time_lapse_frame_interval_off" msgid="3490489191038309496">"Valiwe"</string>
@@ -432,8 +395,6 @@
<string name="menu_search" msgid="7580008232297437190">"Sesha"</string>
<string name="tab_photos" msgid="9110813680630313419">"Izithombe"</string>
<string name="tab_albums" msgid="8079449907770685691">"Ama-albhamu"</string>
- <string name="camera_menu_more_label" msgid="6868642182125198710">"IZINKETHO EZININGI"</string>
- <string name="camera_menu_settings_label" msgid="875454962069404723">"IZILUNGISELELO"</string>
<plurals name="number_of_photos">
<item quantity="one" msgid="6949174783125614798">"%1$d isithombe"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d izithombe"</item>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index c1bb52b..4fe9180 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -68,5 +68,6 @@
<color name="face_detect_start">#80ffffff</color>
<color name="face_detect_success">#8050d060</color>
<color name="face_detect_fail">#80d05060</color>
+ <color name="gray">#FFAAAAAA</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 7cc4be4..ef742d2 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (c) 2009, The Android Open Source Project
+<!-- 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.
@@ -94,7 +94,7 @@
<dimen name="zoom_font_size">14pt</dimen>
<dimen name="shutter_offset">-22dp</dimen>
<dimen name="size_thumbnail">200dip</dimen>
- <dimen name="size_preview">600dip</dimen>
+ <dimen name="size_preview">400dip</dimen>
<dimen name="navigation_bar_height">48dip</dimen>
<dimen name="navigation_bar_width">42dip</dimen>
<dimen name="capture_size">48dip</dimen>
@@ -102,4 +102,54 @@
<dimen name="capture_margin_right">16dip</dimen>
<dimen name="capture_margin_top">16dip</dimen>
<dimen name="camera_controls_size">0dip</dimen>
+ <dimen name="camera_film_strip_gap">32dip</dimen>
+
+ <dimen name="appwidget_width">180dp</dimen>
+ <dimen name="appwidget_height">180dp</dimen>
+ <dimen name="stack_photo_width">160dp</dimen>
+ <dimen name="stack_photo_height">120dp</dimen>
+
+ <!-- configuration for legacy album set page -->
+ <integer name="albumset_rows_land">2</integer>
+ <integer name="albumset_rows_port">3</integer>
+ <dimen name="albumset_padding_top">7dp</dimen>
+ <dimen name="albumset_padding_bottom">7dp</dimen>
+ <dimen name="albumset_slot_gap">7dp</dimen>
+
+ <dimen name="albumset_label_background_height">30dp</dimen>
+ <dimen name="albumset_title_offset">10dp</dimen>
+ <dimen name="albumset_count_offset">10dp</dimen>
+ <dimen name="albumset_title_font_size">12sp</dimen>
+ <dimen name="albumset_count_font_size">9sp</dimen>
+ <dimen name="albumset_left_margin">2dp</dimen>
+ <dimen name="albumset_title_right_margin">20dp</dimen>
+ <dimen name="albumset_icon_size">25dp</dimen>
+
+ <!-- configuration for album page -->
+ <integer name="album_rows_land">2</integer>
+ <integer name="album_rows_port">4</integer>
+ <dimen name="album_slot_gap">5dp</dimen>
+
+ <!-- configuration for manage page -->
+ <dimen name="cache_pin_size">24dp</dimen>
+ <dimen name="cache_pin_margin">8dp</dimen>
+
+ <!-- for manage cache bar -->
+ <dimen name="manage_cache_bottom_height">48dp</dimen>
+
+ <!-- configuration for filtershow UI -->
+ <dimen name="thumbnail_size">96dip</dimen>
+ <dimen name="thumbnail_margin">3dip</dimen>
+ <dimen name="action_item_height">175dip</dimen>
+ <dimen name="touch_circle_size">8dp</dimen>
+
+ <!-- configuration for album set page -->
+ <dimen name="album_set_item_image_height">120dp</dimen>
+ <dimen name="album_set_item_width">140dp</dimen>
+
+ <!-- configuration for preview in editor -->
+ <dimen name="photoeditor_text_size">12dp</dimen>
+ <dimen name="photoeditor_text_padding">10dp</dimen>
+ <dimen name="photoeditor_original_text_size">18dp</dimen>
+ <dimen name="photoeditor_original_text_margin">4dp</dimen>
</resources>
diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml
deleted file mode 100644
index 94697d1..0000000
--- a/res/values/dimensions.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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>
- <dimen name="appwidget_width">180dp</dimen>
- <dimen name="appwidget_height">180dp</dimen>
- <dimen name="stack_photo_width">160dp</dimen>
- <dimen name="stack_photo_height">120dp</dimen>
-
- <!-- configuration for legacy album set page -->
- <integer name="albumset_rows_land">2</integer>
- <integer name="albumset_rows_port">3</integer>
- <dimen name="albumset_padding_top">7dp</dimen>
- <dimen name="albumset_padding_bottom">7dp</dimen>
- <dimen name="albumset_slot_gap">7dp</dimen>
-
- <dimen name="albumset_label_background_height">30dp</dimen>
- <dimen name="albumset_title_offset">10dp</dimen>
- <dimen name="albumset_count_offset">10dp</dimen>
- <dimen name="albumset_title_font_size">12sp</dimen>
- <dimen name="albumset_count_font_size">9sp</dimen>
- <dimen name="albumset_left_margin">2dp</dimen>
- <dimen name="albumset_title_right_margin">20dp</dimen>
- <dimen name="albumset_icon_size">25dp</dimen>
-
- <!-- configuration for album page -->
- <integer name="album_rows_land">2</integer>
- <integer name="album_rows_port">4</integer>
- <dimen name="album_slot_gap">5dp</dimen>
-
- <!-- configuration for manage page -->
- <dimen name="cache_pin_size">24dp</dimen>
- <dimen name="cache_pin_margin">8dp</dimen>
-
- <!-- for manage cache bar -->
- <dimen name="manage_cache_bottom_height">48dp</dimen>
-
- <!-- configuration for filtershow UI -->
- <dimen name="thumbnail_size">96dip</dimen>
- <dimen name="thumbnail_margin">3dip</dimen>
- <dimen name="action_item_height">175dip</dimen>
-
- <!-- configuration for album set page -->
- <dimen name="album_set_item_image_height">120dp</dimen>
- <dimen name="album_set_item_width">140dp</dimen>
-</resources>
diff --git a/res/values/filtershow_color.xml b/res/values/filtershow_color.xml
index 927bfa2..4fb4495 100644
--- a/res/values/filtershow_color.xml
+++ b/res/values/filtershow_color.xml
@@ -24,8 +24,8 @@
<color name="background_toolbar">#363949</color>
<color name="background_main_toolbar">#232323</color>
<color name="toolbar_separation_line">#333333</color>
- <color name="slider_dot_color">#6464FF</color>
- <color name="slider_line_color">#33B5E5</color>
+ <color name="slider_dot_color">#646464</color>
+ <color name="slider_line_color">#888888</color>
<color name="state_panel_separation_line">#232323</color>
<color name="filtershow_background">#333333</color>
<color name="filtershow_graphic">#717171</color>
@@ -38,4 +38,16 @@
<color name="filtershow_categoryview_background">#1a1a1a</color>
<color name="filtershow_categoryview_text">#a7a7a7</color>
<color name="filtershow_category_selection">#ffffffff</color>
+ <color name="gradcontrol_point_center">#ffffffff</color>
+ <color name="gradcontrol_point_edge">#ffffffff</color>
+ <color name="gradcontrol_graypoint_center">#888888</color>
+ <color name="gradcontrol_graypoint_edge">#BBBBBB</color>
+ <color name="gradcontrol_point_shadow_start">#66000000</color>
+ <color name="gradcontrol_point_shadow_end">#00000000</color>
+ <color name="gradcontrol_line_color">#FFFFFF</color>
+ <color name="gradcontrol_line_shadow">#000000</color>
+ <color name="draw_rect_border">#888888</color>
+ <color name="color_chooser_unslected_border">#00000000</color>
+ <color name="color_chooser_slected_border">#a7a7a7</color>
+
</resources>
\ No newline at end of file
diff --git a/res/values/filtershow_ids.xml b/res/values/filtershow_ids.xml
index 8ac2941..460da61 100644
--- a/res/values/filtershow_ids.xml
+++ b/res/values/filtershow_ids.xml
@@ -39,6 +39,7 @@
<item type="id" name="imageCurves" />
<item type="id" name="imageZoom" />
<item type="id" name="editorDraw" />
+ <item type="id" name="editorColorBorder" />
<item type="id" name="editorRedEye" />
<item type="id" name="imageOnlyEditor" />
<item type="id" name="vignetteEditor" />
@@ -47,4 +48,6 @@
<item type="id" name="editorRotate" />
<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 c8ad2a9..98f32eb 100644
--- a/res/values/filtershow_strings.xml
+++ b/res/values/filtershow_strings.xml
@@ -20,6 +20,8 @@
<!-- String shown when we cannot load the image when starting the activity [CHAR LIMIT=NONE] -->
<string name="cannot_load_image">Cannot load the image!</string>
+ <!-- String shown when cannot load the original image. We will edit selected image [CHAR LIMIT=NONE] -->
+ <string name="cannot_edit_original">Cannot edit original</string>
<!-- String displayed when showing the original image [CHAR LIMIT=NONE] -->
<string name="original_picture_text">@string/original</string>
<!-- String displayed when setting the homepage wallpaper in the background [CHAR LIMIT=NONE] -->
@@ -30,10 +32,12 @@
<!-- Text for to display on a download failure [CHAR LIMIT=NONE] -->
<string name="download_failure">Could not download photo. Network unavailable.</string>
- <!-- Text for original image [CHAR LIMIT=20] -->
+ <!-- Text to label an image as "original" [CHAR LIMIT=20] -->
<string name="original">Original</string>
<!-- Text for filters that apply a border to a picture [CHAR LIMIT=20] -->
<string name="borders" msgid="4461692156695893616">Borders</string>
+ <!-- Text for the custom border filter [CHAR LIMIT=20] -->
+ <string name="custom_border">Custom</string>
<!-- actionbar menu -->
@@ -45,6 +49,24 @@
<string name="show_imagestate_panel">Show Applied Effects</string>
<!-- Text for the image state panel menu item [CHAR LIMIT=30] -->
<string name="hide_imagestate_panel">Hide Applied Effects</string>
+ <!-- Text for the menu item to export a flattened photo[CHAR LIMIT=30] -->
+ <string name="export_image">Export</string>
+ <!-- Text for the print menu item [CHAR LIMIT=20] -->
+ <string name="print_image">Print</string>
+
+ <!-- Export Dialog-->
+
+ <!-- Text for the dialog title to export a flattened photo[CHAR LIMIT=25] -->
+ <string name="export_flattened">Export Flattened Image</string>
+ <!-- Text for selecting export image quality [CHAR LIMIT=100] -->
+ <string name="select_output_settings">The exported image will be a copy, without the history.</string>
+ <!-- Text for quality value tag [CHAR LIMIT=30] -->
+ <string name="quality">Quality</string>
+ <!-- Text for size value tag [CHAR LIMIT=30] -->
+ <string name="size">Size</string>
+ <!-- Text for size x [CHAR LIMIT=1] -->
+ <string name="x">x</string>
+
<!-- Name for the overflow menu item for settings [CHAR LIMIT=20] -->
<string name="menu_settings">Settings</string>
@@ -56,6 +78,8 @@
<string name="save_before_exit">Do you want to save before exiting?</string>
<!-- String displayed when saving and exiting editor [CHAR LIMIT=NONE] -->
<string name="save_and_exit">Save and Exit</string>
+ <!-- String displayed when saving and exiting editor [CHAR LIMIT=NONE] -->
+ <string name="save_and_processing">Processing full resolution image...</string>
<!-- String displayed when exiting editor[CHAR LIMIT=NONE] -->
<string name="exit">Exit</string>
@@ -132,6 +156,17 @@
<string name="curvesRGB">Curves</string>
<!-- Label for the image vignette filter (darkens photo around edges) button [CHAR LIMIT=10] -->
<string name="vignette">Vignette</string>
+ <!-- Label for the image vignette main parameter ui [CHAR LIMIT=15] -->
+ <string name="vignette_main">Vignette</string>
+ <!-- Label for the image vignette exposure parameter ui [CHAR LIMIT=15] -->
+ <string name="vignette_exposure">Exposure</string>
+ <!-- Label for the image vignette saturation parameter ui [CHAR LIMIT=15] -->
+ <string name="vignette_saturation">Saturation</string>
+ <!-- Label for the image vignette contrast fparameter ui [CHAR LIMIT=15] -->
+ <string name="vignette_contrast">Contrast</string>
+ <!-- Label for the rate of change in brightness as it goes to the edge [CHAR LIMIT=15] -->
+ <string name="vignette_falloff">Falloff</string>
+
<!-- Label for the image effect that removes redeye. [CHAR LIMIT=10] -->
<string name="redeye">Red Eye</string>
<!-- Label for the that allows drawing on Image [CHAR LIMIT=10] -->
@@ -151,10 +186,37 @@
<!-- Label for the image edges effect (highlights edges in image) [CHAR LIMIT=10] -->
<string name="edge">Edges</string>
<!-- Label for an image effect that replicates the "pop art" style of segmenting
- images into solid colors, as popularized by Andy Warhol [CHAR LIMIT=10] -->
- <string name="kmeans">Warhol</string>
+ images into solid colors, as popularized by Andy Warhol [CHAR LIMIT=15] -->
+ <string name="kmeans">Posterize</string>
<!-- Label for the image downsampling effect (makes image smaller) [CHAR LIMIT=15] -->
<string name="downsample">Downsample</string>
+ <!-- Label for the "neutral density graduated filter" filter effect [CHAR LIMIT=15] -->
+ <string name="grad">Graduated</string>
+ <!-- Label for the Brightness effect [CHAR LIMIT=20] -->
+ <string name="editor_grad_brightness">Brightness</string>
+ <!-- Label for the Contrast filter effect [CHAR LIMIT=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>
+ <!-- new virtual graduated neutral density filter [CHAR LIMIT=20] -->
+ <string name="editor_grad_new">new</string>
+
<!-- Labels for the curves tool -->
@@ -171,6 +233,12 @@
<string name="draw_style">Style</string>
<!-- Label for the size to draw in in [CHAR LIMIT=14] -->
<string name="draw_size">Size</string>
+ <!-- Label for the Hue to draw in [CHAR LIMIT=14] -->
+ <string name="draw_hue">Hue</string>
+ <!-- Label for the color to draw in [CHAR LIMIT=14] -->
+ <string name="draw_saturation">Saturation</string>
+ <!-- Label for the Brightness to draw in [CHAR LIMIT=14] -->
+ <string name="draw_value">Brightness</string>
<!-- Label for the color to draw in [CHAR LIMIT=14] -->
<string name="draw_color">Color</string>
<!-- Label for the line style of drawing in [CHAR LIMIT=14] -->
@@ -182,6 +250,16 @@
<!-- Label for the removing drawing from screen [CHAR LIMIT=14] -->
<string name="draw_clear">Clear</string>
+
+ <!-- Label for the with of the border[CHAR LIMIT=14] -->
+ <string name="color_border_size">Thickness</string>
+ <!-- Label for the border corner size (or rounding) [CHAR LIMIT=14] -->
+ <string name="color_border_corner_size">Corner Size</string>
+ <!-- Label for selecting the border color [CHAR LIMIT=14] -->
+ <string name="color_border_color">Color</string>
+ <!-- Label for the removing borders [CHAR LIMIT=14] -->
+ <string name="color_border_clear">Clear</string>
+
<!-- Label for the select the color [CHAR LIMIT=35] -->
<string name="color_pick_select">Choose custom color</string>
<!-- The title for the color pick dialog [CHAR LIMIT=20] -->
@@ -197,4 +275,57 @@
<!-- Name used to indicate the final image in the state panel [CHAR LIMIT=20] -->
<string name="state_panel_result">Result</string>
+ <!-- Label for the notification [CHAR LIMIT=50] -->
+ <string name="filtershow_notification_label">Saving Image</string>
+ <!-- Label for the notification message [CHAR LIMIT=50] -->
+ <string name="filtershow_notification_message">Processing...</string>
+
+ <!-- Label for the save preset menu [CHAR LIMIT=30] -->
+ <string name="filtershow_save_preset">Save current preset</string>
+ <!-- Label for the manage preset menu [CHAR LIMIT=42] -->
+ <string name="filtershow_manage_preset">Manage user presets</string>
+ <!-- Label for newly created user preset [CHAR LIMIT=30] -->
+ <string name="filtershow_new_preset">New Preset</string>
+ <!-- Label for preset name [CHAR LIMIT=30] -->
+ <string name="filtershow_preset_name">Preset Name</string>
+
+ <!-- Label for showing the image information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_show_info_panel">Information</string>
+ <!-- Label for the information panel [CHAR LIMIT=30] -->
+ <string name="filtershow_show_info_panel_name">Image Name</string>
+ <!-- Label for the information panel [CHAR LIMIT=30] -->
+ <string name="filtershow_show_info_panel_size">Image Size</string>
+ <!-- Label for the information panel [CHAR LIMIT=30] -->
+ <string name="filtershow_show_info_panel_histogram">Histogram</string>
+ <!-- Label for the information panel [CHAR LIMIT=30] -->
+ <string name="filtershow_show_info_panel_exif">EXIF Data</string>
+
+ <!-- Label for the add button in the category panel [CHAR LIMIT=30] -->
+ <string name="filtershow_add_button_looks">Preset</string>
+ <!-- Label for the add button in the versions panel [CHAR LIMIT=30] -->
+ <string name="filtershow_add_button_versions">Version</string>
+ <!-- Label for the Original version in the versions panel [CHAR LIMIT=30] -->
+ <string name="filtershow_version_original">Original</string>
+ <!-- Label for the Current version in the versions panel [CHAR LIMIT=30] -->
+ <string name="filtershow_version_current">Current</string>
+
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_model">Model</string>
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_aperture">Aperture</string>
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_focal_length">Focal Length</string>
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_iso">ISO</string>
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_subject_distance">Subject Distance</string>
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_date">Date taken</string>
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_f_stop">F Stop</string>
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_exposure_time">Exposure Time</string>
+ <!-- Label for exif tags in the information panel [CHAR LIMIT=50] -->
+ <string name="filtershow_exif_copyright">Copyright</string>
+
</resources>
diff --git a/res/values/filtershow_values.xml b/res/values/filtershow_values.xml
index 2e7dce4..a788afe 100644
--- a/res/values/filtershow_values.xml
+++ b/res/values/filtershow_values.xml
@@ -20,4 +20,49 @@
<!-- Text size for the state panel -->
<dimen name="state_panel_text_size">16dip</dimen>
-</resources>
+
+ <!-- Category Panel Height -->
+ <dimen name="category_panel_height">86dip</dimen>
+
+ <!-- Category Panel Icon Size -->
+ <dimen name="category_panel_icon_size">64dip</dimen>
+
+ <!-- Category Panel Text Size -->
+ <dimen name="category_panel_text_size">13dip</dimen>
+
+ <!-- Category Panel Text Size -->
+ <dimen name="category_panel_margin">4dip</dimen>
+
+ <!-- Grad filter dot size -->
+ <dimen name="gradcontrol_dot_size">20dip</dimen>
+
+ <!-- Grad filter minimum touch distance -->
+ <dimen name="gradcontrol_min_touch_dist">80dip</dimen>
+
+ <!-- Grad filter minimum touch distance -->
+ <dimen name="draw_rect_border">20dip</dimen>
+
+ <!-- Grad filter minimum touch distance -->
+ <dimen name="draw_rect_shadow">8dip</dimen>
+
+ <!-- Grad filter minimum touch distance -->
+ <dimen name="draw_rect_border_edge">2dip</dimen>
+
+ <!-- Grad filter minimum touch distance -->
+ <dimen name="draw_rect_round">10dip</dimen>
+
+ <!-- draw color icon size -->
+ <dimen name="draw_style_icon_dim">42dip</dimen>
+
+ <!-- draw color icon size -->
+ <dimen name="draw_color_icon_dim">42dip</dimen>
+
+ <!-- draw check UI size -->
+ <dimen name="draw_color_check_dim">5dip</dimen>
+
+ <!-- draw check UI size -->
+ <dimen name="draw_ui_width">192dip</dimen>
+
+ <!-- Glow effect size -->
+ <dimen name="edge_glow_size">50dip</dimen>
+</resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cb4bc18..1ef8c13 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -345,7 +345,7 @@
<string name="ffx_original">Original</string>
<!-- String for brown-colored old-fashion looking filter (filtershow_fx_0000_vintage) [CHAR LIMIT=10] -->
<string name="ffx_vintage">Vintage</string>
- <!-- String for filter that brightens colors (filtershow_fx_0001_instant) [CHAR LIMIT=10] -->
+ <!-- String for filter that brightens colors like instant cameras(filtershow_fx_0001_instant) [CHAR LIMIT=10] -->
<string name="ffx_instant">Instant</string>
<!-- String for filter that washes out colors (filtershow_fx_0002_bleach) [CHAR LIMIT=10] -->
<string name="ffx_bleach">Bleach</string>
@@ -492,9 +492,6 @@
<!-- The title of the menu item which display online help in browser. [CHAR LIMIT=20]-->
<string name="help">Help</string>
- <!-- Web address for gallery help. DO NOT TRANSLATE -->
- <string name="help_url_gallery_main" translatable="false"></string>
-
<!-- The tilte of a dialog showing there is no external storage. [CHAR LIMIT=20] -->
<string name="no_external_storage_title">No Storage</string>
@@ -572,9 +569,6 @@
<!-- label for the icon meaning 'show me all the images that were taken with the camera' -->
<string name="camera_label">Camera</string>
- <!-- label for the 'video recording application shown in the top level 'all applications' -->
- <string name="video_camera_label">Camcorder</string>
-
<!-- alert to the user to wait for some operation to complete -->
<string name="wait">Please wait\u2026</string>
@@ -945,6 +939,8 @@
<string name="accessibility_switch_to_panorama">Switch to panorama</string>
<!-- The button to switch to new Panorama mode. [CHAR LIMIT = NONE] -->
<string name="accessibility_switch_to_new_panorama">Switch to new panorama</string>
+ <!-- The button to switch to the Re-Focus mode. [CHAR LIMIT = NONE] -->
+ <string name="accessibility_switch_to_refocus">Switch to Refocus</string>
<!-- The button in review mode indicating that the photo taking, video recording, and panorama saving session should be canceled [CHAR LIMIT = NONE] -->
<string name="accessibility_review_cancel">Review cancel</string>
<!-- The button in review mode indicating that the taken photo/video is OK to be attached/uploaded [CHAR LIMIT = NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index e6179e9..33dcbec 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -29,7 +29,15 @@
<item name="android:colorBackgroundCacheHint">@null</item>
</style>
<style name="Theme.FilterShow" parent="Theme.Gallery">
- <item name="android:windowBackground">@color/background_screen</item>
+ <item name="android:windowBackground">@null</item>
+ </style>
+ <style name="Theme.Crop" parent="Theme.GalleryBase">
+ <item name="android:displayOptions"></item>
+ <item name="android:windowContentOverlay">@null</item>
+ <item name="android:actionBarStyle">@style/Holo.ActionBar</item>
+ <item name="android:colorBackground">@null</item>
+ <item name="android:colorBackgroundCacheHint">@null</item>
+ <item name="android:windowBackground">@drawable/filtershow_tiled_background</item>
</style>
<style name="Holo.ActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:displayOptions">useLogo|showHome</item>
@@ -253,9 +261,40 @@
<item name="android:enabled">false</item>
<item name="android:scaleType">center</item>
</style>
- <style name="CameraControls">
+ <style name="CameraControls">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
-
+ <style name="UndoBar">
+ <item name="android:layout_marginLeft">4dp</item>
+ <item name="android:layout_marginRight">4dp</item>
+ <item name="android:paddingLeft">16dp</item>
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">48dp</item>
+ <item name="android:layout_gravity">bottom</item>
+ <item name="android:background">@drawable/panel_undo_holo</item>
+ </style>
+ <style name="UndoBarTextAppearance">
+ <item name="android:textSize">16sp</item>
+ <item name="android:textColor">@android:color/white</item>
+ </style>
+ <style name="UndoBarSeparator">
+ <item name="android:background">@color/gray</item>
+ <item name="android:layout_width">1dp</item>
+ <item name="android:layout_height">match_parent</item>
+ <item name="android:layout_marginTop">10dp</item>
+ <item name="android:layout_marginBottom">10dp</item>
+ <item name="android:paddingRight">12dp</item>
+ </style>
+ <style name="UndoButton">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">match_parent</item>
+ <item name="android:paddingRight">16dp</item>
+ <item name="android:textSize">12sp</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:textColor">@color/gray</item>
+ <item name="android:drawablePadding">8dp</item>
+ <item name="android:background">@drawable/bg_pressed</item>
+ </style>
</resources>
diff --git a/res/xml/video_preferences.xml b/res/xml/video_preferences.xml
index faf5f65..79154e6 100644
--- a/res/xml/video_preferences.xml
+++ b/res/xml/video_preferences.xml
@@ -19,7 +19,6 @@
camera:title="@string/pref_camcorder_settings_category">
<ListPreference
camera:key="pref_video_quality_key"
- camera:defaultValue="@string/pref_video_quality_default"
camera:title="@string/pref_video_quality_title"
camera:entries="@array/pref_video_quality_entries"
camera:entryValues="@array/pref_video_quality_entryvalues"/>
diff --git a/src/com/android/camera/ActivityBase.java b/src/com/android/camera/ActivityBase.java
deleted file mode 100644
index 59bd82c..0000000
--- a/src/com/android/camera/ActivityBase.java
+++ /dev/null
@@ -1,643 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Rect;
-import android.hardware.Camera.Parameters;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.Animation;
-import android.view.animation.DecelerateInterpolator;
-
-import com.android.camera.ui.LayoutChangeNotifier;
-import com.android.camera.ui.PopupManager;
-import com.android.gallery3d.R;
-import com.android.gallery3d.app.AbstractGalleryActivity;
-import com.android.gallery3d.app.AppBridge;
-import com.android.gallery3d.app.FilmstripPage;
-import com.android.gallery3d.app.GalleryActionBar;
-import com.android.gallery3d.app.PhotoPage;
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.ui.ScreenNail;
-import com.android.gallery3d.util.MediaSetUtils;
-
-/**
- * Superclass of camera activity.
- */
-public abstract class ActivityBase extends AbstractGalleryActivity
- implements LayoutChangeNotifier.Listener {
-
- private static final String TAG = "ActivityBase";
- private static final int CAMERA_APP_VIEW_TOGGLE_TIME = 100; // milliseconds
- private static final String INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE =
- "android.media.action.STILL_IMAGE_CAMERA_SECURE";
- public static final String ACTION_IMAGE_CAPTURE_SECURE =
- "android.media.action.IMAGE_CAPTURE_SECURE";
- // The intent extra for camera from secure lock screen. True if the gallery
- // should only show newly captured pictures. sSecureAlbumId does not
- // increment. This is used when switching between camera, camcorder, and
- // panorama. If the extra is not set, it is in the normal camera mode.
- public static final String SECURE_CAMERA_EXTRA = "secure_camera";
-
- private int mResultCodeForTesting;
- private Intent mResultDataForTesting;
- private OnScreenHint mStorageHint;
- private View mSingleTapArea;
-
- protected boolean mOpenCameraFail;
- protected boolean mCameraDisabled;
- protected CameraManager.CameraProxy mCameraDevice;
- protected Parameters mParameters;
- // The activity is paused. The classes that extend this class should set
- // mPaused the first thing in onResume/onPause.
- protected boolean mPaused;
- protected GalleryActionBar mActionBar;
-
- // multiple cameras support
- protected int mNumberOfCameras;
- protected int mCameraId;
- // The activity is going to switch to the specified camera id. This is
- // needed because texture copy is done in GL thread. -1 means camera is not
- // switching.
- protected int mPendingSwitchCameraId = -1;
-
- protected MyAppBridge mAppBridge;
- protected ScreenNail mCameraScreenNail; // This shows camera preview.
- // The view containing only camera related widgets like control panel,
- // indicator bar, focus indicator and etc.
- protected View mCameraAppView;
- protected boolean mShowCameraAppView = true;
- private Animation mCameraAppViewFadeIn;
- private Animation mCameraAppViewFadeOut;
- // Secure album id. This should be incremented every time the camera is
- // launched from the secure lock screen. The id should be the same when
- // switching between camera, camcorder, and panorama.
- protected static int sSecureAlbumId;
- // True if the camera is started from secure lock screen.
- protected boolean mSecureCamera;
- private static boolean sFirstStartAfterScreenOn = true;
-
- private long mStorageSpace = Storage.LOW_STORAGE_THRESHOLD;
- private static final int UPDATE_STORAGE_HINT = 0;
- private final Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case UPDATE_STORAGE_HINT:
- updateStorageHint();
- return;
- }
- }
- };
-
- private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(Intent.ACTION_MEDIA_MOUNTED)
- || action.equals(Intent.ACTION_MEDIA_UNMOUNTED)
- || action.equals(Intent.ACTION_MEDIA_CHECKING)
- || action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
- updateStorageSpaceAndHint();
- }
- }
- };
-
- // close activity when screen turns off
- private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- finish();
- }
- };
-
- private static BroadcastReceiver sScreenOffReceiver;
- private static class ScreenOffReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- sFirstStartAfterScreenOn = true;
- }
- }
-
- public static boolean isFirstStartAfterScreenOn() {
- return sFirstStartAfterScreenOn;
- }
-
- public static void resetFirstStartAfterScreenOn() {
- sFirstStartAfterScreenOn = false;
- }
-
- protected class CameraOpenThread extends Thread {
- @Override
- public void run() {
- try {
- mCameraDevice = Util.openCamera(ActivityBase.this, mCameraId);
- mParameters = mCameraDevice.getParameters();
- } catch (CameraHardwareException e) {
- mOpenCameraFail = true;
- } catch (CameraDisabledException e) {
- mCameraDisabled = true;
- }
- }
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.disableToggleStatusBar();
- // Set a theme with action bar. It is not specified in manifest because
- // we want to hide it by default. setTheme must happen before
- // setContentView.
- //
- // This must be set before we call super.onCreate(), where the window's
- // background is removed.
- setTheme(R.style.Theme_Gallery);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
- if (ApiHelper.HAS_ACTION_BAR) {
- requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
- } else {
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- }
-
- // Check if this is in the secure camera mode.
- Intent intent = getIntent();
- String action = intent.getAction();
- if (INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action)) {
- mSecureCamera = true;
- // Use a new album when this is started from the lock screen.
- sSecureAlbumId++;
- } else if (ACTION_IMAGE_CAPTURE_SECURE.equals(action)) {
- mSecureCamera = true;
- } else {
- mSecureCamera = intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false);
- }
- if (mSecureCamera) {
- IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
- registerReceiver(mScreenOffReceiver, filter);
- if (sScreenOffReceiver == null) {
- sScreenOffReceiver = new ScreenOffReceiver();
- getApplicationContext().registerReceiver(sScreenOffReceiver, filter);
- }
- }
- super.onCreate(icicle);
- }
-
- public boolean isPanoramaActivity() {
- return false;
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- installIntentFilter();
- if (updateStorageHintOnResume()) {
- updateStorageSpace();
- mHandler.sendEmptyMessageDelayed(UPDATE_STORAGE_HINT, 200);
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
-
- if (mStorageHint != null) {
- mStorageHint.cancel();
- mStorageHint = null;
- }
-
- unregisterReceiver(mReceiver);
- }
-
- @Override
- public void setContentView(int layoutResID) {
- super.setContentView(layoutResID);
- // getActionBar() should be after setContentView
- mActionBar = new GalleryActionBar(this);
- mActionBar.hide();
- }
-
- @Override
- public boolean onSearchRequested() {
- return false;
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- // Prevent software keyboard or voice search from showing up.
- if (keyCode == KeyEvent.KEYCODE_SEARCH
- || keyCode == KeyEvent.KEYCODE_MENU) {
- if (event.isLongPress()) return true;
- }
- if (keyCode == KeyEvent.KEYCODE_MENU && mShowCameraAppView) {
- return true;
- }
-
- return super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_MENU && mShowCameraAppView) {
- return true;
- }
- return super.onKeyUp(keyCode, event);
- }
-
- protected void setResultEx(int resultCode) {
- mResultCodeForTesting = resultCode;
- setResult(resultCode);
- }
-
- protected void setResultEx(int resultCode, Intent data) {
- mResultCodeForTesting = resultCode;
- mResultDataForTesting = data;
- setResult(resultCode, data);
- }
-
- public int getResultCode() {
- return mResultCodeForTesting;
- }
-
- public Intent getResultData() {
- return mResultDataForTesting;
- }
-
- @Override
- protected void onDestroy() {
- PopupManager.removeInstance(this);
- if (mSecureCamera) unregisterReceiver(mScreenOffReceiver);
- super.onDestroy();
- }
-
- protected void installIntentFilter() {
- // install an intent filter to receive SD card related events.
- IntentFilter intentFilter =
- new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
- intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
- intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
- intentFilter.addAction(Intent.ACTION_MEDIA_CHECKING);
- intentFilter.addDataScheme("file");
- registerReceiver(mReceiver, intentFilter);
- }
-
- protected void updateStorageSpace() {
- mStorageSpace = Storage.getAvailableSpace();
- }
-
- protected long getStorageSpace() {
- return mStorageSpace;
- }
-
- protected void updateStorageSpaceAndHint() {
- updateStorageSpace();
- updateStorageHint(mStorageSpace);
- }
-
- protected void updateStorageHint() {
- updateStorageHint(mStorageSpace);
- }
-
- protected boolean updateStorageHintOnResume() {
- return true;
- }
-
- protected void updateStorageHint(long storageSpace) {
- String message = null;
- if (storageSpace == Storage.UNAVAILABLE) {
- message = getString(R.string.no_storage);
- } else if (storageSpace == Storage.PREPARING) {
- message = getString(R.string.preparing_sd);
- } else if (storageSpace == Storage.UNKNOWN_SIZE) {
- message = getString(R.string.access_sd_fail);
- } else if (storageSpace <= Storage.LOW_STORAGE_THRESHOLD) {
- message = getString(R.string.spaceIsLow_content);
- }
-
- if (message != null) {
- if (mStorageHint == null) {
- mStorageHint = OnScreenHint.makeText(this, message);
- } else {
- mStorageHint.setText(message);
- }
- mStorageHint.show();
- } else if (mStorageHint != null) {
- mStorageHint.cancel();
- mStorageHint = null;
- }
- }
-
- public void gotoGallery() {
- // Move the next picture with capture animation. "1" means next.
- mAppBridge.switchWithCaptureAnimation(1);
- }
-
- // Call this after setContentView.
- public ScreenNail createCameraScreenNail(boolean getPictures) {
- mCameraAppView = findViewById(R.id.camera_app_root);
- Bundle data = new Bundle();
- String path;
- if (getPictures) {
- if (mSecureCamera) {
- path = "/secure/all/" + sSecureAlbumId;
- } else {
- path = "/local/all/" + MediaSetUtils.CAMERA_BUCKET_ID;
- }
- } else {
- path = "/local/all/0"; // Use 0 so gallery does not show anything.
- }
- data.putString(PhotoPage.KEY_MEDIA_SET_PATH, path);
- data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, path);
- data.putBoolean(PhotoPage.KEY_SHOW_WHEN_LOCKED, mSecureCamera);
-
- // Send an AppBridge to gallery to enable the camera preview.
- if (mAppBridge != null) {
- mCameraScreenNail.recycle();
- }
- mAppBridge = new MyAppBridge();
- data.putParcelable(PhotoPage.KEY_APP_BRIDGE, mAppBridge);
- if (getStateManager().getStateCount() == 0) {
- getStateManager().startState(FilmstripPage.class, data);
- } else {
- getStateManager().switchState(getStateManager().getTopState(),
- FilmstripPage.class, data);
- }
- mCameraScreenNail = mAppBridge.getCameraScreenNail();
- return mCameraScreenNail;
- }
-
- // Call this after setContentView.
- protected ScreenNail reuseCameraScreenNail(boolean getPictures) {
- mCameraAppView = findViewById(R.id.camera_app_root);
- Bundle data = new Bundle();
- String path;
- if (getPictures) {
- if (mSecureCamera) {
- path = "/secure/all/" + sSecureAlbumId;
- } else {
- path = "/local/all/" + MediaSetUtils.CAMERA_BUCKET_ID;
- }
- } else {
- path = "/local/all/0"; // Use 0 so gallery does not show anything.
- }
- data.putString(PhotoPage.KEY_MEDIA_SET_PATH, path);
- data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, path);
- data.putBoolean(PhotoPage.KEY_SHOW_WHEN_LOCKED, mSecureCamera);
-
- // Send an AppBridge to gallery to enable the camera preview.
- if (mAppBridge == null) {
- mAppBridge = new MyAppBridge();
- }
- data.putParcelable(PhotoPage.KEY_APP_BRIDGE, mAppBridge);
- if (getStateManager().getStateCount() == 0) {
- getStateManager().startState(FilmstripPage.class, data);
- }
- mCameraScreenNail = mAppBridge.getCameraScreenNail();
- return mCameraScreenNail;
- }
-
- private class HideCameraAppView implements Animation.AnimationListener {
- @Override
- public void onAnimationEnd(Animation animation) {
- // We cannot set this as GONE because we want to receive the
- // onLayoutChange() callback even when we are invisible.
- mCameraAppView.setVisibility(View.INVISIBLE);
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
-
- @Override
- public void onAnimationStart(Animation animation) {
- }
- }
-
- protected void updateCameraAppView() {
- // Initialize the animation.
- if (mCameraAppViewFadeIn == null) {
- mCameraAppViewFadeIn = new AlphaAnimation(0f, 1f);
- mCameraAppViewFadeIn.setDuration(CAMERA_APP_VIEW_TOGGLE_TIME);
- mCameraAppViewFadeIn.setInterpolator(new DecelerateInterpolator());
-
- mCameraAppViewFadeOut = new AlphaAnimation(1f, 0f);
- mCameraAppViewFadeOut.setDuration(CAMERA_APP_VIEW_TOGGLE_TIME);
- mCameraAppViewFadeOut.setInterpolator(new DecelerateInterpolator());
- mCameraAppViewFadeOut.setAnimationListener(new HideCameraAppView());
- }
-
- if (mShowCameraAppView) {
- mCameraAppView.setVisibility(View.VISIBLE);
- // The "transparent region" is not recomputed when a sibling of
- // SurfaceView changes visibility (unless it involves GONE). It's
- // been broken since 1.0. Call requestLayout to work around it.
- mCameraAppView.requestLayout();
- mCameraAppView.startAnimation(mCameraAppViewFadeIn);
- } else {
- mCameraAppView.startAnimation(mCameraAppViewFadeOut);
- }
- }
-
- protected void onFullScreenChanged(boolean full) {
- if (mShowCameraAppView == full) return;
- mShowCameraAppView = full;
- if (mPaused || isFinishing()) return;
- updateCameraAppView();
- }
-
- @Override
- public GalleryActionBar getGalleryActionBar() {
- return mActionBar;
- }
-
- // Preview frame layout has changed.
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom) {
- if (mAppBridge == null) return;
-
- int width = right - left;
- int height = bottom - top;
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- CameraScreenNail screenNail = (CameraScreenNail) mCameraScreenNail;
- if (Util.getDisplayRotation(this) % 180 == 0) {
- screenNail.setPreviewFrameLayoutSize(width, height);
- } else {
- // Swap the width and height. Camera screen nail draw() is based on
- // natural orientation, not the view system orientation.
- screenNail.setPreviewFrameLayoutSize(height, width);
- }
- notifyScreenNailChanged();
- }
- }
-
- protected void setSingleTapUpListener(View singleTapArea) {
- mSingleTapArea = singleTapArea;
- }
-
- private boolean onSingleTapUp(int x, int y) {
- // Ignore if listener is null or the camera control is invisible.
- if (mSingleTapArea == null || !mShowCameraAppView) return false;
-
- int[] relativeLocation = Util.getRelativeLocation((View) getGLRoot(),
- mSingleTapArea);
- x -= relativeLocation[0];
- y -= relativeLocation[1];
- if (x >= 0 && x < mSingleTapArea.getWidth() && y >= 0
- && y < mSingleTapArea.getHeight()) {
- onSingleTapUp(mSingleTapArea, x, y);
- return true;
- }
- return false;
- }
-
- protected void onSingleTapUp(View view, int x, int y) {
- }
-
- public void setSwipingEnabled(boolean enabled) {
- mAppBridge.setSwipingEnabled(enabled);
- }
-
- public void notifyScreenNailChanged() {
- mAppBridge.notifyScreenNailChanged();
- }
-
- protected void onPreviewTextureCopied() {
- }
-
- protected void onCaptureTextureCopied() {
- }
-
- protected void addSecureAlbumItemIfNeeded(boolean isVideo, Uri uri) {
- if (mSecureCamera) {
- int id = Integer.parseInt(uri.getLastPathSegment());
- mAppBridge.addSecureAlbumItem(isVideo, id);
- }
- }
-
- public boolean isSecureCamera() {
- return mSecureCamera;
- }
-
- //////////////////////////////////////////////////////////////////////////
- // The is the communication interface between the Camera Application and
- // the Gallery PhotoPage.
- //////////////////////////////////////////////////////////////////////////
-
- class MyAppBridge extends AppBridge implements CameraScreenNail.Listener {
- @SuppressWarnings("hiding")
- private ScreenNail mCameraScreenNail;
- private Server mServer;
-
- @Override
- public ScreenNail attachScreenNail() {
- if (mCameraScreenNail == null) {
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- mCameraScreenNail = new CameraScreenNail(this, ActivityBase.this);
- } else {
- Bitmap b = BitmapFactory.decodeResource(getResources(),
- R.drawable.wallpaper_picker_preview);
- mCameraScreenNail = new StaticBitmapScreenNail(b);
- }
- }
- return mCameraScreenNail;
- }
-
- @Override
- public void detachScreenNail() {
- mCameraScreenNail = null;
- }
-
- public ScreenNail getCameraScreenNail() {
- return mCameraScreenNail;
- }
-
- // Return true if the tap is consumed.
- @Override
- public boolean onSingleTapUp(int x, int y) {
- return ActivityBase.this.onSingleTapUp(x, y);
- }
-
- // This is used to notify that the screen nail will be drawn in full screen
- // or not in next draw() call.
- @Override
- public void onFullScreenChanged(boolean full) {
- ActivityBase.this.onFullScreenChanged(full);
- }
-
- @Override
- public void requestRender() {
- getGLRoot().requestRenderForced();
- }
-
- @Override
- public void onPreviewTextureCopied() {
- ActivityBase.this.onPreviewTextureCopied();
- }
-
- @Override
- public void onCaptureTextureCopied() {
- ActivityBase.this.onCaptureTextureCopied();
- }
-
- @Override
- public void setServer(Server s) {
- mServer = s;
- }
-
- @Override
- public boolean isPanorama() {
- return ActivityBase.this.isPanoramaActivity();
- }
-
- @Override
- public boolean isStaticCamera() {
- return !ApiHelper.HAS_SURFACE_TEXTURE;
- }
-
- public void addSecureAlbumItem(boolean isVideo, int id) {
- if (mServer != null) mServer.addSecureAlbumItem(isVideo, id);
- }
-
- private void setCameraRelativeFrame(Rect frame) {
- if (mServer != null) mServer.setCameraRelativeFrame(frame);
- }
-
- private void switchWithCaptureAnimation(int offset) {
- if (mServer != null) mServer.switchWithCaptureAnimation(offset);
- }
-
- private void setSwipingEnabled(boolean enabled) {
- if (mServer != null) mServer.setSwipingEnabled(enabled);
- }
-
- private void notifyScreenNailChanged() {
- if (mServer != null) mServer.notifyScreenNailChanged();
- }
- }
-}
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 5ba769a..4ed6309 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * 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.
@@ -13,551 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.android.camera;
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ObjectAnimator;
-import android.content.ComponentName;
-import android.content.Context;
+import com.android.gallery3d.util.IntentHelper;
+
+import android.app.Activity;
import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.pm.ActivityInfo;
-import android.content.res.Configuration;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.os.IBinder;
-import android.provider.MediaStore;
-import android.provider.Settings;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.OrientationEventListener;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.FrameLayout;
-import com.android.camera.ui.CameraSwitcher;
-import com.android.gallery3d.R;
-import com.android.gallery3d.app.PhotoPage;
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.util.LightCycleHelper;
-
-public class CameraActivity extends ActivityBase
- implements CameraSwitcher.CameraSwitchListener {
- public static final int PHOTO_MODULE_INDEX = 0;
- public static final int VIDEO_MODULE_INDEX = 1;
- public static final int PANORAMA_MODULE_INDEX = 2;
- public static final int LIGHTCYCLE_MODULE_INDEX = 3;
-
- CameraModule mCurrentModule;
- private FrameLayout mFrame;
- private ShutterButton mShutter;
- private CameraSwitcher mSwitcher;
- private View mCameraControls;
- private View mControlsBackground;
- private View mPieMenuButton;
- private Drawable[] mDrawables;
- private int mCurrentModuleIndex;
- private MotionEvent mDown;
- private boolean mAutoRotateScreen;
- private int mHeightOrWidth = -1;
-
- private MyOrientationEventListener mOrientationListener;
- // The degrees of the device rotated clockwise from its natural orientation.
- private int mLastRawOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
-
- private MediaSaveService mMediaSaveService;
- private ServiceConnection mConnection = new ServiceConnection() {
- @Override
- public void onServiceConnected(ComponentName className, IBinder b) {
- mMediaSaveService = ((MediaSaveService.LocalBinder) b).getService();
- mCurrentModule.onMediaSaveServiceConnected(mMediaSaveService);
- }
- @Override
- public void onServiceDisconnected(ComponentName className) {
- mMediaSaveService = null;
- }};
-
- private static final String TAG = "CAM_activity";
-
- private static final int[] DRAW_IDS = {
- R.drawable.ic_switch_camera,
- R.drawable.ic_switch_video,
- R.drawable.ic_switch_pan,
- R.drawable.ic_switch_photosphere
- };
-
+/** Trampoline activity that launches the new Camera activity defined in IntentHelper. */
+public class CameraActivity extends Activity {
@Override
- public void onCreate(Bundle state) {
- super.onCreate(state);
- setContentView(R.layout.camera_main);
- mFrame = (FrameLayout) findViewById(R.id.camera_app_root);
- mDrawables = new Drawable[DRAW_IDS.length];
- for (int i = 0; i < DRAW_IDS.length; i++) {
- mDrawables[i] = getResources().getDrawable(DRAW_IDS[i]);
- }
- init();
- if (MediaStore.INTENT_ACTION_VIDEO_CAMERA.equals(getIntent().getAction())
- || MediaStore.ACTION_VIDEO_CAPTURE.equals(getIntent().getAction())) {
- mCurrentModule = new VideoModule();
- mCurrentModuleIndex = VIDEO_MODULE_INDEX;
- } else {
- mCurrentModule = new PhotoModule();
- mCurrentModuleIndex = PHOTO_MODULE_INDEX;
- }
- mCurrentModule.init(this, mFrame, true);
- mSwitcher.setCurrentIndex(mCurrentModuleIndex);
- mOrientationListener = new MyOrientationEventListener(this);
- bindMediaSaveService();
- }
-
- public void init() {
- boolean landscape = Util.getDisplayRotation(this) % 180 == 90;
- mControlsBackground = findViewById(R.id.blocker);
- mCameraControls = findViewById(R.id.camera_controls);
- mShutter = (ShutterButton) findViewById(R.id.shutter_button);
- mSwitcher = (CameraSwitcher) findViewById(R.id.camera_switcher);
- mPieMenuButton = findViewById(R.id.menu);
- int totaldrawid = (LightCycleHelper.hasLightCycleCapture(this)
- ? DRAW_IDS.length : DRAW_IDS.length - 1);
- if (!ApiHelper.HAS_OLD_PANORAMA) totaldrawid--;
-
- int[] drawids = new int[totaldrawid];
- int[] moduleids = new int[totaldrawid];
- int ix = 0;
- for (int i = 0; i < mDrawables.length; i++) {
- if (i == PANORAMA_MODULE_INDEX && !ApiHelper.HAS_OLD_PANORAMA) {
- continue; // not enabled, so don't add to UI
- }
- if (i == LIGHTCYCLE_MODULE_INDEX && !LightCycleHelper.hasLightCycleCapture(this)) {
- continue; // not enabled, so don't add to UI
- }
- moduleids[ix] = i;
- drawids[ix++] = DRAW_IDS[i];
- }
- mSwitcher.setIds(moduleids, drawids);
- mSwitcher.setSwitchListener(this);
- mSwitcher.setCurrentIndex(mCurrentModuleIndex);
- }
-
- @Override
- public void onDestroy() {
- unbindMediaSaveService();
- super.onDestroy();
- }
-
- // Return whether the auto-rotate screen in system settings
- // is turned on.
- public boolean isAutoRotateScreen() {
- return mAutoRotateScreen;
- }
-
- private class MyOrientationEventListener
- extends OrientationEventListener {
- public MyOrientationEventListener(Context context) {
- super(context);
- }
-
- @Override
- public void onOrientationChanged(int orientation) {
- // We keep the last known orientation. So if the user first orient
- // the camera then point the camera to floor or sky, we still have
- // the correct orientation.
- if (orientation == ORIENTATION_UNKNOWN) return;
- mLastRawOrientation = orientation;
- mCurrentModule.onOrientationChanged(orientation);
- }
- }
-
- private ObjectAnimator mCameraSwitchAnimator;
-
- @Override
- public void onCameraSelected(final int i) {
- if (mPaused) return;
- if (i != mCurrentModuleIndex) {
- mPaused = true;
- CameraScreenNail screenNail = getCameraScreenNail();
- if (screenNail != null) {
- if (mCameraSwitchAnimator != null && mCameraSwitchAnimator.isRunning()) {
- mCameraSwitchAnimator.cancel();
- }
- mCameraSwitchAnimator = ObjectAnimator.ofFloat(
- screenNail, "alpha", screenNail.getAlpha(), 0f);
- mCameraSwitchAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- doChangeCamera(i);
- }
- });
- mCameraSwitchAnimator.start();
- } else {
- doChangeCamera(i);
- }
- }
- }
-
- private void doChangeCamera(int i) {
- boolean canReuse = canReuseScreenNail();
- CameraHolder.instance().keep();
- closeModule(mCurrentModule);
- mCurrentModuleIndex = i;
- switch (i) {
- case VIDEO_MODULE_INDEX:
- mCurrentModule = new VideoModule();
- break;
- case PHOTO_MODULE_INDEX:
- mCurrentModule = new PhotoModule();
- break;
- case PANORAMA_MODULE_INDEX:
- mCurrentModule = new PanoramaModule();
- break;
- case LIGHTCYCLE_MODULE_INDEX:
- mCurrentModule = LightCycleHelper.createPanoramaModule();
- break;
- }
- showPieMenuButton(mCurrentModule.needsPieMenu());
-
- openModule(mCurrentModule, canReuse);
- mCurrentModule.onOrientationChanged(mLastRawOrientation);
- if (mMediaSaveService != null) {
- mCurrentModule.onMediaSaveServiceConnected(mMediaSaveService);
- }
- getCameraScreenNail().setAlpha(0f);
- getCameraScreenNail().setOnFrameDrawnOneShot(mOnFrameDrawn);
- }
-
- public void showPieMenuButton(boolean show) {
- if (show) {
- findViewById(R.id.blocker).setVisibility(View.VISIBLE);
- findViewById(R.id.menu).setVisibility(View.VISIBLE);
- findViewById(R.id.on_screen_indicators).setVisibility(View.VISIBLE);
- } else {
- findViewById(R.id.blocker).setVisibility(View.INVISIBLE);
- findViewById(R.id.menu).setVisibility(View.INVISIBLE);
- findViewById(R.id.on_screen_indicators).setVisibility(View.INVISIBLE);
- }
- }
-
- private Runnable mOnFrameDrawn = new Runnable() {
-
- @Override
- public void run() {
- runOnUiThread(mFadeInCameraScreenNail);
- }
- };
-
- private Runnable mFadeInCameraScreenNail = new Runnable() {
-
- @Override
- public void run() {
- mCameraSwitchAnimator = ObjectAnimator.ofFloat(
- getCameraScreenNail(), "alpha", 0f, 1f);
- mCameraSwitchAnimator.setStartDelay(50);
- mCameraSwitchAnimator.start();
- }
- };
-
- @Override
- public void onShowSwitcherPopup() {
- mCurrentModule.onShowSwitcherPopup();
- }
-
- private void openModule(CameraModule module, boolean canReuse) {
- module.init(this, mFrame, canReuse && canReuseScreenNail());
- mPaused = false;
- module.onResumeBeforeSuper();
- module.onResumeAfterSuper();
- }
-
- private void closeModule(CameraModule module) {
- module.onPauseBeforeSuper();
- module.onPauseAfterSuper();
- mFrame.removeAllViews();
- }
-
- public ShutterButton getShutterButton() {
- return mShutter;
- }
-
- public void hideUI() {
- mCameraControls.setVisibility(View.INVISIBLE);
- hideSwitcher();
- mShutter.setVisibility(View.GONE);
- }
-
- public void showUI() {
- mCameraControls.setVisibility(View.VISIBLE);
- showSwitcher();
- mShutter.setVisibility(View.VISIBLE);
- // Force a layout change to show shutter button
- mShutter.requestLayout();
- }
-
- public void hideSwitcher() {
- mSwitcher.closePopup();
- mSwitcher.setVisibility(View.INVISIBLE);
- }
-
- public void showSwitcher() {
- if (mCurrentModule.needsSwitcher()) {
- mSwitcher.setVisibility(View.VISIBLE);
- }
- }
-
- public boolean isInCameraApp() {
- return mShowCameraAppView;
- }
-
- @Override
- public void onConfigurationChanged(Configuration config) {
- super.onConfigurationChanged(config);
- mCurrentModule.onConfigurationChanged(config);
- }
-
- @Override
- public void onPause() {
- mPaused = true;
- mOrientationListener.disable();
- mCurrentModule.onPauseBeforeSuper();
- super.onPause();
- mCurrentModule.onPauseAfterSuper();
- }
-
- @Override
- public void onResume() {
- mPaused = false;
- if (Settings.System.getInt(getContentResolver(),
- Settings.System.ACCELEROMETER_ROTATION, 0) == 0) {// auto-rotate off
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- mAutoRotateScreen = false;
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
- mAutoRotateScreen = true;
- }
- mOrientationListener.enable();
- mCurrentModule.onResumeBeforeSuper();
- super.onResume();
- mCurrentModule.onResumeAfterSuper();
- }
-
- private void bindMediaSaveService() {
- Intent intent = new Intent(this, MediaSaveService.class);
- bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
- }
-
- private void unbindMediaSaveService() {
- if (mMediaSaveService != null) {
- mMediaSaveService.setListener(null);
- }
- if (mConnection != null) {
- unbindService(mConnection);
- }
- }
-
- @Override
- protected void onFullScreenChanged(boolean full) {
- if (full) {
- showUI();
- } else {
- hideUI();
- }
- super.onFullScreenChanged(full);
- if (ApiHelper.HAS_ROTATION_ANIMATION) {
- setRotationAnimation(full);
- }
- mCurrentModule.onFullScreenChanged(full);
- }
-
- private void setRotationAnimation(boolean fullscreen) {
- int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE;
- if (fullscreen) {
- rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_CROSSFADE;
- }
- Window win = getWindow();
- WindowManager.LayoutParams winParams = win.getAttributes();
- winParams.rotationAnimation = rotationAnimation;
- win.setAttributes(winParams);
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mCurrentModule.onStop();
- getStateManager().clearTasks();
- }
-
- @Override
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- getStateManager().clearActivityResult();
- }
-
- @Override
- protected void installIntentFilter() {
- super.installIntentFilter();
- mCurrentModule.installIntentFilter();
- }
-
- @Override
- protected void onActivityResult(
- int requestCode, int resultCode, Intent data) {
- // Only PhotoPage understands ProxyLauncher.RESULT_USER_CANCELED
- if (resultCode == ProxyLauncher.RESULT_USER_CANCELED
- && !(getStateManager().getTopState() instanceof PhotoPage)) {
- resultCode = RESULT_CANCELED;
- }
- super.onActivityResult(requestCode, resultCode, data);
- // Unmap cancel vs. reset
- if (resultCode == ProxyLauncher.RESULT_USER_CANCELED) {
- resultCode = RESULT_CANCELED;
- }
- mCurrentModule.onActivityResult(requestCode, resultCode, data);
- }
-
- // Preview area is touched. Handle touch focus.
- // Touch to focus is handled by PreviewGestures, this function call
- // is no longer needed. TODO: Clean it up in the next refactor
- @Override
- protected void onSingleTapUp(View view, int x, int y) {
- }
-
- @Override
- public void onBackPressed() {
- if (!mCurrentModule.onBackPressed()) {
- super.onBackPressed();
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- return mCurrentModule.onKeyDown(keyCode, event)
- || super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- return mCurrentModule.onKeyUp(keyCode, event)
- || super.onKeyUp(keyCode, event);
- }
-
- public void cancelActivityTouchHandling() {
- if (mDown != null) {
- MotionEvent cancel = MotionEvent.obtain(mDown);
- cancel.setAction(MotionEvent.ACTION_CANCEL);
- super.dispatchTouchEvent(cancel);
- }
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent m) {
- if (m.getActionMasked() == MotionEvent.ACTION_DOWN) {
- mDown = m;
- }
- if ((mSwitcher != null) && mSwitcher.showsPopup() && !mSwitcher.isInsidePopup(m)) {
- return mSwitcher.onTouch(null, m);
- } else if ((mSwitcher != null) && mSwitcher.isInsidePopup(m)) {
- return superDispatchTouchEvent(m);
- } else {
- return mCurrentModule.dispatchTouchEvent(m);
- }
- }
-
- @Override
- public void startActivityForResult(Intent intent, int requestCode) {
- Intent proxyIntent = new Intent(this, ProxyLauncher.class);
- proxyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
- proxyIntent.putExtra(Intent.EXTRA_INTENT, intent);
- super.startActivityForResult(proxyIntent, requestCode);
- }
-
- public boolean superDispatchTouchEvent(MotionEvent m) {
- return super.dispatchTouchEvent(m);
- }
-
- // Preview texture has been copied. Now camera can be released and the
- // animation can be started.
- @Override
- public void onPreviewTextureCopied() {
- mCurrentModule.onPreviewTextureCopied();
- }
-
- @Override
- public void onCaptureTextureCopied() {
- mCurrentModule.onCaptureTextureCopied();
- }
-
- @Override
- public void onUserInteraction() {
- super.onUserInteraction();
- mCurrentModule.onUserInteraction();
- }
-
- @Override
- protected boolean updateStorageHintOnResume() {
- return mCurrentModule.updateStorageHintOnResume();
- }
-
- @Override
- public void updateCameraAppView() {
- super.updateCameraAppView();
- mCurrentModule.updateCameraAppView();
- }
-
- private boolean canReuseScreenNail() {
- return mCurrentModuleIndex == PHOTO_MODULE_INDEX
- || mCurrentModuleIndex == VIDEO_MODULE_INDEX
- || mCurrentModuleIndex == LIGHTCYCLE_MODULE_INDEX;
- }
-
- @Override
- public boolean isPanoramaActivity() {
- return (mCurrentModuleIndex == PANORAMA_MODULE_INDEX);
- }
-
- // Accessor methods for getting latency times used in performance testing
- public long getAutoFocusTime() {
- return (mCurrentModule instanceof PhotoModule) ?
- ((PhotoModule) mCurrentModule).mAutoFocusTime : -1;
- }
-
- public long getShutterLag() {
- return (mCurrentModule instanceof PhotoModule) ?
- ((PhotoModule) mCurrentModule).mShutterLag : -1;
- }
-
- public long getShutterToPictureDisplayedTime() {
- return (mCurrentModule instanceof PhotoModule) ?
- ((PhotoModule) mCurrentModule).mShutterToPictureDisplayedTime : -1;
- }
-
- public long getPictureDisplayedToJpegCallbackTime() {
- return (mCurrentModule instanceof PhotoModule) ?
- ((PhotoModule) mCurrentModule).mPictureDisplayedToJpegCallbackTime : -1;
- }
-
- public long getJpegCallbackFinishTime() {
- return (mCurrentModule instanceof PhotoModule) ?
- ((PhotoModule) mCurrentModule).mJpegCallbackFinishTime : -1;
- }
-
- public long getCaptureStartTime() {
- return (mCurrentModule instanceof PhotoModule) ?
- ((PhotoModule) mCurrentModule).mCaptureStartTime : -1;
- }
-
- public boolean isRecording() {
- return (mCurrentModule instanceof VideoModule) ?
- ((VideoModule) mCurrentModule).isRecording() : false;
- }
-
- public CameraScreenNail getCameraScreenNail() {
- return (CameraScreenNail) mCameraScreenNail;
- }
-
- public MediaSaveService getMediaSaveService() {
- return mMediaSaveService;
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ Intent intent = IntentHelper.getCameraIntent(CameraActivity.this);
+ // Since this is being launched from a homescreen shorcut,
+ // it's already in a new task. Start Camera activity and
+ // reset the task to its initial state if needed.
+ intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ startActivity(intent);
+ finish();
}
}
diff --git a/src/com/android/camera/CameraBackupAgent.java b/src/com/android/camera/CameraBackupAgent.java
deleted file mode 100644
index 30ba212..0000000
--- a/src/com/android/camera/CameraBackupAgent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.app.backup.BackupAgentHelper;
-import android.app.backup.SharedPreferencesBackupHelper;
-import android.content.Context;
-
-public class CameraBackupAgent extends BackupAgentHelper {
- private static final String CAMERA_BACKUP_KEY = "camera_prefs";
-
- public void onCreate () {
- Context context = getApplicationContext();
- String prefNames[] = ComboPreferences.getSharedPreferencesNames(context);
-
- addHelper(CAMERA_BACKUP_KEY, new SharedPreferencesBackupHelper(context, prefNames));
- }
-}
diff --git a/src/com/android/camera/CameraButtonIntentReceiver.java b/src/com/android/camera/CameraButtonIntentReceiver.java
deleted file mode 100644
index a65942d..0000000
--- a/src/com/android/camera/CameraButtonIntentReceiver.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2007 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.camera;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-/**
- * {@code CameraButtonIntentReceiver} is invoked when the camera button is
- * long-pressed.
- *
- * It is declared in {@code AndroidManifest.xml} to receive the
- * {@code android.intent.action.CAMERA_BUTTON} intent.
- *
- * After making sure we can use the camera hardware, it starts the Camera
- * activity.
- */
-public class CameraButtonIntentReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- // Try to get the camera hardware
- CameraHolder holder = CameraHolder.instance();
- ComboPreferences pref = new ComboPreferences(context);
- int cameraId = CameraSettings.readPreferredCameraId(pref);
- if (holder.tryOpen(cameraId) == null) return;
-
- // We are going to launch the camera, so hold the camera for later use
- holder.keep();
- holder.release();
- Intent i = new Intent(Intent.ACTION_MAIN);
- i.setClass(context, CameraActivity.class);
- i.addCategory(Intent.CATEGORY_LAUNCHER);
- i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- context.startActivity(i);
- }
-}
diff --git a/src/com/android/camera/CameraDisabledException.java b/src/com/android/camera/CameraDisabledException.java
deleted file mode 100644
index 512809b..0000000
--- a/src/com/android/camera/CameraDisabledException.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-/**
- * This class represents the condition that device policy manager has disabled
- * the camera.
- */
-public class CameraDisabledException extends Exception {
-}
diff --git a/src/com/android/camera/CameraErrorCallback.java b/src/com/android/camera/CameraErrorCallback.java
deleted file mode 100644
index 22f800e..0000000
--- a/src/com/android/camera/CameraErrorCallback.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera;
-
-import android.util.Log;
-
-public class CameraErrorCallback
- implements android.hardware.Camera.ErrorCallback {
- private static final String TAG = "CameraErrorCallback";
-
- @Override
- public void onError(int error, android.hardware.Camera camera) {
- Log.e(TAG, "Got camera error callback. error=" + error);
- if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) {
- // We are not sure about the current state of the app (in preview or
- // snapshot or recording). Closing the app is better than creating a
- // new Camera object.
- throw new RuntimeException("Media server died.");
- }
- }
-}
diff --git a/src/com/android/camera/CameraHardwareException.java b/src/com/android/camera/CameraHardwareException.java
deleted file mode 100644
index 8209055..0000000
--- a/src/com/android/camera/CameraHardwareException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-/**
- * This class represents the condition that we cannot open the camera hardware
- * successfully. For example, another process is using the camera.
- */
-public class CameraHardwareException extends Exception {
-
- public CameraHardwareException(Throwable t) {
- super(t);
- }
-}
diff --git a/src/com/android/camera/CameraHolder.java b/src/com/android/camera/CameraHolder.java
deleted file mode 100644
index 5b7bbfd..0000000
--- a/src/com/android/camera/CameraHolder.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import static com.android.camera.Util.Assert;
-
-import android.hardware.Camera.CameraInfo;
-import android.hardware.Camera.Parameters;
-import android.os.Build;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Message;
-import android.util.Log;
-
-import com.android.camera.CameraManager.CameraProxy;
-
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-
-/**
- * The class is used to hold an {@code android.hardware.Camera} instance.
- *
- * <p>The {@code open()} and {@code release()} calls are similar to the ones
- * in {@code android.hardware.Camera}. The difference is if {@code keep()} is
- * called before {@code release()}, CameraHolder will try to hold the {@code
- * android.hardware.Camera} instance for a while, so if {@code open()} is
- * called soon after, we can avoid the cost of {@code open()} in {@code
- * android.hardware.Camera}.
- *
- * <p>This is used in switching between different modules.
- */
-public class CameraHolder {
- private static final String TAG = "CameraHolder";
- private static final int KEEP_CAMERA_TIMEOUT = 3000; // 3 seconds
- private CameraProxy mCameraDevice;
- private long mKeepBeforeTime; // Keep the Camera before this time.
- private final Handler mHandler;
- private boolean mCameraOpened; // true if camera is opened
- private final int mNumberOfCameras;
- private int mCameraId = -1; // current camera id
- private int mBackCameraId = -1;
- private int mFrontCameraId = -1;
- private final CameraInfo[] mInfo;
- private static CameraProxy mMockCamera[];
- private static CameraInfo mMockCameraInfo[];
-
- /* Debug double-open issue */
- private static final boolean DEBUG_OPEN_RELEASE = true;
- private static class OpenReleaseState {
- long time;
- int id;
- String device;
- String[] stack;
- }
- private static ArrayList<OpenReleaseState> sOpenReleaseStates =
- new ArrayList<OpenReleaseState>();
- private static SimpleDateFormat sDateFormat = new SimpleDateFormat(
- "yyyy-MM-dd HH:mm:ss.SSS");
-
- private static synchronized void collectState(int id, CameraProxy device) {
- OpenReleaseState s = new OpenReleaseState();
- s.time = System.currentTimeMillis();
- s.id = id;
- if (device == null) {
- s.device = "(null)";
- } else {
- s.device = device.toString();
- }
-
- StackTraceElement[] stack = Thread.currentThread().getStackTrace();
- String[] lines = new String[stack.length];
- for (int i = 0; i < stack.length; i++) {
- lines[i] = stack[i].toString();
- }
- s.stack = lines;
-
- if (sOpenReleaseStates.size() > 10) {
- sOpenReleaseStates.remove(0);
- }
- sOpenReleaseStates.add(s);
- }
-
- private static synchronized void dumpStates() {
- for (int i = sOpenReleaseStates.size() - 1; i >= 0; i--) {
- OpenReleaseState s = sOpenReleaseStates.get(i);
- String date = sDateFormat.format(new Date(s.time));
- Log.d(TAG, "State " + i + " at " + date);
- Log.d(TAG, "mCameraId = " + s.id + ", mCameraDevice = " + s.device);
- Log.d(TAG, "Stack:");
- for (int j = 0; j < s.stack.length; j++) {
- Log.d(TAG, " " + s.stack[j]);
- }
- }
- }
-
- // We store the camera parameters when we actually open the device,
- // so we can restore them in the subsequent open() requests by the user.
- // This prevents the parameters set by PhotoModule used by VideoModule
- // inadvertently.
- private Parameters mParameters;
-
- // Use a singleton.
- private static CameraHolder sHolder;
- public static synchronized CameraHolder instance() {
- if (sHolder == null) {
- sHolder = new CameraHolder();
- }
- return sHolder;
- }
-
- private static final int RELEASE_CAMERA = 1;
- private class MyHandler extends Handler {
- MyHandler(Looper looper) {
- super(looper);
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch(msg.what) {
- case RELEASE_CAMERA:
- synchronized (CameraHolder.this) {
- // In 'CameraHolder.open', the 'RELEASE_CAMERA' message
- // will be removed if it is found in the queue. However,
- // there is a chance that this message has been handled
- // before being removed. So, we need to add a check
- // here:
- if (!mCameraOpened) release();
- }
- break;
- }
- }
- }
-
- public static void injectMockCamera(CameraInfo[] info, CameraProxy[] camera) {
- mMockCameraInfo = info;
- mMockCamera = camera;
- sHolder = new CameraHolder();
- }
-
- private CameraHolder() {
- HandlerThread ht = new HandlerThread("CameraHolder");
- ht.start();
- mHandler = new MyHandler(ht.getLooper());
- if (mMockCameraInfo != null) {
- mNumberOfCameras = mMockCameraInfo.length;
- mInfo = mMockCameraInfo;
- } else {
- mNumberOfCameras = android.hardware.Camera.getNumberOfCameras();
- mInfo = new CameraInfo[mNumberOfCameras];
- for (int i = 0; i < mNumberOfCameras; i++) {
- mInfo[i] = new CameraInfo();
- android.hardware.Camera.getCameraInfo(i, mInfo[i]);
- }
- }
-
- // get the first (smallest) back and first front camera id
- for (int i = 0; i < mNumberOfCameras; i++) {
- if (mBackCameraId == -1 && mInfo[i].facing == CameraInfo.CAMERA_FACING_BACK) {
- mBackCameraId = i;
- } else if (mFrontCameraId == -1 && mInfo[i].facing == CameraInfo.CAMERA_FACING_FRONT) {
- mFrontCameraId = i;
- }
- }
- }
-
- public int getNumberOfCameras() {
- return mNumberOfCameras;
- }
-
- public CameraInfo[] getCameraInfo() {
- return mInfo;
- }
-
- public synchronized CameraProxy open(int cameraId)
- throws CameraHardwareException {
- if (DEBUG_OPEN_RELEASE) {
- collectState(cameraId, mCameraDevice);
- if (mCameraOpened) {
- Log.e(TAG, "double open");
- dumpStates();
- }
- }
- Assert(!mCameraOpened);
- if (mCameraDevice != null && mCameraId != cameraId) {
- mCameraDevice.release();
- mCameraDevice = null;
- mCameraId = -1;
- }
- if (mCameraDevice == null) {
- try {
- Log.v(TAG, "open camera " + cameraId);
- if (mMockCameraInfo == null) {
- mCameraDevice = CameraManager.instance().cameraOpen(cameraId);
- } else {
- if (mMockCamera == null)
- throw new RuntimeException();
- mCameraDevice = mMockCamera[cameraId];
- }
- mCameraId = cameraId;
- } catch (RuntimeException e) {
- Log.e(TAG, "fail to connect Camera", e);
- throw new CameraHardwareException(e);
- }
- mParameters = mCameraDevice.getParameters();
- } else {
- try {
- mCameraDevice.reconnect();
- } catch (IOException e) {
- Log.e(TAG, "reconnect failed.");
- throw new CameraHardwareException(e);
- }
- mCameraDevice.setParameters(mParameters);
- }
- mCameraOpened = true;
- mHandler.removeMessages(RELEASE_CAMERA);
- mKeepBeforeTime = 0;
- return mCameraDevice;
- }
-
- /**
- * Tries to open the hardware camera. If the camera is being used or
- * unavailable then return {@code null}.
- */
- public synchronized CameraProxy tryOpen(int cameraId) {
- try {
- return !mCameraOpened ? open(cameraId) : null;
- } catch (CameraHardwareException e) {
- // In eng build, we throw the exception so that test tool
- // can detect it and report it
- if ("eng".equals(Build.TYPE)) {
- throw new RuntimeException(e);
- }
- return null;
- }
- }
-
- public synchronized void release() {
- if (DEBUG_OPEN_RELEASE) {
- collectState(mCameraId, mCameraDevice);
- }
-
- if (mCameraDevice == null) return;
-
- long now = System.currentTimeMillis();
- if (now < mKeepBeforeTime) {
- if (mCameraOpened) {
- mCameraOpened = false;
- mCameraDevice.stopPreview();
- }
- mHandler.sendEmptyMessageDelayed(RELEASE_CAMERA,
- mKeepBeforeTime - now);
- return;
- }
- mCameraOpened = false;
- mCameraDevice.release();
- mCameraDevice = null;
- // We must set this to null because it has a reference to Camera.
- // Camera has references to the listeners.
- mParameters = null;
- mCameraId = -1;
- }
-
- public void keep() {
- keep(KEEP_CAMERA_TIMEOUT);
- }
-
- public synchronized void keep(int time) {
- // We allow mCameraOpened in either state for the convenience of the
- // calling activity. The activity may not have a chance to call open()
- // before the user switches to another activity.
- mKeepBeforeTime = System.currentTimeMillis() + time;
- }
-
- public int getBackCameraId() {
- return mBackCameraId;
- }
-
- public int getFrontCameraId() {
- return mFrontCameraId;
- }
-}
diff --git a/src/com/android/camera/CameraManager.java b/src/com/android/camera/CameraManager.java
deleted file mode 100644
index c7005cf5..0000000
--- a/src/com/android/camera/CameraManager.java
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import static com.android.camera.Util.Assert;
-
-import android.annotation.TargetApi;
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera.AutoFocusCallback;
-import android.hardware.Camera.AutoFocusMoveCallback;
-import android.hardware.Camera.ErrorCallback;
-import android.hardware.Camera.FaceDetectionListener;
-import android.hardware.Camera.OnZoomChangeListener;
-import android.hardware.Camera.Parameters;
-import android.hardware.Camera.PictureCallback;
-import android.hardware.Camera.PreviewCallback;
-import android.hardware.Camera.ShutterCallback;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Message;
-import android.util.Log;
-import android.view.SurfaceHolder;
-
-import com.android.gallery3d.common.ApiHelper;
-
-import java.io.IOException;
-
-public class CameraManager {
- private static final String TAG = "CameraManager";
- private static CameraManager sCameraManager = new CameraManager();
-
- private Parameters mParameters;
- private boolean mParametersIsDirty;
- private IOException mReconnectIOException;
-
- private static final int RELEASE = 1;
- private static final int RECONNECT = 2;
- private static final int UNLOCK = 3;
- private static final int LOCK = 4;
- private static final int SET_PREVIEW_TEXTURE_ASYNC = 5;
- private static final int START_PREVIEW_ASYNC = 6;
- private static final int STOP_PREVIEW = 7;
- private static final int SET_PREVIEW_CALLBACK_WITH_BUFFER = 8;
- private static final int ADD_CALLBACK_BUFFER = 9;
- private static final int AUTO_FOCUS = 10;
- private static final int CANCEL_AUTO_FOCUS = 11;
- private static final int SET_AUTO_FOCUS_MOVE_CALLBACK = 12;
- private static final int SET_DISPLAY_ORIENTATION = 13;
- private static final int SET_ZOOM_CHANGE_LISTENER = 14;
- private static final int SET_FACE_DETECTION_LISTENER = 15;
- private static final int START_FACE_DETECTION = 16;
- private static final int STOP_FACE_DETECTION = 17;
- private static final int SET_ERROR_CALLBACK = 18;
- private static final int SET_PARAMETERS = 19;
- private static final int GET_PARAMETERS = 20;
- private static final int SET_PREVIEW_DISPLAY_ASYNC = 21;
- private static final int SET_PREVIEW_CALLBACK = 22;
- private static final int ENABLE_SHUTTER_SOUND = 23;
- private static final int REFRESH_PARAMETERS = 24;
-
- private Handler mCameraHandler;
- private android.hardware.Camera mCamera;
-
- // Used to retain a copy of Parameters for setting parameters.
- private Parameters mParamsToSet;
-
-
- // This holder is used when we need to pass the exception
- // back to the calling thread. SynchornousQueue doesn't
- // allow we to pass a null object thus a holder is needed.
- private class IOExceptionHolder {
- public IOException ex;
- }
-
- public static CameraManager instance() {
- return sCameraManager;
- }
-
- private CameraManager() {
- HandlerThread ht = new HandlerThread("Camera Handler Thread");
- ht.start();
- mCameraHandler = new CameraHandler(ht.getLooper());
- }
-
- private class CameraHandler extends Handler {
- CameraHandler(Looper looper) {
- super(looper);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void startFaceDetection() {
- mCamera.startFaceDetection();
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void stopFaceDetection() {
- mCamera.stopFaceDetection();
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void setFaceDetectionListener(FaceDetectionListener listener) {
- mCamera.setFaceDetectionListener(listener);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- private void setPreviewTexture(Object surfaceTexture) {
- try {
- mCamera.setPreviewTexture((SurfaceTexture) surfaceTexture);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN_MR1)
- private void enableShutterSound(boolean enable) {
- mCamera.enableShutterSound(enable);
- }
-
- /*
- * This method does not deal with the build version check. Everyone should
- * check first before sending message to this handler.
- */
- @Override
- public void handleMessage(final Message msg) {
- try {
- switch (msg.what) {
- case RELEASE:
- mCamera.release();
- mCamera = null;
- return;
-
- case RECONNECT:
- mReconnectIOException = null;
- try {
- mCamera.reconnect();
- } catch (IOException ex) {
- mReconnectIOException = ex;
- }
- return;
-
- case UNLOCK:
- mCamera.unlock();
- return;
-
- case LOCK:
- mCamera.lock();
- return;
-
- case SET_PREVIEW_TEXTURE_ASYNC:
- setPreviewTexture(msg.obj);
- return;
-
- case SET_PREVIEW_DISPLAY_ASYNC:
- try {
- mCamera.setPreviewDisplay((SurfaceHolder) msg.obj);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return;
-
- case START_PREVIEW_ASYNC:
- mCamera.startPreview();
- return;
-
- case STOP_PREVIEW:
- mCamera.stopPreview();
- return;
-
- case SET_PREVIEW_CALLBACK_WITH_BUFFER:
- mCamera.setPreviewCallbackWithBuffer(
- (PreviewCallback) msg.obj);
- return;
-
- case ADD_CALLBACK_BUFFER:
- mCamera.addCallbackBuffer((byte[]) msg.obj);
- return;
-
- case AUTO_FOCUS:
- mCamera.autoFocus((AutoFocusCallback) msg.obj);
- return;
-
- case CANCEL_AUTO_FOCUS:
- mCamera.cancelAutoFocus();
- return;
-
- case SET_AUTO_FOCUS_MOVE_CALLBACK:
- setAutoFocusMoveCallback(mCamera, msg.obj);
- return;
-
- case SET_DISPLAY_ORIENTATION:
- mCamera.setDisplayOrientation(msg.arg1);
- return;
-
- case SET_ZOOM_CHANGE_LISTENER:
- mCamera.setZoomChangeListener(
- (OnZoomChangeListener) msg.obj);
- return;
-
- case SET_FACE_DETECTION_LISTENER:
- setFaceDetectionListener((FaceDetectionListener) msg.obj);
- return;
-
- case START_FACE_DETECTION:
- startFaceDetection();
- return;
-
- case STOP_FACE_DETECTION:
- stopFaceDetection();
- return;
-
- case SET_ERROR_CALLBACK:
- mCamera.setErrorCallback((ErrorCallback) msg.obj);
- return;
-
- case SET_PARAMETERS:
- mParametersIsDirty = true;
- mParamsToSet.unflatten((String) msg.obj);
- mCamera.setParameters(mParamsToSet);
- return;
-
- case GET_PARAMETERS:
- if (mParametersIsDirty) {
- mParameters = mCamera.getParameters();
- mParametersIsDirty = false;
- }
- return;
-
- case SET_PREVIEW_CALLBACK:
- mCamera.setPreviewCallback((PreviewCallback) msg.obj);
- return;
-
- case ENABLE_SHUTTER_SOUND:
- enableShutterSound((msg.arg1 == 1) ? true : false);
- return;
-
- case REFRESH_PARAMETERS:
- mParametersIsDirty = true;
- return;
-
- default:
- throw new RuntimeException("Invalid CameraProxy message=" + msg.what);
- }
- } catch (RuntimeException e) {
- if (msg.what != RELEASE && mCamera != null) {
- try {
- mCamera.release();
- } catch (Exception ex) {
- Log.e(TAG, "Fail to release the camera.");
- }
- mCamera = null;
- }
- throw e;
- }
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
- private void setAutoFocusMoveCallback(android.hardware.Camera camera,
- Object cb) {
- camera.setAutoFocusMoveCallback((AutoFocusMoveCallback) cb);
- }
-
- // Open camera synchronously. This method is invoked in the context of a
- // background thread.
- CameraProxy cameraOpen(int cameraId) {
- // Cannot open camera in mCameraHandler, otherwise all camera events
- // will be routed to mCameraHandler looper, which in turn will call
- // event handler like Camera.onFaceDetection, which in turn will modify
- // UI and cause exception like this:
- // CalledFromWrongThreadException: Only the original thread that created
- // a view hierarchy can touch its views.
- mCamera = android.hardware.Camera.open(cameraId);
- if (mCamera != null) {
- mParametersIsDirty = true;
- if (mParamsToSet == null) {
- mParamsToSet = mCamera.getParameters();
- }
- return new CameraProxy();
- } else {
- return null;
- }
- }
-
- public class CameraProxy {
-
- private CameraProxy() {
- Assert(mCamera != null);
- }
-
- public android.hardware.Camera getCamera() {
- return mCamera;
- }
-
- public void release() {
- // release() must be synchronous so we know exactly when the camera
- // is released and can continue on.
- mCameraHandler.sendEmptyMessage(RELEASE);
- waitDone();
- }
-
- public void reconnect() throws IOException {
- mCameraHandler.sendEmptyMessage(RECONNECT);
- waitDone();
- if (mReconnectIOException != null) {
- throw mReconnectIOException;
- }
- }
-
- public void unlock() {
- mCameraHandler.sendEmptyMessage(UNLOCK);
- }
-
- public void lock() {
- mCameraHandler.sendEmptyMessage(LOCK);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- public void setPreviewTextureAsync(final SurfaceTexture surfaceTexture) {
- mCameraHandler.obtainMessage(SET_PREVIEW_TEXTURE_ASYNC, surfaceTexture).sendToTarget();
- }
-
- public void setPreviewDisplayAsync(final SurfaceHolder surfaceHolder) {
- mCameraHandler.obtainMessage(SET_PREVIEW_DISPLAY_ASYNC, surfaceHolder).sendToTarget();
- }
-
- public void startPreviewAsync() {
- mCameraHandler.sendEmptyMessage(START_PREVIEW_ASYNC);
- }
-
- // stopPreview() is synchronous because many resources should be released after
- // the preview is stopped.
- public void stopPreview() {
- mCameraHandler.sendEmptyMessage(STOP_PREVIEW);
- waitDone();
- }
-
- public void setPreviewCallback(final PreviewCallback cb) {
- mCameraHandler.obtainMessage(SET_PREVIEW_CALLBACK, cb).sendToTarget();
- }
-
- public void setPreviewCallbackWithBuffer(final PreviewCallback cb) {
- mCameraHandler.obtainMessage(SET_PREVIEW_CALLBACK_WITH_BUFFER, cb).sendToTarget();
- }
-
- public void addCallbackBuffer(byte[] callbackBuffer) {
- mCameraHandler.obtainMessage(ADD_CALLBACK_BUFFER, callbackBuffer).sendToTarget();
- }
-
- public void autoFocus(AutoFocusCallback cb) {
- mCameraHandler.obtainMessage(AUTO_FOCUS, cb).sendToTarget();
- }
-
- public void cancelAutoFocus() {
- mCameraHandler.removeMessages(AUTO_FOCUS);
- mCameraHandler.sendEmptyMessage(CANCEL_AUTO_FOCUS);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
- public void setAutoFocusMoveCallback(AutoFocusMoveCallback cb) {
- mCameraHandler.obtainMessage(SET_AUTO_FOCUS_MOVE_CALLBACK, cb).sendToTarget();
- }
-
- public void takePicture(final ShutterCallback shutter, final PictureCallback raw,
- final PictureCallback postview, final PictureCallback jpeg) {
- // Too many parameters, so use post for simplicity
- mCameraHandler.post(new Runnable() {
- @Override
- public void run() {
- mCamera.takePicture(shutter, raw, postview, jpeg);
- }
- });
- }
-
- public void takePicture2(final ShutterCallback shutter, final PictureCallback raw,
- final PictureCallback postview, final PictureCallback jpeg,
- final int cameraState, final int focusState) {
- // Too many parameters, so use post for simplicity
- mCameraHandler.post(new Runnable() {
- @Override
- public void run() {
- try {
- mCamera.takePicture(shutter, raw, postview, jpeg);
- } catch (RuntimeException e) {
- Log.w(TAG, "take picture failed; cameraState:" + cameraState
- + ", focusState:" + focusState);
- throw e;
- }
- }
- });
- }
-
- public void setDisplayOrientation(int degrees) {
- mCameraHandler.obtainMessage(SET_DISPLAY_ORIENTATION, degrees, 0)
- .sendToTarget();
- }
-
- public void setZoomChangeListener(OnZoomChangeListener listener) {
- mCameraHandler.obtainMessage(SET_ZOOM_CHANGE_LISTENER, listener).sendToTarget();
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public void setFaceDetectionListener(FaceDetectionListener listener) {
- mCameraHandler.obtainMessage(SET_FACE_DETECTION_LISTENER, listener).sendToTarget();
- }
-
- public void startFaceDetection() {
- mCameraHandler.sendEmptyMessage(START_FACE_DETECTION);
- }
-
- public void stopFaceDetection() {
- mCameraHandler.sendEmptyMessage(STOP_FACE_DETECTION);
- }
-
- public void setErrorCallback(ErrorCallback cb) {
- mCameraHandler.obtainMessage(SET_ERROR_CALLBACK, cb).sendToTarget();
- }
-
- public void setParameters(Parameters params) {
- if (params == null) {
- Log.v(TAG, "null parameters in setParameters()");
- return;
- }
- mCameraHandler.obtainMessage(SET_PARAMETERS, params.flatten())
- .sendToTarget();
- }
-
- public Parameters getParameters() {
- mCameraHandler.sendEmptyMessage(GET_PARAMETERS);
- waitDone();
- return mParameters;
- }
-
- public void refreshParameters() {
- mCameraHandler.sendEmptyMessage(REFRESH_PARAMETERS);
- }
-
- public void enableShutterSound(boolean enable) {
- mCameraHandler.obtainMessage(
- ENABLE_SHUTTER_SOUND, (enable ? 1 : 0), 0).sendToTarget();
- }
-
- // return false if cancelled.
- public boolean waitDone() {
- final Object waitDoneLock = new Object();
- final Runnable unlockRunnable = new Runnable() {
- @Override
- public void run() {
- synchronized (waitDoneLock) {
- waitDoneLock.notifyAll();
- }
- }
- };
-
- synchronized (waitDoneLock) {
- mCameraHandler.post(unlockRunnable);
- try {
- waitDoneLock.wait();
- } catch (InterruptedException ex) {
- Log.v(TAG, "waitDone interrupted");
- return false;
- }
- }
- return true;
- }
- }
-}
diff --git a/src/com/android/camera/CameraModule.java b/src/com/android/camera/CameraModule.java
deleted file mode 100644
index 3275d5f..0000000
--- a/src/com/android/camera/CameraModule.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.View;
-
-public interface CameraModule {
-
- public void init(CameraActivity activity, View frame, boolean reuseScreenNail);
-
- public void onFullScreenChanged(boolean full);
-
- public void onPauseBeforeSuper();
-
- public void onPauseAfterSuper();
-
- public void onResumeBeforeSuper();
-
- public void onResumeAfterSuper();
-
- public void onConfigurationChanged(Configuration config);
-
- public void onStop();
-
- public void installIntentFilter();
-
- public void onActivityResult(int requestCode, int resultCode, Intent data);
-
- public boolean onBackPressed();
-
- public boolean onKeyDown(int keyCode, KeyEvent event);
-
- public boolean onKeyUp(int keyCode, KeyEvent event);
-
- public void onSingleTapUp(View view, int x, int y);
-
- public boolean dispatchTouchEvent(MotionEvent m);
-
- public void onPreviewTextureCopied();
-
- public void onCaptureTextureCopied();
-
- public void onUserInteraction();
-
- public boolean updateStorageHintOnResume();
-
- public void updateCameraAppView();
-
- public boolean needsSwitcher();
-
- public boolean needsPieMenu();
-
- public void onOrientationChanged(int orientation);
-
- public void onShowSwitcherPopup();
-
- public void onMediaSaveServiceConnected(MediaSaveService s);
-}
diff --git a/src/com/android/camera/CameraPreference.java b/src/com/android/camera/CameraPreference.java
deleted file mode 100644
index 5ddd86d..0000000
--- a/src/com/android/camera/CameraPreference.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-
-import com.android.gallery3d.R;
-
-/**
- * The base class of all Preferences used in Camera. The preferences can be
- * loaded from XML resource by <code>PreferenceInflater</code>.
- */
-public abstract class CameraPreference {
-
- private final String mTitle;
- private SharedPreferences mSharedPreferences;
- private final Context mContext;
-
- static public interface OnPreferenceChangedListener {
- public void onSharedPreferenceChanged();
- public void onRestorePreferencesClicked();
- public void onOverriddenPreferencesClicked();
- public void onCameraPickerClicked(int cameraId);
- }
-
- public CameraPreference(Context context, AttributeSet attrs) {
- mContext = context;
- TypedArray a = context.obtainStyledAttributes(
- attrs, R.styleable.CameraPreference, 0, 0);
- mTitle = a.getString(R.styleable.CameraPreference_title);
- a.recycle();
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- public SharedPreferences getSharedPreferences() {
- if (mSharedPreferences == null) {
- mSharedPreferences = ComboPreferences.get(mContext);
- }
- return mSharedPreferences;
- }
-
- public abstract void reloadValue();
-}
diff --git a/src/com/android/camera/CameraScreenNail.java b/src/com/android/camera/CameraScreenNail.java
deleted file mode 100644
index 993a7d3..0000000
--- a/src/com/android/camera/CameraScreenNail.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.graphics.SurfaceTexture;
-import android.opengl.Matrix;
-import android.util.Log;
-
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.glrenderer.GLCanvas;
-import com.android.gallery3d.glrenderer.RawTexture;
-import com.android.gallery3d.ui.SurfaceTextureScreenNail;
-
-/*
- * This is a ScreenNail which can display camera's preview.
- */
-@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
-public class CameraScreenNail extends SurfaceTextureScreenNail {
- private static final String TAG = "CAM_ScreenNail";
- private static final int ANIM_NONE = 0;
- // Capture animation is about to start.
- private static final int ANIM_CAPTURE_START = 1;
- // Capture animation is running.
- private static final int ANIM_CAPTURE_RUNNING = 2;
- // Switch camera animation needs to copy texture.
- private static final int ANIM_SWITCH_COPY_TEXTURE = 3;
- // Switch camera animation shows the initial feedback by darkening the
- // preview.
- private static final int ANIM_SWITCH_DARK_PREVIEW = 4;
- // Switch camera animation is waiting for the first frame.
- private static final int ANIM_SWITCH_WAITING_FIRST_FRAME = 5;
- // Switch camera animation is about to start.
- private static final int ANIM_SWITCH_START = 6;
- // Switch camera animation is running.
- private static final int ANIM_SWITCH_RUNNING = 7;
-
- private boolean mVisible;
- // True if first onFrameAvailable has been called. If screen nail is drawn
- // too early, it will be all white.
- private boolean mFirstFrameArrived;
- private Listener mListener;
- private final float[] mTextureTransformMatrix = new float[16];
-
- // Animation.
- private CaptureAnimManager mCaptureAnimManager;
- private SwitchAnimManager mSwitchAnimManager = new SwitchAnimManager();
- private int mAnimState = ANIM_NONE;
- private RawTexture mAnimTexture;
- // Some methods are called by GL thread and some are called by main thread.
- // This protects mAnimState, mVisible, and surface texture. This also makes
- // sure some code are atomic. For example, requestRender and setting
- // mAnimState.
- private Object mLock = new Object();
-
- private OnFrameDrawnListener mOneTimeFrameDrawnListener;
- private int mRenderWidth;
- private int mRenderHeight;
- // This represents the scaled, uncropped size of the texture
- // Needed for FaceView
- private int mUncroppedRenderWidth;
- private int mUncroppedRenderHeight;
- private float mScaleX = 1f, mScaleY = 1f;
- private boolean mFullScreen;
- private boolean mEnableAspectRatioClamping = false;
- private boolean mAcquireTexture = false;
- private final DrawClient mDefaultDraw = new DrawClient() {
- @Override
- public void onDraw(GLCanvas canvas, int x, int y, int width, int height) {
- CameraScreenNail.super.draw(canvas, x, y, width, height);
- }
-
- @Override
- public boolean requiresSurfaceTexture() {
- return true;
- }
-
- @Override
- public RawTexture copyToTexture(GLCanvas c, RawTexture texture, int w, int h) {
- // We shouldn't be here since requireSurfaceTexture() returns true.
- return null;
- }
- };
- private DrawClient mDraw = mDefaultDraw;
- private float mAlpha = 1f;
- private Runnable mOnFrameDrawnListener;
-
- public interface Listener {
- void requestRender();
- // Preview has been copied to a texture.
- void onPreviewTextureCopied();
-
- void onCaptureTextureCopied();
- }
-
- public interface OnFrameDrawnListener {
- void onFrameDrawn(CameraScreenNail c);
- }
-
- public interface DrawClient {
- void onDraw(GLCanvas canvas, int x, int y, int width, int height);
-
- boolean requiresSurfaceTexture();
- // The client should implement this if requiresSurfaceTexture() is false;
- RawTexture copyToTexture(GLCanvas c, RawTexture texture, int width, int height);
- }
-
- public CameraScreenNail(Listener listener, Context ctx) {
- mListener = listener;
- mCaptureAnimManager = new CaptureAnimManager(ctx);
- }
-
- public void setFullScreen(boolean full) {
- synchronized (mLock) {
- mFullScreen = full;
- }
- }
-
- /**
- * returns the uncropped, but scaled, width of the rendered texture
- */
- public int getUncroppedRenderWidth() {
- return mUncroppedRenderWidth;
- }
-
- /**
- * returns the uncropped, but scaled, width of the rendered texture
- */
- public int getUncroppedRenderHeight() {
- return mUncroppedRenderHeight;
- }
-
- @Override
- public int getWidth() {
- return mEnableAspectRatioClamping ? mRenderWidth : getTextureWidth();
- }
-
- @Override
- public int getHeight() {
- return mEnableAspectRatioClamping ? mRenderHeight : getTextureHeight();
- }
-
- private int getTextureWidth() {
- return super.getWidth();
- }
-
- private int getTextureHeight() {
- return super.getHeight();
- }
-
- @Override
- public void setSize(int w, int h) {
- super.setSize(w, h);
- mEnableAspectRatioClamping = false;
- if (mRenderWidth == 0) {
- mRenderWidth = w;
- mRenderHeight = h;
- }
- updateRenderSize();
- }
-
- /**
- * Tells the ScreenNail to override the default aspect ratio scaling
- * and instead perform custom scaling to basically do a centerCrop instead
- * of the default centerInside
- *
- * Note that calls to setSize will disable this
- */
- public void enableAspectRatioClamping() {
- mEnableAspectRatioClamping = true;
- updateRenderSize();
- }
-
- private void setPreviewLayoutSize(int w, int h) {
- Log.i(TAG, "preview layout size: "+w+"/"+h);
- mRenderWidth = w;
- mRenderHeight = h;
- updateRenderSize();
- }
-
- private void updateRenderSize() {
- if (!mEnableAspectRatioClamping) {
- mScaleX = mScaleY = 1f;
- mUncroppedRenderWidth = getTextureWidth();
- mUncroppedRenderHeight = getTextureHeight();
- Log.i(TAG, "aspect ratio clamping disabled");
- return;
- }
-
- float aspectRatio;
- if (getTextureWidth() > getTextureHeight()) {
- aspectRatio = (float) getTextureWidth() / (float) getTextureHeight();
- } else {
- aspectRatio = (float) getTextureHeight() / (float) getTextureWidth();
- }
- float scaledTextureWidth, scaledTextureHeight;
- if (mRenderWidth > mRenderHeight) {
- scaledTextureWidth = Math.max(mRenderWidth,
- (int) (mRenderHeight * aspectRatio));
- scaledTextureHeight = Math.max(mRenderHeight,
- (int)(mRenderWidth / aspectRatio));
- } else {
- scaledTextureWidth = Math.max(mRenderWidth,
- (int) (mRenderHeight / aspectRatio));
- scaledTextureHeight = Math.max(mRenderHeight,
- (int) (mRenderWidth * aspectRatio));
- }
- mScaleX = mRenderWidth / scaledTextureWidth;
- mScaleY = mRenderHeight / scaledTextureHeight;
- mUncroppedRenderWidth = Math.round(scaledTextureWidth);
- mUncroppedRenderHeight = Math.round(scaledTextureHeight);
- Log.i(TAG, "aspect ratio clamping enabled, surfaceTexture scale: " + mScaleX + ", " + mScaleY);
- }
-
- public void acquireSurfaceTexture() {
- synchronized (mLock) {
- mFirstFrameArrived = false;
- mAnimTexture = new RawTexture(getTextureWidth(), getTextureHeight(), true);
- mAcquireTexture = true;
- }
- mListener.requestRender();
- }
-
- @Override
- public void releaseSurfaceTexture() {
- synchronized (mLock) {
- if (mAcquireTexture) {
- mAcquireTexture = false;
- mLock.notifyAll();
- } else {
- if (super.getSurfaceTexture() != null) {
- super.releaseSurfaceTexture();
- }
- mAnimState = ANIM_NONE; // stop the animation
- }
- }
- }
-
- public void copyTexture() {
- synchronized (mLock) {
- mListener.requestRender();
- mAnimState = ANIM_SWITCH_COPY_TEXTURE;
- }
- }
-
- public void animateSwitchCamera() {
- Log.v(TAG, "animateSwitchCamera");
- synchronized (mLock) {
- if (mAnimState == ANIM_SWITCH_DARK_PREVIEW) {
- // Do not request render here because camera has been just
- // started. We do not want to draw black frames.
- mAnimState = ANIM_SWITCH_WAITING_FIRST_FRAME;
- }
- }
- }
-
- public void animateCapture(int displayRotation) {
- synchronized (mLock) {
- mCaptureAnimManager.setOrientation(displayRotation);
- mCaptureAnimManager.animateFlashAndSlide();
- mListener.requestRender();
- mAnimState = ANIM_CAPTURE_START;
- }
- }
-
- public RawTexture getAnimationTexture() {
- return mAnimTexture;
- }
-
- public void animateFlash(int displayRotation) {
- synchronized (mLock) {
- mCaptureAnimManager.setOrientation(displayRotation);
- mCaptureAnimManager.animateFlash();
- mListener.requestRender();
- mAnimState = ANIM_CAPTURE_START;
- }
- }
-
- public void animateSlide() {
- synchronized (mLock) {
- mCaptureAnimManager.animateSlide();
- mListener.requestRender();
- }
- }
-
- private void callbackIfNeeded() {
- if (mOneTimeFrameDrawnListener != null) {
- mOneTimeFrameDrawnListener.onFrameDrawn(this);
- mOneTimeFrameDrawnListener = null;
- }
- }
-
- @Override
- protected void updateTransformMatrix(float[] matrix) {
- super.updateTransformMatrix(matrix);
- Matrix.translateM(matrix, 0, .5f, .5f, 0);
- Matrix.scaleM(matrix, 0, mScaleX, mScaleY, 1f);
- Matrix.translateM(matrix, 0, -.5f, -.5f, 0);
- }
-
- public void directDraw(GLCanvas canvas, int x, int y, int width, int height) {
- DrawClient draw;
- synchronized (mLock) {
- draw = mDraw;
- }
- draw.onDraw(canvas, x, y, width, height);
- }
-
- public void setDraw(DrawClient draw) {
- synchronized (mLock) {
- if (draw == null) {
- mDraw = mDefaultDraw;
- } else {
- mDraw = draw;
- }
- }
- mListener.requestRender();
- }
-
- @Override
- public void draw(GLCanvas canvas, int x, int y, int width, int height) {
- synchronized (mLock) {
- allocateTextureIfRequested(canvas);
- if (!mVisible) mVisible = true;
- SurfaceTexture surfaceTexture = getSurfaceTexture();
- if (mDraw.requiresSurfaceTexture() && (surfaceTexture == null || !mFirstFrameArrived)) {
- return;
- }
- if (mOnFrameDrawnListener != null) {
- mOnFrameDrawnListener.run();
- mOnFrameDrawnListener = null;
- }
- float oldAlpha = canvas.getAlpha();
- canvas.setAlpha(mAlpha);
-
- switch (mAnimState) {
- case ANIM_NONE:
- directDraw(canvas, x, y, width, height);
- break;
- case ANIM_SWITCH_COPY_TEXTURE:
- copyPreviewTexture(canvas);
- mSwitchAnimManager.setReviewDrawingSize(width, height);
- mListener.onPreviewTextureCopied();
- mAnimState = ANIM_SWITCH_DARK_PREVIEW;
- // The texture is ready. Fall through to draw darkened
- // preview.
- case ANIM_SWITCH_DARK_PREVIEW:
- case ANIM_SWITCH_WAITING_FIRST_FRAME:
- // Consume the frame. If the buffers are full,
- // onFrameAvailable will not be called. Animation state
- // relies on onFrameAvailable.
- surfaceTexture.updateTexImage();
- mSwitchAnimManager.drawDarkPreview(canvas, x, y, width,
- height, mAnimTexture);
- break;
- case ANIM_SWITCH_START:
- mSwitchAnimManager.startAnimation();
- mAnimState = ANIM_SWITCH_RUNNING;
- break;
- case ANIM_CAPTURE_START:
- copyPreviewTexture(canvas);
- mListener.onCaptureTextureCopied();
- mCaptureAnimManager.startAnimation();
- mAnimState = ANIM_CAPTURE_RUNNING;
- break;
- }
-
- if (mAnimState == ANIM_CAPTURE_RUNNING || mAnimState == ANIM_SWITCH_RUNNING) {
- boolean drawn;
- if (mAnimState == ANIM_CAPTURE_RUNNING) {
- if (!mFullScreen) {
- // Skip the animation if no longer in full screen mode
- drawn = false;
- } else {
- drawn = mCaptureAnimManager.drawAnimation(canvas, this, mAnimTexture,
- x, y, width, height);
- }
- } else {
- drawn = mSwitchAnimManager.drawAnimation(canvas, x, y,
- width, height, this, mAnimTexture);
- }
- if (drawn) {
- mListener.requestRender();
- } else {
- // Continue to the normal draw procedure if the animation is
- // not drawn.
- mAnimState = ANIM_NONE;
- directDraw(canvas, x, y, width, height);
- }
- }
- canvas.setAlpha(oldAlpha);
- callbackIfNeeded();
- } // mLock
- }
-
- private void copyPreviewTexture(GLCanvas canvas) {
- if (!mDraw.requiresSurfaceTexture()) {
- mAnimTexture = mDraw.copyToTexture(
- canvas, mAnimTexture, getTextureWidth(), getTextureHeight());
- } else {
- int width = mAnimTexture.getWidth();
- int height = mAnimTexture.getHeight();
- canvas.beginRenderTarget(mAnimTexture);
- // Flip preview texture vertically. OpenGL uses bottom left point
- // as the origin (0, 0).
- canvas.translate(0, height);
- canvas.scale(1, -1, 1);
- getSurfaceTexture().getTransformMatrix(mTextureTransformMatrix);
- updateTransformMatrix(mTextureTransformMatrix);
- canvas.drawTexture(mExtTexture, mTextureTransformMatrix, 0, 0, width, height);
- canvas.endRenderTarget();
- }
- }
-
- @Override
- public void noDraw() {
- synchronized (mLock) {
- mVisible = false;
- }
- }
-
- @Override
- public void recycle() {
- synchronized (mLock) {
- mVisible = false;
- }
- }
-
- @Override
- public void onFrameAvailable(SurfaceTexture surfaceTexture) {
- synchronized (mLock) {
- if (getSurfaceTexture() != surfaceTexture) {
- return;
- }
- mFirstFrameArrived = true;
- if (mVisible) {
- if (mAnimState == ANIM_SWITCH_WAITING_FIRST_FRAME) {
- mAnimState = ANIM_SWITCH_START;
- }
- // We need to ask for re-render if the SurfaceTexture receives a new
- // frame.
- mListener.requestRender();
- }
- }
- }
-
- // We need to keep track of the size of preview frame on the screen because
- // it's needed when we do switch-camera animation. See comments in
- // SwitchAnimManager.java. This is based on the natural orientation, not the
- // view system orientation.
- public void setPreviewFrameLayoutSize(int width, int height) {
- synchronized (mLock) {
- mSwitchAnimManager.setPreviewFrameLayoutSize(width, height);
- setPreviewLayoutSize(width, height);
- }
- }
-
- public void setOneTimeOnFrameDrawnListener(OnFrameDrawnListener l) {
- synchronized (mLock) {
- mFirstFrameArrived = false;
- mOneTimeFrameDrawnListener = l;
- }
- }
-
- @Override
- public SurfaceTexture getSurfaceTexture() {
- synchronized (mLock) {
- SurfaceTexture surfaceTexture = super.getSurfaceTexture();
- if (surfaceTexture == null && mAcquireTexture) {
- try {
- mLock.wait();
- surfaceTexture = super.getSurfaceTexture();
- } catch (InterruptedException e) {
- Log.w(TAG, "unexpected interruption");
- }
- }
- return surfaceTexture;
- }
- }
-
- private void allocateTextureIfRequested(GLCanvas canvas) {
- synchronized (mLock) {
- if (mAcquireTexture) {
- super.acquireSurfaceTexture(canvas);
- mAcquireTexture = false;
- mLock.notifyAll();
- }
- }
- }
-
- public void setOnFrameDrawnOneShot(Runnable run) {
- synchronized (mLock) {
- mOnFrameDrawnListener = run;
- }
- }
-
- public float getAlpha() {
- synchronized (mLock) {
- return mAlpha;
- }
- }
-
- public void setAlpha(float alpha) {
- synchronized (mLock) {
- mAlpha = alpha;
- mListener.requestRender();
- }
- }
-}
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
deleted file mode 100644
index 4e9a5dd..0000000
--- a/src/com/android/camera/CameraSettings.java
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.hardware.Camera.CameraInfo;
-import android.hardware.Camera.Parameters;
-import android.hardware.Camera.Size;
-import android.media.CamcorderProfile;
-import android.util.FloatMath;
-import android.util.Log;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * Provides utilities and keys for Camera settings.
- */
-public class CameraSettings {
- private static final int NOT_FOUND = -1;
-
- public static final String KEY_VERSION = "pref_version_key";
- public static final String KEY_LOCAL_VERSION = "pref_local_version_key";
- public static final String KEY_RECORD_LOCATION = "pref_camera_recordlocation_key";
- public static final String KEY_VIDEO_QUALITY = "pref_video_quality_key";
- public static final String KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL = "pref_video_time_lapse_frame_interval_key";
- public static final String KEY_PICTURE_SIZE = "pref_camera_picturesize_key";
- public static final String KEY_JPEG_QUALITY = "pref_camera_jpegquality_key";
- public static final String KEY_FOCUS_MODE = "pref_camera_focusmode_key";
- public static final String KEY_FLASH_MODE = "pref_camera_flashmode_key";
- public static final String KEY_VIDEOCAMERA_FLASH_MODE = "pref_camera_video_flashmode_key";
- public static final String KEY_WHITE_BALANCE = "pref_camera_whitebalance_key";
- public static final String KEY_SCENE_MODE = "pref_camera_scenemode_key";
- public static final String KEY_EXPOSURE = "pref_camera_exposure_key";
- public static final String KEY_TIMER = "pref_camera_timer_key";
- public static final String KEY_TIMER_SOUND_EFFECTS = "pref_camera_timer_sound_key";
- public static final String KEY_VIDEO_EFFECT = "pref_video_effect_key";
- public static final String KEY_CAMERA_ID = "pref_camera_id_key";
- public static final String KEY_CAMERA_HDR = "pref_camera_hdr_key";
- public static final String KEY_CAMERA_FIRST_USE_HINT_SHOWN = "pref_camera_first_use_hint_shown_key";
- public static final String KEY_VIDEO_FIRST_USE_HINT_SHOWN = "pref_video_first_use_hint_shown_key";
- public static final String KEY_PHOTOSPHERE_PICTURESIZE = "pref_photosphere_picturesize_key";
-
- public static final String EXPOSURE_DEFAULT_VALUE = "0";
-
- public static final int CURRENT_VERSION = 5;
- public static final int CURRENT_LOCAL_VERSION = 2;
-
- private static final String TAG = "CameraSettings";
-
- private final Context mContext;
- private final Parameters mParameters;
- private final CameraInfo[] mCameraInfo;
- private final int mCameraId;
-
- public CameraSettings(Activity activity, Parameters parameters,
- int cameraId, CameraInfo[] cameraInfo) {
- mContext = activity;
- mParameters = parameters;
- mCameraId = cameraId;
- mCameraInfo = cameraInfo;
- }
-
- public PreferenceGroup getPreferenceGroup(int preferenceRes) {
- PreferenceInflater inflater = new PreferenceInflater(mContext);
- PreferenceGroup group =
- (PreferenceGroup) inflater.inflate(preferenceRes);
- if (mParameters != null) initPreference(group);
- return group;
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- public static String getDefaultVideoQuality(int cameraId,
- String defaultQuality) {
- if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) {
- if (CamcorderProfile.hasProfile(
- cameraId, Integer.valueOf(defaultQuality))) {
- return defaultQuality;
- }
- }
- return Integer.toString(CamcorderProfile.QUALITY_HIGH);
- }
-
- public static void initialCameraPictureSize(
- Context context, Parameters parameters) {
- // When launching the camera app first time, we will set the picture
- // size to the first one in the list defined in "arrays.xml" and is also
- // supported by the driver.
- List<Size> supported = parameters.getSupportedPictureSizes();
- if (supported == null) return;
- for (String candidate : context.getResources().getStringArray(
- R.array.pref_camera_picturesize_entryvalues)) {
- if (setCameraPictureSize(candidate, supported, parameters)) {
- SharedPreferences.Editor editor = ComboPreferences
- .get(context).edit();
- editor.putString(KEY_PICTURE_SIZE, candidate);
- editor.apply();
- return;
- }
- }
- Log.e(TAG, "No supported picture size found");
- }
-
- public static void removePreferenceFromScreen(
- PreferenceGroup group, String key) {
- removePreference(group, key);
- }
-
- public static boolean setCameraPictureSize(
- String candidate, List<Size> supported, Parameters parameters) {
- int index = candidate.indexOf('x');
- if (index == NOT_FOUND) return false;
- int width = Integer.parseInt(candidate.substring(0, index));
- int height = Integer.parseInt(candidate.substring(index + 1));
- for (Size size : supported) {
- if (size.width == width && size.height == height) {
- parameters.setPictureSize(width, height);
- return true;
- }
- }
- return false;
- }
-
- public static int getMaxVideoDuration(Context context) {
- int duration = 0; // in milliseconds, 0 means unlimited.
- try {
- duration = context.getResources().getInteger(R.integer.max_video_recording_length);
- } catch (Resources.NotFoundException ex) {
- }
- return duration;
- }
-
- private void initPreference(PreferenceGroup group) {
- ListPreference videoQuality = group.findPreference(KEY_VIDEO_QUALITY);
- ListPreference timeLapseInterval = group.findPreference(KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL);
- ListPreference pictureSize = group.findPreference(KEY_PICTURE_SIZE);
- ListPreference whiteBalance = group.findPreference(KEY_WHITE_BALANCE);
- ListPreference sceneMode = group.findPreference(KEY_SCENE_MODE);
- ListPreference flashMode = group.findPreference(KEY_FLASH_MODE);
- ListPreference focusMode = group.findPreference(KEY_FOCUS_MODE);
- IconListPreference exposure =
- (IconListPreference) group.findPreference(KEY_EXPOSURE);
- CountDownTimerPreference timer =
- (CountDownTimerPreference) group.findPreference(KEY_TIMER);
- ListPreference countDownSoundEffects = group.findPreference(KEY_TIMER_SOUND_EFFECTS);
- IconListPreference cameraIdPref =
- (IconListPreference) group.findPreference(KEY_CAMERA_ID);
- ListPreference videoFlashMode =
- group.findPreference(KEY_VIDEOCAMERA_FLASH_MODE);
- ListPreference videoEffect = group.findPreference(KEY_VIDEO_EFFECT);
- ListPreference cameraHdr = group.findPreference(KEY_CAMERA_HDR);
-
- // Since the screen could be loaded from different resources, we need
- // to check if the preference is available here
- if (videoQuality != null) {
- filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality());
- }
-
- if (pictureSize != null) {
- filterUnsupportedOptions(group, pictureSize, sizeListToStringList(
- mParameters.getSupportedPictureSizes()));
- filterSimilarPictureSize(group, pictureSize);
- }
- if (whiteBalance != null) {
- filterUnsupportedOptions(group,
- whiteBalance, mParameters.getSupportedWhiteBalance());
- }
- if (sceneMode != null) {
- filterUnsupportedOptions(group,
- sceneMode, mParameters.getSupportedSceneModes());
- }
- if (flashMode != null) {
- filterUnsupportedOptions(group,
- flashMode, mParameters.getSupportedFlashModes());
- }
- if (focusMode != null) {
- if (!Util.isFocusAreaSupported(mParameters)) {
- filterUnsupportedOptions(group,
- focusMode, mParameters.getSupportedFocusModes());
- } else {
- // Remove the focus mode if we can use tap-to-focus.
- removePreference(group, focusMode.getKey());
- }
- }
- if (videoFlashMode != null) {
- filterUnsupportedOptions(group,
- videoFlashMode, mParameters.getSupportedFlashModes());
- }
- if (exposure != null) buildExposureCompensation(group, exposure);
- if (cameraIdPref != null) buildCameraId(group, cameraIdPref);
-
- if (timeLapseInterval != null) {
- if (ApiHelper.HAS_TIME_LAPSE_RECORDING) {
- resetIfInvalid(timeLapseInterval);
- } else {
- removePreference(group, timeLapseInterval.getKey());
- }
- }
- if (videoEffect != null) {
- if (ApiHelper.HAS_EFFECTS_RECORDING) {
- initVideoEffect(group, videoEffect);
- resetIfInvalid(videoEffect);
- } else {
- filterUnsupportedOptions(group, videoEffect, null);
- }
- }
- if (cameraHdr != null && (!ApiHelper.HAS_CAMERA_HDR
- || !Util.isCameraHdrSupported(mParameters))) {
- removePreference(group, cameraHdr.getKey());
- }
- }
-
- private void buildExposureCompensation(
- PreferenceGroup group, IconListPreference exposure) {
- int max = mParameters.getMaxExposureCompensation();
- int min = mParameters.getMinExposureCompensation();
- if (max == 0 && min == 0) {
- removePreference(group, exposure.getKey());
- return;
- }
- float step = mParameters.getExposureCompensationStep();
-
- // show only integer values for exposure compensation
- int maxValue = Math.min(3, (int) FloatMath.floor(max * step));
- int minValue = Math.max(-3, (int) FloatMath.ceil(min * step));
- String explabel = mContext.getResources().getString(R.string.pref_exposure_label);
- CharSequence entries[] = new CharSequence[maxValue - minValue + 1];
- CharSequence entryValues[] = new CharSequence[maxValue - minValue + 1];
- CharSequence labels[] = new CharSequence[maxValue - minValue + 1];
- int[] icons = new int[maxValue - minValue + 1];
- TypedArray iconIds = mContext.getResources().obtainTypedArray(
- R.array.pref_camera_exposure_icons);
- for (int i = minValue; i <= maxValue; ++i) {
- entryValues[i - minValue] = Integer.toString(Math.round(i / step));
- StringBuilder builder = new StringBuilder();
- if (i > 0) builder.append('+');
- entries[i - minValue] = builder.append(i).toString();
- labels[i - minValue] = explabel + " " + builder.toString();
- icons[i - minValue] = iconIds.getResourceId(3 + i, 0);
- }
- exposure.setUseSingleIcon(true);
- exposure.setEntries(entries);
- exposure.setLabels(labels);
- exposure.setEntryValues(entryValues);
- exposure.setLargeIconIds(icons);
- }
-
- private void buildCameraId(
- PreferenceGroup group, IconListPreference preference) {
- int numOfCameras = mCameraInfo.length;
- if (numOfCameras < 2) {
- removePreference(group, preference.getKey());
- return;
- }
-
- CharSequence[] entryValues = new CharSequence[numOfCameras];
- for (int i = 0; i < numOfCameras; ++i) {
- entryValues[i] = "" + i;
- }
- preference.setEntryValues(entryValues);
- }
-
- private static boolean removePreference(PreferenceGroup group, String key) {
- for (int i = 0, n = group.size(); i < n; i++) {
- CameraPreference child = group.get(i);
- if (child instanceof PreferenceGroup) {
- if (removePreference((PreferenceGroup) child, key)) {
- return true;
- }
- }
- if (child instanceof ListPreference &&
- ((ListPreference) child).getKey().equals(key)) {
- group.removePreference(i);
- return true;
- }
- }
- return false;
- }
-
- private void filterUnsupportedOptions(PreferenceGroup group,
- ListPreference pref, List<String> supported) {
-
- // Remove the preference if the parameter is not supported or there is
- // only one options for the settings.
- if (supported == null || supported.size() <= 1) {
- removePreference(group, pref.getKey());
- return;
- }
-
- pref.filterUnsupported(supported);
- if (pref.getEntries().length <= 1) {
- removePreference(group, pref.getKey());
- return;
- }
-
- resetIfInvalid(pref);
- }
-
- private void filterSimilarPictureSize(PreferenceGroup group,
- ListPreference pref) {
- pref.filterDuplicated();
- if (pref.getEntries().length <= 1) {
- removePreference(group, pref.getKey());
- return;
- }
- resetIfInvalid(pref);
- }
-
- private void resetIfInvalid(ListPreference pref) {
- // Set the value to the first entry if it is invalid.
- String value = pref.getValue();
- if (pref.findIndexOfValue(value) == NOT_FOUND) {
- pref.setValueIndex(0);
- }
- }
-
- private static List<String> sizeListToStringList(List<Size> sizes) {
- ArrayList<String> list = new ArrayList<String>();
- for (Size size : sizes) {
- list.add(String.format(Locale.ENGLISH, "%dx%d", size.width, size.height));
- }
- return list;
- }
-
- public static void upgradeLocalPreferences(SharedPreferences pref) {
- int version;
- try {
- version = pref.getInt(KEY_LOCAL_VERSION, 0);
- } catch (Exception ex) {
- version = 0;
- }
- if (version == CURRENT_LOCAL_VERSION) return;
-
- SharedPreferences.Editor editor = pref.edit();
- if (version == 1) {
- // We use numbers to represent the quality now. The quality definition is identical to
- // that of CamcorderProfile.java.
- editor.remove("pref_video_quality_key");
- }
- editor.putInt(KEY_LOCAL_VERSION, CURRENT_LOCAL_VERSION);
- editor.apply();
- }
-
- public static void upgradeGlobalPreferences(SharedPreferences pref) {
- upgradeOldVersion(pref);
- upgradeCameraId(pref);
- }
-
- private static void upgradeOldVersion(SharedPreferences pref) {
- int version;
- try {
- version = pref.getInt(KEY_VERSION, 0);
- } catch (Exception ex) {
- version = 0;
- }
- if (version == CURRENT_VERSION) return;
-
- SharedPreferences.Editor editor = pref.edit();
- if (version == 0) {
- // We won't use the preference which change in version 1.
- // So, just upgrade to version 1 directly
- version = 1;
- }
- if (version == 1) {
- // Change jpeg quality {65,75,85} to {normal,fine,superfine}
- String quality = pref.getString(KEY_JPEG_QUALITY, "85");
- if (quality.equals("65")) {
- quality = "normal";
- } else if (quality.equals("75")) {
- quality = "fine";
- } else {
- quality = "superfine";
- }
- editor.putString(KEY_JPEG_QUALITY, quality);
- version = 2;
- }
- if (version == 2) {
- editor.putString(KEY_RECORD_LOCATION,
- pref.getBoolean(KEY_RECORD_LOCATION, false)
- ? RecordLocationPreference.VALUE_ON
- : RecordLocationPreference.VALUE_NONE);
- version = 3;
- }
- if (version == 3) {
- // Just use video quality to replace it and
- // ignore the current settings.
- editor.remove("pref_camera_videoquality_key");
- editor.remove("pref_camera_video_duration_key");
- }
-
- editor.putInt(KEY_VERSION, CURRENT_VERSION);
- editor.apply();
- }
-
- private static void upgradeCameraId(SharedPreferences pref) {
- // The id stored in the preference may be out of range if we are running
- // inside the emulator and a webcam is removed.
- // Note: This method accesses the global preferences directly, not the
- // combo preferences.
- int cameraId = readPreferredCameraId(pref);
- if (cameraId == 0) return; // fast path
-
- int n = CameraHolder.instance().getNumberOfCameras();
- if (cameraId < 0 || cameraId >= n) {
- writePreferredCameraId(pref, 0);
- }
- }
-
- public static int readPreferredCameraId(SharedPreferences pref) {
- return Integer.parseInt(pref.getString(KEY_CAMERA_ID, "0"));
- }
-
- public static void writePreferredCameraId(SharedPreferences pref,
- int cameraId) {
- Editor editor = pref.edit();
- editor.putString(KEY_CAMERA_ID, Integer.toString(cameraId));
- editor.apply();
- }
-
- public static int readExposure(ComboPreferences preferences) {
- String exposure = preferences.getString(
- CameraSettings.KEY_EXPOSURE,
- EXPOSURE_DEFAULT_VALUE);
- try {
- return Integer.parseInt(exposure);
- } catch (Exception ex) {
- Log.e(TAG, "Invalid exposure: " + exposure);
- }
- return 0;
- }
-
- public static int readEffectType(SharedPreferences pref) {
- String effectSelection = pref.getString(KEY_VIDEO_EFFECT, "none");
- if (effectSelection.equals("none")) {
- return EffectsRecorder.EFFECT_NONE;
- } else if (effectSelection.startsWith("goofy_face")) {
- return EffectsRecorder.EFFECT_GOOFY_FACE;
- } else if (effectSelection.startsWith("backdropper")) {
- return EffectsRecorder.EFFECT_BACKDROPPER;
- }
- Log.e(TAG, "Invalid effect selection: " + effectSelection);
- return EffectsRecorder.EFFECT_NONE;
- }
-
- public static Object readEffectParameter(SharedPreferences pref) {
- String effectSelection = pref.getString(KEY_VIDEO_EFFECT, "none");
- if (effectSelection.equals("none")) {
- return null;
- }
- int separatorIndex = effectSelection.indexOf('/');
- String effectParameter =
- effectSelection.substring(separatorIndex + 1);
- if (effectSelection.startsWith("goofy_face")) {
- if (effectParameter.equals("squeeze")) {
- return EffectsRecorder.EFFECT_GF_SQUEEZE;
- } else if (effectParameter.equals("big_eyes")) {
- return EffectsRecorder.EFFECT_GF_BIG_EYES;
- } else if (effectParameter.equals("big_mouth")) {
- return EffectsRecorder.EFFECT_GF_BIG_MOUTH;
- } else if (effectParameter.equals("small_mouth")) {
- return EffectsRecorder.EFFECT_GF_SMALL_MOUTH;
- } else if (effectParameter.equals("big_nose")) {
- return EffectsRecorder.EFFECT_GF_BIG_NOSE;
- } else if (effectParameter.equals("small_eyes")) {
- return EffectsRecorder.EFFECT_GF_SMALL_EYES;
- }
- } else if (effectSelection.startsWith("backdropper")) {
- // Parameter is a string that either encodes the URI to use,
- // or specifies 'gallery'.
- return effectParameter;
- }
-
- Log.e(TAG, "Invalid effect selection: " + effectSelection);
- return null;
- }
-
- public static void restorePreferences(Context context,
- ComboPreferences preferences, Parameters parameters) {
- int currentCameraId = readPreferredCameraId(preferences);
-
- // Clear the preferences of both cameras.
- int backCameraId = CameraHolder.instance().getBackCameraId();
- if (backCameraId != -1) {
- preferences.setLocalId(context, backCameraId);
- Editor editor = preferences.edit();
- editor.clear();
- editor.apply();
- }
- int frontCameraId = CameraHolder.instance().getFrontCameraId();
- if (frontCameraId != -1) {
- preferences.setLocalId(context, frontCameraId);
- Editor editor = preferences.edit();
- editor.clear();
- editor.apply();
- }
-
- // Switch back to the preferences of the current camera. Otherwise,
- // we may write the preference to wrong camera later.
- preferences.setLocalId(context, currentCameraId);
-
- upgradeGlobalPreferences(preferences.getGlobal());
- upgradeLocalPreferences(preferences.getLocal());
-
- // Write back the current camera id because parameters are related to
- // the camera. Otherwise, we may switch to the front camera but the
- // initial picture size is that of the back camera.
- initialCameraPictureSize(context, parameters);
- writePreferredCameraId(preferences, currentCameraId);
- }
-
- private ArrayList<String> getSupportedVideoQuality() {
- ArrayList<String> supported = new ArrayList<String>();
- // Check for supported quality
- if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) {
- getFineResolutionQuality(supported);
- } else {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_HIGH));
- CamcorderProfile high = CamcorderProfile.get(
- mCameraId, CamcorderProfile.QUALITY_HIGH);
- CamcorderProfile low = CamcorderProfile.get(
- mCameraId, CamcorderProfile.QUALITY_LOW);
- if (high.videoFrameHeight * high.videoFrameWidth >
- low.videoFrameHeight * low.videoFrameWidth) {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_LOW));
- }
- }
-
- return supported;
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- private void getFineResolutionQuality(ArrayList<String> supported) {
- if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_1080P)) {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_1080P));
- }
- if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_720P)) {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_720P));
- }
- if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_480P)) {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_480P));
- }
- }
-
- private void initVideoEffect(PreferenceGroup group, ListPreference videoEffect) {
- CharSequence[] values = videoEffect.getEntryValues();
-
- boolean goofyFaceSupported =
- EffectsRecorder.isEffectSupported(EffectsRecorder.EFFECT_GOOFY_FACE);
- boolean backdropperSupported =
- EffectsRecorder.isEffectSupported(EffectsRecorder.EFFECT_BACKDROPPER) &&
- Util.isAutoExposureLockSupported(mParameters) &&
- Util.isAutoWhiteBalanceLockSupported(mParameters);
-
- ArrayList<String> supported = new ArrayList<String>();
- for (CharSequence value : values) {
- String effectSelection = value.toString();
- if (!goofyFaceSupported && effectSelection.startsWith("goofy_face")) continue;
- if (!backdropperSupported && effectSelection.startsWith("backdropper")) continue;
- supported.add(effectSelection);
- }
-
- filterUnsupportedOptions(group, videoEffect, supported);
- }
-}
diff --git a/src/com/android/camera/CaptureAnimManager.java b/src/com/android/camera/CaptureAnimManager.java
deleted file mode 100644
index 6e80925..0000000
--- a/src/com/android/camera/CaptureAnimManager.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.os.SystemClock;
-import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.glrenderer.GLCanvas;
-import com.android.gallery3d.glrenderer.NinePatchTexture;
-import com.android.gallery3d.glrenderer.RawTexture;
-
-/**
- * Class to handle the capture animation.
- */
-public class CaptureAnimManager {
- @SuppressWarnings("unused")
- private static final String TAG = "CAM_Capture";
- // times mark endpoint of animation phase
- private static final int TIME_FLASH = 200;
- private static final int TIME_HOLD = 400;
- private static final int TIME_SLIDE = 800;
- private static final int TIME_HOLD2 = 3300;
- private static final int TIME_SLIDE2 = 4100;
-
- private static final int ANIM_BOTH = 0;
- private static final int ANIM_FLASH = 1;
- private static final int ANIM_SLIDE = 2;
- private static final int ANIM_HOLD2 = 3;
- private static final int ANIM_SLIDE2 = 4;
-
- private final Interpolator mSlideInterpolator = new DecelerateInterpolator();
-
- private volatile int mAnimOrientation; // Could be 0, 90, 180 or 270 degrees.
- private long mAnimStartTime; // milliseconds.
- private float mX; // The center of the whole view including preview and review.
- private float mY;
- private int mDrawWidth;
- private int mDrawHeight;
- private int mAnimType;
-
- private int mHoldX;
- private int mHoldY;
- private int mHoldW;
- private int mHoldH;
-
- private int mOffset;
-
- private int mMarginRight;
- private int mMarginTop;
- private int mSize;
- private Resources mResources;
- private NinePatchTexture mBorder;
- private int mShadowSize;
-
- public static int getAnimationDuration() {
- return TIME_SLIDE2;
- }
-
- /* preview: camera preview view.
- * review: view of picture just taken.
- */
- public CaptureAnimManager(Context ctx) {
- mBorder = new NinePatchTexture(ctx, R.drawable.capture_thumbnail_shadow);
- mResources = ctx.getResources();
- }
-
- public void setOrientation(int displayRotation) {
- mAnimOrientation = (360 - displayRotation) % 360;
- }
-
- public void animateSlide() {
- if (mAnimType != ANIM_FLASH) {
- return;
- }
- mAnimType = ANIM_SLIDE;
- mAnimStartTime = SystemClock.uptimeMillis();
- }
-
- public void animateFlash() {
- mAnimType = ANIM_FLASH;
- }
-
- public void animateFlashAndSlide() {
- mAnimType = ANIM_BOTH;
- }
-
- public void startAnimation() {
- mAnimStartTime = SystemClock.uptimeMillis();
- }
-
- private void setAnimationGeometry(int x, int y, int w, int h) {
- mMarginRight = mResources.getDimensionPixelSize(R.dimen.capture_margin_right);
- mMarginTop = mResources.getDimensionPixelSize(R.dimen.capture_margin_top);
- mSize = mResources.getDimensionPixelSize(R.dimen.capture_size);
- mShadowSize = mResources.getDimensionPixelSize(R.dimen.capture_border);
- mOffset = mMarginRight + mSize;
- // Set the views to the initial positions.
- mDrawWidth = w;
- mDrawHeight = h;
- mX = x;
- mY = y;
- mHoldW = mSize;
- mHoldH = mSize;
- switch (mAnimOrientation) {
- case 0: // Preview is on the left.
- mHoldX = x + w - mMarginRight - mSize;
- mHoldY = y + mMarginTop;
- break;
- case 90: // Preview is below.
- mHoldX = x + mMarginTop;
- mHoldY = y + mMarginRight;
- break;
- case 180: // Preview on the right.
- mHoldX = x + mMarginRight;
- mHoldY = y + h - mMarginTop - mSize;
- break;
- case 270: // Preview is above.
- mHoldX = x + w - mMarginTop - mSize;
- mHoldY = y + h - mMarginRight - mSize;
- break;
- }
- }
-
- // Returns true if the animation has been drawn.
- public boolean drawAnimation(GLCanvas canvas, CameraScreenNail preview,
- RawTexture review, int lx, int ly, int lw, int lh) {
- setAnimationGeometry(lx, ly, lw, lh);
- long timeDiff = SystemClock.uptimeMillis() - mAnimStartTime;
- // Check if the animation is over
- if (mAnimType == ANIM_SLIDE && timeDiff > TIME_SLIDE2 - TIME_HOLD) return false;
- if (mAnimType == ANIM_BOTH && timeDiff > TIME_SLIDE2) return false;
-
- // determine phase and time in phase
- int animStep = mAnimType;
- if (mAnimType == ANIM_SLIDE) {
- timeDiff += TIME_HOLD;
- }
- if (mAnimType == ANIM_SLIDE || mAnimType == ANIM_BOTH) {
- if (timeDiff < TIME_HOLD) {
- animStep = ANIM_FLASH;
- } else if (timeDiff < TIME_SLIDE) {
- animStep = ANIM_SLIDE;
- timeDiff -= TIME_HOLD;
- } else if (timeDiff < TIME_HOLD2) {
- animStep = ANIM_HOLD2;
- timeDiff -= TIME_SLIDE;
- } else {
- // SLIDE2
- animStep = ANIM_SLIDE2;
- timeDiff -= TIME_HOLD2;
- }
- }
-
- if (animStep == ANIM_FLASH) {
- review.draw(canvas, (int) mX, (int) mY, mDrawWidth, mDrawHeight);
- if (timeDiff < TIME_FLASH) {
- float f = 0.3f - 0.3f * timeDiff / TIME_FLASH;
- int color = Color.argb((int) (255 * f), 255, 255, 255);
- canvas.fillRect(mX, mY, mDrawWidth, mDrawHeight, color);
- }
- } else if (animStep == ANIM_SLIDE) {
- float fraction = mSlideInterpolator.getInterpolation((float) (timeDiff) / (TIME_SLIDE - TIME_HOLD));
- float x = mX;
- float y = mY;
- float w = 0;
- float h = 0;
- x = interpolate(mX, mHoldX, fraction);
- y = interpolate(mY, mHoldY, fraction);
- w = interpolate(mDrawWidth, mHoldW, fraction);
- h = interpolate(mDrawHeight, mHoldH, fraction);
- preview.directDraw(canvas, (int) mX, (int) mY, mDrawWidth, mDrawHeight);
- review.draw(canvas, (int) x, (int) y, (int) w, (int) h);
- } else if (animStep == ANIM_HOLD2) {
- preview.directDraw(canvas, (int) mX, (int) mY, mDrawWidth, mDrawHeight);
- review.draw(canvas, mHoldX, mHoldY, mHoldW, mHoldH);
- mBorder.draw(canvas, (int) mHoldX - mShadowSize, (int) mHoldY - mShadowSize,
- (int) mHoldW + 2 * mShadowSize, (int) mHoldH + 2 * mShadowSize);
- } else if (animStep == ANIM_SLIDE2) {
- float fraction = (float)(timeDiff) / (TIME_SLIDE2 - TIME_HOLD2);
- float x = mHoldX;
- float y = mHoldY;
- float d = mOffset * fraction;
- switch (mAnimOrientation) {
- case 0:
- x = mHoldX + d;
- break;
- case 180:
- x = mHoldX - d;
- break;
- case 90:
- y = mHoldY - d;
- break;
- case 270:
- y = mHoldY + d;
- break;
- }
- preview.directDraw(canvas, (int) mX, (int) mY, mDrawWidth, mDrawHeight);
- mBorder.draw(canvas, (int) x - mShadowSize, (int) y - mShadowSize,
- (int) mHoldW + 2 * mShadowSize, (int) mHoldH + 2 * mShadowSize);
- review.draw(canvas, (int) x, (int) y, mHoldW, mHoldH);
- }
- return true;
- }
-
- private static float interpolate(float start, float end, float fraction) {
- return start + (end - start) * fraction;
- }
-
-}
diff --git a/src/com/android/camera/ComboPreferences.java b/src/com/android/camera/ComboPreferences.java
deleted file mode 100644
index e17e47a..0000000
--- a/src/com/android/camera/ComboPreferences.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera;
-
-import android.app.backup.BackupManager;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.preference.PreferenceManager;
-
-import com.android.gallery3d.util.UsageStatistics;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-public class ComboPreferences implements
- SharedPreferences,
- OnSharedPreferenceChangeListener {
- private SharedPreferences mPrefGlobal; // global preferences
- private SharedPreferences mPrefLocal; // per-camera preferences
- private String mPackageName;
- private CopyOnWriteArrayList<OnSharedPreferenceChangeListener> mListeners;
- // TODO: Remove this WeakHashMap in the camera code refactoring
- private static WeakHashMap<Context, ComboPreferences> sMap =
- new WeakHashMap<Context, ComboPreferences>();
-
- public ComboPreferences(Context context) {
- mPackageName = context.getPackageName();
- mPrefGlobal = context.getSharedPreferences(
- getGlobalSharedPreferencesName(context), Context.MODE_PRIVATE);
- mPrefGlobal.registerOnSharedPreferenceChangeListener(this);
-
- synchronized (sMap) {
- sMap.put(context, this);
- }
- mListeners = new CopyOnWriteArrayList<OnSharedPreferenceChangeListener>();
-
- // The global preferences was previously stored in the default
- // shared preferences file. They should be stored in the camera-specific
- // shared preferences file so we can backup them solely.
- SharedPreferences oldprefs =
- PreferenceManager.getDefaultSharedPreferences(context);
- if (!mPrefGlobal.contains(CameraSettings.KEY_VERSION)
- && oldprefs.contains(CameraSettings.KEY_VERSION)) {
- moveGlobalPrefsFrom(oldprefs);
- }
- }
-
- public static ComboPreferences get(Context context) {
- synchronized (sMap) {
- return sMap.get(context);
- }
- }
-
- private static String getLocalSharedPreferencesName(
- Context context, int cameraId) {
- return context.getPackageName() + "_preferences_" + cameraId;
- }
-
- private static String getGlobalSharedPreferencesName(Context context) {
- return context.getPackageName() + "_preferences_camera";
- }
-
- private void movePrefFrom(
- Map<String, ?> m, String key, SharedPreferences src) {
- if (m.containsKey(key)) {
- Object v = m.get(key);
- if (v instanceof String) {
- mPrefGlobal.edit().putString(key, (String) v).apply();
- } else if (v instanceof Integer) {
- mPrefGlobal.edit().putInt(key, (Integer) v).apply();
- } else if (v instanceof Long) {
- mPrefGlobal.edit().putLong(key, (Long) v).apply();
- } else if (v instanceof Float) {
- mPrefGlobal.edit().putFloat(key, (Float) v).apply();
- } else if (v instanceof Boolean) {
- mPrefGlobal.edit().putBoolean(key, (Boolean) v).apply();
- }
- src.edit().remove(key).apply();
- }
- }
-
- private void moveGlobalPrefsFrom(SharedPreferences src) {
- Map<String, ?> prefMap = src.getAll();
- movePrefFrom(prefMap, CameraSettings.KEY_VERSION, src);
- movePrefFrom(prefMap, CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL, src);
- movePrefFrom(prefMap, CameraSettings.KEY_CAMERA_ID, src);
- movePrefFrom(prefMap, CameraSettings.KEY_RECORD_LOCATION, src);
- movePrefFrom(prefMap, CameraSettings.KEY_CAMERA_FIRST_USE_HINT_SHOWN, src);
- movePrefFrom(prefMap, CameraSettings.KEY_VIDEO_FIRST_USE_HINT_SHOWN, src);
- movePrefFrom(prefMap, CameraSettings.KEY_VIDEO_EFFECT, src);
- }
-
- public static String[] getSharedPreferencesNames(Context context) {
- int numOfCameras = CameraHolder.instance().getNumberOfCameras();
- String prefNames[] = new String[numOfCameras + 1];
- prefNames[0] = getGlobalSharedPreferencesName(context);
- for (int i = 0; i < numOfCameras; i++) {
- prefNames[i + 1] = getLocalSharedPreferencesName(context, i);
- }
- return prefNames;
- }
-
- // Sets the camera id and reads its preferences. Each camera has its own
- // preferences.
- public void setLocalId(Context context, int cameraId) {
- String prefName = getLocalSharedPreferencesName(context, cameraId);
- if (mPrefLocal != null) {
- mPrefLocal.unregisterOnSharedPreferenceChangeListener(this);
- }
- mPrefLocal = context.getSharedPreferences(
- prefName, Context.MODE_PRIVATE);
- mPrefLocal.registerOnSharedPreferenceChangeListener(this);
- }
-
- public SharedPreferences getGlobal() {
- return mPrefGlobal;
- }
-
- public SharedPreferences getLocal() {
- return mPrefLocal;
- }
-
- @Override
- public Map<String, ?> getAll() {
- throw new UnsupportedOperationException(); // Can be implemented if needed.
- }
-
- private static boolean isGlobal(String key) {
- return key.equals(CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL)
- || key.equals(CameraSettings.KEY_CAMERA_ID)
- || key.equals(CameraSettings.KEY_RECORD_LOCATION)
- || key.equals(CameraSettings.KEY_CAMERA_FIRST_USE_HINT_SHOWN)
- || key.equals(CameraSettings.KEY_VIDEO_FIRST_USE_HINT_SHOWN)
- || key.equals(CameraSettings.KEY_VIDEO_EFFECT)
- || key.equals(CameraSettings.KEY_TIMER)
- || key.equals(CameraSettings.KEY_TIMER_SOUND_EFFECTS)
- || key.equals(CameraSettings.KEY_PHOTOSPHERE_PICTURESIZE);
- }
-
- @Override
- public String getString(String key, String defValue) {
- if (isGlobal(key) || !mPrefLocal.contains(key)) {
- return mPrefGlobal.getString(key, defValue);
- } else {
- return mPrefLocal.getString(key, defValue);
- }
- }
-
- @Override
- public int getInt(String key, int defValue) {
- if (isGlobal(key) || !mPrefLocal.contains(key)) {
- return mPrefGlobal.getInt(key, defValue);
- } else {
- return mPrefLocal.getInt(key, defValue);
- }
- }
-
- @Override
- public long getLong(String key, long defValue) {
- if (isGlobal(key) || !mPrefLocal.contains(key)) {
- return mPrefGlobal.getLong(key, defValue);
- } else {
- return mPrefLocal.getLong(key, defValue);
- }
- }
-
- @Override
- public float getFloat(String key, float defValue) {
- if (isGlobal(key) || !mPrefLocal.contains(key)) {
- return mPrefGlobal.getFloat(key, defValue);
- } else {
- return mPrefLocal.getFloat(key, defValue);
- }
- }
-
- @Override
- public boolean getBoolean(String key, boolean defValue) {
- if (isGlobal(key) || !mPrefLocal.contains(key)) {
- return mPrefGlobal.getBoolean(key, defValue);
- } else {
- return mPrefLocal.getBoolean(key, defValue);
- }
- }
-
- // This method is not used.
- @Override
- public Set<String> getStringSet(String key, Set<String> defValues) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean contains(String key) {
- return mPrefLocal.contains(key) || mPrefGlobal.contains(key);
- }
-
- private class MyEditor implements Editor {
- private Editor mEditorGlobal;
- private Editor mEditorLocal;
-
- MyEditor() {
- mEditorGlobal = mPrefGlobal.edit();
- mEditorLocal = mPrefLocal.edit();
- }
-
- @Override
- public boolean commit() {
- boolean result1 = mEditorGlobal.commit();
- boolean result2 = mEditorLocal.commit();
- return result1 && result2;
- }
-
- @Override
- public void apply() {
- mEditorGlobal.apply();
- mEditorLocal.apply();
- }
-
- // Note: clear() and remove() affects both local and global preferences.
- @Override
- public Editor clear() {
- mEditorGlobal.clear();
- mEditorLocal.clear();
- return this;
- }
-
- @Override
- public Editor remove(String key) {
- mEditorGlobal.remove(key);
- mEditorLocal.remove(key);
- return this;
- }
-
- @Override
- public Editor putString(String key, String value) {
- if (isGlobal(key)) {
- mEditorGlobal.putString(key, value);
- } else {
- mEditorLocal.putString(key, value);
- }
- return this;
- }
-
- @Override
- public Editor putInt(String key, int value) {
- if (isGlobal(key)) {
- mEditorGlobal.putInt(key, value);
- } else {
- mEditorLocal.putInt(key, value);
- }
- return this;
- }
-
- @Override
- public Editor putLong(String key, long value) {
- if (isGlobal(key)) {
- mEditorGlobal.putLong(key, value);
- } else {
- mEditorLocal.putLong(key, value);
- }
- return this;
- }
-
- @Override
- public Editor putFloat(String key, float value) {
- if (isGlobal(key)) {
- mEditorGlobal.putFloat(key, value);
- } else {
- mEditorLocal.putFloat(key, value);
- }
- return this;
- }
-
- @Override
- public Editor putBoolean(String key, boolean value) {
- if (isGlobal(key)) {
- mEditorGlobal.putBoolean(key, value);
- } else {
- mEditorLocal.putBoolean(key, value);
- }
- return this;
- }
-
- // This method is not used.
- @Override
- public Editor putStringSet(String key, Set<String> values) {
- throw new UnsupportedOperationException();
- }
- }
-
- // Note the remove() and clear() of the returned Editor may not work as
- // expected because it doesn't touch the global preferences at all.
- @Override
- public Editor edit() {
- return new MyEditor();
- }
-
- @Override
- public void registerOnSharedPreferenceChangeListener(
- OnSharedPreferenceChangeListener listener) {
- mListeners.add(listener);
- }
-
- @Override
- public void unregisterOnSharedPreferenceChangeListener(
- OnSharedPreferenceChangeListener listener) {
- mListeners.remove(listener);
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
- String key) {
- for (OnSharedPreferenceChangeListener listener : mListeners) {
- listener.onSharedPreferenceChanged(this, key);
- }
- BackupManager.dataChanged(mPackageName);
- UsageStatistics.onEvent("CameraSettingsChange", null, key);
- }
-}
diff --git a/src/com/android/camera/CountDownTimerPreference.java b/src/com/android/camera/CountDownTimerPreference.java
deleted file mode 100644
index 9c66dda..0000000
--- a/src/com/android/camera/CountDownTimerPreference.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.camera;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.android.gallery3d.R;
-
-public class CountDownTimerPreference extends ListPreference {
- private static final int[] DURATIONS = {
- 0, 1, 2, 3, 4, 5, 10, 15, 20, 30, 60
- };
- public CountDownTimerPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- initCountDownDurationChoices(context);
- }
-
- private void initCountDownDurationChoices(Context context) {
- CharSequence[] entryValues = new CharSequence[DURATIONS.length];
- CharSequence[] entries = new CharSequence[DURATIONS.length];
- for (int i = 0; i < DURATIONS.length; i++) {
- entryValues[i] = Integer.toString(DURATIONS[i]);
- if (i == 0) {
- entries[0] = context.getString(R.string.setting_off); // Off
- } else {
- entries[i] = context.getResources()
- .getQuantityString(R.plurals.pref_camera_timer_entry, i, i);
- }
- }
- setEntries(entries);
- setEntryValues(entryValues);
- }
-}
diff --git a/src/com/android/camera/DisableCameraReceiver.java b/src/com/android/camera/DisableCameraReceiver.java
index 3517405..d51d6b9 100644
--- a/src/com/android/camera/DisableCameraReceiver.java
+++ b/src/com/android/camera/DisableCameraReceiver.java
@@ -28,7 +28,7 @@
// receiver runs when BOOT_COMPLETED intent is received. After running once
// this receiver will be disabled, so it will not run again.
public class DisableCameraReceiver extends BroadcastReceiver {
- private static final String TAG = "DisableCameraReceiver";
+ private static final String TAG = "G:DisableCameraReceiver";
private static final boolean CHECK_BACK_CAMERA_ONLY = true;
private static final String ACTIVITIES[] = {
"com.android.camera.CameraLauncher",
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
deleted file mode 100644
index 2db44c7..0000000
--- a/src/com/android/camera/EffectsRecorder.java
+++ /dev/null
@@ -1,1240 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera;
-import android.media.CamcorderProfile;
-import android.media.MediaRecorder;
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Log;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-
-/**
- * Encapsulates the mobile filter framework components needed to record video
- * with effects applied. Modeled after MediaRecorder.
- */
-@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) // uses SurfaceTexture
-public class EffectsRecorder {
- private static final String TAG = "EffectsRecorder";
-
- private static Class<?> sClassFilter;
- private static Method sFilterIsAvailable;
- private static EffectsRecorder sEffectsRecorder;
- // The index of the current effects recorder.
- private static int sEffectsRecorderIndex;
-
- private static boolean sReflectionInited = false;
-
- private static Class<?> sClsLearningDoneListener;
- private static Class<?> sClsOnRunnerDoneListener;
- private static Class<?> sClsOnRecordingDoneListener;
- private static Class<?> sClsSurfaceTextureSourceListener;
-
- private static Method sFilterSetInputValue;
-
- private static Constructor<?> sCtPoint;
- private static Constructor<?> sCtQuad;
-
- private static Method sLearningDoneListenerOnLearningDone;
-
- private static Method sObjectEquals;
- private static Method sObjectToString;
-
- private static Class<?> sClsGraphRunner;
- private static Method sGraphRunnerGetGraph;
- private static Method sGraphRunnerSetDoneCallback;
- private static Method sGraphRunnerRun;
- private static Method sGraphRunnerGetError;
- private static Method sGraphRunnerStop;
-
- private static Method sFilterGraphGetFilter;
- private static Method sFilterGraphTearDown;
-
- private static Method sOnRunnerDoneListenerOnRunnerDone;
-
- private static Class<?> sClsGraphEnvironment;
- private static Constructor<?> sCtGraphEnvironment;
- private static Method sGraphEnvironmentCreateGLEnvironment;
- private static Method sGraphEnvironmentGetRunner;
- private static Method sGraphEnvironmentAddReferences;
- private static Method sGraphEnvironmentLoadGraph;
- private static Method sGraphEnvironmentGetContext;
-
- private static Method sFilterContextGetGLEnvironment;
- private static Method sGLEnvironmentIsActive;
- private static Method sGLEnvironmentActivate;
- private static Method sGLEnvironmentDeactivate;
- private static Method sSurfaceTextureTargetDisconnect;
- private static Method sOnRecordingDoneListenerOnRecordingDone;
- private static Method sSurfaceTextureSourceListenerOnSurfaceTextureSourceReady;
-
- private Object mLearningDoneListener;
- private Object mRunnerDoneCallback;
- private Object mSourceReadyCallback;
- // A callback to finalize the media after the recording is done.
- private Object mRecordingDoneListener;
-
- static {
- try {
- sClassFilter = Class.forName("android.filterfw.core.Filter");
- sFilterIsAvailable = sClassFilter.getMethod("isAvailable",
- String.class);
- } catch (ClassNotFoundException ex) {
- Log.v(TAG, "Can't find the class android.filterfw.core.Filter");
- } catch (NoSuchMethodException e) {
- Log.v(TAG, "Can't find the method Filter.isAvailable");
- }
- }
-
- public static final int EFFECT_NONE = 0;
- public static final int EFFECT_GOOFY_FACE = 1;
- public static final int EFFECT_BACKDROPPER = 2;
-
- public static final int EFFECT_GF_SQUEEZE = 0;
- public static final int EFFECT_GF_BIG_EYES = 1;
- public static final int EFFECT_GF_BIG_MOUTH = 2;
- public static final int EFFECT_GF_SMALL_MOUTH = 3;
- public static final int EFFECT_GF_BIG_NOSE = 4;
- public static final int EFFECT_GF_SMALL_EYES = 5;
- public static final int NUM_OF_GF_EFFECTS = EFFECT_GF_SMALL_EYES + 1;
-
- public static final int EFFECT_MSG_STARTED_LEARNING = 0;
- public static final int EFFECT_MSG_DONE_LEARNING = 1;
- public static final int EFFECT_MSG_SWITCHING_EFFECT = 2;
- public static final int EFFECT_MSG_EFFECTS_STOPPED = 3;
- public static final int EFFECT_MSG_RECORDING_DONE = 4;
- public static final int EFFECT_MSG_PREVIEW_RUNNING = 5;
-
- private Context mContext;
- private Handler mHandler;
-
- private CameraManager.CameraProxy mCameraDevice;
- private CamcorderProfile mProfile;
- private double mCaptureRate = 0;
- private SurfaceTexture mPreviewSurfaceTexture;
- private int mPreviewWidth;
- private int mPreviewHeight;
- private MediaRecorder.OnInfoListener mInfoListener;
- private MediaRecorder.OnErrorListener mErrorListener;
-
- private String mOutputFile;
- private FileDescriptor mFd;
- private int mOrientationHint = 0;
- private long mMaxFileSize = 0;
- private int mMaxDurationMs = 0;
- private int mCameraFacing = Camera.CameraInfo.CAMERA_FACING_BACK;
- private int mCameraDisplayOrientation;
-
- private int mEffect = EFFECT_NONE;
- private int mCurrentEffect = EFFECT_NONE;
- private EffectsListener mEffectsListener;
-
- private Object mEffectParameter;
-
- private Object mGraphEnv;
- private int mGraphId;
- private Object mRunner = null;
- private Object mOldRunner = null;
-
- private SurfaceTexture mTextureSource;
-
- private static final int STATE_CONFIGURE = 0;
- private static final int STATE_WAITING_FOR_SURFACE = 1;
- private static final int STATE_STARTING_PREVIEW = 2;
- private static final int STATE_PREVIEW = 3;
- private static final int STATE_RECORD = 4;
- private static final int STATE_RELEASED = 5;
- private int mState = STATE_CONFIGURE;
-
- private boolean mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- private SoundClips.Player mSoundPlayer;
-
- /** Determine if a given effect is supported at runtime
- * Some effects require libraries not available on all devices
- */
- public static boolean isEffectSupported(int effectId) {
- if (sFilterIsAvailable == null) return false;
-
- try {
- switch (effectId) {
- case EFFECT_GOOFY_FACE:
- return (Boolean) sFilterIsAvailable.invoke(null,
- "com.google.android.filterpacks.facedetect.GoofyRenderFilter");
- case EFFECT_BACKDROPPER:
- return (Boolean) sFilterIsAvailable.invoke(null,
- "android.filterpacks.videoproc.BackDropperFilter");
- default:
- return false;
- }
- } catch (Exception ex) {
- Log.e(TAG, "Fail to check filter", ex);
- }
- return false;
- }
-
- public EffectsRecorder(Context context) {
- if (mLogVerbose) Log.v(TAG, "EffectsRecorder created (" + this + ")");
-
- if (!sReflectionInited) {
- try {
- sFilterSetInputValue = sClassFilter.getMethod("setInputValue",
- new Class[] {String.class, Object.class});
-
- Class<?> clsPoint = Class.forName("android.filterfw.geometry.Point");
- sCtPoint = clsPoint.getConstructor(new Class[] {float.class,
- float.class});
-
- Class<?> clsQuad = Class.forName("android.filterfw.geometry.Quad");
- sCtQuad = clsQuad.getConstructor(new Class[] {clsPoint, clsPoint,
- clsPoint, clsPoint});
-
- Class<?> clsBackDropperFilter = Class.forName(
- "android.filterpacks.videoproc.BackDropperFilter");
- sClsLearningDoneListener = Class.forName(
- "android.filterpacks.videoproc.BackDropperFilter$LearningDoneListener");
- sLearningDoneListenerOnLearningDone = sClsLearningDoneListener
- .getMethod("onLearningDone", new Class[] {clsBackDropperFilter});
-
- sObjectEquals = Object.class.getMethod("equals", new Class[] {Object.class});
- sObjectToString = Object.class.getMethod("toString");
-
- sClsOnRunnerDoneListener = Class.forName(
- "android.filterfw.core.GraphRunner$OnRunnerDoneListener");
- sOnRunnerDoneListenerOnRunnerDone = sClsOnRunnerDoneListener.getMethod(
- "onRunnerDone", new Class[] {int.class});
-
- sClsGraphRunner = Class.forName("android.filterfw.core.GraphRunner");
- sGraphRunnerGetGraph = sClsGraphRunner.getMethod("getGraph");
- sGraphRunnerSetDoneCallback = sClsGraphRunner.getMethod(
- "setDoneCallback", new Class[] {sClsOnRunnerDoneListener});
- sGraphRunnerRun = sClsGraphRunner.getMethod("run");
- sGraphRunnerGetError = sClsGraphRunner.getMethod("getError");
- sGraphRunnerStop = sClsGraphRunner.getMethod("stop");
-
- Class<?> clsFilterContext = Class.forName("android.filterfw.core.FilterContext");
- sFilterContextGetGLEnvironment = clsFilterContext.getMethod(
- "getGLEnvironment");
-
- Class<?> clsFilterGraph = Class.forName("android.filterfw.core.FilterGraph");
- sFilterGraphGetFilter = clsFilterGraph.getMethod("getFilter",
- new Class[] {String.class});
- sFilterGraphTearDown = clsFilterGraph.getMethod("tearDown",
- new Class[] {clsFilterContext});
-
- sClsGraphEnvironment = Class.forName("android.filterfw.GraphEnvironment");
- sCtGraphEnvironment = sClsGraphEnvironment.getConstructor();
- sGraphEnvironmentCreateGLEnvironment = sClsGraphEnvironment.getMethod(
- "createGLEnvironment");
- sGraphEnvironmentGetRunner = sClsGraphEnvironment.getMethod(
- "getRunner", new Class[] {int.class, int.class});
- sGraphEnvironmentAddReferences = sClsGraphEnvironment.getMethod(
- "addReferences", new Class[] {Object[].class});
- sGraphEnvironmentLoadGraph = sClsGraphEnvironment.getMethod(
- "loadGraph", new Class[] {Context.class, int.class});
- sGraphEnvironmentGetContext = sClsGraphEnvironment.getMethod(
- "getContext");
-
- Class<?> clsGLEnvironment = Class.forName("android.filterfw.core.GLEnvironment");
- sGLEnvironmentIsActive = clsGLEnvironment.getMethod("isActive");
- sGLEnvironmentActivate = clsGLEnvironment.getMethod("activate");
- sGLEnvironmentDeactivate = clsGLEnvironment.getMethod("deactivate");
-
- Class<?> clsSurfaceTextureTarget = Class.forName(
- "android.filterpacks.videosrc.SurfaceTextureTarget");
- sSurfaceTextureTargetDisconnect = clsSurfaceTextureTarget.getMethod(
- "disconnect", new Class[] {clsFilterContext});
-
- sClsOnRecordingDoneListener = Class.forName(
- "android.filterpacks.videosink.MediaEncoderFilter$OnRecordingDoneListener");
- sOnRecordingDoneListenerOnRecordingDone =
- sClsOnRecordingDoneListener.getMethod("onRecordingDone");
-
- sClsSurfaceTextureSourceListener = Class.forName(
- "android.filterpacks.videosrc.SurfaceTextureSource$SurfaceTextureSourceListener");
- sSurfaceTextureSourceListenerOnSurfaceTextureSourceReady =
- sClsSurfaceTextureSourceListener.getMethod(
- "onSurfaceTextureSourceReady",
- new Class[] {SurfaceTexture.class});
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
-
- sReflectionInited = true;
- }
-
- sEffectsRecorderIndex++;
- Log.v(TAG, "Current effects recorder index is " + sEffectsRecorderIndex);
- sEffectsRecorder = this;
- SerializableInvocationHandler sih = new SerializableInvocationHandler(
- sEffectsRecorderIndex);
- mLearningDoneListener = Proxy.newProxyInstance(
- sClsLearningDoneListener.getClassLoader(),
- new Class[] {sClsLearningDoneListener}, sih);
- mRunnerDoneCallback = Proxy.newProxyInstance(
- sClsOnRunnerDoneListener.getClassLoader(),
- new Class[] {sClsOnRunnerDoneListener}, sih);
- mSourceReadyCallback = Proxy.newProxyInstance(
- sClsSurfaceTextureSourceListener.getClassLoader(),
- new Class[] {sClsSurfaceTextureSourceListener}, sih);
- mRecordingDoneListener = Proxy.newProxyInstance(
- sClsOnRecordingDoneListener.getClassLoader(),
- new Class[] {sClsOnRecordingDoneListener}, sih);
-
- mContext = context;
- mHandler = new Handler(Looper.getMainLooper());
- mSoundPlayer = SoundClips.getPlayer(context);
- }
-
- public synchronized void setCamera(CameraManager.CameraProxy cameraDevice) {
- switch (mState) {
- case STATE_PREVIEW:
- throw new RuntimeException("setCamera cannot be called while previewing!");
- case STATE_RECORD:
- throw new RuntimeException("setCamera cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException("setCamera called on an already released recorder!");
- default:
- break;
- }
-
- mCameraDevice = cameraDevice;
- }
-
- public void setProfile(CamcorderProfile profile) {
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setProfile cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException("setProfile called on an already released recorder!");
- default:
- break;
- }
- mProfile = profile;
- }
-
- public void setOutputFile(String outputFile) {
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setOutputFile cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException("setOutputFile called on an already released recorder!");
- default:
- break;
- }
-
- mOutputFile = outputFile;
- mFd = null;
- }
-
- public void setOutputFile(FileDescriptor fd) {
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setOutputFile cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException("setOutputFile called on an already released recorder!");
- default:
- break;
- }
-
- mOutputFile = null;
- mFd = fd;
- }
-
- /**
- * Sets the maximum filesize (in bytes) of the recording session.
- * This will be passed on to the MediaEncoderFilter and then to the
- * MediaRecorder ultimately. If zero or negative, the MediaRecorder will
- * disable the limit
- */
- public synchronized void setMaxFileSize(long maxFileSize) {
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setMaxFileSize cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException(
- "setMaxFileSize called on an already released recorder!");
- default:
- break;
- }
- mMaxFileSize = maxFileSize;
- }
-
- /**
- * Sets the maximum recording duration (in ms) for the next recording session
- * Setting it to zero (the default) disables the limit.
- */
- public synchronized void setMaxDuration(int maxDurationMs) {
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setMaxDuration cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException(
- "setMaxDuration called on an already released recorder!");
- default:
- break;
- }
- mMaxDurationMs = maxDurationMs;
- }
-
-
- public void setCaptureRate(double fps) {
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setCaptureRate cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException(
- "setCaptureRate called on an already released recorder!");
- default:
- break;
- }
-
- if (mLogVerbose) Log.v(TAG, "Setting time lapse capture rate to " + fps + " fps");
- mCaptureRate = fps;
- }
-
- public void setPreviewSurfaceTexture(SurfaceTexture previewSurfaceTexture,
- int previewWidth,
- int previewHeight) {
- if (mLogVerbose) Log.v(TAG, "setPreviewSurfaceTexture(" + this + ")");
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException(
- "setPreviewSurfaceTexture cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException(
- "setPreviewSurfaceTexture called on an already released recorder!");
- default:
- break;
- }
-
- mPreviewSurfaceTexture = previewSurfaceTexture;
- mPreviewWidth = previewWidth;
- mPreviewHeight = previewHeight;
-
- switch (mState) {
- case STATE_WAITING_FOR_SURFACE:
- startPreview();
- break;
- case STATE_STARTING_PREVIEW:
- case STATE_PREVIEW:
- initializeEffect(true);
- break;
- }
- }
-
- public void setEffect(int effect, Object effectParameter) {
- if (mLogVerbose) Log.v(TAG,
- "setEffect: effect ID " + effect +
- ", parameter " + effectParameter.toString());
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setEffect cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException("setEffect called on an already released recorder!");
- default:
- break;
- }
-
- mEffect = effect;
- mEffectParameter = effectParameter;
-
- if (mState == STATE_PREVIEW ||
- mState == STATE_STARTING_PREVIEW) {
- initializeEffect(false);
- }
- }
-
- public interface EffectsListener {
- public void onEffectsUpdate(int effectId, int effectMsg);
- public void onEffectsError(Exception exception, String filePath);
- }
-
- public void setEffectsListener(EffectsListener listener) {
- mEffectsListener = listener;
- }
-
- private void setFaceDetectOrientation() {
- if (mCurrentEffect == EFFECT_GOOFY_FACE) {
- Object rotateFilter = getGraphFilter(mRunner, "rotate");
- Object metaRotateFilter = getGraphFilter(mRunner, "metarotate");
- setInputValue(rotateFilter, "rotation", mOrientationHint);
- int reverseDegrees = (360 - mOrientationHint) % 360;
- setInputValue(metaRotateFilter, "rotation", reverseDegrees);
- }
- }
-
- private void setRecordingOrientation() {
- if (mState != STATE_RECORD && mRunner != null) {
- Object bl = newInstance(sCtPoint, new Object[] {0, 0});
- Object br = newInstance(sCtPoint, new Object[] {1, 0});
- Object tl = newInstance(sCtPoint, new Object[] {0, 1});
- Object tr = newInstance(sCtPoint, new Object[] {1, 1});
- Object recordingRegion;
- if (mCameraFacing == Camera.CameraInfo.CAMERA_FACING_BACK) {
- // The back camera is not mirrored, so use a identity transform
- recordingRegion = newInstance(sCtQuad, new Object[] {bl, br, tl, tr});
- } else {
- // Recording region needs to be tweaked for front cameras, since they
- // mirror their preview
- if (mOrientationHint == 0 || mOrientationHint == 180) {
- // Horizontal flip in landscape
- recordingRegion = newInstance(sCtQuad, new Object[] {br, bl, tr, tl});
- } else {
- // Horizontal flip in portrait
- recordingRegion = newInstance(sCtQuad, new Object[] {tl, tr, bl, br});
- }
- }
- Object recorder = getGraphFilter(mRunner, "recorder");
- setInputValue(recorder, "inputRegion", recordingRegion);
- }
- }
- public void setOrientationHint(int degrees) {
- switch (mState) {
- case STATE_RELEASED:
- throw new RuntimeException(
- "setOrientationHint called on an already released recorder!");
- default:
- break;
- }
- if (mLogVerbose) Log.v(TAG, "Setting orientation hint to: " + degrees);
- mOrientationHint = degrees;
- setFaceDetectOrientation();
- setRecordingOrientation();
- }
-
- public void setCameraDisplayOrientation(int orientation) {
- if (mState != STATE_CONFIGURE) {
- throw new RuntimeException(
- "setCameraDisplayOrientation called after configuration!");
- }
- mCameraDisplayOrientation = orientation;
- }
-
- public void setCameraFacing(int facing) {
- switch (mState) {
- case STATE_RELEASED:
- throw new RuntimeException(
- "setCameraFacing called on alrady released recorder!");
- default:
- break;
- }
- mCameraFacing = facing;
- setRecordingOrientation();
- }
-
- public void setOnInfoListener(MediaRecorder.OnInfoListener infoListener) {
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setInfoListener cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException(
- "setInfoListener called on an already released recorder!");
- default:
- break;
- }
- mInfoListener = infoListener;
- }
-
- public void setOnErrorListener(MediaRecorder.OnErrorListener errorListener) {
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("setErrorListener cannot be called while recording!");
- case STATE_RELEASED:
- throw new RuntimeException(
- "setErrorListener called on an already released recorder!");
- default:
- break;
- }
- mErrorListener = errorListener;
- }
-
- private void initializeFilterFramework() {
- mGraphEnv = newInstance(sCtGraphEnvironment);
- invoke(mGraphEnv, sGraphEnvironmentCreateGLEnvironment);
-
- int videoFrameWidth = mProfile.videoFrameWidth;
- int videoFrameHeight = mProfile.videoFrameHeight;
- if (mCameraDisplayOrientation == 90 || mCameraDisplayOrientation == 270) {
- int tmp = videoFrameWidth;
- videoFrameWidth = videoFrameHeight;
- videoFrameHeight = tmp;
- }
-
- invoke(mGraphEnv, sGraphEnvironmentAddReferences,
- new Object[] {new Object[] {
- "textureSourceCallback", mSourceReadyCallback,
- "recordingWidth", videoFrameWidth,
- "recordingHeight", videoFrameHeight,
- "recordingProfile", mProfile,
- "learningDoneListener", mLearningDoneListener,
- "recordingDoneListener", mRecordingDoneListener}});
- mRunner = null;
- mGraphId = -1;
- mCurrentEffect = EFFECT_NONE;
- }
-
- private synchronized void initializeEffect(boolean forceReset) {
- if (forceReset ||
- mCurrentEffect != mEffect ||
- mCurrentEffect == EFFECT_BACKDROPPER) {
-
- invoke(mGraphEnv, sGraphEnvironmentAddReferences,
- new Object[] {new Object[] {
- "previewSurfaceTexture", mPreviewSurfaceTexture,
- "previewWidth", mPreviewWidth,
- "previewHeight", mPreviewHeight,
- "orientation", mOrientationHint}});
- if (mState == STATE_PREVIEW ||
- mState == STATE_STARTING_PREVIEW) {
- // Switching effects while running. Inform video camera.
- sendMessage(mCurrentEffect, EFFECT_MSG_SWITCHING_EFFECT);
- }
-
- switch (mEffect) {
- case EFFECT_GOOFY_FACE:
- mGraphId = (Integer) invoke(mGraphEnv,
- sGraphEnvironmentLoadGraph,
- new Object[] {mContext, R.raw.goofy_face});
- break;
- case EFFECT_BACKDROPPER:
- sendMessage(EFFECT_BACKDROPPER, EFFECT_MSG_STARTED_LEARNING);
- mGraphId = (Integer) invoke(mGraphEnv,
- sGraphEnvironmentLoadGraph,
- new Object[] {mContext, R.raw.backdropper});
- break;
- default:
- throw new RuntimeException("Unknown effect ID" + mEffect + "!");
- }
- mCurrentEffect = mEffect;
-
- mOldRunner = mRunner;
- mRunner = invoke(mGraphEnv, sGraphEnvironmentGetRunner,
- new Object[] {mGraphId,
- getConstant(sClsGraphEnvironment, "MODE_ASYNCHRONOUS")});
- invoke(mRunner, sGraphRunnerSetDoneCallback, new Object[] {mRunnerDoneCallback});
- if (mLogVerbose) {
- Log.v(TAG, "New runner: " + mRunner
- + ". Old runner: " + mOldRunner);
- }
- if (mState == STATE_PREVIEW ||
- mState == STATE_STARTING_PREVIEW) {
- // Switching effects while running. Stop existing runner.
- // The stop callback will take care of starting new runner.
- mCameraDevice.stopPreview();
- mCameraDevice.setPreviewTextureAsync(null);
- invoke(mOldRunner, sGraphRunnerStop);
- }
- }
-
- switch (mCurrentEffect) {
- case EFFECT_GOOFY_FACE:
- tryEnableVideoStabilization(true);
- Object goofyFilter = getGraphFilter(mRunner, "goofyrenderer");
- setInputValue(goofyFilter, "currentEffect",
- ((Integer) mEffectParameter).intValue());
- break;
- case EFFECT_BACKDROPPER:
- tryEnableVideoStabilization(false);
- Object backgroundSrc = getGraphFilter(mRunner, "background");
- if (ApiHelper.HAS_EFFECTS_RECORDING_CONTEXT_INPUT) {
- // Set the context first before setting sourceUrl to
- // guarantee the content URI get resolved properly.
- setInputValue(backgroundSrc, "context", mContext);
- }
- setInputValue(backgroundSrc, "sourceUrl", mEffectParameter);
- // For front camera, the background video needs to be mirrored in the
- // backdropper filter
- if (mCameraFacing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
- Object replacer = getGraphFilter(mRunner, "replacer");
- setInputValue(replacer, "mirrorBg", true);
- if (mLogVerbose) Log.v(TAG, "Setting the background to be mirrored");
- }
- break;
- default:
- break;
- }
- setFaceDetectOrientation();
- setRecordingOrientation();
- }
-
- public synchronized void startPreview() {
- if (mLogVerbose) Log.v(TAG, "Starting preview (" + this + ")");
-
- switch (mState) {
- case STATE_STARTING_PREVIEW:
- case STATE_PREVIEW:
- // Already running preview
- Log.w(TAG, "startPreview called when already running preview");
- return;
- case STATE_RECORD:
- throw new RuntimeException("Cannot start preview when already recording!");
- case STATE_RELEASED:
- throw new RuntimeException("setEffect called on an already released recorder!");
- default:
- break;
- }
-
- if (mEffect == EFFECT_NONE) {
- throw new RuntimeException("No effect selected!");
- }
- if (mEffectParameter == null) {
- throw new RuntimeException("No effect parameter provided!");
- }
- if (mProfile == null) {
- throw new RuntimeException("No recording profile provided!");
- }
- if (mPreviewSurfaceTexture == null) {
- if (mLogVerbose) Log.v(TAG, "Passed a null surface; waiting for valid one");
- mState = STATE_WAITING_FOR_SURFACE;
- return;
- }
- if (mCameraDevice == null) {
- throw new RuntimeException("No camera to record from!");
- }
-
- if (mLogVerbose) Log.v(TAG, "Initializing filter framework and running the graph.");
- initializeFilterFramework();
-
- initializeEffect(true);
-
- mState = STATE_STARTING_PREVIEW;
- invoke(mRunner, sGraphRunnerRun);
- // Rest of preview startup handled in mSourceReadyCallback
- }
-
- private Object invokeObjectEquals(Object proxy, Object[] args) {
- return Boolean.valueOf(proxy == args[0]);
- }
-
- private Object invokeObjectToString() {
- return "Proxy-" + toString();
- }
-
- private void invokeOnLearningDone() {
- if (mLogVerbose) Log.v(TAG, "Learning done callback triggered");
- // Called in a processing thread, so have to post message back to UI
- // thread
- sendMessage(EFFECT_BACKDROPPER, EFFECT_MSG_DONE_LEARNING);
- enable3ALocks(true);
- }
-
- private void invokeOnRunnerDone(Object[] args) {
- int runnerDoneResult = (Integer) args[0];
- synchronized (EffectsRecorder.this) {
- if (mLogVerbose) {
- Log.v(TAG,
- "Graph runner done (" + EffectsRecorder.this
- + ", mRunner " + mRunner
- + ", mOldRunner " + mOldRunner + ")");
- }
- if (runnerDoneResult ==
- (Integer) getConstant(sClsGraphRunner, "RESULT_ERROR")) {
- // Handle error case
- Log.e(TAG, "Error running filter graph!");
- Exception e = null;
- if (mRunner != null) {
- e = (Exception) invoke(mRunner, sGraphRunnerGetError);
- } else if (mOldRunner != null) {
- e = (Exception) invoke(mOldRunner, sGraphRunnerGetError);
- }
- raiseError(e);
- }
- if (mOldRunner != null) {
- // Tear down old graph if available
- if (mLogVerbose) Log.v(TAG, "Tearing down old graph.");
- Object glEnv = getContextGLEnvironment(mGraphEnv);
- if (glEnv != null && !(Boolean) invoke(glEnv, sGLEnvironmentIsActive)) {
- invoke(glEnv, sGLEnvironmentActivate);
- }
- getGraphTearDown(mOldRunner,
- invoke(mGraphEnv, sGraphEnvironmentGetContext));
- if (glEnv != null && (Boolean) invoke(glEnv, sGLEnvironmentIsActive)) {
- invoke(glEnv, sGLEnvironmentDeactivate);
- }
- mOldRunner = null;
- }
- if (mState == STATE_PREVIEW ||
- mState == STATE_STARTING_PREVIEW) {
- // Switching effects, start up the new runner
- if (mLogVerbose) {
- Log.v(TAG, "Previous effect halted. Running graph again. state: "
- + mState);
- }
- tryEnable3ALocks(false);
- // In case of an error, the graph restarts from beginning and in case
- // of the BACKDROPPER effect, the learner re-learns the background.
- // Hence, we need to show the learning dialogue to the user
- // to avoid recording before the learning is done. Else, the user
- // could start recording before the learning is done and the new
- // background comes up later leading to an end result video
- // with a heterogeneous background.
- // For BACKDROPPER effect, this path is also executed sometimes at
- // the end of a normal recording session. In such a case, the graph
- // does not restart and hence the learner does not re-learn. So we
- // do not want to show the learning dialogue then.
- if (runnerDoneResult == (Integer) getConstant(
- sClsGraphRunner, "RESULT_ERROR")
- && mCurrentEffect == EFFECT_BACKDROPPER) {
- sendMessage(EFFECT_BACKDROPPER, EFFECT_MSG_STARTED_LEARNING);
- }
- invoke(mRunner, sGraphRunnerRun);
- } else if (mState != STATE_RELEASED) {
- // Shutting down effects
- if (mLogVerbose) Log.v(TAG, "Runner halted, restoring direct preview");
- tryEnable3ALocks(false);
- sendMessage(EFFECT_NONE, EFFECT_MSG_EFFECTS_STOPPED);
- } else {
- // STATE_RELEASED - camera will be/has been released as well, do nothing.
- }
- }
- }
-
- private void invokeOnSurfaceTextureSourceReady(Object[] args) {
- SurfaceTexture source = (SurfaceTexture) args[0];
- if (mLogVerbose) Log.v(TAG, "SurfaceTexture ready callback received");
- synchronized (EffectsRecorder.this) {
- mTextureSource = source;
-
- if (mState == STATE_CONFIGURE) {
- // Stop preview happened while the runner was doing startup tasks
- // Since we haven't started anything up, don't do anything
- // Rest of cleanup will happen in onRunnerDone
- if (mLogVerbose) Log.v(TAG, "Ready callback: Already stopped, skipping.");
- return;
- }
- if (mState == STATE_RELEASED) {
- // EffectsRecorder has been released, so don't touch the camera device
- // or anything else
- if (mLogVerbose) Log.v(TAG, "Ready callback: Already released, skipping.");
- return;
- }
- if (source == null) {
- if (mLogVerbose) {
- Log.v(TAG, "Ready callback: source null! Looks like graph was closed!");
- }
- if (mState == STATE_PREVIEW ||
- mState == STATE_STARTING_PREVIEW ||
- mState == STATE_RECORD) {
- // A null source here means the graph is shutting down
- // unexpectedly, so we need to turn off preview before
- // the surface texture goes away.
- if (mLogVerbose) {
- Log.v(TAG, "Ready callback: State: " + mState
- + ". stopCameraPreview");
- }
-
- stopCameraPreview();
- }
- return;
- }
-
- // Lock AE/AWB to reduce transition flicker
- tryEnable3ALocks(true);
-
- mCameraDevice.stopPreview();
- if (mLogVerbose) Log.v(TAG, "Runner active, connecting effects preview");
- mCameraDevice.setPreviewTextureAsync(mTextureSource);
-
- mCameraDevice.startPreviewAsync();
-
- // Unlock AE/AWB after preview started
- tryEnable3ALocks(false);
-
- mState = STATE_PREVIEW;
-
- if (mLogVerbose) Log.v(TAG, "Start preview/effect switch complete");
-
- // Sending a message to listener that preview is complete
- sendMessage(mCurrentEffect, EFFECT_MSG_PREVIEW_RUNNING);
- }
- }
-
- private void invokeOnRecordingDone() {
- // Forward the callback to the VideoModule object (as an asynchronous event).
- if (mLogVerbose) Log.v(TAG, "Recording done callback triggered");
- sendMessage(EFFECT_NONE, EFFECT_MSG_RECORDING_DONE);
- }
-
- public synchronized void startRecording() {
- if (mLogVerbose) Log.v(TAG, "Starting recording (" + this + ")");
-
- switch (mState) {
- case STATE_RECORD:
- throw new RuntimeException("Already recording, cannot begin anew!");
- case STATE_RELEASED:
- throw new RuntimeException(
- "startRecording called on an already released recorder!");
- default:
- break;
- }
-
- if ((mOutputFile == null) && (mFd == null)) {
- throw new RuntimeException("No output file name or descriptor provided!");
- }
-
- if (mState == STATE_CONFIGURE) {
- startPreview();
- }
-
- Object recorder = getGraphFilter(mRunner, "recorder");
- if (mFd != null) {
- setInputValue(recorder, "outputFileDescriptor", mFd);
- } else {
- setInputValue(recorder, "outputFile", mOutputFile);
- }
- // It is ok to set the audiosource without checking for timelapse here
- // since that check will be done in the MediaEncoderFilter itself
- setInputValue(recorder, "audioSource", MediaRecorder.AudioSource.CAMCORDER);
- setInputValue(recorder, "recordingProfile", mProfile);
- setInputValue(recorder, "orientationHint", mOrientationHint);
- // Important to set the timelapseinterval to 0 if the capture rate is not >0
- // since the recorder does not get created every time the recording starts.
- // The recorder infers whether the capture is timelapsed based on the value of
- // this interval
- boolean captureTimeLapse = mCaptureRate > 0;
- if (captureTimeLapse) {
- double timeBetweenFrameCapture = 1 / mCaptureRate;
- setInputValue(recorder, "timelapseRecordingIntervalUs",
- (long) (1000000 * timeBetweenFrameCapture));
-
- } else {
- setInputValue(recorder, "timelapseRecordingIntervalUs", 0L);
- }
-
- if (mInfoListener != null) {
- setInputValue(recorder, "infoListener", mInfoListener);
- }
- if (mErrorListener != null) {
- setInputValue(recorder, "errorListener", mErrorListener);
- }
- setInputValue(recorder, "maxFileSize", mMaxFileSize);
- setInputValue(recorder, "maxDurationMs", mMaxDurationMs);
- setInputValue(recorder, "recording", true);
- mSoundPlayer.play(SoundClips.START_VIDEO_RECORDING);
- mState = STATE_RECORD;
- }
-
- public synchronized void stopRecording() {
- if (mLogVerbose) Log.v(TAG, "Stop recording (" + this + ")");
-
- switch (mState) {
- case STATE_CONFIGURE:
- case STATE_STARTING_PREVIEW:
- case STATE_PREVIEW:
- Log.w(TAG, "StopRecording called when recording not active!");
- return;
- case STATE_RELEASED:
- throw new RuntimeException("stopRecording called on released EffectsRecorder!");
- default:
- break;
- }
- Object recorder = getGraphFilter(mRunner, "recorder");
- setInputValue(recorder, "recording", false);
- mSoundPlayer.play(SoundClips.STOP_VIDEO_RECORDING);
- mState = STATE_PREVIEW;
- }
-
- // Called to tell the filter graph that the display surfacetexture is not valid anymore.
- // So the filter graph should not hold any reference to the surface created with that.
- public synchronized void disconnectDisplay() {
- if (mLogVerbose) Log.v(TAG, "Disconnecting the graph from the " +
- "SurfaceTexture");
- Object display = getGraphFilter(mRunner, "display");
- invoke(display, sSurfaceTextureTargetDisconnect, new Object[] {
- invoke(mGraphEnv, sGraphEnvironmentGetContext)});
- }
-
- // The VideoModule will call this to notify that the camera is being
- // released to the outside world. This call should happen after the
- // stopRecording call. Else, the effects may throw an exception.
- // With the recording stopped, the stopPreview call will not try to
- // release the camera again.
- // This must be called in onPause() if the effects are ON.
- public synchronized void disconnectCamera() {
- if (mLogVerbose) Log.v(TAG, "Disconnecting the effects from Camera");
- stopCameraPreview();
- mCameraDevice = null;
- }
-
- // In a normal case, when the disconnect is not called, we should not
- // set the camera device to null, since on return callback, we try to
- // enable 3A locks, which need the cameradevice.
- public synchronized void stopCameraPreview() {
- if (mLogVerbose) Log.v(TAG, "Stopping camera preview.");
- if (mCameraDevice == null) {
- Log.d(TAG, "Camera already null. Nothing to disconnect");
- return;
- }
- mCameraDevice.stopPreview();
- mCameraDevice.setPreviewTextureAsync(null);
- }
-
- // Stop and release effect resources
- public synchronized void stopPreview() {
- if (mLogVerbose) Log.v(TAG, "Stopping preview (" + this + ")");
- switch (mState) {
- case STATE_CONFIGURE:
- Log.w(TAG, "StopPreview called when preview not active!");
- return;
- case STATE_RELEASED:
- throw new RuntimeException("stopPreview called on released EffectsRecorder!");
- default:
- break;
- }
-
- if (mState == STATE_RECORD) {
- stopRecording();
- }
-
- mCurrentEffect = EFFECT_NONE;
-
- // This will not do anything if the camera has already been disconnected.
- stopCameraPreview();
-
- mState = STATE_CONFIGURE;
- mOldRunner = mRunner;
- invoke(mRunner, sGraphRunnerStop);
- mRunner = null;
- // Rest of stop and release handled in mRunnerDoneCallback
- }
-
- // Try to enable/disable video stabilization if supported; otherwise return false
- // It is called from a synchronized block.
- boolean tryEnableVideoStabilization(boolean toggle) {
- if (mLogVerbose) Log.v(TAG, "tryEnableVideoStabilization.");
- if (mCameraDevice == null) {
- Log.d(TAG, "Camera already null. Not enabling video stabilization.");
- return false;
- }
- Camera.Parameters params = mCameraDevice.getParameters();
-
- String vstabSupported = params.get("video-stabilization-supported");
- if ("true".equals(vstabSupported)) {
- if (mLogVerbose) Log.v(TAG, "Setting video stabilization to " + toggle);
- params.set("video-stabilization", toggle ? "true" : "false");
- mCameraDevice.setParameters(params);
- return true;
- }
- if (mLogVerbose) Log.v(TAG, "Video stabilization not supported");
- return false;
- }
-
- // Try to enable/disable 3A locks if supported; otherwise return false
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- synchronized boolean tryEnable3ALocks(boolean toggle) {
- if (mLogVerbose) Log.v(TAG, "tryEnable3ALocks");
- if (mCameraDevice == null) {
- Log.d(TAG, "Camera already null. Not tryenabling 3A locks.");
- return false;
- }
- Camera.Parameters params = mCameraDevice.getParameters();
- if (Util.isAutoExposureLockSupported(params) &&
- Util.isAutoWhiteBalanceLockSupported(params)) {
- params.setAutoExposureLock(toggle);
- params.setAutoWhiteBalanceLock(toggle);
- mCameraDevice.setParameters(params);
- return true;
- }
- return false;
- }
-
- // Try to enable/disable 3A locks if supported; otherwise, throw error
- // Use this when locks are essential to success
- synchronized void enable3ALocks(boolean toggle) {
- if (mLogVerbose) Log.v(TAG, "Enable3ALocks");
- if (mCameraDevice == null) {
- Log.d(TAG, "Camera already null. Not enabling 3A locks.");
- return;
- }
- Camera.Parameters params = mCameraDevice.getParameters();
- if (!tryEnable3ALocks(toggle)) {
- throw new RuntimeException("Attempt to lock 3A on camera with no locking support!");
- }
- }
-
- static class SerializableInvocationHandler
- implements InvocationHandler, Serializable {
- private final int mEffectsRecorderIndex;
- public SerializableInvocationHandler(int index) {
- mEffectsRecorderIndex = index;
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- if (sEffectsRecorder == null) return null;
- if (mEffectsRecorderIndex != sEffectsRecorderIndex) {
- Log.v(TAG, "Ignore old callback " + mEffectsRecorderIndex);
- return null;
- }
- if (method.equals(sObjectEquals)) {
- return sEffectsRecorder.invokeObjectEquals(proxy, args);
- } else if (method.equals(sObjectToString)) {
- return sEffectsRecorder.invokeObjectToString();
- } else if (method.equals(sLearningDoneListenerOnLearningDone)) {
- sEffectsRecorder.invokeOnLearningDone();
- } else if (method.equals(sOnRunnerDoneListenerOnRunnerDone)) {
- sEffectsRecorder.invokeOnRunnerDone(args);
- } else if (method.equals(
- sSurfaceTextureSourceListenerOnSurfaceTextureSourceReady)) {
- sEffectsRecorder.invokeOnSurfaceTextureSourceReady(args);
- } else if (method.equals(sOnRecordingDoneListenerOnRecordingDone)) {
- sEffectsRecorder.invokeOnRecordingDone();
- }
- return null;
- }
- }
-
- // Indicates that all camera/recording activity needs to halt
- public synchronized void release() {
- if (mLogVerbose) Log.v(TAG, "Releasing (" + this + ")");
-
- switch (mState) {
- case STATE_RECORD:
- case STATE_STARTING_PREVIEW:
- case STATE_PREVIEW:
- stopPreview();
- // Fall-through
- default:
- if (mSoundPlayer != null) {
- mSoundPlayer.release();
- mSoundPlayer = null;
- }
- mState = STATE_RELEASED;
- break;
- }
- sEffectsRecorder = null;
- }
-
- private void sendMessage(final int effect, final int msg) {
- if (mEffectsListener != null) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mEffectsListener.onEffectsUpdate(effect, msg);
- }
- });
- }
- }
-
- private void raiseError(final Exception exception) {
- if (mEffectsListener != null) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- if (mFd != null) {
- mEffectsListener.onEffectsError(exception, null);
- } else {
- mEffectsListener.onEffectsError(exception, mOutputFile);
- }
- }
- });
- }
- }
-
- // invoke method on receiver with no arguments
- private Object invoke(Object receiver, Method method) {
- try {
- return method.invoke(receiver);
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- // invoke method on receiver with arguments
- private Object invoke(Object receiver, Method method, Object[] args) {
- try {
- return method.invoke(receiver, args);
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private void setInputValue(Object receiver, String key, Object value) {
- try {
- sFilterSetInputValue.invoke(receiver, new Object[] {key, value});
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private Object newInstance(Constructor<?> ct, Object[] initArgs) {
- try {
- return ct.newInstance(initArgs);
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private Object newInstance(Constructor<?> ct) {
- try {
- return ct.newInstance();
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private Object getGraphFilter(Object receiver, String name) {
- try {
- return sFilterGraphGetFilter.invoke(sGraphRunnerGetGraph
- .invoke(receiver), new Object[] {name});
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private Object getContextGLEnvironment(Object receiver) {
- try {
- return sFilterContextGetGLEnvironment
- .invoke(sGraphEnvironmentGetContext.invoke(receiver));
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private void getGraphTearDown(Object receiver, Object filterContext) {
- try {
- sFilterGraphTearDown.invoke(sGraphRunnerGetGraph.invoke(receiver),
- new Object[]{filterContext});
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private Object getConstant(Class<?> cls, String name) {
- try {
- return cls.getDeclaredField(name).get(null);
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-}
diff --git a/src/com/android/camera/Exif.java b/src/com/android/camera/Exif.java
deleted file mode 100644
index c6ec6af..0000000
--- a/src/com/android/camera/Exif.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera;
-
-import android.util.Log;
-
-import com.android.gallery3d.exif.ExifInterface;
-
-import java.io.IOException;
-
-public class Exif {
- private static final String TAG = "CameraExif";
-
- public static ExifInterface getExif(byte[] jpegData) {
- ExifInterface exif = new ExifInterface();
- try {
- exif.readExif(jpegData);
- } catch (IOException e) {
- Log.w(TAG, "Failed to read EXIF data", e);
- }
- return exif;
- }
-
- // Returns the degrees in clockwise. Values are 0, 90, 180, or 270.
- public static int getOrientation(ExifInterface exif) {
- Integer val = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION);
- if (val == null) {
- return 0;
- } else {
- return ExifInterface.getRotationForOrientationValue(val.shortValue());
- }
- }
-
- public static int getOrientation(byte[] jpegData) {
- if (jpegData == null) return 0;
-
- ExifInterface exif = getExif(jpegData);
- return getOrientation(exif);
- }
-}
diff --git a/src/com/android/camera/FocusOverlayManager.java b/src/com/android/camera/FocusOverlayManager.java
deleted file mode 100644
index 8bcb52f..0000000
--- a/src/com/android/camera/FocusOverlayManager.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.annotation.TargetApi;
-import android.graphics.Matrix;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.hardware.Camera.Area;
-import android.hardware.Camera.Parameters;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.util.Log;
-
-import com.android.gallery3d.common.ApiHelper;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/* A class that handles everything about focus in still picture mode.
- * This also handles the metering area because it is the same as focus area.
- *
- * The test cases:
- * (1) The camera has continuous autofocus. Move the camera. Take a picture when
- * CAF is not in progress.
- * (2) The camera has continuous autofocus. Move the camera. Take a picture when
- * CAF is in progress.
- * (3) The camera has face detection. Point the camera at some faces. Hold the
- * shutter. Release to take a picture.
- * (4) The camera has face detection. Point the camera at some faces. Single tap
- * the shutter to take a picture.
- * (5) The camera has autofocus. Single tap the shutter to take a picture.
- * (6) The camera has autofocus. Hold the shutter. Release to take a picture.
- * (7) The camera has no autofocus. Single tap the shutter and take a picture.
- * (8) The camera has autofocus and supports focus area. Touch the screen to
- * trigger autofocus. Take a picture.
- * (9) The camera has autofocus and supports focus area. Touch the screen to
- * trigger autofocus. Wait until it times out.
- * (10) The camera has no autofocus and supports metering area. Touch the screen
- * to change metering area.
- */
-public class FocusOverlayManager {
- private static final String TAG = "CAM_FocusManager";
-
- private static final int RESET_TOUCH_FOCUS = 0;
- private static final int RESET_TOUCH_FOCUS_DELAY = 3000;
-
- private int mState = STATE_IDLE;
- private static final int STATE_IDLE = 0; // Focus is not active.
- private static final int STATE_FOCUSING = 1; // Focus is in progress.
- // Focus is in progress and the camera should take a picture after focus finishes.
- private static final int STATE_FOCUSING_SNAP_ON_FINISH = 2;
- private static final int STATE_SUCCESS = 3; // Focus finishes and succeeds.
- private static final int STATE_FAIL = 4; // Focus finishes and fails.
-
- private boolean mInitialized;
- private boolean mFocusAreaSupported;
- private boolean mMeteringAreaSupported;
- private boolean mLockAeAwbNeeded;
- private boolean mAeAwbLock;
- private Matrix mMatrix;
-
- private int mPreviewWidth; // The width of the preview frame layout.
- private int mPreviewHeight; // The height of the preview frame layout.
- private boolean mMirror; // true if the camera is front-facing.
- private int mDisplayOrientation;
- private List<Object> mFocusArea; // focus area in driver format
- private List<Object> mMeteringArea; // metering area in driver format
- private String mFocusMode;
- private String[] mDefaultFocusModes;
- private String mOverrideFocusMode;
- private Parameters mParameters;
- private ComboPreferences mPreferences;
- private Handler mHandler;
- Listener mListener;
- private boolean mPreviousMoving;
- private boolean mFocusDefault;
-
- private FocusUI mUI;
-
- public interface FocusUI {
- public boolean hasFaces();
- public void clearFocus();
- public void setFocusPosition(int x, int y);
- public void onFocusStarted();
- public void onFocusSucceeded(boolean timeOut);
- public void onFocusFailed(boolean timeOut);
- public void pauseFaceDetection();
- public void resumeFaceDetection();
- }
-
- public interface Listener {
- public void autoFocus();
- public void cancelAutoFocus();
- public boolean capture();
- public void startFaceDetection();
- public void stopFaceDetection();
- public void setFocusParameters();
- }
-
- private class MainHandler extends Handler {
- public MainHandler(Looper looper) {
- super(looper);
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case RESET_TOUCH_FOCUS: {
- cancelAutoFocus();
- mListener.startFaceDetection();
- break;
- }
- }
- }
- }
-
- public FocusOverlayManager(ComboPreferences preferences, String[] defaultFocusModes,
- Parameters parameters, Listener listener,
- boolean mirror, Looper looper, FocusUI ui) {
- mHandler = new MainHandler(looper);
- mMatrix = new Matrix();
- mPreferences = preferences;
- mDefaultFocusModes = defaultFocusModes;
- setParameters(parameters);
- mListener = listener;
- setMirror(mirror);
- mFocusDefault = true;
- mUI = ui;
- }
-
- public void setParameters(Parameters parameters) {
- // parameters can only be null when onConfigurationChanged is called
- // before camera is open. We will just return in this case, because
- // parameters will be set again later with the right parameters after
- // camera is open.
- if (parameters == null) return;
- mParameters = parameters;
- mFocusAreaSupported = Util.isFocusAreaSupported(parameters);
- mMeteringAreaSupported = Util.isMeteringAreaSupported(parameters);
- mLockAeAwbNeeded = (Util.isAutoExposureLockSupported(mParameters) ||
- Util.isAutoWhiteBalanceLockSupported(mParameters));
- }
-
- public void setPreviewSize(int previewWidth, int previewHeight) {
- if (mPreviewWidth != previewWidth || mPreviewHeight != previewHeight) {
- mPreviewWidth = previewWidth;
- mPreviewHeight = previewHeight;
- setMatrix();
- }
- }
-
- public void setMirror(boolean mirror) {
- mMirror = mirror;
- setMatrix();
- }
-
- public void setDisplayOrientation(int displayOrientation) {
- mDisplayOrientation = displayOrientation;
- setMatrix();
- }
-
- private void setMatrix() {
- if (mPreviewWidth != 0 && mPreviewHeight != 0) {
- Matrix matrix = new Matrix();
- Util.prepareMatrix(matrix, mMirror, mDisplayOrientation,
- mPreviewWidth, mPreviewHeight);
- // In face detection, the matrix converts the driver coordinates to UI
- // coordinates. In tap focus, the inverted matrix converts the UI
- // coordinates to driver coordinates.
- matrix.invert(mMatrix);
- mInitialized = true;
- }
- }
-
- private void lockAeAwbIfNeeded() {
- if (mLockAeAwbNeeded && !mAeAwbLock) {
- mAeAwbLock = true;
- mListener.setFocusParameters();
- }
- }
-
- private void unlockAeAwbIfNeeded() {
- if (mLockAeAwbNeeded && mAeAwbLock && (mState != STATE_FOCUSING_SNAP_ON_FINISH)) {
- mAeAwbLock = false;
- mListener.setFocusParameters();
- }
- }
-
- public void onShutterDown() {
- if (!mInitialized) return;
-
- boolean autoFocusCalled = false;
- if (needAutoFocusCall()) {
- // Do not focus if touch focus has been triggered.
- if (mState != STATE_SUCCESS && mState != STATE_FAIL) {
- autoFocus();
- autoFocusCalled = true;
- }
- }
-
- if (!autoFocusCalled) lockAeAwbIfNeeded();
- }
-
- public void onShutterUp() {
- if (!mInitialized) return;
-
- if (needAutoFocusCall()) {
- // User releases half-pressed focus key.
- if (mState == STATE_FOCUSING || mState == STATE_SUCCESS
- || mState == STATE_FAIL) {
- cancelAutoFocus();
- }
- }
-
- // Unlock AE and AWB after cancelAutoFocus. Camera API does not
- // guarantee setParameters can be called during autofocus.
- unlockAeAwbIfNeeded();
- }
-
- public void doSnap() {
- if (!mInitialized) return;
-
- // If the user has half-pressed the shutter and focus is completed, we
- // can take the photo right away. If the focus mode is infinity, we can
- // also take the photo.
- if (!needAutoFocusCall() || (mState == STATE_SUCCESS || mState == STATE_FAIL)) {
- capture();
- } else if (mState == STATE_FOCUSING) {
- // Half pressing the shutter (i.e. the focus button event) will
- // already have requested AF for us, so just request capture on
- // focus here.
- mState = STATE_FOCUSING_SNAP_ON_FINISH;
- } else if (mState == STATE_IDLE) {
- // We didn't do focus. This can happen if the user press focus key
- // while the snapshot is still in progress. The user probably wants
- // the next snapshot as soon as possible, so we just do a snapshot
- // without focusing again.
- capture();
- }
- }
-
- public void onAutoFocus(boolean focused, boolean shutterButtonPressed) {
- if (mState == STATE_FOCUSING_SNAP_ON_FINISH) {
- // Take the picture no matter focus succeeds or fails. No need
- // to play the AF sound if we're about to play the shutter
- // sound.
- if (focused) {
- mState = STATE_SUCCESS;
- } else {
- mState = STATE_FAIL;
- }
- updateFocusUI();
- capture();
- } else if (mState == STATE_FOCUSING) {
- // This happens when (1) user is half-pressing the focus key or
- // (2) touch focus is triggered. Play the focus tone. Do not
- // take the picture now.
- if (focused) {
- mState = STATE_SUCCESS;
- } else {
- mState = STATE_FAIL;
- }
- updateFocusUI();
- // If this is triggered by touch focus, cancel focus after a
- // while.
- if (!mFocusDefault) {
- mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
- }
- if (shutterButtonPressed) {
- // Lock AE & AWB so users can half-press shutter and recompose.
- lockAeAwbIfNeeded();
- }
- } else if (mState == STATE_IDLE) {
- // User has released the focus key before focus completes.
- // Do nothing.
- }
- }
-
- public void onAutoFocusMoving(boolean moving) {
- if (!mInitialized) return;
-
-
- // Ignore if the camera has detected some faces.
- if (mUI.hasFaces()) {
- mUI.clearFocus();
- return;
- }
-
- // Ignore if we have requested autofocus. This method only handles
- // continuous autofocus.
- if (mState != STATE_IDLE) return;
-
- // animate on false->true trasition only b/8219520
- if (moving && !mPreviousMoving) {
- mUI.onFocusStarted();
- } else if (!moving) {
- mUI.onFocusSucceeded(true);
- }
- mPreviousMoving = moving;
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void initializeFocusAreas(int x, int y) {
- if (mFocusArea == null) {
- mFocusArea = new ArrayList<Object>();
- mFocusArea.add(new Area(new Rect(), 1));
- }
-
- // Convert the coordinates to driver format.
- calculateTapArea(x, y, 1f, ((Area) mFocusArea.get(0)).rect);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void initializeMeteringAreas(int x, int y) {
- if (mMeteringArea == null) {
- mMeteringArea = new ArrayList<Object>();
- mMeteringArea.add(new Area(new Rect(), 1));
- }
-
- // Convert the coordinates to driver format.
- // AE area is bigger because exposure is sensitive and
- // easy to over- or underexposure if area is too small.
- calculateTapArea(x, y, 1.5f, ((Area) mMeteringArea.get(0)).rect);
- }
-
- public void onSingleTapUp(int x, int y) {
- if (!mInitialized || mState == STATE_FOCUSING_SNAP_ON_FINISH) return;
-
- // Let users be able to cancel previous touch focus.
- if ((!mFocusDefault) && (mState == STATE_FOCUSING ||
- mState == STATE_SUCCESS || mState == STATE_FAIL)) {
- cancelAutoFocus();
- }
- if (mPreviewWidth == 0 || mPreviewHeight == 0) return;
- mFocusDefault = false;
- // Initialize mFocusArea.
- if (mFocusAreaSupported) {
- initializeFocusAreas(x, y);
- }
- // Initialize mMeteringArea.
- if (mMeteringAreaSupported) {
- initializeMeteringAreas(x, y);
- }
-
- // Use margin to set the focus indicator to the touched area.
- mUI.setFocusPosition(x, y);
-
- // Stop face detection because we want to specify focus and metering area.
- mListener.stopFaceDetection();
-
- // Set the focus area and metering area.
- mListener.setFocusParameters();
- if (mFocusAreaSupported) {
- autoFocus();
- } else { // Just show the indicator in all other cases.
- updateFocusUI();
- // Reset the metering area in 3 seconds.
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
- mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
- }
- }
-
- public void onPreviewStarted() {
- mState = STATE_IDLE;
- }
-
- public void onPreviewStopped() {
- // If auto focus was in progress, it would have been stopped.
- mState = STATE_IDLE;
- resetTouchFocus();
- updateFocusUI();
- }
-
- public void onCameraReleased() {
- onPreviewStopped();
- }
-
- private void autoFocus() {
- Log.v(TAG, "Start autofocus.");
- mListener.autoFocus();
- mState = STATE_FOCUSING;
- // Pause the face view because the driver will keep sending face
- // callbacks after the focus completes.
- mUI.pauseFaceDetection();
- updateFocusUI();
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
- }
-
- private void cancelAutoFocus() {
- Log.v(TAG, "Cancel autofocus.");
-
- // Reset the tap area before calling mListener.cancelAutofocus.
- // Otherwise, focus mode stays at auto and the tap area passed to the
- // driver is not reset.
- resetTouchFocus();
- mListener.cancelAutoFocus();
- mUI.resumeFaceDetection();
- mState = STATE_IDLE;
- updateFocusUI();
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
- }
-
- private void capture() {
- if (mListener.capture()) {
- mState = STATE_IDLE;
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
- }
- }
-
- public String getFocusMode() {
- if (mOverrideFocusMode != null) return mOverrideFocusMode;
- if (mParameters == null) return Parameters.FOCUS_MODE_AUTO;
- List<String> supportedFocusModes = mParameters.getSupportedFocusModes();
-
- if (mFocusAreaSupported && !mFocusDefault) {
- // Always use autofocus in tap-to-focus.
- mFocusMode = Parameters.FOCUS_MODE_AUTO;
- } else {
- // The default is continuous autofocus.
- mFocusMode = mPreferences.getString(
- CameraSettings.KEY_FOCUS_MODE, null);
-
- // Try to find a supported focus mode from the default list.
- if (mFocusMode == null) {
- for (int i = 0; i < mDefaultFocusModes.length; i++) {
- String mode = mDefaultFocusModes[i];
- if (Util.isSupported(mode, supportedFocusModes)) {
- mFocusMode = mode;
- break;
- }
- }
- }
- }
- if (!Util.isSupported(mFocusMode, supportedFocusModes)) {
- // For some reasons, the driver does not support the current
- // focus mode. Fall back to auto.
- if (Util.isSupported(Parameters.FOCUS_MODE_AUTO,
- mParameters.getSupportedFocusModes())) {
- mFocusMode = Parameters.FOCUS_MODE_AUTO;
- } else {
- mFocusMode = mParameters.getFocusMode();
- }
- }
- return mFocusMode;
- }
-
- public List getFocusAreas() {
- return mFocusArea;
- }
-
- public List getMeteringAreas() {
- return mMeteringArea;
- }
-
- public void updateFocusUI() {
- if (!mInitialized) return;
- // Show only focus indicator or face indicator.
-
- if (mState == STATE_IDLE) {
- if (mFocusDefault) {
- mUI.clearFocus();
- } else {
- // Users touch on the preview and the indicator represents the
- // metering area. Either focus area is not supported or
- // autoFocus call is not required.
- mUI.onFocusStarted();
- }
- } else if (mState == STATE_FOCUSING || mState == STATE_FOCUSING_SNAP_ON_FINISH) {
- mUI.onFocusStarted();
- } else {
- if (Util.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusMode)) {
- // TODO: check HAL behavior and decide if this can be removed.
- mUI.onFocusSucceeded(false);
- } else if (mState == STATE_SUCCESS) {
- mUI.onFocusSucceeded(false);
- } else if (mState == STATE_FAIL) {
- mUI.onFocusFailed(false);
- }
- }
- }
-
- public void resetTouchFocus() {
- if (!mInitialized) return;
-
- // Put focus indicator to the center. clear reset position
- mUI.clearFocus();
- // Initialize mFocusArea.
- if (mFocusAreaSupported) {
- initializeFocusAreas(mPreviewWidth / 2, mPreviewHeight / 2);
- }
- // Initialize mMeteringArea.
- if (mMeteringAreaSupported) {
- initializeMeteringAreas(mPreviewWidth / 2, mPreviewHeight / 2);
- }
- mFocusDefault = true;
- }
-
- private void calculateTapArea(int x, int y, float areaMultiple, Rect rect) {
- int areaSize = (int) (Math.min(mPreviewWidth, mPreviewHeight) * areaMultiple / 20);
- int left = Util.clamp(x - areaSize, 0, mPreviewWidth - 2 * areaSize);
- int top = Util.clamp(y - areaSize, 0, mPreviewHeight - 2 * areaSize);
-
- RectF rectF = new RectF(left, top, left + 2 * areaSize, top + 2 * areaSize);
- mMatrix.mapRect(rectF);
- Util.rectFToRect(rectF, rect);
- }
-
- /* package */ int getFocusState() {
- return mState;
- }
-
- public boolean isFocusCompleted() {
- return mState == STATE_SUCCESS || mState == STATE_FAIL;
- }
-
- public boolean isFocusingSnapOnFinish() {
- return mState == STATE_FOCUSING_SNAP_ON_FINISH;
- }
-
- public void removeMessages() {
- mHandler.removeMessages(RESET_TOUCH_FOCUS);
- }
-
- public void overrideFocusMode(String focusMode) {
- mOverrideFocusMode = focusMode;
- }
-
- public void setAeAwbLock(boolean lock) {
- mAeAwbLock = lock;
- }
-
- public boolean getAeAwbLock() {
- return mAeAwbLock;
- }
-
- private boolean needAutoFocusCall() {
- String focusMode = getFocusMode();
- return !(focusMode.equals(Parameters.FOCUS_MODE_INFINITY)
- || focusMode.equals(Parameters.FOCUS_MODE_FIXED)
- || focusMode.equals(Parameters.FOCUS_MODE_EDOF));
- }
-}
diff --git a/src/com/android/camera/IconListPreference.java b/src/com/android/camera/IconListPreference.java
deleted file mode 100644
index e5f75d3..0000000
--- a/src/com/android/camera/IconListPreference.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-
-import com.android.gallery3d.R;
-
-import java.util.List;
-
-/** A {@code ListPreference} where each entry has a corresponding icon. */
-public class IconListPreference extends ListPreference {
- private int mSingleIconId;
- private int mIconIds[];
- private int mLargeIconIds[];
- private int mImageIds[];
- private boolean mUseSingleIcon;
-
- public IconListPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- TypedArray a = context.obtainStyledAttributes(
- attrs, R.styleable.IconListPreference, 0, 0);
- Resources res = context.getResources();
- mSingleIconId = a.getResourceId(
- R.styleable.IconListPreference_singleIcon, 0);
- mIconIds = getIds(res, a.getResourceId(
- R.styleable.IconListPreference_icons, 0));
- mLargeIconIds = getIds(res, a.getResourceId(
- R.styleable.IconListPreference_largeIcons, 0));
- mImageIds = getIds(res, a.getResourceId(
- R.styleable.IconListPreference_images, 0));
- a.recycle();
- }
-
- public int getSingleIcon() {
- return mSingleIconId;
- }
-
- public int[] getIconIds() {
- return mIconIds;
- }
-
- public int[] getLargeIconIds() {
- return mLargeIconIds;
- }
-
- public int[] getImageIds() {
- return mImageIds;
- }
-
- public boolean getUseSingleIcon() {
- return mUseSingleIcon;
- }
-
- public void setIconIds(int[] iconIds) {
- mIconIds = iconIds;
- }
-
- public void setLargeIconIds(int[] largeIconIds) {
- mLargeIconIds = largeIconIds;
- }
-
- public void setUseSingleIcon(boolean useSingle) {
- mUseSingleIcon = useSingle;
- }
-
- private int[] getIds(Resources res, int iconsRes) {
- if (iconsRes == 0) return null;
- TypedArray array = res.obtainTypedArray(iconsRes);
- int n = array.length();
- int ids[] = new int[n];
- for (int i = 0; i < n; ++i) {
- ids[i] = array.getResourceId(i, 0);
- }
- array.recycle();
- return ids;
- }
-
- @Override
- public void filterUnsupported(List<String> supported) {
- CharSequence entryValues[] = getEntryValues();
- IntArray iconIds = new IntArray();
- IntArray largeIconIds = new IntArray();
- IntArray imageIds = new IntArray();
-
- for (int i = 0, len = entryValues.length; i < len; i++) {
- if (supported.indexOf(entryValues[i].toString()) >= 0) {
- if (mIconIds != null) iconIds.add(mIconIds[i]);
- if (mLargeIconIds != null) largeIconIds.add(mLargeIconIds[i]);
- if (mImageIds != null) imageIds.add(mImageIds[i]);
- }
- }
- if (mIconIds != null) mIconIds = iconIds.toArray(new int[iconIds.size()]);
- if (mLargeIconIds != null) {
- mLargeIconIds = largeIconIds.toArray(new int[largeIconIds.size()]);
- }
- if (mImageIds != null) mImageIds = imageIds.toArray(new int[imageIds.size()]);
- super.filterUnsupported(supported);
- }
-}
diff --git a/src/com/android/camera/IntArray.java b/src/com/android/camera/IntArray.java
deleted file mode 100644
index a2550db..0000000
--- a/src/com/android/camera/IntArray.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera;
-
-public class IntArray {
- private static final int INIT_CAPACITY = 8;
-
- private int mData[] = new int[INIT_CAPACITY];
- private int mSize = 0;
-
- public void add(int value) {
- if (mData.length == mSize) {
- int temp[] = new int[mSize + mSize];
- System.arraycopy(mData, 0, temp, 0, mSize);
- mData = temp;
- }
- mData[mSize++] = value;
- }
-
- public int size() {
- return mSize;
- }
-
- public int[] toArray(int[] result) {
- if (result == null || result.length < mSize) {
- result = new int[mSize];
- }
- System.arraycopy(mData, 0, result, 0, mSize);
- return result;
- }
-}
diff --git a/src/com/android/camera/ListPreference.java b/src/com/android/camera/ListPreference.java
deleted file mode 100644
index 38866de..0000000
--- a/src/com/android/camera/ListPreference.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.util.TypedValue;
-
-import com.android.gallery3d.R;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A type of <code>CameraPreference</code> whose number of possible values
- * is limited.
- */
-public class ListPreference extends CameraPreference {
- private static final String TAG = "ListPreference";
- private final String mKey;
- private String mValue;
- private final CharSequence[] mDefaultValues;
-
- private CharSequence[] mEntries;
- private CharSequence[] mEntryValues;
- private CharSequence[] mLabels;
- private boolean mLoaded = false;
-
- public ListPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- TypedArray a = context.obtainStyledAttributes(
- attrs, R.styleable.ListPreference, 0, 0);
-
- mKey = Util.checkNotNull(
- a.getString(R.styleable.ListPreference_key));
-
- // We allow the defaultValue attribute to be a string or an array of
- // strings. The reason we need multiple default values is that some
- // of them may be unsupported on a specific platform (for example,
- // continuous auto-focus). In that case the first supported value
- // in the array will be used.
- int attrDefaultValue = R.styleable.ListPreference_defaultValue;
- TypedValue tv = a.peekValue(attrDefaultValue);
- if (tv != null && tv.type == TypedValue.TYPE_REFERENCE) {
- mDefaultValues = a.getTextArray(attrDefaultValue);
- } else {
- mDefaultValues = new CharSequence[1];
- mDefaultValues[0] = a.getString(attrDefaultValue);
- }
-
- setEntries(a.getTextArray(R.styleable.ListPreference_entries));
- setEntryValues(a.getTextArray(
- R.styleable.ListPreference_entryValues));
- setLabels(a.getTextArray(
- R.styleable.ListPreference_labelList));
- a.recycle();
- }
-
- public String getKey() {
- return mKey;
- }
-
- public CharSequence[] getEntries() {
- return mEntries;
- }
-
- public CharSequence[] getEntryValues() {
- return mEntryValues;
- }
-
- public CharSequence[] getLabels() {
- return mLabels;
- }
-
- public void setEntries(CharSequence entries[]) {
- mEntries = entries == null ? new CharSequence[0] : entries;
- }
-
- public void setEntryValues(CharSequence values[]) {
- mEntryValues = values == null ? new CharSequence[0] : values;
- }
-
- public void setLabels(CharSequence labels[]) {
- mLabels = labels == null ? new CharSequence[0] : labels;
- }
-
- public String getValue() {
- if (!mLoaded) {
- mValue = getSharedPreferences().getString(mKey,
- findSupportedDefaultValue());
- mLoaded = true;
- }
- return mValue;
- }
-
- // Find the first value in mDefaultValues which is supported.
- private String findSupportedDefaultValue() {
- for (int i = 0; i < mDefaultValues.length; i++) {
- for (int j = 0; j < mEntryValues.length; j++) {
- // Note that mDefaultValues[i] may be null (if unspecified
- // in the xml file).
- if (mEntryValues[j].equals(mDefaultValues[i])) {
- return mDefaultValues[i].toString();
- }
- }
- }
- return null;
- }
-
- public void setValue(String value) {
- if (findIndexOfValue(value) < 0) throw new IllegalArgumentException();
- mValue = value;
- persistStringValue(value);
- }
-
- public void setValueIndex(int index) {
- setValue(mEntryValues[index].toString());
- }
-
- public int findIndexOfValue(String value) {
- for (int i = 0, n = mEntryValues.length; i < n; ++i) {
- if (Util.equals(mEntryValues[i], value)) return i;
- }
- return -1;
- }
-
- public int getCurrentIndex() {
- return findIndexOfValue(getValue());
- }
-
- public String getEntry() {
- return mEntries[findIndexOfValue(getValue())].toString();
- }
-
- public String getLabel() {
- return mLabels[findIndexOfValue(getValue())].toString();
- }
-
- protected void persistStringValue(String value) {
- SharedPreferences.Editor editor = getSharedPreferences().edit();
- editor.putString(mKey, value);
- editor.apply();
- }
-
- @Override
- public void reloadValue() {
- this.mLoaded = false;
- }
-
- public void filterUnsupported(List<String> supported) {
- ArrayList<CharSequence> entries = new ArrayList<CharSequence>();
- ArrayList<CharSequence> entryValues = new ArrayList<CharSequence>();
- for (int i = 0, len = mEntryValues.length; i < len; i++) {
- if (supported.indexOf(mEntryValues[i].toString()) >= 0) {
- entries.add(mEntries[i]);
- entryValues.add(mEntryValues[i]);
- }
- }
- int size = entries.size();
- mEntries = entries.toArray(new CharSequence[size]);
- mEntryValues = entryValues.toArray(new CharSequence[size]);
- }
-
- public void filterDuplicated() {
- ArrayList<CharSequence> entries = new ArrayList<CharSequence>();
- ArrayList<CharSequence> entryValues = new ArrayList<CharSequence>();
- for (int i = 0, len = mEntryValues.length; i < len; i++) {
- if (!entries.contains(mEntries[i])) {
- entries.add(mEntries[i]);
- entryValues.add(mEntryValues[i]);
- }
- }
- int size = entries.size();
- mEntries = entries.toArray(new CharSequence[size]);
- mEntryValues = entryValues.toArray(new CharSequence[size]);
- }
-
- public void print() {
- Log.v(TAG, "Preference key=" + getKey() + ". value=" + getValue());
- for (int i = 0; i < mEntryValues.length; i++) {
- Log.v(TAG, "entryValues[" + i + "]=" + mEntryValues[i]);
- }
- }
-}
diff --git a/src/com/android/camera/LocationManager.java b/src/com/android/camera/LocationManager.java
deleted file mode 100644
index fcf21b6..0000000
--- a/src/com/android/camera/LocationManager.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import android.content.Context;
-import android.location.Location;
-import android.location.LocationProvider;
-import android.os.Bundle;
-import android.util.Log;
-
-/**
- * A class that handles everything about location.
- */
-public class LocationManager {
- private static final String TAG = "LocationManager";
-
- private Context mContext;
- private Listener mListener;
- private android.location.LocationManager mLocationManager;
- private boolean mRecordLocation;
-
- LocationListener [] mLocationListeners = new LocationListener[] {
- new LocationListener(android.location.LocationManager.GPS_PROVIDER),
- new LocationListener(android.location.LocationManager.NETWORK_PROVIDER)
- };
-
- public interface Listener {
- public void showGpsOnScreenIndicator(boolean hasSignal);
- public void hideGpsOnScreenIndicator();
- }
-
- public LocationManager(Context context, Listener listener) {
- mContext = context;
- mListener = listener;
- }
-
- public Location getCurrentLocation() {
- if (!mRecordLocation) return null;
-
- // go in best to worst order
- for (int i = 0; i < mLocationListeners.length; i++) {
- Location l = mLocationListeners[i].current();
- if (l != null) return l;
- }
- Log.d(TAG, "No location received yet.");
- return null;
- }
-
- public void recordLocation(boolean recordLocation) {
- if (mRecordLocation != recordLocation) {
- mRecordLocation = recordLocation;
- if (recordLocation) {
- startReceivingLocationUpdates();
- } else {
- stopReceivingLocationUpdates();
- }
- }
- }
-
- private void startReceivingLocationUpdates() {
- if (mLocationManager == null) {
- mLocationManager = (android.location.LocationManager)
- mContext.getSystemService(Context.LOCATION_SERVICE);
- }
- if (mLocationManager != null) {
- try {
- mLocationManager.requestLocationUpdates(
- android.location.LocationManager.NETWORK_PROVIDER,
- 1000,
- 0F,
- mLocationListeners[1]);
- } catch (SecurityException ex) {
- Log.i(TAG, "fail to request location update, ignore", ex);
- } catch (IllegalArgumentException ex) {
- Log.d(TAG, "provider does not exist " + ex.getMessage());
- }
- try {
- mLocationManager.requestLocationUpdates(
- android.location.LocationManager.GPS_PROVIDER,
- 1000,
- 0F,
- mLocationListeners[0]);
- if (mListener != null) mListener.showGpsOnScreenIndicator(false);
- } catch (SecurityException ex) {
- Log.i(TAG, "fail to request location update, ignore", ex);
- } catch (IllegalArgumentException ex) {
- Log.d(TAG, "provider does not exist " + ex.getMessage());
- }
- Log.d(TAG, "startReceivingLocationUpdates");
- }
- }
-
- private void stopReceivingLocationUpdates() {
- if (mLocationManager != null) {
- for (int i = 0; i < mLocationListeners.length; i++) {
- try {
- mLocationManager.removeUpdates(mLocationListeners[i]);
- } catch (Exception ex) {
- Log.i(TAG, "fail to remove location listners, ignore", ex);
- }
- }
- Log.d(TAG, "stopReceivingLocationUpdates");
- }
- if (mListener != null) mListener.hideGpsOnScreenIndicator();
- }
-
- private class LocationListener
- implements android.location.LocationListener {
- Location mLastLocation;
- boolean mValid = false;
- String mProvider;
-
- public LocationListener(String provider) {
- mProvider = provider;
- mLastLocation = new Location(mProvider);
- }
-
- @Override
- public void onLocationChanged(Location newLocation) {
- if (newLocation.getLatitude() == 0.0
- && newLocation.getLongitude() == 0.0) {
- // Hack to filter out 0.0,0.0 locations
- return;
- }
- // If GPS is available before start camera, we won't get status
- // update so update GPS indicator when we receive data.
- if (mListener != null && mRecordLocation &&
- android.location.LocationManager.GPS_PROVIDER.equals(mProvider)) {
- mListener.showGpsOnScreenIndicator(true);
- }
- if (!mValid) {
- Log.d(TAG, "Got first location.");
- }
- mLastLocation.set(newLocation);
- mValid = true;
- }
-
- @Override
- public void onProviderEnabled(String provider) {
- }
-
- @Override
- public void onProviderDisabled(String provider) {
- mValid = false;
- }
-
- @Override
- public void onStatusChanged(
- String provider, int status, Bundle extras) {
- switch(status) {
- case LocationProvider.OUT_OF_SERVICE:
- case LocationProvider.TEMPORARILY_UNAVAILABLE: {
- mValid = false;
- if (mListener != null && mRecordLocation &&
- android.location.LocationManager.GPS_PROVIDER.equals(provider)) {
- mListener.showGpsOnScreenIndicator(false);
- }
- break;
- }
- }
- }
-
- public Location current() {
- return mValid ? mLastLocation : null;
- }
- }
-}
diff --git a/src/com/android/camera/MediaSaveService.java b/src/com/android/camera/MediaSaveService.java
deleted file mode 100644
index e37b45c..0000000
--- a/src/com/android/camera/MediaSaveService.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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.camera;
-
-import android.app.Service;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.location.Location;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Binder;
-import android.os.IBinder;
-import android.provider.MediaStore.Video;
-import android.util.Log;
-
-import com.android.gallery3d.exif.ExifInterface;
-
-import java.io.File;
-
-/*
- * Service for saving images in the background thread.
- */
-public class MediaSaveService extends Service {
- private static final int SAVE_TASK_LIMIT = 3;
- private static final String TAG = MediaSaveService.class.getSimpleName();
-
- private final IBinder mBinder = new LocalBinder();
- private int mTaskNumber;
- private Listener mListener;
-
- interface Listener {
-
- public void onQueueStatus(boolean full);
- }
-
- interface OnMediaSavedListener {
- public void onMediaSaved(Uri uri);
- }
-
- class LocalBinder extends Binder {
- public MediaSaveService getService() {
- return MediaSaveService.this;
- }
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return mBinder;
- }
-
- @Override
- public int onStartCommand(Intent intent, int flag, int startId) {
- return START_STICKY;
- }
-
- @Override
- public void onDestroy() {
- }
-
- @Override
- public void onCreate() {
- mTaskNumber = 0;
- }
-
- public boolean isQueueFull() {
- return (mTaskNumber >= SAVE_TASK_LIMIT);
- }
-
- // Runs in main thread
- public void addImage(final byte[] data, String title, long date, Location loc,
- int width, int height, int orientation, ExifInterface exif,
- OnMediaSavedListener l, ContentResolver resolver) {
- if (isQueueFull()) {
- Log.e(TAG, "Cannot add image when the queue is full");
- return;
- }
- ImageSaveTask t = new ImageSaveTask(data, title, date,
- (loc == null) ? null : new Location(loc),
- width, height, orientation, exif, resolver, l);
-
- mTaskNumber++;
- if (isQueueFull()) {
- onQueueFull();
- }
- t.execute();
- }
-
- public void addVideo(String path, long duration, ContentValues values,
- OnMediaSavedListener l, ContentResolver resolver) {
- // We don't set a queue limit for video saving because the file
- // is already in the storage. Only updating the database.
- new VideoSaveTask(path, duration, values, l, resolver).execute();
- }
-
- public void setListener(Listener l) {
- mListener = l;
- if (l == null) return;
- l.onQueueStatus(isQueueFull());
- }
-
- private void onQueueFull() {
- if (mListener != null) mListener.onQueueStatus(true);
- }
-
- private void onQueueAvailable() {
- if (mListener != null) mListener.onQueueStatus(false);
- }
-
- private class ImageSaveTask extends AsyncTask <Void, Void, Uri> {
- private byte[] data;
- private String title;
- private long date;
- private Location loc;
- private int width, height;
- private int orientation;
- private ExifInterface exif;
- private ContentResolver resolver;
- private OnMediaSavedListener listener;
-
- public ImageSaveTask(byte[] data, String title, long date, Location loc,
- int width, int height, int orientation, ExifInterface exif,
- ContentResolver resolver, OnMediaSavedListener listener) {
- this.data = data;
- this.title = title;
- this.date = date;
- this.loc = loc;
- this.width = width;
- this.height = height;
- this.orientation = orientation;
- this.exif = exif;
- this.resolver = resolver;
- this.listener = listener;
- }
-
- @Override
- protected void onPreExecute() {
- // do nothing.
- }
-
- @Override
- protected Uri doInBackground(Void... v) {
- return Storage.addImage(
- resolver, title, date, loc, orientation, exif, data, width, height);
- }
-
- @Override
- protected void onPostExecute(Uri uri) {
- if (listener != null) listener.onMediaSaved(uri);
- mTaskNumber--;
- if (mTaskNumber == SAVE_TASK_LIMIT - 1) onQueueAvailable();
- }
- }
-
- private class VideoSaveTask extends AsyncTask <Void, Void, Uri> {
- private String path;
- private long duration;
- private ContentValues values;
- private OnMediaSavedListener listener;
- private ContentResolver resolver;
-
- public VideoSaveTask(String path, long duration, ContentValues values,
- OnMediaSavedListener l, ContentResolver r) {
- this.path = path;
- this.duration = duration;
- this.values = new ContentValues(values);
- this.listener = l;
- this.resolver = r;
- }
-
- @Override
- protected void onPreExecute() {
- // do nothing.
- }
-
- @Override
- protected Uri doInBackground(Void... v) {
- values.put(Video.Media.SIZE, new File(path).length());
- values.put(Video.Media.DURATION, duration);
- Uri uri = null;
- try {
- Uri videoTable = Uri.parse("content://media/external/video/media");
- uri = resolver.insert(videoTable, values);
-
- // Rename the video file to the final name. This avoids other
- // apps reading incomplete data. We need to do it after we are
- // certain that the previous insert to MediaProvider is completed.
- String finalName = values.getAsString(
- Video.Media.DATA);
- if (new File(path).renameTo(new File(finalName))) {
- path = finalName;
- }
-
- resolver.update(uri, values, null, null);
- } catch (Exception e) {
- // We failed to insert into the database. This can happen if
- // the SD card is unmounted.
- Log.e(TAG, "failed to add video to media store", e);
- uri = null;
- } finally {
- Log.v(TAG, "Current video URI: " + uri);
- }
- return uri;
- }
-
- @Override
- protected void onPostExecute(Uri uri) {
- if (listener != null) listener.onMediaSaved(uri);
- }
- }
-}
diff --git a/src/com/android/camera/Mosaic.java b/src/com/android/camera/Mosaic.java
deleted file mode 100644
index 78876c3..0000000
--- a/src/com/android/camera/Mosaic.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-/**
- * The Java interface to JNI calls regarding mosaic stitching.
- *
- * A high-level usage is:
- *
- * Mosaic mosaic = new Mosaic();
- * mosaic.setSourceImageDimensions(width, height);
- * mosaic.reset(blendType);
- *
- * while ((pixels = hasNextImage()) != null) {
- * mosaic.setSourceImage(pixels);
- * }
- *
- * mosaic.createMosaic(highRes);
- * byte[] result = mosaic.getFinalMosaic();
- *
- */
-public class Mosaic {
- /**
- * In this mode, the images are stitched together in the same spatial arrangement as acquired
- * i.e. if the user follows a curvy trajectory, the image boundary of the resulting mosaic will
- * be curved in the same manner. This mode is useful if the user wants to capture a mosaic as
- * if "painting" the scene using the smart-phone device and does not want any corrective warps
- * to distort the captured images.
- */
- public static final int BLENDTYPE_FULL = 0;
-
- /**
- * This mode is the same as BLENDTYPE_FULL except that the resulting mosaic is rotated
- * to balance the first and last images to be approximately at the same vertical offset in the
- * output mosaic. This is useful when acquiring a mosaic by a typical panning-like motion to
- * remove a one-sided curve in the mosaic (typically due to the camera not staying horizontal
- * during the video capture) and convert it to a more symmetrical "smiley-face" like output.
- */
- public static final int BLENDTYPE_PAN = 1;
-
- /**
- * This mode compensates for typical "smiley-face" like output in longer mosaics and creates
- * a rectangular mosaic with minimal black borders (by unwrapping the mosaic onto an imaginary
- * cylinder). If the user follows a curved trajectory (instead of a perfect panning trajectory),
- * the resulting mosaic here may suffer from some image distortions in trying to map the
- * trajectory to a cylinder.
- */
- public static final int BLENDTYPE_CYLINDERPAN = 2;
-
- /**
- * This mode is basically BLENDTYPE_CYLINDERPAN plus doing a rectangle cropping before returning
- * the mosaic. The mode is useful for making the resulting mosaic have a rectangle shape.
- */
- public static final int BLENDTYPE_HORIZONTAL =3;
-
- /**
- * This strip type will use the default thin strips where the strips are
- * spaced according to the image capture rate.
- */
- public static final int STRIPTYPE_THIN = 0;
-
- /**
- * This strip type will use wider strips for blending. The strip separation
- * is controlled by a threshold on the native side. Since the strips are
- * wider, there is an additional cross-fade blending step to make the seam
- * boundaries smoother. Since this mode uses lesser image frames, it is
- * computationally more efficient than the thin strip mode.
- */
- public static final int STRIPTYPE_WIDE = 1;
-
- /**
- * Return flags returned by createMosaic() are one of the following.
- */
- public static final int MOSAIC_RET_OK = 1;
- public static final int MOSAIC_RET_ERROR = -1;
- public static final int MOSAIC_RET_CANCELLED = -2;
- public static final int MOSAIC_RET_LOW_TEXTURE = -3;
- public static final int MOSAIC_RET_FEW_INLIERS = 2;
-
-
- static {
- System.loadLibrary("jni_mosaic");
- }
-
- /**
- * Allocate memory for the image frames at the given resolution.
- *
- * @param width width of the input frames in pixels
- * @param height height of the input frames in pixels
- */
- public native void allocateMosaicMemory(int width, int height);
-
- /**
- * Free memory allocated by allocateMosaicMemory.
- *
- */
- public native void freeMosaicMemory();
-
- /**
- * Pass the input image frame to the native layer. Each time the a new
- * source image t is set, the transformation matrix from the first source
- * image to t is computed and returned.
- *
- * @param pixels source image of NV21 format.
- * @return Float array of length 11; first 9 entries correspond to the 3x3
- * transformation matrix between the first frame and the passed frame;
- * the 10th entry is the number of the passed frame, where the counting
- * starts from 1; and the 11th entry is the returning code, whose value
- * is one of those MOSAIC_RET_* returning flags defined above.
- */
- public native float[] setSourceImage(byte[] pixels);
-
- /**
- * This is an alternative to the setSourceImage function above. This should
- * be called when the image data is already on the native side in a fixed
- * byte array. In implementation, this array is filled by the GL thread
- * using glReadPixels directly from GPU memory (where it is accessed by
- * an associated SurfaceTexture).
- *
- * @return Float array of length 11; first 9 entries correspond to the 3x3
- * transformation matrix between the first frame and the passed frame;
- * the 10th entry is the number of the passed frame, where the counting
- * starts from 1; and the 11th entry is the returning code, whose value
- * is one of those MOSAIC_RET_* returning flags defined above.
- */
- public native float[] setSourceImageFromGPU();
-
- /**
- * Set the type of blending.
- *
- * @param type the blending type defined in the class. {BLENDTYPE_FULL,
- * BLENDTYPE_PAN, BLENDTYPE_CYLINDERPAN, BLENDTYPE_HORIZONTAL}
- */
- public native void setBlendingType(int type);
-
- /**
- * Set the type of strips to use for blending.
- * @param type the blending strip type to use {STRIPTYPE_THIN,
- * STRIPTYPE_WIDE}.
- */
- public native void setStripType(int type);
-
- /**
- * Tell the native layer to create the final mosaic after all the input frame
- * data have been collected.
- * The case of generating high-resolution mosaic may take dozens of seconds to finish.
- *
- * @param value True means generating a high-resolution mosaic -
- * which is based on the original images set in setSourceImage().
- * False means generating a low-resolution version -
- * which is based on 1/4 downscaled images from the original images.
- * @return Returns a status code suggesting if the mosaic building was
- * successful, in error, or was cancelled by the user.
- */
- public native int createMosaic(boolean value);
-
- /**
- * Get the data for the created mosaic.
- *
- * @return Returns an integer array which contains the final mosaic in the ARGB_8888 format.
- * The first MosaicWidth*MosaicHeight values contain the image data, followed by 2
- * integers corresponding to the values MosaicWidth and MosaicHeight respectively.
- */
- public native int[] getFinalMosaic();
-
- /**
- * Get the data for the created mosaic.
- *
- * @return Returns a byte array which contains the final mosaic in the NV21 format.
- * The first MosaicWidth*MosaicHeight*1.5 values contain the image data, followed by
- * 8 bytes which pack the MosaicWidth and MosaicHeight integers into 4 bytes each
- * respectively.
- */
- public native byte[] getFinalMosaicNV21();
-
- /**
- * Reset the state of the frame arrays which maintain the captured frame data.
- * Also re-initializes the native mosaic object to make it ready for capturing a new mosaic.
- */
- public native void reset();
-
- /**
- * Get the progress status of the mosaic computation process.
- * @param hires Boolean flag to select whether to report progress of the
- * low-res or high-res mosaicer.
- * @param cancelComputation Boolean flag to allow cancelling the
- * mosaic computation when needed from the GUI end.
- * @return Returns a number from 0-100 where 50 denotes that the mosaic
- * computation is 50% done.
- */
- public native int reportProgress(boolean hires, boolean cancelComputation);
-}
diff --git a/src/com/android/camera/MosaicFrameProcessor.java b/src/com/android/camera/MosaicFrameProcessor.java
deleted file mode 100644
index efd4ad2..0000000
--- a/src/com/android/camera/MosaicFrameProcessor.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import android.util.Log;
-
-/**
- * Class to handle the processing of each frame by Mosaicer.
- */
-public class MosaicFrameProcessor {
- private static final String TAG = "MosaicFrameProcessor";
- private static final int NUM_FRAMES_IN_BUFFER = 2;
- private static final int MAX_NUMBER_OF_FRAMES = 100;
- private static final int MOSAIC_RET_CODE_INDEX = 10;
- private static final int FRAME_COUNT_INDEX = 9;
- private static final int X_COORD_INDEX = 2;
- private static final int Y_COORD_INDEX = 5;
- private static final int HR_TO_LR_DOWNSAMPLE_FACTOR = 4;
- private static final int WINDOW_SIZE = 3;
-
- private Mosaic mMosaicer;
- private boolean mIsMosaicMemoryAllocated = false;
- private float mTranslationLastX;
- private float mTranslationLastY;
-
- private int mFillIn = 0;
- private int mTotalFrameCount = 0;
- private int mLastProcessFrameIdx = -1;
- private int mCurrProcessFrameIdx = -1;
- private boolean mFirstRun;
-
- // Panning rate is in unit of percentage of image content translation per
- // frame. Use moving average to calculate the panning rate.
- private float mPanningRateX;
- private float mPanningRateY;
-
- private float[] mDeltaX = new float[WINDOW_SIZE];
- private float[] mDeltaY = new float[WINDOW_SIZE];
- private int mOldestIdx = 0;
- private float mTotalTranslationX = 0f;
- private float mTotalTranslationY = 0f;
-
- private ProgressListener mProgressListener;
-
- private int mPreviewWidth;
- private int mPreviewHeight;
- private int mPreviewBufferSize;
-
- private static MosaicFrameProcessor sMosaicFrameProcessor; // singleton
-
- public interface ProgressListener {
- public void onProgress(boolean isFinished, float panningRateX, float panningRateY,
- float progressX, float progressY);
- }
-
- public static MosaicFrameProcessor getInstance() {
- if (sMosaicFrameProcessor == null) {
- sMosaicFrameProcessor = new MosaicFrameProcessor();
- }
- return sMosaicFrameProcessor;
- }
-
- private MosaicFrameProcessor() {
- mMosaicer = new Mosaic();
- }
-
- public void setProgressListener(ProgressListener listener) {
- mProgressListener = listener;
- }
-
- public int reportProgress(boolean hires, boolean cancel) {
- return mMosaicer.reportProgress(hires, cancel);
- }
-
- public void initialize(int previewWidth, int previewHeight, int bufSize) {
- mPreviewWidth = previewWidth;
- mPreviewHeight = previewHeight;
- mPreviewBufferSize = bufSize;
- setupMosaicer(mPreviewWidth, mPreviewHeight, mPreviewBufferSize);
- setStripType(Mosaic.STRIPTYPE_WIDE);
- // no need to call reset() here. reset() should be called by the client
- // after this initialization before calling other methods of this object.
- }
-
- public void clear() {
- if (mIsMosaicMemoryAllocated) {
- mMosaicer.freeMosaicMemory();
- mIsMosaicMemoryAllocated = false;
- }
- synchronized (this) {
- notify();
- }
- }
-
- public boolean isMosaicMemoryAllocated() {
- return mIsMosaicMemoryAllocated;
- }
-
- public void setStripType(int type) {
- mMosaicer.setStripType(type);
- }
-
- private void setupMosaicer(int previewWidth, int previewHeight, int bufSize) {
- Log.v(TAG, "setupMosaicer w, h=" + previewWidth + ',' + previewHeight + ',' + bufSize);
-
- if (mIsMosaicMemoryAllocated) throw new RuntimeException("MosaicFrameProcessor in use!");
- mIsMosaicMemoryAllocated = true;
- mMosaicer.allocateMosaicMemory(previewWidth, previewHeight);
- }
-
- public void reset() {
- // reset() can be called even if MosaicFrameProcessor is not initialized.
- // Only counters will be changed.
- mFirstRun = true;
- mTotalFrameCount = 0;
- mFillIn = 0;
- mTotalTranslationX = 0;
- mTranslationLastX = 0;
- mTotalTranslationY = 0;
- mTranslationLastY = 0;
- mPanningRateX = 0;
- mPanningRateY = 0;
- mLastProcessFrameIdx = -1;
- mCurrProcessFrameIdx = -1;
- for (int i = 0; i < WINDOW_SIZE; ++i) {
- mDeltaX[i] = 0f;
- mDeltaY[i] = 0f;
- }
- mMosaicer.reset();
- }
-
- public int createMosaic(boolean highRes) {
- return mMosaicer.createMosaic(highRes);
- }
-
- public byte[] getFinalMosaicNV21() {
- return mMosaicer.getFinalMosaicNV21();
- }
-
- // Processes the last filled image frame through the mosaicer and
- // updates the UI to show progress.
- // When done, processes and displays the final mosaic.
- public void processFrame() {
- if (!mIsMosaicMemoryAllocated) {
- // clear() is called and buffers are cleared, stop computation.
- // This can happen when the onPause() is called in the activity, but still some frames
- // are not processed yet and thus the callback may be invoked.
- return;
- }
-
- mCurrProcessFrameIdx = mFillIn;
- mFillIn = ((mFillIn + 1) % NUM_FRAMES_IN_BUFFER);
-
- // Check that we are trying to process a frame different from the
- // last one processed (useful if this class was running asynchronously)
- if (mCurrProcessFrameIdx != mLastProcessFrameIdx) {
- mLastProcessFrameIdx = mCurrProcessFrameIdx;
-
- // TODO: make the termination condition regarding reaching
- // MAX_NUMBER_OF_FRAMES solely determined in the library.
- if (mTotalFrameCount < MAX_NUMBER_OF_FRAMES) {
- // If we are still collecting new frames for the current mosaic,
- // process the new frame.
- calculateTranslationRate();
-
- // Publish progress of the ongoing processing
- if (mProgressListener != null) {
- mProgressListener.onProgress(false, mPanningRateX, mPanningRateY,
- mTranslationLastX * HR_TO_LR_DOWNSAMPLE_FACTOR / mPreviewWidth,
- mTranslationLastY * HR_TO_LR_DOWNSAMPLE_FACTOR / mPreviewHeight);
- }
- } else {
- if (mProgressListener != null) {
- mProgressListener.onProgress(true, mPanningRateX, mPanningRateY,
- mTranslationLastX * HR_TO_LR_DOWNSAMPLE_FACTOR / mPreviewWidth,
- mTranslationLastY * HR_TO_LR_DOWNSAMPLE_FACTOR / mPreviewHeight);
- }
- }
- }
- }
-
- public void calculateTranslationRate() {
- float[] frameData = mMosaicer.setSourceImageFromGPU();
- int ret_code = (int) frameData[MOSAIC_RET_CODE_INDEX];
- mTotalFrameCount = (int) frameData[FRAME_COUNT_INDEX];
- float translationCurrX = frameData[X_COORD_INDEX];
- float translationCurrY = frameData[Y_COORD_INDEX];
-
- if (mFirstRun) {
- // First time: no need to update delta values.
- mTranslationLastX = translationCurrX;
- mTranslationLastY = translationCurrY;
- mFirstRun = false;
- return;
- }
-
- // Moving average: remove the oldest translation/deltaTime and
- // add the newest translation/deltaTime in
- int idx = mOldestIdx;
- mTotalTranslationX -= mDeltaX[idx];
- mTotalTranslationY -= mDeltaY[idx];
- mDeltaX[idx] = Math.abs(translationCurrX - mTranslationLastX);
- mDeltaY[idx] = Math.abs(translationCurrY - mTranslationLastY);
- mTotalTranslationX += mDeltaX[idx];
- mTotalTranslationY += mDeltaY[idx];
-
- // The panning rate is measured as the rate of the translation percentage in
- // image width/height. Take the horizontal panning rate for example, the image width
- // used in finding the translation is (PreviewWidth / HR_TO_LR_DOWNSAMPLE_FACTOR).
- // To get the horizontal translation percentage, the horizontal translation,
- // (translationCurrX - mTranslationLastX), is divided by the
- // image width. We then get the rate by dividing the translation percentage with the
- // number of frames.
- mPanningRateX = mTotalTranslationX /
- (mPreviewWidth / HR_TO_LR_DOWNSAMPLE_FACTOR) / WINDOW_SIZE;
- mPanningRateY = mTotalTranslationY /
- (mPreviewHeight / HR_TO_LR_DOWNSAMPLE_FACTOR) / WINDOW_SIZE;
-
- mTranslationLastX = translationCurrX;
- mTranslationLastY = translationCurrY;
- mOldestIdx = (mOldestIdx + 1) % WINDOW_SIZE;
- }
-}
diff --git a/src/com/android/camera/MosaicPreviewRenderer.java b/src/com/android/camera/MosaicPreviewRenderer.java
deleted file mode 100644
index 26ce733..0000000
--- a/src/com/android/camera/MosaicPreviewRenderer.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import android.annotation.TargetApi;
-import android.graphics.SurfaceTexture;
-import android.os.ConditionVariable;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Message;
-import android.util.Log;
-
-import com.android.gallery3d.common.ApiHelper;
-
-import javax.microedition.khronos.egl.EGL10;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.egl.EGLContext;
-import javax.microedition.khronos.egl.EGLDisplay;
-import javax.microedition.khronos.egl.EGLSurface;
-import javax.microedition.khronos.opengles.GL10;
-
-@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) // uses SurfaceTexture
-public class MosaicPreviewRenderer {
- private static final String TAG = "MosaicPreviewRenderer";
- private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
- private static final boolean DEBUG = false;
-
- private int mWidth; // width of the view in UI
- private int mHeight; // height of the view in UI
-
- private boolean mIsLandscape = true;
- private final float[] mTransformMatrix = new float[16];
-
- private ConditionVariable mEglThreadBlockVar = new ConditionVariable();
- private HandlerThread mEglThread;
- private EGLHandler mEglHandler;
-
- private EGLConfig mEglConfig;
- private EGLDisplay mEglDisplay;
- private EGLContext mEglContext;
- private EGLSurface mEglSurface;
- private SurfaceTexture mMosaicOutputSurfaceTexture;
- private SurfaceTexture mInputSurfaceTexture;
- private EGL10 mEgl;
- private GL10 mGl;
-
- private class EGLHandler extends Handler {
- public static final int MSG_INIT_EGL_SYNC = 0;
- public static final int MSG_SHOW_PREVIEW_FRAME_SYNC = 1;
- public static final int MSG_SHOW_PREVIEW_FRAME = 2;
- public static final int MSG_ALIGN_FRAME_SYNC = 3;
- public static final int MSG_RELEASE = 4;
-
- public EGLHandler(Looper looper) {
- super(looper);
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_INIT_EGL_SYNC:
- doInitGL();
- mEglThreadBlockVar.open();
- break;
- case MSG_SHOW_PREVIEW_FRAME_SYNC:
- doShowPreviewFrame();
- mEglThreadBlockVar.open();
- break;
- case MSG_SHOW_PREVIEW_FRAME:
- doShowPreviewFrame();
- break;
- case MSG_ALIGN_FRAME_SYNC:
- doAlignFrame();
- mEglThreadBlockVar.open();
- break;
- case MSG_RELEASE:
- doRelease();
- mEglThreadBlockVar.open();
- break;
- }
- }
-
- private void doAlignFrame() {
- mInputSurfaceTexture.updateTexImage();
- mInputSurfaceTexture.getTransformMatrix(mTransformMatrix);
-
- MosaicRenderer.setWarping(true);
- // Call preprocess to render it to low-res and high-res RGB textures.
- MosaicRenderer.preprocess(mTransformMatrix);
- // Now, transfer the textures from GPU to CPU memory for processing
- MosaicRenderer.transferGPUtoCPU();
- MosaicRenderer.updateMatrix();
- draw();
- mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
- }
-
- private void doShowPreviewFrame() {
- mInputSurfaceTexture.updateTexImage();
- mInputSurfaceTexture.getTransformMatrix(mTransformMatrix);
-
- MosaicRenderer.setWarping(false);
- // Call preprocess to render it to low-res and high-res RGB textures.
- MosaicRenderer.preprocess(mTransformMatrix);
- MosaicRenderer.updateMatrix();
- draw();
- mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
- }
-
- private void doInitGL() {
- // These are copied from GLSurfaceView
- mEgl = (EGL10) EGLContext.getEGL();
- mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
- if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
- throw new RuntimeException("eglGetDisplay failed");
- }
- int[] version = new int[2];
- if (!mEgl.eglInitialize(mEglDisplay, version)) {
- throw new RuntimeException("eglInitialize failed");
- } else {
- Log.v(TAG, "EGL version: " + version[0] + '.' + version[1]);
- }
- int[] attribList = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
- mEglConfig = chooseConfig(mEgl, mEglDisplay);
- mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig, EGL10.EGL_NO_CONTEXT,
- attribList);
-
- if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
- throw new RuntimeException("failed to createContext");
- }
- mEglSurface = mEgl.eglCreateWindowSurface(
- mEglDisplay, mEglConfig, mMosaicOutputSurfaceTexture, null);
- if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) {
- throw new RuntimeException("failed to createWindowSurface");
- }
-
- if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
- throw new RuntimeException("failed to eglMakeCurrent");
- }
-
- mGl = (GL10) mEglContext.getGL();
-
- mInputSurfaceTexture = new SurfaceTexture(MosaicRenderer.init());
- MosaicRenderer.reset(mWidth, mHeight, mIsLandscape);
- }
-
- private void doRelease() {
- mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
- mEgl.eglDestroyContext(mEglDisplay, mEglContext);
- mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE,
- EGL10.EGL_NO_CONTEXT);
- mEgl.eglTerminate(mEglDisplay);
- mEglSurface = null;
- mEglContext = null;
- mEglDisplay = null;
- releaseSurfaceTexture(mInputSurfaceTexture);
- mEglThread.quit();
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void releaseSurfaceTexture(SurfaceTexture st) {
- if (ApiHelper.HAS_RELEASE_SURFACE_TEXTURE) {
- st.release();
- }
- }
-
- // Should be called from other thread.
- public void sendMessageSync(int msg) {
- mEglThreadBlockVar.close();
- sendEmptyMessage(msg);
- mEglThreadBlockVar.block();
- }
-
- }
-
- public MosaicPreviewRenderer(SurfaceTexture tex, int w, int h, boolean isLandscape) {
- mMosaicOutputSurfaceTexture = tex;
- mWidth = w;
- mHeight = h;
- mIsLandscape = isLandscape;
-
- mEglThread = new HandlerThread("PanoramaRealtimeRenderer");
- mEglThread.start();
- mEglHandler = new EGLHandler(mEglThread.getLooper());
-
- // We need to sync this because the generation of surface texture for input is
- // done here and the client will continue with the assumption that the
- // generation is completed.
- mEglHandler.sendMessageSync(EGLHandler.MSG_INIT_EGL_SYNC);
- }
-
- public void release() {
- mEglHandler.sendMessageSync(EGLHandler.MSG_RELEASE);
- }
-
- public void showPreviewFrameSync() {
- mEglHandler.sendMessageSync(EGLHandler.MSG_SHOW_PREVIEW_FRAME_SYNC);
- }
-
- public void showPreviewFrame() {
- mEglHandler.sendEmptyMessage(EGLHandler.MSG_SHOW_PREVIEW_FRAME);
- }
-
- public void alignFrameSync() {
- mEglHandler.sendMessageSync(EGLHandler.MSG_ALIGN_FRAME_SYNC);
- }
-
- public SurfaceTexture getInputSurfaceTexture() {
- return mInputSurfaceTexture;
- }
-
- private void draw() {
- MosaicRenderer.step();
- }
-
- private static void checkEglError(String prompt, EGL10 egl) {
- int error;
- while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
- Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
- }
- }
-
- private static final int EGL_OPENGL_ES2_BIT = 4;
- private static final int[] CONFIG_SPEC = new int[] {
- EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL10.EGL_RED_SIZE, 8,
- EGL10.EGL_GREEN_SIZE, 8,
- EGL10.EGL_BLUE_SIZE, 8,
- EGL10.EGL_NONE
- };
-
- private static EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
- int[] numConfig = new int[1];
- if (!egl.eglChooseConfig(display, CONFIG_SPEC, null, 0, numConfig)) {
- throw new IllegalArgumentException("eglChooseConfig failed");
- }
-
- int numConfigs = numConfig[0];
- if (numConfigs <= 0) {
- throw new IllegalArgumentException("No configs match configSpec");
- }
-
- EGLConfig[] configs = new EGLConfig[numConfigs];
- if (!egl.eglChooseConfig(
- display, CONFIG_SPEC, configs, numConfigs, numConfig)) {
- throw new IllegalArgumentException("eglChooseConfig#2 failed");
- }
-
- return configs[0];
- }
-}
diff --git a/src/com/android/camera/MosaicRenderer.java b/src/com/android/camera/MosaicRenderer.java
deleted file mode 100644
index c50ca0d..0000000
--- a/src/com/android/camera/MosaicRenderer.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-/**
- * The Java interface to JNI calls regarding mosaic preview rendering.
- *
- */
-public class MosaicRenderer
-{
- static
- {
- System.loadLibrary("jni_mosaic");
- }
-
- /**
- * Function to be called in onSurfaceCreated() to initialize
- * the GL context, load and link the shaders and create the
- * program. Returns a texture ID to be used for SurfaceTexture.
- *
- * @return textureID the texture ID of the newly generated texture to
- * be assigned to the SurfaceTexture object.
- */
- public static native int init();
-
- /**
- * Pass the drawing surface's width and height to initialize the
- * renderer viewports and FBO dimensions.
- *
- * @param width width of the drawing surface in pixels.
- * @param height height of the drawing surface in pixels.
- * @param isLandscapeOrientation is the orientation of the activity layout in landscape.
- */
- public static native void reset(int width, int height, boolean isLandscapeOrientation);
-
- /**
- * Calling this function will render the SurfaceTexture to a new 2D texture
- * using the provided STMatrix.
- *
- * @param stMatrix texture coordinate transform matrix obtained from the
- * Surface texture
- */
- public static native void preprocess(float[] stMatrix);
-
- /**
- * This function calls glReadPixels to transfer both the low-res and high-res
- * data from the GPU memory to the CPU memory for further processing by the
- * mosaicing library.
- */
- public static native void transferGPUtoCPU();
-
- /**
- * Function to be called in onDrawFrame() to update the screen with
- * the new frame data.
- */
- public static native void step();
-
- /**
- * Call this function when a new low-res frame has been processed by
- * the mosaicing library. This will tell the renderer library to
- * update its texture and warping transformation. Any calls to step()
- * after this call will use the new image frame and transformation data.
- */
- public static native void updateMatrix();
-
- /**
- * This function allows toggling between showing the input image data
- * (without applying any warp) and the warped image data. For running
- * the renderer as a viewfinder, we set the flag to false. To see the
- * preview mosaic, we set the flag to true.
- *
- * @param flag boolean flag to set the warping to true or false.
- */
- public static native void setWarping(boolean flag);
-}
diff --git a/src/com/android/camera/OnClickAttr.java b/src/com/android/camera/OnClickAttr.java
deleted file mode 100644
index 07a1063..0000000
--- a/src/com/android/camera/OnClickAttr.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-/**
- * Interface for OnClickAttr annotation.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface OnClickAttr {
-}
diff --git a/src/com/android/camera/OnScreenHint.java b/src/com/android/camera/OnScreenHint.java
deleted file mode 100644
index 4d7fa70..0000000
--- a/src/com/android/camera/OnScreenHint.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.content.Context;
-import android.graphics.PixelFormat;
-import android.os.Handler;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.TextView;
-
-import com.android.gallery3d.R;
-
-/**
- * A on-screen hint is a view containing a little message for the user and will
- * be shown on the screen continuously. This class helps you create and show
- * those.
- *
- * <p>
- * When the view is shown to the user, appears as a floating view over the
- * application.
- * <p>
- * The easiest way to use this class is to call one of the static methods that
- * constructs everything you need and returns a new {@code OnScreenHint} object.
- */
-public class OnScreenHint {
- static final String TAG = "OnScreenHint";
-
- int mGravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
- int mX, mY;
- float mHorizontalMargin;
- float mVerticalMargin;
- View mView;
- View mNextView;
-
- private final WindowManager.LayoutParams mParams =
- new WindowManager.LayoutParams();
- private final WindowManager mWM;
- private final Handler mHandler = new Handler();
-
- /**
- * Construct an empty OnScreenHint object.
- *
- * @param context The context to use. Usually your
- * {@link android.app.Application} or
- * {@link android.app.Activity} object.
- */
- private OnScreenHint(Context context) {
- mWM = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- mY = context.getResources().getDimensionPixelSize(
- R.dimen.hint_y_offset);
-
- mParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
- mParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
- mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
- | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
- mParams.format = PixelFormat.TRANSLUCENT;
- mParams.windowAnimations = R.style.Animation_OnScreenHint;
- mParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
- mParams.setTitle("OnScreenHint");
- }
-
- /**
- * Show the view on the screen.
- */
- public void show() {
- if (mNextView == null) {
- throw new RuntimeException("View is not initialized");
- }
- mHandler.post(mShow);
- }
-
- /**
- * Close the view if it's showing.
- */
- public void cancel() {
- mHandler.post(mHide);
- }
-
- /**
- * Make a standard hint that just contains a text view.
- *
- * @param context The context to use. Usually your
- * {@link android.app.Application} or
- * {@link android.app.Activity} object.
- * @param text The text to show. Can be formatted text.
- *
- */
- public static OnScreenHint makeText(Context context, CharSequence text) {
- OnScreenHint result = new OnScreenHint(context);
-
- LayoutInflater inflate =
- (LayoutInflater) context.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- View v = inflate.inflate(R.layout.on_screen_hint, null);
- TextView tv = (TextView) v.findViewById(R.id.message);
- tv.setText(text);
-
- result.mNextView = v;
-
- return result;
- }
-
- /**
- * Update the text in a OnScreenHint that was previously created using one
- * of the makeText() methods.
- * @param s The new text for the OnScreenHint.
- */
- public void setText(CharSequence s) {
- if (mNextView == null) {
- throw new RuntimeException("This OnScreenHint was not "
- + "created with OnScreenHint.makeText()");
- }
- TextView tv = (TextView) mNextView.findViewById(R.id.message);
- if (tv == null) {
- throw new RuntimeException("This OnScreenHint was not "
- + "created with OnScreenHint.makeText()");
- }
- tv.setText(s);
- }
-
- private synchronized void handleShow() {
- if (mView != mNextView) {
- // remove the old view if necessary
- handleHide();
- mView = mNextView;
- final int gravity = mGravity;
- mParams.gravity = gravity;
- if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK)
- == Gravity.FILL_HORIZONTAL) {
- mParams.horizontalWeight = 1.0f;
- }
- if ((gravity & Gravity.VERTICAL_GRAVITY_MASK)
- == Gravity.FILL_VERTICAL) {
- mParams.verticalWeight = 1.0f;
- }
- mParams.x = mX;
- mParams.y = mY;
- mParams.verticalMargin = mVerticalMargin;
- mParams.horizontalMargin = mHorizontalMargin;
- if (mView.getParent() != null) {
- mWM.removeView(mView);
- }
- mWM.addView(mView, mParams);
- }
- }
-
- private synchronized void handleHide() {
- if (mView != null) {
- // note: checking parent() just to make sure the view has
- // been added... i have seen cases where we get here when
- // the view isn't yet added, so let's try not to crash.
- if (mView.getParent() != null) {
- mWM.removeView(mView);
- }
- mView = null;
- }
- }
-
- private final Runnable mShow = new Runnable() {
- @Override
- public void run() {
- handleShow();
- }
- };
-
- private final Runnable mHide = new Runnable() {
- @Override
- public void run() {
- handleHide();
- }
- };
-}
-
diff --git a/src/com/android/camera/OnScreenIndicators.java b/src/com/android/camera/OnScreenIndicators.java
deleted file mode 100644
index 77c8faf..0000000
--- a/src/com/android/camera/OnScreenIndicators.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * 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.camera;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.hardware.Camera;
-import android.hardware.Camera.Parameters;
-import android.view.View;
-import android.widget.ImageView;
-
-import com.android.gallery3d.R;
-
-/**
- * The on-screen indicators of the pie menu button. They show the camera
- * settings in the viewfinder.
- */
-public class OnScreenIndicators {
- private final int[] mWBArray;
- private final View mOnScreenIndicators;
- private final ImageView mExposureIndicator;
- private final ImageView mFlashIndicator;
- private final ImageView mSceneIndicator;
- private final ImageView mLocationIndicator;
- private final ImageView mTimerIndicator;
- private final ImageView mWBIndicator;
-
- public OnScreenIndicators(Context ctx, View onScreenIndicatorsView) {
- TypedArray iconIds = ctx.getResources().obtainTypedArray(
- R.array.camera_wb_indicators);
- final int n = iconIds.length();
- mWBArray = new int[n];
- for (int i = 0; i < n; i++) {
- mWBArray[i] = iconIds.getResourceId(i, R.drawable.ic_indicator_wb_off);
- }
- mOnScreenIndicators = onScreenIndicatorsView;
- mExposureIndicator = (ImageView) onScreenIndicatorsView.findViewById(
- R.id.menu_exposure_indicator);
- mFlashIndicator = (ImageView) onScreenIndicatorsView.findViewById(
- R.id.menu_flash_indicator);
- mSceneIndicator = (ImageView) onScreenIndicatorsView.findViewById(
- R.id.menu_scenemode_indicator);
- mLocationIndicator = (ImageView) onScreenIndicatorsView.findViewById(
- R.id.menu_location_indicator);
- mTimerIndicator = (ImageView) onScreenIndicatorsView.findViewById(
- R.id.menu_timer_indicator);
- mWBIndicator = (ImageView) onScreenIndicatorsView.findViewById(
- R.id.menu_wb_indicator);
- }
-
- /**
- * Resets all indicators to show the default values.
- */
- public void resetToDefault() {
- updateExposureOnScreenIndicator(0);
- updateFlashOnScreenIndicator(Parameters.FLASH_MODE_OFF);
- updateSceneOnScreenIndicator(Parameters.SCENE_MODE_AUTO);
- updateWBIndicator(2);
- updateTimerIndicator(false);
- updateLocationIndicator(false);
- }
-
- /**
- * Sets the exposure indicator using exposure compensations step rounding.
- */
- public void updateExposureOnScreenIndicator(Camera.Parameters params, int value) {
- if (mExposureIndicator == null) {
- return;
- }
- float step = params.getExposureCompensationStep();
- value = Math.round(value * step);
- updateExposureOnScreenIndicator(value);
- }
-
- /**
- * Set the exposure indicator to the given value.
- *
- * @param value Value between -3 and 3. If outside this range, 0 is used by
- * default.
- */
- public void updateExposureOnScreenIndicator(int value) {
- int id = 0;
- switch(value) {
- case -3:
- id = R.drawable.ic_indicator_ev_n3;
- break;
- case -2:
- id = R.drawable.ic_indicator_ev_n2;
- break;
- case -1:
- id = R.drawable.ic_indicator_ev_n1;
- break;
- case 0:
- id = R.drawable.ic_indicator_ev_0;
- break;
- case 1:
- id = R.drawable.ic_indicator_ev_p1;
- break;
- case 2:
- id = R.drawable.ic_indicator_ev_p2;
- break;
- case 3:
- id = R.drawable.ic_indicator_ev_p3;
- break;
- }
- mExposureIndicator.setImageResource(id);
- }
-
- public void updateWBIndicator(int wbIndex) {
- if (mWBIndicator == null) return;
- mWBIndicator.setImageResource(mWBArray[wbIndex]);
- }
-
- public void updateTimerIndicator(boolean on) {
- if (mTimerIndicator == null) return;
- mTimerIndicator.setImageResource(on ? R.drawable.ic_indicator_timer_on
- : R.drawable.ic_indicator_timer_off);
- }
-
- public void updateLocationIndicator(boolean on) {
- if (mLocationIndicator == null) return;
- mLocationIndicator.setImageResource(on ? R.drawable.ic_indicator_loc_on
- : R.drawable.ic_indicator_loc_off);
- }
-
- /**
- * Set the flash indicator to the given value.
- *
- * @param value One of Parameters.FLASH_MODE_OFF,
- * Parameters.FLASH_MODE_AUTO, Parameters.FLASH_MODE_ON.
- */
- public void updateFlashOnScreenIndicator(String value) {
- if (mFlashIndicator == null) {
- return;
- }
- if (value == null || Parameters.FLASH_MODE_OFF.equals(value)) {
- mFlashIndicator.setImageResource(R.drawable.ic_indicator_flash_off);
- } else {
- if (Parameters.FLASH_MODE_AUTO.equals(value)) {
- mFlashIndicator.setImageResource(R.drawable.ic_indicator_flash_auto);
- } else if (Parameters.FLASH_MODE_ON.equals(value)
- || Parameters.FLASH_MODE_TORCH.equals(value)) {
- mFlashIndicator.setImageResource(R.drawable.ic_indicator_flash_on);
- } else {
- mFlashIndicator.setImageResource(R.drawable.ic_indicator_flash_off);
- }
- }
- }
-
- /**
- * Set the scene indicator depending on the given scene mode.
- *
- * @param value the current Parameters.SCENE_MODE_* value.
- */
- public void updateSceneOnScreenIndicator(String value) {
- if (mSceneIndicator == null) {
- return;
- }
- if ((value == null) || Parameters.SCENE_MODE_AUTO.equals(value)) {
- mSceneIndicator.setImageResource(R.drawable.ic_indicator_sce_off);
- } else if (Parameters.SCENE_MODE_HDR.equals(value)) {
- mSceneIndicator.setImageResource(R.drawable.ic_indicator_sce_hdr);
- } else {
- mSceneIndicator.setImageResource(R.drawable.ic_indicator_sce_on);
- }
- }
-
- /**
- * Sets the visibility of all indicators.
- *
- * @param visibility View.VISIBLE, View.GONE etc.
- */
- public void setVisibility(int visibility) {
- mOnScreenIndicators.setVisibility(visibility);
- }
-}
diff --git a/src/com/android/camera/PanoProgressBar.java b/src/com/android/camera/PanoProgressBar.java
deleted file mode 100644
index 8dfb366..0000000
--- a/src/com/android/camera/PanoProgressBar.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.RectF;
-import android.util.AttributeSet;
-import android.widget.ImageView;
-
-class PanoProgressBar extends ImageView {
- @SuppressWarnings("unused")
- private static final String TAG = "PanoProgressBar";
- public static final int DIRECTION_NONE = 0;
- public static final int DIRECTION_LEFT = 1;
- public static final int DIRECTION_RIGHT = 2;
- private float mProgress = 0;
- private float mMaxProgress = 0;
- private float mLeftMostProgress = 0;
- private float mRightMostProgress = 0;
- private float mProgressOffset = 0;
- private float mIndicatorWidth = 0;
- private int mDirection = 0;
- private final Paint mBackgroundPaint = new Paint();
- private final Paint mDoneAreaPaint = new Paint();
- private final Paint mIndicatorPaint = new Paint();
- private float mWidth;
- private float mHeight;
- private RectF mDrawBounds;
- private OnDirectionChangeListener mListener = null;
-
- public interface OnDirectionChangeListener {
- public void onDirectionChange(int direction);
- }
-
- public PanoProgressBar(Context context, AttributeSet attrs) {
- super(context, attrs);
- mDoneAreaPaint.setStyle(Paint.Style.FILL);
- mDoneAreaPaint.setAlpha(0xff);
-
- mBackgroundPaint.setStyle(Paint.Style.FILL);
- mBackgroundPaint.setAlpha(0xff);
-
- mIndicatorPaint.setStyle(Paint.Style.FILL);
- mIndicatorPaint.setAlpha(0xff);
-
- mDrawBounds = new RectF();
- }
-
- public void setOnDirectionChangeListener(OnDirectionChangeListener l) {
- mListener = l;
- }
-
- private void setDirection(int direction) {
- if (mDirection != direction) {
- mDirection = direction;
- if (mListener != null) {
- mListener.onDirectionChange(mDirection);
- }
- invalidate();
- }
- }
-
- public int getDirection() {
- return mDirection;
- }
-
- @Override
- public void setBackgroundColor(int color) {
- mBackgroundPaint.setColor(color);
- invalidate();
- }
-
- public void setDoneColor(int color) {
- mDoneAreaPaint.setColor(color);
- invalidate();
- }
-
- public void setIndicatorColor(int color) {
- mIndicatorPaint.setColor(color);
- invalidate();
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- mWidth = w;
- mHeight = h;
- mDrawBounds.set(0, 0, mWidth, mHeight);
- }
-
- public void setMaxProgress(int progress) {
- mMaxProgress = progress;
- }
-
- public void setIndicatorWidth(float w) {
- mIndicatorWidth = w;
- invalidate();
- }
-
- public void setRightIncreasing(boolean rightIncreasing) {
- if (rightIncreasing) {
- mLeftMostProgress = 0;
- mRightMostProgress = 0;
- mProgressOffset = 0;
- setDirection(DIRECTION_RIGHT);
- } else {
- mLeftMostProgress = mWidth;
- mRightMostProgress = mWidth;
- mProgressOffset = mWidth;
- setDirection(DIRECTION_LEFT);
- }
- invalidate();
- }
-
- public void setProgress(int progress) {
- // The panning direction will be decided after user pan more than 10 degrees in one
- // direction.
- if (mDirection == DIRECTION_NONE) {
- if (progress > 10) {
- setRightIncreasing(true);
- } else if (progress < -10) {
- setRightIncreasing(false);
- }
- }
- // mDirection might be modified by setRightIncreasing() above. Need to check again.
- if (mDirection != DIRECTION_NONE) {
- mProgress = progress * mWidth / mMaxProgress + mProgressOffset;
- // value bounds.
- mProgress = Math.min(mWidth, Math.max(0, mProgress));
- if (mDirection == DIRECTION_RIGHT) {
- // The right most progress is adjusted.
- mRightMostProgress = Math.max(mRightMostProgress, mProgress);
- }
- if (mDirection == DIRECTION_LEFT) {
- // The left most progress is adjusted.
- mLeftMostProgress = Math.min(mLeftMostProgress, mProgress);
- }
- invalidate();
- }
- }
-
- public void reset() {
- mProgress = 0;
- mProgressOffset = 0;
- setDirection(DIRECTION_NONE);
- invalidate();
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- // the background
- canvas.drawRect(mDrawBounds, mBackgroundPaint);
- if (mDirection != DIRECTION_NONE) {
- // the progress area
- canvas.drawRect(mLeftMostProgress, mDrawBounds.top, mRightMostProgress,
- mDrawBounds.bottom, mDoneAreaPaint);
- // the indication bar
- float l;
- float r;
- if (mDirection == DIRECTION_RIGHT) {
- l = Math.max(mProgress - mIndicatorWidth, 0f);
- r = mProgress;
- } else {
- l = mProgress;
- r = Math.min(mProgress + mIndicatorWidth, mWidth);
- }
- canvas.drawRect(l, mDrawBounds.top, r, mDrawBounds.bottom, mIndicatorPaint);
- }
-
- // draw the mask image on the top for shaping.
- super.onDraw(canvas);
- }
-}
diff --git a/src/com/android/camera/PanoUtil.java b/src/com/android/camera/PanoUtil.java
deleted file mode 100644
index e50eacc..0000000
--- a/src/com/android/camera/PanoUtil.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class PanoUtil {
- public static String createName(String format, long dateTaken) {
- Date date = new Date(dateTaken);
- SimpleDateFormat dateFormat = new SimpleDateFormat(format);
- return dateFormat.format(date);
- }
-
- // TODO: Add comments about the range of these two arguments.
- public static double calculateDifferenceBetweenAngles(double firstAngle,
- double secondAngle) {
- double difference1 = (secondAngle - firstAngle) % 360;
- if (difference1 < 0) {
- difference1 += 360;
- }
-
- double difference2 = (firstAngle - secondAngle) % 360;
- if (difference2 < 0) {
- difference2 += 360;
- }
-
- return Math.min(difference1, difference2);
- }
-
- public static void decodeYUV420SPQuarterRes(int[] rgb, byte[] yuv420sp, int width, int height) {
- final int frameSize = width * height;
-
- for (int j = 0, ypd = 0; j < height; j += 4) {
- int uvp = frameSize + (j >> 1) * width, u = 0, v = 0;
- for (int i = 0; i < width; i += 4, ypd++) {
- int y = (0xff & (yuv420sp[j * width + i])) - 16;
- if (y < 0) {
- y = 0;
- }
- if ((i & 1) == 0) {
- v = (0xff & yuv420sp[uvp++]) - 128;
- u = (0xff & yuv420sp[uvp++]) - 128;
- uvp += 2; // Skip the UV values for the 4 pixels skipped in between
- }
- int y1192 = 1192 * y;
- int r = (y1192 + 1634 * v);
- int g = (y1192 - 833 * v - 400 * u);
- int b = (y1192 + 2066 * u);
-
- if (r < 0) {
- r = 0;
- } else if (r > 262143) {
- r = 262143;
- }
- if (g < 0) {
- g = 0;
- } else if (g > 262143) {
- g = 262143;
- }
- if (b < 0) {
- b = 0;
- } else if (b > 262143) {
- b = 262143;
- }
-
- rgb[ypd] = 0xff000000 | ((r << 6) & 0xff0000) | ((g >> 2) & 0xff00) |
- ((b >> 10) & 0xff);
- }
- }
- }
-}
diff --git a/src/com/android/camera/PanoramaModule.java b/src/com/android/camera/PanoramaModule.java
deleted file mode 100644
index 007ea7a..0000000
--- a/src/com/android/camera/PanoramaModule.java
+++ /dev/null
@@ -1,1304 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import android.annotation.TargetApi;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.ImageFormat;
-import android.graphics.Matrix;
-import android.graphics.PixelFormat;
-import android.graphics.Rect;
-import android.graphics.SurfaceTexture;
-import android.graphics.YuvImage;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.hardware.Camera.Parameters;
-import android.hardware.Camera.Size;
-import android.location.Location;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Handler;
-import android.os.Message;
-import android.os.PowerManager;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.OrientationEventListener;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.android.camera.CameraManager.CameraProxy;
-import com.android.camera.ui.LayoutChangeNotifier;
-import com.android.camera.ui.LayoutNotifyView;
-import com.android.camera.ui.PopupManager;
-import com.android.camera.ui.Rotatable;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.exif.ExifInterface;
-import com.android.gallery3d.exif.ExifTag;
-import com.android.gallery3d.ui.GLRootView;
-import com.android.gallery3d.util.UsageStatistics;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- * Activity to handle panorama capturing.
- */
-@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) // uses SurfaceTexture
-public class PanoramaModule implements CameraModule,
- SurfaceTexture.OnFrameAvailableListener,
- ShutterButton.OnShutterButtonListener,
- LayoutChangeNotifier.Listener {
-
- public static final int DEFAULT_SWEEP_ANGLE = 160;
- public static final int DEFAULT_BLEND_MODE = Mosaic.BLENDTYPE_HORIZONTAL;
- public static final int DEFAULT_CAPTURE_PIXELS = 960 * 720;
-
- private static final int MSG_LOW_RES_FINAL_MOSAIC_READY = 1;
- private static final int MSG_GENERATE_FINAL_MOSAIC_ERROR = 2;
- private static final int MSG_END_DIALOG_RESET_TO_PREVIEW = 3;
- private static final int MSG_CLEAR_SCREEN_DELAY = 4;
- private static final int MSG_CONFIG_MOSAIC_PREVIEW = 5;
- private static final int MSG_RESET_TO_PREVIEW = 6;
-
- private static final int SCREEN_DELAY = 2 * 60 * 1000;
-
- private static final String TAG = "CAM PanoModule";
- private static final int PREVIEW_STOPPED = 0;
- private static final int PREVIEW_ACTIVE = 1;
- private static final int CAPTURE_STATE_VIEWFINDER = 0;
- private static final int CAPTURE_STATE_MOSAIC = 1;
- // The unit of speed is degrees per frame.
- private static final float PANNING_SPEED_THRESHOLD = 2.5f;
-
- private ContentResolver mContentResolver;
-
- private GLRootView mGLRootView;
- private ViewGroup mPanoLayout;
- private LinearLayout mCaptureLayout;
- private View mReviewLayout;
- private ImageView mReview;
- private View mCaptureIndicator;
- private PanoProgressBar mPanoProgressBar;
- private PanoProgressBar mSavingProgressBar;
- private Matrix mProgressDirectionMatrix = new Matrix();
- private float[] mProgressAngle = new float[2];
- private LayoutNotifyView mPreviewArea;
- private View mLeftIndicator;
- private View mRightIndicator;
- private MosaicPreviewRenderer mMosaicPreviewRenderer;
- private Object mRendererLock = new Object();
- private TextView mTooFastPrompt;
- private ShutterButton mShutterButton;
- private Object mWaitObject = new Object();
-
- private String mPreparePreviewString;
- private String mDialogTitle;
- private String mDialogOkString;
- private String mDialogPanoramaFailedString;
- private String mDialogWaitingPreviousString;
-
- private int mIndicatorColor;
- private int mIndicatorColorFast;
- private int mReviewBackground;
-
- private boolean mUsingFrontCamera;
- private int mPreviewWidth;
- private int mPreviewHeight;
- private int mCameraState;
- private int mCaptureState;
- private PowerManager.WakeLock mPartialWakeLock;
- private MosaicFrameProcessor mMosaicFrameProcessor;
- private boolean mMosaicFrameProcessorInitialized;
- private AsyncTask <Void, Void, Void> mWaitProcessorTask;
- private long mTimeTaken;
- private Handler mMainHandler;
- private SurfaceTexture mCameraTexture;
- private boolean mThreadRunning;
- private boolean mCancelComputation;
- private float mHorizontalViewAngle;
- private float mVerticalViewAngle;
-
- // Prefer FOCUS_MODE_INFINITY to FOCUS_MODE_CONTINUOUS_VIDEO because of
- // getting a better image quality by the former.
- private String mTargetFocusMode = Parameters.FOCUS_MODE_INFINITY;
-
- private PanoOrientationEventListener mOrientationEventListener;
- // The value could be 0, 90, 180, 270 for the 4 different orientations measured in clockwise
- // respectively.
- private int mDeviceOrientation;
- private int mDeviceOrientationAtCapture;
- private int mCameraOrientation;
- private int mOrientationCompensation;
-
- private RotateDialogController mRotateDialog;
-
- private SoundClips.Player mSoundPlayer;
-
- private Runnable mOnFrameAvailableRunnable;
-
- private CameraActivity mActivity;
- private View mRootView;
- private CameraProxy mCameraDevice;
- private boolean mPaused;
- private boolean mIsCreatingRenderer;
-
- private LocationManager mLocationManager;
- private ComboPreferences mPreferences;
-
- private class MosaicJpeg {
- public MosaicJpeg(byte[] data, int width, int height) {
- this.data = data;
- this.width = width;
- this.height = height;
- this.isValid = true;
- }
-
- public MosaicJpeg() {
- this.data = null;
- this.width = 0;
- this.height = 0;
- this.isValid = false;
- }
-
- public final byte[] data;
- public final int width;
- public final int height;
- public final boolean isValid;
- }
-
- private class PanoOrientationEventListener extends OrientationEventListener {
- public PanoOrientationEventListener(Context context) {
- super(context);
- }
-
- @Override
- public void onOrientationChanged(int orientation) {
- // We keep the last known orientation. So if the user first orient
- // the camera then point the camera to floor or sky, we still have
- // the correct orientation.
- if (orientation == ORIENTATION_UNKNOWN) return;
- mDeviceOrientation = Util.roundOrientation(orientation, mDeviceOrientation);
- // When the screen is unlocked, display rotation may change. Always
- // calculate the up-to-date orientationCompensation.
- int orientationCompensation = mDeviceOrientation
- + Util.getDisplayRotation(mActivity) % 360;
- if (mOrientationCompensation != orientationCompensation) {
- mOrientationCompensation = orientationCompensation;
- mActivity.getGLRoot().requestLayoutContentPane();
- }
- }
- }
-
- @Override
- public void init(CameraActivity activity, View parent, boolean reuseScreenNail) {
- mActivity = activity;
- mRootView = parent;
-
- createContentView();
-
- mContentResolver = mActivity.getContentResolver();
- if (reuseScreenNail) {
- mActivity.reuseCameraScreenNail(true);
- } else {
- mActivity.createCameraScreenNail(true);
- }
-
- // This runs in UI thread.
- mOnFrameAvailableRunnable = new Runnable() {
- @Override
- public void run() {
- // Frames might still be available after the activity is paused.
- // If we call onFrameAvailable after pausing, the GL thread will crash.
- if (mPaused) return;
-
- MosaicPreviewRenderer renderer = null;
- synchronized (mRendererLock) {
- if (mMosaicPreviewRenderer == null) {
- return;
- }
- renderer = mMosaicPreviewRenderer;
- }
- if (mGLRootView.getVisibility() != View.VISIBLE) {
- renderer.showPreviewFrameSync();
- mGLRootView.setVisibility(View.VISIBLE);
- } else {
- if (mCaptureState == CAPTURE_STATE_VIEWFINDER) {
- renderer.showPreviewFrame();
- } else {
- renderer.alignFrameSync();
- mMosaicFrameProcessor.processFrame();
- }
- }
- }
- };
-
- PowerManager pm = (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE);
- mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Panorama");
-
- mOrientationEventListener = new PanoOrientationEventListener(mActivity);
-
- mMosaicFrameProcessor = MosaicFrameProcessor.getInstance();
-
- Resources appRes = mActivity.getResources();
- mPreparePreviewString = appRes.getString(R.string.pano_dialog_prepare_preview);
- mDialogTitle = appRes.getString(R.string.pano_dialog_title);
- mDialogOkString = appRes.getString(R.string.dialog_ok);
- mDialogPanoramaFailedString = appRes.getString(R.string.pano_dialog_panorama_failed);
- mDialogWaitingPreviousString = appRes.getString(R.string.pano_dialog_waiting_previous);
-
- mGLRootView = (GLRootView) mActivity.getGLRoot();
-
- mPreferences = new ComboPreferences(mActivity);
- CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal());
- mLocationManager = new LocationManager(mActivity, null);
-
- mMainHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_LOW_RES_FINAL_MOSAIC_READY:
- onBackgroundThreadFinished();
- showFinalMosaic((Bitmap) msg.obj);
- saveHighResMosaic();
- break;
- case MSG_GENERATE_FINAL_MOSAIC_ERROR:
- onBackgroundThreadFinished();
- if (mPaused) {
- resetToPreview();
- } else {
- mRotateDialog.showAlertDialog(
- mDialogTitle, mDialogPanoramaFailedString,
- mDialogOkString, new Runnable() {
- @Override
- public void run() {
- resetToPreview();
- }},
- null, null);
- }
- clearMosaicFrameProcessorIfNeeded();
- break;
- case MSG_END_DIALOG_RESET_TO_PREVIEW:
- onBackgroundThreadFinished();
- resetToPreview();
- clearMosaicFrameProcessorIfNeeded();
- break;
- case MSG_CLEAR_SCREEN_DELAY:
- mActivity.getWindow().clearFlags(WindowManager.LayoutParams.
- FLAG_KEEP_SCREEN_ON);
- break;
- case MSG_CONFIG_MOSAIC_PREVIEW:
- configMosaicPreview(msg.arg1, msg.arg2);
- break;
- case MSG_RESET_TO_PREVIEW:
- resetToPreview();
- break;
- }
- }
- };
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent m) {
- return mActivity.superDispatchTouchEvent(m);
- }
-
- private void setupCamera() throws CameraHardwareException, CameraDisabledException {
- openCamera();
- Parameters parameters = mCameraDevice.getParameters();
- setupCaptureParams(parameters);
- configureCamera(parameters);
- }
-
- private void releaseCamera() {
- if (mCameraDevice != null) {
- mCameraDevice.setPreviewCallbackWithBuffer(null);
- CameraHolder.instance().release();
- mCameraDevice = null;
- mCameraState = PREVIEW_STOPPED;
- }
- }
-
- private void openCamera() throws CameraHardwareException, CameraDisabledException {
- int cameraId = CameraHolder.instance().getBackCameraId();
- // If there is no back camera, use the first camera. Camera id starts
- // from 0. Currently if a camera is not back facing, it is front facing.
- // This is also forward compatible if we have a new facing other than
- // back or front in the future.
- if (cameraId == -1) cameraId = 0;
- mCameraDevice = Util.openCamera(mActivity, cameraId);
- mCameraOrientation = Util.getCameraOrientation(cameraId);
- if (cameraId == CameraHolder.instance().getFrontCameraId()) mUsingFrontCamera = true;
- }
-
- private boolean findBestPreviewSize(List<Size> supportedSizes, boolean need4To3,
- boolean needSmaller) {
- int pixelsDiff = DEFAULT_CAPTURE_PIXELS;
- boolean hasFound = false;
- for (Size size : supportedSizes) {
- int h = size.height;
- int w = size.width;
- // we only want 4:3 format.
- int d = DEFAULT_CAPTURE_PIXELS - h * w;
- if (needSmaller && d < 0) { // no bigger preview than 960x720.
- continue;
- }
- if (need4To3 && (h * 4 != w * 3)) {
- continue;
- }
- d = Math.abs(d);
- if (d < pixelsDiff) {
- mPreviewWidth = w;
- mPreviewHeight = h;
- pixelsDiff = d;
- hasFound = true;
- }
- }
- return hasFound;
- }
-
- private void setupCaptureParams(Parameters parameters) {
- List<Size> supportedSizes = parameters.getSupportedPreviewSizes();
- if (!findBestPreviewSize(supportedSizes, true, true)) {
- Log.w(TAG, "No 4:3 ratio preview size supported.");
- if (!findBestPreviewSize(supportedSizes, false, true)) {
- Log.w(TAG, "Can't find a supported preview size smaller than 960x720.");
- findBestPreviewSize(supportedSizes, false, false);
- }
- }
- Log.v(TAG, "preview h = " + mPreviewHeight + " , w = " + mPreviewWidth);
- parameters.setPreviewSize(mPreviewWidth, mPreviewHeight);
-
- List<int[]> frameRates = parameters.getSupportedPreviewFpsRange();
- int last = frameRates.size() - 1;
- int minFps = (frameRates.get(last))[Parameters.PREVIEW_FPS_MIN_INDEX];
- int maxFps = (frameRates.get(last))[Parameters.PREVIEW_FPS_MAX_INDEX];
- parameters.setPreviewFpsRange(minFps, maxFps);
- Log.v(TAG, "preview fps: " + minFps + ", " + maxFps);
-
- List<String> supportedFocusModes = parameters.getSupportedFocusModes();
- if (supportedFocusModes.indexOf(mTargetFocusMode) >= 0) {
- parameters.setFocusMode(mTargetFocusMode);
- } else {
- // Use the default focus mode and log a message
- Log.w(TAG, "Cannot set the focus mode to " + mTargetFocusMode +
- " becuase the mode is not supported.");
- }
-
- parameters.set(Util.RECORDING_HINT, Util.FALSE);
-
- mHorizontalViewAngle = parameters.getHorizontalViewAngle();
- mVerticalViewAngle = parameters.getVerticalViewAngle();
- }
-
- public int getPreviewBufSize() {
- PixelFormat pixelInfo = new PixelFormat();
- PixelFormat.getPixelFormatInfo(mCameraDevice.getParameters().getPreviewFormat(), pixelInfo);
- // TODO: remove this extra 32 byte after the driver bug is fixed.
- return (mPreviewWidth * mPreviewHeight * pixelInfo.bitsPerPixel / 8) + 32;
- }
-
- private void configureCamera(Parameters parameters) {
- mCameraDevice.setParameters(parameters);
- }
-
- private void configMosaicPreview(final int w, final int h) {
- synchronized (mRendererLock) {
- if (mIsCreatingRenderer) {
- mMainHandler.removeMessages(MSG_CONFIG_MOSAIC_PREVIEW);
- mMainHandler.obtainMessage(MSG_CONFIG_MOSAIC_PREVIEW, w, h).sendToTarget();
- return;
- }
- mIsCreatingRenderer = true;
- }
- stopCameraPreview();
- CameraScreenNail screenNail = (CameraScreenNail) mActivity.mCameraScreenNail;
- screenNail.setSize(w, h);
- synchronized (mRendererLock) {
- if (mMosaicPreviewRenderer != null) {
- mMosaicPreviewRenderer.release();
- }
- mMosaicPreviewRenderer = null;
- screenNail.releaseSurfaceTexture();
- screenNail.acquireSurfaceTexture();
- }
- mActivity.notifyScreenNailChanged();
- final boolean isLandscape = (mActivity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
- new Thread(new Runnable() {
- @Override
- public void run() {
- CameraScreenNail screenNail = (CameraScreenNail) mActivity.mCameraScreenNail;
- SurfaceTexture surfaceTexture = screenNail.getSurfaceTexture();
- if (surfaceTexture == null) {
- synchronized (mRendererLock) {
- mIsCreatingRenderer = false;
- mRendererLock.notifyAll();
- return;
- }
- }
- MosaicPreviewRenderer renderer = new MosaicPreviewRenderer(
- screenNail.getSurfaceTexture(), w, h, isLandscape);
- synchronized (mRendererLock) {
- mMosaicPreviewRenderer = renderer;
- mCameraTexture = mMosaicPreviewRenderer.getInputSurfaceTexture();
-
- if (!mPaused && !mThreadRunning && mWaitProcessorTask == null) {
- mMainHandler.sendEmptyMessage(MSG_RESET_TO_PREVIEW);
- }
- mIsCreatingRenderer = false;
- mRendererLock.notifyAll();
- }
- }
- }).start();
- }
-
- // Receives the layout change event from the preview area. So we can set
- // the camera preview screennail to the same size and initialize the mosaic
- // preview renderer.
- @Override
- public void onLayoutChange(View v, int l, int t, int r, int b) {
- Log.i(TAG, "layout change: "+(r - l) + "/" +(b - t));
- mActivity.onLayoutChange(v, l, t, r, b);
- configMosaicPreview(r - l, b - t);
- }
-
- @Override
- public void onFrameAvailable(SurfaceTexture surface) {
- /* This function may be called by some random thread,
- * so let's be safe and jump back to ui thread.
- * No OpenGL calls can be done here. */
- mActivity.runOnUiThread(mOnFrameAvailableRunnable);
- }
-
- private void hideDirectionIndicators() {
- mLeftIndicator.setVisibility(View.GONE);
- mRightIndicator.setVisibility(View.GONE);
- }
-
- private void showDirectionIndicators(int direction) {
- switch (direction) {
- case PanoProgressBar.DIRECTION_NONE:
- mLeftIndicator.setVisibility(View.VISIBLE);
- mRightIndicator.setVisibility(View.VISIBLE);
- break;
- case PanoProgressBar.DIRECTION_LEFT:
- mLeftIndicator.setVisibility(View.VISIBLE);
- mRightIndicator.setVisibility(View.GONE);
- break;
- case PanoProgressBar.DIRECTION_RIGHT:
- mLeftIndicator.setVisibility(View.GONE);
- mRightIndicator.setVisibility(View.VISIBLE);
- break;
- }
- }
-
- public void startCapture() {
- // Reset values so we can do this again.
- mCancelComputation = false;
- mTimeTaken = System.currentTimeMillis();
- mActivity.setSwipingEnabled(false);
- mActivity.hideSwitcher();
- mShutterButton.setImageResource(R.drawable.btn_shutter_recording);
- mCaptureState = CAPTURE_STATE_MOSAIC;
- mCaptureIndicator.setVisibility(View.VISIBLE);
- showDirectionIndicators(PanoProgressBar.DIRECTION_NONE);
-
- mMosaicFrameProcessor.setProgressListener(new MosaicFrameProcessor.ProgressListener() {
- @Override
- public void onProgress(boolean isFinished, float panningRateX, float panningRateY,
- float progressX, float progressY) {
- float accumulatedHorizontalAngle = progressX * mHorizontalViewAngle;
- float accumulatedVerticalAngle = progressY * mVerticalViewAngle;
- if (isFinished
- || (Math.abs(accumulatedHorizontalAngle) >= DEFAULT_SWEEP_ANGLE)
- || (Math.abs(accumulatedVerticalAngle) >= DEFAULT_SWEEP_ANGLE)) {
- stopCapture(false);
- } else {
- float panningRateXInDegree = panningRateX * mHorizontalViewAngle;
- float panningRateYInDegree = panningRateY * mVerticalViewAngle;
- updateProgress(panningRateXInDegree, panningRateYInDegree,
- accumulatedHorizontalAngle, accumulatedVerticalAngle);
- }
- }
- });
-
- mPanoProgressBar.reset();
- // TODO: calculate the indicator width according to different devices to reflect the actual
- // angle of view of the camera device.
- mPanoProgressBar.setIndicatorWidth(20);
- mPanoProgressBar.setMaxProgress(DEFAULT_SWEEP_ANGLE);
- mPanoProgressBar.setVisibility(View.VISIBLE);
- mDeviceOrientationAtCapture = mDeviceOrientation;
- keepScreenOn();
- mActivity.getOrientationManager().lockOrientation();
- setupProgressDirectionMatrix();
- }
-
- void setupProgressDirectionMatrix() {
- int degrees = Util.getDisplayRotation(mActivity);
- int cameraId = CameraHolder.instance().getBackCameraId();
- int orientation = Util.getDisplayOrientation(degrees, cameraId);
- mProgressDirectionMatrix.reset();
- mProgressDirectionMatrix.postRotate(orientation);
- }
-
- private void stopCapture(boolean aborted) {
- mCaptureState = CAPTURE_STATE_VIEWFINDER;
- mCaptureIndicator.setVisibility(View.GONE);
- hideTooFastIndication();
- hideDirectionIndicators();
-
- mMosaicFrameProcessor.setProgressListener(null);
- stopCameraPreview();
-
- mCameraTexture.setOnFrameAvailableListener(null);
-
- if (!aborted && !mThreadRunning) {
- mRotateDialog.showWaitingDialog(mPreparePreviewString);
- // Hide shutter button, shutter icon, etc when waiting for
- // panorama to stitch
- mActivity.hideUI();
- runBackgroundThread(new Thread() {
- @Override
- public void run() {
- MosaicJpeg jpeg = generateFinalMosaic(false);
-
- if (jpeg != null && jpeg.isValid) {
- Bitmap bitmap = null;
- bitmap = BitmapFactory.decodeByteArray(jpeg.data, 0, jpeg.data.length);
- mMainHandler.sendMessage(mMainHandler.obtainMessage(
- MSG_LOW_RES_FINAL_MOSAIC_READY, bitmap));
- } else {
- mMainHandler.sendMessage(mMainHandler.obtainMessage(
- MSG_END_DIALOG_RESET_TO_PREVIEW));
- }
- }
- });
- }
- keepScreenOnAwhile();
- }
-
- private void showTooFastIndication() {
- mTooFastPrompt.setVisibility(View.VISIBLE);
- // The PreviewArea also contains the border for "too fast" indication.
- mPreviewArea.setVisibility(View.VISIBLE);
- mPanoProgressBar.setIndicatorColor(mIndicatorColorFast);
- mLeftIndicator.setEnabled(true);
- mRightIndicator.setEnabled(true);
- }
-
- private void hideTooFastIndication() {
- mTooFastPrompt.setVisibility(View.GONE);
- // We set "INVISIBLE" instead of "GONE" here because we need mPreviewArea to have layout
- // information so we can know the size and position for mCameraScreenNail.
- mPreviewArea.setVisibility(View.INVISIBLE);
- mPanoProgressBar.setIndicatorColor(mIndicatorColor);
- mLeftIndicator.setEnabled(false);
- mRightIndicator.setEnabled(false);
- }
-
- private void updateProgress(float panningRateXInDegree, float panningRateYInDegree,
- float progressHorizontalAngle, float progressVerticalAngle) {
- mGLRootView.requestRender();
-
- if ((Math.abs(panningRateXInDegree) > PANNING_SPEED_THRESHOLD)
- || (Math.abs(panningRateYInDegree) > PANNING_SPEED_THRESHOLD)) {
- showTooFastIndication();
- } else {
- hideTooFastIndication();
- }
-
- // progressHorizontalAngle and progressVerticalAngle are relative to the
- // camera. Convert them to UI direction.
- mProgressAngle[0] = progressHorizontalAngle;
- mProgressAngle[1] = progressVerticalAngle;
- mProgressDirectionMatrix.mapPoints(mProgressAngle);
-
- int angleInMajorDirection =
- (Math.abs(mProgressAngle[0]) > Math.abs(mProgressAngle[1]))
- ? (int) mProgressAngle[0]
- : (int) mProgressAngle[1];
- mPanoProgressBar.setProgress((angleInMajorDirection));
- }
-
- private void setViews(Resources appRes) {
- mCaptureState = CAPTURE_STATE_VIEWFINDER;
- mPanoProgressBar = (PanoProgressBar) mRootView.findViewById(R.id.pano_pan_progress_bar);
- mPanoProgressBar.setBackgroundColor(appRes.getColor(R.color.pano_progress_empty));
- mPanoProgressBar.setDoneColor(appRes.getColor(R.color.pano_progress_done));
- mPanoProgressBar.setIndicatorColor(mIndicatorColor);
- mPanoProgressBar.setOnDirectionChangeListener(
- new PanoProgressBar.OnDirectionChangeListener () {
- @Override
- public void onDirectionChange(int direction) {
- if (mCaptureState == CAPTURE_STATE_MOSAIC) {
- showDirectionIndicators(direction);
- }
- }
- });
-
- mLeftIndicator = mRootView.findViewById(R.id.pano_pan_left_indicator);
- mRightIndicator = mRootView.findViewById(R.id.pano_pan_right_indicator);
- mLeftIndicator.setEnabled(false);
- mRightIndicator.setEnabled(false);
- mTooFastPrompt = (TextView) mRootView.findViewById(R.id.pano_capture_too_fast_textview);
- // This mPreviewArea also shows the border for visual "too fast" indication.
- mPreviewArea = (LayoutNotifyView) mRootView.findViewById(R.id.pano_preview_area);
- mPreviewArea.setOnLayoutChangeListener(this);
-
- mSavingProgressBar = (PanoProgressBar) mRootView.findViewById(R.id.pano_saving_progress_bar);
- mSavingProgressBar.setIndicatorWidth(0);
- mSavingProgressBar.setMaxProgress(100);
- mSavingProgressBar.setBackgroundColor(appRes.getColor(R.color.pano_progress_empty));
- mSavingProgressBar.setDoneColor(appRes.getColor(R.color.pano_progress_indication));
-
- mCaptureIndicator = mRootView.findViewById(R.id.pano_capture_indicator);
-
- mReviewLayout = mRootView.findViewById(R.id.pano_review_layout);
- mReview = (ImageView) mRootView.findViewById(R.id.pano_reviewarea);
- mReview.setBackgroundColor(mReviewBackground);
- View cancelButton = mRootView.findViewById(R.id.pano_review_cancel_button);
- cancelButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- if (mPaused || mCameraTexture == null) return;
- cancelHighResComputation();
- }
- });
-
- mShutterButton = mActivity.getShutterButton();
- mShutterButton.setImageResource(R.drawable.btn_new_shutter);
- mShutterButton.setOnShutterButtonListener(this);
-
- if (mActivity.getResources().getConfiguration().orientation
- == Configuration.ORIENTATION_PORTRAIT) {
- Rotatable view = (Rotatable) mRootView.findViewById(R.id.pano_rotate_reviewarea);
- view.setOrientation(270, false);
- }
- }
-
- private void createContentView() {
- mActivity.getLayoutInflater().inflate(R.layout.panorama_module, (ViewGroup) mRootView, true);
- Resources appRes = mActivity.getResources();
- mCaptureLayout = (LinearLayout) mRootView.findViewById(R.id.camera_app);
- mIndicatorColor = appRes.getColor(R.color.pano_progress_indication);
- mReviewBackground = appRes.getColor(R.color.review_background);
- mIndicatorColorFast = appRes.getColor(R.color.pano_progress_indication_fast);
- mPanoLayout = (ViewGroup) mRootView.findViewById(R.id.camera_app_root);
- mRotateDialog = new RotateDialogController(mActivity, R.layout.rotate_dialog);
- setViews(appRes);
- }
-
- @Override
- public void onShutterButtonClick() {
- // If mCameraTexture == null then GL setup is not finished yet.
- // No buttons can be pressed.
- if (mPaused || mThreadRunning || mCameraTexture == null) return;
- // Since this button will stay on the screen when capturing, we need to check the state
- // right now.
- switch (mCaptureState) {
- case CAPTURE_STATE_VIEWFINDER:
- if(mActivity.getStorageSpace() <= Storage.LOW_STORAGE_THRESHOLD) return;
- mSoundPlayer.play(SoundClips.START_VIDEO_RECORDING);
- startCapture();
- break;
- case CAPTURE_STATE_MOSAIC:
- mSoundPlayer.play(SoundClips.STOP_VIDEO_RECORDING);
- stopCapture(false);
- }
- }
-
- @Override
- public void onShutterButtonFocus(boolean pressed) {
- }
-
- public void reportProgress() {
- mSavingProgressBar.reset();
- mSavingProgressBar.setRightIncreasing(true);
- Thread t = new Thread() {
- @Override
- public void run() {
- while (mThreadRunning) {
- final int progress = mMosaicFrameProcessor.reportProgress(
- true, mCancelComputation);
-
- try {
- synchronized (mWaitObject) {
- mWaitObject.wait(50);
- }
- } catch (InterruptedException e) {
- throw new RuntimeException("Panorama reportProgress failed", e);
- }
- // Update the progress bar
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- mSavingProgressBar.setProgress(progress);
- }
- });
- }
- }
- };
- t.start();
- }
-
- private int getCaptureOrientation() {
- // The panorama image returned from the library is oriented based on the
- // natural orientation of a camera. We need to set an orientation for the image
- // in its EXIF header, so the image can be displayed correctly.
- // The orientation is calculated from compensating the
- // device orientation at capture and the camera orientation respective to
- // the natural orientation of the device.
- int orientation;
- if (mUsingFrontCamera) {
- // mCameraOrientation is negative with respect to the front facing camera.
- // See document of android.hardware.Camera.Parameters.setRotation.
- orientation = (mDeviceOrientationAtCapture - mCameraOrientation + 360) % 360;
- } else {
- orientation = (mDeviceOrientationAtCapture + mCameraOrientation) % 360;
- }
- return orientation;
- }
-
- public void saveHighResMosaic() {
- runBackgroundThread(new Thread() {
- @Override
- public void run() {
- mPartialWakeLock.acquire();
- MosaicJpeg jpeg;
- try {
- jpeg = generateFinalMosaic(true);
- } finally {
- mPartialWakeLock.release();
- }
-
- if (jpeg == null) { // Cancelled by user.
- mMainHandler.sendEmptyMessage(MSG_END_DIALOG_RESET_TO_PREVIEW);
- } else if (!jpeg.isValid) { // Error when generating mosaic.
- mMainHandler.sendEmptyMessage(MSG_GENERATE_FINAL_MOSAIC_ERROR);
- } else {
- int orientation = getCaptureOrientation();
- Uri uri = savePanorama(jpeg.data, jpeg.width, jpeg.height, orientation);
- if (uri != null) {
- mActivity.addSecureAlbumItemIfNeeded(false, uri);
- Util.broadcastNewPicture(mActivity, uri);
- }
- mMainHandler.sendMessage(
- mMainHandler.obtainMessage(MSG_END_DIALOG_RESET_TO_PREVIEW));
- }
- }
- });
- reportProgress();
- }
-
- private void runBackgroundThread(Thread thread) {
- mThreadRunning = true;
- thread.start();
- }
-
- private void onBackgroundThreadFinished() {
- mThreadRunning = false;
- mRotateDialog.dismissDialog();
- }
-
- private void cancelHighResComputation() {
- mCancelComputation = true;
- synchronized (mWaitObject) {
- mWaitObject.notify();
- }
- }
-
- // This function will be called upon the first camera frame is available.
- private void reset() {
- mCaptureState = CAPTURE_STATE_VIEWFINDER;
-
- mActivity.getOrientationManager().unlockOrientation();
- // We should set mGLRootView visible too. However, since there might be no
- // frame available yet, setting mGLRootView visible should be done right after
- // the first camera frame is available and therefore it is done by
- // mOnFirstFrameAvailableRunnable.
- mActivity.setSwipingEnabled(true);
- mShutterButton.setImageResource(R.drawable.btn_new_shutter);
- mReviewLayout.setVisibility(View.GONE);
- mPanoProgressBar.setVisibility(View.GONE);
- mGLRootView.setVisibility(View.VISIBLE);
- // Orientation change will trigger onLayoutChange->configMosaicPreview->
- // resetToPreview. Do not show the capture UI in film strip.
- if (mActivity.mShowCameraAppView) {
- mCaptureLayout.setVisibility(View.VISIBLE);
- mActivity.showUI();
- }
- mMosaicFrameProcessor.reset();
- }
-
- private void resetToPreview() {
- reset();
- if (!mPaused) startCameraPreview();
- }
-
- private static class FlipBitmapDrawable extends BitmapDrawable {
-
- public FlipBitmapDrawable(Resources res, Bitmap bitmap) {
- super(res, bitmap);
- }
-
- @Override
- public void draw(Canvas canvas) {
- Rect bounds = getBounds();
- int cx = bounds.centerX();
- int cy = bounds.centerY();
- canvas.save(Canvas.MATRIX_SAVE_FLAG);
- canvas.rotate(180, cx, cy);
- super.draw(canvas);
- canvas.restore();
- }
- }
-
- private void showFinalMosaic(Bitmap bitmap) {
- if (bitmap != null) {
- int orientation = getCaptureOrientation();
- if (orientation >= 180) {
- // We need to flip the drawable to compensate
- mReview.setImageDrawable(new FlipBitmapDrawable(
- mActivity.getResources(), bitmap));
- } else {
- mReview.setImageBitmap(bitmap);
- }
- }
-
- mCaptureLayout.setVisibility(View.GONE);
- mReviewLayout.setVisibility(View.VISIBLE);
- }
-
- private Uri savePanorama(byte[] jpegData, int width, int height, int orientation) {
- if (jpegData != null) {
- String filename = PanoUtil.createName(
- mActivity.getResources().getString(R.string.pano_file_name_format), mTimeTaken);
- String filepath = Storage.generateFilepath(filename);
-
- Location loc = mLocationManager.getCurrentLocation();
- ExifInterface exif = new ExifInterface();
- try {
- exif.readExif(jpegData);
- exif.addGpsDateTimeStampTag(mTimeTaken);
- exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, mTimeTaken,
- TimeZone.getDefault());
- exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION,
- ExifInterface.getOrientationValueForRotation(orientation)));
- writeLocation(loc, exif);
- exif.writeExif(jpegData, filepath);
- } catch (IOException e) {
- Log.e(TAG, "Cannot set exif for " + filepath, e);
- Storage.writeFile(filepath, jpegData);
- }
- int jpegLength = (int) (new File(filepath).length());
- return Storage.addImage(mContentResolver, filename, mTimeTaken,
- loc, orientation, jpegLength, filepath, width, height);
- }
- return null;
- }
-
- private static void writeLocation(Location location, ExifInterface exif) {
- if (location == null) {
- return;
- }
- exif.addGpsTags(location.getLatitude(), location.getLongitude());
- exif.setTag(exif.buildTag(ExifInterface.TAG_GPS_PROCESSING_METHOD, location.getProvider()));
- }
-
- private void clearMosaicFrameProcessorIfNeeded() {
- if (!mPaused || mThreadRunning) return;
- // Only clear the processor if it is initialized by this activity
- // instance. Other activity instances may be using it.
- if (mMosaicFrameProcessorInitialized) {
- mMosaicFrameProcessor.clear();
- mMosaicFrameProcessorInitialized = false;
- }
- }
-
- private void initMosaicFrameProcessorIfNeeded() {
- if (mPaused || mThreadRunning) return;
- mMosaicFrameProcessor.initialize(
- mPreviewWidth, mPreviewHeight, getPreviewBufSize());
- mMosaicFrameProcessorInitialized = true;
- }
-
- @Override
- public void onPauseBeforeSuper() {
- mPaused = true;
- if (mLocationManager != null) mLocationManager.recordLocation(false);
- }
-
- @Override
- public void onPauseAfterSuper() {
- mOrientationEventListener.disable();
- if (mCameraDevice == null) {
- // Camera open failed. Nothing should be done here.
- return;
- }
- // Stop the capturing first.
- if (mCaptureState == CAPTURE_STATE_MOSAIC) {
- stopCapture(true);
- reset();
- }
-
- releaseCamera();
- synchronized (mRendererLock) {
- mCameraTexture = null;
-
- // The preview renderer might not have a chance to be initialized
- // before onPause().
- if (mMosaicPreviewRenderer != null) {
- mMosaicPreviewRenderer.release();
- mMosaicPreviewRenderer = null;
- }
- }
-
- clearMosaicFrameProcessorIfNeeded();
- if (mWaitProcessorTask != null) {
- mWaitProcessorTask.cancel(true);
- mWaitProcessorTask = null;
- }
- resetScreenOn();
- if (mSoundPlayer != null) {
- mSoundPlayer.release();
- mSoundPlayer = null;
- }
- CameraScreenNail screenNail = (CameraScreenNail) mActivity.mCameraScreenNail;
- screenNail.releaseSurfaceTexture();
- System.gc();
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- Drawable lowResReview = null;
- if (mThreadRunning) lowResReview = mReview.getDrawable();
-
- // Change layout in response to configuration change
- mCaptureLayout.setOrientation(
- newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE
- ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
- mCaptureLayout.removeAllViews();
- LayoutInflater inflater = mActivity.getLayoutInflater();
- inflater.inflate(R.layout.preview_frame_pano, mCaptureLayout);
-
- mPanoLayout.removeView(mReviewLayout);
- inflater.inflate(R.layout.pano_review, mPanoLayout);
-
- setViews(mActivity.getResources());
- if (mThreadRunning) {
- mReview.setImageDrawable(lowResReview);
- mCaptureLayout.setVisibility(View.GONE);
- mReviewLayout.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- public void onOrientationChanged(int orientation) {
- }
-
- @Override
- public void onResumeBeforeSuper() {
- mPaused = false;
- }
-
- @Override
- public void onResumeAfterSuper() {
- mOrientationEventListener.enable();
-
- mCaptureState = CAPTURE_STATE_VIEWFINDER;
-
- try {
- setupCamera();
- } catch (CameraHardwareException e) {
- Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
- return;
- } catch (CameraDisabledException e) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
- return;
- }
-
- // Set up sound playback for shutter button
- mSoundPlayer = SoundClips.getPlayer(mActivity);
-
- // Check if another panorama instance is using the mosaic frame processor.
- mRotateDialog.dismissDialog();
- if (!mThreadRunning && mMosaicFrameProcessor.isMosaicMemoryAllocated()) {
- mGLRootView.setVisibility(View.GONE);
- mRotateDialog.showWaitingDialog(mDialogWaitingPreviousString);
- // If stitching is still going on, make sure switcher and shutter button
- // are not showing
- mActivity.hideUI();
- mWaitProcessorTask = new WaitProcessorTask().execute();
- } else {
- mGLRootView.setVisibility(View.VISIBLE);
- // Camera must be initialized before MosaicFrameProcessor is
- // initialized. The preview size has to be decided by camera device.
- initMosaicFrameProcessorIfNeeded();
- int w = mPreviewArea.getWidth();
- int h = mPreviewArea.getHeight();
- if (w != 0 && h != 0) { // The layout has been calculated.
- configMosaicPreview(w, h);
- }
- }
- keepScreenOnAwhile();
-
- // Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(mPreferences,
- mContentResolver);
- mLocationManager.recordLocation(recordLocation);
-
- // Dismiss open menu if exists.
- PopupManager.getInstance(mActivity).notifyShowPopup(null);
- mRootView.requestLayout();
- UsageStatistics.onContentViewChanged(
- UsageStatistics.COMPONENT_CAMERA, "PanoramaModule");
- }
-
- /**
- * Generate the final mosaic image.
- *
- * @param highRes flag to indicate whether we want to get a high-res version.
- * @return a MosaicJpeg with its isValid flag set to true if successful; null if the generation
- * process is cancelled; and a MosaicJpeg with its isValid flag set to false if there
- * is an error in generating the final mosaic.
- */
- public MosaicJpeg generateFinalMosaic(boolean highRes) {
- int mosaicReturnCode = mMosaicFrameProcessor.createMosaic(highRes);
- if (mosaicReturnCode == Mosaic.MOSAIC_RET_CANCELLED) {
- return null;
- } else if (mosaicReturnCode == Mosaic.MOSAIC_RET_ERROR) {
- return new MosaicJpeg();
- }
-
- byte[] imageData = mMosaicFrameProcessor.getFinalMosaicNV21();
- if (imageData == null) {
- Log.e(TAG, "getFinalMosaicNV21() returned null.");
- return new MosaicJpeg();
- }
-
- int len = imageData.length - 8;
- int width = (imageData[len + 0] << 24) + ((imageData[len + 1] & 0xFF) << 16)
- + ((imageData[len + 2] & 0xFF) << 8) + (imageData[len + 3] & 0xFF);
- int height = (imageData[len + 4] << 24) + ((imageData[len + 5] & 0xFF) << 16)
- + ((imageData[len + 6] & 0xFF) << 8) + (imageData[len + 7] & 0xFF);
- Log.v(TAG, "ImLength = " + (len) + ", W = " + width + ", H = " + height);
-
- if (width <= 0 || height <= 0) {
- // TODO: pop up an error message indicating that the final result is not generated.
- Log.e(TAG, "width|height <= 0!!, len = " + (len) + ", W = " + width + ", H = " +
- height);
- return new MosaicJpeg();
- }
-
- YuvImage yuvimage = new YuvImage(imageData, ImageFormat.NV21, width, height, null);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- yuvimage.compressToJpeg(new Rect(0, 0, width, height), 100, out);
- try {
- out.close();
- } catch (Exception e) {
- Log.e(TAG, "Exception in storing final mosaic", e);
- return new MosaicJpeg();
- }
- return new MosaicJpeg(out.toByteArray(), width, height);
- }
-
- private void startCameraPreview() {
- if (mCameraDevice == null) {
- // Camera open failed. Return.
- return;
- }
-
- // This works around a driver issue. startPreview may fail if
- // stopPreview/setPreviewTexture/startPreview are called several times
- // in a row. mCameraTexture can be null after pressing home during
- // mosaic generation and coming back. Preview will be started later in
- // onLayoutChange->configMosaicPreview. This also reduces the latency.
- synchronized (mRendererLock) {
- if (mCameraTexture == null) return;
-
- // If we're previewing already, stop the preview first (this will
- // blank the screen).
- if (mCameraState != PREVIEW_STOPPED) stopCameraPreview();
-
- // Set the display orientation to 0, so that the underlying mosaic
- // library can always get undistorted mPreviewWidth x mPreviewHeight
- // image data from SurfaceTexture.
- mCameraDevice.setDisplayOrientation(0);
-
- mCameraTexture.setOnFrameAvailableListener(this);
- mCameraDevice.setPreviewTextureAsync(mCameraTexture);
- }
- mCameraDevice.startPreviewAsync();
- mCameraState = PREVIEW_ACTIVE;
- }
-
- private void stopCameraPreview() {
- if (mCameraDevice != null && mCameraState != PREVIEW_STOPPED) {
- Log.v(TAG, "stopPreview");
- mCameraDevice.stopPreview();
- }
- mCameraState = PREVIEW_STOPPED;
- }
-
- @Override
- public void onUserInteraction() {
- if (mCaptureState != CAPTURE_STATE_MOSAIC) keepScreenOnAwhile();
- }
-
- @Override
- public boolean onBackPressed() {
- // If panorama is generating low res or high res mosaic, ignore back
- // key. So the activity will not be destroyed.
- if (mThreadRunning) return true;
- return false;
- }
-
- private void resetScreenOn() {
- mMainHandler.removeMessages(MSG_CLEAR_SCREEN_DELAY);
- mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
-
- private void keepScreenOnAwhile() {
- mMainHandler.removeMessages(MSG_CLEAR_SCREEN_DELAY);
- mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- mMainHandler.sendEmptyMessageDelayed(MSG_CLEAR_SCREEN_DELAY, SCREEN_DELAY);
- }
-
- private void keepScreenOn() {
- mMainHandler.removeMessages(MSG_CLEAR_SCREEN_DELAY);
- mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
-
- private class WaitProcessorTask extends AsyncTask<Void, Void, Void> {
- @Override
- protected Void doInBackground(Void... params) {
- synchronized (mMosaicFrameProcessor) {
- while (!isCancelled() && mMosaicFrameProcessor.isMosaicMemoryAllocated()) {
- try {
- mMosaicFrameProcessor.wait();
- } catch (Exception e) {
- // ignore
- }
- }
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(Void result) {
- mWaitProcessorTask = null;
- mRotateDialog.dismissDialog();
- mGLRootView.setVisibility(View.VISIBLE);
- initMosaicFrameProcessorIfNeeded();
- int w = mPreviewArea.getWidth();
- int h = mPreviewArea.getHeight();
- if (w != 0 && h != 0) { // The layout has been calculated.
- configMosaicPreview(w, h);
- }
- resetToPreview();
- }
- }
-
- @Override
- public void onFullScreenChanged(boolean full) {
- }
-
-
- @Override
- public void onStop() {
- }
-
- @Override
- public void installIntentFilter() {
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- }
-
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- return false;
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- return false;
- }
-
- @Override
- public void onSingleTapUp(View view, int x, int y) {
- }
-
- @Override
- public void onPreviewTextureCopied() {
- }
-
- @Override
- public void onCaptureTextureCopied() {
- }
-
- @Override
- public boolean updateStorageHintOnResume() {
- return false;
- }
-
- @Override
- public void updateCameraAppView() {
- }
-
- @Override
- public boolean needsSwitcher() {
- return true;
- }
-
- @Override
- public boolean needsPieMenu() {
- return false;
- }
-
- @Override
- public void onShowSwitcherPopup() {
- }
-
- @Override
- public void onMediaSaveServiceConnected(MediaSaveService s) {
- // do nothing.
- }
-}
diff --git a/src/com/android/camera/PhotoController.java b/src/com/android/camera/PhotoController.java
deleted file mode 100644
index b76022e..0000000
--- a/src/com/android/camera/PhotoController.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.camera;
-
-import android.view.SurfaceHolder;
-import android.view.View;
-
-import com.android.camera.ShutterButton.OnShutterButtonListener;
-
-
-public interface PhotoController extends OnShutterButtonListener {
-
- public static final int PREVIEW_STOPPED = 0;
- public static final int IDLE = 1; // preview is active
- // Focus is in progress. The exact focus state is in Focus.java.
- public static final int FOCUSING = 2;
- public static final int SNAPSHOT_IN_PROGRESS = 3;
- // Switching between cameras.
- public static final int SWITCHING_CAMERA = 4;
-
- // returns the actual set zoom value
- public int onZoomChanged(int requestedZoom);
-
- public boolean isImageCaptureIntent();
-
- public boolean isCameraIdle();
-
- public void onCaptureDone();
-
- public void onCaptureCancelled();
-
- public void onCaptureRetake();
-
- public void cancelAutoFocus();
-
- public void stopPreview();
-
- public int getCameraState();
-
- public void onSingleTapUp(View view, int x, int y);
-
- public void onSurfaceCreated(SurfaceHolder holder);
-
- public void onCountDownFinished();
-
- public void onScreenSizeChanged(int width, int height, int previewWidth, int previewHeight);
-
-}
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
deleted file mode 100644
index d0f21ed..0000000
--- a/src/com/android/camera/PhotoMenu.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.content.res.Resources;
-import android.hardware.Camera.Parameters;
-
-import com.android.camera.ui.AbstractSettingPopup;
-import com.android.camera.ui.CountdownTimerPopup;
-import com.android.camera.ui.ListPrefSettingPopup;
-import com.android.camera.ui.PieItem;
-import com.android.camera.ui.PieItem.OnClickListener;
-import com.android.camera.ui.PieRenderer;
-import com.android.gallery3d.R;
-
-import java.util.Locale;
-
-public class PhotoMenu extends PieController
- implements CountdownTimerPopup.Listener,
- ListPrefSettingPopup.Listener {
- private static String TAG = "CAM_photomenu";
-
- private final String mSettingOff;
-
- private PhotoUI mUI;
- private AbstractSettingPopup mPopup;
- private CameraActivity mActivity;
-
- public PhotoMenu(CameraActivity activity, PhotoUI ui, PieRenderer pie) {
- super(activity, pie);
- mUI = ui;
- mSettingOff = activity.getString(R.string.setting_off_value);
- mActivity = activity;
- }
-
- public void initialize(PreferenceGroup group) {
- super.initialize(group);
- mPopup = null;
- PieItem item = null;
- final Resources res = mActivity.getResources();
- Locale locale = res.getConfiguration().locale;
- // the order is from left to right in the menu
-
- // hdr
- if (group.findPreference(CameraSettings.KEY_CAMERA_HDR) != null) {
- item = makeSwitchItem(CameraSettings.KEY_CAMERA_HDR, true);
- mRenderer.addItem(item);
- }
- // exposure compensation
- if (group.findPreference(CameraSettings.KEY_EXPOSURE) != null) {
- item = makeItem(CameraSettings.KEY_EXPOSURE);
- item.setLabel(res.getString(R.string.pref_exposure_label));
- mRenderer.addItem(item);
- }
- // more settings
- PieItem more = makeItem(R.drawable.ic_settings_holo_light);
- more.setLabel(res.getString(R.string.camera_menu_more_label));
- mRenderer.addItem(more);
- // flash
- if (group.findPreference(CameraSettings.KEY_FLASH_MODE) != null) {
- item = makeItem(CameraSettings.KEY_FLASH_MODE);
- item.setLabel(res.getString(R.string.pref_camera_flashmode_label));
- mRenderer.addItem(item);
- }
- // camera switcher
- if (group.findPreference(CameraSettings.KEY_CAMERA_ID) != null) {
- item = makeSwitchItem(CameraSettings.KEY_CAMERA_ID, false);
- final PieItem fitem = item;
- item.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(PieItem item) {
- // Find the index of next camera.
- ListPreference pref = mPreferenceGroup
- .findPreference(CameraSettings.KEY_CAMERA_ID);
- if (pref != null) {
- int index = pref.findIndexOfValue(pref.getValue());
- CharSequence[] values = pref.getEntryValues();
- index = (index + 1) % values.length;
- pref.setValueIndex(index);
- mListener.onCameraPickerClicked(index);
- }
- updateItem(fitem, CameraSettings.KEY_CAMERA_ID);
- }
- });
- mRenderer.addItem(item);
- }
- // location
- if (group.findPreference(CameraSettings.KEY_RECORD_LOCATION) != null) {
- item = makeSwitchItem(CameraSettings.KEY_RECORD_LOCATION, true);
- more.addItem(item);
- if (mActivity.isSecureCamera()) {
- // Prevent location preference from getting changed in secure camera mode
- item.setEnabled(false);
- }
- }
- // countdown timer
- final ListPreference ctpref = group.findPreference(CameraSettings.KEY_TIMER);
- final ListPreference beeppref = group.findPreference(CameraSettings.KEY_TIMER_SOUND_EFFECTS);
- item = makeItem(R.drawable.ic_timer);
- item.setLabel(res.getString(R.string.pref_camera_timer_title).toUpperCase(locale));
- item.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(PieItem item) {
- CountdownTimerPopup timerPopup = (CountdownTimerPopup) mActivity.getLayoutInflater().inflate(
- R.layout.countdown_setting_popup, null, false);
- timerPopup.initialize(ctpref, beeppref);
- timerPopup.setSettingChangedListener(PhotoMenu.this);
- mUI.dismissPopup();
- mPopup = timerPopup;
- mUI.showPopup(mPopup);
- }
- });
- more.addItem(item);
- // image size
- item = makeItem(R.drawable.ic_imagesize);
- final ListPreference sizePref = group.findPreference(CameraSettings.KEY_PICTURE_SIZE);
- item.setLabel(res.getString(R.string.pref_camera_picturesize_title).toUpperCase(locale));
- item.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(PieItem item) {
- ListPrefSettingPopup popup = (ListPrefSettingPopup) mActivity.getLayoutInflater().inflate(
- R.layout.list_pref_setting_popup, null, false);
- popup.initialize(sizePref);
- popup.setSettingChangedListener(PhotoMenu.this);
- mUI.dismissPopup();
- mPopup = popup;
- mUI.showPopup(mPopup);
- }
- });
- more.addItem(item);
- // white balance
- if (group.findPreference(CameraSettings.KEY_WHITE_BALANCE) != null) {
- item = makeItem(CameraSettings.KEY_WHITE_BALANCE);
- item.setLabel(res.getString(R.string.pref_camera_whitebalance_label));
- more.addItem(item);
- }
- // scene mode
- if (group.findPreference(CameraSettings.KEY_SCENE_MODE) != null) {
- IconListPreference pref = (IconListPreference) group.findPreference(
- CameraSettings.KEY_SCENE_MODE);
- pref.setUseSingleIcon(true);
- item = makeItem(CameraSettings.KEY_SCENE_MODE);
- more.addItem(item);
- }
- }
-
- @Override
- // Hit when an item in a popup gets selected
- public void onListPrefChanged(ListPreference pref) {
- if (mPopup != null) {
- mUI.dismissPopup();
- }
- onSettingChanged(pref);
- }
-
- public void popupDismissed() {
- // the popup gets dismissed
- if (mPopup != null) {
- mPopup = null;
- }
- }
-
- // Return true if the preference has the specified key but not the value.
- private static boolean notSame(ListPreference pref, String key, String value) {
- return (key.equals(pref.getKey()) && !value.equals(pref.getValue()));
- }
-
- private void setPreference(String key, String value) {
- ListPreference pref = mPreferenceGroup.findPreference(key);
- if (pref != null && !value.equals(pref.getValue())) {
- pref.setValue(value);
- reloadPreferences();
- }
- }
-
- @Override
- public void onSettingChanged(ListPreference pref) {
- // Reset the scene mode if HDR is set to on. Reset HDR if scene mode is
- // set to non-auto.
- if (notSame(pref, CameraSettings.KEY_CAMERA_HDR, mSettingOff)) {
- setPreference(CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO);
- } else if (notSame(pref, CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO)) {
- setPreference(CameraSettings.KEY_CAMERA_HDR, mSettingOff);
- }
- super.onSettingChanged(pref);
- }
-
-}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
deleted file mode 100644
index e88645d..0000000
--- a/src/com/android/camera/PhotoModule.java
+++ /dev/null
@@ -1,2103 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.ContentProviderClient;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences.Editor;
-import android.content.res.Configuration;
-import android.graphics.Bitmap;
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera.CameraInfo;
-import android.hardware.Camera.Parameters;
-import android.hardware.Camera.PictureCallback;
-import android.hardware.Camera.Size;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.location.Location;
-import android.media.CameraProfile;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.ConditionVariable;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.os.MessageQueue;
-import android.os.SystemClock;
-import android.provider.MediaStore;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.OrientationEventListener;
-import android.view.SurfaceHolder;
-import android.view.View;
-import android.view.WindowManager;
-
-import com.android.camera.CameraManager.CameraProxy;
-import com.android.camera.ui.CountDownView.OnCountDownFinishedListener;
-import com.android.camera.ui.PopupManager;
-import com.android.camera.ui.RotateTextToast;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.exif.ExifInterface;
-import com.android.gallery3d.exif.ExifTag;
-import com.android.gallery3d.exif.Rational;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.crop.CropExtras;
-import com.android.gallery3d.util.UsageStatistics;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Formatter;
-import java.util.List;
-
-public class PhotoModule
- implements CameraModule,
- PhotoController,
- FocusOverlayManager.Listener,
- CameraPreference.OnPreferenceChangedListener,
- ShutterButton.OnShutterButtonListener,
- MediaSaveService.Listener,
- OnCountDownFinishedListener,
- SensorEventListener {
-
- private static final String TAG = "CAM_PhotoModule";
-
- // We number the request code from 1000 to avoid collision with Gallery.
- private static final int REQUEST_CROP = 1000;
-
- private static final int SETUP_PREVIEW = 1;
- private static final int FIRST_TIME_INIT = 2;
- private static final int CLEAR_SCREEN_DELAY = 3;
- private static final int SET_CAMERA_PARAMETERS_WHEN_IDLE = 4;
- private static final int CHECK_DISPLAY_ROTATION = 5;
- private static final int SHOW_TAP_TO_FOCUS_TOAST = 6;
- private static final int SWITCH_CAMERA = 7;
- private static final int SWITCH_CAMERA_START_ANIMATION = 8;
- private static final int CAMERA_OPEN_DONE = 9;
- private static final int START_PREVIEW_DONE = 10;
- private static final int OPEN_CAMERA_FAIL = 11;
- private static final int CAMERA_DISABLED = 12;
- private static final int CAPTURE_ANIMATION_DONE = 13;
-
- // The subset of parameters we need to update in setCameraParameters().
- private static final int UPDATE_PARAM_INITIALIZE = 1;
- private static final int UPDATE_PARAM_ZOOM = 2;
- private static final int UPDATE_PARAM_PREFERENCE = 4;
- private static final int UPDATE_PARAM_ALL = -1;
-
- // This is the timeout to keep the camera in onPause for the first time
- // after screen on if the activity is started from secure lock screen.
- private static final int KEEP_CAMERA_TIMEOUT = 1000; // ms
-
- // copied from Camera hierarchy
- private CameraActivity mActivity;
- private CameraProxy mCameraDevice;
- private int mCameraId;
- private Parameters mParameters;
- private boolean mPaused;
-
- private PhotoUI mUI;
-
- // these are only used by Camera
-
- // The activity is going to switch to the specified camera id. This is
- // needed because texture copy is done in GL thread. -1 means camera is not
- // switching.
- protected int mPendingSwitchCameraId = -1;
- private boolean mOpenCameraFail;
- private boolean mCameraDisabled;
-
- // When setCameraParametersWhenIdle() is called, we accumulate the subsets
- // needed to be updated in mUpdateSet.
- private int mUpdateSet;
-
- private static final int SCREEN_DELAY = 2 * 60 * 1000;
-
- private int mZoomValue; // The current zoom value.
-
- private Parameters mInitialParams;
- private boolean mFocusAreaSupported;
- private boolean mMeteringAreaSupported;
- private boolean mAeLockSupported;
- private boolean mAwbLockSupported;
- private boolean mContinousFocusSupported;
-
- // The degrees of the device rotated clockwise from its natural orientation.
- private int mOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
- private ComboPreferences mPreferences;
-
- private static final String sTempCropFilename = "crop-temp";
-
- private ContentProviderClient mMediaProviderClient;
- private boolean mFaceDetectionStarted = false;
-
- // mCropValue and mSaveUri are used only if isImageCaptureIntent() is true.
- private String mCropValue;
- private Uri mSaveUri;
-
- // We use a queue to generated names of the images to be used later
- // when the image is ready to be saved.
- private NamedImages mNamedImages;
-
- private Runnable mDoSnapRunnable = new Runnable() {
- @Override
- public void run() {
- onShutterButtonClick();
- }
- };
-
- private Runnable mFlashRunnable = new Runnable() {
- @Override
- public void run() {
- animateFlash();
- }
- };
-
- private final StringBuilder mBuilder = new StringBuilder();
- private final Formatter mFormatter = new Formatter(mBuilder);
- private final Object[] mFormatterArgs = new Object[1];
-
- /**
- * An unpublished intent flag requesting to return as soon as capturing
- * is completed.
- *
- * TODO: consider publishing by moving into MediaStore.
- */
- private static final String EXTRA_QUICK_CAPTURE =
- "android.intent.extra.quickCapture";
-
- // The display rotation in degrees. This is only valid when mCameraState is
- // not PREVIEW_STOPPED.
- private int mDisplayRotation;
- // The value for android.hardware.Camera.setDisplayOrientation.
- private int mCameraDisplayOrientation;
- // The value for UI components like indicators.
- private int mDisplayOrientation;
- // The value for android.hardware.Camera.Parameters.setRotation.
- private int mJpegRotation;
- private boolean mFirstTimeInitialized;
- private boolean mIsImageCaptureIntent;
-
- private int mCameraState = PREVIEW_STOPPED;
- private boolean mSnapshotOnIdle = false;
-
- private ContentResolver mContentResolver;
-
- private LocationManager mLocationManager;
-
- private final PostViewPictureCallback mPostViewPictureCallback =
- new PostViewPictureCallback();
- private final RawPictureCallback mRawPictureCallback =
- new RawPictureCallback();
- private final AutoFocusCallback mAutoFocusCallback =
- new AutoFocusCallback();
- private final Object mAutoFocusMoveCallback =
- ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK
- ? new AutoFocusMoveCallback()
- : null;
-
- private final CameraErrorCallback mErrorCallback = new CameraErrorCallback();
-
- private long mFocusStartTime;
- private long mShutterCallbackTime;
- private long mPostViewPictureCallbackTime;
- private long mRawPictureCallbackTime;
- private long mJpegPictureCallbackTime;
- private long mOnResumeTime;
- private byte[] mJpegImageData;
-
- // These latency time are for the CameraLatency test.
- public long mAutoFocusTime;
- public long mShutterLag;
- public long mShutterToPictureDisplayedTime;
- public long mPictureDisplayedToJpegCallbackTime;
- public long mJpegCallbackFinishTime;
- public long mCaptureStartTime;
-
- // This handles everything about focus.
- private FocusOverlayManager mFocusManager;
-
- private String mSceneMode;
-
- private final Handler mHandler = new MainHandler();
- private PreferenceGroup mPreferenceGroup;
-
- private boolean mQuickCapture;
-
- CameraStartUpThread mCameraStartUpThread;
- ConditionVariable mStartPreviewPrerequisiteReady = new ConditionVariable();
-
- private SensorManager mSensorManager;
- private float[] mGData = new float[3];
- private float[] mMData = new float[3];
- private float[] mR = new float[16];
- private int mHeading = -1;
-
- private MediaSaveService.OnMediaSavedListener mOnMediaSavedListener =
- new MediaSaveService.OnMediaSavedListener() {
- @Override
- public void onMediaSaved(Uri uri) {
- if (uri != null) {
- mActivity.addSecureAlbumItemIfNeeded(false, uri);
- Util.broadcastNewPicture(mActivity, uri);
- }
- }
- };
-
- // The purpose is not to block the main thread in onCreate and onResume.
- private class CameraStartUpThread extends Thread {
- private volatile boolean mCancelled;
-
- public void cancel() {
- mCancelled = true;
- interrupt();
- }
-
- public boolean isCanceled() {
- return mCancelled;
- }
-
- @Override
- public void run() {
- try {
- // We need to check whether the activity is paused before long
- // operations to ensure that onPause() can be done ASAP.
- if (mCancelled) return;
- mCameraDevice = Util.openCamera(mActivity, mCameraId);
- mParameters = mCameraDevice.getParameters();
- // Wait until all the initialization needed by startPreview are
- // done.
- mStartPreviewPrerequisiteReady.block();
-
- initializeCapabilities();
- if (mFocusManager == null) initializeFocusManager();
- if (mCancelled) return;
- setCameraParameters(UPDATE_PARAM_ALL);
- mHandler.sendEmptyMessage(CAMERA_OPEN_DONE);
- if (mCancelled) return;
- startPreview();
- mHandler.sendEmptyMessage(START_PREVIEW_DONE);
- mOnResumeTime = SystemClock.uptimeMillis();
- mHandler.sendEmptyMessage(CHECK_DISPLAY_ROTATION);
- } catch (CameraHardwareException e) {
- mHandler.sendEmptyMessage(OPEN_CAMERA_FAIL);
- } catch (CameraDisabledException e) {
- mHandler.sendEmptyMessage(CAMERA_DISABLED);
- }
- }
- }
-
- /**
- * This Handler is used to post message back onto the main thread of the
- * application
- */
- private class MainHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case SETUP_PREVIEW: {
- setupPreview();
- break;
- }
-
- case CLEAR_SCREEN_DELAY: {
- mActivity.getWindow().clearFlags(
- WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- break;
- }
-
- case FIRST_TIME_INIT: {
- initializeFirstTime();
- break;
- }
-
- case SET_CAMERA_PARAMETERS_WHEN_IDLE: {
- setCameraParametersWhenIdle(0);
- break;
- }
-
- case CHECK_DISPLAY_ROTATION: {
- // Set the display orientation if display rotation has changed.
- // Sometimes this happens when the device is held upside
- // down and camera app is opened. Rotation animation will
- // take some time and the rotation value we have got may be
- // wrong. Framework does not have a callback for this now.
- if (Util.getDisplayRotation(mActivity) != mDisplayRotation) {
- setDisplayOrientation();
- }
- if (SystemClock.uptimeMillis() - mOnResumeTime < 5000) {
- mHandler.sendEmptyMessageDelayed(CHECK_DISPLAY_ROTATION, 100);
- }
- break;
- }
-
- case SHOW_TAP_TO_FOCUS_TOAST: {
- showTapToFocusToast();
- break;
- }
-
- case SWITCH_CAMERA: {
- switchCamera();
- break;
- }
-
- case SWITCH_CAMERA_START_ANIMATION: {
- ((CameraScreenNail) mActivity.mCameraScreenNail).animateSwitchCamera();
- break;
- }
-
- case CAMERA_OPEN_DONE: {
- onCameraOpened();
- break;
- }
-
- case START_PREVIEW_DONE: {
- onPreviewStarted();
- break;
- }
-
- case OPEN_CAMERA_FAIL: {
- mCameraStartUpThread = null;
- mOpenCameraFail = true;
- Util.showErrorAndFinish(mActivity,
- R.string.cannot_connect_camera);
- break;
- }
-
- case CAMERA_DISABLED: {
- mCameraStartUpThread = null;
- mCameraDisabled = true;
- Util.showErrorAndFinish(mActivity,
- R.string.camera_disabled);
- break;
- }
- case CAPTURE_ANIMATION_DONE: {
- mUI.enablePreviewThumb(false);
- break;
- }
- }
- }
- }
-
- @Override
- public void init(CameraActivity activity, View parent, boolean reuseNail) {
- mActivity = activity;
- mUI = new PhotoUI(activity, this, parent);
- mPreferences = new ComboPreferences(mActivity);
- CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal());
- mCameraId = getPreferredCameraId(mPreferences);
-
- mContentResolver = mActivity.getContentResolver();
-
- // To reduce startup time, open the camera and start the preview in
- // another thread.
- mCameraStartUpThread = new CameraStartUpThread();
- mCameraStartUpThread.start();
-
-
- // Surface texture is from camera screen nail and startPreview needs it.
- // This must be done before startPreview.
- mIsImageCaptureIntent = isImageCaptureIntent();
- if (reuseNail) {
- mActivity.reuseCameraScreenNail(!mIsImageCaptureIntent);
- } else {
- mActivity.createCameraScreenNail(!mIsImageCaptureIntent);
- }
-
- mPreferences.setLocalId(mActivity, mCameraId);
- CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
- // we need to reset exposure for the preview
- resetExposureCompensation();
- // Starting the preview needs preferences, camera screen nail, and
- // focus area indicator.
- mStartPreviewPrerequisiteReady.open();
-
- initializeControlByIntent();
- mQuickCapture = mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE, false);
- mLocationManager = new LocationManager(mActivity, mUI);
- mSensorManager = (SensorManager)(mActivity.getSystemService(Context.SENSOR_SERVICE));
-
- }
-
- private void initializeControlByIntent() {
- mUI.initializeControlByIntent();
- if (mIsImageCaptureIntent) {
- setupCaptureParams();
- }
- }
-
- private void onPreviewStarted() {
- mCameraStartUpThread = null;
- setCameraState(IDLE);
- if (!ApiHelper.HAS_SURFACE_TEXTURE) {
- // This may happen if surfaceCreated has arrived.
- mCameraDevice.setPreviewDisplayAsync(mUI.getSurfaceHolder());
- }
- startFaceDetection();
- locationFirstRun();
- }
-
- // Prompt the user to pick to record location for the very first run of
- // camera only
- private void locationFirstRun() {
- if (RecordLocationPreference.isSet(mPreferences)) {
- return;
- }
- if (mActivity.isSecureCamera()) return;
- // Check if the back camera exists
- int backCameraId = CameraHolder.instance().getBackCameraId();
- if (backCameraId == -1) {
- // If there is no back camera, do not show the prompt.
- return;
- }
-
- new AlertDialog.Builder(mActivity)
- .setTitle(R.string.remember_location_title)
- .setMessage(R.string.remember_location_prompt)
- .setPositiveButton(R.string.remember_location_yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int arg1) {
- setLocationPreference(RecordLocationPreference.VALUE_ON);
- }
- })
- .setNegativeButton(R.string.remember_location_no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int arg1) {
- dialog.cancel();
- }
- })
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- setLocationPreference(RecordLocationPreference.VALUE_OFF);
- }
- })
- .show();
- }
-
- private void setLocationPreference(String value) {
- mPreferences.edit()
- .putString(CameraSettings.KEY_RECORD_LOCATION, value)
- .apply();
- // TODO: Fix this to use the actual onSharedPreferencesChanged listener
- // instead of invoking manually
- onSharedPreferenceChanged();
- }
-
- private void onCameraOpened() {
- View root = mUI.getRootView();
- // These depend on camera parameters.
-
- int width = root.getWidth();
- int height = root.getHeight();
- mFocusManager.setPreviewSize(width, height);
- // Full-screen screennail
- if (Util.getDisplayRotation(mActivity) % 180 == 0) {
- ((CameraScreenNail) mActivity.mCameraScreenNail).setPreviewFrameLayoutSize(width, height);
- } else {
- ((CameraScreenNail) mActivity.mCameraScreenNail).setPreviewFrameLayoutSize(height, width);
- }
- // Set touch focus listener.
- mActivity.setSingleTapUpListener(root);
- openCameraCommon();
- onFullScreenChanged(mActivity.isInCameraApp());
- }
-
- private void switchCamera() {
- if (mPaused) return;
-
- Log.v(TAG, "Start to switch camera. id=" + mPendingSwitchCameraId);
- mCameraId = mPendingSwitchCameraId;
- mPendingSwitchCameraId = -1;
- setCameraId(mCameraId);
-
- // from onPause
- closeCamera();
- mUI.collapseCameraControls();
- mUI.clearFaces();
- if (mFocusManager != null) mFocusManager.removeMessages();
-
- // Restart the camera and initialize the UI. From onCreate.
- mPreferences.setLocalId(mActivity, mCameraId);
- CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
- try {
- mCameraDevice = Util.openCamera(mActivity, mCameraId);
- mParameters = mCameraDevice.getParameters();
- } catch (CameraHardwareException e) {
- Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
- return;
- } catch (CameraDisabledException e) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
- return;
- }
- initializeCapabilities();
- CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
- boolean mirror = (info.facing == CameraInfo.CAMERA_FACING_FRONT);
- mFocusManager.setMirror(mirror);
- mFocusManager.setParameters(mInitialParams);
- setupPreview();
-
- openCameraCommon();
-
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- // Start switch camera animation. Post a message because
- // onFrameAvailable from the old camera may already exist.
- mHandler.sendEmptyMessage(SWITCH_CAMERA_START_ANIMATION);
- }
- }
-
- protected void setCameraId(int cameraId) {
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CAMERA_ID);
- pref.setValue("" + cameraId);
- }
-
- // either open a new camera or switch cameras
- private void openCameraCommon() {
- loadCameraPreferences();
-
- mUI.onCameraOpened(mPreferenceGroup, mPreferences, mParameters, this);
- updateSceneMode();
- showTapToFocusToastIfNeeded();
-
-
- }
-
- public void onScreenSizeChanged(int width, int height, int previewWidth, int previewHeight) {
- Log.d(TAG, "Preview size changed.");
- if (mFocusManager != null) mFocusManager.setPreviewSize(width, height);
- ((CameraScreenNail) mActivity.mCameraScreenNail).setPreviewFrameLayoutSize(
- previewWidth, previewHeight);
- mActivity.notifyScreenNailChanged();
- }
-
- private void resetExposureCompensation() {
- String value = mPreferences.getString(CameraSettings.KEY_EXPOSURE,
- CameraSettings.EXPOSURE_DEFAULT_VALUE);
- if (!CameraSettings.EXPOSURE_DEFAULT_VALUE.equals(value)) {
- Editor editor = mPreferences.edit();
- editor.putString(CameraSettings.KEY_EXPOSURE, "0");
- editor.apply();
- }
- }
-
- private void keepMediaProviderInstance() {
- // We want to keep a reference to MediaProvider in camera's lifecycle.
- // TODO: Utilize mMediaProviderClient instance to replace
- // ContentResolver calls.
- if (mMediaProviderClient == null) {
- mMediaProviderClient = mContentResolver
- .acquireContentProviderClient(MediaStore.AUTHORITY);
- }
- }
-
- // Snapshots can only be taken after this is called. It should be called
- // once only. We could have done these things in onCreate() but we want to
- // make preview screen appear as soon as possible.
- private void initializeFirstTime() {
- if (mFirstTimeInitialized) return;
-
- // Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
- mLocationManager.recordLocation(recordLocation);
-
- keepMediaProviderInstance();
-
- mUI.initializeFirstTime();
- MediaSaveService s = mActivity.getMediaSaveService();
- // We set the listener only when both service and shutterbutton
- // are initialized.
- if (s != null) {
- s.setListener(this);
- }
-
- mNamedImages = new NamedImages();
-
- mFirstTimeInitialized = true;
- addIdleHandler();
-
- mActivity.updateStorageSpaceAndHint();
- }
-
- // If the activity is paused and resumed, this method will be called in
- // onResume.
- private void initializeSecondTime() {
- // Start location update if needed.
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
- mLocationManager.recordLocation(recordLocation);
- MediaSaveService s = mActivity.getMediaSaveService();
- if (s != null) {
- s.setListener(this);
- }
- mNamedImages = new NamedImages();
- mUI.initializeSecondTime(mParameters);
- keepMediaProviderInstance();
- }
-
- @Override
- public void onSurfaceCreated(SurfaceHolder holder) {
- // Do not access the camera if camera start up thread is not finished.
- if (mCameraDevice == null || mCameraStartUpThread != null)
- return;
-
- mCameraDevice.setPreviewDisplayAsync(holder);
- // This happens when onConfigurationChanged arrives, surface has been
- // destroyed, and there is no onFullScreenChanged.
- if (mCameraState == PREVIEW_STOPPED) {
- setupPreview();
- }
- }
-
- private void showTapToFocusToastIfNeeded() {
- // Show the tap to focus toast if this is the first start.
- if (mFocusAreaSupported &&
- mPreferences.getBoolean(CameraSettings.KEY_CAMERA_FIRST_USE_HINT_SHOWN, true)) {
- // Delay the toast for one second to wait for orientation.
- mHandler.sendEmptyMessageDelayed(SHOW_TAP_TO_FOCUS_TOAST, 1000);
- }
- }
-
- private void addIdleHandler() {
- MessageQueue queue = Looper.myQueue();
- queue.addIdleHandler(new MessageQueue.IdleHandler() {
- @Override
- public boolean queueIdle() {
- Storage.ensureOSXCompatible();
- return false;
- }
- });
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- @Override
- public void startFaceDetection() {
- if (!ApiHelper.HAS_FACE_DETECTION) return;
- if (mFaceDetectionStarted) return;
- if (mParameters.getMaxNumDetectedFaces() > 0) {
- mFaceDetectionStarted = true;
- CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
- mUI.onStartFaceDetection(mDisplayOrientation,
- (info.facing == CameraInfo.CAMERA_FACING_FRONT));
- mCameraDevice.setFaceDetectionListener(mUI);
- mCameraDevice.startFaceDetection();
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- @Override
- public void stopFaceDetection() {
- if (!ApiHelper.HAS_FACE_DETECTION) return;
- if (!mFaceDetectionStarted) return;
- if (mParameters.getMaxNumDetectedFaces() > 0) {
- mFaceDetectionStarted = false;
- mCameraDevice.setFaceDetectionListener(null);
- mCameraDevice.stopFaceDetection();
- mUI.clearFaces();
- }
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent m) {
- if (mCameraState == SWITCHING_CAMERA) return true;
- return mUI.dispatchTouchEvent(m);
- }
-
- private final class ShutterCallback
- implements android.hardware.Camera.ShutterCallback {
-
- private boolean mAnimateFlash;
-
- public ShutterCallback(boolean animateFlash) {
- mAnimateFlash = animateFlash;
- }
-
- @Override
- public void onShutter() {
- mShutterCallbackTime = System.currentTimeMillis();
- mShutterLag = mShutterCallbackTime - mCaptureStartTime;
- Log.v(TAG, "mShutterLag = " + mShutterLag + "ms");
- if (mAnimateFlash) {
- mActivity.runOnUiThread(mFlashRunnable);
- }
- }
- }
-
- private final class PostViewPictureCallback implements PictureCallback {
- @Override
- public void onPictureTaken(
- byte [] data, android.hardware.Camera camera) {
- mPostViewPictureCallbackTime = System.currentTimeMillis();
- Log.v(TAG, "mShutterToPostViewCallbackTime = "
- + (mPostViewPictureCallbackTime - mShutterCallbackTime)
- + "ms");
- }
- }
-
- private final class RawPictureCallback implements PictureCallback {
- @Override
- public void onPictureTaken(
- byte [] rawData, android.hardware.Camera camera) {
- mRawPictureCallbackTime = System.currentTimeMillis();
- Log.v(TAG, "mShutterToRawCallbackTime = "
- + (mRawPictureCallbackTime - mShutterCallbackTime) + "ms");
- }
- }
-
- private final class JpegPictureCallback implements PictureCallback {
- Location mLocation;
-
- public JpegPictureCallback(Location loc) {
- mLocation = loc;
- }
-
- @Override
- public void onPictureTaken(
- final byte [] jpegData, final android.hardware.Camera camera) {
- if (mPaused) {
- return;
- }
- if (mSceneMode == Util.SCENE_MODE_HDR) {
- mActivity.showSwitcher();
- mActivity.setSwipingEnabled(true);
- }
-
- mJpegPictureCallbackTime = System.currentTimeMillis();
- // If postview callback has arrived, the captured image is displayed
- // in postview callback. If not, the captured image is displayed in
- // raw picture callback.
- if (mPostViewPictureCallbackTime != 0) {
- mShutterToPictureDisplayedTime =
- mPostViewPictureCallbackTime - mShutterCallbackTime;
- mPictureDisplayedToJpegCallbackTime =
- mJpegPictureCallbackTime - mPostViewPictureCallbackTime;
- } else {
- mShutterToPictureDisplayedTime =
- mRawPictureCallbackTime - mShutterCallbackTime;
- mPictureDisplayedToJpegCallbackTime =
- mJpegPictureCallbackTime - mRawPictureCallbackTime;
- }
- Log.v(TAG, "mPictureDisplayedToJpegCallbackTime = "
- + mPictureDisplayedToJpegCallbackTime + "ms");
-
- // Only animate when in full screen capture mode
- // i.e. If monkey/a user swipes to the gallery during picture taking,
- // don't show animation
- if (ApiHelper.HAS_SURFACE_TEXTURE && !mIsImageCaptureIntent
- && mActivity.mShowCameraAppView) {
- // Finish capture animation
- mHandler.removeMessages(CAPTURE_ANIMATION_DONE);
- ((CameraScreenNail) mActivity.mCameraScreenNail).animateSlide();
- mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
- CaptureAnimManager.getAnimationDuration());
- }
- mFocusManager.updateFocusUI(); // Ensure focus indicator is hidden.
- if (!mIsImageCaptureIntent) {
- if (ApiHelper.CAN_START_PREVIEW_IN_JPEG_CALLBACK) {
- setupPreview();
- } else {
- // Camera HAL of some devices have a bug. Starting preview
- // immediately after taking a picture will fail. Wait some
- // time before starting the preview.
- mHandler.sendEmptyMessageDelayed(SETUP_PREVIEW, 300);
- }
- }
-
- if (!mIsImageCaptureIntent) {
- // Calculate the width and the height of the jpeg.
- Size s = mParameters.getPictureSize();
- ExifInterface exif = Exif.getExif(jpegData);
- int orientation = Exif.getOrientation(exif);
- int width, height;
- if ((mJpegRotation + orientation) % 180 == 0) {
- width = s.width;
- height = s.height;
- } else {
- width = s.height;
- height = s.width;
- }
- String title = mNamedImages.getTitle();
- long date = mNamedImages.getDate();
- if (title == null) {
- Log.e(TAG, "Unbalanced name/data pair");
- } else {
- if (date == -1) date = mCaptureStartTime;
- if (mHeading >= 0) {
- // heading direction has been updated by the sensor.
- ExifTag directionRefTag = exif.buildTag(
- ExifInterface.TAG_GPS_IMG_DIRECTION_REF,
- ExifInterface.GpsTrackRef.MAGNETIC_DIRECTION);
- ExifTag directionTag = exif.buildTag(
- ExifInterface.TAG_GPS_IMG_DIRECTION,
- new Rational(mHeading, 1));
- exif.setTag(directionRefTag);
- exif.setTag(directionTag);
- }
- mActivity.getMediaSaveService().addImage(
- jpegData, title, date, mLocation, width, height,
- orientation, exif, mOnMediaSavedListener, mContentResolver);
- }
- } else {
- mJpegImageData = jpegData;
- if (!mQuickCapture) {
- mUI.showPostCaptureAlert();
- } else {
- onCaptureDone();
- }
- }
-
- // Check this in advance of each shot so we don't add to shutter
- // latency. It's true that someone else could write to the SD card in
- // the mean time and fill it, but that could have happened between the
- // shutter press and saving the JPEG too.
- mActivity.updateStorageSpaceAndHint();
-
- long now = System.currentTimeMillis();
- mJpegCallbackFinishTime = now - mJpegPictureCallbackTime;
- Log.v(TAG, "mJpegCallbackFinishTime = "
- + mJpegCallbackFinishTime + "ms");
- mJpegPictureCallbackTime = 0;
- }
- }
-
- private final class AutoFocusCallback
- implements android.hardware.Camera.AutoFocusCallback {
- @Override
- public void onAutoFocus(
- boolean focused, android.hardware.Camera camera) {
- if (mPaused) return;
-
- mAutoFocusTime = System.currentTimeMillis() - mFocusStartTime;
- Log.v(TAG, "mAutoFocusTime = " + mAutoFocusTime + "ms");
- setCameraState(IDLE);
- mFocusManager.onAutoFocus(focused, mUI.isShutterPressed());
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
- private final class AutoFocusMoveCallback
- implements android.hardware.Camera.AutoFocusMoveCallback {
- @Override
- public void onAutoFocusMoving(
- boolean moving, android.hardware.Camera camera) {
- mFocusManager.onAutoFocusMoving(moving);
- }
- }
-
- private static class NamedImages {
- private ArrayList<NamedEntity> mQueue;
- private boolean mStop;
- private NamedEntity mNamedEntity;
-
- public NamedImages() {
- mQueue = new ArrayList<NamedEntity>();
- }
-
- public void nameNewImage(ContentResolver resolver, long date) {
- NamedEntity r = new NamedEntity();
- r.title = Util.createJpegName(date);
- r.date = date;
- mQueue.add(r);
- }
-
- public String getTitle() {
- if (mQueue.isEmpty()) {
- mNamedEntity = null;
- return null;
- }
- mNamedEntity = mQueue.get(0);
- mQueue.remove(0);
-
- return mNamedEntity.title;
- }
-
- // Must be called after getTitle().
- public long getDate() {
- if (mNamedEntity == null) return -1;
- return mNamedEntity.date;
- }
-
- private static class NamedEntity {
- String title;
- long date;
- }
- }
-
- private void setCameraState(int state) {
- mCameraState = state;
- switch (state) {
- case PhotoController.PREVIEW_STOPPED:
- case PhotoController.SNAPSHOT_IN_PROGRESS:
- case PhotoController.FOCUSING:
- case PhotoController.SWITCHING_CAMERA:
- mUI.enableGestures(false);
- break;
- case PhotoController.IDLE:
- if (mActivity.isInCameraApp()) {
- mUI.enableGestures(true);
- }
- break;
- }
- }
-
- private void animateFlash() {
- // Only animate when in full screen capture mode
- // i.e. If monkey/a user swipes to the gallery during picture taking,
- // don't show animation
- if (ApiHelper.HAS_SURFACE_TEXTURE && !mIsImageCaptureIntent
- && mActivity.mShowCameraAppView) {
- // Start capture animation.
- ((CameraScreenNail) mActivity.mCameraScreenNail).animateFlash(mDisplayRotation);
- mUI.enablePreviewThumb(true);
- mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
- CaptureAnimManager.getAnimationDuration());
- }
- }
-
- @Override
- public boolean capture() {
- // If we are already in the middle of taking a snapshot or the image save request
- // is full then ignore.
- if (mCameraDevice == null || mCameraState == SNAPSHOT_IN_PROGRESS
- || mCameraState == SWITCHING_CAMERA
- || mActivity.getMediaSaveService().isQueueFull()) {
- return false;
- }
- mCaptureStartTime = System.currentTimeMillis();
- mPostViewPictureCallbackTime = 0;
- mJpegImageData = null;
-
- final boolean animateBefore = (mSceneMode == Util.SCENE_MODE_HDR);
-
- if (animateBefore) {
- animateFlash();
- }
-
- // Set rotation and gps data.
- int orientation;
- // We need to be consistent with the framework orientation (i.e. the
- // orientation of the UI.) when the auto-rotate screen setting is on.
- if (mActivity.isAutoRotateScreen()) {
- orientation = (360 - mDisplayRotation) % 360;
- } else {
- orientation = mOrientation;
- }
- mJpegRotation = Util.getJpegRotation(mCameraId, orientation);
- mParameters.setRotation(mJpegRotation);
- Location loc = mLocationManager.getCurrentLocation();
- Util.setGpsParameters(mParameters, loc);
- mCameraDevice.setParameters(mParameters);
-
- mCameraDevice.takePicture2(new ShutterCallback(!animateBefore),
- mRawPictureCallback, mPostViewPictureCallback,
- new JpegPictureCallback(loc), mCameraState,
- mFocusManager.getFocusState());
-
- mNamedImages.nameNewImage(mContentResolver, mCaptureStartTime);
-
- mFaceDetectionStarted = false;
- setCameraState(SNAPSHOT_IN_PROGRESS);
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
- UsageStatistics.ACTION_CAPTURE_DONE, "Photo");
- return true;
- }
-
- @Override
- public void setFocusParameters() {
- setCameraParameters(UPDATE_PARAM_PREFERENCE);
- }
-
- private int getPreferredCameraId(ComboPreferences preferences) {
- int intentCameraId = Util.getCameraFacingIntentExtras(mActivity);
- if (intentCameraId != -1) {
- // Testing purpose. Launch a specific camera through the intent
- // extras.
- return intentCameraId;
- } else {
- return CameraSettings.readPreferredCameraId(preferences);
- }
- }
-
- @Override
- public void onFullScreenChanged(boolean full) {
- mUI.onFullScreenChanged(full);
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- if (mActivity.mCameraScreenNail != null) {
- ((CameraScreenNail) mActivity.mCameraScreenNail).setFullScreen(full);
- }
- return;
- }
- }
-
- private void updateSceneMode() {
- // If scene mode is set, we cannot set flash mode, white balance, and
- // focus mode, instead, we read it from driver
- if (!Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) {
- overrideCameraSettings(mParameters.getFlashMode(),
- mParameters.getWhiteBalance(), mParameters.getFocusMode());
- } else {
- overrideCameraSettings(null, null, null);
- }
- }
-
- private void overrideCameraSettings(final String flashMode,
- final String whiteBalance, final String focusMode) {
- mUI.overrideSettings(
- CameraSettings.KEY_FLASH_MODE, flashMode,
- CameraSettings.KEY_WHITE_BALANCE, whiteBalance,
- CameraSettings.KEY_FOCUS_MODE, focusMode);
- }
-
- private void loadCameraPreferences() {
- CameraSettings settings = new CameraSettings(mActivity, mInitialParams,
- mCameraId, CameraHolder.instance().getCameraInfo());
- mPreferenceGroup = settings.getPreferenceGroup(R.xml.camera_preferences);
- }
-
- @Override
- public void onOrientationChanged(int orientation) {
- // We keep the last known orientation. So if the user first orient
- // the camera then point the camera to floor or sky, we still have
- // the correct orientation.
- if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) return;
- mOrientation = Util.roundOrientation(orientation, mOrientation);
-
- // Show the toast after getting the first orientation changed.
- if (mHandler.hasMessages(SHOW_TAP_TO_FOCUS_TOAST)) {
- mHandler.removeMessages(SHOW_TAP_TO_FOCUS_TOAST);
- showTapToFocusToast();
- }
- }
-
- @Override
- public void onStop() {
- if (mMediaProviderClient != null) {
- mMediaProviderClient.release();
- mMediaProviderClient = null;
- }
- }
-
- @Override
- public void onCaptureCancelled() {
- mActivity.setResultEx(Activity.RESULT_CANCELED, new Intent());
- mActivity.finish();
- }
-
- @Override
- public void onCaptureRetake() {
- if (mPaused)
- return;
- mUI.hidePostCaptureAlert();
- setupPreview();
- }
-
- @Override
- public void onCaptureDone() {
- if (mPaused) {
- return;
- }
-
- byte[] data = mJpegImageData;
-
- if (mCropValue == null) {
- // First handle the no crop case -- just return the value. If the
- // caller specifies a "save uri" then write the data to its
- // stream. Otherwise, pass back a scaled down version of the bitmap
- // directly in the extras.
- if (mSaveUri != null) {
- OutputStream outputStream = null;
- try {
- outputStream = mContentResolver.openOutputStream(mSaveUri);
- outputStream.write(data);
- outputStream.close();
-
- mActivity.setResultEx(Activity.RESULT_OK);
- mActivity.finish();
- } catch (IOException ex) {
- // ignore exception
- } finally {
- Util.closeSilently(outputStream);
- }
- } else {
- ExifInterface exif = Exif.getExif(data);
- int orientation = Exif.getOrientation(exif);
- Bitmap bitmap = Util.makeBitmap(data, 50 * 1024);
- bitmap = Util.rotate(bitmap, orientation);
- mActivity.setResultEx(Activity.RESULT_OK,
- new Intent("inline-data").putExtra("data", bitmap));
- mActivity.finish();
- }
- } else {
- // Save the image to a temp file and invoke the cropper
- Uri tempUri = null;
- FileOutputStream tempStream = null;
- try {
- File path = mActivity.getFileStreamPath(sTempCropFilename);
- path.delete();
- tempStream = mActivity.openFileOutput(sTempCropFilename, 0);
- tempStream.write(data);
- tempStream.close();
- tempUri = Uri.fromFile(path);
- } catch (FileNotFoundException ex) {
- mActivity.setResultEx(Activity.RESULT_CANCELED);
- mActivity.finish();
- return;
- } catch (IOException ex) {
- mActivity.setResultEx(Activity.RESULT_CANCELED);
- mActivity.finish();
- return;
- } finally {
- Util.closeSilently(tempStream);
- }
-
- Bundle newExtras = new Bundle();
- if (mCropValue.equals("circle")) {
- newExtras.putString("circleCrop", "true");
- }
- if (mSaveUri != null) {
- newExtras.putParcelable(MediaStore.EXTRA_OUTPUT, mSaveUri);
- } else {
- newExtras.putBoolean(CropExtras.KEY_RETURN_DATA, true);
- }
- if (mActivity.isSecureCamera()) {
- newExtras.putBoolean(CropExtras.KEY_SHOW_WHEN_LOCKED, true);
- }
-
- Intent cropIntent = new Intent(FilterShowActivity.CROP_ACTION);
-
- cropIntent.setData(tempUri);
- cropIntent.putExtras(newExtras);
-
- mActivity.startActivityForResult(cropIntent, REQUEST_CROP);
- }
- }
-
- @Override
- public void onShutterButtonFocus(boolean pressed) {
- if (mPaused || mUI.collapseCameraControls()
- || (mCameraState == SNAPSHOT_IN_PROGRESS)
- || (mCameraState == PREVIEW_STOPPED)) return;
-
- // Do not do focus if there is not enough storage.
- if (pressed && !canTakePicture()) return;
-
- if (pressed) {
- mFocusManager.onShutterDown();
- } else {
- // for countdown mode, we need to postpone the shutter release
- // i.e. lock the focus during countdown.
- if (!mUI.isCountingDown()) {
- mFocusManager.onShutterUp();
- }
- }
- }
-
- @Override
- public void onShutterButtonClick() {
- if (mPaused || mUI.collapseCameraControls()
- || (mCameraState == SWITCHING_CAMERA)
- || (mCameraState == PREVIEW_STOPPED)) return;
-
- // Do not take the picture if there is not enough storage.
- if (mActivity.getStorageSpace() <= Storage.LOW_STORAGE_THRESHOLD) {
- Log.i(TAG, "Not enough space or storage not ready. remaining="
- + mActivity.getStorageSpace());
- return;
- }
- Log.v(TAG, "onShutterButtonClick: mCameraState=" + mCameraState);
-
- if (mSceneMode == Util.SCENE_MODE_HDR) {
- mActivity.hideSwitcher();
- mActivity.setSwipingEnabled(false);
- }
- // If the user wants to do a snapshot while the previous one is still
- // in progress, remember the fact and do it after we finish the previous
- // one and re-start the preview. Snapshot in progress also includes the
- // state that autofocus is focusing and a picture will be taken when
- // focus callback arrives.
- if ((mFocusManager.isFocusingSnapOnFinish() || mCameraState == SNAPSHOT_IN_PROGRESS)
- && !mIsImageCaptureIntent) {
- mSnapshotOnIdle = true;
- return;
- }
-
- String timer = mPreferences.getString(
- CameraSettings.KEY_TIMER,
- mActivity.getString(R.string.pref_camera_timer_default));
- boolean playSound = mPreferences.getString(CameraSettings.KEY_TIMER_SOUND_EFFECTS,
- mActivity.getString(R.string.pref_camera_timer_sound_default))
- .equals(mActivity.getString(R.string.setting_on_value));
-
- int seconds = Integer.parseInt(timer);
- // When shutter button is pressed, check whether the previous countdown is
- // finished. If not, cancel the previous countdown and start a new one.
- if (mUI.isCountingDown()) {
- mUI.cancelCountDown();
- }
- if (seconds > 0) {
- mUI.startCountDown(seconds, playSound);
- } else {
- mSnapshotOnIdle = false;
- mFocusManager.doSnap();
- }
- }
-
- @Override
- public void installIntentFilter() {
- }
-
- @Override
- public boolean updateStorageHintOnResume() {
- return mFirstTimeInitialized;
- }
-
- @Override
- public void updateCameraAppView() {
- }
-
- @Override
- public void onResumeBeforeSuper() {
- mPaused = false;
- }
-
- @Override
- public void onResumeAfterSuper() {
- if (mOpenCameraFail || mCameraDisabled) return;
-
- mJpegPictureCallbackTime = 0;
- mZoomValue = 0;
-
- // Start the preview if it is not started.
- if (mCameraState == PREVIEW_STOPPED && mCameraStartUpThread == null) {
- resetExposureCompensation();
- mCameraStartUpThread = new CameraStartUpThread();
- mCameraStartUpThread.start();
- }
-
- // If first time initialization is not finished, put it in the
- // message queue.
- if (!mFirstTimeInitialized) {
- mHandler.sendEmptyMessage(FIRST_TIME_INIT);
- } else {
- initializeSecondTime();
- }
- keepScreenOnAwhile();
-
- // Dismiss open menu if exists.
- PopupManager.getInstance(mActivity).notifyShowPopup(null);
- UsageStatistics.onContentViewChanged(
- UsageStatistics.COMPONENT_CAMERA, "PhotoModule");
-
- Sensor gsensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
- if (gsensor != null) {
- mSensorManager.registerListener(this, gsensor, SensorManager.SENSOR_DELAY_NORMAL);
- }
-
- Sensor msensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
- if (msensor != null) {
- mSensorManager.registerListener(this, msensor, SensorManager.SENSOR_DELAY_NORMAL);
- }
- }
-
- void waitCameraStartUpThread() {
- try {
- if (mCameraStartUpThread != null) {
- mCameraStartUpThread.cancel();
- mCameraStartUpThread.join();
- mCameraStartUpThread = null;
- setCameraState(IDLE);
- }
- } catch (InterruptedException e) {
- // ignore
- }
- }
-
- @Override
- public void onPauseBeforeSuper() {
- mPaused = true;
- Sensor gsensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
- if (gsensor != null) {
- mSensorManager.unregisterListener(this, gsensor);
- }
-
- Sensor msensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
- if (msensor != null) {
- mSensorManager.unregisterListener(this, msensor);
- }
- }
-
- @Override
- public void onPauseAfterSuper() {
- // Wait the camera start up thread to finish.
- waitCameraStartUpThread();
-
- // When camera is started from secure lock screen for the first time
- // after screen on, the activity gets onCreate->onResume->onPause->onResume.
- // To reduce the latency, keep the camera for a short time so it does
- // not need to be opened again.
- if (mCameraDevice != null && mActivity.isSecureCamera()
- && ActivityBase.isFirstStartAfterScreenOn()) {
- ActivityBase.resetFirstStartAfterScreenOn();
- CameraHolder.instance().keep(KEEP_CAMERA_TIMEOUT);
- }
- // Reset the focus first. Camera CTS does not guarantee that
- // cancelAutoFocus is allowed after preview stops.
- if (mCameraDevice != null && mCameraState != PREVIEW_STOPPED) {
- mCameraDevice.cancelAutoFocus();
- }
- stopPreview();
- // Release surface texture.
- ((CameraScreenNail) mActivity.mCameraScreenNail).releaseSurfaceTexture();
-
- mNamedImages = null;
-
- if (mLocationManager != null) mLocationManager.recordLocation(false);
-
- // If we are in an image capture intent and has taken
- // a picture, we just clear it in onPause.
- mJpegImageData = null;
-
- // Remove the messages in the event queue.
- mHandler.removeMessages(SETUP_PREVIEW);
- mHandler.removeMessages(FIRST_TIME_INIT);
- mHandler.removeMessages(CHECK_DISPLAY_ROTATION);
- mHandler.removeMessages(SWITCH_CAMERA);
- mHandler.removeMessages(SWITCH_CAMERA_START_ANIMATION);
- mHandler.removeMessages(CAMERA_OPEN_DONE);
- mHandler.removeMessages(START_PREVIEW_DONE);
- mHandler.removeMessages(OPEN_CAMERA_FAIL);
- mHandler.removeMessages(CAMERA_DISABLED);
-
- closeCamera();
-
- resetScreenOn();
- mUI.onPause();
-
- mPendingSwitchCameraId = -1;
- if (mFocusManager != null) mFocusManager.removeMessages();
- MediaSaveService s = mActivity.getMediaSaveService();
- if (s != null) {
- s.setListener(null);
- }
- }
-
- /**
- * The focus manager is the first UI related element to get initialized,
- * and it requires the RenderOverlay, so initialize it here
- */
- private void initializeFocusManager() {
- // Create FocusManager object. startPreview needs it.
- // if mFocusManager not null, reuse it
- // otherwise create a new instance
- if (mFocusManager != null) {
- mFocusManager.removeMessages();
- } else {
- CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
- boolean mirror = (info.facing == CameraInfo.CAMERA_FACING_FRONT);
- String[] defaultFocusModes = mActivity.getResources().getStringArray(
- R.array.pref_camera_focusmode_default_array);
- mFocusManager = new FocusOverlayManager(mPreferences, defaultFocusModes,
- mInitialParams, this, mirror,
- mActivity.getMainLooper(), mUI);
- }
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- Log.v(TAG, "onConfigurationChanged");
- setDisplayOrientation();
- }
-
- @Override
- public void onActivityResult(
- int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case REQUEST_CROP: {
- Intent intent = new Intent();
- if (data != null) {
- Bundle extras = data.getExtras();
- if (extras != null) {
- intent.putExtras(extras);
- }
- }
- mActivity.setResultEx(resultCode, intent);
- mActivity.finish();
-
- File path = mActivity.getFileStreamPath(sTempCropFilename);
- path.delete();
-
- break;
- }
- }
- }
-
- private boolean canTakePicture() {
- return isCameraIdle() && (mActivity.getStorageSpace() > Storage.LOW_STORAGE_THRESHOLD);
- }
-
- @Override
- public void autoFocus() {
- mFocusStartTime = System.currentTimeMillis();
- mCameraDevice.autoFocus(mAutoFocusCallback);
- setCameraState(FOCUSING);
- }
-
- @Override
- public void cancelAutoFocus() {
- mCameraDevice.cancelAutoFocus();
- setCameraState(IDLE);
- setCameraParameters(UPDATE_PARAM_PREFERENCE);
- }
-
- // Preview area is touched. Handle touch focus.
- @Override
- public void onSingleTapUp(View view, int x, int y) {
- if (mPaused || mCameraDevice == null || !mFirstTimeInitialized
- || mCameraState == SNAPSHOT_IN_PROGRESS
- || mCameraState == SWITCHING_CAMERA
- || mCameraState == PREVIEW_STOPPED) {
- return;
- }
-
- // Do not trigger touch focus if popup window is opened.
- if (mUI.removeTopLevelPopup()) return;
-
- // Check if metering area or focus area is supported.
- if (!mFocusAreaSupported && !mMeteringAreaSupported) return;
- mFocusManager.onSingleTapUp(x, y);
- }
-
- @Override
- public boolean onBackPressed() {
- return mUI.onBackPressed();
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_VOLUME_UP:
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- case KeyEvent.KEYCODE_FOCUS:
- if (mActivity.isInCameraApp() && mFirstTimeInitialized) {
- if (event.getRepeatCount() == 0) {
- onShutterButtonFocus(true);
- }
- return true;
- }
- return false;
- case KeyEvent.KEYCODE_CAMERA:
- if (mFirstTimeInitialized && event.getRepeatCount() == 0) {
- onShutterButtonClick();
- }
- return true;
- case KeyEvent.KEYCODE_DPAD_CENTER:
- // If we get a dpad center event without any focused view, move
- // the focus to the shutter button and press it.
- if (mFirstTimeInitialized && event.getRepeatCount() == 0) {
- // Start auto-focus immediately to reduce shutter lag. After
- // the shutter button gets the focus, onShutterButtonFocus()
- // will be called again but it is fine.
- if (mUI.removeTopLevelPopup()) return true;
- onShutterButtonFocus(true);
- mUI.pressShutterButton();
- }
- return true;
- }
- return false;
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_VOLUME_UP:
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- if (mActivity.isInCameraApp() && mFirstTimeInitialized) {
- onShutterButtonClick();
- return true;
- }
- return false;
- case KeyEvent.KEYCODE_FOCUS:
- if (mFirstTimeInitialized) {
- onShutterButtonFocus(false);
- }
- return true;
- }
- return false;
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void closeCamera() {
- if (mCameraDevice != null) {
- mCameraDevice.setZoomChangeListener(null);
- if(ApiHelper.HAS_FACE_DETECTION) {
- mCameraDevice.setFaceDetectionListener(null);
- }
- mCameraDevice.setErrorCallback(null);
- CameraHolder.instance().release();
- mFaceDetectionStarted = false;
- mCameraDevice = null;
- setCameraState(PREVIEW_STOPPED);
- mFocusManager.onCameraReleased();
- }
- }
-
- private void setDisplayOrientation() {
- mDisplayRotation = Util.getDisplayRotation(mActivity);
- mDisplayOrientation = Util.getDisplayOrientation(mDisplayRotation, mCameraId);
- mCameraDisplayOrientation = Util.getDisplayOrientation(0, mCameraId);
- mUI.setDisplayOrientation(mDisplayOrientation);
- if (mFocusManager != null) {
- mFocusManager.setDisplayOrientation(mDisplayOrientation);
- }
- // GLRoot also uses the DisplayRotation, and needs to be told to layout to update
- mActivity.getGLRoot().requestLayoutContentPane();
- }
-
- // Only called by UI thread.
- private void setupPreview() {
- mFocusManager.resetTouchFocus();
- startPreview();
- setCameraState(IDLE);
- startFaceDetection();
- }
-
- // This can be called by UI Thread or CameraStartUpThread. So this should
- // not modify the views.
- private void startPreview() {
- mCameraDevice.setErrorCallback(mErrorCallback);
-
- // ICS camera frameworks has a bug. Face detection state is not cleared
- // after taking a picture. Stop the preview to work around it. The bug
- // was fixed in JB.
- if (mCameraState != PREVIEW_STOPPED) stopPreview();
-
- setDisplayOrientation();
-
- if (!mSnapshotOnIdle) {
- // If the focus mode is continuous autofocus, call cancelAutoFocus to
- // resume it because it may have been paused by autoFocus call.
- if (Util.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusManager.getFocusMode())) {
- mCameraDevice.cancelAutoFocus();
- }
- mFocusManager.setAeAwbLock(false); // Unlock AE and AWB.
- }
- setCameraParameters(UPDATE_PARAM_ALL);
-
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- CameraScreenNail screenNail = (CameraScreenNail) mActivity.mCameraScreenNail;
- if (mUI.getSurfaceTexture() == null) {
- Size size = mParameters.getPreviewSize();
- if (mCameraDisplayOrientation % 180 == 0) {
- screenNail.setSize(size.width, size.height);
- } else {
- screenNail.setSize(size.height, size.width);
- }
- screenNail.enableAspectRatioClamping();
- mActivity.notifyScreenNailChanged();
- screenNail.acquireSurfaceTexture();
- CameraStartUpThread t = mCameraStartUpThread;
- if (t != null && t.isCanceled()) {
- return; // Exiting, so no need to get the surface texture.
- }
- mUI.setSurfaceTexture(screenNail.getSurfaceTexture());
- } else {
- updatePreviewSize(screenNail);
- }
- mCameraDevice.setDisplayOrientation(mCameraDisplayOrientation);
- Object st = mUI.getSurfaceTexture();
- if (st != null) {
- mCameraDevice.setPreviewTextureAsync((SurfaceTexture) st);
- }
- } else {
- mCameraDevice.setDisplayOrientation(mDisplayOrientation);
- mCameraDevice.setPreviewDisplayAsync(mUI.getSurfaceHolder());
- }
-
- Log.v(TAG, "startPreview");
- mCameraDevice.startPreviewAsync();
-
- mFocusManager.onPreviewStarted();
-
- if (mSnapshotOnIdle) {
- mHandler.post(mDoSnapRunnable);
- }
- }
-
- private void updatePreviewSize(CameraScreenNail snail) {
- Size size = mParameters.getPreviewSize();
- int w = size.width;
- int h = size.height;
- if (mCameraDisplayOrientation % 180 != 0) {
- w = size.height;
- h = size.width;
- }
- if (snail.getWidth() != w || snail.getHeight() != h) {
- snail.setSize(w, h);
- }
- snail.enableAspectRatioClamping();
- mActivity.notifyScreenNailChanged();
- }
-
- @Override
- public void stopPreview() {
- if (mCameraDevice != null && mCameraState != PREVIEW_STOPPED) {
- Log.v(TAG, "stopPreview");
- mCameraDevice.stopPreview();
- mFaceDetectionStarted = false;
- }
- setCameraState(PREVIEW_STOPPED);
- if (mFocusManager != null) mFocusManager.onPreviewStopped();
- }
-
- @SuppressWarnings("deprecation")
- private void updateCameraParametersInitialize() {
- // Reset preview frame rate to the maximum because it may be lowered by
- // video camera application.
- List<Integer> frameRates = mParameters.getSupportedPreviewFrameRates();
- if (frameRates != null) {
- Integer max = Collections.max(frameRates);
- mParameters.setPreviewFrameRate(max);
- }
-
- mParameters.set(Util.RECORDING_HINT, Util.FALSE);
-
- // Disable video stabilization. Convenience methods not available in API
- // level <= 14
- String vstabSupported = mParameters.get("video-stabilization-supported");
- if ("true".equals(vstabSupported)) {
- mParameters.set("video-stabilization", "false");
- }
- }
-
- private void updateCameraParametersZoom() {
- // Set zoom.
- if (mParameters.isZoomSupported()) {
- mParameters.setZoom(mZoomValue);
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
- private void setAutoExposureLockIfSupported() {
- if (mAeLockSupported) {
- mParameters.setAutoExposureLock(mFocusManager.getAeAwbLock());
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
- private void setAutoWhiteBalanceLockIfSupported() {
- if (mAwbLockSupported) {
- mParameters.setAutoWhiteBalanceLock(mFocusManager.getAeAwbLock());
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void setFocusAreasIfSupported() {
- if (mFocusAreaSupported) {
- mParameters.setFocusAreas(mFocusManager.getFocusAreas());
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void setMeteringAreasIfSupported() {
- if (mMeteringAreaSupported) {
- // Use the same area for focus and metering.
- mParameters.setMeteringAreas(mFocusManager.getMeteringAreas());
- }
- }
-
- private void updateCameraParametersPreference() {
- setAutoExposureLockIfSupported();
- setAutoWhiteBalanceLockIfSupported();
- setFocusAreasIfSupported();
- setMeteringAreasIfSupported();
-
- // Set picture size.
- String pictureSize = mPreferences.getString(
- CameraSettings.KEY_PICTURE_SIZE, null);
- if (pictureSize == null) {
- CameraSettings.initialCameraPictureSize(mActivity, mParameters);
- } else {
- List<Size> supported = mParameters.getSupportedPictureSizes();
- CameraSettings.setCameraPictureSize(
- pictureSize, supported, mParameters);
- }
- Size size = mParameters.getPictureSize();
-
- // Set a preview size that is closest to the viewfinder height and has
- // the right aspect ratio.
- List<Size> sizes = mParameters.getSupportedPreviewSizes();
- Size optimalSize = Util.getOptimalPreviewSize(mActivity, sizes,
- (double) size.width / size.height);
- Size original = mParameters.getPreviewSize();
- if (!original.equals(optimalSize)) {
- mParameters.setPreviewSize(optimalSize.width, optimalSize.height);
- // Zoom related settings will be changed for different preview
- // sizes, so set and read the parameters to get latest values
- if (mHandler.getLooper() == Looper.myLooper()) {
- // On UI thread only, not when camera starts up
- setupPreview();
- } else {
- mCameraDevice.setParameters(mParameters);
- }
- mParameters = mCameraDevice.getParameters();
- }
- Log.v(TAG, "Preview size is " + optimalSize.width + "x" + optimalSize.height);
-
- // Since changing scene mode may change supported values, set scene mode
- // first. HDR is a scene mode. To promote it in UI, it is stored in a
- // separate preference.
- String hdr = mPreferences.getString(CameraSettings.KEY_CAMERA_HDR,
- mActivity.getString(R.string.pref_camera_hdr_default));
- if (mActivity.getString(R.string.setting_on_value).equals(hdr)) {
- mSceneMode = Util.SCENE_MODE_HDR;
- } else {
- mSceneMode = mPreferences.getString(
- CameraSettings.KEY_SCENE_MODE,
- mActivity.getString(R.string.pref_camera_scenemode_default));
- }
- if (Util.isSupported(mSceneMode, mParameters.getSupportedSceneModes())) {
- if (!mParameters.getSceneMode().equals(mSceneMode)) {
- mParameters.setSceneMode(mSceneMode);
-
- // Setting scene mode will change the settings of flash mode,
- // white balance, and focus mode. Here we read back the
- // parameters, so we can know those settings.
- mCameraDevice.setParameters(mParameters);
- mParameters = mCameraDevice.getParameters();
- }
- } else {
- mSceneMode = mParameters.getSceneMode();
- if (mSceneMode == null) {
- mSceneMode = Parameters.SCENE_MODE_AUTO;
- }
- }
-
- // Set JPEG quality.
- int jpegQuality = CameraProfile.getJpegEncodingQualityParameter(mCameraId,
- CameraProfile.QUALITY_HIGH);
- mParameters.setJpegQuality(jpegQuality);
-
- // For the following settings, we need to check if the settings are
- // still supported by latest driver, if not, ignore the settings.
-
- // Set exposure compensation
- int value = CameraSettings.readExposure(mPreferences);
- int max = mParameters.getMaxExposureCompensation();
- int min = mParameters.getMinExposureCompensation();
- if (value >= min && value <= max) {
- mParameters.setExposureCompensation(value);
- } else {
- Log.w(TAG, "invalid exposure range: " + value);
- }
-
- if (Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) {
- // Set flash mode.
- String flashMode = mPreferences.getString(
- CameraSettings.KEY_FLASH_MODE,
- mActivity.getString(R.string.pref_camera_flashmode_default));
- List<String> supportedFlash = mParameters.getSupportedFlashModes();
- if (Util.isSupported(flashMode, supportedFlash)) {
- mParameters.setFlashMode(flashMode);
- } else {
- flashMode = mParameters.getFlashMode();
- if (flashMode == null) {
- flashMode = mActivity.getString(
- R.string.pref_camera_flashmode_no_flash);
- }
- }
-
- // Set white balance parameter.
- String whiteBalance = mPreferences.getString(
- CameraSettings.KEY_WHITE_BALANCE,
- mActivity.getString(R.string.pref_camera_whitebalance_default));
- if (Util.isSupported(whiteBalance,
- mParameters.getSupportedWhiteBalance())) {
- mParameters.setWhiteBalance(whiteBalance);
- } else {
- whiteBalance = mParameters.getWhiteBalance();
- if (whiteBalance == null) {
- whiteBalance = Parameters.WHITE_BALANCE_AUTO;
- }
- }
-
- // Set focus mode.
- mFocusManager.overrideFocusMode(null);
- mParameters.setFocusMode(mFocusManager.getFocusMode());
- } else {
- mFocusManager.overrideFocusMode(mParameters.getFocusMode());
- }
-
- if (mContinousFocusSupported && ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK) {
- updateAutoFocusMoveCallback();
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
- private void updateAutoFocusMoveCallback() {
- if (mParameters.getFocusMode().equals(Util.FOCUS_MODE_CONTINUOUS_PICTURE)) {
- mCameraDevice.setAutoFocusMoveCallback(
- (AutoFocusMoveCallback) mAutoFocusMoveCallback);
- } else {
- mCameraDevice.setAutoFocusMoveCallback(null);
- }
- }
-
- // We separate the parameters into several subsets, so we can update only
- // the subsets actually need updating. The PREFERENCE set needs extra
- // locking because the preference can be changed from GLThread as well.
- private void setCameraParameters(int updateSet) {
- if ((updateSet & UPDATE_PARAM_INITIALIZE) != 0) {
- updateCameraParametersInitialize();
- }
-
- if ((updateSet & UPDATE_PARAM_ZOOM) != 0) {
- updateCameraParametersZoom();
- }
-
- if ((updateSet & UPDATE_PARAM_PREFERENCE) != 0) {
- updateCameraParametersPreference();
- }
-
- mCameraDevice.setParameters(mParameters);
- }
-
- // If the Camera is idle, update the parameters immediately, otherwise
- // accumulate them in mUpdateSet and update later.
- private void setCameraParametersWhenIdle(int additionalUpdateSet) {
- mUpdateSet |= additionalUpdateSet;
- if (mCameraDevice == null) {
- // We will update all the parameters when we open the device, so
- // we don't need to do anything now.
- mUpdateSet = 0;
- return;
- } else if (isCameraIdle()) {
- setCameraParameters(mUpdateSet);
- updateSceneMode();
- mUpdateSet = 0;
- } else {
- if (!mHandler.hasMessages(SET_CAMERA_PARAMETERS_WHEN_IDLE)) {
- mHandler.sendEmptyMessageDelayed(
- SET_CAMERA_PARAMETERS_WHEN_IDLE, 1000);
- }
- }
- }
-
- public boolean isCameraIdle() {
- return (mCameraState == IDLE) ||
- (mCameraState == PREVIEW_STOPPED) ||
- ((mFocusManager != null) && mFocusManager.isFocusCompleted()
- && (mCameraState != SWITCHING_CAMERA));
- }
-
- public boolean isImageCaptureIntent() {
- String action = mActivity.getIntent().getAction();
- return (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
- || ActivityBase.ACTION_IMAGE_CAPTURE_SECURE.equals(action));
- }
-
- private void setupCaptureParams() {
- Bundle myExtras = mActivity.getIntent().getExtras();
- if (myExtras != null) {
- mSaveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
- mCropValue = myExtras.getString("crop");
- }
- }
-
- @Override
- public void onSharedPreferenceChanged() {
- // ignore the events after "onPause()"
- if (mPaused) return;
-
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
- mLocationManager.recordLocation(recordLocation);
-
- setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE);
- mUI.updateOnScreenIndicators(mParameters, mPreferenceGroup, mPreferences);
- }
-
- @Override
- public void onCameraPickerClicked(int cameraId) {
- if (mPaused || mPendingSwitchCameraId != -1) return;
-
- mPendingSwitchCameraId = cameraId;
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- Log.v(TAG, "Start to copy texture. cameraId=" + cameraId);
- // We need to keep a preview frame for the animation before
- // releasing the camera. This will trigger onPreviewTextureCopied.
- ((CameraScreenNail) mActivity.mCameraScreenNail).copyTexture();
- // Disable all camera controls.
- setCameraState(SWITCHING_CAMERA);
- } else {
- switchCamera();
- }
- }
-
- // Preview texture has been copied. Now camera can be released and the
- // animation can be started.
- @Override
- public void onPreviewTextureCopied() {
- mHandler.sendEmptyMessage(SWITCH_CAMERA);
- }
-
- @Override
- public void onCaptureTextureCopied() {
- }
-
- @Override
- public void onUserInteraction() {
- if (!mActivity.isFinishing()) keepScreenOnAwhile();
- }
-
- private void resetScreenOn() {
- mHandler.removeMessages(CLEAR_SCREEN_DELAY);
- mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
-
- private void keepScreenOnAwhile() {
- mHandler.removeMessages(CLEAR_SCREEN_DELAY);
- mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- mHandler.sendEmptyMessageDelayed(CLEAR_SCREEN_DELAY, SCREEN_DELAY);
- }
-
- // TODO: Delete this function after old camera code is removed
- @Override
- public void onRestorePreferencesClicked() {
- }
-
- @Override
- public void onOverriddenPreferencesClicked() {
- if (mPaused) return;
- mUI.showPreferencesToast();
- }
-
- private void showTapToFocusToast() {
- // TODO: Use a toast?
- new RotateTextToast(mActivity, R.string.tap_to_focus, 0).show();
- // Clear the preference.
- Editor editor = mPreferences.edit();
- editor.putBoolean(CameraSettings.KEY_CAMERA_FIRST_USE_HINT_SHOWN, false);
- editor.apply();
- }
-
- private void initializeCapabilities() {
- mInitialParams = mCameraDevice.getParameters();
- mFocusAreaSupported = Util.isFocusAreaSupported(mInitialParams);
- mMeteringAreaSupported = Util.isMeteringAreaSupported(mInitialParams);
- mAeLockSupported = Util.isAutoExposureLockSupported(mInitialParams);
- mAwbLockSupported = Util.isAutoWhiteBalanceLockSupported(mInitialParams);
- mContinousFocusSupported = mInitialParams.getSupportedFocusModes().contains(
- Util.FOCUS_MODE_CONTINUOUS_PICTURE);
- }
-
- @Override
- public void onCountDownFinished() {
- mSnapshotOnIdle = false;
- mFocusManager.doSnap();
- mFocusManager.onShutterUp();
- }
-
- @Override
- public boolean needsSwitcher() {
- return !mIsImageCaptureIntent;
- }
-
- @Override
- public boolean needsPieMenu() {
- return true;
- }
-
- @Override
- public void onShowSwitcherPopup() {
- mUI.onShowSwitcherPopup();
- }
-
- @Override
- public int onZoomChanged(int index) {
- // Not useful to change zoom value when the activity is paused.
- if (mPaused) return index;
- mZoomValue = index;
- if (mParameters == null || mCameraDevice == null) return index;
- // Set zoom parameters asynchronously
- mParameters.setZoom(mZoomValue);
- mCameraDevice.setParameters(mParameters);
- Parameters p = mCameraDevice.getParameters();
- if (p != null) return p.getZoom();
- return index;
- }
-
- @Override
- public int getCameraState() {
- return mCameraState;
- }
-
- @Override
- public void onQueueStatus(boolean full) {
- mUI.enableShutter(!full);
- }
-
- @Override
- public void onMediaSaveServiceConnected(MediaSaveService s) {
- // We set the listener only when both service and shutterbutton
- // are initialized.
- if (mFirstTimeInitialized) {
- s.setListener(this);
- }
- }
-
- @Override
- public void onAccuracyChanged(Sensor sensor, int accuracy) {
- }
-
- @Override
- public void onSensorChanged(SensorEvent event) {
- int type = event.sensor.getType();
- float[] data;
- if (type == Sensor.TYPE_ACCELEROMETER) {
- data = mGData;
- } else if (type == Sensor.TYPE_MAGNETIC_FIELD) {
- data = mMData;
- } else {
- // we should not be here.
- return;
- }
- for (int i = 0; i < 3 ; i++) {
- data[i] = event.values[i];
- }
- float[] orientation = new float[3];
- SensorManager.getRotationMatrix(mR, null, mGData, mMData);
- SensorManager.getOrientation(mR, orientation);
- mHeading = (int) (orientation[0] * 180f / Math.PI) % 360;
- if (mHeading < 0) {
- mHeading += 360;
- }
- }
-}
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
deleted file mode 100644
index 68507f4..0000000
--- a/src/com/android/camera/PhotoUI.java
+++ /dev/null
@@ -1,691 +0,0 @@
-/*
- * 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.camera;
-
-import android.hardware.Camera;
-import android.hardware.Camera.Face;
-import android.hardware.Camera.FaceDetectionListener;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnLayoutChangeListener;
-import android.view.ViewGroup;
-import android.view.ViewStub;
-import android.widget.FrameLayout;
-import android.widget.FrameLayout.LayoutParams;
-import android.widget.Toast;
-
-import com.android.camera.CameraPreference.OnPreferenceChangedListener;
-import com.android.camera.FocusOverlayManager.FocusUI;
-import com.android.camera.ui.AbstractSettingPopup;
-import com.android.camera.ui.CountDownView;
-import com.android.camera.ui.CountDownView.OnCountDownFinishedListener;
-import com.android.camera.ui.FaceView;
-import com.android.camera.ui.FocusIndicator;
-import com.android.camera.ui.PieRenderer;
-import com.android.camera.ui.PieRenderer.PieListener;
-import com.android.camera.ui.RenderOverlay;
-import com.android.camera.ui.ZoomRenderer;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-import java.util.List;
-
-public class PhotoUI implements PieListener,
- SurfaceHolder.Callback,
- PreviewGestures.SingleTapListener,
- FocusUI,
- LocationManager.Listener,
- FaceDetectionListener,
- PreviewGestures.SwipeListener {
-
- private static final String TAG = "CAM_UI";
-
- private CameraActivity mActivity;
- private PhotoController mController;
- private PreviewGestures mGestures;
-
- private View mRootView;
- private Object mSurfaceTexture;
- private volatile SurfaceHolder mSurfaceHolder;
-
- private AbstractSettingPopup mPopup;
- private ShutterButton mShutterButton;
- private CountDownView mCountDownView;
-
- private FaceView mFaceView;
- private RenderOverlay mRenderOverlay;
- private View mReviewCancelButton;
- private View mReviewDoneButton;
- private View mReviewRetakeButton;
-
- private View mMenuButton;
- private View mBlocker;
- private PhotoMenu mMenu;
-
- private OnScreenIndicators mOnScreenIndicators;
-
- private PieRenderer mPieRenderer;
- private ZoomRenderer mZoomRenderer;
- private Toast mNotSelectableToast;
-
- private int mZoomMax;
- private List<Integer> mZoomRatios;
-
- private int mPreviewWidth = 0;
- private int mPreviewHeight = 0;
- private View mPreviewThumb;
-
- private OnLayoutChangeListener mLayoutListener = new OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right,
- int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- int width = right - left;
- int height = bottom - top;
- // Full-screen screennail
- int w = width;
- int h = height;
- if (Util.getDisplayRotation(mActivity) % 180 != 0) {
- w = height;
- h = width;
- }
- if (mPreviewWidth != width || mPreviewHeight != height) {
- mPreviewWidth = width;
- mPreviewHeight = height;
- mController.onScreenSizeChanged(width, height, w, h);
- }
- }
- };
-
- public PhotoUI(CameraActivity activity, PhotoController controller, View parent) {
- mActivity = activity;
- mController = controller;
- mRootView = parent;
-
- mActivity.getLayoutInflater().inflate(R.layout.photo_module,
- (ViewGroup) mRootView, true);
- mRenderOverlay = (RenderOverlay) mRootView.findViewById(R.id.render_overlay);
-
- initIndicators();
- mCountDownView = (CountDownView) (mRootView.findViewById(R.id.count_down_to_capture));
- mCountDownView.setCountDownFinishedListener((OnCountDownFinishedListener) mController);
-
- if (ApiHelper.HAS_FACE_DETECTION) {
- ViewStub faceViewStub = (ViewStub) mRootView
- .findViewById(R.id.face_view_stub);
- if (faceViewStub != null) {
- faceViewStub.inflate();
- mFaceView = (FaceView) mRootView.findViewById(R.id.face_view);
- }
- }
-
- }
-
- public View getRootView() {
- return mRootView;
- }
-
- private void initIndicators() {
- mOnScreenIndicators = new OnScreenIndicators(mActivity,
- mActivity.findViewById(R.id.on_screen_indicators));
- }
-
- public void onCameraOpened(PreferenceGroup prefGroup, ComboPreferences prefs,
- Camera.Parameters params, OnPreferenceChangedListener listener) {
- if (mPieRenderer == null) {
- mPieRenderer = new PieRenderer(mActivity);
- mPieRenderer.setPieListener(this);
- mRenderOverlay.addRenderer(mPieRenderer);
- }
- if (mMenu == null) {
- mMenu = new PhotoMenu(mActivity, this, mPieRenderer);
- mMenu.setListener(listener);
- }
- mMenu.initialize(prefGroup);
-
- if (mZoomRenderer == null) {
- mZoomRenderer = new ZoomRenderer(mActivity);
- mRenderOverlay.addRenderer(mZoomRenderer);
- }
- if (mGestures == null) {
- // this will handle gesture disambiguation and dispatching
- mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer,
- this);
- }
- mGestures.reset();
- mGestures.setRenderOverlay(mRenderOverlay);
- mGestures.addTouchReceiver(mMenuButton);
- mGestures.addUnclickableArea(mBlocker);
- enablePreviewThumb(false);
- // make sure to add touch targets for image capture
- if (mController.isImageCaptureIntent()) {
- if (mReviewCancelButton != null) {
- mGestures.addTouchReceiver(mReviewCancelButton);
- }
- if (mReviewDoneButton != null) {
- mGestures.addTouchReceiver(mReviewDoneButton);
- }
- }
- mRenderOverlay.requestLayout();
-
- initializeZoom(params);
- updateOnScreenIndicators(params, prefGroup, prefs);
- }
-
- private void openMenu() {
- if (mPieRenderer != null) {
- // If autofocus is not finished, cancel autofocus so that the
- // subsequent touch can be handled by PreviewGestures
- if (mController.getCameraState() == PhotoController.FOCUSING) {
- mController.cancelAutoFocus();
- }
- mPieRenderer.showInCenter();
- }
- }
-
- public void initializeControlByIntent() {
- mBlocker = mActivity.findViewById(R.id.blocker);
- mPreviewThumb = mActivity.findViewById(R.id.preview_thumb);
- mPreviewThumb.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mActivity.gotoGallery();
- }
- });
- mMenuButton = mActivity.findViewById(R.id.menu);
- mMenuButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- openMenu();
- }
- });
- if (mController.isImageCaptureIntent()) {
- mActivity.hideSwitcher();
- ViewGroup cameraControls = (ViewGroup) mActivity.findViewById(R.id.camera_controls);
- mActivity.getLayoutInflater().inflate(R.layout.review_module_control, cameraControls);
-
- mReviewDoneButton = mActivity.findViewById(R.id.btn_done);
- mReviewCancelButton = mActivity.findViewById(R.id.btn_cancel);
- mReviewRetakeButton = mActivity.findViewById(R.id.btn_retake);
- mReviewCancelButton.setVisibility(View.VISIBLE);
-
- mReviewDoneButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mController.onCaptureDone();
- }
- });
- mReviewCancelButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mController.onCaptureCancelled();
- }
- });
-
- mReviewRetakeButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mController.onCaptureRetake();
- }
- });
- }
- }
-
- // called from onResume but only the first time
- public void initializeFirstTime() {
- // Initialize shutter button.
- mShutterButton = mActivity.getShutterButton();
- mShutterButton.setImageResource(R.drawable.btn_new_shutter);
- mShutterButton.setOnShutterButtonListener(mController);
- mShutterButton.setVisibility(View.VISIBLE);
- mRootView.addOnLayoutChangeListener(mLayoutListener);
- }
-
- // called from onResume every other time
- public void initializeSecondTime(Camera.Parameters params) {
- initializeZoom(params);
- if (mController.isImageCaptureIntent()) {
- hidePostCaptureAlert();
- }
- if (mMenu != null) {
- mMenu.reloadPreferences();
- }
- mRootView.addOnLayoutChangeListener(mLayoutListener);
- }
-
- public void initializeZoom(Camera.Parameters params) {
- if ((params == null) || !params.isZoomSupported()
- || (mZoomRenderer == null)) return;
- mZoomMax = params.getMaxZoom();
- mZoomRatios = params.getZoomRatios();
- // Currently we use immediate zoom for fast zooming to get better UX and
- // there is no plan to take advantage of the smooth zoom.
- if (mZoomRenderer != null) {
- mZoomRenderer.setZoomMax(mZoomMax);
- mZoomRenderer.setZoom(params.getZoom());
- mZoomRenderer.setZoomValue(mZoomRatios.get(params.getZoom()));
- mZoomRenderer.setOnZoomChangeListener(new ZoomChangeListener());
- }
- }
-
- public void enableGestures(boolean enable) {
- if (mGestures != null) {
- mGestures.setEnabled(enable);
- }
- }
-
- @Override
- public void showGpsOnScreenIndicator(boolean hasSignal) { }
-
- @Override
- public void hideGpsOnScreenIndicator() { }
-
- public void overrideSettings(final String ... keyvalues) {
- mMenu.overrideSettings(keyvalues);
- }
-
- public void updateOnScreenIndicators(Camera.Parameters params,
- PreferenceGroup group, ComboPreferences prefs) {
- if (params == null) return;
- mOnScreenIndicators.updateSceneOnScreenIndicator(params.getSceneMode());
- mOnScreenIndicators.updateExposureOnScreenIndicator(params,
- CameraSettings.readExposure(prefs));
- mOnScreenIndicators.updateFlashOnScreenIndicator(params.getFlashMode());
- int wbIndex = 2;
- ListPreference pref = group.findPreference(CameraSettings.KEY_WHITE_BALANCE);
- if (pref != null) {
- wbIndex = pref.getCurrentIndex();
- }
- mOnScreenIndicators.updateWBIndicator(wbIndex);
- boolean location = RecordLocationPreference.get(
- prefs, mActivity.getContentResolver());
- mOnScreenIndicators.updateLocationIndicator(location);
- }
-
- public void setCameraState(int state) {
- }
-
- public boolean dispatchTouchEvent(MotionEvent m) {
- if (mGestures != null && mRenderOverlay != null) {
- return mGestures.dispatchTouch(m);
- }
- return false;
- }
-
- public boolean onBackPressed() {
- if (mPieRenderer != null && mPieRenderer.showsItems()) {
- mPieRenderer.hide();
- return true;
- }
- // In image capture mode, back button should:
- // 1) if there is any popup, dismiss them, 2) otherwise, get out of
- // image capture
- if (mController.isImageCaptureIntent()) {
- if (!removeTopLevelPopup()) {
- // no popup to dismiss, cancel image capture
- mController.onCaptureCancelled();
- }
- return true;
- } else if (!mController.isCameraIdle()) {
- // ignore backs while we're taking a picture
- return true;
- } else {
- return removeTopLevelPopup();
- }
- }
-
- public void onFullScreenChanged(boolean full) {
- if (mFaceView != null) {
- mFaceView.setBlockDraw(!full);
- }
- if (mPopup != null) {
- dismissPopup(full);
- }
- if (mGestures != null) {
- mGestures.setEnabled(full);
- }
- if (mRenderOverlay != null) {
- // this can not happen in capture mode
- mRenderOverlay.setVisibility(full ? View.VISIBLE : View.GONE);
- }
- if (mPieRenderer != null) {
- mPieRenderer.setBlockFocus(!full);
- }
- setShowMenu(full);
- if (mBlocker != null) {
- mBlocker.setVisibility(full ? View.VISIBLE : View.GONE);
- }
- if (!full && mCountDownView != null) mCountDownView.cancelCountDown();
- }
-
- public void enablePreviewThumb(boolean enabled) {
- if (enabled) {
- mGestures.addTouchReceiver(mPreviewThumb);
- mPreviewThumb.setVisibility(View.VISIBLE);
- } else {
- mGestures.removeTouchReceiver(mPreviewThumb);
- mPreviewThumb.setVisibility(View.GONE);
- }
- }
-
- public boolean removeTopLevelPopup() {
- // Remove the top level popup or dialog box and return true if there's any
- if (mPopup != null) {
- dismissPopup();
- return true;
- }
- return false;
- }
-
- public void showPopup(AbstractSettingPopup popup) {
- mActivity.hideUI();
- mBlocker.setVisibility(View.INVISIBLE);
- setShowMenu(false);
- mPopup = popup;
- mPopup.setVisibility(View.VISIBLE);
- FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT);
- lp.gravity = Gravity.CENTER;
- ((FrameLayout) mRootView).addView(mPopup, lp);
- mGestures.addTouchReceiver(mPopup);
- }
-
- public void dismissPopup() {
- dismissPopup(true);
- }
-
- private void dismissPopup(boolean fullScreen) {
- if (fullScreen) {
- mActivity.showUI();
- mBlocker.setVisibility(View.VISIBLE);
- }
- setShowMenu(fullScreen);
- if (mPopup != null) {
- mGestures.removeTouchReceiver(mPopup);
- ((FrameLayout) mRootView).removeView(mPopup);
- mPopup = null;
- }
- mMenu.popupDismissed();
- }
-
- public void onShowSwitcherPopup() {
- if (mPieRenderer != null && mPieRenderer.showsItems()) {
- mPieRenderer.hide();
- }
- }
-
- private void setShowMenu(boolean show) {
- if (mOnScreenIndicators != null) {
- mOnScreenIndicators.setVisibility(show ? View.VISIBLE : View.GONE);
- }
- if (mMenuButton != null) {
- mMenuButton.setVisibility(show ? View.VISIBLE : View.GONE);
- }
- }
-
- public boolean collapseCameraControls() {
- // Remove all the popups/dialog boxes
- boolean ret = false;
- if (mPopup != null) {
- dismissPopup();
- ret = true;
- }
- onShowSwitcherPopup();
- return ret;
- }
-
- protected void showPostCaptureAlert() {
- mOnScreenIndicators.setVisibility(View.GONE);
- mMenuButton.setVisibility(View.GONE);
- Util.fadeIn(mReviewDoneButton);
- mShutterButton.setVisibility(View.INVISIBLE);
- Util.fadeIn(mReviewRetakeButton);
- pauseFaceDetection();
- }
-
- protected void hidePostCaptureAlert() {
- mOnScreenIndicators.setVisibility(View.VISIBLE);
- mMenuButton.setVisibility(View.VISIBLE);
- Util.fadeOut(mReviewDoneButton);
- mShutterButton.setVisibility(View.VISIBLE);
- Util.fadeOut(mReviewRetakeButton);
- resumeFaceDetection();
- }
-
- public void setDisplayOrientation(int orientation) {
- if (mFaceView != null) {
- mFaceView.setDisplayOrientation(orientation);
- }
- }
-
- // shutter button handling
-
- public boolean isShutterPressed() {
- return mShutterButton.isPressed();
- }
-
- // focus handling
-
-
- private class ZoomChangeListener implements ZoomRenderer.OnZoomChangedListener {
- @Override
- public void onZoomValueChanged(int index) {
- int newZoom = mController.onZoomChanged(index);
- if (mZoomRenderer != null) {
- mZoomRenderer.setZoomValue(mZoomRatios.get(newZoom));
- }
- }
-
- @Override
- public void onZoomStart() {
- if (mPieRenderer != null) {
- mPieRenderer.setBlockFocus(true);
- }
- }
-
- @Override
- public void onZoomEnd() {
- if (mPieRenderer != null) {
- mPieRenderer.setBlockFocus(false);
- }
- }
- }
-
- @Override
- public void onPieOpened(int centerX, int centerY) {
- dismissPopup();
- mActivity.cancelActivityTouchHandling();
- mActivity.setSwipingEnabled(false);
- if (mFaceView != null) {
- mFaceView.setBlockDraw(true);
- }
- }
-
- @Override
- public void onPieClosed() {
- mActivity.setSwipingEnabled(true);
- if (mFaceView != null) {
- mFaceView.setBlockDraw(false);
- }
- }
-
- // Surface Listener
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- Log.v(TAG, "surfaceChanged:" + holder + " width=" + width + ". height="
- + height);
- }
-
- @Override
- public void surfaceCreated(SurfaceHolder holder) {
- Log.v(TAG, "surfaceCreated: " + holder);
- mSurfaceHolder = holder;
- mController.onSurfaceCreated(holder);
- }
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {
- Log.v(TAG, "surfaceDestroyed: " + holder);
- mSurfaceHolder = null;
- mController.stopPreview();
- }
-
- public Object getSurfaceTexture() {
- return mSurfaceTexture;
- }
-
- public void setSurfaceTexture(Object st) {
- mSurfaceTexture = st;
- }
-
- public SurfaceHolder getSurfaceHolder() {
- return mSurfaceHolder;
- }
-
- public boolean isCountingDown() {
- return mCountDownView.isCountingDown();
- }
-
- public void cancelCountDown() {
- mCountDownView.cancelCountDown();
- }
-
- public void startCountDown(int sec, boolean playSound) {
- mCountDownView.startCountDown(sec, playSound);
- }
-
- public void showPreferencesToast() {
- if (mNotSelectableToast == null) {
- String str = mActivity.getResources().getString(R.string.not_selectable_in_scene_mode);
- mNotSelectableToast = Toast.makeText(mActivity, str, Toast.LENGTH_SHORT);
- }
- mNotSelectableToast.show();
- }
-
- public void onPause() {
- mCountDownView.cancelCountDown();
- // Close the camera now because other activities may need to use it.
- mSurfaceTexture = null;
-
- // Clear UI.
- collapseCameraControls();
- if (mFaceView != null) mFaceView.clear();
-
-
- mRootView.removeOnLayoutChangeListener(mLayoutListener);
- mPreviewWidth = 0;
- mPreviewHeight = 0;
- }
-
- public void enableShutter(boolean enabled) {
- if (mShutterButton != null) {
- mShutterButton.setEnabled(enabled);
- }
- }
-
- public void pressShutterButton() {
- if (mShutterButton.isInTouchMode()) {
- mShutterButton.requestFocusFromTouch();
- } else {
- mShutterButton.requestFocus();
- }
- mShutterButton.setPressed(true);
- }
-
- // forward from preview gestures to controller
- @Override
- public void onSingleTapUp(View view, int x, int y) {
- mController.onSingleTapUp(view, x, y);
- }
-
- // focus UI implementation
-
- private FocusIndicator getFocusIndicator() {
- return (mFaceView != null && mFaceView.faceExists()) ? mFaceView : mPieRenderer;
- }
-
- @Override
- public boolean hasFaces() {
- return (mFaceView != null && mFaceView.faceExists());
- }
-
- public void clearFaces() {
- if (mFaceView != null) mFaceView.clear();
- }
-
- @Override
- public void clearFocus() {
- FocusIndicator indicator = getFocusIndicator();
- if (indicator != null) indicator.clear();
- }
-
- @Override
- public void setFocusPosition(int x, int y) {
- mPieRenderer.setFocus(x, y);
- }
-
- @Override
- public void onFocusStarted() {
- getFocusIndicator().showStart();
- }
-
- @Override
- public void onFocusSucceeded(boolean timeout) {
- getFocusIndicator().showSuccess(timeout);
- }
-
- @Override
- public void onFocusFailed(boolean timeout) {
- getFocusIndicator().showFail(timeout);
- }
-
- @Override
- public void pauseFaceDetection() {
- if (mFaceView != null) mFaceView.pause();
- }
-
- @Override
- public void resumeFaceDetection() {
- if (mFaceView != null) mFaceView.resume();
- }
-
- public void onStartFaceDetection(int orientation, boolean mirror) {
- mFaceView.clear();
- mFaceView.setVisibility(View.VISIBLE);
- mFaceView.setDisplayOrientation(orientation);
- mFaceView.setMirror(mirror);
- mFaceView.resume();
- }
-
- @Override
- public void onFaceDetection(Face[] faces, android.hardware.Camera camera) {
- mFaceView.setFaces(faces);
- }
-
- @Override
- public void onSwipe(int direction) {
- if (direction == PreviewGestures.DIR_UP) {
- openMenu();
- }
- }
-
-}
diff --git a/src/com/android/camera/PieController.java b/src/com/android/camera/PieController.java
deleted file mode 100644
index 3cbcb4b..0000000
--- a/src/com/android/camera/PieController.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.app.Activity;
-import android.graphics.drawable.Drawable;
-import android.util.Log;
-
-import com.android.camera.CameraPreference.OnPreferenceChangedListener;
-import com.android.camera.drawable.TextDrawable;
-import com.android.camera.ui.PieItem;
-import com.android.camera.ui.PieItem.OnClickListener;
-import com.android.camera.ui.PieRenderer;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class PieController {
-
- private static String TAG = "CAM_piecontrol";
-
- protected static final int MODE_PHOTO = 0;
- protected static final int MODE_VIDEO = 1;
-
- protected static float CENTER = (float) Math.PI / 2;
- protected static final float SWEEP = 0.06f;
-
- protected Activity mActivity;
- protected PreferenceGroup mPreferenceGroup;
- protected OnPreferenceChangedListener mListener;
- protected PieRenderer mRenderer;
- private List<IconListPreference> mPreferences;
- private Map<IconListPreference, PieItem> mPreferenceMap;
- private Map<IconListPreference, String> mOverrides;
-
- public void setListener(OnPreferenceChangedListener listener) {
- mListener = listener;
- }
-
- public PieController(Activity activity, PieRenderer pie) {
- mActivity = activity;
- mRenderer = pie;
- mPreferences = new ArrayList<IconListPreference>();
- mPreferenceMap = new HashMap<IconListPreference, PieItem>();
- mOverrides = new HashMap<IconListPreference, String>();
- }
-
- public void initialize(PreferenceGroup group) {
- mRenderer.clearItems();
- mPreferenceMap.clear();
- setPreferenceGroup(group);
- }
-
- public void onSettingChanged(ListPreference pref) {
- if (mListener != null) {
- mListener.onSharedPreferenceChanged();
- }
- }
-
- protected void setCameraId(int cameraId) {
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CAMERA_ID);
- pref.setValue("" + cameraId);
- }
-
- protected PieItem makeItem(int resId) {
- // We need a mutable version as we change the alpha
- Drawable d = mActivity.getResources().getDrawable(resId).mutate();
- return new PieItem(d, 0);
- }
-
- protected PieItem makeItem(CharSequence value) {
- TextDrawable drawable = new TextDrawable(mActivity.getResources(), value);
- return new PieItem(drawable, 0);
- }
-
- public PieItem makeItem(String prefKey) {
- final IconListPreference pref =
- (IconListPreference) mPreferenceGroup.findPreference(prefKey);
- if (pref == null) return null;
- int[] iconIds = pref.getLargeIconIds();
- int resid = -1;
- if (!pref.getUseSingleIcon() && iconIds != null) {
- // Each entry has a corresponding icon.
- int index = pref.findIndexOfValue(pref.getValue());
- resid = iconIds[index];
- } else {
- // The preference only has a single icon to represent it.
- resid = pref.getSingleIcon();
- }
- PieItem item = makeItem(resid);
- item.setLabel(pref.getTitle().toUpperCase());
- mPreferences.add(pref);
- mPreferenceMap.put(pref, item);
- int nOfEntries = pref.getEntries().length;
- if (nOfEntries > 1) {
- for (int i = 0; i < nOfEntries; i++) {
- PieItem inner = null;
- if (iconIds != null) {
- inner = makeItem(iconIds[i]);
- } else {
- inner = makeItem(pref.getEntries()[i]);
- }
- inner.setLabel(pref.getLabels()[i]);
- item.addItem(inner);
- final int index = i;
- inner.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(PieItem item) {
- pref.setValueIndex(index);
- reloadPreference(pref);
- onSettingChanged(pref);
- }
- });
- }
- }
- return item;
- }
-
- public PieItem makeSwitchItem(final String prefKey, boolean addListener) {
- final IconListPreference pref =
- (IconListPreference) mPreferenceGroup.findPreference(prefKey);
- if (pref == null) return null;
- int[] iconIds = pref.getLargeIconIds();
- int resid = -1;
- int index = pref.findIndexOfValue(pref.getValue());
- if (!pref.getUseSingleIcon() && iconIds != null) {
- // Each entry has a corresponding icon.
- resid = iconIds[index];
- } else {
- // The preference only has a single icon to represent it.
- resid = pref.getSingleIcon();
- }
- PieItem item = makeItem(resid);
- item.setLabel(pref.getLabels()[index]);
- item.setImageResource(mActivity, resid);
- mPreferences.add(pref);
- mPreferenceMap.put(pref, item);
- if (addListener) {
- final PieItem fitem = item;
- item.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(PieItem item) {
- IconListPreference pref = (IconListPreference) mPreferenceGroup
- .findPreference(prefKey);
- int index = pref.findIndexOfValue(pref.getValue());
- CharSequence[] values = pref.getEntryValues();
- index = (index + 1) % values.length;
- pref.setValueIndex(index);
- fitem.setLabel(pref.getLabels()[index]);
- fitem.setImageResource(mActivity,
- ((IconListPreference) pref).getLargeIconIds()[index]);
- reloadPreference(pref);
- onSettingChanged(pref);
- }
- });
- }
- return item;
- }
-
-
- public PieItem makeDialItem(ListPreference pref, int iconId, float center, float sweep) {
- PieItem item = makeItem(iconId);
- return item;
- }
-
- public void addItem(String prefKey) {
- PieItem item = makeItem(prefKey);
- mRenderer.addItem(item);
- }
-
- public void updateItem(PieItem item, String prefKey) {
- IconListPreference pref = (IconListPreference) mPreferenceGroup
- .findPreference(prefKey);
- if (pref != null) {
- int index = pref.findIndexOfValue(pref.getValue());
- item.setLabel(pref.getLabels()[index]);
- item.setImageResource(mActivity,
- ((IconListPreference) pref).getLargeIconIds()[index]);
- }
- }
-
- public void setPreferenceGroup(PreferenceGroup group) {
- mPreferenceGroup = group;
- }
-
- public void reloadPreferences() {
- mPreferenceGroup.reloadValue();
- for (IconListPreference pref : mPreferenceMap.keySet()) {
- reloadPreference(pref);
- }
- }
-
- private void reloadPreference(IconListPreference pref) {
- if (pref.getUseSingleIcon()) return;
- PieItem item = mPreferenceMap.get(pref);
- String overrideValue = mOverrides.get(pref);
- int[] iconIds = pref.getLargeIconIds();
- if (iconIds != null) {
- // Each entry has a corresponding icon.
- int index;
- if (overrideValue == null) {
- index = pref.findIndexOfValue(pref.getValue());
- } else {
- index = pref.findIndexOfValue(overrideValue);
- if (index == -1) {
- // Avoid the crash if camera driver has bugs.
- Log.e(TAG, "Fail to find override value=" + overrideValue);
- pref.print();
- return;
- }
- }
- item.setImageResource(mActivity, iconIds[index]);
- } else {
- // The preference only has a single icon to represent it.
- item.setImageResource(mActivity, pref.getSingleIcon());
- }
- }
-
- // Scene mode may override other camera settings (ex: flash mode).
- public void overrideSettings(final String ... keyvalues) {
- if (keyvalues.length % 2 != 0) {
- throw new IllegalArgumentException();
- }
- for (IconListPreference pref : mPreferenceMap.keySet()) {
- override(pref, keyvalues);
- }
- }
-
- private void override(IconListPreference pref, final String ... keyvalues) {
- mOverrides.remove(pref);
- for (int i = 0; i < keyvalues.length; i += 2) {
- String key = keyvalues[i];
- String value = keyvalues[i + 1];
- if (key.equals(pref.getKey())) {
- mOverrides.put(pref, value);
- PieItem item = mPreferenceMap.get(pref);
- item.setEnabled(value == null);
- break;
- }
- }
- reloadPreference(pref);
- }
-}
diff --git a/src/com/android/camera/PreferenceGroup.java b/src/com/android/camera/PreferenceGroup.java
deleted file mode 100644
index 4d0519f..0000000
--- a/src/com/android/camera/PreferenceGroup.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import java.util.ArrayList;
-
-/**
- * A collection of <code>CameraPreference</code>s. It may contain other
- * <code>PreferenceGroup</code> and form a tree structure.
- */
-public class PreferenceGroup extends CameraPreference {
- private ArrayList<CameraPreference> list =
- new ArrayList<CameraPreference>();
-
- public PreferenceGroup(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void addChild(CameraPreference child) {
- list.add(child);
- }
-
- public void removePreference(int index) {
- list.remove(index);
- }
-
- public CameraPreference get(int index) {
- return list.get(index);
- }
-
- public int size() {
- return list.size();
- }
-
- @Override
- public void reloadValue() {
- for (CameraPreference pref : list) {
- pref.reloadValue();
- }
- }
-
- /**
- * Finds the preference with the given key recursively. Returns
- * <code>null</code> if cannot find.
- */
- public ListPreference findPreference(String key) {
- // Find a leaf preference with the given key. Currently, the base
- // type of all "leaf" preference is "ListPreference". If we add some
- // other types later, we need to change the code.
- for (CameraPreference pref : list) {
- if (pref instanceof ListPreference) {
- ListPreference listPref = (ListPreference) pref;
- if(listPref.getKey().equals(key)) return listPref;
- } else if(pref instanceof PreferenceGroup) {
- ListPreference listPref =
- ((PreferenceGroup) pref).findPreference(key);
- if (listPref != null) return listPref;
- }
- }
- return null;
- }
-}
diff --git a/src/com/android/camera/PreferenceInflater.java b/src/com/android/camera/PreferenceInflater.java
deleted file mode 100644
index 231c983..0000000
--- a/src/com/android/camera/PreferenceInflater.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.util.Xml;
-import android.view.InflateException;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * Inflate <code>CameraPreference</code> from XML resource.
- */
-public class PreferenceInflater {
- private static final String PACKAGE_NAME =
- PreferenceInflater.class.getPackage().getName();
-
- private static final Class<?>[] CTOR_SIGNATURE =
- new Class[] {Context.class, AttributeSet.class};
- private static final HashMap<String, Constructor<?>> sConstructorMap =
- new HashMap<String, Constructor<?>>();
-
- private Context mContext;
-
- public PreferenceInflater(Context context) {
- mContext = context;
- }
-
- public CameraPreference inflate(int resId) {
- return inflate(mContext.getResources().getXml(resId));
- }
-
- private CameraPreference newPreference(String tagName, Object[] args) {
- String name = PACKAGE_NAME + "." + tagName;
- Constructor<?> constructor = sConstructorMap.get(name);
- try {
- if (constructor == null) {
- // Class not found in the cache, see if it's real, and try to
- // add it
- Class<?> clazz = mContext.getClassLoader().loadClass(name);
- constructor = clazz.getConstructor(CTOR_SIGNATURE);
- sConstructorMap.put(name, constructor);
- }
- return (CameraPreference) constructor.newInstance(args);
- } catch (NoSuchMethodException e) {
- throw new InflateException("Error inflating class " + name, e);
- } catch (ClassNotFoundException e) {
- throw new InflateException("No such class: " + name, e);
- } catch (Exception e) {
- throw new InflateException("While create instance of" + name, e);
- }
- }
-
- private CameraPreference inflate(XmlPullParser parser) {
-
- AttributeSet attrs = Xml.asAttributeSet(parser);
- ArrayList<CameraPreference> list = new ArrayList<CameraPreference>();
- Object args[] = new Object[]{mContext, attrs};
-
- try {
- for (int type = parser.next();
- type != XmlPullParser.END_DOCUMENT; type = parser.next()) {
- if (type != XmlPullParser.START_TAG) continue;
- CameraPreference pref = newPreference(parser.getName(), args);
-
- int depth = parser.getDepth();
- if (depth > list.size()) {
- list.add(pref);
- } else {
- list.set(depth - 1, pref);
- }
- if (depth > 1) {
- ((PreferenceGroup) list.get(depth - 2)).addChild(pref);
- }
- }
-
- if (list.size() == 0) {
- throw new InflateException("No root element found");
- }
- return list.get(0);
- } catch (XmlPullParserException e) {
- throw new InflateException(e);
- } catch (IOException e) {
- throw new InflateException(parser.getPositionDescription(), e);
- }
- }
-}
diff --git a/src/com/android/camera/PreviewFrameLayout.java b/src/com/android/camera/PreviewFrameLayout.java
deleted file mode 100644
index 03ef91c..0000000
--- a/src/com/android/camera/PreviewFrameLayout.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.content.Context;
-import android.content.res.Configuration;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewStub;
-import android.widget.RelativeLayout;
-
-import com.android.camera.ui.LayoutChangeHelper;
-import com.android.camera.ui.LayoutChangeNotifier;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-/**
- * A layout which handles the preview aspect ratio.
- */
-public class PreviewFrameLayout extends RelativeLayout implements LayoutChangeNotifier {
-
- private static final String TAG = "CAM_preview";
-
- /** A callback to be invoked when the preview frame's size changes. */
- public interface OnSizeChangedListener {
- public void onSizeChanged(int width, int height);
- }
-
- private double mAspectRatio;
- private View mBorder;
- private OnSizeChangedListener mListener;
- private LayoutChangeHelper mLayoutChangeHelper;
-
- public PreviewFrameLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- setAspectRatio(4.0 / 3.0);
- mLayoutChangeHelper = new LayoutChangeHelper(this);
- }
-
- @Override
- protected void onFinishInflate() {
- mBorder = findViewById(R.id.preview_border);
- }
-
- public void setAspectRatio(double ratio) {
- if (ratio <= 0.0) throw new IllegalArgumentException();
-
- if (mAspectRatio != ratio) {
- mAspectRatio = ratio;
- requestLayout();
- }
- }
-
- public void showBorder(boolean enabled) {
- mBorder.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
- }
-
- public void fadeOutBorder() {
- Util.fadeOut(mBorder);
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- int previewWidth = MeasureSpec.getSize(widthSpec);
- int previewHeight = MeasureSpec.getSize(heightSpec);
-
- if (!ApiHelper.HAS_SURFACE_TEXTURE) {
- // Get the padding of the border background.
- int hPadding = getPaddingLeft() + getPaddingRight();
- int vPadding = getPaddingTop() + getPaddingBottom();
-
- // Resize the preview frame with correct aspect ratio.
- previewWidth -= hPadding;
- previewHeight -= vPadding;
-
- boolean widthLonger = previewWidth > previewHeight;
- int longSide = (widthLonger ? previewWidth : previewHeight);
- int shortSide = (widthLonger ? previewHeight : previewWidth);
- if (longSide > shortSide * mAspectRatio) {
- longSide = (int) ((double) shortSide * mAspectRatio);
- } else {
- shortSide = (int) ((double) longSide / mAspectRatio);
- }
- if (widthLonger) {
- previewWidth = longSide;
- previewHeight = shortSide;
- } else {
- previewWidth = shortSide;
- previewHeight = longSide;
- }
-
- // Add the padding of the border.
- previewWidth += hPadding;
- previewHeight += vPadding;
- }
-
- // Ask children to follow the new preview dimension.
- super.onMeasure(MeasureSpec.makeMeasureSpec(previewWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(previewHeight, MeasureSpec.EXACTLY));
- }
-
- public void setOnSizeChangedListener(OnSizeChangedListener listener) {
- mListener = listener;
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- if (mListener != null) mListener.onSizeChanged(w, h);
- }
-
- @Override
- public void setOnLayoutChangeListener(
- LayoutChangeNotifier.Listener listener) {
- mLayoutChangeHelper.setOnLayoutChangeListener(listener);
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- super.onLayout(changed, l, t, r, b);
- mLayoutChangeHelper.onLayout(changed, l, t, r, b);
- }
-}
diff --git a/src/com/android/camera/PreviewGestures.java b/src/com/android/camera/PreviewGestures.java
deleted file mode 100644
index 0b80ff6..0000000
--- a/src/com/android/camera/PreviewGestures.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.os.Handler;
-import android.os.Message;
-import android.view.MotionEvent;
-import android.view.ScaleGestureDetector;
-import android.view.View;
-import android.view.ViewConfiguration;
-
-import com.android.camera.ui.PieRenderer;
-import com.android.camera.ui.RenderOverlay;
-import com.android.camera.ui.ZoomRenderer;
-import com.android.gallery3d.R;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class PreviewGestures
- implements ScaleGestureDetector.OnScaleGestureListener {
-
- private static final String TAG = "CAM_gestures";
-
- private static final long TIMEOUT_PIE = 200;
- private static final int MSG_PIE = 1;
- private static final int MODE_NONE = 0;
- private static final int MODE_PIE = 1;
- private static final int MODE_ZOOM = 2;
- private static final int MODE_MODULE = 3;
- private static final int MODE_ALL = 4;
- private static final int MODE_SWIPE = 5;
-
- public static final int DIR_UP = 0;
- public static final int DIR_DOWN = 1;
- public static final int DIR_LEFT = 2;
- public static final int DIR_RIGHT = 3;
-
- private CameraActivity mActivity;
- private SingleTapListener mTapListener;
- private RenderOverlay mOverlay;
- private PieRenderer mPie;
- private ZoomRenderer mZoom;
- private MotionEvent mDown;
- private MotionEvent mCurrent;
- private ScaleGestureDetector mScale;
- private List<View> mReceivers;
- private List<View> mUnclickableAreas;
- private int mMode;
- private int mSlop;
- private int mTapTimeout;
- private boolean mEnabled;
- private boolean mZoomOnly;
- private int mOrientation;
- private int[] mLocation;
- private SwipeListener mSwipeListener;
-
- private Handler mHandler = new Handler() {
- public void handleMessage(Message msg) {
- if (msg.what == MSG_PIE) {
- mMode = MODE_PIE;
- openPie();
- cancelActivityTouchHandling(mDown);
- }
- }
- };
-
- public interface SingleTapListener {
- public void onSingleTapUp(View v, int x, int y);
- }
-
- interface SwipeListener {
- public void onSwipe(int direction);
- }
-
- public PreviewGestures(CameraActivity ctx, SingleTapListener tapListener,
- ZoomRenderer zoom, PieRenderer pie, SwipeListener swipe) {
- mActivity = ctx;
- mTapListener = tapListener;
- mPie = pie;
- mZoom = zoom;
- mMode = MODE_ALL;
- mScale = new ScaleGestureDetector(ctx, this);
- mSlop = (int) ctx.getResources().getDimension(R.dimen.pie_touch_slop);
- mTapTimeout = ViewConfiguration.getTapTimeout();
- mEnabled = true;
- mLocation = new int[2];
- mSwipeListener = swipe;
- }
-
- public void setRenderOverlay(RenderOverlay overlay) {
- mOverlay = overlay;
- }
-
- public void setOrientation(int orientation) {
- mOrientation = orientation;
- }
-
- public void setEnabled(boolean enabled) {
- mEnabled = enabled;
- if (!enabled) {
- cancelPie();
- }
- }
-
- public void setZoomOnly(boolean zoom) {
- mZoomOnly = zoom;
- }
-
- public void addTouchReceiver(View v) {
- if (mReceivers == null) {
- mReceivers = new ArrayList<View>();
- }
- mReceivers.add(v);
- }
-
- public void removeTouchReceiver(View v) {
- if (mReceivers == null || v == null) return;
- mReceivers.remove(v);
- }
-
- public void addUnclickableArea(View v) {
- if (mUnclickableAreas == null) {
- mUnclickableAreas = new ArrayList<View>();
- }
- mUnclickableAreas.add(v);
- }
-
- public void clearTouchReceivers() {
- if (mReceivers != null) {
- mReceivers.clear();
- }
- }
-
- public void clearUnclickableAreas() {
- if (mUnclickableAreas != null) {
- mUnclickableAreas.clear();
- }
- }
-
- private boolean checkClickable(MotionEvent m) {
- if (mUnclickableAreas != null) {
- for (View v : mUnclickableAreas) {
- if (isInside(m, v)) {
- return false;
- }
- }
- }
- return true;
- }
-
- public void reset() {
- clearTouchReceivers();
- clearUnclickableAreas();
- }
-
- public boolean dispatchTouch(MotionEvent m) {
- if (!mEnabled) {
- return mActivity.superDispatchTouchEvent(m);
- }
- mCurrent = m;
- if (MotionEvent.ACTION_DOWN == m.getActionMasked()) {
- if (checkReceivers(m)) {
- mMode = MODE_MODULE;
- return mActivity.superDispatchTouchEvent(m);
- } else {
- mMode = MODE_ALL;
- mDown = MotionEvent.obtain(m);
- if (mPie != null && mPie.showsItems()) {
- mMode = MODE_PIE;
- return sendToPie(m);
- }
- if (mPie != null && !mZoomOnly && checkClickable(m)) {
- mHandler.sendEmptyMessageDelayed(MSG_PIE, TIMEOUT_PIE);
- }
- if (mZoom != null) {
- mScale.onTouchEvent(m);
- }
- // make sure this is ok
- return mActivity.superDispatchTouchEvent(m);
- }
- } else if (mMode == MODE_NONE) {
- return false;
- } else if (mMode == MODE_SWIPE) {
- if (MotionEvent.ACTION_UP == m.getActionMasked()) {
- mSwipeListener.onSwipe(getSwipeDirection(m));
- }
- return true;
- } else if (mMode == MODE_PIE) {
- if (MotionEvent.ACTION_POINTER_DOWN == m.getActionMasked()) {
- sendToPie(makeCancelEvent(m));
- if (mZoom != null) {
- onScaleBegin(mScale);
- }
- } else {
- return sendToPie(m);
- }
- return true;
- } else if (mMode == MODE_ZOOM) {
- mScale.onTouchEvent(m);
- if (!mScale.isInProgress() && MotionEvent.ACTION_POINTER_UP == m.getActionMasked()) {
- mMode = MODE_NONE;
- onScaleEnd(mScale);
- }
- return true;
- } else if (mMode == MODE_MODULE) {
- return mActivity.superDispatchTouchEvent(m);
- } else {
- // didn't receive down event previously;
- // assume module wasn't initialzed and ignore this event.
- if (mDown == null) {
- return true;
- }
- if (MotionEvent.ACTION_POINTER_DOWN == m.getActionMasked()) {
- if (!mZoomOnly) {
- cancelPie();
- sendToPie(makeCancelEvent(m));
- }
- if (mZoom != null) {
- mScale.onTouchEvent(m);
- onScaleBegin(mScale);
- }
- } else if ((mMode == MODE_ZOOM) && !mScale.isInProgress()
- && MotionEvent.ACTION_POINTER_UP == m.getActionMasked()) {
- // user initiated and stopped zoom gesture without zooming
- mScale.onTouchEvent(m);
- onScaleEnd(mScale);
- }
- // not zoom or pie mode and no timeout yet
- if (mZoom != null) {
- boolean res = mScale.onTouchEvent(m);
- if (mScale.isInProgress()) {
- cancelPie();
- cancelActivityTouchHandling(m);
- return res;
- }
- }
- if (MotionEvent.ACTION_UP == m.getActionMasked()) {
- cancelPie();
- // must have been tap
- if (m.getEventTime() - mDown.getEventTime() < mTapTimeout
- && checkClickable(m)) {
- cancelActivityTouchHandling(m);
- mTapListener.onSingleTapUp(null,
- (int) mDown.getX() - mOverlay.getWindowPositionX(),
- (int) mDown.getY() - mOverlay.getWindowPositionY());
- return true;
- } else {
- return mActivity.superDispatchTouchEvent(m);
- }
- } else if (MotionEvent.ACTION_MOVE == m.getActionMasked()) {
- if ((Math.abs(m.getX() - mDown.getX()) > mSlop)
- || Math.abs(m.getY() - mDown.getY()) > mSlop) {
- // moved too far and no timeout yet, no focus or pie
- cancelPie();
- int dir = getSwipeDirection(m);
- if (dir == DIR_LEFT) {
- mMode = MODE_MODULE;
- return mActivity.superDispatchTouchEvent(m);
- } else {
- cancelActivityTouchHandling(m);
- mMode = MODE_NONE;
- }
- }
- }
- return false;
- }
- }
-
- private boolean checkReceivers(MotionEvent m) {
- if (mReceivers != null) {
- for (View receiver : mReceivers) {
- if (isInside(m, receiver)) {
- return true;
- }
- }
- }
- return false;
- }
-
- // left tests for finger moving right to left
- private int getSwipeDirection(MotionEvent m) {
- float dx = 0;
- float dy = 0;
- switch (mOrientation) {
- case 0:
- dx = m.getX() - mDown.getX();
- dy = m.getY() - mDown.getY();
- break;
- case 90:
- dx = - (m.getY() - mDown.getY());
- dy = m.getX() - mDown.getX();
- break;
- case 180:
- dx = -(m.getX() - mDown.getX());
- dy = m.getY() - mDown.getY();
- break;
- case 270:
- dx = m.getY() - mDown.getY();
- dy = m.getX() - mDown.getX();
- break;
- }
- if (dx < 0 && (Math.abs(dy) / -dx < 2)) return DIR_LEFT;
- if (dx > 0 && (Math.abs(dy) / dx < 2)) return DIR_RIGHT;
- if (dy > 0) return DIR_DOWN;
- return DIR_UP;
- }
-
- private boolean isInside(MotionEvent evt, View v) {
- v.getLocationInWindow(mLocation);
- // when view is flipped horizontally
- if ((int) v.getRotationY() == 180) {
- mLocation[0] -= v.getWidth();
- }
- // when view is flipped vertically
- if ((int) v.getRotationX() == 180) {
- mLocation[1] -= v.getHeight();
- }
- return (v.getVisibility() == View.VISIBLE
- && evt.getX() >= mLocation[0] && evt.getX() < mLocation[0] + v.getWidth()
- && evt.getY() >= mLocation[1] && evt.getY() < mLocation[1] + v.getHeight());
- }
-
- public void cancelActivityTouchHandling(MotionEvent m) {
- mActivity.superDispatchTouchEvent(makeCancelEvent(m));
- }
-
- private MotionEvent makeCancelEvent(MotionEvent m) {
- MotionEvent c = MotionEvent.obtain(m);
- c.setAction(MotionEvent.ACTION_CANCEL);
- return c;
- }
-
- private void openPie() {
- mDown.offsetLocation(-mOverlay.getWindowPositionX(),
- -mOverlay.getWindowPositionY());
- mOverlay.directDispatchTouch(mDown, mPie);
- }
-
- private void cancelPie() {
- mHandler.removeMessages(MSG_PIE);
- }
-
- private boolean sendToPie(MotionEvent m) {
- m.offsetLocation(-mOverlay.getWindowPositionX(),
- -mOverlay.getWindowPositionY());
- return mOverlay.directDispatchTouch(m, mPie);
- }
-
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- return mZoom.onScale(detector);
- }
-
- @Override
- public boolean onScaleBegin(ScaleGestureDetector detector) {
- if (mMode != MODE_ZOOM) {
- mMode = MODE_ZOOM;
- cancelActivityTouchHandling(mCurrent);
- }
- if (mCurrent.getActionMasked() != MotionEvent.ACTION_MOVE) {
- return mZoom.onScaleBegin(detector);
- } else {
- return true;
- }
- }
-
- @Override
- public void onScaleEnd(ScaleGestureDetector detector) {
- if (mCurrent.getActionMasked() != MotionEvent.ACTION_MOVE) {
- mZoom.onScaleEnd(detector);
- }
- }
-}
diff --git a/src/com/android/camera/ProxyLauncher.java b/src/com/android/camera/ProxyLauncher.java
deleted file mode 100644
index 8c56621..0000000
--- a/src/com/android/camera/ProxyLauncher.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-
-public class ProxyLauncher extends Activity {
-
- public static final int RESULT_USER_CANCELED = -2;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (savedInstanceState == null) {
- Intent intent = getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
- startActivityForResult(intent, 0);
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_CANCELED) {
- resultCode = RESULT_USER_CANCELED;
- }
- setResult(resultCode, data);
- finish();
- }
-
-}
diff --git a/src/com/android/camera/RecordLocationPreference.java b/src/com/android/camera/RecordLocationPreference.java
deleted file mode 100644
index 9992afa..0000000
--- a/src/com/android/camera/RecordLocationPreference.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.util.AttributeSet;
-
-/**
- * {@code RecordLocationPreference} is used to keep the "store locaiton"
- * option in {@code SharedPreference}.
- */
-public class RecordLocationPreference extends IconListPreference {
-
- public static final String VALUE_NONE = "none";
- public static final String VALUE_ON = "on";
- public static final String VALUE_OFF = "off";
-
- private final ContentResolver mResolver;
-
- public RecordLocationPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- mResolver = context.getContentResolver();
- }
-
- @Override
- public String getValue() {
- return get(getSharedPreferences(), mResolver) ? VALUE_ON : VALUE_OFF;
- }
-
- public static boolean get(
- SharedPreferences pref, ContentResolver resolver) {
- String value = pref.getString(
- CameraSettings.KEY_RECORD_LOCATION, VALUE_NONE);
- return VALUE_ON.equals(value);
- }
-
- public static boolean isSet(SharedPreferences pref) {
- String value = pref.getString(
- CameraSettings.KEY_RECORD_LOCATION, VALUE_NONE);
- return !VALUE_NONE.equals(value);
- }
-}
diff --git a/src/com/android/camera/RotateDialogController.java b/src/com/android/camera/RotateDialogController.java
deleted file mode 100644
index 5d5e5e7..0000000
--- a/src/com/android/camera/RotateDialogController.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import android.app.Activity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.android.camera.ui.Rotatable;
-import com.android.camera.ui.RotateLayout;
-import com.android.gallery3d.R;
-
-public class RotateDialogController implements Rotatable {
-
- @SuppressWarnings("unused")
- private static final String TAG = "RotateDialogController";
- private static final long ANIM_DURATION = 150; // millis
-
- private Activity mActivity;
- private int mLayoutResourceID;
- private View mDialogRootLayout;
- private RotateLayout mRotateDialog;
- private View mRotateDialogTitleLayout;
- private View mRotateDialogButtonLayout;
- private TextView mRotateDialogTitle;
- private ProgressBar mRotateDialogSpinner;
- private TextView mRotateDialogText;
- private TextView mRotateDialogButton1;
- private TextView mRotateDialogButton2;
-
- private Animation mFadeInAnim, mFadeOutAnim;
-
- public RotateDialogController(Activity a, int layoutResource) {
- mActivity = a;
- mLayoutResourceID = layoutResource;
- }
-
- private void inflateDialogLayout() {
- if (mDialogRootLayout == null) {
- ViewGroup layoutRoot = (ViewGroup) mActivity.getWindow().getDecorView();
- LayoutInflater inflater = mActivity.getLayoutInflater();
- View v = inflater.inflate(mLayoutResourceID, layoutRoot);
- mDialogRootLayout = v.findViewById(R.id.rotate_dialog_root_layout);
- mRotateDialog = (RotateLayout) v.findViewById(R.id.rotate_dialog_layout);
- mRotateDialogTitleLayout = v.findViewById(R.id.rotate_dialog_title_layout);
- mRotateDialogButtonLayout = v.findViewById(R.id.rotate_dialog_button_layout);
- mRotateDialogTitle = (TextView) v.findViewById(R.id.rotate_dialog_title);
- mRotateDialogSpinner = (ProgressBar) v.findViewById(R.id.rotate_dialog_spinner);
- mRotateDialogText = (TextView) v.findViewById(R.id.rotate_dialog_text);
- mRotateDialogButton1 = (Button) v.findViewById(R.id.rotate_dialog_button1);
- mRotateDialogButton2 = (Button) v.findViewById(R.id.rotate_dialog_button2);
-
- mFadeInAnim = AnimationUtils.loadAnimation(
- mActivity, android.R.anim.fade_in);
- mFadeOutAnim = AnimationUtils.loadAnimation(
- mActivity, android.R.anim.fade_out);
- mFadeInAnim.setDuration(ANIM_DURATION);
- mFadeOutAnim.setDuration(ANIM_DURATION);
- }
- }
-
- @Override
- public void setOrientation(int orientation, boolean animation) {
- inflateDialogLayout();
- mRotateDialog.setOrientation(orientation, animation);
- }
-
- public void resetRotateDialog() {
- inflateDialogLayout();
- mRotateDialogTitleLayout.setVisibility(View.GONE);
- mRotateDialogSpinner.setVisibility(View.GONE);
- mRotateDialogButton1.setVisibility(View.GONE);
- mRotateDialogButton2.setVisibility(View.GONE);
- mRotateDialogButtonLayout.setVisibility(View.GONE);
- }
-
- private void fadeOutDialog() {
- mDialogRootLayout.startAnimation(mFadeOutAnim);
- mDialogRootLayout.setVisibility(View.GONE);
- }
-
- private void fadeInDialog() {
- mDialogRootLayout.startAnimation(mFadeInAnim);
- mDialogRootLayout.setVisibility(View.VISIBLE);
- }
-
- public void dismissDialog() {
- if (mDialogRootLayout != null && mDialogRootLayout.getVisibility() != View.GONE) {
- fadeOutDialog();
- }
- }
-
- public void showAlertDialog(String title, String msg, String button1Text,
- final Runnable r1, String button2Text, final Runnable r2) {
- resetRotateDialog();
-
- if (title != null) {
- mRotateDialogTitle.setText(title);
- mRotateDialogTitleLayout.setVisibility(View.VISIBLE);
- }
-
- mRotateDialogText.setText(msg);
-
- if (button1Text != null) {
- mRotateDialogButton1.setText(button1Text);
- mRotateDialogButton1.setContentDescription(button1Text);
- mRotateDialogButton1.setVisibility(View.VISIBLE);
- mRotateDialogButton1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (r1 != null) r1.run();
- dismissDialog();
- }
- });
- mRotateDialogButtonLayout.setVisibility(View.VISIBLE);
- }
- if (button2Text != null) {
- mRotateDialogButton2.setText(button2Text);
- mRotateDialogButton2.setContentDescription(button2Text);
- mRotateDialogButton2.setVisibility(View.VISIBLE);
- mRotateDialogButton2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (r2 != null) r2.run();
- dismissDialog();
- }
- });
- mRotateDialogButtonLayout.setVisibility(View.VISIBLE);
- }
-
- fadeInDialog();
- }
-
- public void showWaitingDialog(String msg) {
- resetRotateDialog();
-
- mRotateDialogText.setText(msg);
- mRotateDialogSpinner.setVisibility(View.VISIBLE);
-
- fadeInDialog();
- }
-
- public int getVisibility() {
- if (mDialogRootLayout != null) {
- return mDialogRootLayout.getVisibility();
- }
- return View.INVISIBLE;
- }
-}
diff --git a/src/com/android/camera/SecureCameraActivity.java b/src/com/android/camera/SecureCameraActivity.java
deleted file mode 100644
index 2fa68f8..0000000
--- a/src/com/android/camera/SecureCameraActivity.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-// Use a different activity for secure camera only. So it can have a different
-// task affinity from others. This makes sure non-secure camera activity is not
-// started in secure lock screen.
-public class SecureCameraActivity extends CameraActivity {
-}
diff --git a/src/com/android/camera/ShutterButton.java b/src/com/android/camera/ShutterButton.java
deleted file mode 100755
index a1bbb1a..0000000
--- a/src/com/android/camera/ShutterButton.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2008 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.camera;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.ImageView;
-
-/**
- * A button designed to be used for the on-screen shutter button.
- * It's currently an {@code ImageView} that can call a delegate when the
- * pressed state changes.
- */
-public class ShutterButton extends ImageView {
-
- private boolean mTouchEnabled = true;
-
- /**
- * A callback to be invoked when a ShutterButton's pressed state changes.
- */
- public interface OnShutterButtonListener {
- /**
- * Called when a ShutterButton has been pressed.
- *
- * @param pressed The ShutterButton that was pressed.
- */
- void onShutterButtonFocus(boolean pressed);
- void onShutterButtonClick();
- }
-
- private OnShutterButtonListener mListener;
- private boolean mOldPressed;
-
- public ShutterButton(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void setOnShutterButtonListener(OnShutterButtonListener listener) {
- mListener = listener;
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent m) {
- if (mTouchEnabled) {
- return super.dispatchTouchEvent(m);
- } else {
- return false;
- }
- }
-
- public void enableTouch(boolean enable) {
- mTouchEnabled = enable;
- }
-
- /**
- * Hook into the drawable state changing to get changes to isPressed -- the
- * onPressed listener doesn't always get called when the pressed state
- * changes.
- */
- @Override
- protected void drawableStateChanged() {
- super.drawableStateChanged();
- final boolean pressed = isPressed();
- if (pressed != mOldPressed) {
- if (!pressed) {
- // When pressing the physical camera button the sequence of
- // events is:
- // focus pressed, optional camera pressed, focus released.
- // We want to emulate this sequence of events with the shutter
- // button. When clicking using a trackball button, the view
- // system changes the drawable state before posting click
- // notification, so the sequence of events is:
- // pressed(true), optional click, pressed(false)
- // When clicking using touch events, the view system changes the
- // drawable state after posting click notification, so the
- // sequence of events is:
- // pressed(true), pressed(false), optional click
- // Since we're emulating the physical camera button, we want to
- // have the same order of events. So we want the optional click
- // callback to be delivered before the pressed(false) callback.
- //
- // To do this, we delay the posting of the pressed(false) event
- // slightly by pushing it on the event queue. This moves it
- // after the optional click notification, so our client always
- // sees events in this sequence:
- // pressed(true), optional click, pressed(false)
- post(new Runnable() {
- @Override
- public void run() {
- callShutterButtonFocus(pressed);
- }
- });
- } else {
- callShutterButtonFocus(pressed);
- }
- mOldPressed = pressed;
- }
- }
-
- private void callShutterButtonFocus(boolean pressed) {
- if (mListener != null) {
- mListener.onShutterButtonFocus(pressed);
- }
- }
-
- @Override
- public boolean performClick() {
- boolean result = super.performClick();
- if (mListener != null && getVisibility() == View.VISIBLE) {
- mListener.onShutterButtonClick();
- }
- return result;
- }
-}
diff --git a/src/com/android/camera/SoundClips.java b/src/com/android/camera/SoundClips.java
deleted file mode 100644
index 8155c03..0000000
--- a/src/com/android/camera/SoundClips.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.media.AudioManager;
-import android.media.MediaActionSound;
-import android.media.SoundPool;
-import android.util.Log;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-/*
- * This class controls the sound playback according to the API level.
- */
-public class SoundClips {
- // Sound actions.
- public static final int FOCUS_COMPLETE = 0;
- public static final int START_VIDEO_RECORDING = 1;
- public static final int STOP_VIDEO_RECORDING = 2;
-
- public interface Player {
- public void release();
- public void play(int action);
- }
-
- public static Player getPlayer(Context context) {
- if (ApiHelper.HAS_MEDIA_ACTION_SOUND) {
- return new MediaActionSoundPlayer();
- } else {
- return new SoundPoolPlayer(context);
- }
- }
-
- public static int getAudioTypeForSoundPool() {
- return ApiHelper.getIntFieldIfExists(AudioManager.class,
- "STREAM_SYSTEM_ENFORCED", null, AudioManager.STREAM_RING);
- }
-
- /**
- * This class implements SoundClips.Player using MediaActionSound,
- * which exists since API level 16.
- */
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
- private static class MediaActionSoundPlayer implements Player {
- private static final String TAG = "MediaActionSoundPlayer";
- private MediaActionSound mSound;
-
- @Override
- public void release() {
- if (mSound != null) {
- mSound.release();
- mSound = null;
- }
- }
-
- public MediaActionSoundPlayer() {
- mSound = new MediaActionSound();
- mSound.load(MediaActionSound.START_VIDEO_RECORDING);
- mSound.load(MediaActionSound.STOP_VIDEO_RECORDING);
- mSound.load(MediaActionSound.FOCUS_COMPLETE);
- }
-
- @Override
- public synchronized void play(int action) {
- switch(action) {
- case FOCUS_COMPLETE:
- mSound.play(MediaActionSound.FOCUS_COMPLETE);
- break;
- case START_VIDEO_RECORDING:
- mSound.play(MediaActionSound.START_VIDEO_RECORDING);
- break;
- case STOP_VIDEO_RECORDING:
- mSound.play(MediaActionSound.STOP_VIDEO_RECORDING);
- break;
- default:
- Log.w(TAG, "Unrecognized action:" + action);
- }
- }
- }
-
- /**
- * This class implements SoundClips.Player using SoundPool, which
- * exists since API level 1.
- */
- private static class SoundPoolPlayer implements
- Player, SoundPool.OnLoadCompleteListener {
-
- private static final String TAG = "SoundPoolPlayer";
- private static final int NUM_SOUND_STREAMS = 1;
- private static final int[] SOUND_RES = { // Soundtrack res IDs.
- R.raw.focus_complete,
- R.raw.video_record
- };
-
- // ID returned by load() should be non-zero.
- private static final int ID_NOT_LOADED = 0;
-
- // Maps a sound action to the id;
- private final int[] mSoundRes = {0, 1, 1};
- // Store the context for lazy loading.
- private Context mContext;
- // mSoundPool is created every time load() is called and cleared every
- // time release() is called.
- private SoundPool mSoundPool;
- // Sound ID of each sound resources. Given when the sound is loaded.
- private final int[] mSoundIDs;
- private final boolean[] mSoundIDReady;
- private int mSoundIDToPlay;
-
- public SoundPoolPlayer(Context context) {
- mContext = context;
-
- mSoundIDToPlay = ID_NOT_LOADED;
-
- mSoundPool = new SoundPool(NUM_SOUND_STREAMS, getAudioTypeForSoundPool(), 0);
- mSoundPool.setOnLoadCompleteListener(this);
-
- mSoundIDs = new int[SOUND_RES.length];
- mSoundIDReady = new boolean[SOUND_RES.length];
- for (int i = 0; i < SOUND_RES.length; i++) {
- mSoundIDs[i] = mSoundPool.load(mContext, SOUND_RES[i], 1);
- mSoundIDReady[i] = false;
- }
- }
-
- @Override
- public synchronized void release() {
- if (mSoundPool != null) {
- mSoundPool.release();
- mSoundPool = null;
- }
- }
-
- @Override
- public synchronized void play(int action) {
- if (action < 0 || action >= mSoundRes.length) {
- Log.e(TAG, "Resource ID not found for action:" + action + " in play().");
- return;
- }
-
- int index = mSoundRes[action];
- if (mSoundIDs[index] == ID_NOT_LOADED) {
- // Not loaded yet, load first and then play when the loading is complete.
- mSoundIDs[index] = mSoundPool.load(mContext, SOUND_RES[index], 1);
- mSoundIDToPlay = mSoundIDs[index];
- } else if (!mSoundIDReady[index]) {
- // Loading and not ready yet.
- mSoundIDToPlay = mSoundIDs[index];
- } else {
- mSoundPool.play(mSoundIDs[index], 1f, 1f, 0, 0, 1f);
- }
- }
-
- @Override
- public void onLoadComplete(SoundPool pool, int soundID, int status) {
- if (status != 0) {
- Log.e(TAG, "loading sound tracks failed (status=" + status + ")");
- for (int i = 0; i < mSoundIDs.length; i++ ) {
- if (mSoundIDs[i] == soundID) {
- mSoundIDs[i] = ID_NOT_LOADED;
- break;
- }
- }
- return;
- }
-
- for (int i = 0; i < mSoundIDs.length; i++ ) {
- if (mSoundIDs[i] == soundID) {
- mSoundIDReady[i] = true;
- break;
- }
- }
-
- if (soundID == mSoundIDToPlay) {
- mSoundIDToPlay = ID_NOT_LOADED;
- mSoundPool.play(soundID, 1f, 1f, 0, 0, 1f);
- }
- }
- }
-}
diff --git a/src/com/android/camera/StaticBitmapScreenNail.java b/src/com/android/camera/StaticBitmapScreenNail.java
deleted file mode 100644
index 10788c0..0000000
--- a/src/com/android/camera/StaticBitmapScreenNail.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.graphics.Bitmap;
-
-import com.android.gallery3d.ui.BitmapScreenNail;
-
-public class StaticBitmapScreenNail extends BitmapScreenNail {
- public StaticBitmapScreenNail(Bitmap bitmap) {
- super(bitmap);
- }
-
- @Override
- public void recycle() {
- // Always keep the bitmap in memory.
- }
-}
diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java
deleted file mode 100644
index ba995ed..0000000
--- a/src/com/android/camera/Storage.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera;
-
-import android.annotation.TargetApi;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.location.Location;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Environment;
-import android.os.StatFs;
-import android.provider.MediaStore.Images;
-import android.provider.MediaStore.Images.ImageColumns;
-import android.provider.MediaStore.MediaColumns;
-import android.util.Log;
-
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.exif.ExifInterface;
-
-import java.io.File;
-import java.io.FileOutputStream;
-
-public class Storage {
- private static final String TAG = "CameraStorage";
-
- public static final String DCIM =
- Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString();
-
- public static final String DIRECTORY = DCIM + "/Camera";
-
- // Match the code in MediaProvider.computeBucketValues().
- public static final String BUCKET_ID =
- String.valueOf(DIRECTORY.toLowerCase().hashCode());
-
- public static final long UNAVAILABLE = -1L;
- public static final long PREPARING = -2L;
- public static final long UNKNOWN_SIZE = -3L;
- public static final long LOW_STORAGE_THRESHOLD = 50000000;
-
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
- private static void setImageSize(ContentValues values, int width, int height) {
- // The two fields are available since ICS but got published in JB
- if (ApiHelper.HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT) {
- values.put(MediaColumns.WIDTH, width);
- values.put(MediaColumns.HEIGHT, height);
- }
- }
-
- public static void writeFile(String path, byte[] data) {
- FileOutputStream out = null;
- try {
- out = new FileOutputStream(path);
- out.write(data);
- } catch (Exception e) {
- Log.e(TAG, "Failed to write data", e);
- } finally {
- try {
- out.close();
- } catch (Exception e) {
- }
- }
- }
-
- // Save the image and add it to media store.
- public static Uri addImage(ContentResolver resolver, String title,
- long date, Location location, int orientation, ExifInterface exif,
- byte[] jpeg, int width, int height) {
- // Save the image.
- String path = generateFilepath(title);
- if (exif != null) {
- try {
- exif.writeExif(jpeg, path);
- } catch (Exception e) {
- Log.e(TAG, "Failed to write data", e);
- }
- } else {
- writeFile(path, jpeg);
- }
- return addImage(resolver, title, date, location, orientation,
- jpeg.length, path, width, height);
- }
-
- // Add the image to media store.
- public static Uri addImage(ContentResolver resolver, String title,
- long date, Location location, int orientation, int jpegLength,
- String path, int width, int height) {
- // Insert into MediaStore.
- ContentValues values = new ContentValues(9);
- values.put(ImageColumns.TITLE, title);
- values.put(ImageColumns.DISPLAY_NAME, title + ".jpg");
- values.put(ImageColumns.DATE_TAKEN, date);
- values.put(ImageColumns.MIME_TYPE, "image/jpeg");
- // Clockwise rotation in degrees. 0, 90, 180, or 270.
- values.put(ImageColumns.ORIENTATION, orientation);
- values.put(ImageColumns.DATA, path);
- values.put(ImageColumns.SIZE, jpegLength);
-
- setImageSize(values, width, height);
-
- if (location != null) {
- values.put(ImageColumns.LATITUDE, location.getLatitude());
- values.put(ImageColumns.LONGITUDE, location.getLongitude());
- }
-
- Uri uri = null;
- try {
- uri = resolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
- } catch (Throwable th) {
- // This can happen when the external volume is already mounted, but
- // MediaScanner has not notify MediaProvider to add that volume.
- // The picture is still safe and MediaScanner will find it and
- // insert it into MediaProvider. The only problem is that the user
- // cannot click the thumbnail to review the picture.
- Log.e(TAG, "Failed to write MediaStore" + th);
- }
- return uri;
- }
-
- public static void deleteImage(ContentResolver resolver, Uri uri) {
- try {
- resolver.delete(uri, null, null);
- } catch (Throwable th) {
- Log.e(TAG, "Failed to delete image: " + uri);
- }
- }
-
- public static String generateFilepath(String title) {
- return DIRECTORY + '/' + title + ".jpg";
- }
-
- public static long getAvailableSpace() {
- String state = Environment.getExternalStorageState();
- Log.d(TAG, "External storage state=" + state);
- if (Environment.MEDIA_CHECKING.equals(state)) {
- return PREPARING;
- }
- if (!Environment.MEDIA_MOUNTED.equals(state)) {
- return UNAVAILABLE;
- }
-
- File dir = new File(DIRECTORY);
- dir.mkdirs();
- if (!dir.isDirectory() || !dir.canWrite()) {
- return UNAVAILABLE;
- }
-
- try {
- StatFs stat = new StatFs(DIRECTORY);
- return stat.getAvailableBlocks() * (long) stat.getBlockSize();
- } catch (Exception e) {
- Log.i(TAG, "Fail to access external storage", e);
- }
- return UNKNOWN_SIZE;
- }
-
- /**
- * OSX requires plugged-in USB storage to have path /DCIM/NNNAAAAA to be
- * imported. This is a temporary fix for bug#1655552.
- */
- public static void ensureOSXCompatible() {
- File nnnAAAAA = new File(DCIM, "100ANDRO");
- if (!(nnnAAAAA.exists() || nnnAAAAA.mkdirs())) {
- Log.e(TAG, "Failed to create " + nnnAAAAA.getPath());
- }
- }
-}
diff --git a/src/com/android/camera/SwitchAnimManager.java b/src/com/android/camera/SwitchAnimManager.java
deleted file mode 100644
index 6ec8822..0000000
--- a/src/com/android/camera/SwitchAnimManager.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.os.SystemClock;
-import android.util.Log;
-
-import com.android.gallery3d.glrenderer.GLCanvas;
-import com.android.gallery3d.glrenderer.RawTexture;
-
-/**
- * Class to handle the animation when switching between back and front cameras.
- * An image of the previous camera zooms in and fades out. The preview of the
- * new camera zooms in and fades in. The image of the previous camera is called
- * review in this class.
- */
-public class SwitchAnimManager {
- private static final String TAG = "SwitchAnimManager";
- // The amount of change for zooming in and out.
- private static final float ZOOM_DELTA_PREVIEW = 0.2f;
- private static final float ZOOM_DELTA_REVIEW = 0.5f;
- private static final float ANIMATION_DURATION = 400; // ms
- public static final float INITIAL_DARKEN_ALPHA = 0.8f;
-
- private long mAnimStartTime; // milliseconds.
- // The drawing width and height of the review image. This is saved when the
- // texture is copied.
- private int mReviewDrawingWidth;
- private int mReviewDrawingHeight;
- // The maximum width of the camera screen nail width from onDraw. We need to
- // know how much the preview is scaled and scale the review the same amount.
- // For example, the preview is not full screen in film strip mode.
- private int mPreviewFrameLayoutWidth;
-
- public SwitchAnimManager() {
- }
-
- public void setReviewDrawingSize(int width, int height) {
- mReviewDrawingWidth = width;
- mReviewDrawingHeight = height;
- }
-
- // width: the width of PreviewFrameLayout view.
- // height: the height of PreviewFrameLayout view. Not used. Kept for
- // consistency.
- public void setPreviewFrameLayoutSize(int width, int height) {
- mPreviewFrameLayoutWidth = width;
- }
-
- // w and h: the rectangle area where the animation takes place.
- public void startAnimation() {
- mAnimStartTime = SystemClock.uptimeMillis();
- }
-
- // Returns true if the animation has been drawn.
- // preview: camera preview view.
- // review: snapshot of the preview before switching the camera.
- public boolean drawAnimation(GLCanvas canvas, int x, int y, int width,
- int height, CameraScreenNail preview, RawTexture review) {
- long timeDiff = SystemClock.uptimeMillis() - mAnimStartTime;
- if (timeDiff > ANIMATION_DURATION) return false;
- float fraction = timeDiff / ANIMATION_DURATION;
-
- // Calculate the position and the size of the preview.
- float centerX = x + width / 2f;
- float centerY = y + height / 2f;
- float previewAnimScale = 1 - ZOOM_DELTA_PREVIEW * (1 - fraction);
- float previewWidth = width * previewAnimScale;
- float previewHeight = height * previewAnimScale;
- int previewX = Math.round(centerX - previewWidth / 2);
- int previewY = Math.round(centerY - previewHeight / 2);
-
- // Calculate the position and the size of the review.
- float reviewAnimScale = 1 + ZOOM_DELTA_REVIEW * fraction;
-
- // Calculate how much preview is scaled.
- // The scaling is done by PhotoView in Gallery so we don't have the
- // scaling information but only the width and the height passed to this
- // method. The inference of the scale ratio is done by matching the
- // current width and the original width we have at first when the camera
- // layout is inflated.
- float scaleRatio = 1;
- if (mPreviewFrameLayoutWidth != 0) {
- scaleRatio = (float) width / mPreviewFrameLayoutWidth;
- } else {
- Log.e(TAG, "mPreviewFrameLayoutWidth is 0.");
- }
- float reviewWidth = mReviewDrawingWidth * reviewAnimScale * scaleRatio;
- float reviewHeight = mReviewDrawingHeight * reviewAnimScale * scaleRatio;
- int reviewX = Math.round(centerX - reviewWidth / 2);
- int reviewY = Math.round(centerY - reviewHeight / 2);
-
- // Draw the preview.
- float alpha = canvas.getAlpha();
- canvas.setAlpha(fraction); // fade in
- preview.directDraw(canvas, previewX, previewY, Math.round(previewWidth),
- Math.round(previewHeight));
-
- // Draw the review.
- canvas.setAlpha((1f - fraction) * INITIAL_DARKEN_ALPHA); // fade out
- review.draw(canvas, reviewX, reviewY, Math.round(reviewWidth),
- Math.round(reviewHeight));
- canvas.setAlpha(alpha);
- return true;
- }
-
- public boolean drawDarkPreview(GLCanvas canvas, int x, int y, int width,
- int height, RawTexture review) {
- // Calculate the position and the size.
- float centerX = x + width / 2f;
- float centerY = y + height / 2f;
- float scaleRatio = 1;
- if (mPreviewFrameLayoutWidth != 0) {
- scaleRatio = (float) width / mPreviewFrameLayoutWidth;
- } else {
- Log.e(TAG, "mPreviewFrameLayoutWidth is 0.");
- }
- float reviewWidth = mReviewDrawingWidth * scaleRatio;
- float reviewHeight = mReviewDrawingHeight * scaleRatio;
- int reviewX = Math.round(centerX - reviewWidth / 2);
- int reviewY = Math.round(centerY - reviewHeight / 2);
-
- // Draw the review.
- float alpha = canvas.getAlpha();
- canvas.setAlpha(INITIAL_DARKEN_ALPHA);
- review.draw(canvas, reviewX, reviewY, Math.round(reviewWidth),
- Math.round(reviewHeight));
- canvas.setAlpha(alpha);
- return true;
- }
-
-}
diff --git a/src/com/android/camera/Thumbnail.java b/src/com/android/camera/Thumbnail.java
deleted file mode 100644
index 5f8483d..0000000
--- a/src/com/android/camera/Thumbnail.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera;
-
-import android.graphics.Bitmap;
-import android.media.MediaMetadataRetriever;
-
-import java.io.FileDescriptor;
-
-public class Thumbnail {
- public static Bitmap createVideoThumbnailBitmap(FileDescriptor fd, int targetWidth) {
- return createVideoThumbnailBitmap(null, fd, targetWidth);
- }
-
- public static Bitmap createVideoThumbnailBitmap(String filePath, int targetWidth) {
- return createVideoThumbnailBitmap(filePath, null, targetWidth);
- }
-
- private static Bitmap createVideoThumbnailBitmap(String filePath, FileDescriptor fd,
- int targetWidth) {
- Bitmap bitmap = null;
- MediaMetadataRetriever retriever = new MediaMetadataRetriever();
- try {
- if (filePath != null) {
- retriever.setDataSource(filePath);
- } else {
- retriever.setDataSource(fd);
- }
- bitmap = retriever.getFrameAtTime(-1);
- } catch (IllegalArgumentException ex) {
- // Assume this is a corrupt video file
- } catch (RuntimeException ex) {
- // Assume this is a corrupt video file.
- } finally {
- try {
- retriever.release();
- } catch (RuntimeException ex) {
- // Ignore failures while cleaning up.
- }
- }
- if (bitmap == null) return null;
-
- // Scale down the bitmap if it is bigger than we need.
- int width = bitmap.getWidth();
- int height = bitmap.getHeight();
- if (width > targetWidth) {
- float scale = (float) targetWidth / width;
- int w = Math.round(scale * width);
- int h = Math.round(scale * height);
- bitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
- }
- return bitmap;
- }
-}
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
deleted file mode 100644
index 44af425..0000000
--- a/src/com/android/camera/Util.java
+++ /dev/null
@@ -1,783 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.admin.DevicePolicyManager;
-import android.content.ActivityNotFoundException;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.graphics.Point;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.hardware.Camera;
-import android.hardware.Camera.CameraInfo;
-import android.hardware.Camera.Parameters;
-import android.hardware.Camera.Size;
-import android.location.Location;
-import android.net.Uri;
-import android.os.Build;
-import android.os.ParcelFileDescriptor;
-import android.provider.Settings;
-import android.telephony.TelephonyManager;
-import android.util.DisplayMetrics;
-import android.util.FloatMath;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.Display;
-import android.view.OrientationEventListener;
-import android.view.Surface;
-import android.view.View;
-import android.view.WindowManager;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.Animation;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * Collection of utility functions used in this package.
- */
-public class Util {
- private static final String TAG = "Util";
-
- // Orientation hysteresis amount used in rounding, in degrees
- public static final int ORIENTATION_HYSTERESIS = 5;
-
- public static final String REVIEW_ACTION = "com.android.camera.action.REVIEW";
- // See android.hardware.Camera.ACTION_NEW_PICTURE.
- public static final String ACTION_NEW_PICTURE = "android.hardware.action.NEW_PICTURE";
- // See android.hardware.Camera.ACTION_NEW_VIDEO.
- public static final String ACTION_NEW_VIDEO = "android.hardware.action.NEW_VIDEO";
-
- // Fields from android.hardware.Camera.Parameters
- public static final String FOCUS_MODE_CONTINUOUS_PICTURE = "continuous-picture";
- public static final String RECORDING_HINT = "recording-hint";
- private static final String AUTO_EXPOSURE_LOCK_SUPPORTED = "auto-exposure-lock-supported";
- private static final String AUTO_WHITE_BALANCE_LOCK_SUPPORTED = "auto-whitebalance-lock-supported";
- private static final String VIDEO_SNAPSHOT_SUPPORTED = "video-snapshot-supported";
- public static final String SCENE_MODE_HDR = "hdr";
- public static final String TRUE = "true";
- public static final String FALSE = "false";
-
- public static boolean isSupported(String value, List<String> supported) {
- return supported == null ? false : supported.indexOf(value) >= 0;
- }
-
- public static boolean isAutoExposureLockSupported(Parameters params) {
- return TRUE.equals(params.get(AUTO_EXPOSURE_LOCK_SUPPORTED));
- }
-
- public static boolean isAutoWhiteBalanceLockSupported(Parameters params) {
- return TRUE.equals(params.get(AUTO_WHITE_BALANCE_LOCK_SUPPORTED));
- }
-
- public static boolean isVideoSnapshotSupported(Parameters params) {
- return TRUE.equals(params.get(VIDEO_SNAPSHOT_SUPPORTED));
- }
-
- public static boolean isCameraHdrSupported(Parameters params) {
- List<String> supported = params.getSupportedSceneModes();
- return (supported != null) && supported.contains(SCENE_MODE_HDR);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public static boolean isMeteringAreaSupported(Parameters params) {
- if (ApiHelper.HAS_CAMERA_METERING_AREA) {
- return params.getMaxNumMeteringAreas() > 0;
- }
- return false;
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- public static boolean isFocusAreaSupported(Parameters params) {
- if (ApiHelper.HAS_CAMERA_FOCUS_AREA) {
- return (params.getMaxNumFocusAreas() > 0
- && isSupported(Parameters.FOCUS_MODE_AUTO,
- params.getSupportedFocusModes()));
- }
- return false;
- }
-
- // Private intent extras. Test only.
- private static final String EXTRAS_CAMERA_FACING =
- "android.intent.extras.CAMERA_FACING";
-
- private static float sPixelDensity = 1;
- private static ImageFileNamer sImageFileNamer;
-
- private Util() {
- }
-
- public static void initialize(Context context) {
- DisplayMetrics metrics = new DisplayMetrics();
- WindowManager wm = (WindowManager)
- context.getSystemService(Context.WINDOW_SERVICE);
- wm.getDefaultDisplay().getMetrics(metrics);
- sPixelDensity = metrics.density;
- sImageFileNamer = new ImageFileNamer(
- context.getString(R.string.image_file_name_format));
- }
-
- public static int dpToPixel(int dp) {
- return Math.round(sPixelDensity * dp);
- }
-
- // Rotates the bitmap by the specified degree.
- // If a new bitmap is created, the original bitmap is recycled.
- public static Bitmap rotate(Bitmap b, int degrees) {
- return rotateAndMirror(b, degrees, false);
- }
-
- // Rotates and/or mirrors the bitmap. If a new bitmap is created, the
- // original bitmap is recycled.
- public static Bitmap rotateAndMirror(Bitmap b, int degrees, boolean mirror) {
- if ((degrees != 0 || mirror) && b != null) {
- Matrix m = new Matrix();
- // Mirror first.
- // horizontal flip + rotation = -rotation + horizontal flip
- if (mirror) {
- m.postScale(-1, 1);
- degrees = (degrees + 360) % 360;
- if (degrees == 0 || degrees == 180) {
- m.postTranslate(b.getWidth(), 0);
- } else if (degrees == 90 || degrees == 270) {
- m.postTranslate(b.getHeight(), 0);
- } else {
- throw new IllegalArgumentException("Invalid degrees=" + degrees);
- }
- }
- if (degrees != 0) {
- // clockwise
- m.postRotate(degrees,
- (float) b.getWidth() / 2, (float) b.getHeight() / 2);
- }
-
- try {
- Bitmap b2 = Bitmap.createBitmap(
- b, 0, 0, b.getWidth(), b.getHeight(), m, true);
- if (b != b2) {
- b.recycle();
- b = b2;
- }
- } catch (OutOfMemoryError ex) {
- // We have no memory to rotate. Return the original bitmap.
- }
- }
- return b;
- }
-
- /*
- * Compute the sample size as a function of minSideLength
- * and maxNumOfPixels.
- * minSideLength is used to specify that minimal width or height of a
- * bitmap.
- * maxNumOfPixels is used to specify the maximal size in pixels that is
- * tolerable in terms of memory usage.
- *
- * The function returns a sample size based on the constraints.
- * Both size and minSideLength can be passed in as -1
- * which indicates no care of the corresponding constraint.
- * The functions prefers returning a sample size that
- * generates a smaller bitmap, unless minSideLength = -1.
- *
- * Also, the function rounds up the sample size to a power of 2 or multiple
- * of 8 because BitmapFactory only honors sample size this way.
- * For example, BitmapFactory downsamples an image by 2 even though the
- * request is 3. So we round up the sample size to avoid OOM.
- */
- public static int computeSampleSize(BitmapFactory.Options options,
- int minSideLength, int maxNumOfPixels) {
- int initialSize = computeInitialSampleSize(options, minSideLength,
- maxNumOfPixels);
-
- int roundedSize;
- if (initialSize <= 8) {
- roundedSize = 1;
- while (roundedSize < initialSize) {
- roundedSize <<= 1;
- }
- } else {
- roundedSize = (initialSize + 7) / 8 * 8;
- }
-
- return roundedSize;
- }
-
- private static int computeInitialSampleSize(BitmapFactory.Options options,
- int minSideLength, int maxNumOfPixels) {
- double w = options.outWidth;
- double h = options.outHeight;
-
- int lowerBound = (maxNumOfPixels < 0) ? 1 :
- (int) Math.ceil(Math.sqrt(w * h / maxNumOfPixels));
- int upperBound = (minSideLength < 0) ? 128 :
- (int) Math.min(Math.floor(w / minSideLength),
- Math.floor(h / minSideLength));
-
- if (upperBound < lowerBound) {
- // return the larger one when there is no overlapping zone.
- return lowerBound;
- }
-
- if (maxNumOfPixels < 0 && minSideLength < 0) {
- return 1;
- } else if (minSideLength < 0) {
- return lowerBound;
- } else {
- return upperBound;
- }
- }
-
- public static Bitmap makeBitmap(byte[] jpegData, int maxNumOfPixels) {
- try {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inJustDecodeBounds = true;
- BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length,
- options);
- if (options.mCancel || options.outWidth == -1
- || options.outHeight == -1) {
- return null;
- }
- options.inSampleSize = computeSampleSize(
- options, -1, maxNumOfPixels);
- options.inJustDecodeBounds = false;
-
- options.inDither = false;
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- return BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length,
- options);
- } catch (OutOfMemoryError ex) {
- Log.e(TAG, "Got oom exception ", ex);
- return null;
- }
- }
-
- public static void closeSilently(Closeable c) {
- if (c == null) return;
- try {
- c.close();
- } catch (Throwable t) {
- // do nothing
- }
- }
-
- public static void Assert(boolean cond) {
- if (!cond) {
- throw new AssertionError();
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private static void throwIfCameraDisabled(Activity activity) throws CameraDisabledException {
- // Check if device policy has disabled the camera.
- if (ApiHelper.HAS_GET_CAMERA_DISABLED) {
- DevicePolicyManager dpm = (DevicePolicyManager) activity.getSystemService(
- Context.DEVICE_POLICY_SERVICE);
- if (dpm.getCameraDisabled(null)) {
- throw new CameraDisabledException();
- }
- }
- }
-
- public static CameraManager.CameraProxy openCamera(Activity activity, int cameraId)
- throws CameraHardwareException, CameraDisabledException {
- throwIfCameraDisabled(activity);
-
- try {
- return CameraHolder.instance().open(cameraId);
- } catch (CameraHardwareException e) {
- // In eng build, we throw the exception so that test tool
- // can detect it and report it
- if ("eng".equals(Build.TYPE)) {
- throw new RuntimeException("openCamera failed", e);
- } else {
- throw e;
- }
- }
- }
-
- public static void showErrorAndFinish(final Activity activity, int msgId) {
- DialogInterface.OnClickListener buttonListener =
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- activity.finish();
- }
- };
- TypedValue out = new TypedValue();
- activity.getTheme().resolveAttribute(android.R.attr.alertDialogIcon, out, true);
- new AlertDialog.Builder(activity)
- .setCancelable(false)
- .setTitle(R.string.camera_error_title)
- .setMessage(msgId)
- .setNeutralButton(R.string.dialog_ok, buttonListener)
- .setIcon(out.resourceId)
- .show();
- }
-
- public static <T> T checkNotNull(T object) {
- if (object == null) throw new NullPointerException();
- return object;
- }
-
- public static boolean equals(Object a, Object b) {
- return (a == b) || (a == null ? false : a.equals(b));
- }
-
- public static int nextPowerOf2(int n) {
- n -= 1;
- n |= n >>> 16;
- n |= n >>> 8;
- n |= n >>> 4;
- n |= n >>> 2;
- n |= n >>> 1;
- return n + 1;
- }
-
- public static float distance(float x, float y, float sx, float sy) {
- float dx = x - sx;
- float dy = y - sy;
- return FloatMath.sqrt(dx * dx + dy * dy);
- }
-
- public static int clamp(int x, int min, int max) {
- if (x > max) return max;
- if (x < min) return min;
- return x;
- }
-
- public static boolean systemRotationLocked(Activity activity) {
- return Settings.System.getInt(activity.getContentResolver(),
- Settings.System.ACCELEROMETER_ROTATION, 0) == 0;
- }
-
- public static int getDisplayRotation(Activity activity) {
- int rotation = activity.getWindowManager().getDefaultDisplay()
- .getRotation();
- switch (rotation) {
- case Surface.ROTATION_0: return 0;
- case Surface.ROTATION_90: return 90;
- case Surface.ROTATION_180: return 180;
- case Surface.ROTATION_270: return 270;
- }
- return 0;
- }
-
- public static int getDisplayOrientation(int degrees, int cameraId) {
- // See android.hardware.Camera.setDisplayOrientation for
- // documentation.
- Camera.CameraInfo info = new Camera.CameraInfo();
- Camera.getCameraInfo(cameraId, info);
- int result;
- if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
- result = (info.orientation + degrees) % 360;
- result = (360 - result) % 360; // compensate the mirror
- } else { // back-facing
- result = (info.orientation - degrees + 360) % 360;
- }
- return result;
- }
-
- public static int getCameraOrientation(int cameraId) {
- Camera.CameraInfo info = new Camera.CameraInfo();
- Camera.getCameraInfo(cameraId, info);
- return info.orientation;
- }
-
- public static int roundOrientation(int orientation, int orientationHistory) {
- boolean changeOrientation = false;
- if (orientationHistory == OrientationEventListener.ORIENTATION_UNKNOWN) {
- changeOrientation = true;
- } else {
- int dist = Math.abs(orientation - orientationHistory);
- dist = Math.min( dist, 360 - dist );
- changeOrientation = ( dist >= 45 + ORIENTATION_HYSTERESIS );
- }
- if (changeOrientation) {
- return ((orientation + 45) / 90 * 90) % 360;
- }
- return orientationHistory;
- }
-
- @SuppressWarnings("deprecation")
- @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
- private static Point getDefaultDisplaySize(Activity activity, Point size) {
- Display d = activity.getWindowManager().getDefaultDisplay();
- if (Build.VERSION.SDK_INT >= ApiHelper.VERSION_CODES.HONEYCOMB_MR2) {
- d.getSize(size);
- } else {
- size.set(d.getWidth(), d.getHeight());
- }
- return size;
- }
-
- public static Size getOptimalPreviewSize(Activity currentActivity,
- List<Size> sizes, double targetRatio) {
- // Use a very small tolerance because we want an exact match.
- final double ASPECT_TOLERANCE = 0.001;
- if (sizes == null) return null;
-
- Size optimalSize = null;
- double minDiff = Double.MAX_VALUE;
-
- // Because of bugs of overlay and layout, we sometimes will try to
- // layout the viewfinder in the portrait orientation and thus get the
- // wrong size of preview surface. When we change the preview size, the
- // new overlay will be created before the old one closed, which causes
- // an exception. For now, just get the screen size.
- Point point = getDefaultDisplaySize(currentActivity, new Point());
- int targetHeight = Math.min(point.x, point.y);
- // Try to find an size match aspect ratio and size
- for (Size size : sizes) {
- double ratio = (double) size.width / size.height;
- if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
- if (Math.abs(size.height - targetHeight) < minDiff) {
- optimalSize = size;
- minDiff = Math.abs(size.height - targetHeight);
- }
- }
- // Cannot find the one match the aspect ratio. This should not happen.
- // Ignore the requirement.
- if (optimalSize == null) {
- Log.w(TAG, "No preview size match the aspect ratio");
- minDiff = Double.MAX_VALUE;
- for (Size size : sizes) {
- if (Math.abs(size.height - targetHeight) < minDiff) {
- optimalSize = size;
- minDiff = Math.abs(size.height - targetHeight);
- }
- }
- }
- return optimalSize;
- }
-
- // Returns the largest picture size which matches the given aspect ratio.
- public static Size getOptimalVideoSnapshotPictureSize(
- List<Size> sizes, double targetRatio) {
- // Use a very small tolerance because we want an exact match.
- final double ASPECT_TOLERANCE = 0.001;
- if (sizes == null) return null;
-
- Size optimalSize = null;
-
- // Try to find a size matches aspect ratio and has the largest width
- for (Size size : sizes) {
- double ratio = (double) size.width / size.height;
- if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;
- if (optimalSize == null || size.width > optimalSize.width) {
- optimalSize = size;
- }
- }
-
- // Cannot find one that matches the aspect ratio. This should not happen.
- // Ignore the requirement.
- if (optimalSize == null) {
- Log.w(TAG, "No picture size match the aspect ratio");
- for (Size size : sizes) {
- if (optimalSize == null || size.width > optimalSize.width) {
- optimalSize = size;
- }
- }
- }
- return optimalSize;
- }
-
- public static void dumpParameters(Parameters parameters) {
- String flattened = parameters.flatten();
- StringTokenizer tokenizer = new StringTokenizer(flattened, ";");
- Log.d(TAG, "Dump all camera parameters:");
- while (tokenizer.hasMoreElements()) {
- Log.d(TAG, tokenizer.nextToken());
- }
- }
-
- /**
- * Returns whether the device is voice-capable (meaning, it can do MMS).
- */
- public static boolean isMmsCapable(Context context) {
- TelephonyManager telephonyManager = (TelephonyManager)
- context.getSystemService(Context.TELEPHONY_SERVICE);
- if (telephonyManager == null) {
- return false;
- }
-
- try {
- Class<?> partypes[] = new Class[0];
- Method sIsVoiceCapable = TelephonyManager.class.getMethod(
- "isVoiceCapable", partypes);
-
- Object arglist[] = new Object[0];
- Object retobj = sIsVoiceCapable.invoke(telephonyManager, arglist);
- return (Boolean) retobj;
- } catch (java.lang.reflect.InvocationTargetException ite) {
- // Failure, must be another device.
- // Assume that it is voice capable.
- } catch (IllegalAccessException iae) {
- // Failure, must be an other device.
- // Assume that it is voice capable.
- } catch (NoSuchMethodException nsme) {
- }
- return true;
- }
-
- // This is for test only. Allow the camera to launch the specific camera.
- public static int getCameraFacingIntentExtras(Activity currentActivity) {
- int cameraId = -1;
-
- int intentCameraId =
- currentActivity.getIntent().getIntExtra(Util.EXTRAS_CAMERA_FACING, -1);
-
- if (isFrontCameraIntent(intentCameraId)) {
- // Check if the front camera exist
- int frontCameraId = CameraHolder.instance().getFrontCameraId();
- if (frontCameraId != -1) {
- cameraId = frontCameraId;
- }
- } else if (isBackCameraIntent(intentCameraId)) {
- // Check if the back camera exist
- int backCameraId = CameraHolder.instance().getBackCameraId();
- if (backCameraId != -1) {
- cameraId = backCameraId;
- }
- }
- return cameraId;
- }
-
- private static boolean isFrontCameraIntent(int intentCameraId) {
- return (intentCameraId == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
- }
-
- private static boolean isBackCameraIntent(int intentCameraId) {
- return (intentCameraId == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
- }
-
- private static int sLocation[] = new int[2];
-
- // This method is not thread-safe.
- public static boolean pointInView(float x, float y, View v) {
- v.getLocationInWindow(sLocation);
- return x >= sLocation[0] && x < (sLocation[0] + v.getWidth())
- && y >= sLocation[1] && y < (sLocation[1] + v.getHeight());
- }
-
- public static int[] getRelativeLocation(View reference, View view) {
- reference.getLocationInWindow(sLocation);
- int referenceX = sLocation[0];
- int referenceY = sLocation[1];
- view.getLocationInWindow(sLocation);
- sLocation[0] -= referenceX;
- sLocation[1] -= referenceY;
- return sLocation;
- }
-
- public static boolean isUriValid(Uri uri, ContentResolver resolver) {
- if (uri == null) return false;
-
- try {
- ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r");
- if (pfd == null) {
- Log.e(TAG, "Fail to open URI. URI=" + uri);
- return false;
- }
- pfd.close();
- } catch (IOException ex) {
- return false;
- }
- return true;
- }
-
- public static void viewUri(Uri uri, Context context) {
- if (!isUriValid(uri, context.getContentResolver())) {
- Log.e(TAG, "Uri invalid. uri=" + uri);
- return;
- }
-
- try {
- context.startActivity(new Intent(Util.REVIEW_ACTION, uri));
- } catch (ActivityNotFoundException ex) {
- try {
- context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
- } catch (ActivityNotFoundException e) {
- Log.e(TAG, "review image fail. uri=" + uri, e);
- }
- }
- }
-
- public static void dumpRect(RectF rect, String msg) {
- Log.v(TAG, msg + "=(" + rect.left + "," + rect.top
- + "," + rect.right + "," + rect.bottom + ")");
- }
-
- public static void rectFToRect(RectF rectF, Rect rect) {
- rect.left = Math.round(rectF.left);
- rect.top = Math.round(rectF.top);
- rect.right = Math.round(rectF.right);
- rect.bottom = Math.round(rectF.bottom);
- }
-
- public static void prepareMatrix(Matrix matrix, boolean mirror, int displayOrientation,
- int viewWidth, int viewHeight) {
- // Need mirror for front camera.
- matrix.setScale(mirror ? -1 : 1, 1);
- // This is the value for android.hardware.Camera.setDisplayOrientation.
- matrix.postRotate(displayOrientation);
- // Camera driver coordinates range from (-1000, -1000) to (1000, 1000).
- // UI coordinates range from (0, 0) to (width, height).
- matrix.postScale(viewWidth / 2000f, viewHeight / 2000f);
- matrix.postTranslate(viewWidth / 2f, viewHeight / 2f);
- }
-
- public static String createJpegName(long dateTaken) {
- synchronized (sImageFileNamer) {
- return sImageFileNamer.generateName(dateTaken);
- }
- }
-
- public static void broadcastNewPicture(Context context, Uri uri) {
- context.sendBroadcast(new Intent(ACTION_NEW_PICTURE, uri));
- // Keep compatibility
- context.sendBroadcast(new Intent("com.android.camera.NEW_PICTURE", uri));
- }
-
- public static void fadeIn(View view, float startAlpha, float endAlpha, long duration) {
- if (view.getVisibility() == View.VISIBLE) return;
-
- view.setVisibility(View.VISIBLE);
- Animation animation = new AlphaAnimation(startAlpha, endAlpha);
- animation.setDuration(duration);
- view.startAnimation(animation);
- }
-
- public static void fadeIn(View view) {
- fadeIn(view, 0F, 1F, 400);
-
- // We disabled the button in fadeOut(), so enable it here.
- view.setEnabled(true);
- }
-
- public static void fadeOut(View view) {
- if (view.getVisibility() != View.VISIBLE) return;
-
- // Since the button is still clickable before fade-out animation
- // ends, we disable the button first to block click.
- view.setEnabled(false);
- Animation animation = new AlphaAnimation(1F, 0F);
- animation.setDuration(400);
- view.startAnimation(animation);
- view.setVisibility(View.GONE);
- }
-
- public static int getJpegRotation(int cameraId, int orientation) {
- // See android.hardware.Camera.Parameters.setRotation for
- // documentation.
- int rotation = 0;
- if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
- CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId];
- if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
- rotation = (info.orientation - orientation + 360) % 360;
- } else { // back-facing camera
- rotation = (info.orientation + orientation) % 360;
- }
- }
- return rotation;
- }
-
- public static void setGpsParameters(Parameters parameters, Location loc) {
- // Clear previous GPS location from the parameters.
- parameters.removeGpsData();
-
- // We always encode GpsTimeStamp
- parameters.setGpsTimestamp(System.currentTimeMillis() / 1000);
-
- // Set GPS location.
- if (loc != null) {
- double lat = loc.getLatitude();
- double lon = loc.getLongitude();
- boolean hasLatLon = (lat != 0.0d) || (lon != 0.0d);
-
- if (hasLatLon) {
- Log.d(TAG, "Set gps location");
- parameters.setGpsLatitude(lat);
- parameters.setGpsLongitude(lon);
- parameters.setGpsProcessingMethod(loc.getProvider().toUpperCase());
- if (loc.hasAltitude()) {
- parameters.setGpsAltitude(loc.getAltitude());
- } else {
- // for NETWORK_PROVIDER location provider, we may have
- // no altitude information, but the driver needs it, so
- // we fake one.
- parameters.setGpsAltitude(0);
- }
- if (loc.getTime() != 0) {
- // Location.getTime() is UTC in milliseconds.
- // gps-timestamp is UTC in seconds.
- long utcTimeSeconds = loc.getTime() / 1000;
- parameters.setGpsTimestamp(utcTimeSeconds);
- }
- } else {
- loc = null;
- }
- }
- }
-
- private static class ImageFileNamer {
- private SimpleDateFormat mFormat;
-
- // The date (in milliseconds) used to generate the last name.
- private long mLastDate;
-
- // Number of names generated for the same second.
- private int mSameSecondCount;
-
- public ImageFileNamer(String format) {
- mFormat = new SimpleDateFormat(format);
- }
-
- public String generateName(long dateTaken) {
- Date date = new Date(dateTaken);
- String result = mFormat.format(date);
-
- // If the last name was generated for the same second,
- // we append _1, _2, etc to the name.
- if (dateTaken / 1000 == mLastDate / 1000) {
- mSameSecondCount++;
- result += "_" + mSameSecondCount;
- } else {
- mLastDate = dateTaken;
- mSameSecondCount = 0;
- }
-
- return result;
- }
- }
-}
diff --git a/src/com/android/camera/VideoController.java b/src/com/android/camera/VideoController.java
deleted file mode 100644
index 474f521..0000000
--- a/src/com/android/camera/VideoController.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.camera;
-
-import android.view.View;
-
-import com.android.camera.ShutterButton.OnShutterButtonListener;
-
-public interface VideoController extends OnShutterButtonListener {
-
- public void onReviewDoneClicked(View view);
- public void onReviewCancelClicked(View viwe);
- public void onReviewPlayClicked(View view);
-
- public boolean isVideoCaptureIntent();
- public boolean isInReviewMode();
- public int onZoomChanged(int index);
-
- public void onSingleTapUp(View view, int x, int y);
-
- public void stopPreview();
-}
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java
deleted file mode 100644
index 9bfcdea..0000000
--- a/src/com/android/camera/VideoMenu.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-
-import com.android.camera.ui.AbstractSettingPopup;
-import com.android.camera.ui.ListPrefSettingPopup;
-import com.android.camera.ui.MoreSettingPopup;
-import com.android.camera.ui.PieItem;
-import com.android.camera.ui.PieItem.OnClickListener;
-import com.android.camera.ui.PieRenderer;
-import com.android.camera.ui.TimeIntervalPopup;
-import com.android.gallery3d.R;
-
-public class VideoMenu extends PieController
- implements MoreSettingPopup.Listener,
- ListPrefSettingPopup.Listener,
- TimeIntervalPopup.Listener {
-
- private static String TAG = "CAM_VideoMenu";
-
- private VideoUI mUI;
- private String[] mOtherKeys;
- private AbstractSettingPopup mPopup;
-
- private static final int POPUP_NONE = 0;
- private static final int POPUP_FIRST_LEVEL = 1;
- private static final int POPUP_SECOND_LEVEL = 2;
- private int mPopupStatus;
- private CameraActivity mActivity;
-
- public VideoMenu(CameraActivity activity, VideoUI ui, PieRenderer pie) {
- super(activity, pie);
- mUI = ui;
- mActivity = activity;
- }
-
- public void initialize(PreferenceGroup group) {
- super.initialize(group);
- mPopup = null;
- mPopupStatus = POPUP_NONE;
- PieItem item = null;
- // white balance
- if (group.findPreference(CameraSettings.KEY_WHITE_BALANCE) != null) {
- item = makeItem(CameraSettings.KEY_WHITE_BALANCE);
- mRenderer.addItem(item);
- }
- // settings popup
- mOtherKeys = new String[] {
- CameraSettings.KEY_VIDEO_EFFECT,
- CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL,
- CameraSettings.KEY_VIDEO_QUALITY,
- CameraSettings.KEY_RECORD_LOCATION
- };
- item = makeItem(R.drawable.ic_settings_holo_light);
- item.setLabel(mActivity.getResources().getString(R.string.camera_menu_settings_label));
- item.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(PieItem item) {
- if (mPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) {
- initializePopup();
- mPopupStatus = POPUP_FIRST_LEVEL;
- }
- mUI.showPopup(mPopup);
- }
- });
- mRenderer.addItem(item);
- // camera switcher
- if (group.findPreference(CameraSettings.KEY_CAMERA_ID) != null) {
- item = makeItem(R.drawable.ic_switch_back);
- IconListPreference lpref = (IconListPreference) group.findPreference(
- CameraSettings.KEY_CAMERA_ID);
- item.setLabel(lpref.getLabel());
- item.setImageResource(mActivity,
- ((IconListPreference) lpref).getIconIds()
- [lpref.findIndexOfValue(lpref.getValue())]);
-
- final PieItem fitem = item;
- item.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(PieItem item) {
- // Find the index of next camera.
- ListPreference pref =
- mPreferenceGroup.findPreference(CameraSettings.KEY_CAMERA_ID);
- if (pref != null) {
- int index = pref.findIndexOfValue(pref.getValue());
- CharSequence[] values = pref.getEntryValues();
- index = (index + 1) % values.length;
- int newCameraId = Integer.parseInt((String) values[index]);
- fitem.setImageResource(mActivity,
- ((IconListPreference) pref).getIconIds()[index]);
- fitem.setLabel(pref.getLabel());
- mListener.onCameraPickerClicked(newCameraId);
- }
- }
- });
- mRenderer.addItem(item);
- }
- // flash
- if (group.findPreference(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE) != null) {
- item = makeItem(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE);
- mRenderer.addItem(item);
- }
- }
-
- @Override
- public void reloadPreferences() {
- super.reloadPreferences();
- if (mPopup != null) {
- mPopup.reloadPreference();
- }
- }
-
- @Override
- public void overrideSettings(final String ... keyvalues) {
- super.overrideSettings(keyvalues);
- if (mPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) {
- mPopupStatus = POPUP_FIRST_LEVEL;
- initializePopup();
- }
- ((MoreSettingPopup) mPopup).overrideSettings(keyvalues);
- }
-
- @Override
- // Hit when an item in the second-level popup gets selected
- public void onListPrefChanged(ListPreference pref) {
- if (mPopup != null) {
- if (mPopupStatus == POPUP_SECOND_LEVEL) {
- mUI.dismissPopup(true);
- }
- }
- super.onSettingChanged(pref);
- }
-
- protected void initializePopup() {
- LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
-
- MoreSettingPopup popup = (MoreSettingPopup) inflater.inflate(
- R.layout.more_setting_popup, null, false);
- popup.setSettingChangedListener(this);
- popup.initialize(mPreferenceGroup, mOtherKeys);
- if (mActivity.isSecureCamera()) {
- // Prevent location preference from getting changed in secure camera mode
- popup.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION, false);
- }
- mPopup = popup;
- }
-
- public void popupDismissed(boolean topPopupOnly) {
- // if the 2nd level popup gets dismissed
- if (mPopupStatus == POPUP_SECOND_LEVEL) {
- initializePopup();
- mPopupStatus = POPUP_FIRST_LEVEL;
- if (topPopupOnly) mUI.showPopup(mPopup);
- }
- }
-
- @Override
- // Hit when an item in the first-level popup gets selected, then bring up
- // the second-level popup
- public void onPreferenceClicked(ListPreference pref) {
- if (mPopupStatus != POPUP_FIRST_LEVEL) return;
-
- LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
-
- if (CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL.equals(pref.getKey())) {
- TimeIntervalPopup timeInterval = (TimeIntervalPopup) inflater.inflate(
- R.layout.time_interval_popup, null, false);
- timeInterval.initialize((IconListPreference) pref);
- timeInterval.setSettingChangedListener(this);
- mUI.dismissPopup(true);
- mPopup = timeInterval;
- } else {
- ListPrefSettingPopup basic = (ListPrefSettingPopup) inflater.inflate(
- R.layout.list_pref_setting_popup, null, false);
- basic.initialize(pref);
- basic.setSettingChangedListener(this);
- mUI.dismissPopup(true);
- mPopup = basic;
- }
- mUI.showPopup(mPopup);
- mPopupStatus = POPUP_SECOND_LEVEL;
- }
-
-}
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
deleted file mode 100644
index 2eb3d1b..0000000
--- a/src/com/android/camera/VideoModule.java
+++ /dev/null
@@ -1,2328 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.content.ActivityNotFoundException;
-import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences.Editor;
-import android.content.res.Configuration;
-import android.graphics.Bitmap;
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera.CameraInfo;
-import android.hardware.Camera.Parameters;
-import android.hardware.Camera.PictureCallback;
-import android.hardware.Camera.Size;
-import android.location.Location;
-import android.media.CamcorderProfile;
-import android.media.CameraProfile;
-import android.media.MediaRecorder;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.os.ParcelFileDescriptor;
-import android.os.SystemClock;
-import android.provider.MediaStore;
-import android.provider.MediaStore.MediaColumns;
-import android.provider.MediaStore.Video;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.OrientationEventListener;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.Toast;
-
-import com.android.camera.ui.PopupManager;
-import com.android.camera.ui.RotateTextToast;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.exif.ExifInterface;
-import com.android.gallery3d.util.AccessibilityUtils;
-import com.android.gallery3d.util.UsageStatistics;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-public class VideoModule implements CameraModule,
- VideoController,
- CameraPreference.OnPreferenceChangedListener,
- ShutterButton.OnShutterButtonListener,
- MediaRecorder.OnErrorListener,
- MediaRecorder.OnInfoListener,
- EffectsRecorder.EffectsListener {
-
- private static final String TAG = "CAM_VideoModule";
-
- // We number the request code from 1000 to avoid collision with Gallery.
- private static final int REQUEST_EFFECT_BACKDROPPER = 1000;
-
- private static final int CHECK_DISPLAY_ROTATION = 3;
- private static final int CLEAR_SCREEN_DELAY = 4;
- private static final int UPDATE_RECORD_TIME = 5;
- private static final int ENABLE_SHUTTER_BUTTON = 6;
- private static final int SHOW_TAP_TO_SNAPSHOT_TOAST = 7;
- private static final int SWITCH_CAMERA = 8;
- private static final int SWITCH_CAMERA_START_ANIMATION = 9;
- private static final int HIDE_SURFACE_VIEW = 10;
- private static final int CAPTURE_ANIMATION_DONE = 11;
-
- private static final int SCREEN_DELAY = 2 * 60 * 1000;
-
- private static final long SHUTTER_BUTTON_TIMEOUT = 500L; // 500ms
-
- /**
- * An unpublished intent flag requesting to start recording straight away
- * and return as soon as recording is stopped.
- * TODO: consider publishing by moving into MediaStore.
- */
- private static final String EXTRA_QUICK_CAPTURE =
- "android.intent.extra.quickCapture";
-
- private static final int MIN_THUMB_SIZE = 64;
- // module fields
- private CameraActivity mActivity;
- private boolean mPaused;
- private int mCameraId;
- private Parameters mParameters;
-
- private Boolean mCameraOpened = false;
-
- private boolean mSnapshotInProgress = false;
-
- private static final String EFFECT_BG_FROM_GALLERY = "gallery";
-
- private final CameraErrorCallback mErrorCallback = new CameraErrorCallback();
-
- private ComboPreferences mPreferences;
- private PreferenceGroup mPreferenceGroup;
-
- private CameraScreenNail.OnFrameDrawnListener mFrameDrawnListener;
-
- private boolean mIsVideoCaptureIntent;
- private boolean mQuickCapture;
- private boolean mIsInReviewMode = false;
-
- private MediaRecorder mMediaRecorder;
- private EffectsRecorder mEffectsRecorder;
- private boolean mEffectsDisplayResult;
-
- private int mEffectType = EffectsRecorder.EFFECT_NONE;
- private Object mEffectParameter = null;
- private String mEffectUriFromGallery = null;
- private String mPrefVideoEffectDefault;
- private boolean mResetEffect = true;
-
- private boolean mSwitchingCamera;
- private boolean mMediaRecorderRecording = false;
- private long mRecordingStartTime;
- private boolean mRecordingTimeCountsDown = false;
- private long mOnResumeTime;
- // The video file that the hardware camera is about to record into
- // (or is recording into.)
- private String mVideoFilename;
- private ParcelFileDescriptor mVideoFileDescriptor;
-
- // The video file that has already been recorded, and that is being
- // examined by the user.
- private String mCurrentVideoFilename;
- private Uri mCurrentVideoUri;
- private ContentValues mCurrentVideoValues;
-
- private CamcorderProfile mProfile;
-
- // The video duration limit. 0 menas no limit.
- private int mMaxVideoDurationInMs;
-
- // Time Lapse parameters.
- private boolean mCaptureTimeLapse = false;
- // Default 0. If it is larger than 0, the camcorder is in time lapse mode.
- private int mTimeBetweenTimeLapseFrameCaptureMs = 0;
-
- boolean mPreviewing = false; // True if preview is started.
- // The display rotation in degrees. This is only valid when mPreviewing is
- // true.
- private int mDisplayRotation;
- private int mCameraDisplayOrientation;
-
- private int mDesiredPreviewWidth;
- private int mDesiredPreviewHeight;
- private ContentResolver mContentResolver;
-
- private LocationManager mLocationManager;
-
- private int mPendingSwitchCameraId;
-
- private final Handler mHandler = new MainHandler();
- private VideoUI mUI;
- // The degrees of the device rotated clockwise from its natural orientation.
- private int mOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
-
- private int mZoomValue; // The current zoom value.
-
- private boolean mRestoreFlash; // This is used to check if we need to restore the flash
- // status when going back from gallery.
-
- private final MediaSaveService.OnMediaSavedListener mOnVideoSavedListener =
- new MediaSaveService.OnMediaSavedListener() {
- @Override
- public void onMediaSaved(Uri uri) {
- if (uri != null) {
- mActivity.addSecureAlbumItemIfNeeded(true, uri);
- mActivity.sendBroadcast(
- new Intent(Util.ACTION_NEW_VIDEO, uri));
- Util.broadcastNewPicture(mActivity, uri);
- }
- }
- };
-
- private final MediaSaveService.OnMediaSavedListener mOnPhotoSavedListener =
- new MediaSaveService.OnMediaSavedListener() {
- @Override
- public void onMediaSaved(Uri uri) {
- if (uri != null) {
- Util.broadcastNewPicture(mActivity, uri);
- }
- }
- };
-
-
- protected class CameraOpenThread extends Thread {
- @Override
- public void run() {
- openCamera();
- }
- }
-
- private void openCamera() {
- try {
- synchronized(mCameraOpened) {
- if (!mCameraOpened) {
- mActivity.mCameraDevice = Util.openCamera(mActivity, mCameraId);
- mCameraOpened = true;
- }
- }
- mParameters = mActivity.mCameraDevice.getParameters();
- } catch (CameraHardwareException e) {
- mActivity.mOpenCameraFail = true;
- } catch (CameraDisabledException e) {
- mActivity.mCameraDisabled = true;
- }
- }
-
- // This Handler is used to post message back onto the main thread of the
- // application
- private class MainHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
-
- case ENABLE_SHUTTER_BUTTON:
- mUI.enableShutter(true);
- break;
-
- case CLEAR_SCREEN_DELAY: {
- mActivity.getWindow().clearFlags(
- WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- break;
- }
-
- case UPDATE_RECORD_TIME: {
- updateRecordingTime();
- break;
- }
-
- case CHECK_DISPLAY_ROTATION: {
- // Restart the preview if display rotation has changed.
- // Sometimes this happens when the device is held upside
- // down and camera app is opened. Rotation animation will
- // take some time and the rotation value we have got may be
- // wrong. Framework does not have a callback for this now.
- if ((Util.getDisplayRotation(mActivity) != mDisplayRotation)
- && !mMediaRecorderRecording && !mSwitchingCamera) {
- startPreview();
- }
- if (SystemClock.uptimeMillis() - mOnResumeTime < 5000) {
- mHandler.sendEmptyMessageDelayed(CHECK_DISPLAY_ROTATION, 100);
- }
- break;
- }
-
- case SHOW_TAP_TO_SNAPSHOT_TOAST: {
- showTapToSnapshotToast();
- break;
- }
-
- case SWITCH_CAMERA: {
- switchCamera();
- break;
- }
-
- case SWITCH_CAMERA_START_ANIMATION: {
- ((CameraScreenNail) mActivity.mCameraScreenNail).animateSwitchCamera();
-
- // Enable all camera controls.
- mSwitchingCamera = false;
- break;
- }
-
- case HIDE_SURFACE_VIEW: {
- mUI.hideSurfaceView();
- break;
- }
-
- case CAPTURE_ANIMATION_DONE: {
- mUI.enablePreviewThumb(false);
- break;
- }
-
- default:
- Log.v(TAG, "Unhandled message: " + msg.what);
- break;
- }
- }
- }
-
- private BroadcastReceiver mReceiver = null;
-
- private class MyBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(Intent.ACTION_MEDIA_EJECT)) {
- stopVideoRecording();
- } else if (action.equals(Intent.ACTION_MEDIA_SCANNER_STARTED)) {
- Toast.makeText(mActivity,
- mActivity.getResources().getString(R.string.wait), Toast.LENGTH_LONG).show();
- }
- }
- }
-
- private String createName(long dateTaken) {
- Date date = new Date(dateTaken);
- SimpleDateFormat dateFormat = new SimpleDateFormat(
- mActivity.getString(R.string.video_file_name_format));
-
- return dateFormat.format(date);
- }
-
- private int getPreferredCameraId(ComboPreferences preferences) {
- int intentCameraId = Util.getCameraFacingIntentExtras(mActivity);
- if (intentCameraId != -1) {
- // Testing purpose. Launch a specific camera through the intent
- // extras.
- return intentCameraId;
- } else {
- return CameraSettings.readPreferredCameraId(preferences);
- }
- }
-
- private void initializeSurfaceView() {
- if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) { // API level < 16
- mFrameDrawnListener = new CameraScreenNail.OnFrameDrawnListener() {
- @Override
- public void onFrameDrawn(CameraScreenNail c) {
- mHandler.sendEmptyMessage(HIDE_SURFACE_VIEW);
- }
- };
- mUI.getSurfaceHolder().addCallback(mUI);
- }
- }
-
- @Override
- public void init(CameraActivity activity, View root, boolean reuseScreenNail) {
- mActivity = activity;
- mUI = new VideoUI(activity, this, root);
- mPreferences = new ComboPreferences(mActivity);
- CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal());
- mCameraId = getPreferredCameraId(mPreferences);
-
- mPreferences.setLocalId(mActivity, mCameraId);
- CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
-
- mActivity.mNumberOfCameras = CameraHolder.instance().getNumberOfCameras();
- mPrefVideoEffectDefault = mActivity.getString(R.string.pref_video_effect_default);
- resetEffect();
-
- /*
- * To reduce startup time, we start the preview in another thread.
- * We make sure the preview is started at the end of onCreate.
- */
- CameraOpenThread cameraOpenThread = new CameraOpenThread();
- cameraOpenThread.start();
-
- mContentResolver = mActivity.getContentResolver();
-
- // Surface texture is from camera screen nail and startPreview needs it.
- // This must be done before startPreview.
- mIsVideoCaptureIntent = isVideoCaptureIntent();
- if (reuseScreenNail) {
- mActivity.reuseCameraScreenNail(!mIsVideoCaptureIntent);
- } else {
- mActivity.createCameraScreenNail(!mIsVideoCaptureIntent);
- }
- initializeSurfaceView();
-
- // Make sure camera device is opened.
- try {
- cameraOpenThread.join();
- if (mActivity.mOpenCameraFail) {
- Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
- return;
- } else if (mActivity.mCameraDisabled) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
- return;
- }
- } catch (InterruptedException ex) {
- // ignore
- }
-
- readVideoPreferences();
- mUI.setPrefChangedListener(this);
- new Thread(new Runnable() {
- @Override
- public void run() {
- startPreview();
- }
- }).start();
-
- mQuickCapture = mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE, false);
- mLocationManager = new LocationManager(mActivity, null);
-
- mUI.setOrientationIndicator(0, false);
- setDisplayOrientation();
-
- mUI.showTimeLapseUI(mCaptureTimeLapse);
- initializeVideoSnapshot();
- resizeForPreviewAspectRatio();
-
- initializeVideoControl();
- mPendingSwitchCameraId = -1;
- mUI.updateOnScreenIndicators(mParameters, mPreferences);
-
- // Disable the shutter button if effects are ON since it might take
- // a little more time for the effects preview to be ready. We do not
- // want to allow recording before that happens. The shutter button
- // will be enabled when we get the message from effectsrecorder that
- // the preview is running. This becomes critical when the camera is
- // swapped.
- if (effectsActive()) {
- mUI.enableShutter(false);
- }
- }
-
- // SingleTapListener
- // Preview area is touched. Take a picture.
- @Override
- public void onSingleTapUp(View view, int x, int y) {
- if (mMediaRecorderRecording && effectsActive()) {
- new RotateTextToast(mActivity, R.string.disable_video_snapshot_hint,
- mOrientation).show();
- return;
- }
-
- MediaSaveService s = mActivity.getMediaSaveService();
- if (mPaused || mSnapshotInProgress || effectsActive() || s == null || s.isQueueFull()) {
- return;
- }
-
- if (!mMediaRecorderRecording) {
- // check for dismissing popup
- mUI.dismissPopup(true);
- return;
- }
-
- // Set rotation and gps data.
- int rotation = Util.getJpegRotation(mCameraId, mOrientation);
- mParameters.setRotation(rotation);
- Location loc = mLocationManager.getCurrentLocation();
- Util.setGpsParameters(mParameters, loc);
- mActivity.mCameraDevice.setParameters(mParameters);
-
- Log.v(TAG, "Video snapshot start");
- mActivity.mCameraDevice.takePicture(null, null, null, new JpegPictureCallback(loc));
- showVideoSnapshotUI(true);
- mSnapshotInProgress = true;
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
- UsageStatistics.ACTION_CAPTURE_DONE, "VideoSnapshot");
- }
-
- @Override
- public void onStop() {}
-
- private void loadCameraPreferences() {
- CameraSettings settings = new CameraSettings(mActivity, mParameters,
- mCameraId, CameraHolder.instance().getCameraInfo());
- // Remove the video quality preference setting when the quality is given in the intent.
- mPreferenceGroup = filterPreferenceScreenByIntent(
- settings.getPreferenceGroup(R.xml.video_preferences));
- }
-
- private void initializeVideoControl() {
- loadCameraPreferences();
- mUI.initializePopup(mPreferenceGroup);
- if (effectsActive()) {
- mUI.overrideSettings(
- CameraSettings.KEY_VIDEO_QUALITY,
- Integer.toString(getLowVideoQuality()));
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- private static int getLowVideoQuality() {
- if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) {
- return CamcorderProfile.QUALITY_480P;
- } else {
- return CamcorderProfile.QUALITY_LOW;
- }
- }
-
-
- @Override
- public void onOrientationChanged(int orientation) {
- // We keep the last known orientation. So if the user first orient
- // the camera then point the camera to floor or sky, we still have
- // the correct orientation.
- if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) return;
- int newOrientation = Util.roundOrientation(orientation, mOrientation);
-
- if (mOrientation != newOrientation) {
- mOrientation = newOrientation;
- // The input of effects recorder is affected by
- // android.hardware.Camera.setDisplayOrientation. Its value only
- // compensates the camera orientation (no Display.getRotation).
- // So the orientation hint here should only consider sensor
- // orientation.
- if (effectsActive()) {
- mEffectsRecorder.setOrientationHint(mOrientation);
- }
- }
-
- // Show the toast after getting the first orientation changed.
- if (mHandler.hasMessages(SHOW_TAP_TO_SNAPSHOT_TOAST)) {
- mHandler.removeMessages(SHOW_TAP_TO_SNAPSHOT_TOAST);
- showTapToSnapshotToast();
- }
- }
-
- private void startPlayVideoActivity() {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(mCurrentVideoUri, convertOutputFormatToMimeType(mProfile.fileFormat));
- try {
- mActivity.startActivity(intent);
- } catch (ActivityNotFoundException ex) {
- Log.e(TAG, "Couldn't view video " + mCurrentVideoUri, ex);
- }
- }
-
- @OnClickAttr
- public void onReviewPlayClicked(View v) {
- startPlayVideoActivity();
- }
-
- @OnClickAttr
- public void onReviewDoneClicked(View v) {
- mIsInReviewMode = false;
- doReturnToCaller(true);
- }
-
- @OnClickAttr
- public void onReviewCancelClicked(View v) {
- mIsInReviewMode = false;
- stopVideoRecording();
- doReturnToCaller(false);
- }
-
- @Override
- public boolean isInReviewMode() {
- return mIsInReviewMode;
- }
-
- private void onStopVideoRecording() {
- mEffectsDisplayResult = true;
- boolean recordFail = stopVideoRecording();
- if (mIsVideoCaptureIntent) {
- if (!effectsActive()) {
- if (mQuickCapture) {
- doReturnToCaller(!recordFail);
- } else if (!recordFail) {
- showCaptureResult();
- }
- }
- } else if (!recordFail){
- // Start capture animation.
- if (!mPaused && ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
- // The capture animation is disabled on ICS because we use SurfaceView
- // for preview during recording. When the recording is done, we switch
- // back to use SurfaceTexture for preview and we need to stop then start
- // the preview. This will cause the preview flicker since the preview
- // will not be continuous for a short period of time.
-
- // Get orientation directly from display rotation to make sure it's up
- // to date. OnConfigurationChanged callback usually kicks in a bit later, if
- // device is rotated during recording.
- mDisplayRotation = Util.getDisplayRotation(mActivity);
- ((CameraScreenNail) mActivity.mCameraScreenNail).animateCapture(mDisplayRotation);
-
- mUI.enablePreviewThumb(true);
-
- // Make sure to disable the thumbnail preview after the
- // animation is done to disable the click target.
- mHandler.removeMessages(CAPTURE_ANIMATION_DONE);
- mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
- CaptureAnimManager.getAnimationDuration());
- }
- }
- }
-
- public void onProtectiveCurtainClick(View v) {
- // Consume clicks
- }
-
- @Override
- public void onShutterButtonClick() {
- if (mUI.collapseCameraControls() || mSwitchingCamera) return;
-
- boolean stop = mMediaRecorderRecording;
-
- if (stop) {
- onStopVideoRecording();
- } else {
- startVideoRecording();
- }
- mUI.enableShutter(false);
-
- // Keep the shutter button disabled when in video capture intent
- // mode and recording is stopped. It'll be re-enabled when
- // re-take button is clicked.
- if (!(mIsVideoCaptureIntent && stop)) {
- mHandler.sendEmptyMessageDelayed(
- ENABLE_SHUTTER_BUTTON, SHUTTER_BUTTON_TIMEOUT);
- }
- }
-
- @Override
- public void onShutterButtonFocus(boolean pressed) {
- mUI.setShutterPressed(pressed);
- }
-
- private void readVideoPreferences() {
- // The preference stores values from ListPreference and is thus string type for all values.
- // We need to convert it to int manually.
- String defaultQuality = CameraSettings.getDefaultVideoQuality(mCameraId,
- mActivity.getResources().getString(R.string.pref_video_quality_default));
- String videoQuality =
- mPreferences.getString(CameraSettings.KEY_VIDEO_QUALITY,
- defaultQuality);
- int quality = Integer.valueOf(videoQuality);
-
- // Set video quality.
- Intent intent = mActivity.getIntent();
- if (intent.hasExtra(MediaStore.EXTRA_VIDEO_QUALITY)) {
- int extraVideoQuality =
- intent.getIntExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
- if (extraVideoQuality > 0) {
- quality = CamcorderProfile.QUALITY_HIGH;
- } else { // 0 is mms.
- quality = CamcorderProfile.QUALITY_LOW;
- }
- }
-
- // Set video duration limit. The limit is read from the preference,
- // unless it is specified in the intent.
- if (intent.hasExtra(MediaStore.EXTRA_DURATION_LIMIT)) {
- int seconds =
- intent.getIntExtra(MediaStore.EXTRA_DURATION_LIMIT, 0);
- mMaxVideoDurationInMs = 1000 * seconds;
- } else {
- mMaxVideoDurationInMs = CameraSettings.getMaxVideoDuration(mActivity);
- }
-
- // Set effect
- mEffectType = CameraSettings.readEffectType(mPreferences);
- if (mEffectType != EffectsRecorder.EFFECT_NONE) {
- mEffectParameter = CameraSettings.readEffectParameter(mPreferences);
- // Set quality to be no higher than 480p.
- CamcorderProfile profile = CamcorderProfile.get(mCameraId, quality);
- if (profile.videoFrameHeight > 480) {
- quality = getLowVideoQuality();
- }
- } else {
- mEffectParameter = null;
- }
- // Read time lapse recording interval.
- if (ApiHelper.HAS_TIME_LAPSE_RECORDING) {
- String frameIntervalStr = mPreferences.getString(
- CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL,
- mActivity.getString(R.string.pref_video_time_lapse_frame_interval_default));
- mTimeBetweenTimeLapseFrameCaptureMs = Integer.parseInt(frameIntervalStr);
- mCaptureTimeLapse = (mTimeBetweenTimeLapseFrameCaptureMs != 0);
- }
- // TODO: This should be checked instead directly +1000.
- if (mCaptureTimeLapse) quality += 1000;
- mProfile = CamcorderProfile.get(mCameraId, quality);
- getDesiredPreviewSize();
- }
-
- private void writeDefaultEffectToPrefs() {
- ComboPreferences.Editor editor = mPreferences.edit();
- editor.putString(CameraSettings.KEY_VIDEO_EFFECT,
- mActivity.getString(R.string.pref_video_effect_default));
- editor.apply();
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- private void getDesiredPreviewSize() {
- mParameters = mActivity.mCameraDevice.getParameters();
- if (ApiHelper.HAS_GET_SUPPORTED_VIDEO_SIZE) {
- if (mParameters.getSupportedVideoSizes() == null || effectsActive()) {
- mDesiredPreviewWidth = mProfile.videoFrameWidth;
- mDesiredPreviewHeight = mProfile.videoFrameHeight;
- } else { // Driver supports separates outputs for preview and video.
- List<Size> sizes = mParameters.getSupportedPreviewSizes();
- Size preferred = mParameters.getPreferredPreviewSizeForVideo();
- int product = preferred.width * preferred.height;
- Iterator<Size> it = sizes.iterator();
- // Remove the preview sizes that are not preferred.
- while (it.hasNext()) {
- Size size = it.next();
- if (size.width * size.height > product) {
- it.remove();
- }
- }
- Size optimalSize = Util.getOptimalPreviewSize(mActivity, sizes,
- (double) mProfile.videoFrameWidth / mProfile.videoFrameHeight);
- mDesiredPreviewWidth = optimalSize.width;
- mDesiredPreviewHeight = optimalSize.height;
- }
- } else {
- mDesiredPreviewWidth = mProfile.videoFrameWidth;
- mDesiredPreviewHeight = mProfile.videoFrameHeight;
- }
- Log.v(TAG, "mDesiredPreviewWidth=" + mDesiredPreviewWidth +
- ". mDesiredPreviewHeight=" + mDesiredPreviewHeight);
- }
-
- private void resizeForPreviewAspectRatio() {
- mUI.setAspectRatio(
- (double) mProfile.videoFrameWidth / mProfile.videoFrameHeight);
- }
-
- @Override
- public void installIntentFilter() {
- // install an intent filter to receive SD card related events.
- IntentFilter intentFilter =
- new IntentFilter(Intent.ACTION_MEDIA_EJECT);
- intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
- intentFilter.addDataScheme("file");
- mReceiver = new MyBroadcastReceiver();
- mActivity.registerReceiver(mReceiver, intentFilter);
- }
-
- @Override
- public void onResumeBeforeSuper() {
- mPaused = false;
- }
-
- @Override
- public void onResumeAfterSuper() {
- if (mActivity.mOpenCameraFail || mActivity.mCameraDisabled)
- return;
- mUI.enableShutter(false);
- mZoomValue = 0;
-
- showVideoSnapshotUI(false);
-
- if (!mPreviewing) {
- resetEffect();
- openCamera();
- if (mActivity.mOpenCameraFail) {
- Util.showErrorAndFinish(mActivity,
- R.string.cannot_connect_camera);
- return;
- } else if (mActivity.mCameraDisabled) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
- return;
- }
- readVideoPreferences();
- resizeForPreviewAspectRatio();
- new Thread(new Runnable() {
- @Override
- public void run() {
- startPreview();
- }
- }).start();
- } else {
- // preview already started
- mUI.enableShutter(true);
- }
-
- // Initializing it here after the preview is started.
- mUI.initializeZoom(mParameters);
-
- keepScreenOnAwhile();
-
- // Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(mPreferences,
- mContentResolver);
- mLocationManager.recordLocation(recordLocation);
-
- if (mPreviewing) {
- mOnResumeTime = SystemClock.uptimeMillis();
- mHandler.sendEmptyMessageDelayed(CHECK_DISPLAY_ROTATION, 100);
- }
- // Dismiss open menu if exists.
- PopupManager.getInstance(mActivity).notifyShowPopup(null);
-
- UsageStatistics.onContentViewChanged(
- UsageStatistics.COMPONENT_CAMERA, "VideoModule");
- }
-
- private void setDisplayOrientation() {
- mDisplayRotation = Util.getDisplayRotation(mActivity);
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- // The display rotation is handled by gallery.
- mCameraDisplayOrientation = Util.getDisplayOrientation(0, mCameraId);
- } else {
- // We need to consider display rotation ourselves.
- mCameraDisplayOrientation = Util.getDisplayOrientation(mDisplayRotation, mCameraId);
- }
- // GLRoot also uses the DisplayRotation, and needs to be told to layout to update
- mActivity.getGLRoot().requestLayoutContentPane();
- }
-
- @Override
- public int onZoomChanged(int index) {
- // Not useful to change zoom value when the activity is paused.
- if (mPaused) return index;
- mZoomValue = index;
- if (mParameters == null || mActivity.mCameraDevice == null) return index;
- // Set zoom parameters asynchronously
- mParameters.setZoom(mZoomValue);
- mActivity.mCameraDevice.setParameters(mParameters);
- Parameters p = mActivity.mCameraDevice.getParameters();
- if (p != null) return p.getZoom();
- return index;
- }
- private void startPreview() {
- Log.v(TAG, "startPreview");
-
- mActivity.mCameraDevice.setErrorCallback(mErrorCallback);
- if (mPreviewing == true) {
- stopPreview();
- if (effectsActive() && mEffectsRecorder != null) {
- mEffectsRecorder.release();
- mEffectsRecorder = null;
- }
- }
-
- setDisplayOrientation();
- mActivity.mCameraDevice.setDisplayOrientation(mCameraDisplayOrientation);
- setCameraParameters();
-
- try {
- if (!effectsActive()) {
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- SurfaceTexture surfaceTexture = ((CameraScreenNail) mActivity.mCameraScreenNail)
- .getSurfaceTexture();
- if (surfaceTexture == null) {
- return; // The texture has been destroyed (pause, etc)
- }
- mActivity.mCameraDevice.setPreviewTextureAsync(surfaceTexture);
- } else {
- mActivity.mCameraDevice.setPreviewDisplayAsync(mUI.getSurfaceHolder());
- }
- mActivity.mCameraDevice.startPreviewAsync();
- mPreviewing = true;
- onPreviewStarted();
- } else {
- initializeEffectsPreview();
- mEffectsRecorder.startPreview();
- mPreviewing = true;
- onPreviewStarted();
- }
- } catch (Throwable ex) {
- closeCamera();
- throw new RuntimeException("startPreview failed", ex);
- } finally {
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (mActivity.mOpenCameraFail) {
- Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
- } else if (mActivity.mCameraDisabled) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
- }
- }
- });
- }
-
- }
-
- private void onPreviewStarted() {
- mUI.enableShutter(true);
- }
-
- @Override
- public void stopPreview() {
- mActivity.mCameraDevice.stopPreview();
- mPreviewing = false;
- }
-
- // Closing the effects out. Will shut down the effects graph.
- private void closeEffects() {
- Log.v(TAG, "Closing effects");
- mEffectType = EffectsRecorder.EFFECT_NONE;
- if (mEffectsRecorder == null) {
- Log.d(TAG, "Effects are already closed. Nothing to do");
- return;
- }
- // This call can handle the case where the camera is already released
- // after the recording has been stopped.
- mEffectsRecorder.release();
- mEffectsRecorder = null;
- }
-
- // By default, we want to close the effects as well with the camera.
- private void closeCamera() {
- closeCamera(true);
- }
-
- // In certain cases, when the effects are active, we may want to shutdown
- // only the camera related parts, and handle closing the effects in the
- // effectsUpdate callback.
- // For example, in onPause, we want to make the camera available to
- // outside world immediately, however, want to wait till the effects
- // callback to shut down the effects. In such a case, we just disconnect
- // the effects from the camera by calling disconnectCamera. That way
- // the effects can handle that when shutting down.
- //
- // @param closeEffectsAlso - indicates whether we want to close the
- // effects also along with the camera.
- private void closeCamera(boolean closeEffectsAlso) {
- Log.v(TAG, "closeCamera");
- if (mActivity.mCameraDevice == null) {
- Log.d(TAG, "already stopped.");
- return;
- }
-
- if (mEffectsRecorder != null) {
- // Disconnect the camera from effects so that camera is ready to
- // be released to the outside world.
- mEffectsRecorder.disconnectCamera();
- }
- if (closeEffectsAlso) closeEffects();
- mActivity.mCameraDevice.setZoomChangeListener(null);
- mActivity.mCameraDevice.setErrorCallback(null);
- synchronized(mCameraOpened) {
- if (mCameraOpened) {
- CameraHolder.instance().release();
- }
- mCameraOpened = false;
- }
- mActivity.mCameraDevice = null;
- mPreviewing = false;
- mSnapshotInProgress = false;
- }
-
- private void releasePreviewResources() {
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- CameraScreenNail screenNail = (CameraScreenNail) mActivity.mCameraScreenNail;
- screenNail.releaseSurfaceTexture();
- if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
- mHandler.removeMessages(HIDE_SURFACE_VIEW);
- mUI.hideSurfaceView();
- }
- }
- }
-
- @Override
- public void onPauseBeforeSuper() {
- mPaused = true;
-
- if (mMediaRecorderRecording) {
- // Camera will be released in onStopVideoRecording.
- onStopVideoRecording();
- } else {
- closeCamera();
- if (!effectsActive()) releaseMediaRecorder();
- }
- if (effectsActive()) {
- // If the effects are active, make sure we tell the graph that the
- // surfacetexture is not valid anymore. Disconnect the graph from
- // the display. This should be done before releasing the surface
- // texture.
- mEffectsRecorder.disconnectDisplay();
- } else {
- // Close the file descriptor and clear the video namer only if the
- // effects are not active. If effects are active, we need to wait
- // till we get the callback from the Effects that the graph is done
- // recording. That also needs a change in the stopVideoRecording()
- // call to not call closeCamera if the effects are active, because
- // that will close down the effects are well, thus making this if
- // condition invalid.
- closeVideoFileDescriptor();
- }
-
- releasePreviewResources();
-
- if (mReceiver != null) {
- mActivity.unregisterReceiver(mReceiver);
- mReceiver = null;
- }
- resetScreenOn();
-
- if (mLocationManager != null) mLocationManager.recordLocation(false);
-
- mHandler.removeMessages(CHECK_DISPLAY_ROTATION);
- mHandler.removeMessages(SWITCH_CAMERA);
- mHandler.removeMessages(SWITCH_CAMERA_START_ANIMATION);
- mPendingSwitchCameraId = -1;
- mSwitchingCamera = false;
- // Call onPause after stopping video recording. So the camera can be
- // released as soon as possible.
- }
-
- @Override
- public void onPauseAfterSuper() {
- }
-
- @Override
- public void onUserInteraction() {
- if (!mMediaRecorderRecording && !mActivity.isFinishing()) {
- keepScreenOnAwhile();
- }
- }
-
- @Override
- public boolean onBackPressed() {
- if (mPaused) return true;
- if (mMediaRecorderRecording) {
- onStopVideoRecording();
- return true;
- } else if (mUI.hidePieRenderer()) {
- return true;
- } else {
- return mUI.removeTopLevelPopup();
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- // Do not handle any key if the activity is paused.
- if (mPaused) {
- return true;
- }
-
- switch (keyCode) {
- case KeyEvent.KEYCODE_CAMERA:
- if (event.getRepeatCount() == 0) {
- mUI.clickShutter();
- return true;
- }
- break;
- case KeyEvent.KEYCODE_DPAD_CENTER:
- if (event.getRepeatCount() == 0) {
- mUI.clickShutter();
- return true;
- }
- break;
- case KeyEvent.KEYCODE_MENU:
- if (mMediaRecorderRecording) return true;
- break;
- }
- return false;
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_CAMERA:
- mUI.pressShutter(false);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean isVideoCaptureIntent() {
- String action = mActivity.getIntent().getAction();
- return (MediaStore.ACTION_VIDEO_CAPTURE.equals(action));
- }
-
- private void doReturnToCaller(boolean valid) {
- Intent resultIntent = new Intent();
- int resultCode;
- if (valid) {
- resultCode = Activity.RESULT_OK;
- resultIntent.setData(mCurrentVideoUri);
- } else {
- resultCode = Activity.RESULT_CANCELED;
- }
- mActivity.setResultEx(resultCode, resultIntent);
- mActivity.finish();
- }
-
- private void cleanupEmptyFile() {
- if (mVideoFilename != null) {
- File f = new File(mVideoFilename);
- if (f.length() == 0 && f.delete()) {
- Log.v(TAG, "Empty video file deleted: " + mVideoFilename);
- mVideoFilename = null;
- }
- }
- }
-
- private void setupMediaRecorderPreviewDisplay() {
- // Nothing to do here if using SurfaceTexture.
- if (!ApiHelper.HAS_SURFACE_TEXTURE) {
- mMediaRecorder.setPreviewDisplay(mUI.getSurfaceHolder().getSurface());
- } else if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
- // We stop the preview here before unlocking the device because we
- // need to change the SurfaceTexture to SurfaceView for preview.
- stopPreview();
- mActivity.mCameraDevice.setPreviewDisplayAsync(mUI.getSurfaceHolder());
- // The orientation for SurfaceTexture is different from that for
- // SurfaceView. For SurfaceTexture we don't need to consider the
- // display rotation. Just consider the sensor's orientation and we
- // will set the orientation correctly when showing the texture.
- // Gallery will handle the orientation for the preview. For
- // SurfaceView we will have to take everything into account so the
- // display rotation is considered.
- mActivity.mCameraDevice.setDisplayOrientation(
- Util.getDisplayOrientation(mDisplayRotation, mCameraId));
- mActivity.mCameraDevice.startPreviewAsync();
- mPreviewing = true;
- mMediaRecorder.setPreviewDisplay(mUI.getSurfaceHolder().getSurface());
- }
- }
-
- // Prepares media recorder.
- private void initializeRecorder() {
- Log.v(TAG, "initializeRecorder");
- // If the mCameraDevice is null, then this activity is going to finish
- if (mActivity.mCameraDevice == null) return;
-
- if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING && ApiHelper.HAS_SURFACE_TEXTURE) {
- // Set the SurfaceView to visible so the surface gets created.
- // surfaceCreated() is called immediately when the visibility is
- // changed to visible. Thus, mSurfaceViewReady should become true
- // right after calling setVisibility().
- mUI.showSurfaceView();
- if (!mUI.isSurfaceViewReady()) return;
- }
-
- Intent intent = mActivity.getIntent();
- Bundle myExtras = intent.getExtras();
-
- long requestedSizeLimit = 0;
- closeVideoFileDescriptor();
- if (mIsVideoCaptureIntent && myExtras != null) {
- Uri saveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
- if (saveUri != null) {
- try {
- mVideoFileDescriptor =
- mContentResolver.openFileDescriptor(saveUri, "rw");
- mCurrentVideoUri = saveUri;
- } catch (java.io.FileNotFoundException ex) {
- // invalid uri
- Log.e(TAG, ex.toString());
- }
- }
- requestedSizeLimit = myExtras.getLong(MediaStore.EXTRA_SIZE_LIMIT);
- }
- mMediaRecorder = new MediaRecorder();
-
- setupMediaRecorderPreviewDisplay();
- // Unlock the camera object before passing it to media recorder.
- mActivity.mCameraDevice.unlock();
- mActivity.mCameraDevice.waitDone();
- mMediaRecorder.setCamera(mActivity.mCameraDevice.getCamera());
- if (!mCaptureTimeLapse) {
- mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
- }
- mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
- mMediaRecorder.setProfile(mProfile);
- mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);
- if (mCaptureTimeLapse) {
- double fps = 1000 / (double) mTimeBetweenTimeLapseFrameCaptureMs;
- setCaptureRate(mMediaRecorder, fps);
- }
-
- setRecordLocation();
-
- // Set output file.
- // Try Uri in the intent first. If it doesn't exist, use our own
- // instead.
- if (mVideoFileDescriptor != null) {
- mMediaRecorder.setOutputFile(mVideoFileDescriptor.getFileDescriptor());
- } else {
- generateVideoFilename(mProfile.fileFormat);
- mMediaRecorder.setOutputFile(mVideoFilename);
- }
-
- // Set maximum file size.
- long maxFileSize = mActivity.getStorageSpace() - Storage.LOW_STORAGE_THRESHOLD;
- if (requestedSizeLimit > 0 && requestedSizeLimit < maxFileSize) {
- maxFileSize = requestedSizeLimit;
- }
-
- try {
- mMediaRecorder.setMaxFileSize(maxFileSize);
- } catch (RuntimeException exception) {
- // We are going to ignore failure of setMaxFileSize here, as
- // a) The composer selected may simply not support it, or
- // b) The underlying media framework may not handle 64-bit range
- // on the size restriction.
- }
-
- // See android.hardware.Camera.Parameters.setRotation for
- // documentation.
- // Note that mOrientation here is the device orientation, which is the opposite of
- // what activity.getWindowManager().getDefaultDisplay().getRotation() would return,
- // which is the orientation the graphics need to rotate in order to render correctly.
- int rotation = 0;
- if (mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
- CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
- if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
- rotation = (info.orientation - mOrientation + 360) % 360;
- } else { // back-facing camera
- rotation = (info.orientation + mOrientation) % 360;
- }
- }
- mMediaRecorder.setOrientationHint(rotation);
-
- try {
- mMediaRecorder.prepare();
- } catch (IOException e) {
- Log.e(TAG, "prepare failed for " + mVideoFilename, e);
- releaseMediaRecorder();
- throw new RuntimeException(e);
- }
-
- mMediaRecorder.setOnErrorListener(this);
- mMediaRecorder.setOnInfoListener(this);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- private static void setCaptureRate(MediaRecorder recorder, double fps) {
- recorder.setCaptureRate(fps);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private void setRecordLocation() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- Location loc = mLocationManager.getCurrentLocation();
- if (loc != null) {
- mMediaRecorder.setLocation((float) loc.getLatitude(),
- (float) loc.getLongitude());
- }
- }
- }
-
- private void initializeEffectsPreview() {
- Log.v(TAG, "initializeEffectsPreview");
- // If the mCameraDevice is null, then this activity is going to finish
- if (mActivity.mCameraDevice == null) return;
-
- boolean inLandscape = (mActivity.getResources().getConfiguration().orientation
- == Configuration.ORIENTATION_LANDSCAPE);
-
- CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
-
- mEffectsDisplayResult = false;
- mEffectsRecorder = new EffectsRecorder(mActivity);
-
- // TODO: Confirm none of the following need to go to initializeEffectsRecording()
- // and none of these change even when the preview is not refreshed.
- mEffectsRecorder.setCameraDisplayOrientation(mCameraDisplayOrientation);
- mEffectsRecorder.setCamera(mActivity.mCameraDevice);
- mEffectsRecorder.setCameraFacing(info.facing);
- mEffectsRecorder.setProfile(mProfile);
- mEffectsRecorder.setEffectsListener(this);
- mEffectsRecorder.setOnInfoListener(this);
- mEffectsRecorder.setOnErrorListener(this);
-
- // The input of effects recorder is affected by
- // android.hardware.Camera.setDisplayOrientation. Its value only
- // compensates the camera orientation (no Display.getRotation). So the
- // orientation hint here should only consider sensor orientation.
- int orientation = 0;
- if (mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
- orientation = mOrientation;
- }
- mEffectsRecorder.setOrientationHint(orientation);
-
- CameraScreenNail screenNail = (CameraScreenNail) mActivity.mCameraScreenNail;
- mEffectsRecorder.setPreviewSurfaceTexture(screenNail.getSurfaceTexture(),
- screenNail.getWidth(), screenNail.getHeight());
-
- if (mEffectType == EffectsRecorder.EFFECT_BACKDROPPER &&
- ((String) mEffectParameter).equals(EFFECT_BG_FROM_GALLERY)) {
- mEffectsRecorder.setEffect(mEffectType, mEffectUriFromGallery);
- } else {
- mEffectsRecorder.setEffect(mEffectType, mEffectParameter);
- }
- }
-
- private void initializeEffectsRecording() {
- Log.v(TAG, "initializeEffectsRecording");
-
- Intent intent = mActivity.getIntent();
- Bundle myExtras = intent.getExtras();
-
- long requestedSizeLimit = 0;
- closeVideoFileDescriptor();
- if (mIsVideoCaptureIntent && myExtras != null) {
- Uri saveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
- if (saveUri != null) {
- try {
- mVideoFileDescriptor =
- mContentResolver.openFileDescriptor(saveUri, "rw");
- mCurrentVideoUri = saveUri;
- } catch (java.io.FileNotFoundException ex) {
- // invalid uri
- Log.e(TAG, ex.toString());
- }
- }
- requestedSizeLimit = myExtras.getLong(MediaStore.EXTRA_SIZE_LIMIT);
- }
-
- mEffectsRecorder.setProfile(mProfile);
- // important to set the capture rate to zero if not timelapsed, since the
- // effectsrecorder object does not get created again for each recording
- // session
- if (mCaptureTimeLapse) {
- mEffectsRecorder.setCaptureRate((1000 / (double) mTimeBetweenTimeLapseFrameCaptureMs));
- } else {
- mEffectsRecorder.setCaptureRate(0);
- }
-
- // Set output file
- if (mVideoFileDescriptor != null) {
- mEffectsRecorder.setOutputFile(mVideoFileDescriptor.getFileDescriptor());
- } else {
- generateVideoFilename(mProfile.fileFormat);
- mEffectsRecorder.setOutputFile(mVideoFilename);
- }
-
- // Set maximum file size.
- long maxFileSize = mActivity.getStorageSpace() - Storage.LOW_STORAGE_THRESHOLD;
- if (requestedSizeLimit > 0 && requestedSizeLimit < maxFileSize) {
- maxFileSize = requestedSizeLimit;
- }
- mEffectsRecorder.setMaxFileSize(maxFileSize);
- mEffectsRecorder.setMaxDuration(mMaxVideoDurationInMs);
- }
-
-
- private void releaseMediaRecorder() {
- Log.v(TAG, "Releasing media recorder.");
- if (mMediaRecorder != null) {
- cleanupEmptyFile();
- mMediaRecorder.reset();
- mMediaRecorder.release();
- mMediaRecorder = null;
- }
- mVideoFilename = null;
- }
-
- private void releaseEffectsRecorder() {
- Log.v(TAG, "Releasing effects recorder.");
- if (mEffectsRecorder != null) {
- cleanupEmptyFile();
- mEffectsRecorder.release();
- mEffectsRecorder = null;
- }
- mEffectType = EffectsRecorder.EFFECT_NONE;
- mVideoFilename = null;
- }
-
- private void generateVideoFilename(int outputFileFormat) {
- long dateTaken = System.currentTimeMillis();
- String title = createName(dateTaken);
- // Used when emailing.
- String filename = title + convertOutputFormatToFileExt(outputFileFormat);
- String mime = convertOutputFormatToMimeType(outputFileFormat);
- String path = Storage.DIRECTORY + '/' + filename;
- String tmpPath = path + ".tmp";
- mCurrentVideoValues = new ContentValues(9);
- mCurrentVideoValues.put(Video.Media.TITLE, title);
- mCurrentVideoValues.put(Video.Media.DISPLAY_NAME, filename);
- mCurrentVideoValues.put(Video.Media.DATE_TAKEN, dateTaken);
- mCurrentVideoValues.put(MediaColumns.DATE_MODIFIED, dateTaken / 1000);
- mCurrentVideoValues.put(Video.Media.MIME_TYPE, mime);
- mCurrentVideoValues.put(Video.Media.DATA, path);
- mCurrentVideoValues.put(Video.Media.RESOLUTION,
- Integer.toString(mProfile.videoFrameWidth) + "x" +
- Integer.toString(mProfile.videoFrameHeight));
- Location loc = mLocationManager.getCurrentLocation();
- if (loc != null) {
- mCurrentVideoValues.put(Video.Media.LATITUDE, loc.getLatitude());
- mCurrentVideoValues.put(Video.Media.LONGITUDE, loc.getLongitude());
- }
- mVideoFilename = tmpPath;
- Log.v(TAG, "New video filename: " + mVideoFilename);
- }
-
- private void saveVideo() {
- if (mVideoFileDescriptor == null) {
- long duration = SystemClock.uptimeMillis() - mRecordingStartTime;
- if (duration > 0) {
- if (mCaptureTimeLapse) {
- duration = getTimeLapseVideoLength(duration);
- }
- } else {
- Log.w(TAG, "Video duration <= 0 : " + duration);
- }
- mActivity.getMediaSaveService().addVideo(mCurrentVideoFilename,
- duration, mCurrentVideoValues,
- mOnVideoSavedListener, mContentResolver);
- }
- mCurrentVideoValues = null;
- }
-
- private void deleteVideoFile(String fileName) {
- Log.v(TAG, "Deleting video " + fileName);
- File f = new File(fileName);
- if (!f.delete()) {
- Log.v(TAG, "Could not delete " + fileName);
- }
- }
-
- private PreferenceGroup filterPreferenceScreenByIntent(
- PreferenceGroup screen) {
- Intent intent = mActivity.getIntent();
- if (intent.hasExtra(MediaStore.EXTRA_VIDEO_QUALITY)) {
- CameraSettings.removePreferenceFromScreen(screen,
- CameraSettings.KEY_VIDEO_QUALITY);
- }
-
- if (intent.hasExtra(MediaStore.EXTRA_DURATION_LIMIT)) {
- CameraSettings.removePreferenceFromScreen(screen,
- CameraSettings.KEY_VIDEO_QUALITY);
- }
- return screen;
- }
-
- // from MediaRecorder.OnErrorListener
- @Override
- public void onError(MediaRecorder mr, int what, int extra) {
- Log.e(TAG, "MediaRecorder error. what=" + what + ". extra=" + extra);
- if (what == MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN) {
- // We may have run out of space on the sdcard.
- stopVideoRecording();
- mActivity.updateStorageSpaceAndHint();
- }
- }
-
- // from MediaRecorder.OnInfoListener
- @Override
- public void onInfo(MediaRecorder mr, int what, int extra) {
- if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
- if (mMediaRecorderRecording) onStopVideoRecording();
- } else if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) {
- if (mMediaRecorderRecording) onStopVideoRecording();
-
- // Show the toast.
- Toast.makeText(mActivity, R.string.video_reach_size_limit,
- Toast.LENGTH_LONG).show();
- }
- }
-
- /*
- * Make sure we're not recording music playing in the background, ask the
- * MediaPlaybackService to pause playback.
- */
- private void pauseAudioPlayback() {
- // Shamelessly copied from MediaPlaybackService.java, which
- // should be public, but isn't.
- Intent i = new Intent("com.android.music.musicservicecommand");
- i.putExtra("command", "pause");
-
- mActivity.sendBroadcast(i);
- }
-
- // For testing.
- public boolean isRecording() {
- return mMediaRecorderRecording;
- }
-
- private void startVideoRecording() {
- Log.v(TAG, "startVideoRecording");
- mUI.enablePreviewThumb(false);
- mActivity.setSwipingEnabled(false);
-
- mActivity.updateStorageSpaceAndHint();
- if (mActivity.getStorageSpace() <= Storage.LOW_STORAGE_THRESHOLD) {
- Log.v(TAG, "Storage issue, ignore the start request");
- return;
- }
-
- if (!mActivity.mCameraDevice.waitDone()) return;
- mCurrentVideoUri = null;
- if (effectsActive()) {
- initializeEffectsRecording();
- if (mEffectsRecorder == null) {
- Log.e(TAG, "Fail to initialize effect recorder");
- return;
- }
- } else {
- initializeRecorder();
- if (mMediaRecorder == null) {
- Log.e(TAG, "Fail to initialize media recorder");
- return;
- }
- }
-
- pauseAudioPlayback();
-
- if (effectsActive()) {
- try {
- mEffectsRecorder.startRecording();
- } catch (RuntimeException e) {
- Log.e(TAG, "Could not start effects recorder. ", e);
- releaseEffectsRecorder();
- return;
- }
- } else {
- try {
- mMediaRecorder.start(); // Recording is now started
- } catch (RuntimeException e) {
- Log.e(TAG, "Could not start media recorder. ", e);
- releaseMediaRecorder();
- // If start fails, frameworks will not lock the camera for us.
- mActivity.mCameraDevice.lock();
- return;
- }
- }
-
- // Make sure the video recording has started before announcing
- // this in accessibility.
- AccessibilityUtils.makeAnnouncement(mActivity.getShutterButton(),
- mActivity.getString(R.string.video_recording_started));
-
- // The parameters might have been altered by MediaRecorder already.
- // We need to force mCameraDevice to refresh before getting it.
- mActivity.mCameraDevice.refreshParameters();
- // The parameters may have been changed by MediaRecorder upon starting
- // recording. We need to alter the parameters if we support camcorder
- // zoom. To reduce latency when setting the parameters during zoom, we
- // update mParameters here once.
- if (ApiHelper.HAS_ZOOM_WHEN_RECORDING) {
- mParameters = mActivity.mCameraDevice.getParameters();
- }
-
- mUI.enableCameraControls(false);
-
- mMediaRecorderRecording = true;
- if (!Util.systemRotationLocked(mActivity)) {
- mActivity.getOrientationManager().lockOrientation();
- }
- mRecordingStartTime = SystemClock.uptimeMillis();
- mUI.showRecordingUI(true, mParameters.isZoomSupported());
-
- updateRecordingTime();
- keepScreenOn();
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
- UsageStatistics.ACTION_CAPTURE_START, "Video");
- }
-
- private void showCaptureResult() {
- mIsInReviewMode = true;
- Bitmap bitmap = null;
- if (mVideoFileDescriptor != null) {
- bitmap = Thumbnail.createVideoThumbnailBitmap(mVideoFileDescriptor.getFileDescriptor(),
- mDesiredPreviewWidth);
- } else if (mCurrentVideoFilename != null) {
- bitmap = Thumbnail.createVideoThumbnailBitmap(mCurrentVideoFilename,
- mDesiredPreviewWidth);
- }
- if (bitmap != null) {
- // MetadataRetriever already rotates the thumbnail. We should rotate
- // it to match the UI orientation (and mirror if it is front-facing camera).
- CameraInfo[] info = CameraHolder.instance().getCameraInfo();
- boolean mirror = (info[mCameraId].facing == CameraInfo.CAMERA_FACING_FRONT);
- bitmap = Util.rotateAndMirror(bitmap, 0, mirror);
- mUI.showReviewImage(bitmap);
- }
-
- mUI.showReviewControls();
- mUI.enableCameraControls(false);
- mUI.showTimeLapseUI(false);
- }
-
- private void hideAlert() {
- mUI.enableCameraControls(true);
- mUI.hideReviewUI();
- if (mCaptureTimeLapse) {
- mUI.showTimeLapseUI(true);
- }
- }
-
- private boolean stopVideoRecording() {
- Log.v(TAG, "stopVideoRecording");
- mActivity.setSwipingEnabled(true);
- mActivity.showSwitcher();
-
- boolean fail = false;
- if (mMediaRecorderRecording) {
- boolean shouldAddToMediaStoreNow = false;
-
- try {
- if (effectsActive()) {
- // This is asynchronous, so we can't add to media store now because thumbnail
- // may not be ready. In such case saveVideo() is called later
- // through a callback from the MediaEncoderFilter to EffectsRecorder,
- // and then to the VideoModule.
- mEffectsRecorder.stopRecording();
- } else {
- mMediaRecorder.setOnErrorListener(null);
- mMediaRecorder.setOnInfoListener(null);
- mMediaRecorder.stop();
- shouldAddToMediaStoreNow = true;
- }
- mCurrentVideoFilename = mVideoFilename;
- Log.v(TAG, "stopVideoRecording: Setting current video filename: "
- + mCurrentVideoFilename);
- AccessibilityUtils.makeAnnouncement(mActivity.getShutterButton(),
- mActivity.getString(R.string.video_recording_stopped));
- } catch (RuntimeException e) {
- Log.e(TAG, "stop fail", e);
- if (mVideoFilename != null) deleteVideoFile(mVideoFilename);
- fail = true;
- }
- mMediaRecorderRecording = false;
- if (!Util.systemRotationLocked(mActivity)) {
- mActivity.getOrientationManager().unlockOrientation();
- }
-
- // If the activity is paused, this means activity is interrupted
- // during recording. Release the camera as soon as possible because
- // face unlock or other applications may need to use the camera.
- // However, if the effects are active, then we can only release the
- // camera and cannot release the effects recorder since that will
- // stop the graph. It is possible to separate out the Camera release
- // part and the effects release part. However, the effects recorder
- // does hold on to the camera, hence, it needs to be "disconnected"
- // from the camera in the closeCamera call.
- if (mPaused) {
- // Closing only the camera part if effects active. Effects will
- // be closed in the callback from effects.
- boolean closeEffects = !effectsActive();
- closeCamera(closeEffects);
- }
-
- mUI.showRecordingUI(false, mParameters.isZoomSupported());
- if (!mIsVideoCaptureIntent) {
- mUI.enableCameraControls(true);
- }
- // The orientation was fixed during video recording. Now make it
- // reflect the device orientation as video recording is stopped.
- mUI.setOrientationIndicator(0, true);
- keepScreenOnAwhile();
- if (shouldAddToMediaStoreNow) {
- saveVideo();
- }
- }
- // always release media recorder if no effects running
- if (!effectsActive()) {
- releaseMediaRecorder();
- if (!mPaused) {
- mActivity.mCameraDevice.lock();
- mActivity.mCameraDevice.waitDone();
- if (ApiHelper.HAS_SURFACE_TEXTURE &&
- !ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
- stopPreview();
- // Switch back to use SurfaceTexture for preview.
- ((CameraScreenNail) mActivity.mCameraScreenNail).setOneTimeOnFrameDrawnListener(
- mFrameDrawnListener);
- startPreview();
- }
- }
- }
- // Update the parameters here because the parameters might have been altered
- // by MediaRecorder.
- if (!mPaused) mParameters = mActivity.mCameraDevice.getParameters();
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
- fail ? UsageStatistics.ACTION_CAPTURE_FAIL :
- UsageStatistics.ACTION_CAPTURE_DONE, "Video",
- SystemClock.uptimeMillis() - mRecordingStartTime);
- return fail;
- }
-
- private void resetScreenOn() {
- mHandler.removeMessages(CLEAR_SCREEN_DELAY);
- mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
-
- private void keepScreenOnAwhile() {
- mHandler.removeMessages(CLEAR_SCREEN_DELAY);
- mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- mHandler.sendEmptyMessageDelayed(CLEAR_SCREEN_DELAY, SCREEN_DELAY);
- }
-
- private void keepScreenOn() {
- mHandler.removeMessages(CLEAR_SCREEN_DELAY);
- mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
-
- private static String millisecondToTimeString(long milliSeconds, boolean displayCentiSeconds) {
- long seconds = milliSeconds / 1000; // round down to compute seconds
- long minutes = seconds / 60;
- long hours = minutes / 60;
- long remainderMinutes = minutes - (hours * 60);
- long remainderSeconds = seconds - (minutes * 60);
-
- StringBuilder timeStringBuilder = new StringBuilder();
-
- // Hours
- if (hours > 0) {
- if (hours < 10) {
- timeStringBuilder.append('0');
- }
- timeStringBuilder.append(hours);
-
- timeStringBuilder.append(':');
- }
-
- // Minutes
- if (remainderMinutes < 10) {
- timeStringBuilder.append('0');
- }
- timeStringBuilder.append(remainderMinutes);
- timeStringBuilder.append(':');
-
- // Seconds
- if (remainderSeconds < 10) {
- timeStringBuilder.append('0');
- }
- timeStringBuilder.append(remainderSeconds);
-
- // Centi seconds
- if (displayCentiSeconds) {
- timeStringBuilder.append('.');
- long remainderCentiSeconds = (milliSeconds - seconds * 1000) / 10;
- if (remainderCentiSeconds < 10) {
- timeStringBuilder.append('0');
- }
- timeStringBuilder.append(remainderCentiSeconds);
- }
-
- return timeStringBuilder.toString();
- }
-
- private long getTimeLapseVideoLength(long deltaMs) {
- // For better approximation calculate fractional number of frames captured.
- // This will update the video time at a higher resolution.
- double numberOfFrames = (double) deltaMs / mTimeBetweenTimeLapseFrameCaptureMs;
- return (long) (numberOfFrames / mProfile.videoFrameRate * 1000);
- }
-
- private void updateRecordingTime() {
- if (!mMediaRecorderRecording) {
- return;
- }
- long now = SystemClock.uptimeMillis();
- long delta = now - mRecordingStartTime;
-
- // Starting a minute before reaching the max duration
- // limit, we'll countdown the remaining time instead.
- boolean countdownRemainingTime = (mMaxVideoDurationInMs != 0
- && delta >= mMaxVideoDurationInMs - 60000);
-
- long deltaAdjusted = delta;
- if (countdownRemainingTime) {
- deltaAdjusted = Math.max(0, mMaxVideoDurationInMs - deltaAdjusted) + 999;
- }
- String text;
-
- long targetNextUpdateDelay;
- if (!mCaptureTimeLapse) {
- text = millisecondToTimeString(deltaAdjusted, false);
- targetNextUpdateDelay = 1000;
- } else {
- // The length of time lapse video is different from the length
- // of the actual wall clock time elapsed. Display the video length
- // only in format hh:mm:ss.dd, where dd are the centi seconds.
- text = millisecondToTimeString(getTimeLapseVideoLength(delta), true);
- targetNextUpdateDelay = mTimeBetweenTimeLapseFrameCaptureMs;
- }
-
- mUI.setRecordingTime(text);
-
- if (mRecordingTimeCountsDown != countdownRemainingTime) {
- // Avoid setting the color on every update, do it only
- // when it needs changing.
- mRecordingTimeCountsDown = countdownRemainingTime;
-
- int color = mActivity.getResources().getColor(countdownRemainingTime
- ? R.color.recording_time_remaining_text
- : R.color.recording_time_elapsed_text);
-
- mUI.setRecordingTimeTextColor(color);
- }
-
- long actualNextUpdateDelay = targetNextUpdateDelay - (delta % targetNextUpdateDelay);
- mHandler.sendEmptyMessageDelayed(
- UPDATE_RECORD_TIME, actualNextUpdateDelay);
- }
-
- private static boolean isSupported(String value, List<String> supported) {
- return supported == null ? false : supported.indexOf(value) >= 0;
- }
-
- @SuppressWarnings("deprecation")
- private void setCameraParameters() {
- mParameters.setPreviewSize(mDesiredPreviewWidth, mDesiredPreviewHeight);
- mParameters.setPreviewFrameRate(mProfile.videoFrameRate);
-
- // Set flash mode.
- String flashMode;
- if (mActivity.mShowCameraAppView) {
- flashMode = mPreferences.getString(
- CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
- mActivity.getString(R.string.pref_camera_video_flashmode_default));
- } else {
- flashMode = Parameters.FLASH_MODE_OFF;
- }
- List<String> supportedFlash = mParameters.getSupportedFlashModes();
- if (isSupported(flashMode, supportedFlash)) {
- mParameters.setFlashMode(flashMode);
- } else {
- flashMode = mParameters.getFlashMode();
- if (flashMode == null) {
- flashMode = mActivity.getString(
- R.string.pref_camera_flashmode_no_flash);
- }
- }
-
- // Set white balance parameter.
- String whiteBalance = mPreferences.getString(
- CameraSettings.KEY_WHITE_BALANCE,
- mActivity.getString(R.string.pref_camera_whitebalance_default));
- if (isSupported(whiteBalance,
- mParameters.getSupportedWhiteBalance())) {
- mParameters.setWhiteBalance(whiteBalance);
- } else {
- whiteBalance = mParameters.getWhiteBalance();
- if (whiteBalance == null) {
- whiteBalance = Parameters.WHITE_BALANCE_AUTO;
- }
- }
-
- // Set zoom.
- if (mParameters.isZoomSupported()) {
- mParameters.setZoom(mZoomValue);
- }
-
- // Set continuous autofocus.
- List<String> supportedFocus = mParameters.getSupportedFocusModes();
- if (isSupported(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO, supportedFocus)) {
- mParameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
- }
-
- mParameters.set(Util.RECORDING_HINT, Util.TRUE);
-
- // Enable video stabilization. Convenience methods not available in API
- // level <= 14
- String vstabSupported = mParameters.get("video-stabilization-supported");
- if ("true".equals(vstabSupported)) {
- mParameters.set("video-stabilization", "true");
- }
-
- // Set picture size.
- // The logic here is different from the logic in still-mode camera.
- // There we determine the preview size based on the picture size, but
- // here we determine the picture size based on the preview size.
- List<Size> supported = mParameters.getSupportedPictureSizes();
- Size optimalSize = Util.getOptimalVideoSnapshotPictureSize(supported,
- (double) mDesiredPreviewWidth / mDesiredPreviewHeight);
- Size original = mParameters.getPictureSize();
- if (!original.equals(optimalSize)) {
- mParameters.setPictureSize(optimalSize.width, optimalSize.height);
- }
- Log.v(TAG, "Video snapshot size is " + optimalSize.width + "x" +
- optimalSize.height);
-
- // Set JPEG quality.
- int jpegQuality = CameraProfile.getJpegEncodingQualityParameter(mCameraId,
- CameraProfile.QUALITY_HIGH);
- mParameters.setJpegQuality(jpegQuality);
-
- mActivity.mCameraDevice.setParameters(mParameters);
- // Keep preview size up to date.
- mParameters = mActivity.mCameraDevice.getParameters();
-
- updateCameraScreenNailSize(mDesiredPreviewWidth, mDesiredPreviewHeight);
- }
-
- private void updateCameraScreenNailSize(int width, int height) {
- if (!ApiHelper.HAS_SURFACE_TEXTURE) return;
-
- if (mCameraDisplayOrientation % 180 != 0) {
- int tmp = width;
- width = height;
- height = tmp;
- }
-
- CameraScreenNail screenNail = (CameraScreenNail) mActivity.mCameraScreenNail;
- int oldWidth = screenNail.getWidth();
- int oldHeight = screenNail.getHeight();
-
- if (oldWidth != width || oldHeight != height) {
- screenNail.setSize(width, height);
- screenNail.enableAspectRatioClamping();
- mActivity.notifyScreenNailChanged();
- }
-
- if (screenNail.getSurfaceTexture() == null) {
- screenNail.acquireSurfaceTexture();
- }
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case REQUEST_EFFECT_BACKDROPPER:
- if (resultCode == Activity.RESULT_OK) {
- // onActivityResult() runs before onResume(), so this parameter will be
- // seen by startPreview from onResume()
- mEffectUriFromGallery = data.getData().toString();
- Log.v(TAG, "Received URI from gallery: " + mEffectUriFromGallery);
- mResetEffect = false;
- } else {
- mEffectUriFromGallery = null;
- Log.w(TAG, "No URI from gallery");
- mResetEffect = true;
- }
- break;
- }
- }
-
- @Override
- public void onEffectsUpdate(int effectId, int effectMsg) {
- Log.v(TAG, "onEffectsUpdate. Effect Message = " + effectMsg);
- if (effectMsg == EffectsRecorder.EFFECT_MSG_EFFECTS_STOPPED) {
- // Effects have shut down. Hide learning message if any,
- // and restart regular preview.
- checkQualityAndStartPreview();
- } else if (effectMsg == EffectsRecorder.EFFECT_MSG_RECORDING_DONE) {
- // This follows the codepath from onStopVideoRecording.
- if (mEffectsDisplayResult) {
- saveVideo();
- if (mIsVideoCaptureIntent) {
- if (mQuickCapture) {
- doReturnToCaller(true);
- } else {
- showCaptureResult();
- }
- }
- }
- mEffectsDisplayResult = false;
- // In onPause, these were not called if the effects were active. We
- // had to wait till the effects recording is complete to do this.
- if (mPaused) {
- closeVideoFileDescriptor();
- }
- } else if (effectMsg == EffectsRecorder.EFFECT_MSG_PREVIEW_RUNNING) {
- // Enable the shutter button once the preview is complete.
- mUI.enableShutter(true);
- }
- // In onPause, this was not called if the effects were active. We had to
- // wait till the effects completed to do this.
- if (mPaused) {
- Log.v(TAG, "OnEffectsUpdate: closing effects if activity paused");
- closeEffects();
- }
- }
-
- public void onCancelBgTraining(View v) {
- // Write default effect out to shared prefs
- writeDefaultEffectToPrefs();
- // Tell VideoCamer to re-init based on new shared pref values.
- onSharedPreferenceChanged();
- }
-
- @Override
- public synchronized void onEffectsError(Exception exception, String fileName) {
- // TODO: Eventually we may want to show the user an error dialog, and then restart the
- // camera and encoder gracefully. For now, we just delete the file and bail out.
- if (fileName != null && new File(fileName).exists()) {
- deleteVideoFile(fileName);
- }
- try {
- if (Class.forName("android.filterpacks.videosink.MediaRecorderStopException")
- .isInstance(exception)) {
- Log.w(TAG, "Problem recoding video file. Removing incomplete file.");
- return;
- }
- } catch (ClassNotFoundException ex) {
- Log.w(TAG, ex);
- }
- throw new RuntimeException("Error during recording!", exception);
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- Log.v(TAG, "onConfigurationChanged");
- setDisplayOrientation();
- }
-
- @Override
- public void onOverriddenPreferencesClicked() {
- }
-
- @Override
- // TODO: Delete this after old camera code is removed
- public void onRestorePreferencesClicked() {
- }
-
- private boolean effectsActive() {
- return (mEffectType != EffectsRecorder.EFFECT_NONE);
- }
-
- @Override
- public void onSharedPreferenceChanged() {
- // ignore the events after "onPause()" or preview has not started yet
- if (mPaused) return;
- synchronized (mPreferences) {
- // If mCameraDevice is not ready then we can set the parameter in
- // startPreview().
- if (mActivity.mCameraDevice == null) return;
-
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
- mLocationManager.recordLocation(recordLocation);
-
- // Check if the current effects selection has changed
- if (updateEffectSelection()) return;
-
- readVideoPreferences();
- mUI.showTimeLapseUI(mCaptureTimeLapse);
- // We need to restart the preview if preview size is changed.
- Size size = mParameters.getPreviewSize();
- if (size.width != mDesiredPreviewWidth
- || size.height != mDesiredPreviewHeight) {
- if (!effectsActive()) {
- stopPreview();
- } else {
- mEffectsRecorder.release();
- mEffectsRecorder = null;
- }
- resizeForPreviewAspectRatio();
- startPreview(); // Parameters will be set in startPreview().
- } else {
- setCameraParameters();
- }
- mUI.updateOnScreenIndicators(mParameters, mPreferences);
- }
- }
-
- protected void setCameraId(int cameraId) {
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CAMERA_ID);
- pref.setValue("" + cameraId);
- }
-
- private void switchCamera() {
- if (mPaused) return;
-
- Log.d(TAG, "Start to switch camera.");
- mCameraId = mPendingSwitchCameraId;
- mPendingSwitchCameraId = -1;
- setCameraId(mCameraId);
-
- closeCamera();
- mUI.collapseCameraControls();
- // Restart the camera and initialize the UI. From onCreate.
- mPreferences.setLocalId(mActivity, mCameraId);
- CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
- openCamera();
- readVideoPreferences();
- startPreview();
- initializeVideoSnapshot();
- resizeForPreviewAspectRatio();
- initializeVideoControl();
-
- // From onResume
- mUI.initializeZoom(mParameters);
- mUI.setOrientationIndicator(0, false);
-
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- // Start switch camera animation. Post a message because
- // onFrameAvailable from the old camera may already exist.
- mHandler.sendEmptyMessage(SWITCH_CAMERA_START_ANIMATION);
- }
- mUI.updateOnScreenIndicators(mParameters, mPreferences);
- }
-
- // Preview texture has been copied. Now camera can be released and the
- // animation can be started.
- @Override
- public void onPreviewTextureCopied() {
- mHandler.sendEmptyMessage(SWITCH_CAMERA);
- }
-
- @Override
- public void onCaptureTextureCopied() {
- }
-
- private boolean updateEffectSelection() {
- int previousEffectType = mEffectType;
- Object previousEffectParameter = mEffectParameter;
- mEffectType = CameraSettings.readEffectType(mPreferences);
- mEffectParameter = CameraSettings.readEffectParameter(mPreferences);
-
- if (mEffectType == previousEffectType) {
- if (mEffectType == EffectsRecorder.EFFECT_NONE) return false;
- if (mEffectParameter.equals(previousEffectParameter)) return false;
- }
- Log.v(TAG, "New effect selection: " + mPreferences.getString(
- CameraSettings.KEY_VIDEO_EFFECT, "none"));
-
- if (mEffectType == EffectsRecorder.EFFECT_NONE) {
- // Stop effects and return to normal preview
- mEffectsRecorder.stopPreview();
- mPreviewing = false;
- return true;
- }
- if (mEffectType == EffectsRecorder.EFFECT_BACKDROPPER &&
- ((String) mEffectParameter).equals(EFFECT_BG_FROM_GALLERY)) {
- // Request video from gallery to use for background
- Intent i = new Intent(Intent.ACTION_PICK);
- i.setDataAndType(Video.Media.EXTERNAL_CONTENT_URI,
- "video/*");
- i.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
- mActivity.startActivityForResult(i, REQUEST_EFFECT_BACKDROPPER);
- return true;
- }
- if (previousEffectType == EffectsRecorder.EFFECT_NONE) {
- // Stop regular preview and start effects.
- stopPreview();
- checkQualityAndStartPreview();
- } else {
- // Switch currently running effect
- mEffectsRecorder.setEffect(mEffectType, mEffectParameter);
- }
- return true;
- }
-
- // Verifies that the current preview view size is correct before starting
- // preview. If not, resets the surface texture and resizes the view.
- private void checkQualityAndStartPreview() {
- readVideoPreferences();
- mUI.showTimeLapseUI(mCaptureTimeLapse);
- Size size = mParameters.getPreviewSize();
- if (size.width != mDesiredPreviewWidth
- || size.height != mDesiredPreviewHeight) {
- resizeForPreviewAspectRatio();
- }
- // Start up preview again
- startPreview();
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent m) {
- if (mSwitchingCamera) return true;
- return mUI.dispatchTouchEvent(m);
- }
-
- private void initializeVideoSnapshot() {
- if (mParameters == null) return;
- if (Util.isVideoSnapshotSupported(mParameters) && !mIsVideoCaptureIntent) {
- mActivity.setSingleTapUpListener(mUI.getPreview());
- // Show the tap to focus toast if this is the first start.
- if (mPreferences.getBoolean(
- CameraSettings.KEY_VIDEO_FIRST_USE_HINT_SHOWN, true)) {
- // Delay the toast for one second to wait for orientation.
- mHandler.sendEmptyMessageDelayed(SHOW_TAP_TO_SNAPSHOT_TOAST, 1000);
- }
- } else {
- mActivity.setSingleTapUpListener(null);
- }
- }
-
- void showVideoSnapshotUI(boolean enabled) {
- if (mParameters == null) return;
- if (Util.isVideoSnapshotSupported(mParameters) && !mIsVideoCaptureIntent) {
- if (ApiHelper.HAS_SURFACE_TEXTURE && enabled) {
- ((CameraScreenNail) mActivity.mCameraScreenNail).animateCapture(mDisplayRotation);
- } else {
- mUI.showPreviewBorder(enabled);
- }
- mUI.enableShutter(!enabled);
- }
- }
-
- @Override
- public void updateCameraAppView() {
- if (!mPreviewing || mParameters.getFlashMode() == null) return;
-
- // When going to and back from gallery, we need to turn off/on the flash.
- if (!mActivity.mShowCameraAppView) {
- if (mParameters.getFlashMode().equals(Parameters.FLASH_MODE_OFF)) {
- mRestoreFlash = false;
- return;
- }
- mRestoreFlash = true;
- setCameraParameters();
- } else if (mRestoreFlash) {
- mRestoreFlash = false;
- setCameraParameters();
- }
- }
-
- @Override
- public void onFullScreenChanged(boolean full) {
- mUI.onFullScreenChanged(full);
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- if (mActivity.mCameraScreenNail != null) {
- ((CameraScreenNail) mActivity.mCameraScreenNail).setFullScreen(full);
- }
- return;
- }
- }
-
- private final class JpegPictureCallback implements PictureCallback {
- Location mLocation;
-
- public JpegPictureCallback(Location loc) {
- mLocation = loc;
- }
-
- @Override
- public void onPictureTaken(byte [] jpegData, android.hardware.Camera camera) {
- Log.v(TAG, "onPictureTaken");
- mSnapshotInProgress = false;
- showVideoSnapshotUI(false);
- storeImage(jpegData, mLocation);
- }
- }
-
- private void storeImage(final byte[] data, Location loc) {
- long dateTaken = System.currentTimeMillis();
- String title = Util.createJpegName(dateTaken);
- ExifInterface exif = Exif.getExif(data);
- int orientation = Exif.getOrientation(exif);
- Size s = mParameters.getPictureSize();
- mActivity.getMediaSaveService().addImage(
- data, title, dateTaken, loc, s.width, s.height, orientation,
- exif, mOnPhotoSavedListener, mContentResolver);
- }
-
- private boolean resetEffect() {
- if (mResetEffect) {
- String value = mPreferences.getString(CameraSettings.KEY_VIDEO_EFFECT,
- mPrefVideoEffectDefault);
- if (!mPrefVideoEffectDefault.equals(value)) {
- writeDefaultEffectToPrefs();
- return true;
- }
- }
- mResetEffect = true;
- return false;
- }
-
- private String convertOutputFormatToMimeType(int outputFileFormat) {
- if (outputFileFormat == MediaRecorder.OutputFormat.MPEG_4) {
- return "video/mp4";
- }
- return "video/3gpp";
- }
-
- private String convertOutputFormatToFileExt(int outputFileFormat) {
- if (outputFileFormat == MediaRecorder.OutputFormat.MPEG_4) {
- return ".mp4";
- }
- return ".3gp";
- }
-
- private void closeVideoFileDescriptor() {
- if (mVideoFileDescriptor != null) {
- try {
- mVideoFileDescriptor.close();
- } catch (IOException e) {
- Log.e(TAG, "Fail to close fd", e);
- }
- mVideoFileDescriptor = null;
- }
- }
-
- private void showTapToSnapshotToast() {
- new RotateTextToast(mActivity, R.string.video_snapshot_hint, 0)
- .show();
- // Clear the preference.
- Editor editor = mPreferences.edit();
- editor.putBoolean(CameraSettings.KEY_VIDEO_FIRST_USE_HINT_SHOWN, false);
- editor.apply();
- }
-
- @Override
- public boolean updateStorageHintOnResume() {
- return true;
- }
-
- // required by OnPreferenceChangedListener
- @Override
- public void onCameraPickerClicked(int cameraId) {
- if (mPaused || mPendingSwitchCameraId != -1) return;
-
- mPendingSwitchCameraId = cameraId;
- if (ApiHelper.HAS_SURFACE_TEXTURE) {
- Log.d(TAG, "Start to copy texture.");
- // We need to keep a preview frame for the animation before
- // releasing the camera. This will trigger onPreviewTextureCopied.
- ((CameraScreenNail) mActivity.mCameraScreenNail).copyTexture();
- // Disable all camera controls.
- mSwitchingCamera = true;
- } else {
- switchCamera();
- }
- }
-
- @Override
- public boolean needsSwitcher() {
- return !mIsVideoCaptureIntent;
- }
-
- @Override
- public boolean needsPieMenu() {
- return true;
- }
-
- @Override
- public void onShowSwitcherPopup() {
- mUI.onShowSwitcherPopup();
- }
-
- @Override
- public void onMediaSaveServiceConnected(MediaSaveService s) {
- // do nothing.
- }
-}
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
deleted file mode 100644
index 9fc0576..0000000
--- a/src/com/android/camera/VideoUI.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * 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.camera;
-
-import android.graphics.Bitmap;
-import android.hardware.Camera.Parameters;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.FrameLayout.LayoutParams;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.android.camera.CameraPreference.OnPreferenceChangedListener;
-import com.android.camera.ui.AbstractSettingPopup;
-import com.android.camera.ui.PieRenderer;
-import com.android.camera.ui.PreviewSurfaceView;
-import com.android.camera.ui.RenderOverlay;
-import com.android.camera.ui.RotateLayout;
-import com.android.camera.ui.ZoomRenderer;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-import java.util.List;
-
-public class VideoUI implements SurfaceHolder.Callback, PieRenderer.PieListener,
- PreviewGestures.SingleTapListener,
- PreviewGestures.SwipeListener {
- private final static String TAG = "CAM_VideoUI";
- // module fields
- private CameraActivity mActivity;
- private View mRootView;
- private PreviewFrameLayout mPreviewFrameLayout;
- private boolean mSurfaceViewReady;
- private PreviewSurfaceView mPreviewSurfaceView;
- // An review image having same size as preview. It is displayed when
- // recording is stopped in capture intent.
- private ImageView mReviewImage;
- private View mReviewCancelButton;
- private View mReviewDoneButton;
- private View mReviewPlayButton;
- private ShutterButton mShutterButton;
- private TextView mRecordingTimeView;
- private LinearLayout mLabelsLinearLayout;
- private View mTimeLapseLabel;
- private RenderOverlay mRenderOverlay;
- private PieRenderer mPieRenderer;
- private VideoMenu mVideoMenu;
- private AbstractSettingPopup mPopup;
- private ZoomRenderer mZoomRenderer;
- private PreviewGestures mGestures;
- private View mMenu;
- private View mBlocker;
- private OnScreenIndicators mOnScreenIndicators;
- private RotateLayout mRecordingTimeRect;
- private VideoController mController;
- private int mZoomMax;
- private List<Integer> mZoomRatios;
- private View mPreviewThumb;
-
- public VideoUI(CameraActivity activity, VideoController controller, View parent) {
- mActivity = activity;
- mController = controller;
- mRootView = parent;
- mActivity.getLayoutInflater().inflate(R.layout.video_module, (ViewGroup) mRootView, true);
- mPreviewSurfaceView = (PreviewSurfaceView) mRootView
- .findViewById(R.id.preview_surface_view);
- initializeMiscControls();
- initializeControlByIntent();
- initializeOverlay();
- }
-
- private void initializeControlByIntent() {
- mBlocker = mActivity.findViewById(R.id.blocker);
- mMenu = mActivity.findViewById(R.id.menu);
- mMenu.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mPieRenderer != null) {
- mPieRenderer.showInCenter();
- }
- }
- });
- mOnScreenIndicators = new OnScreenIndicators(mActivity,
- mActivity.findViewById(R.id.on_screen_indicators));
- mOnScreenIndicators.resetToDefault();
- if (mController.isVideoCaptureIntent()) {
- mActivity.hideSwitcher();
- ViewGroup cameraControls = (ViewGroup) mActivity.findViewById(R.id.camera_controls);
- mActivity.getLayoutInflater().inflate(R.layout.review_module_control, cameraControls);
- // Cannot use RotateImageView for "done" and "cancel" button because
- // the tablet layout uses RotateLayout, which cannot be cast to
- // RotateImageView.
- mReviewDoneButton = mActivity.findViewById(R.id.btn_done);
- mReviewCancelButton = mActivity.findViewById(R.id.btn_cancel);
- mReviewPlayButton = mActivity.findViewById(R.id.btn_play);
- mReviewCancelButton.setVisibility(View.VISIBLE);
- mReviewDoneButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mController.onReviewDoneClicked(v);
- }
- });
- mReviewCancelButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mController.onReviewCancelClicked(v);
- }
- });
- mReviewPlayButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mController.onReviewPlayClicked(v);
- }
- });
- }
- }
-
- public boolean collapseCameraControls() {
- boolean ret = false;
- if (mPopup != null) {
- dismissPopup(false);
- ret = true;
- }
- return ret;
- }
-
- public boolean removeTopLevelPopup() {
- if (mPopup != null) {
- dismissPopup(true);
- return true;
- }
- return false;
- }
-
- public void enableCameraControls(boolean enable) {
- if (mGestures != null) {
- mGestures.setZoomOnly(!enable);
- }
- if (mPieRenderer != null && mPieRenderer.showsItems()) {
- mPieRenderer.hide();
- }
- }
-
- public void overrideSettings(final String... keyvalues) {
- mVideoMenu.overrideSettings(keyvalues);
- }
-
- public View getPreview() {
- return mPreviewFrameLayout;
- }
-
- public void setOrientationIndicator(int orientation, boolean animation) {
- if (mGestures != null) {
- mGestures.setOrientation(orientation);
- }
- // We change the orientation of the linearlayout only for phone UI
- // because when in portrait the width is not enough.
- if (mLabelsLinearLayout != null) {
- if (((orientation / 90) & 1) == 0) {
- mLabelsLinearLayout.setOrientation(LinearLayout.VERTICAL);
- } else {
- mLabelsLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
- }
- }
- mRecordingTimeRect.setOrientation(0, animation);
- }
-
- public SurfaceHolder getSurfaceHolder() {
- return mPreviewSurfaceView.getHolder();
- }
-
- public void hideSurfaceView() {
- mPreviewSurfaceView.setVisibility(View.GONE);
- }
-
- public void showSurfaceView() {
- mPreviewSurfaceView.setVisibility(View.VISIBLE);
- }
-
- private void initializeOverlay() {
- mRenderOverlay = (RenderOverlay) mRootView.findViewById(R.id.render_overlay);
- if (mPieRenderer == null) {
- mPieRenderer = new PieRenderer(mActivity);
- mVideoMenu = new VideoMenu(mActivity, this, mPieRenderer);
- mPieRenderer.setPieListener(this);
- }
- mRenderOverlay.addRenderer(mPieRenderer);
- if (mZoomRenderer == null) {
- mZoomRenderer = new ZoomRenderer(mActivity);
- }
- mRenderOverlay.addRenderer(mZoomRenderer);
- if (mGestures == null) {
- mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer, this);
- }
- mGestures.setRenderOverlay(mRenderOverlay);
- mGestures.reset();
- mGestures.addTouchReceiver(mMenu);
- mGestures.addUnclickableArea(mBlocker);
- if (mController.isVideoCaptureIntent()) {
- if (mReviewCancelButton != null) {
- mGestures.addTouchReceiver(mReviewCancelButton);
- }
- if (mReviewDoneButton != null) {
- mGestures.addTouchReceiver(mReviewDoneButton);
- }
- if (mReviewPlayButton != null) {
- mGestures.addTouchReceiver(mReviewPlayButton);
- }
- }
-
- mPreviewThumb = mActivity.findViewById(R.id.preview_thumb);
- mPreviewThumb.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mActivity.gotoGallery();
- }
- });
- }
-
- public void setPrefChangedListener(OnPreferenceChangedListener listener) {
- mVideoMenu.setListener(listener);
- }
-
- private void initializeMiscControls() {
- mPreviewFrameLayout = (PreviewFrameLayout) mRootView.findViewById(R.id.frame);
- mPreviewFrameLayout.setOnLayoutChangeListener(mActivity);
- mReviewImage = (ImageView) mRootView.findViewById(R.id.review_image);
- mShutterButton = mActivity.getShutterButton();
- mShutterButton.setImageResource(R.drawable.btn_new_shutter_video);
- mShutterButton.setOnShutterButtonListener(mController);
- mShutterButton.setVisibility(View.VISIBLE);
- mShutterButton.requestFocus();
- mShutterButton.enableTouch(true);
- mRecordingTimeView = (TextView) mRootView.findViewById(R.id.recording_time);
- mRecordingTimeRect = (RotateLayout) mRootView.findViewById(R.id.recording_time_rect);
- mTimeLapseLabel = mRootView.findViewById(R.id.time_lapse_label);
- // The R.id.labels can only be found in phone layout.
- // That is, mLabelsLinearLayout should be null in tablet layout.
- mLabelsLinearLayout = (LinearLayout) mRootView.findViewById(R.id.labels);
- }
-
- public void updateOnScreenIndicators(Parameters param, ComboPreferences prefs) {
- mOnScreenIndicators.updateFlashOnScreenIndicator(param.getFlashMode());
- boolean location = RecordLocationPreference.get(
- prefs, mActivity.getContentResolver());
- mOnScreenIndicators.updateLocationIndicator(location);
-
- }
-
- public void setAspectRatio(double ratio) {
- mPreviewFrameLayout.setAspectRatio(ratio);
- }
-
- public void showTimeLapseUI(boolean enable) {
- if (mTimeLapseLabel != null) {
- mTimeLapseLabel.setVisibility(enable ? View.VISIBLE : View.GONE);
- }
- }
-
- private void openMenu() {
- if (mPieRenderer != null) {
- mPieRenderer.showInCenter();
- }
- }
-
- public void showPopup(AbstractSettingPopup popup) {
- mActivity.hideUI();
- mBlocker.setVisibility(View.INVISIBLE);
- setShowMenu(false);
- mPopup = popup;
- mPopup.setVisibility(View.VISIBLE);
- FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT);
- lp.gravity = Gravity.CENTER;
- ((FrameLayout) mRootView).addView(mPopup, lp);
- mGestures.addTouchReceiver(mPopup);
- }
-
- public void dismissPopup(boolean topLevelOnly) {
- dismissPopup(topLevelOnly, true);
- }
-
- public void dismissPopup(boolean topLevelPopupOnly, boolean fullScreen) {
- // In review mode, we do not want to bring up the camera UI
- if (mController.isInReviewMode()) return;
-
- if (fullScreen) {
- mActivity.showUI();
- mBlocker.setVisibility(View.VISIBLE);
- }
- setShowMenu(fullScreen);
- if (mPopup != null) {
- mGestures.removeTouchReceiver(mPopup);
- ((FrameLayout) mRootView).removeView(mPopup);
- mPopup = null;
- }
- mVideoMenu.popupDismissed(topLevelPopupOnly);
- }
-
- public void onShowSwitcherPopup() {
- hidePieRenderer();
- }
-
- public boolean hidePieRenderer() {
- if (mPieRenderer != null && mPieRenderer.showsItems()) {
- mPieRenderer.hide();
- return true;
- }
- return false;
- }
-
- // disable preview gestures after shutter is pressed
- public void setShutterPressed(boolean pressed) {
- if (mGestures == null) return;
- mGestures.setEnabled(!pressed);
- }
-
- public void enableShutter(boolean enable) {
- if (mShutterButton != null) {
- mShutterButton.setEnabled(enable);
- }
- }
-
- // PieListener
- @Override
- public void onPieOpened(int centerX, int centerY) {
- dismissPopup(false, true);
- mActivity.cancelActivityTouchHandling();
- mActivity.setSwipingEnabled(false);
- }
-
- @Override
- public void onPieClosed() {
- mActivity.setSwipingEnabled(true);
- }
-
- public void showPreviewBorder(boolean enable) {
- mPreviewFrameLayout.showBorder(enable);
- }
-
- // SingleTapListener
- // Preview area is touched. Take a picture.
- @Override
- public void onSingleTapUp(View view, int x, int y) {
- mController.onSingleTapUp(view, x, y);
- }
-
- // SurfaceView callback
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- Log.v(TAG, "Surface changed. width=" + width + ". height=" + height);
- }
-
- @Override
- public void surfaceCreated(SurfaceHolder holder) {
- Log.v(TAG, "Surface created");
- mSurfaceViewReady = true;
- }
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {
- Log.v(TAG, "Surface destroyed");
- mSurfaceViewReady = false;
- mController.stopPreview();
- }
-
- public boolean isSurfaceViewReady() {
- return mSurfaceViewReady;
- }
-
- public void showRecordingUI(boolean recording, boolean zoomSupported) {
- mMenu.setVisibility(recording ? View.GONE : View.VISIBLE);
- mOnScreenIndicators.setVisibility(recording ? View.GONE : View.VISIBLE);
- if (recording) {
- mShutterButton.setImageResource(R.drawable.btn_shutter_video_recording);
- mActivity.hideSwitcher();
- mRecordingTimeView.setText("");
- mRecordingTimeView.setVisibility(View.VISIBLE);
- // The camera is not allowed to be accessed in older api levels during
- // recording. It is therefore necessary to hide the zoom UI on older
- // platforms.
- // See the documentation of android.media.MediaRecorder.start() for
- // further explanation.
- if (!ApiHelper.HAS_ZOOM_WHEN_RECORDING && zoomSupported) {
- // TODO: disable zoom UI here.
- }
- } else {
- mShutterButton.setImageResource(R.drawable.btn_new_shutter_video);
- mActivity.showSwitcher();
- mRecordingTimeView.setVisibility(View.GONE);
- if (!ApiHelper.HAS_ZOOM_WHEN_RECORDING && zoomSupported) {
- // TODO: enable zoom UI here.
- }
- }
- }
-
- public void showReviewImage(Bitmap bitmap) {
- mReviewImage.setImageBitmap(bitmap);
- mReviewImage.setVisibility(View.VISIBLE);
- }
-
- public void showReviewControls() {
- Util.fadeOut(mShutterButton);
- Util.fadeIn(mReviewDoneButton);
- Util.fadeIn(mReviewPlayButton);
- mReviewImage.setVisibility(View.VISIBLE);
- mMenu.setVisibility(View.GONE);
- mOnScreenIndicators.setVisibility(View.GONE);
- }
-
- public void hideReviewUI() {
- mReviewImage.setVisibility(View.GONE);
- mShutterButton.setEnabled(true);
- mMenu.setVisibility(View.VISIBLE);
- mOnScreenIndicators.setVisibility(View.VISIBLE);
- Util.fadeOut(mReviewDoneButton);
- Util.fadeOut(mReviewPlayButton);
- Util.fadeIn(mShutterButton);
- }
-
- private void setShowMenu(boolean show) {
- if (mOnScreenIndicators != null) {
- mOnScreenIndicators.setVisibility(show ? View.VISIBLE : View.GONE);
- }
- if (mMenu != null) {
- mMenu.setVisibility(show ? View.VISIBLE : View.GONE);
- }
- }
-
- public void onFullScreenChanged(boolean full) {
- if (mGestures != null) {
- mGestures.setEnabled(full);
- }
- if (mPopup != null) {
- dismissPopup(false, full);
- }
- if (mRenderOverlay != null) {
- // this can not happen in capture mode
- mRenderOverlay.setVisibility(full ? View.VISIBLE : View.GONE);
- }
- setShowMenu(full);
- if (mBlocker != null) {
- // this can not happen in capture mode
- mBlocker.setVisibility(full ? View.VISIBLE : View.GONE);
- }
- }
-
- public void initializePopup(PreferenceGroup pref) {
- mVideoMenu.initialize(pref);
- }
-
- public void initializeZoom(Parameters param) {
- if (param == null || !param.isZoomSupported()) return;
- mZoomMax = param.getMaxZoom();
- mZoomRatios = param.getZoomRatios();
- // Currently we use immediate zoom for fast zooming to get better UX and
- // there is no plan to take advantage of the smooth zoom.
- mZoomRenderer.setZoomMax(mZoomMax);
- mZoomRenderer.setZoom(param.getZoom());
- mZoomRenderer.setZoomValue(mZoomRatios.get(param.getZoom()));
- mZoomRenderer.setOnZoomChangeListener(new ZoomChangeListener());
- }
-
- public void clickShutter() {
- mShutterButton.performClick();
- }
-
- public void pressShutter(boolean pressed) {
- mShutterButton.setPressed(pressed);
- }
-
- public boolean dispatchTouchEvent(MotionEvent m) {
- if (mGestures != null && mRenderOverlay != null) {
- return mGestures.dispatchTouch(m);
- }
- return false;
- }
-
- public void setRecordingTime(String text) {
- mRecordingTimeView.setText(text);
- }
-
- public void setRecordingTimeTextColor(int color) {
- mRecordingTimeView.setTextColor(color);
- }
-
- private class ZoomChangeListener implements ZoomRenderer.OnZoomChangedListener {
- @Override
- public void onZoomValueChanged(int index) {
- int newZoom = mController.onZoomChanged(index);
- if (mZoomRenderer != null) {
- mZoomRenderer.setZoomValue(mZoomRatios.get(newZoom));
- }
- }
-
- @Override
- public void onZoomStart() {
- }
-
- @Override
- public void onZoomEnd() {
- }
- }
-
- @Override
- public void onSwipe(int direction) {
- if (direction == PreviewGestures.DIR_UP) {
- openMenu();
- }
- }
-
- /**
- * Enable or disable the preview thumbnail for click events.
- */
- public void enablePreviewThumb(boolean enabled) {
- if (enabled) {
- mGestures.addTouchReceiver(mPreviewThumb);
- mPreviewThumb.setVisibility(View.VISIBLE);
- } else {
- mGestures.removeTouchReceiver(mPreviewThumb);
- mPreviewThumb.setVisibility(View.GONE);
- }
- }
-}
diff --git a/src/com/android/camera/drawable/TextDrawable.java b/src/com/android/camera/drawable/TextDrawable.java
deleted file mode 100644
index 60d8719..0000000
--- a/src/com/android/camera/drawable/TextDrawable.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.drawable;
-
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.ColorFilter;
-import android.graphics.Paint;
-import android.graphics.Typeface;
-import android.graphics.Paint.Align;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.util.TypedValue;
-
-
-public class TextDrawable extends Drawable {
-
- private static final int DEFAULT_COLOR = Color.WHITE;
- private static final int DEFAULT_TEXTSIZE = 15;
-
- private Paint mPaint;
- private CharSequence mText;
- private int mIntrinsicWidth;
- private int mIntrinsicHeight;
- private boolean mUseDropShadow;
-
- public TextDrawable(Resources res) {
- this(res, "");
- }
-
- public TextDrawable(Resources res, CharSequence text) {
- mText = text;
- updatePaint();
- float textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
- DEFAULT_TEXTSIZE, res.getDisplayMetrics());
- mPaint.setTextSize(textSize);
- mIntrinsicWidth = (int) (mPaint.measureText(mText, 0, mText.length()) + .5);
- mIntrinsicHeight = mPaint.getFontMetricsInt(null);
- }
-
- private void updatePaint() {
- if (mPaint == null) {
- mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- }
- mPaint.setColor(DEFAULT_COLOR);
- mPaint.setTextAlign(Align.CENTER);
- if (mUseDropShadow) {
- mPaint.setTypeface(Typeface.DEFAULT_BOLD);
- mPaint.setShadowLayer(10, 0, 0, 0xff000000);
- } else {
- mPaint.setTypeface(Typeface.DEFAULT);
- mPaint.setShadowLayer(0, 0, 0, 0);
- }
- }
-
- public void setText(CharSequence txt) {
- mText = txt;
- if (txt == null) {
- mIntrinsicWidth = 0;
- mIntrinsicHeight = 0;
- } else {
- mIntrinsicWidth = (int) (mPaint.measureText(mText, 0, mText.length()) + .5);
- mIntrinsicHeight = mPaint.getFontMetricsInt(null);
- }
- }
-
- @Override
- public void draw(Canvas canvas) {
- if (mText != null) {
- Rect bounds = getBounds();
- canvas.drawText(mText, 0, mText.length(),
- bounds.centerX(), bounds.centerY(), mPaint);
- }
- }
-
- public void setDropShadow(boolean shadow) {
- mUseDropShadow = shadow;
- updatePaint();
- }
-
- @Override
- public int getOpacity() {
- return mPaint.getAlpha();
- }
-
- @Override
- public int getIntrinsicWidth() {
- return mIntrinsicWidth;
- }
-
- @Override
- public int getIntrinsicHeight() {
- return mIntrinsicHeight;
- }
-
- @Override
- public void setAlpha(int alpha) {
- mPaint.setAlpha(alpha);
- }
-
- @Override
- public void setColorFilter(ColorFilter filter) {
- mPaint.setColorFilter(filter);
- }
-
-}
diff --git a/src/com/android/camera/ui/AbstractSettingPopup.java b/src/com/android/camera/ui/AbstractSettingPopup.java
deleted file mode 100644
index 783b6c7..0000000
--- a/src/com/android/camera/ui/AbstractSettingPopup.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.android.gallery3d.R;
-
-// A popup window that shows one or more camera settings.
-abstract public class AbstractSettingPopup extends RotateLayout {
- protected ViewGroup mSettingList;
- protected TextView mTitle;
-
- public AbstractSettingPopup(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- mTitle = (TextView) findViewById(R.id.title);
- mSettingList = (ViewGroup) findViewById(R.id.settingList);
- }
-
- abstract public void reloadPreference();
-}
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
deleted file mode 100644
index 7940ae0..0000000
--- a/src/com/android/camera/ui/CameraControls.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * 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.camera.ui;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.graphics.Rect;
-import android.hardware.display.DisplayManager;
-import android.hardware.display.DisplayManager.DisplayListener;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import com.android.camera.Util;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-public class CameraControls extends RotatableLayout {
-
- private static final String TAG = "CAM_Controls";
-
- private View mBackgroundView;
- private View mShutter;
- private View mSwitcher;
- private View mMenu;
- private View mIndicators;
- private View mPreview;
- private Object mDisplayListener = null;
- private int mLastRotation = 0;
-
- public CameraControls(Context context, AttributeSet attrs) {
- super(context, attrs);
- initDisplayListener();
- }
-
- public CameraControls(Context context) {
- super(context);
- initDisplayListener();
- }
-
- public void initDisplayListener() {
- if (ApiHelper.HAS_DISPLAY_LISTENER) {
- mDisplayListener = new DisplayListener() {
-
- @Override
- public void onDisplayAdded(int arg0) {}
-
- @Override
- public void onDisplayChanged(int arg0) {
- checkLayoutFlip();
- }
-
- @Override
- public void onDisplayRemoved(int arg0) {}
- };
- }
- }
-
- private void checkLayoutFlip() {
- int currentRotation = Util.getDisplayRotation((Activity) getContext());
- if ((currentRotation - mLastRotation + 360) % 360 == 180) {
- mLastRotation = currentRotation;
- flipChildren();
- getParent().requestLayout();
- }
- }
-
- @Override
- public void onFinishInflate() {
- super.onFinishInflate();
- mBackgroundView = findViewById(R.id.blocker);
- mSwitcher = findViewById(R.id.camera_switcher);
- mShutter = findViewById(R.id.shutter_button);
- mMenu = findViewById(R.id.menu);
- mIndicators = findViewById(R.id.on_screen_indicators);
- mPreview = findViewById(R.id.preview_thumb);
- }
-
- @Override
- public void onAttachedToWindow() {
- super.onAttachedToWindow();
- adjustControlsToRightPosition();
- mLastRotation = Util.getDisplayRotation((Activity) getContext());
- if (ApiHelper.HAS_DISPLAY_LISTENER) {
- ((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE))
- .registerDisplayListener((DisplayListener) mDisplayListener, null);
- }
- }
-
- @Override
- public void onWindowVisibilityChanged(int visibility) {
- if (visibility == View.VISIBLE) {
- // Make sure when coming back from onPause, the layout is rotated correctly
- checkLayoutFlip();
- }
- }
-
- @Override
- public void onDetachedFromWindow () {
- super.onDetachedFromWindow();
- if (ApiHelper.HAS_DISPLAY_LISTENER) {
- ((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE))
- .unregisterDisplayListener((DisplayListener) mDisplayListener);
- }
- }
-
- @Override
- public void onLayout(boolean changed, int l, int t, int r, int b) {
- mLastRotation = Util.getDisplayRotation((Activity) getContext());
- int orientation = getResources().getConfiguration().orientation;
- int size = getResources().getDimensionPixelSize(R.dimen.camera_controls_size);
- int rotation = getUnifiedRotation();
- adjustBackground();
- // As l,t,r,b are positions relative to parents, we need to convert them
- // to child's coordinates
- r = r - l;
- b = b - t;
- l = 0;
- t = 0;
- for (int i = 0; i < getChildCount(); i++) {
- View v = getChildAt(i);
- v.layout(l, t, r, b);
- }
- Rect shutter = new Rect();
- topRight(mPreview, l, t, r, b);
- if (size > 0) {
- // restrict controls to size
- switch (rotation) {
- case 0:
- case 180:
- l = (l + r - size) / 2;
- r = l + size;
- break;
- case 90:
- case 270:
- t = (t + b - size) / 2;
- b = t + size;
- break;
- }
- }
- center(mShutter, l, t, r, b, orientation, rotation, shutter);
- center(mBackgroundView, l, t, r, b, orientation, rotation, new Rect());
- toLeft(mSwitcher, shutter, rotation);
- toRight(mMenu, shutter, rotation);
- toRight(mIndicators, shutter, rotation);
- View retake = findViewById(R.id.btn_retake);
- if (retake != null) {
- center(retake, shutter, rotation);
- View cancel = findViewById(R.id.btn_cancel);
- toLeft(cancel, shutter, rotation);
- View done = findViewById(R.id.btn_done);
- toRight(done, shutter, rotation);
- }
- }
-
- private int getUnifiedRotation() {
- // all the layout code assumes camera device orientation to be portrait
- // adjust rotation for landscape
- int orientation = getResources().getConfiguration().orientation;
- int rotation = Util.getDisplayRotation((Activity) getContext());
- int camOrientation = (rotation % 180 == 0) ? Configuration.ORIENTATION_PORTRAIT
- : Configuration.ORIENTATION_LANDSCAPE;
- if (camOrientation != orientation) {
- return (rotation + 90) % 360;
- }
- return rotation;
- }
-
- private void center(View v, int l, int t, int r, int b, int orientation, int rotation, Rect result) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
- int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
- int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
- switch (rotation) {
- case 0:
- // phone portrait; controls bottom
- result.left = (r + l) / 2 - tw / 2 + lp.leftMargin;
- result.right = (r + l) / 2 + tw / 2 - lp.rightMargin;
- result.bottom = b - lp.bottomMargin;
- result.top = b - th + lp.topMargin;
- break;
- case 90:
- // phone landscape: controls right
- result.right = r - lp.rightMargin;
- result.left = r - tw + lp.leftMargin;
- result.top = (b + t) / 2 - th / 2 + lp.topMargin;
- result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin;
- break;
- case 180:
- // phone upside down: controls top
- result.left = (r + l) / 2 - tw / 2 + lp.leftMargin;
- result.right = (r + l) / 2 + tw / 2 - lp.rightMargin;
- result.top = t + lp.topMargin;
- result.bottom = t + th - lp.bottomMargin;
- break;
- case 270:
- // reverse landscape: controls left
- result.left = l + lp.leftMargin;
- result.right = l + tw - lp.rightMargin;
- result.top = (b + t) / 2 - th / 2 + lp.topMargin;
- result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin;
- break;
- }
- v.layout(result.left, result.top, result.right, result.bottom);
- }
-
- private void center(View v, Rect other, int rotation) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
- int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
- int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
- int cx = (other.left + other.right) / 2;
- int cy = (other.top + other.bottom) / 2;
- v.layout(cx - tw / 2 + lp.leftMargin,
- cy - th / 2 + lp.topMargin,
- cx + tw / 2 - lp.rightMargin,
- cy + th / 2 - lp.bottomMargin);
- }
-
- private void toLeft(View v, Rect other, int rotation) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
- int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
- int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
- int cx = (other.left + other.right) / 2;
- int cy = (other.top + other.bottom) / 2;
- int l = 0, r = 0, t = 0, b = 0;
- switch (rotation) {
- case 0:
- // portrait, to left of anchor at bottom
- l = other.left - tw + lp.leftMargin;
- r = other.left - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 90:
- // phone landscape: below anchor on right
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.bottom + lp.topMargin;
- b = other.bottom + th - lp.bottomMargin;
- break;
- case 180:
- // phone upside down: right of anchor at top
- l = other.right + lp.leftMargin;
- r = other.right + tw - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 270:
- // reverse landscape: above anchor on left
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.top - th + lp.topMargin;
- b = other.top - lp.bottomMargin;
- break;
- }
- v.layout(l, t, r, b);
- }
-
- private void toRight(View v, Rect other, int rotation) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
- int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
- int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
- int cx = (other.left + other.right) / 2;
- int cy = (other.top + other.bottom) / 2;
- int l = 0, r = 0, t = 0, b = 0;
- switch (rotation) {
- case 0:
- l = other.right + lp.leftMargin;
- r = other.right + tw - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 90:
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.top - th + lp.topMargin;
- b = other.top - lp.bottomMargin;
- break;
- case 180:
- l = other.left - tw + lp.leftMargin;
- r = other.left - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 270:
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.bottom + lp.topMargin;
- b = other.bottom + th - lp.bottomMargin;
- break;
- }
- v.layout(l, t, r, b);
- }
-
- private void topRight(View v, int l, int t, int r, int b) {
- // layout using the specific margins; the rotation code messes up the others
- int mt = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_top);
- int mr = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_right);
- v.layout(r - v.getMeasuredWidth() - mr, t + mt, r - mr, t + mt + v.getMeasuredHeight());
- }
-
- // In reverse landscape and reverse portrait, camera controls will be laid out
- // on the wrong side of the screen. We need to make adjustment to move the controls
- // to the USB side
- public void adjustControlsToRightPosition() {
- int orientation = getUnifiedRotation();
- if (orientation >= 180) {
- flipChildren();
- }
- }
-
- private void adjustBackground() {
- int rotation = getUnifiedRotation();
- // remove current drawable and reset rotation
- mBackgroundView.setBackgroundDrawable(null);
- mBackgroundView.setRotationX(0);
- mBackgroundView.setRotationY(0);
- // if the switcher background is top aligned we need to flip the background
- // drawable vertically; if left aligned, flip horizontally
- switch (rotation) {
- case 180:
- mBackgroundView.setRotationX(180);
- break;
- case 270:
- mBackgroundView.setRotationY(180);
- break;
- default:
- break;
- }
- mBackgroundView.setBackgroundResource(R.drawable.switcher_bg);
- }
-
-}
diff --git a/src/com/android/camera/ui/CameraRootView.java b/src/com/android/camera/ui/CameraRootView.java
deleted file mode 100644
index 76fea2c..0000000
--- a/src/com/android/camera/ui/CameraRootView.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.camera.ui;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.RelativeLayout;
-
-import com.android.camera.Util;
-import com.android.gallery3d.R;
-
-public class CameraRootView extends RelativeLayout {
-
- private int mTopMargin = 0;
- private int mBottomMargin = 0;
- private int mLeftMargin = 0;
- private int mRightMargin = 0;
- private int mOffset = 0;
- private Rect mCurrentInsets;
- public CameraRootView(Context context, AttributeSet attrs) {
- super(context, attrs);
- // Layout the window as if we did not need navigation bar
- setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
- }
-
- @Override
- protected boolean fitSystemWindows(Rect insets) {
- super.fitSystemWindows(insets);
- mCurrentInsets = insets;
- // insets include status bar, navigation bar, etc
- // In this case, we are only concerned with the size of nav bar
- if (mOffset > 0) return true;
-
- if (insets.bottom > 0) {
- mOffset = insets.bottom;
- } else if (insets.right > 0) {
- mOffset = insets.right;
- }
- return true;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int rotation = Util.getDisplayRotation((Activity) getContext());
- // all the layout code assumes camera device orientation to be portrait
- // adjust rotation for landscape
- int orientation = getResources().getConfiguration().orientation;
- int camOrientation = (rotation % 180 == 0) ? Configuration.ORIENTATION_PORTRAIT
- : Configuration.ORIENTATION_LANDSCAPE;
- if (camOrientation != orientation) {
- rotation = (rotation + 90) % 360;
- }
- // calculate margins
- mLeftMargin = 0;
- mRightMargin = 0;
- mBottomMargin = 0;
- mTopMargin = 0;
- switch (rotation) {
- case 0:
- mBottomMargin += mOffset;
- break;
- case 90:
- mRightMargin += mOffset;
- break;
- case 180:
- mTopMargin += mOffset;
- break;
- case 270:
- mLeftMargin += mOffset;
- break;
- }
- if (mCurrentInsets != null) {
- if (mCurrentInsets.right > 0) {
- // navigation bar on the right
- mRightMargin = mRightMargin > 0 ? mRightMargin : mCurrentInsets.right;
- } else {
- // navigation bar on the bottom
- mBottomMargin = mBottomMargin > 0 ? mBottomMargin : mCurrentInsets.bottom;
- }
- }
- // make sure all the children are resized
- super.onMeasure(widthMeasureSpec - mLeftMargin - mRightMargin,
- heightMeasureSpec - mTopMargin - mBottomMargin);
-
- setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
- }
-
- @Override
- public void onLayout(boolean changed, int l, int t, int r, int b) {
- int orientation = getResources().getConfiguration().orientation;
- // Lay out children
- for (int i = 0; i < getChildCount(); i++) {
- View v = getChildAt(i);
- if (v instanceof CameraControls) {
- // Lay out camera controls to center on the short side of the screen
- // so that they stay in place during rotation
- int width = v.getMeasuredWidth();
- int height = v.getMeasuredHeight();
- if (orientation == Configuration.ORIENTATION_PORTRAIT) {
- int left = (l + r - width) / 2;
- v.layout(left, t + mTopMargin, left + width, b - mBottomMargin);
- } else {
- int top = (t + b - height) / 2;
- v.layout(l + mLeftMargin, top, r - mRightMargin, top + height);
- }
- } else {
- v.layout(l + mLeftMargin, t + mTopMargin, r - mRightMargin, b - mBottomMargin);
- }
- }
- }
-}
diff --git a/src/com/android/camera/ui/CameraSwitcher.java b/src/com/android/camera/ui/CameraSwitcher.java
deleted file mode 100644
index 537577f..0000000
--- a/src/com/android/camera/ui/CameraSwitcher.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.animation.Animator;
-import android.animation.Animator.AnimatorListener;
-import android.animation.AnimatorListenerAdapter;
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnTouchListener;
-import android.view.ViewGroup;
-import android.widget.FrameLayout.LayoutParams;
-import android.widget.LinearLayout;
-
-import com.android.camera.Util;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.util.LightCycleHelper;
-import com.android.gallery3d.util.UsageStatistics;
-
-public class CameraSwitcher extends RotateImageView
- implements OnClickListener, OnTouchListener {
-
- private static final String TAG = "CAM_Switcher";
- private static final int SWITCHER_POPUP_ANIM_DURATION = 200;
-
- public static final int PHOTO_MODULE_INDEX = 0;
- public static final int VIDEO_MODULE_INDEX = 1;
- public static final int PANORAMA_MODULE_INDEX = 2;
- public static final int LIGHTCYCLE_MODULE_INDEX = 3;
- private static final int[] DRAW_IDS = {
- R.drawable.ic_switch_camera,
- R.drawable.ic_switch_video,
- R.drawable.ic_switch_pan,
- R.drawable.ic_switch_photosphere
- };
- public interface CameraSwitchListener {
- public void onCameraSelected(int i);
- public void onShowSwitcherPopup();
- }
-
- private CameraSwitchListener mListener;
- private int mCurrentIndex;
- private int[] mModuleIds;
- private int[] mDrawIds;
- private int mItemSize;
- private View mPopup;
- private View mParent;
- private boolean mShowingPopup;
- private boolean mNeedsAnimationSetup;
- private Drawable mIndicator;
-
- private float mTranslationX = 0;
- private float mTranslationY = 0;
-
- private AnimatorListener mHideAnimationListener;
- private AnimatorListener mShowAnimationListener;
-
- public CameraSwitcher(Context context) {
- super(context);
- init(context);
- }
-
- public CameraSwitcher(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context);
- }
-
- private void init(Context context) {
- mItemSize = context.getResources().getDimensionPixelSize(R.dimen.switcher_size);
- setOnClickListener(this);
- mIndicator = context.getResources().getDrawable(R.drawable.ic_switcher_menu_indicator);
- initializeDrawables(context);
- }
-
- public void initializeDrawables(Context context) {
- int totaldrawid = (LightCycleHelper.hasLightCycleCapture(context)
- ? DRAW_IDS.length : DRAW_IDS.length - 1);
- if (!ApiHelper.HAS_OLD_PANORAMA) totaldrawid--;
-
- int[] drawids = new int[totaldrawid];
- int[] moduleids = new int[totaldrawid];
- int ix = 0;
- for (int i = 0; i < DRAW_IDS.length; i++) {
- if (i == PANORAMA_MODULE_INDEX && !ApiHelper.HAS_OLD_PANORAMA) {
- continue; // not enabled, so don't add to UI
- }
- if (i == LIGHTCYCLE_MODULE_INDEX && !LightCycleHelper.hasLightCycleCapture(context)) {
- continue; // not enabled, so don't add to UI
- }
- moduleids[ix] = i;
- drawids[ix++] = DRAW_IDS[i];
- }
- setIds(moduleids, drawids);
- }
-
- public void setIds(int[] moduleids, int[] drawids) {
- mDrawIds = drawids;
- mModuleIds = moduleids;
- }
-
- public void setCurrentIndex(int i) {
- mCurrentIndex = i;
- setImageResource(mDrawIds[i]);
- }
-
- public void setSwitchListener(CameraSwitchListener l) {
- mListener = l;
- }
-
- @Override
- public void onClick(View v) {
- showSwitcher();
- mListener.onShowSwitcherPopup();
- }
-
- private void onCameraSelected(int ix) {
- hidePopup();
- if ((ix != mCurrentIndex) && (mListener != null)) {
- UsageStatistics.onEvent("CameraModeSwitch", null, null);
- UsageStatistics.setPendingTransitionCause(
- UsageStatistics.TRANSITION_MENU_TAP);
- setCurrentIndex(ix);
- mListener.onCameraSelected(mModuleIds[ix]);
- }
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- mIndicator.setBounds(getDrawable().getBounds());
- mIndicator.draw(canvas);
- }
-
- private void initPopup() {
- mParent = LayoutInflater.from(getContext()).inflate(R.layout.switcher_popup,
- (ViewGroup) getParent());
- LinearLayout content = (LinearLayout) mParent.findViewById(R.id.content);
- mPopup = content;
- // Set the gravity of the popup, so that it shows up at the right position
- // on screen
- LayoutParams lp = ((LayoutParams) mPopup.getLayoutParams());
- lp.gravity = ((LayoutParams) mParent.findViewById(R.id.camera_switcher)
- .getLayoutParams()).gravity;
- mPopup.setLayoutParams(lp);
-
- mPopup.setVisibility(View.INVISIBLE);
- mNeedsAnimationSetup = true;
- for (int i = mDrawIds.length - 1; i >= 0; i--) {
- RotateImageView item = new RotateImageView(getContext());
- item.setImageResource(mDrawIds[i]);
- item.setBackgroundResource(R.drawable.bg_pressed);
- final int index = i;
- item.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (showsPopup()) onCameraSelected(index);
- }
- });
- switch (mDrawIds[i]) {
- case R.drawable.ic_switch_camera:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_camera));
- break;
- case R.drawable.ic_switch_video:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_video));
- break;
- case R.drawable.ic_switch_pan:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_panorama));
- break;
- case R.drawable.ic_switch_photosphere:
- item.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_switch_to_new_panorama));
- break;
- default:
- break;
- }
- content.addView(item, new LinearLayout.LayoutParams(mItemSize, mItemSize));
- }
- mPopup.measure(MeasureSpec.makeMeasureSpec(mParent.getWidth(), MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(mParent.getHeight(), MeasureSpec.AT_MOST));
- }
-
- public boolean showsPopup() {
- return mShowingPopup;
- }
-
- public boolean isInsidePopup(MotionEvent evt) {
- if (!showsPopup()) return false;
- int topLeft[] = new int[2];
- mPopup.getLocationOnScreen(topLeft);
- int left = topLeft[0];
- int top = topLeft[1];
- int bottom = top + mPopup.getHeight();
- int right = left + mPopup.getWidth();
- return evt.getX() >= left && evt.getX() < right
- && evt.getY() >= top && evt.getY() < bottom;
- }
-
- private void hidePopup() {
- mShowingPopup = false;
- setVisibility(View.VISIBLE);
- if (mPopup != null && !animateHidePopup()) {
- mPopup.setVisibility(View.INVISIBLE);
- }
- mParent.setOnTouchListener(null);
- }
-
- @Override
- public void onConfigurationChanged(Configuration config) {
- if (showsPopup()) {
- ((ViewGroup) mParent).removeView(mPopup);
- mPopup = null;
- initPopup();
- mPopup.setVisibility(View.VISIBLE);
- }
- }
-
- private void showSwitcher() {
- mShowingPopup = true;
- if (mPopup == null) {
- initPopup();
- }
- layoutPopup();
- mPopup.setVisibility(View.VISIBLE);
- if (!animateShowPopup()) {
- setVisibility(View.INVISIBLE);
- }
- mParent.setOnTouchListener(this);
- }
-
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- closePopup();
- return true;
- }
-
- public void closePopup() {
- if (showsPopup()) {
- hidePopup();
- }
- }
-
- @Override
- public void setOrientation(int degree, boolean animate) {
- super.setOrientation(degree, animate);
- ViewGroup content = (ViewGroup) mPopup;
- if (content == null) return;
- for (int i = 0; i < content.getChildCount(); i++) {
- RotateImageView iv = (RotateImageView) content.getChildAt(i);
- iv.setOrientation(degree, animate);
- }
- }
-
- private void layoutPopup() {
- int orientation = Util.getDisplayRotation((Activity) getContext());
- int w = mPopup.getMeasuredWidth();
- int h = mPopup.getMeasuredHeight();
- if (orientation == 0) {
- mPopup.layout(getRight() - w, getBottom() - h, getRight(), getBottom());
- mTranslationX = 0;
- mTranslationY = h / 3;
- } else if (orientation == 90) {
- mTranslationX = w / 3;
- mTranslationY = - h / 3;
- mPopup.layout(getRight() - w, getTop(), getRight(), getTop() + h);
- } else if (orientation == 180) {
- mTranslationX = - w / 3;
- mTranslationY = - h / 3;
- mPopup.layout(getLeft(), getTop(), getLeft() + w, getTop() + h);
- } else {
- mTranslationX = - w / 3;
- mTranslationY = h - getHeight();
- mPopup.layout(getLeft(), getBottom() - h, getLeft() + w, getBottom());
- }
- }
-
- @Override
- public void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- if (mPopup != null) {
- layoutPopup();
- }
- }
-
- private void popupAnimationSetup() {
- if (!ApiHelper.HAS_VIEW_PROPERTY_ANIMATOR) {
- return;
- }
- layoutPopup();
- mPopup.setScaleX(0.3f);
- mPopup.setScaleY(0.3f);
- mPopup.setTranslationX(mTranslationX);
- mPopup.setTranslationY(mTranslationY);
- mNeedsAnimationSetup = false;
- }
-
- private boolean animateHidePopup() {
- if (!ApiHelper.HAS_VIEW_PROPERTY_ANIMATOR) {
- return false;
- }
- if (mHideAnimationListener == null) {
- mHideAnimationListener = new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- // Verify that we weren't canceled
- if (!showsPopup() && mPopup != null) {
- mPopup.setVisibility(View.INVISIBLE);
- ((ViewGroup) mParent).removeView(mPopup);
- mPopup = null;
- }
- }
- };
- }
- mPopup.animate()
- .alpha(0f)
- .scaleX(0.3f).scaleY(0.3f)
- .translationX(mTranslationX)
- .translationY(mTranslationY)
- .setDuration(SWITCHER_POPUP_ANIM_DURATION)
- .setListener(mHideAnimationListener);
- animate().alpha(1f).setDuration(SWITCHER_POPUP_ANIM_DURATION)
- .setListener(null);
- return true;
- }
-
- private boolean animateShowPopup() {
- if (!ApiHelper.HAS_VIEW_PROPERTY_ANIMATOR) {
- return false;
- }
- if (mNeedsAnimationSetup) {
- popupAnimationSetup();
- }
- if (mShowAnimationListener == null) {
- mShowAnimationListener = new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- // Verify that we weren't canceled
- if (showsPopup()) {
- setVisibility(View.INVISIBLE);
- // request layout to make sure popup is laid out correctly on ICS
- mPopup.requestLayout();
- }
- }
- };
- }
- mPopup.animate()
- .alpha(1f)
- .scaleX(1f).scaleY(1f)
- .translationX(0)
- .translationY(0)
- .setDuration(SWITCHER_POPUP_ANIM_DURATION)
- .setListener(null);
- animate().alpha(0f).setDuration(SWITCHER_POPUP_ANIM_DURATION)
- .setListener(mShowAnimationListener);
- return true;
- }
-}
diff --git a/src/com/android/camera/ui/CheckedLinearLayout.java b/src/com/android/camera/ui/CheckedLinearLayout.java
deleted file mode 100644
index 4e77504..0000000
--- a/src/com/android/camera/ui/CheckedLinearLayout.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.Checkable;
-import android.widget.LinearLayout;
-
-public class CheckedLinearLayout extends LinearLayout implements Checkable {
- private static final int[] CHECKED_STATE_SET = {
- android.R.attr.state_checked
- };
- private boolean mChecked;
-
- public CheckedLinearLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- public boolean isChecked() {
- return mChecked;
- }
-
- @Override
- public void setChecked(boolean checked) {
- if (mChecked != checked) {
- mChecked = checked;
- refreshDrawableState();
- }
- }
-
- @Override
- public void toggle() {
- setChecked(!mChecked);
- }
-
- @Override
- public int[] onCreateDrawableState(int extraSpace) {
- final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
- if (mChecked) {
- mergeDrawableStates(drawableState, CHECKED_STATE_SET);
- }
- return drawableState;
- }
-}
diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java
deleted file mode 100644
index 907d335..0000000
--- a/src/com/android/camera/ui/CountDownView.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import java.util.Locale;
-
-import android.content.Context;
-import android.media.AudioManager;
-import android.media.SoundPool;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-import com.android.gallery3d.R;
-
-public class CountDownView extends FrameLayout {
-
- private static final String TAG = "CAM_CountDownView";
- private static final int SET_TIMER_TEXT = 1;
- private TextView mRemainingSecondsView;
- private int mRemainingSecs = 0;
- private OnCountDownFinishedListener mListener;
- private Animation mCountDownAnim;
- private SoundPool mSoundPool;
- private int mBeepTwice;
- private int mBeepOnce;
- private boolean mPlaySound;
- private final Handler mHandler = new MainHandler();
-
- public CountDownView(Context context, AttributeSet attrs) {
- super(context, attrs);
- mCountDownAnim = AnimationUtils.loadAnimation(context, R.anim.count_down_exit);
- // Load the beeps
- mSoundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
- mBeepOnce = mSoundPool.load(context, R.raw.beep_once, 1);
- mBeepTwice = mSoundPool.load(context, R.raw.beep_twice, 1);
- }
-
- public boolean isCountingDown() {
- return mRemainingSecs > 0;
- };
-
- public interface OnCountDownFinishedListener {
- public void onCountDownFinished();
- }
-
- private void remainingSecondsChanged(int newVal) {
- mRemainingSecs = newVal;
- if (newVal == 0) {
- // Countdown has finished
- setVisibility(View.INVISIBLE);
- mListener.onCountDownFinished();
- } else {
- Locale locale = getResources().getConfiguration().locale;
- String localizedValue = String.format(locale, "%d", newVal);
- mRemainingSecondsView.setText(localizedValue);
- // Fade-out animation
- mCountDownAnim.reset();
- mRemainingSecondsView.clearAnimation();
- mRemainingSecondsView.startAnimation(mCountDownAnim);
-
- // Play sound effect for the last 3 seconds of the countdown
- if (mPlaySound) {
- if (newVal == 1) {
- mSoundPool.play(mBeepTwice, 1.0f, 1.0f, 0, 0, 1.0f);
- } else if (newVal <= 3) {
- mSoundPool.play(mBeepOnce, 1.0f, 1.0f, 0, 0, 1.0f);
- }
- }
- // Schedule the next remainingSecondsChanged() call in 1 second
- mHandler.sendEmptyMessageDelayed(SET_TIMER_TEXT, 1000);
- }
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mRemainingSecondsView = (TextView) findViewById(R.id.remaining_seconds);
- }
-
- public void setCountDownFinishedListener(OnCountDownFinishedListener listener) {
- mListener = listener;
- }
-
- public void startCountDown(int sec, boolean playSound) {
- if (sec <= 0) {
- Log.w(TAG, "Invalid input for countdown timer: " + sec + " seconds");
- return;
- }
- setVisibility(View.VISIBLE);
- mPlaySound = playSound;
- remainingSecondsChanged(sec);
- }
-
- public void cancelCountDown() {
- if (mRemainingSecs > 0) {
- mRemainingSecs = 0;
- mHandler.removeMessages(SET_TIMER_TEXT);
- setVisibility(View.INVISIBLE);
- }
- }
-
- private class MainHandler extends Handler {
- @Override
- public void handleMessage(Message message) {
- if (message.what == SET_TIMER_TEXT) {
- remainingSecondsChanged(mRemainingSecs -1);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/android/camera/ui/CountdownTimerPopup.java b/src/com/android/camera/ui/CountdownTimerPopup.java
deleted file mode 100644
index 7c3572b..0000000
--- a/src/com/android/camera/ui/CountdownTimerPopup.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.NumberPicker;
-import android.widget.NumberPicker.OnValueChangeListener;
-
-import com.android.camera.ListPreference;
-import com.android.gallery3d.R;
-
-import java.util.Locale;
-
-/**
- * This is a popup window that allows users to specify a countdown timer
- */
-
-public class CountdownTimerPopup extends AbstractSettingPopup {
- private static final String TAG = "TimerSettingPopup";
- private NumberPicker mNumberSpinner;
- private String[] mDurations;
- private ListPreference mTimer;
- private ListPreference mBeep;
- private Listener mListener;
- private Button mConfirmButton;
- private View mPickerTitle;
- private CheckBox mTimerSound;
- private View mSoundTitle;
-
- static public interface Listener {
- public void onListPrefChanged(ListPreference pref);
- }
-
- public void setSettingChangedListener(Listener listener) {
- mListener = listener;
- }
-
- public CountdownTimerPopup(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void initialize(ListPreference timer, ListPreference beep) {
- mTimer = timer;
- mBeep = beep;
- // Set title.
- mTitle.setText(mTimer.getTitle());
-
- // Duration
- CharSequence[] entries = mTimer.getEntryValues();
- mDurations = new String[entries.length];
- Locale locale = getResources().getConfiguration().locale;
- mDurations[0] = getResources().getString(R.string.setting_off); // Off
- for (int i = 1; i < entries.length; i++)
- mDurations[i] = String.format(locale, "%d", Integer.parseInt(entries[i].toString()));
- int durationCount = mDurations.length;
- mNumberSpinner = (NumberPicker) findViewById(R.id.duration);
- mNumberSpinner.setMinValue(0);
- mNumberSpinner.setMaxValue(durationCount - 1);
- mNumberSpinner.setDisplayedValues(mDurations);
- mNumberSpinner.setWrapSelectorWheel(false);
- mNumberSpinner.setOnValueChangedListener(new OnValueChangeListener() {
- @Override
- public void onValueChange(NumberPicker picker, int oldValue, int newValue) {
- setTimeSelectionEnabled(newValue != 0);
- }
- });
- mConfirmButton = (Button) findViewById(R.id.timer_set_button);
- mPickerTitle = findViewById(R.id.set_time_interval_title);
-
- // Disable focus on the spinners to prevent keyboard from coming up
- mNumberSpinner.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
-
- mConfirmButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- updateInputState();
- }
- });
- mTimerSound = (CheckBox) findViewById(R.id.sound_check_box);
- mSoundTitle = findViewById(R.id.beep_title);
- }
-
- private void restoreSetting() {
- int index = mTimer.findIndexOfValue(mTimer.getValue());
- if (index == -1) {
- Log.e(TAG, "Invalid preference value.");
- mTimer.print();
- throw new IllegalArgumentException();
- } else {
- setTimeSelectionEnabled(index != 0);
- mNumberSpinner.setValue(index);
- }
- boolean checked = mBeep.findIndexOfValue(mBeep.getValue()) != 0;
- mTimerSound.setChecked(checked);
- }
-
- @Override
- public void setVisibility(int visibility) {
- if (visibility == View.VISIBLE) {
- if (getVisibility() != View.VISIBLE) {
- // Set the number pickers and on/off switch to be consistent
- // with the preference
- restoreSetting();
- }
- }
- super.setVisibility(visibility);
- }
-
- protected void setTimeSelectionEnabled(boolean enabled) {
- mPickerTitle.setVisibility(enabled ? VISIBLE : INVISIBLE);
- mTimerSound.setEnabled(enabled);
- mSoundTitle.setEnabled(enabled);
- }
-
- @Override
- public void reloadPreference() {
- }
-
- private void updateInputState() {
- mTimer.setValueIndex(mNumberSpinner.getValue());
- mBeep.setValueIndex(mTimerSound.isChecked() ? 1 : 0);
- if (mListener != null) {
- mListener.onListPrefChanged(mTimer);
- mListener.onListPrefChanged(mBeep);
- }
- }
-}
diff --git a/src/com/android/camera/ui/EffectSettingPopup.java b/src/com/android/camera/ui/EffectSettingPopup.java
deleted file mode 100644
index 568781a..0000000
--- a/src/com/android/camera/ui/EffectSettingPopup.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.ui;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.GridView;
-import android.widget.SimpleAdapter;
-
-import com.android.camera.IconListPreference;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-// A popup window that shows video effect setting. It has two grid view.
-// One shows the goofy face effects. The other shows the background replacer
-// effects.
-public class EffectSettingPopup extends AbstractSettingPopup implements
- AdapterView.OnItemClickListener, View.OnClickListener {
- private static final String TAG = "EffectSettingPopup";
- private String mNoEffect;
- private IconListPreference mPreference;
- private Listener mListener;
- private View mClearEffects;
- private GridView mSillyFacesGrid;
- private GridView mBackgroundGrid;
-
- // Data for silly face items. (text, image, and preference value)
- ArrayList<HashMap<String, Object>> mSillyFacesItem =
- new ArrayList<HashMap<String, Object>>();
-
- // Data for background replacer items. (text, image, and preference value)
- ArrayList<HashMap<String, Object>> mBackgroundItem =
- new ArrayList<HashMap<String, Object>>();
-
-
- static public interface Listener {
- public void onSettingChanged();
- }
-
- public EffectSettingPopup(Context context, AttributeSet attrs) {
- super(context, attrs);
- mNoEffect = context.getString(R.string.pref_video_effect_default);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mClearEffects = findViewById(R.id.clear_effects);
- mClearEffects.setOnClickListener(this);
- mSillyFacesGrid = (GridView) findViewById(R.id.effect_silly_faces);
- mBackgroundGrid = (GridView) findViewById(R.id.effect_background);
- }
-
- public void initialize(IconListPreference preference) {
- mPreference = preference;
- Context context = getContext();
- CharSequence[] entries = mPreference.getEntries();
- CharSequence[] entryValues = mPreference.getEntryValues();
- int[] iconIds = mPreference.getImageIds();
- if (iconIds == null) {
- iconIds = mPreference.getLargeIconIds();
- }
-
- // Set title.
- mTitle.setText(mPreference.getTitle());
-
- for(int i = 0; i < entries.length; ++i) {
- String value = entryValues[i].toString();
- if (value.equals(mNoEffect)) continue; // no effect, skip it.
- HashMap<String, Object> map = new HashMap<String, Object>();
- map.put("value", value);
- map.put("text", entries[i].toString());
- if (iconIds != null) map.put("image", iconIds[i]);
- if (value.startsWith("goofy_face")) {
- mSillyFacesItem.add(map);
- } else if (value.startsWith("backdropper")) {
- mBackgroundItem.add(map);
- }
- }
-
- boolean hasSillyFaces = mSillyFacesItem.size() > 0;
- boolean hasBackground = mBackgroundItem.size() > 0;
-
- // Initialize goofy face if it is supported.
- if (hasSillyFaces) {
- findViewById(R.id.effect_silly_faces_title).setVisibility(View.VISIBLE);
- findViewById(R.id.effect_silly_faces_title_separator).setVisibility(View.VISIBLE);
- mSillyFacesGrid.setVisibility(View.VISIBLE);
- SimpleAdapter sillyFacesItemAdapter = new SimpleAdapter(context,
- mSillyFacesItem, R.layout.effect_setting_item,
- new String[] {"text", "image"},
- new int[] {R.id.text, R.id.image});
- mSillyFacesGrid.setAdapter(sillyFacesItemAdapter);
- mSillyFacesGrid.setOnItemClickListener(this);
- }
-
- if (hasSillyFaces && hasBackground) {
- findViewById(R.id.effect_background_separator).setVisibility(View.VISIBLE);
- }
-
- // Initialize background replacer if it is supported.
- if (hasBackground) {
- findViewById(R.id.effect_background_title).setVisibility(View.VISIBLE);
- findViewById(R.id.effect_background_title_separator).setVisibility(View.VISIBLE);
- mBackgroundGrid.setVisibility(View.VISIBLE);
- SimpleAdapter backgroundItemAdapter = new SimpleAdapter(context,
- mBackgroundItem, R.layout.effect_setting_item,
- new String[] {"text", "image"},
- new int[] {R.id.text, R.id.image});
- mBackgroundGrid.setAdapter(backgroundItemAdapter);
- mBackgroundGrid.setOnItemClickListener(this);
- }
-
- reloadPreference();
- }
-
- @Override
- public void setVisibility(int visibility) {
- if (visibility == View.VISIBLE) {
- if (getVisibility() != View.VISIBLE) {
- // Do not show or hide "Clear effects" button when the popup
- // is already visible. Otherwise it looks strange.
- boolean noEffect = mPreference.getValue().equals(mNoEffect);
- mClearEffects.setVisibility(noEffect ? View.GONE : View.VISIBLE);
- }
- reloadPreference();
- }
- super.setVisibility(visibility);
- }
-
- // The value of the preference may have changed. Update the UI.
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- @Override
- public void reloadPreference() {
- mBackgroundGrid.setItemChecked(mBackgroundGrid.getCheckedItemPosition(), false);
- mSillyFacesGrid.setItemChecked(mSillyFacesGrid.getCheckedItemPosition(), false);
-
- String value = mPreference.getValue();
- if (value.equals(mNoEffect)) return;
-
- for (int i = 0; i < mSillyFacesItem.size(); i++) {
- if (value.equals(mSillyFacesItem.get(i).get("value"))) {
- mSillyFacesGrid.setItemChecked(i, true);
- return;
- }
- }
-
- for (int i = 0; i < mBackgroundItem.size(); i++) {
- if (value.equals(mBackgroundItem.get(i).get("value"))) {
- mBackgroundGrid.setItemChecked(i, true);
- return;
- }
- }
-
- Log.e(TAG, "Invalid preference value: " + value);
- mPreference.print();
- }
-
- public void setSettingChangedListener(Listener listener) {
- mListener = listener;
- }
-
- @Override
- public void onItemClick(AdapterView<?> parent, View view,
- int index, long id) {
- String value;
- if (parent == mSillyFacesGrid) {
- value = (String) mSillyFacesItem.get(index).get("value");
- } else if (parent == mBackgroundGrid) {
- value = (String) mBackgroundItem.get(index).get("value");
- } else {
- return;
- }
-
- // Tapping the selected effect will deselect it (clear effects).
- if (value.equals(mPreference.getValue())) {
- mPreference.setValue(mNoEffect);
- } else {
- mPreference.setValue(value);
- }
- reloadPreference();
- if (mListener != null) mListener.onSettingChanged();
- }
-
- @Override
- public void onClick(View v) {
- // Clear the effect.
- mPreference.setValue(mNoEffect);
- reloadPreference();
- if (mListener != null) mListener.onSettingChanged();
- }
-}
diff --git a/src/com/android/camera/ui/ExpandedGridView.java b/src/com/android/camera/ui/ExpandedGridView.java
deleted file mode 100644
index 13cf58f..0000000
--- a/src/com/android/camera/ui/ExpandedGridView.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.GridView;
-
-public class ExpandedGridView extends GridView {
- public ExpandedGridView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- // If UNSPECIFIED is passed to GridView, it will show only one row.
- // Here GridView is put in a ScrollView, so pass it a very big size with
- // AT_MOST to show all the rows.
- heightMeasureSpec = MeasureSpec.makeMeasureSpec(65536, MeasureSpec.AT_MOST);
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
-}
diff --git a/src/com/android/camera/ui/FaceView.java b/src/com/android/camera/ui/FaceView.java
deleted file mode 100644
index f4dd823..0000000
--- a/src/com/android/camera/ui/FaceView.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.RectF;
-import android.hardware.Camera.Face;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-
-import com.android.camera.CameraActivity;
-import com.android.camera.CameraScreenNail;
-import com.android.camera.Util;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-@TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
-public class FaceView extends View
- implements FocusIndicator, Rotatable {
- private static final String TAG = "CAM FaceView";
- private final boolean LOGV = false;
- // The value for android.hardware.Camera.setDisplayOrientation.
- private int mDisplayOrientation;
- // The orientation compensation for the face indicator to make it look
- // correctly in all device orientations. Ex: if the value is 90, the
- // indicator should be rotated 90 degrees counter-clockwise.
- private int mOrientation;
- private boolean mMirror;
- private boolean mPause;
- private Matrix mMatrix = new Matrix();
- private RectF mRect = new RectF();
- // As face detection can be flaky, we add a layer of filtering on top of it
- // to avoid rapid changes in state (eg, flickering between has faces and
- // not having faces)
- private Face[] mFaces;
- private Face[] mPendingFaces;
- private int mColor;
- private final int mFocusingColor;
- private final int mFocusedColor;
- private final int mFailColor;
- private Paint mPaint;
- private volatile boolean mBlocked;
-
- private int mUncroppedWidth;
- private int mUncroppedHeight;
- private static final int MSG_SWITCH_FACES = 1;
- private static final int SWITCH_DELAY = 70;
- private boolean mStateSwitchPending = false;
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_SWITCH_FACES:
- mStateSwitchPending = false;
- mFaces = mPendingFaces;
- invalidate();
- break;
- }
- }
- };
-
- public FaceView(Context context, AttributeSet attrs) {
- super(context, attrs);
- Resources res = getResources();
- mFocusingColor = res.getColor(R.color.face_detect_start);
- mFocusedColor = res.getColor(R.color.face_detect_success);
- mFailColor = res.getColor(R.color.face_detect_fail);
- mColor = mFocusingColor;
- mPaint = new Paint();
- mPaint.setAntiAlias(true);
- mPaint.setStyle(Style.STROKE);
- mPaint.setStrokeWidth(res.getDimension(R.dimen.face_circle_stroke));
- }
-
- public void setFaces(Face[] faces) {
- if (LOGV) Log.v(TAG, "Num of faces=" + faces.length);
- if (mPause) return;
- if (mFaces != null) {
- if ((faces.length > 0 && mFaces.length == 0)
- || (faces.length == 0 && mFaces.length > 0)) {
- mPendingFaces = faces;
- if (!mStateSwitchPending) {
- mStateSwitchPending = true;
- mHandler.sendEmptyMessageDelayed(MSG_SWITCH_FACES, SWITCH_DELAY);
- }
- return;
- }
- }
- if (mStateSwitchPending) {
- mStateSwitchPending = false;
- mHandler.removeMessages(MSG_SWITCH_FACES);
- }
- mFaces = faces;
- invalidate();
- }
-
- public void setDisplayOrientation(int orientation) {
- mDisplayOrientation = orientation;
- if (LOGV) Log.v(TAG, "mDisplayOrientation=" + orientation);
- }
-
- @Override
- public void setOrientation(int orientation, boolean animation) {
- mOrientation = orientation;
- invalidate();
- }
-
- public void setMirror(boolean mirror) {
- mMirror = mirror;
- if (LOGV) Log.v(TAG, "mMirror=" + mirror);
- }
-
- public boolean faceExists() {
- return (mFaces != null && mFaces.length > 0);
- }
-
- @Override
- public void showStart() {
- mColor = mFocusingColor;
- invalidate();
- }
-
- // Ignore the parameter. No autofocus animation for face detection.
- @Override
- public void showSuccess(boolean timeout) {
- mColor = mFocusedColor;
- invalidate();
- }
-
- // Ignore the parameter. No autofocus animation for face detection.
- @Override
- public void showFail(boolean timeout) {
- mColor = mFailColor;
- invalidate();
- }
-
- @Override
- public void clear() {
- // Face indicator is displayed during preview. Do not clear the
- // drawable.
- mColor = mFocusingColor;
- mFaces = null;
- invalidate();
- }
-
- public void pause() {
- mPause = true;
- }
-
- public void resume() {
- mPause = false;
- }
-
- public void setBlockDraw(boolean block) {
- mBlocked = block;
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- if (!mBlocked && (mFaces != null) && (mFaces.length > 0)) {
- int rw, rh;
- if (mUncroppedWidth == 0) {
- // TODO: This check is temporary. It needs to be removed after the
- // refactoring is fully functioning.
- final CameraScreenNail sn = ((CameraActivity) getContext()).getCameraScreenNail();
- rw = sn.getUncroppedRenderWidth();
- rh = sn.getUncroppedRenderHeight();
- } else {
- rw = mUncroppedWidth;
- rh = mUncroppedHeight;
- }
- // Prepare the matrix.
- if (((rh > rw) && ((mDisplayOrientation == 0) || (mDisplayOrientation == 180)))
- || ((rw > rh) && ((mDisplayOrientation == 90) || (mDisplayOrientation == 270)))) {
- int temp = rw;
- rw = rh;
- rh = temp;
- }
- Util.prepareMatrix(mMatrix, mMirror, mDisplayOrientation, rw, rh);
- int dx = (getWidth() - rw) / 2;
- int dy = (getHeight() - rh) / 2;
-
- // Focus indicator is directional. Rotate the matrix and the canvas
- // so it looks correctly in all orientations.
- canvas.save();
- mMatrix.postRotate(mOrientation); // postRotate is clockwise
- canvas.rotate(-mOrientation); // rotate is counter-clockwise (for canvas)
- for (int i = 0; i < mFaces.length; i++) {
- // Filter out false positives.
- if (mFaces[i].score < 50) continue;
-
- // Transform the coordinates.
- mRect.set(mFaces[i].rect);
- if (LOGV) Util.dumpRect(mRect, "Original rect");
- mMatrix.mapRect(mRect);
- if (LOGV) Util.dumpRect(mRect, "Transformed rect");
- mPaint.setColor(mColor);
- mRect.offset(dx, dy);
- canvas.drawOval(mRect, mPaint);
- }
- canvas.restore();
- }
- super.onDraw(canvas);
- }
-}
diff --git a/src/com/android/camera/ui/FocusIndicator.java b/src/com/android/camera/ui/FocusIndicator.java
deleted file mode 100644
index e060570..0000000
--- a/src/com/android/camera/ui/FocusIndicator.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-public interface FocusIndicator {
- public void showStart();
- public void showSuccess(boolean timeout);
- public void showFail(boolean timeout);
- public void clear();
-}
diff --git a/src/com/android/camera/ui/InLineSettingCheckBox.java b/src/com/android/camera/ui/InLineSettingCheckBox.java
deleted file mode 100644
index c1aa5a9..0000000
--- a/src/com/android/camera/ui/InLineSettingCheckBox.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.accessibility.AccessibilityEvent;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-
-
-import com.android.camera.ListPreference;
-import com.android.gallery3d.R;
-
-/* A check box setting control which turns on/off the setting. */
-public class InLineSettingCheckBox extends InLineSettingItem {
- private CheckBox mCheckBox;
-
- OnCheckedChangeListener mCheckedChangeListener = new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean desiredState) {
- changeIndex(desiredState ? 1 : 0);
- }
- };
-
- public InLineSettingCheckBox(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mCheckBox = (CheckBox) findViewById(R.id.setting_check_box);
- mCheckBox.setOnCheckedChangeListener(mCheckedChangeListener);
- }
-
- @Override
- public void initialize(ListPreference preference) {
- super.initialize(preference);
- // Add content descriptions for the increment and decrement buttons.
- mCheckBox.setContentDescription(getContext().getResources().getString(
- R.string.accessibility_check_box, mPreference.getTitle()));
- }
-
- @Override
- protected void updateView() {
- mCheckBox.setOnCheckedChangeListener(null);
- if (mOverrideValue == null) {
- mCheckBox.setChecked(mIndex == 1);
- } else {
- int index = mPreference.findIndexOfValue(mOverrideValue);
- mCheckBox.setChecked(index == 1);
- }
- mCheckBox.setOnCheckedChangeListener(mCheckedChangeListener);
- }
-
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- event.getText().add(mPreference.getTitle());
- return true;
- }
-
- @Override
- public void setEnabled(boolean enable) {
- if (mTitle != null) mTitle.setEnabled(enable);
- if (mCheckBox != null) mCheckBox.setEnabled(enable);
- }
-}
diff --git a/src/com/android/camera/ui/InLineSettingItem.java b/src/com/android/camera/ui/InLineSettingItem.java
deleted file mode 100644
index 839a77f..0000000
--- a/src/com/android/camera/ui/InLineSettingItem.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.accessibility.AccessibilityEvent;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.android.camera.ListPreference;
-import com.android.gallery3d.R;
-
-/**
- * A one-line camera setting could be one of three types: knob, switch or restore
- * preference button. The setting includes a title for showing the preference
- * title which is initialized in the SimpleAdapter. A knob also includes
- * (ex: Picture size), a previous button, the current value (ex: 5MP),
- * and a next button. A switch, i.e. the preference RecordLocationPreference,
- * has only two values on and off which will be controlled in a switch button.
- * Other setting popup window includes several InLineSettingItem items with
- * different types if possible.
- */
-public abstract class InLineSettingItem extends LinearLayout {
- private Listener mListener;
- protected ListPreference mPreference;
- protected int mIndex;
- // Scene mode can override the original preference value.
- protected String mOverrideValue;
- protected TextView mTitle;
-
- static public interface Listener {
- public void onSettingChanged(ListPreference pref);
- }
-
- public InLineSettingItem(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- protected void setTitle(ListPreference preference) {
- mTitle = ((TextView) findViewById(R.id.title));
- mTitle.setText(preference.getTitle());
- }
-
- public void initialize(ListPreference preference) {
- setTitle(preference);
- if (preference == null) return;
- mPreference = preference;
- reloadPreference();
- }
-
- protected abstract void updateView();
-
- protected boolean changeIndex(int index) {
- if (index >= mPreference.getEntryValues().length || index < 0) return false;
- mIndex = index;
- mPreference.setValueIndex(mIndex);
- if (mListener != null) {
- mListener.onSettingChanged(mPreference);
- }
- updateView();
- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
- return true;
- }
-
- // The value of the preference may have changed. Update the UI.
- public void reloadPreference() {
- mIndex = mPreference.findIndexOfValue(mPreference.getValue());
- updateView();
- }
-
- public void setSettingChangedListener(Listener listener) {
- mListener = listener;
- }
-
- public void overrideSettings(String value) {
- mOverrideValue = value;
- updateView();
- }
-}
diff --git a/src/com/android/camera/ui/InLineSettingMenu.java b/src/com/android/camera/ui/InLineSettingMenu.java
deleted file mode 100644
index 8e45c3e..0000000
--- a/src/com/android/camera/ui/InLineSettingMenu.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.accessibility.AccessibilityEvent;
-import android.widget.TextView;
-
-import com.android.camera.ListPreference;
-import com.android.gallery3d.R;
-
-/* Setting menu item that will bring up a menu when you click on it. */
-public class InLineSettingMenu extends InLineSettingItem {
- private static final String TAG = "InLineSettingMenu";
- // The view that shows the current selected setting. Ex: 5MP
- private TextView mEntry;
-
- public InLineSettingMenu(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mEntry = (TextView) findViewById(R.id.current_setting);
- }
-
- @Override
- public void initialize(ListPreference preference) {
- super.initialize(preference);
- //TODO: add contentDescription
- }
-
- @Override
- protected void updateView() {
- if (mOverrideValue == null) {
- mEntry.setText(mPreference.getEntry());
- } else {
- int index = mPreference.findIndexOfValue(mOverrideValue);
- if (index != -1) {
- mEntry.setText(mPreference.getEntries()[index]);
- } else {
- // Avoid the crash if camera driver has bugs.
- Log.e(TAG, "Fail to find override value=" + mOverrideValue);
- mPreference.print();
- }
- }
- }
-
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- event.getText().add(mPreference.getTitle() + mPreference.getEntry());
- return true;
- }
-
- @Override
- public void setEnabled(boolean enable) {
- super.setEnabled(enable);
- if (mTitle != null) mTitle.setEnabled(enable);
- if (mEntry != null) mEntry.setEnabled(enable);
- }
-}
diff --git a/src/com/android/camera/ui/LayoutChangeHelper.java b/src/com/android/camera/ui/LayoutChangeHelper.java
deleted file mode 100644
index ef4eb6a..0000000
--- a/src/com/android/camera/ui/LayoutChangeHelper.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.view.View;
-
-public class LayoutChangeHelper implements LayoutChangeNotifier {
- private LayoutChangeNotifier.Listener mListener;
- private boolean mFirstTimeLayout;
- private View mView;
-
- public LayoutChangeHelper(View v) {
- mView = v;
- mFirstTimeLayout = true;
- }
-
- @Override
- public void setOnLayoutChangeListener(LayoutChangeNotifier.Listener listener) {
- mListener = listener;
- }
-
- public void onLayout(boolean changed, int l, int t, int r, int b) {
- if (mListener == null) return;
- if (mFirstTimeLayout || changed) {
- mFirstTimeLayout = false;
- mListener.onLayoutChange(mView, l, t, r, b);
- }
- }
-}
diff --git a/src/com/android/camera/ui/LayoutChangeNotifier.java b/src/com/android/camera/ui/LayoutChangeNotifier.java
deleted file mode 100644
index 6261d34..0000000
--- a/src/com/android/camera/ui/LayoutChangeNotifier.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.view.View;
-
-public interface LayoutChangeNotifier {
- public interface Listener {
- // Invoked only when the layout has changed or it is the first layout.
- public void onLayoutChange(View v, int l, int t, int r, int b);
- }
-
- public void setOnLayoutChangeListener(LayoutChangeNotifier.Listener listener);
-}
diff --git a/src/com/android/camera/ui/LayoutNotifyView.java b/src/com/android/camera/ui/LayoutNotifyView.java
deleted file mode 100644
index 6e118fc..0000000
--- a/src/com/android/camera/ui/LayoutNotifyView.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-
-/*
- * Customized view to support onLayoutChange() at or before API 10.
- */
-public class LayoutNotifyView extends View implements LayoutChangeNotifier {
- private LayoutChangeHelper mLayoutChangeHelper = new LayoutChangeHelper(this);
-
- public LayoutNotifyView(Context context) {
- super(context);
- }
-
- public LayoutNotifyView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- public void setOnLayoutChangeListener(
- LayoutChangeNotifier.Listener listener) {
- mLayoutChangeHelper.setOnLayoutChangeListener(listener);
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- super.onLayout(changed, l, t, r, b);
- mLayoutChangeHelper.onLayout(changed, l, t, r, b);
- }
-}
diff --git a/src/com/android/camera/ui/ListPrefSettingPopup.java b/src/com/android/camera/ui/ListPrefSettingPopup.java
deleted file mode 100644
index cfef73f..0000000
--- a/src/com/android/camera/ui/ListPrefSettingPopup.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.AdapterView;
-import android.widget.ImageView;
-import android.widget.SimpleAdapter;
-
-import com.android.camera.IconListPreference;
-import com.android.camera.ListPreference;
-import com.android.gallery3d.R;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-// A popup window that shows one camera setting. The title is the name of the
-// setting (ex: white-balance). The entries are the supported values (ex:
-// daylight, incandescent, etc). If initialized with an IconListPreference,
-// the entries will contain both text and icons. Otherwise, entries will be
-// shown in text.
-public class ListPrefSettingPopup extends AbstractSettingPopup implements
- AdapterView.OnItemClickListener {
- private static final String TAG = "ListPrefSettingPopup";
- private ListPreference mPreference;
- private Listener mListener;
-
- static public interface Listener {
- public void onListPrefChanged(ListPreference pref);
- }
-
- public ListPrefSettingPopup(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- private class ListPrefSettingAdapter extends SimpleAdapter {
- ListPrefSettingAdapter(Context context, List<? extends Map<String, ?>> data,
- int resource, String[] from, int[] to) {
- super(context, data, resource, from, to);
- }
-
- @Override
- public void setViewImage(ImageView v, String value) {
- if ("".equals(value)) {
- // Some settings have no icons. Ex: exposure compensation.
- v.setVisibility(View.GONE);
- } else {
- super.setViewImage(v, value);
- }
- }
- }
-
- public void initialize(ListPreference preference) {
- mPreference = preference;
- Context context = getContext();
- CharSequence[] entries = mPreference.getEntries();
- int[] iconIds = null;
- if (preference instanceof IconListPreference) {
- iconIds = ((IconListPreference) mPreference).getImageIds();
- if (iconIds == null) {
- iconIds = ((IconListPreference) mPreference).getLargeIconIds();
- }
- }
- // Set title.
- mTitle.setText(mPreference.getTitle());
-
- // Prepare the ListView.
- ArrayList<HashMap<String, Object>> listItem =
- new ArrayList<HashMap<String, Object>>();
- for(int i = 0; i < entries.length; ++i) {
- HashMap<String, Object> map = new HashMap<String, Object>();
- map.put("text", entries[i].toString());
- if (iconIds != null) map.put("image", iconIds[i]);
- listItem.add(map);
- }
- SimpleAdapter listItemAdapter = new ListPrefSettingAdapter(context, listItem,
- R.layout.setting_item,
- new String[] {"text", "image"},
- new int[] {R.id.text, R.id.image});
- ((ListView) mSettingList).setAdapter(listItemAdapter);
- ((ListView) mSettingList).setOnItemClickListener(this);
- reloadPreference();
- }
-
- // The value of the preference may have changed. Update the UI.
- @Override
- public void reloadPreference() {
- int index = mPreference.findIndexOfValue(mPreference.getValue());
- if (index != -1) {
- ((ListView) mSettingList).setItemChecked(index, true);
- } else {
- Log.e(TAG, "Invalid preference value.");
- mPreference.print();
- }
- }
-
- public void setSettingChangedListener(Listener listener) {
- mListener = listener;
- }
-
- @Override
- public void onItemClick(AdapterView<?> parent, View view,
- int index, long id) {
- mPreference.setValueIndex(index);
- if (mListener != null) mListener.onListPrefChanged(mPreference);
- }
-}
diff --git a/src/com/android/camera/ui/MoreSettingPopup.java b/src/com/android/camera/ui/MoreSettingPopup.java
deleted file mode 100644
index 5900058..0000000
--- a/src/com/android/camera/ui/MoreSettingPopup.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-import com.android.camera.ListPreference;
-import com.android.camera.PreferenceGroup;
-import com.android.gallery3d.R;
-
-import java.util.ArrayList;
-
-/* A popup window that contains several camera settings. */
-public class MoreSettingPopup extends AbstractSettingPopup
- implements InLineSettingItem.Listener,
- AdapterView.OnItemClickListener {
- @SuppressWarnings("unused")
- private static final String TAG = "MoreSettingPopup";
-
- private Listener mListener;
- private ArrayList<ListPreference> mListItem = new ArrayList<ListPreference>();
-
- // Keep track of which setting items are disabled
- // e.g. White balance will be disabled when scene mode is set to non-auto
- private boolean[] mEnabled;
-
- static public interface Listener {
- public void onSettingChanged(ListPreference pref);
- public void onPreferenceClicked(ListPreference pref);
- }
-
- private class MoreSettingAdapter extends ArrayAdapter<ListPreference> {
- LayoutInflater mInflater;
- String mOnString;
- String mOffString;
- MoreSettingAdapter() {
- super(MoreSettingPopup.this.getContext(), 0, mListItem);
- Context context = getContext();
- mInflater = LayoutInflater.from(context);
- mOnString = context.getString(R.string.setting_on);
- mOffString = context.getString(R.string.setting_off);
- }
-
- private int getSettingLayoutId(ListPreference pref) {
-
- if (isOnOffPreference(pref)) {
- return R.layout.in_line_setting_check_box;
- }
- return R.layout.in_line_setting_menu;
- }
-
- private boolean isOnOffPreference(ListPreference pref) {
- CharSequence[] entries = pref.getEntries();
- if (entries.length != 2) return false;
- String str1 = entries[0].toString();
- String str2 = entries[1].toString();
- return ((str1.equals(mOnString) && str2.equals(mOffString)) ||
- (str1.equals(mOffString) && str2.equals(mOnString)));
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView != null) return convertView;
-
- ListPreference pref = mListItem.get(position);
-
- int viewLayoutId = getSettingLayoutId(pref);
- InLineSettingItem view = (InLineSettingItem)
- mInflater.inflate(viewLayoutId, parent, false);
-
- view.initialize(pref); // no init for restore one
- view.setSettingChangedListener(MoreSettingPopup.this);
- if (position >= 0 && position < mEnabled.length) {
- view.setEnabled(mEnabled[position]);
- } else {
- Log.w(TAG, "Invalid input: enabled list length, " + mEnabled.length
- + " position " + position);
- }
- return view;
- }
-
- @Override
- public boolean isEnabled(int position) {
- if (position >= 0 && position < mEnabled.length) {
- return mEnabled[position];
- }
- return true;
- }
- }
-
- public void setSettingChangedListener(Listener listener) {
- mListener = listener;
- }
-
- public MoreSettingPopup(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void initialize(PreferenceGroup group, String[] keys) {
- // Prepare the setting items.
- for (int i = 0; i < keys.length; ++i) {
- ListPreference pref = group.findPreference(keys[i]);
- if (pref != null) mListItem.add(pref);
- }
-
- ArrayAdapter<ListPreference> mListItemAdapter = new MoreSettingAdapter();
- ((ListView) mSettingList).setAdapter(mListItemAdapter);
- ((ListView) mSettingList).setOnItemClickListener(this);
- ((ListView) mSettingList).setSelector(android.R.color.transparent);
- // Initialize mEnabled
- mEnabled = new boolean[mListItem.size()];
- for (int i = 0; i < mEnabled.length; i++) {
- mEnabled[i] = true;
- }
- }
-
- // When preferences are disabled, we will display them grayed out. Users
- // will not be able to change the disabled preferences, but they can still see
- // the current value of the preferences
- public void setPreferenceEnabled(String key, boolean enable) {
- int count = mEnabled == null ? 0 : mEnabled.length;
- for (int j = 0; j < count; j++) {
- ListPreference pref = mListItem.get(j);
- if (pref != null && key.equals(pref.getKey())) {
- mEnabled[j] = enable;
- break;
- }
- }
- }
-
- public void onSettingChanged(ListPreference pref) {
- if (mListener != null) {
- mListener.onSettingChanged(pref);
- }
- }
-
- // Scene mode can override other camera settings (ex: flash mode).
- public void overrideSettings(final String ... keyvalues) {
- int count = mEnabled == null ? 0 : mEnabled.length;
- for (int i = 0; i < keyvalues.length; i += 2) {
- String key = keyvalues[i];
- String value = keyvalues[i + 1];
- for (int j = 0; j < count; j++) {
- ListPreference pref = mListItem.get(j);
- if (pref != null && key.equals(pref.getKey())) {
- // Change preference
- if (value != null) pref.setValue(value);
- // If the preference is overridden, disable the preference
- boolean enable = value == null;
- mEnabled[j] = enable;
- if (mSettingList.getChildCount() > j) {
- mSettingList.getChildAt(j).setEnabled(enable);
- }
- }
- }
- }
- reloadPreference();
- }
-
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position,
- long id) {
- if (mListener != null) {
- ListPreference pref = mListItem.get(position);
- mListener.onPreferenceClicked(pref);
- }
- }
-
- @Override
- public void reloadPreference() {
- int count = mSettingList.getChildCount();
- for (int i = 0; i < count; i++) {
- ListPreference pref = mListItem.get(i);
- if (pref != null) {
- InLineSettingItem settingItem =
- (InLineSettingItem) mSettingList.getChildAt(i);
- settingItem.reloadPreference();
- }
- }
- }
-}
diff --git a/src/com/android/camera/ui/OnIndicatorEventListener.java b/src/com/android/camera/ui/OnIndicatorEventListener.java
deleted file mode 100644
index 566f5c7..0000000
--- a/src/com/android/camera/ui/OnIndicatorEventListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-public interface OnIndicatorEventListener {
- public static int EVENT_ENTER_SECOND_LEVEL_INDICATOR_BAR = 0;
- public static int EVENT_LEAVE_SECOND_LEVEL_INDICATOR_BAR = 1;
- public static int EVENT_ENTER_ZOOM_CONTROL = 2;
- public static int EVENT_LEAVE_ZOOM_CONTROL = 3;
- void onIndicatorEvent(int event);
-}
diff --git a/src/com/android/camera/ui/OverlayRenderer.java b/src/com/android/camera/ui/OverlayRenderer.java
deleted file mode 100644
index 417e219..0000000
--- a/src/com/android/camera/ui/OverlayRenderer.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.view.MotionEvent;
-
-public abstract class OverlayRenderer implements RenderOverlay.Renderer {
-
- private static final String TAG = "CAM OverlayRenderer";
- protected RenderOverlay mOverlay;
-
- protected int mLeft, mTop, mRight, mBottom;
-
- protected boolean mVisible;
-
- public void setVisible(boolean vis) {
- mVisible = vis;
- update();
- }
-
- public boolean isVisible() {
- return mVisible;
- }
-
- // default does not handle touch
- @Override
- public boolean handlesTouch() {
- return false;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent evt) {
- return false;
- }
-
- public abstract void onDraw(Canvas canvas);
-
- public void draw(Canvas canvas) {
- if (mVisible) {
- onDraw(canvas);
- }
- }
-
- @Override
- public void setOverlay(RenderOverlay overlay) {
- mOverlay = overlay;
- }
-
- @Override
- public void layout(int left, int top, int right, int bottom) {
- mLeft = left;
- mRight = right;
- mTop = top;
- mBottom = bottom;
- }
-
- protected Context getContext() {
- if (mOverlay != null) {
- return mOverlay.getContext();
- } else {
- return null;
- }
- }
-
- public int getWidth() {
- return mRight - mLeft;
- }
-
- public int getHeight() {
- return mBottom - mTop;
- }
-
- protected void update() {
- if (mOverlay != null) {
- mOverlay.update();
- }
- }
-
-}
diff --git a/src/com/android/camera/ui/PieItem.java b/src/com/android/camera/ui/PieItem.java
deleted file mode 100644
index 47fe067..0000000
--- a/src/com/android/camera/ui/PieItem.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Path;
-import android.graphics.drawable.Drawable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Pie menu item
- */
-public class PieItem {
-
- public static interface OnClickListener {
- void onClick(PieItem item);
- }
-
- private Drawable mDrawable;
- private int level;
-
- private boolean mSelected;
- private boolean mEnabled;
- private List<PieItem> mItems;
- private Path mPath;
- private OnClickListener mOnClickListener;
- private float mAlpha;
- private CharSequence mLabel;
-
- // Gray out the view when disabled
- private static final float ENABLED_ALPHA = 1;
- private static final float DISABLED_ALPHA = (float) 0.3;
- private boolean mChangeAlphaWhenDisabled = true;
-
- public PieItem(Drawable drawable, int level) {
- mDrawable = drawable;
- this.level = level;
- if (drawable != null) {
- setAlpha(1f);
- }
- mEnabled = true;
- }
-
- public void setLabel(CharSequence txt) {
- mLabel = txt;
- }
-
- public CharSequence getLabel() {
- return mLabel;
- }
-
- public boolean hasItems() {
- return mItems != null;
- }
-
- public List<PieItem> getItems() {
- return mItems;
- }
-
- public void addItem(PieItem item) {
- if (mItems == null) {
- mItems = new ArrayList<PieItem>();
- }
- mItems.add(item);
- }
-
- public void clearItems() {
- mItems = null;
- }
-
- public void setLevel(int level) {
- this.level = level;
- }
-
- public void setPath(Path p) {
- mPath = p;
- }
-
- public Path getPath() {
- return mPath;
- }
-
- public void setChangeAlphaWhenDisabled (boolean enable) {
- mChangeAlphaWhenDisabled = enable;
- }
-
- public void setAlpha(float alpha) {
- mAlpha = alpha;
- mDrawable.setAlpha((int) (255 * alpha));
- }
-
- public void setEnabled(boolean enabled) {
- mEnabled = enabled;
- if (mChangeAlphaWhenDisabled) {
- if (mEnabled) {
- setAlpha(ENABLED_ALPHA);
- } else {
- setAlpha(DISABLED_ALPHA);
- }
- }
- }
-
- public boolean isEnabled() {
- return mEnabled;
- }
-
- public void setSelected(boolean s) {
- mSelected = s;
- }
-
- public boolean isSelected() {
- return mSelected;
- }
-
- public int getLevel() {
- return level;
- }
-
-
- public void setOnClickListener(OnClickListener listener) {
- mOnClickListener = listener;
- }
-
- public void performClick() {
- if (mOnClickListener != null) {
- mOnClickListener.onClick(this);
- }
- }
-
- public int getIntrinsicWidth() {
- return mDrawable.getIntrinsicWidth();
- }
-
- public int getIntrinsicHeight() {
- return mDrawable.getIntrinsicHeight();
- }
-
- public void setBounds(int left, int top, int right, int bottom) {
- mDrawable.setBounds(left, top, right, bottom);
- }
-
- public void draw(Canvas canvas) {
- mDrawable.draw(canvas);
- }
-
- public void setImageResource(Context context, int resId) {
- Drawable d = context.getResources().getDrawable(resId).mutate();
- d.setBounds(mDrawable.getBounds());
- mDrawable = d;
- setAlpha(mAlpha);
- }
-
-}
diff --git a/src/com/android/camera/ui/PieMenuButton.java b/src/com/android/camera/ui/PieMenuButton.java
deleted file mode 100644
index e571931..0000000
--- a/src/com/android/camera/ui/PieMenuButton.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-
-public class PieMenuButton extends View {
- private boolean mPressed;
- private boolean mReadyToClick = false;
- public PieMenuButton(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void drawableStateChanged() {
- super.drawableStateChanged();
- mPressed = isPressed();
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (MotionEvent.ACTION_UP == event.getAction() && mPressed) {
- // Perform a customized click as soon as the ACTION_UP event
- // is received. The reason for doing this is that Framework
- // delays the performClick() call after ACTION_UP. But we do not
- // want the delay because it affects an important state change
- // for PieRenderer.
- mReadyToClick = true;
- performClick();
- }
- return super.onTouchEvent(event);
- }
-
- @Override
- public boolean performClick() {
- if (mReadyToClick) {
- // We only respond to our customized click which happens right
- // after ACTION_UP event is received, with no delay.
- mReadyToClick = false;
- return super.performClick();
- }
- return false;
- }
-};
\ No newline at end of file
diff --git a/src/com/android/camera/ui/PieRenderer.java b/src/com/android/camera/ui/PieRenderer.java
deleted file mode 100644
index edae2be..0000000
--- a/src/com/android/camera/ui/PieRenderer.java
+++ /dev/null
@@ -1,1104 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.Point;
-import android.graphics.PointF;
-import android.graphics.RectF;
-import android.os.Handler;
-import android.os.Message;
-import android.util.FloatMath;
-import android.view.MotionEvent;
-import android.view.ViewConfiguration;
-import android.view.animation.Animation;
-import android.view.animation.Animation.AnimationListener;
-import android.view.animation.LinearInterpolator;
-import android.view.animation.Transformation;
-
-import com.android.camera.drawable.TextDrawable;
-import com.android.gallery3d.R;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class PieRenderer extends OverlayRenderer
- implements FocusIndicator {
-
- private static final String TAG = "CAM Pie";
-
- // Sometimes continuous autofocus starts and stops several times quickly.
- // These states are used to make sure the animation is run for at least some
- // time.
- private volatile int mState;
- private ScaleAnimation mAnimation = new ScaleAnimation();
- private static final int STATE_IDLE = 0;
- private static final int STATE_FOCUSING = 1;
- private static final int STATE_FINISHING = 2;
- private static final int STATE_PIE = 8;
-
- private static final float MATH_PI_2 = (float)(Math.PI / 2);
-
- private Runnable mDisappear = new Disappear();
- private Animation.AnimationListener mEndAction = new EndAction();
- private static final int SCALING_UP_TIME = 600;
- private static final int SCALING_DOWN_TIME = 100;
- private static final int DISAPPEAR_TIMEOUT = 200;
- private static final int DIAL_HORIZONTAL = 157;
- // fade out timings
- private static final int PIE_FADE_OUT_DURATION = 600;
-
- private static final long PIE_FADE_IN_DURATION = 200;
- private static final long PIE_XFADE_DURATION = 200;
- private static final long PIE_SELECT_FADE_DURATION = 300;
- private static final long PIE_OPEN_SUB_DELAY = 400;
- private static final long PIE_SLICE_DURATION = 80;
-
- private static final int MSG_OPEN = 0;
- private static final int MSG_CLOSE = 1;
- private static final int MSG_OPENSUBMENU = 2;
-
- protected static float CENTER = (float) Math.PI / 2;
- protected static float RAD24 = (float)(24 * Math.PI / 180);
- protected static final float SWEEP_SLICE = 0.14f;
- protected static final float SWEEP_ARC = 0.23f;
-
- // geometry
- private int mRadius;
- private int mRadiusInc;
-
- // the detection if touch is inside a slice is offset
- // inbounds by this amount to allow the selection to show before the
- // finger covers it
- private int mTouchOffset;
-
- private List<PieItem> mOpen;
-
- private Paint mSelectedPaint;
- private Paint mSubPaint;
- private Paint mMenuArcPaint;
-
- // touch handling
- private PieItem mCurrentItem;
-
- private Paint mFocusPaint;
- private int mSuccessColor;
- private int mFailColor;
- private int mCircleSize;
- private int mFocusX;
- private int mFocusY;
- private int mCenterX;
- private int mCenterY;
- private int mArcCenterY;
- private int mSliceCenterY;
- private int mPieCenterX;
- private int mPieCenterY;
- private int mSliceRadius;
- private int mArcRadius;
- private int mArcOffset;
-
- private int mDialAngle;
- private RectF mCircle;
- private RectF mDial;
- private Point mPoint1;
- private Point mPoint2;
- private int mStartAnimationAngle;
- private boolean mFocused;
- private int mInnerOffset;
- private int mOuterStroke;
- private int mInnerStroke;
- private boolean mTapMode;
- private boolean mBlockFocus;
- private int mTouchSlopSquared;
- private Point mDown;
- private boolean mOpening;
- private LinearAnimation mXFade;
- private LinearAnimation mFadeIn;
- private FadeOutAnimation mFadeOut;
- private LinearAnimation mSlice;
- private volatile boolean mFocusCancelled;
- private PointF mPolar = new PointF();
- private TextDrawable mLabel;
- private int mDeadZone;
- private int mAngleZone;
- private float mCenterAngle;
-
-
-
- private Handler mHandler = new Handler() {
- public void handleMessage(Message msg) {
- switch(msg.what) {
- case MSG_OPEN:
- if (mListener != null) {
- mListener.onPieOpened(mPieCenterX, mPieCenterY);
- }
- break;
- case MSG_CLOSE:
- if (mListener != null) {
- mListener.onPieClosed();
- }
- break;
- case MSG_OPENSUBMENU:
- onEnterOpen();
- break;
- }
-
- }
- };
-
- private PieListener mListener;
-
- static public interface PieListener {
- public void onPieOpened(int centerX, int centerY);
- public void onPieClosed();
- }
-
- public void setPieListener(PieListener pl) {
- mListener = pl;
- }
-
- public PieRenderer(Context context) {
- init(context);
- }
-
- private void init(Context ctx) {
- setVisible(false);
- mOpen = new ArrayList<PieItem>();
- mOpen.add(new PieItem(null, 0));
- Resources res = ctx.getResources();
- mRadius = (int) res.getDimensionPixelSize(R.dimen.pie_radius_start);
- mRadiusInc = (int) res.getDimensionPixelSize(R.dimen.pie_radius_increment);
- mCircleSize = mRadius - res.getDimensionPixelSize(R.dimen.focus_radius_offset);
- mTouchOffset = (int) res.getDimensionPixelSize(R.dimen.pie_touch_offset);
- mSelectedPaint = new Paint();
- mSelectedPaint.setColor(Color.argb(255, 51, 181, 229));
- mSelectedPaint.setAntiAlias(true);
- mSubPaint = new Paint();
- mSubPaint.setAntiAlias(true);
- mSubPaint.setColor(Color.argb(200, 250, 230, 128));
- mFocusPaint = new Paint();
- mFocusPaint.setAntiAlias(true);
- mFocusPaint.setColor(Color.WHITE);
- mFocusPaint.setStyle(Paint.Style.STROKE);
- mSuccessColor = Color.GREEN;
- mFailColor = Color.RED;
- mCircle = new RectF();
- mDial = new RectF();
- mPoint1 = new Point();
- mPoint2 = new Point();
- mInnerOffset = res.getDimensionPixelSize(R.dimen.focus_inner_offset);
- mOuterStroke = res.getDimensionPixelSize(R.dimen.focus_outer_stroke);
- mInnerStroke = res.getDimensionPixelSize(R.dimen.focus_inner_stroke);
- mState = STATE_IDLE;
- mBlockFocus = false;
- mTouchSlopSquared = ViewConfiguration.get(ctx).getScaledTouchSlop();
- mTouchSlopSquared = mTouchSlopSquared * mTouchSlopSquared;
- mDown = new Point();
- mMenuArcPaint = new Paint();
- mMenuArcPaint.setAntiAlias(true);
- mMenuArcPaint.setColor(Color.argb(140, 255, 255, 255));
- mMenuArcPaint.setStrokeWidth(10);
- mMenuArcPaint.setStyle(Paint.Style.STROKE);
- mSliceRadius = res.getDimensionPixelSize(R.dimen.pie_item_radius);
- mArcRadius = res.getDimensionPixelSize(R.dimen.pie_arc_radius);
- mArcOffset = res.getDimensionPixelSize(R.dimen.pie_arc_offset);
- mLabel = new TextDrawable(res);
- mLabel.setDropShadow(true);
- mDeadZone = res.getDimensionPixelSize(R.dimen.pie_deadzone_width);
- mAngleZone = res.getDimensionPixelSize(R.dimen.pie_anglezone_width);
- }
-
- private PieItem getRoot() {
- return mOpen.get(0);
- }
-
- public boolean showsItems() {
- return mTapMode;
- }
-
- public void addItem(PieItem item) {
- // add the item to the pie itself
- getRoot().addItem(item);
- }
-
- public void clearItems() {
- getRoot().clearItems();
- }
-
- public void showInCenter() {
- if ((mState == STATE_PIE) && isVisible()) {
- mTapMode = false;
- show(false);
- } else {
- if (mState != STATE_IDLE) {
- cancelFocus();
- }
- mState = STATE_PIE;
- resetPieCenter();
- setCenter(mPieCenterX, mPieCenterY);
- mTapMode = true;
- show(true);
- }
- }
-
- public void hide() {
- show(false);
- }
-
- /**
- * guaranteed has center set
- * @param show
- */
- private void show(boolean show) {
- if (show) {
- if (mXFade != null) {
- mXFade.cancel();
- }
- mState = STATE_PIE;
- // ensure clean state
- mCurrentItem = null;
- PieItem root = getRoot();
- for (PieItem openItem : mOpen) {
- if (openItem.hasItems()) {
- for (PieItem item : openItem.getItems()) {
- item.setSelected(false);
- }
- }
- }
- mLabel.setText("");
- mOpen.clear();
- mOpen.add(root);
- layoutPie();
- fadeIn();
- } else {
- mState = STATE_IDLE;
- mTapMode = false;
- if (mXFade != null) {
- mXFade.cancel();
- }
- if (mLabel != null) {
- mLabel.setText("");
- }
- }
- setVisible(show);
- mHandler.sendEmptyMessage(show ? MSG_OPEN : MSG_CLOSE);
- }
-
- private void fadeIn() {
- mFadeIn = new LinearAnimation(0, 1);
- mFadeIn.setDuration(PIE_FADE_IN_DURATION);
- mFadeIn.setAnimationListener(new AnimationListener() {
- @Override
- public void onAnimationStart(Animation animation) {
- }
-
- @Override
- public void onAnimationEnd(Animation animation) {
- mFadeIn = null;
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
- });
- mFadeIn.startNow();
- mOverlay.startAnimation(mFadeIn);
- }
-
- public void setCenter(int x, int y) {
- mPieCenterX = x;
- mPieCenterY = y;
- mSliceCenterY = y + mSliceRadius - mArcOffset;
- mArcCenterY = y - mArcOffset + mArcRadius;
- }
-
- @Override
- public void layout(int l, int t, int r, int b) {
- super.layout(l, t, r, b);
- mCenterX = (r - l) / 2;
- mCenterY = (b - t) / 2;
-
- mFocusX = mCenterX;
- mFocusY = mCenterY;
- resetPieCenter();
- setCircle(mFocusX, mFocusY);
- if (isVisible() && mState == STATE_PIE) {
- setCenter(mPieCenterX, mPieCenterY);
- layoutPie();
- }
- }
-
- private void resetPieCenter() {
- mPieCenterX = mCenterX;
- mPieCenterY = (int) (getHeight() - 2.5f * mDeadZone);
- }
-
- private void layoutPie() {
- mCenterAngle = getCenterAngle();
- layoutItems(0, getRoot().getItems());
- layoutLabel(getLevel());
- }
-
- private void layoutLabel(int level) {
- int x = mPieCenterX - (int) (FloatMath.sin(mCenterAngle - CENTER)
- * (mArcRadius + (level + 2) * mRadiusInc));
- int y = mArcCenterY - mArcRadius - (level + 2) * mRadiusInc;
- int w = mLabel.getIntrinsicWidth();
- int h = mLabel.getIntrinsicHeight();
- mLabel.setBounds(x - w/2, y - h/2, x + w/2, y + h/2);
- }
-
- private void layoutItems(int level, List<PieItem> items) {
- int extend = 1;
- Path path = makeSlice(getDegrees(0) + extend, getDegrees(SWEEP_ARC) - extend,
- mArcRadius, mArcRadius + mRadiusInc + mRadiusInc / 4,
- mPieCenterX, mArcCenterY - level * mRadiusInc);
- final int count = items.size();
- int pos = 0;
- for (PieItem item : items) {
- // shared between items
- item.setPath(path);
- float angle = getArcCenter(item, pos, count);
- int w = item.getIntrinsicWidth();
- int h = item.getIntrinsicHeight();
- // move views to outer border
- int r = mArcRadius + mRadiusInc * 2 / 3;
- int x = (int) (r * Math.cos(angle));
- int y = mArcCenterY - (level * mRadiusInc) - (int) (r * Math.sin(angle)) - h / 2;
- x = mPieCenterX + x - w / 2;
- item.setBounds(x, y, x + w, y + h);
- item.setLevel(level);
- if (item.hasItems()) {
- layoutItems(level + 1, item.getItems());
- }
- pos++;
- }
- }
-
- private Path makeSlice(float start, float end, int inner, int outer, int cx, int cy) {
- RectF bb =
- new RectF(cx - outer, cy - outer, cx + outer,
- cy + outer);
- RectF bbi =
- new RectF(cx - inner, cy - inner, cx + inner,
- cy + inner);
- Path path = new Path();
- path.arcTo(bb, start, end - start, true);
- path.arcTo(bbi, end, start - end);
- path.close();
- return path;
- }
-
- private float getArcCenter(PieItem item, int pos, int count) {
- return getCenter(pos, count, SWEEP_ARC);
- }
-
- private float getSliceCenter(PieItem item, int pos, int count) {
- float center = (getCenterAngle() - CENTER) * 0.5f + CENTER;
- return center + (count - 1) * SWEEP_SLICE / 2f
- - pos * SWEEP_SLICE;
- }
-
- private float getCenter(int pos, int count, float sweep) {
- return mCenterAngle + (count - 1) * sweep / 2f - pos * sweep;
- }
-
- private float getCenterAngle() {
- float center = CENTER;
- if (mPieCenterX < mDeadZone + mAngleZone) {
- center = CENTER - (mAngleZone - mPieCenterX + mDeadZone) * RAD24
- / (float) mAngleZone;
- } else if (mPieCenterX > getWidth() - mDeadZone - mAngleZone) {
- center = CENTER + (mPieCenterX - (getWidth() - mDeadZone - mAngleZone)) * RAD24
- / (float) mAngleZone;
- }
- return center;
- }
-
- /**
- * converts a
- * @param angle from 0..PI to Android degrees (clockwise starting at 3 o'clock)
- * @return skia angle
- */
- private float getDegrees(double angle) {
- return (float) (360 - 180 * angle / Math.PI);
- }
-
- private void startFadeOut(final PieItem item) {
- if (mFadeIn != null) {
- mFadeIn.cancel();
- }
- if (mXFade != null) {
- mXFade.cancel();
- }
- mFadeOut = new FadeOutAnimation();
- mFadeOut.setDuration(PIE_FADE_OUT_DURATION);
- mFadeOut.setAnimationListener(new AnimationListener() {
- @Override
- public void onAnimationStart(Animation animation) {
- }
-
- @Override
- public void onAnimationEnd(Animation animation) {
- item.performClick();
- mFadeOut = null;
- deselect();
- show(false);
- mOverlay.setAlpha(1);
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
- });
- mFadeOut.startNow();
- mOverlay.startAnimation(mFadeOut);
- }
-
- // root does not count
- private boolean hasOpenItem() {
- return mOpen.size() > 1;
- }
-
- // pop an item of the open item stack
- private PieItem closeOpenItem() {
- PieItem item = getOpenItem();
- mOpen.remove(mOpen.size() -1);
- return item;
- }
-
- private PieItem getOpenItem() {
- return mOpen.get(mOpen.size() - 1);
- }
-
- // return the children either the root or parent of the current open item
- private PieItem getParent() {
- return mOpen.get(Math.max(0, mOpen.size() - 2));
- }
-
- private int getLevel() {
- return mOpen.size() - 1;
- }
-
- @Override
- public void onDraw(Canvas canvas) {
- float alpha = 1;
- if (mXFade != null) {
- alpha = mXFade.getValue();
- } else if (mFadeIn != null) {
- alpha = mFadeIn.getValue();
- } else if (mFadeOut != null) {
- alpha = mFadeOut.getValue();
- }
- int state = canvas.save();
- if (mFadeIn != null) {
- float sf = 0.9f + alpha * 0.1f;
- canvas.scale(sf, sf, mPieCenterX, mPieCenterY);
- }
- if (mState != STATE_PIE) {
- drawFocus(canvas);
- }
- if (mState == STATE_FINISHING) {
- canvas.restoreToCount(state);
- return;
- }
- if (mState != STATE_PIE) return;
- if (!hasOpenItem() || (mXFade != null)) {
- // draw base menu
- drawArc(canvas, getLevel(), getParent());
- List<PieItem> items = getParent().getItems();
- final int count = items.size();
- int pos = 0;
- for (PieItem item : getParent().getItems()) {
- drawItem(Math.max(0, mOpen.size() - 2), pos, count, canvas, item, alpha);
- pos++;
- }
- mLabel.draw(canvas);
- }
- if (hasOpenItem()) {
- int level = getLevel();
- drawArc(canvas, level, getOpenItem());
- List<PieItem> items = getOpenItem().getItems();
- final int count = items.size();
- int pos = 0;
- for (PieItem inner : items) {
- if (mFadeOut != null) {
- drawItem(level, pos, count, canvas, inner, alpha);
- } else {
- drawItem(level, pos, count, canvas, inner, (mXFade != null) ? (1 - 0.5f * alpha) : 1);
- }
- pos++;
- }
- mLabel.draw(canvas);
- }
- canvas.restoreToCount(state);
- }
-
- private void drawArc(Canvas canvas, int level, PieItem item) {
- // arc
- if (mState == STATE_PIE) {
- final int count = item.getItems().size();
- float start = mCenterAngle + (count * SWEEP_ARC / 2f);
- float end = mCenterAngle - (count * SWEEP_ARC / 2f);
- int cy = mArcCenterY - level * mRadiusInc;
- canvas.drawArc(new RectF(mPieCenterX - mArcRadius, cy - mArcRadius,
- mPieCenterX + mArcRadius, cy + mArcRadius),
- getDegrees(end), getDegrees(start) - getDegrees(end), false, mMenuArcPaint);
- }
- }
-
- private void drawItem(int level, int pos, int count, Canvas canvas, PieItem item, float alpha) {
- if (mState == STATE_PIE) {
- if (item.getPath() != null) {
- int y = mArcCenterY - level * mRadiusInc;
- if (item.isSelected()) {
- Paint p = mSelectedPaint;
- int state = canvas.save();
- float angle = 0;
- if (mSlice != null) {
- angle = mSlice.getValue();
- } else {
- angle = getArcCenter(item, pos, count) - SWEEP_ARC / 2f;
- }
- angle = getDegrees(angle);
- canvas.rotate(angle, mPieCenterX, y);
- if (mFadeOut != null) {
- p.setAlpha((int)(255 * alpha));
- }
- canvas.drawPath(item.getPath(), p);
- if (mFadeOut != null) {
- p.setAlpha(255);
- }
- canvas.restoreToCount(state);
- }
- if (mFadeOut == null) {
- alpha = alpha * (item.isEnabled() ? 1 : 0.3f);
- // draw the item view
- item.setAlpha(alpha);
- }
- item.draw(canvas);
- }
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent evt) {
- float x = evt.getX();
- float y = evt.getY();
- int action = evt.getActionMasked();
- getPolar(x, y, !mTapMode, mPolar);
- if (MotionEvent.ACTION_DOWN == action) {
- if ((x < mDeadZone) || (x > getWidth() - mDeadZone)) {
- return false;
- }
- mDown.x = (int) evt.getX();
- mDown.y = (int) evt.getY();
- mOpening = false;
- if (mTapMode) {
- PieItem item = findItem(mPolar);
- if ((item != null) && (mCurrentItem != item)) {
- mState = STATE_PIE;
- onEnter(item);
- }
- } else {
- setCenter((int) x, (int) y);
- show(true);
- }
- return true;
- } else if (MotionEvent.ACTION_UP == action) {
- if (isVisible()) {
- PieItem item = mCurrentItem;
- if (mTapMode) {
- item = findItem(mPolar);
- if (mOpening) {
- mOpening = false;
- return true;
- }
- }
- if (item == null) {
- mTapMode = false;
- show(false);
- } else if (!mOpening && !item.hasItems()) {
- startFadeOut(item);
- mTapMode = false;
- } else {
- mTapMode = true;
- }
- return true;
- }
- } else if (MotionEvent.ACTION_CANCEL == action) {
- if (isVisible() || mTapMode) {
- show(false);
- }
- deselect();
- mHandler.removeMessages(MSG_OPENSUBMENU);
- return false;
- } else if (MotionEvent.ACTION_MOVE == action) {
- if (pulledToCenter(mPolar)) {
- mHandler.removeMessages(MSG_OPENSUBMENU);
- if (hasOpenItem()) {
- if (mCurrentItem != null) {
- mCurrentItem.setSelected(false);
- }
- closeOpenItem();
- mCurrentItem = null;
- } else {
- deselect();
- }
- mLabel.setText("");
- return false;
- }
- PieItem item = findItem(mPolar);
- boolean moved = hasMoved(evt);
- if ((item != null) && (mCurrentItem != item) && (!mOpening || moved)) {
- mHandler.removeMessages(MSG_OPENSUBMENU);
- // only select if we didn't just open or have moved past slop
- if (moved) {
- // switch back to swipe mode
- mTapMode = false;
- }
- onEnterSelect(item);
- mHandler.sendEmptyMessageDelayed(MSG_OPENSUBMENU, PIE_OPEN_SUB_DELAY);
- }
- }
- return false;
- }
-
- private boolean pulledToCenter(PointF polarCoords) {
- return polarCoords.y < mArcRadius - mRadiusInc;
- }
-
- private boolean inside(PointF polar, PieItem item, int pos, int count) {
- float start = getSliceCenter(item, pos, count) - SWEEP_SLICE / 2f;
- boolean res = (mArcRadius < polar.y)
- && (start < polar.x)
- && (start + SWEEP_SLICE > polar.x)
- && (!mTapMode || (mArcRadius + mRadiusInc > polar.y));
- return res;
- }
-
- private void getPolar(float x, float y, boolean useOffset, PointF res) {
- // get angle and radius from x/y
- res.x = (float) Math.PI / 2;
- x = x - mPieCenterX;
- float y1 = mSliceCenterY - getLevel() * mRadiusInc - y;
- float y2 = mArcCenterY - getLevel() * mRadiusInc - y;
- res.y = (float) Math.sqrt(x * x + y2 * y2);
- if (x != 0) {
- res.x = (float) Math.atan2(y1, x);
- if (res.x < 0) {
- res.x = (float) (2 * Math.PI + res.x);
- }
- }
- res.y = res.y + (useOffset ? mTouchOffset : 0);
- }
-
- private boolean hasMoved(MotionEvent e) {
- return mTouchSlopSquared < (e.getX() - mDown.x) * (e.getX() - mDown.x)
- + (e.getY() - mDown.y) * (e.getY() - mDown.y);
- }
-
- private void onEnterSelect(PieItem item) {
- if (mCurrentItem != null) {
- mCurrentItem.setSelected(false);
- }
- if (item != null && item.isEnabled()) {
- moveSelection(mCurrentItem, item);
- item.setSelected(true);
- mCurrentItem = item;
- mLabel.setText(mCurrentItem.getLabel());
- layoutLabel(getLevel());
- } else {
- mCurrentItem = null;
- }
- }
-
- private void onEnterOpen() {
- if ((mCurrentItem != null) && (mCurrentItem != getOpenItem()) && mCurrentItem.hasItems()) {
- openCurrentItem();
- }
- }
-
- /**
- * enter a slice for a view
- * updates model only
- * @param item
- */
- private void onEnter(PieItem item) {
- if (mCurrentItem != null) {
- mCurrentItem.setSelected(false);
- }
- if (item != null && item.isEnabled()) {
- item.setSelected(true);
- mCurrentItem = item;
- mLabel.setText(mCurrentItem.getLabel());
- if ((mCurrentItem != getOpenItem()) && mCurrentItem.hasItems()) {
- openCurrentItem();
- layoutLabel(getLevel());
- }
- } else {
- mCurrentItem = null;
- }
- }
-
- private void deselect() {
- if (mCurrentItem != null) {
- mCurrentItem.setSelected(false);
- }
- if (hasOpenItem()) {
- PieItem item = closeOpenItem();
- onEnter(item);
- } else {
- mCurrentItem = null;
- }
- }
-
- private int getItemPos(PieItem target) {
- List<PieItem> items = getOpenItem().getItems();
- return items.indexOf(target);
- }
-
- private int getCurrentCount() {
- return getOpenItem().getItems().size();
- }
-
- private void moveSelection(PieItem from, PieItem to) {
- final int count = getCurrentCount();
- final int fromPos = getItemPos(from);
- final int toPos = getItemPos(to);
- if (fromPos != -1 && toPos != -1) {
- float startAngle = getArcCenter(from, getItemPos(from), count)
- - SWEEP_ARC / 2f;
- float endAngle = getArcCenter(to, getItemPos(to), count)
- - SWEEP_ARC / 2f;
- mSlice = new LinearAnimation(startAngle, endAngle);
- mSlice.setDuration(PIE_SLICE_DURATION);
- mSlice.setAnimationListener(new AnimationListener() {
- @Override
- public void onAnimationEnd(Animation arg0) {
- mSlice = null;
- }
-
- @Override
- public void onAnimationRepeat(Animation arg0) {
- }
-
- @Override
- public void onAnimationStart(Animation arg0) {
- }
- });
- mOverlay.startAnimation(mSlice);
- }
- }
-
- private void openCurrentItem() {
- if ((mCurrentItem != null) && mCurrentItem.hasItems()) {
- mOpen.add(mCurrentItem);
- layoutLabel(getLevel());
- mOpening = true;
- if (mFadeIn != null) {
- mFadeIn.cancel();
- }
- mXFade = new LinearAnimation(1, 0);
- mXFade.setDuration(PIE_XFADE_DURATION);
- final PieItem ci = mCurrentItem;
- mXFade.setAnimationListener(new AnimationListener() {
- @Override
- public void onAnimationStart(Animation animation) {
- }
-
- @Override
- public void onAnimationEnd(Animation animation) {
- mXFade = null;
- ci.setSelected(false);
- mOpening = false;
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
- });
- mXFade.startNow();
- mOverlay.startAnimation(mXFade);
- }
- }
-
- /**
- * @param polar x: angle, y: dist
- * @return the item at angle/dist or null
- */
- private PieItem findItem(PointF polar) {
- // find the matching item:
- List<PieItem> items = getOpenItem().getItems();
- final int count = items.size();
- int pos = 0;
- for (PieItem item : items) {
- if (inside(polar, item, pos, count)) {
- return item;
- }
- pos++;
- }
- return null;
- }
-
-
- @Override
- public boolean handlesTouch() {
- return true;
- }
-
- // focus specific code
-
- public void setBlockFocus(boolean blocked) {
- mBlockFocus = blocked;
- if (blocked) {
- clear();
- }
- }
-
- public void setFocus(int x, int y) {
- mFocusX = x;
- mFocusY = y;
- setCircle(mFocusX, mFocusY);
- }
-
- public void alignFocus(int x, int y) {
- mOverlay.removeCallbacks(mDisappear);
- mAnimation.cancel();
- mAnimation.reset();
- mFocusX = x;
- mFocusY = y;
- mDialAngle = DIAL_HORIZONTAL;
- setCircle(x, y);
- mFocused = false;
- }
-
- public int getSize() {
- return 2 * mCircleSize;
- }
-
- private int getRandomRange() {
- return (int)(-60 + 120 * Math.random());
- }
-
- private void setCircle(int cx, int cy) {
- mCircle.set(cx - mCircleSize, cy - mCircleSize,
- cx + mCircleSize, cy + mCircleSize);
- mDial.set(cx - mCircleSize + mInnerOffset, cy - mCircleSize + mInnerOffset,
- cx + mCircleSize - mInnerOffset, cy + mCircleSize - mInnerOffset);
- }
-
- public void drawFocus(Canvas canvas) {
- if (mBlockFocus) return;
- mFocusPaint.setStrokeWidth(mOuterStroke);
- canvas.drawCircle((float) mFocusX, (float) mFocusY, (float) mCircleSize, mFocusPaint);
- if (mState == STATE_PIE) return;
- int color = mFocusPaint.getColor();
- if (mState == STATE_FINISHING) {
- mFocusPaint.setColor(mFocused ? mSuccessColor : mFailColor);
- }
- mFocusPaint.setStrokeWidth(mInnerStroke);
- drawLine(canvas, mDialAngle, mFocusPaint);
- drawLine(canvas, mDialAngle + 45, mFocusPaint);
- drawLine(canvas, mDialAngle + 180, mFocusPaint);
- drawLine(canvas, mDialAngle + 225, mFocusPaint);
- canvas.save();
- // rotate the arc instead of its offset to better use framework's shape caching
- canvas.rotate(mDialAngle, mFocusX, mFocusY);
- canvas.drawArc(mDial, 0, 45, false, mFocusPaint);
- canvas.drawArc(mDial, 180, 45, false, mFocusPaint);
- canvas.restore();
- mFocusPaint.setColor(color);
- }
-
- private void drawLine(Canvas canvas, int angle, Paint p) {
- convertCart(angle, mCircleSize - mInnerOffset, mPoint1);
- convertCart(angle, mCircleSize - mInnerOffset + mInnerOffset / 3, mPoint2);
- canvas.drawLine(mPoint1.x + mFocusX, mPoint1.y + mFocusY,
- mPoint2.x + mFocusX, mPoint2.y + mFocusY, p);
- }
-
- private static void convertCart(int angle, int radius, Point out) {
- double a = 2 * Math.PI * (angle % 360) / 360;
- out.x = (int) (radius * Math.cos(a) + 0.5);
- out.y = (int) (radius * Math.sin(a) + 0.5);
- }
-
- @Override
- public void showStart() {
- if (mState == STATE_PIE) return;
- cancelFocus();
- mStartAnimationAngle = 67;
- int range = getRandomRange();
- startAnimation(SCALING_UP_TIME,
- false, mStartAnimationAngle, mStartAnimationAngle + range);
- mState = STATE_FOCUSING;
- }
-
- @Override
- public void showSuccess(boolean timeout) {
- if (mState == STATE_FOCUSING) {
- startAnimation(SCALING_DOWN_TIME,
- timeout, mStartAnimationAngle);
- mState = STATE_FINISHING;
- mFocused = true;
- }
- }
-
- @Override
- public void showFail(boolean timeout) {
- if (mState == STATE_FOCUSING) {
- startAnimation(SCALING_DOWN_TIME,
- timeout, mStartAnimationAngle);
- mState = STATE_FINISHING;
- mFocused = false;
- }
- }
-
- private void cancelFocus() {
- mFocusCancelled = true;
- mOverlay.removeCallbacks(mDisappear);
- if (mAnimation != null && !mAnimation.hasEnded()) {
- mAnimation.cancel();
- }
- mFocusCancelled = false;
- mFocused = false;
- mState = STATE_IDLE;
- }
-
- @Override
- public void clear() {
- if (mState == STATE_PIE) return;
- cancelFocus();
- mOverlay.post(mDisappear);
- }
-
- private void startAnimation(long duration, boolean timeout,
- float toScale) {
- startAnimation(duration, timeout, mDialAngle,
- toScale);
- }
-
- private void startAnimation(long duration, boolean timeout,
- float fromScale, float toScale) {
- setVisible(true);
- mAnimation.reset();
- mAnimation.setDuration(duration);
- mAnimation.setScale(fromScale, toScale);
- mAnimation.setAnimationListener(timeout ? mEndAction : null);
- mOverlay.startAnimation(mAnimation);
- update();
- }
-
- private class EndAction implements Animation.AnimationListener {
- @Override
- public void onAnimationEnd(Animation animation) {
- // Keep the focus indicator for some time.
- if (!mFocusCancelled) {
- mOverlay.postDelayed(mDisappear, DISAPPEAR_TIMEOUT);
- }
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
-
- @Override
- public void onAnimationStart(Animation animation) {
- }
- }
-
- private class Disappear implements Runnable {
- @Override
- public void run() {
- if (mState == STATE_PIE) return;
- setVisible(false);
- mFocusX = mCenterX;
- mFocusY = mCenterY;
- mState = STATE_IDLE;
- setCircle(mFocusX, mFocusY);
- mFocused = false;
- }
- }
-
- private class FadeOutAnimation extends Animation {
-
- private float mAlpha;
-
- public float getValue() {
- return mAlpha;
- }
-
- @Override
- protected void applyTransformation(float interpolatedTime, Transformation t) {
- if (interpolatedTime < 0.2) {
- mAlpha = 1;
- } else if (interpolatedTime < 0.3) {
- mAlpha = 0;
- } else {
- mAlpha = 1 - (interpolatedTime - 0.3f) / 0.7f;
- }
- }
- }
-
- private class ScaleAnimation extends Animation {
- private float mFrom = 1f;
- private float mTo = 1f;
-
- public ScaleAnimation() {
- setFillAfter(true);
- }
-
- public void setScale(float from, float to) {
- mFrom = from;
- mTo = to;
- }
-
- @Override
- protected void applyTransformation(float interpolatedTime, Transformation t) {
- mDialAngle = (int)(mFrom + (mTo - mFrom) * interpolatedTime);
- }
- }
-
- private class LinearAnimation extends Animation {
- private float mFrom;
- private float mTo;
- private float mValue;
-
- public LinearAnimation(float from, float to) {
- setFillAfter(true);
- setInterpolator(new LinearInterpolator());
- mFrom = from;
- mTo = to;
- }
-
- public float getValue() {
- return mValue;
- }
-
- @Override
- protected void applyTransformation(float interpolatedTime, Transformation t) {
- mValue = (mFrom + (mTo - mFrom) * interpolatedTime);
- }
- }
-
-}
diff --git a/src/com/android/camera/ui/PopupManager.java b/src/com/android/camera/ui/PopupManager.java
deleted file mode 100644
index 0dcf34f..0000000
--- a/src/com/android/camera/ui/PopupManager.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-import android.content.Context;
-import android.view.View;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * A manager which notifies the event of a new popup in order to dismiss the
- * old popup if exists.
- */
-public class PopupManager {
- private static HashMap<Context, PopupManager> sMap =
- new HashMap<Context, PopupManager>();
-
- public interface OnOtherPopupShowedListener {
- public void onOtherPopupShowed();
- }
-
- private PopupManager() {}
-
- private ArrayList<OnOtherPopupShowedListener> mListeners = new ArrayList<OnOtherPopupShowedListener>();
-
- public void notifyShowPopup(View view) {
- for (OnOtherPopupShowedListener listener : mListeners) {
- if ((View) listener != view) {
- listener.onOtherPopupShowed();
- }
- }
- }
-
- public void setOnOtherPopupShowedListener(OnOtherPopupShowedListener listener) {
- mListeners.add(listener);
- }
-
- public static PopupManager getInstance(Context context) {
- PopupManager instance = sMap.get(context);
- if (instance == null) {
- instance = new PopupManager();
- sMap.put(context, instance);
- }
- return instance;
- }
-
- public static void removeInstance(Context context) {
- PopupManager instance = sMap.get(context);
- sMap.remove(context);
- }
-}
diff --git a/src/com/android/camera/ui/PreviewSurfaceView.java b/src/com/android/camera/ui/PreviewSurfaceView.java
deleted file mode 100644
index 9a428e2..0000000
--- a/src/com/android/camera/ui/PreviewSurfaceView.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.ViewGroup;
-
-import com.android.gallery3d.common.ApiHelper;
-
-public class PreviewSurfaceView extends SurfaceView {
- public PreviewSurfaceView(Context context, AttributeSet attrs) {
- super(context, attrs);
- setZOrderMediaOverlay(true);
- getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- }
-
- public void shrink() {
- setLayoutSize(1);
- }
-
- public void expand() {
- setLayoutSize(ViewGroup.LayoutParams.MATCH_PARENT);
- }
-
- private void setLayoutSize(int size) {
- ViewGroup.LayoutParams p = getLayoutParams();
- if (p.width != size || p.height != size) {
- p.width = size;
- p.height = size;
- setLayoutParams(p);
- }
- }
-}
diff --git a/src/com/android/camera/ui/RenderOverlay.java b/src/com/android/camera/ui/RenderOverlay.java
deleted file mode 100644
index ba25915..0000000
--- a/src/com/android/camera/ui/RenderOverlay.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class RenderOverlay extends FrameLayout {
-
- private static final String TAG = "CAM_Overlay";
-
- interface Renderer {
-
- public boolean handlesTouch();
- public boolean onTouchEvent(MotionEvent evt);
- public void setOverlay(RenderOverlay overlay);
- public void layout(int left, int top, int right, int bottom);
- public void draw(Canvas canvas);
-
- }
-
- private RenderView mRenderView;
- private List<Renderer> mClients;
-
- // reverse list of touch clients
- private List<Renderer> mTouchClients;
- private int[] mPosition = new int[2];
-
- public RenderOverlay(Context context, AttributeSet attrs) {
- super(context, attrs);
- mRenderView = new RenderView(context);
- addView(mRenderView, new LayoutParams(LayoutParams.MATCH_PARENT,
- LayoutParams.MATCH_PARENT));
- mClients = new ArrayList<Renderer>(10);
- mTouchClients = new ArrayList<Renderer>(10);
- setWillNotDraw(false);
- }
-
- public void addRenderer(Renderer renderer) {
- mClients.add(renderer);
- renderer.setOverlay(this);
- if (renderer.handlesTouch()) {
- mTouchClients.add(0, renderer);
- }
- renderer.layout(getLeft(), getTop(), getRight(), getBottom());
- }
-
- public void addRenderer(int pos, Renderer renderer) {
- mClients.add(pos, renderer);
- renderer.setOverlay(this);
- renderer.layout(getLeft(), getTop(), getRight(), getBottom());
- }
-
- public void remove(Renderer renderer) {
- mClients.remove(renderer);
- renderer.setOverlay(null);
- }
-
- public int getClientSize() {
- return mClients.size();
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent m) {
- return false;
- }
-
- public boolean directDispatchTouch(MotionEvent m, Renderer target) {
- mRenderView.setTouchTarget(target);
- boolean res = super.dispatchTouchEvent(m);
- mRenderView.setTouchTarget(null);
- return res;
- }
-
- private void adjustPosition() {
- getLocationInWindow(mPosition);
- }
-
- public int getWindowPositionX() {
- return mPosition[0];
- }
-
- public int getWindowPositionY() {
- return mPosition[1];
- }
-
- public void update() {
- mRenderView.invalidate();
- }
-
- private class RenderView extends View {
-
- private Renderer mTouchTarget;
-
- public RenderView(Context context) {
- super(context);
- setWillNotDraw(false);
- }
-
- public void setTouchTarget(Renderer target) {
- mTouchTarget = target;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent evt) {
- if (mTouchTarget != null) {
- return mTouchTarget.onTouchEvent(evt);
- }
- if (mTouchClients != null) {
- boolean res = false;
- for (Renderer client : mTouchClients) {
- res |= client.onTouchEvent(evt);
- }
- return res;
- }
- return false;
- }
-
- @Override
- public void onLayout(boolean changed, int left, int top, int right, int bottom) {
- adjustPosition();
- super.onLayout(changed, left, top, right, bottom);
- if (mClients == null) return;
- for (Renderer renderer : mClients) {
- renderer.layout(left, top, right, bottom);
- }
- }
-
- @Override
- public void draw(Canvas canvas) {
- super.draw(canvas);
- if (mClients == null) return;
- boolean redraw = false;
- for (Renderer renderer : mClients) {
- renderer.draw(canvas);
- redraw = redraw || ((OverlayRenderer) renderer).isVisible();
- }
- if (redraw) {
- invalidate();
- }
- }
- }
-
-}
diff --git a/src/com/android/camera/ui/Rotatable.java b/src/com/android/camera/ui/Rotatable.java
deleted file mode 100644
index 6d428b8..0000000
--- a/src/com/android/camera/ui/Rotatable.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-public interface Rotatable {
- // Set parameter 'animation' to true to have animation when rotation.
- public void setOrientation(int orientation, boolean animation);
-}
diff --git a/src/com/android/camera/ui/RotatableLayout.java b/src/com/android/camera/ui/RotatableLayout.java
deleted file mode 100644
index 8355c88..0000000
--- a/src/com/android/camera/ui/RotatableLayout.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * 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.camera.ui;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-
-import com.android.camera.Util;
-
-/* RotatableLayout rotates itself as well as all its children when orientation
- * changes. Specifically, when going from portrait to landscape, camera
- * controls move from the bottom of the screen to right side of the screen
- * (i.e. counter clockwise). Similarly, when the screen changes to portrait, we
- * need to move the controls from right side to the bottom of the screen, which
- * is a clockwise rotation.
- */
-
-public class RotatableLayout extends FrameLayout {
-
- private static final String TAG = "RotatableLayout";
- // Initial orientation of the layout (ORIENTATION_PORTRAIT, or ORIENTATION_LANDSCAPE)
- private int mInitialOrientation;
- private int mPrevRotation;
- private RotationListener mListener = null;
- public interface RotationListener {
- public void onRotation(int rotation);
- }
- public RotatableLayout(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mInitialOrientation = getResources().getConfiguration().orientation;
- }
-
- public RotatableLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- mInitialOrientation = getResources().getConfiguration().orientation;
- }
-
- public RotatableLayout(Context context) {
- super(context);
- mInitialOrientation = getResources().getConfiguration().orientation;
- }
-
- @Override
- public void onAttachedToWindow() {
- mPrevRotation = Util.getDisplayRotation((Activity) getContext());
- // check if there is any rotation before the view is attached to window
- int currentOrientation = getResources().getConfiguration().orientation;
- if (mInitialOrientation == currentOrientation) {
- return;
- }
- if (mInitialOrientation == Configuration.ORIENTATION_LANDSCAPE
- && currentOrientation == Configuration.ORIENTATION_PORTRAIT) {
- rotateLayout(true);
- } else if (mInitialOrientation == Configuration.ORIENTATION_PORTRAIT
- && currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
- rotateLayout(false);
- }
- }
-
- @Override
- public void onConfigurationChanged(Configuration config) {
- super.onConfigurationChanged(config);
- int rotation = Util.getDisplayRotation((Activity) getContext());
- if ((rotation - mPrevRotation + 360) % 180 == 0) {
- mPrevRotation = rotation;
- return;
- }
- boolean clockwise = isClockWiseRotation(mPrevRotation, rotation);
- rotateLayout(clockwise);
- mPrevRotation = rotation;
- }
-
- protected void rotateLayout(boolean clockwise) {
- // Change the size of the layout
- ViewGroup.LayoutParams lp = getLayoutParams();
- int width = lp.width;
- int height = lp.height;
- lp.height = width;
- lp.width = height;
- setLayoutParams(lp);
-
- // rotate all the children
- rotateChildren(clockwise);
- }
-
- protected void rotateChildren(boolean clockwise) {
- int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- View child = getChildAt(i);
- rotate(child, clockwise);
- }
- if (mListener != null) mListener.onRotation(clockwise ? 90 : 270);
- }
-
- protected void flipChildren() {
- mPrevRotation = Util.getDisplayRotation((Activity) getContext());
- int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- View child = getChildAt(i);
- flip(child);
- }
- if (mListener != null) mListener.onRotation(180);
- }
-
- public void setRotationListener(RotationListener listener) {
- mListener = listener;
- }
-
- public static boolean isClockWiseRotation(int prevRotation, int currentRotation) {
- if (prevRotation == (currentRotation + 90) % 360) {
- return true;
- }
- return false;
- }
-
- public static void rotate(View view, boolean isClockwise) {
- if (isClockwise) {
- rotateClockwise(view);
- } else {
- rotateCounterClockwise(view);
- }
- }
-
- private static boolean contains(int value, int mask) {
- return (value & mask) == mask;
- }
-
- public static void rotateClockwise(View view) {
- if (view == null) return;
- LayoutParams lp = (LayoutParams) view.getLayoutParams();
- int gravity = lp.gravity;
- int ngravity = 0;
- // rotate gravity
- if (contains(gravity, Gravity.LEFT)) {
- ngravity |= Gravity.TOP;
- }
- if (contains(gravity, Gravity.RIGHT)) {
- ngravity |= Gravity.BOTTOM;
- }
- if (contains(gravity, Gravity.TOP)) {
- ngravity |= Gravity.RIGHT;
- }
- if (contains(gravity, Gravity.BOTTOM)) {
- ngravity |= Gravity.LEFT;
- }
- if (contains(gravity, Gravity.CENTER)) {
- ngravity |= Gravity.CENTER;
- }
- if (contains(gravity, Gravity.CENTER_HORIZONTAL)) {
- ngravity |= Gravity.CENTER_VERTICAL;
- }
- if (contains(gravity, Gravity.CENTER_VERTICAL)) {
- ngravity |= Gravity.CENTER_HORIZONTAL;
- }
- lp.gravity = ngravity;
- int ml = lp.leftMargin;
- int mr = lp.rightMargin;
- int mt = lp.topMargin;
- int mb = lp.bottomMargin;
- lp.leftMargin = mb;
- lp.rightMargin = mt;
- lp.topMargin = ml;
- lp.bottomMargin = mr;
- int width = lp.width;
- int height = lp.height;
- lp.width = height;
- lp.height = width;
- view.setLayoutParams(lp);
- }
-
- public static void rotateCounterClockwise(View view) {
- if (view == null) return;
- LayoutParams lp = (LayoutParams) view.getLayoutParams();
- int gravity = lp.gravity;
- int ngravity = 0;
- // change gravity
- if (contains(gravity, Gravity.RIGHT)) {
- ngravity |= Gravity.TOP;
- }
- if (contains(gravity, Gravity.LEFT)) {
- ngravity |= Gravity.BOTTOM;
- }
- if (contains(gravity, Gravity.TOP)) {
- ngravity |= Gravity.LEFT;
- }
- if (contains(gravity, Gravity.BOTTOM)) {
- ngravity |= Gravity.RIGHT;
- }
- if (contains(gravity, Gravity.CENTER)) {
- ngravity |= Gravity.CENTER;
- }
- if (contains(gravity, Gravity.CENTER_HORIZONTAL)) {
- ngravity |= Gravity.CENTER_VERTICAL;
- }
- if (contains(gravity, Gravity.CENTER_VERTICAL)) {
- ngravity |= Gravity.CENTER_HORIZONTAL;
- }
- lp.gravity = ngravity;
- int ml = lp.leftMargin;
- int mr = lp.rightMargin;
- int mt = lp.topMargin;
- int mb = lp.bottomMargin;
- lp.leftMargin = mt;
- lp.rightMargin = mb;
- lp.topMargin = mr;
- lp.bottomMargin = ml;
- int width = lp.width;
- int height = lp.height;
- lp.width = height;
- lp.height = width;
- view.setLayoutParams(lp);
- }
-
- // Rotate a given view 180 degrees
- public static void flip(View view) {
- rotateClockwise(view);
- rotateClockwise(view);
- }
-}
\ No newline at end of file
diff --git a/src/com/android/camera/ui/RotateImageView.java b/src/com/android/camera/ui/RotateImageView.java
deleted file mode 100644
index 05e1a7c..0000000
--- a/src/com/android/camera/ui/RotateImageView.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera.ui;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.TransitionDrawable;
-import android.media.ThumbnailUtils;
-import android.util.AttributeSet;
-import android.view.ViewGroup.LayoutParams;
-import android.view.animation.AnimationUtils;
-import android.widget.ImageView;
-
-/**
- * A @{code ImageView} which can rotate it's content.
- */
-public class RotateImageView extends TwoStateImageView implements Rotatable {
-
- @SuppressWarnings("unused")
- private static final String TAG = "RotateImageView";
-
- private static final int ANIMATION_SPEED = 270; // 270 deg/sec
-
- private int mCurrentDegree = 0; // [0, 359]
- private int mStartDegree = 0;
- private int mTargetDegree = 0;
-
- private boolean mClockwise = false, mEnableAnimation = true;
-
- private long mAnimationStartTime = 0;
- private long mAnimationEndTime = 0;
-
- public RotateImageView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public RotateImageView(Context context) {
- super(context);
- }
-
- protected int getDegree() {
- return mTargetDegree;
- }
-
- // Rotate the view counter-clockwise
- @Override
- public void setOrientation(int degree, boolean animation) {
- mEnableAnimation = animation;
- // make sure in the range of [0, 359]
- degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
- if (degree == mTargetDegree) return;
-
- mTargetDegree = degree;
- if (mEnableAnimation) {
- mStartDegree = mCurrentDegree;
- mAnimationStartTime = AnimationUtils.currentAnimationTimeMillis();
-
- int diff = mTargetDegree - mCurrentDegree;
- diff = diff >= 0 ? diff : 360 + diff; // make it in range [0, 359]
-
- // Make it in range [-179, 180]. That's the shorted distance between the
- // two angles
- diff = diff > 180 ? diff - 360 : diff;
-
- mClockwise = diff >= 0;
- mAnimationEndTime = mAnimationStartTime
- + Math.abs(diff) * 1000 / ANIMATION_SPEED;
- } else {
- mCurrentDegree = mTargetDegree;
- }
-
- invalidate();
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- Drawable drawable = getDrawable();
- if (drawable == null) return;
-
- Rect bounds = drawable.getBounds();
- int w = bounds.right - bounds.left;
- int h = bounds.bottom - bounds.top;
-
- if (w == 0 || h == 0) return; // nothing to draw
-
- if (mCurrentDegree != mTargetDegree) {
- long time = AnimationUtils.currentAnimationTimeMillis();
- if (time < mAnimationEndTime) {
- int deltaTime = (int)(time - mAnimationStartTime);
- int degree = mStartDegree + ANIMATION_SPEED
- * (mClockwise ? deltaTime : -deltaTime) / 1000;
- degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
- mCurrentDegree = degree;
- invalidate();
- } else {
- mCurrentDegree = mTargetDegree;
- }
- }
-
- int left = getPaddingLeft();
- int top = getPaddingTop();
- int right = getPaddingRight();
- int bottom = getPaddingBottom();
- int width = getWidth() - left - right;
- int height = getHeight() - top - bottom;
-
- int saveCount = canvas.getSaveCount();
-
- // Scale down the image first if required.
- if ((getScaleType() == ImageView.ScaleType.FIT_CENTER) &&
- ((width < w) || (height < h))) {
- float ratio = Math.min((float) width / w, (float) height / h);
- canvas.scale(ratio, ratio, width / 2.0f, height / 2.0f);
- }
- canvas.translate(left + width / 2, top + height / 2);
- canvas.rotate(-mCurrentDegree);
- canvas.translate(-w / 2, -h / 2);
- drawable.draw(canvas);
- canvas.restoreToCount(saveCount);
- }
-
- private Bitmap mThumb;
- private Drawable[] mThumbs;
- private TransitionDrawable mThumbTransition;
-
- public void setBitmap(Bitmap bitmap) {
- // Make sure uri and original are consistently both null or both
- // non-null.
- if (bitmap == null) {
- mThumb = null;
- mThumbs = null;
- setImageDrawable(null);
- setVisibility(GONE);
- return;
- }
-
- LayoutParams param = getLayoutParams();
- final int miniThumbWidth = param.width
- - getPaddingLeft() - getPaddingRight();
- final int miniThumbHeight = param.height
- - getPaddingTop() - getPaddingBottom();
- mThumb = ThumbnailUtils.extractThumbnail(
- bitmap, miniThumbWidth, miniThumbHeight);
- Drawable drawable;
- if (mThumbs == null || !mEnableAnimation) {
- mThumbs = new Drawable[2];
- mThumbs[1] = new BitmapDrawable(getContext().getResources(), mThumb);
- setImageDrawable(mThumbs[1]);
- } else {
- mThumbs[0] = mThumbs[1];
- mThumbs[1] = new BitmapDrawable(getContext().getResources(), mThumb);
- mThumbTransition = new TransitionDrawable(mThumbs);
- setImageDrawable(mThumbTransition);
- mThumbTransition.startTransition(500);
- }
- setVisibility(VISIBLE);
- }
-}
diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java
deleted file mode 100644
index 86f5c81..0000000
--- a/src/com/android/camera/ui/RotateLayout.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.ui;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-
-import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.util.MotionEventHelper;
-
-// A RotateLayout is designed to display a single item and provides the
-// capabilities to rotate the item.
-public class RotateLayout extends ViewGroup implements Rotatable {
- @SuppressWarnings("unused")
- private static final String TAG = "RotateLayout";
- private int mOrientation;
- private Matrix mMatrix = new Matrix();
- protected View mChild;
-
- public RotateLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- // The transparent background here is a workaround of the render issue
- // happened when the view is rotated as the device's orientation
- // changed. The view looks fine in landscape. After rotation, the view
- // is invisible.
- setBackgroundResource(android.R.color.transparent);
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- @Override
- protected void onFinishInflate() {
- mChild = getChildAt(0);
- if (ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES) {
- mChild.setPivotX(0);
- mChild.setPivotY(0);
- }
- }
-
- @Override
- protected void onLayout(
- boolean change, int left, int top, int right, int bottom) {
- int width = right - left;
- int height = bottom - top;
- switch (mOrientation) {
- case 0:
- case 180:
- mChild.layout(0, 0, width, height);
- break;
- case 90:
- case 270:
- mChild.layout(0, 0, height, width);
- break;
- }
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent event) {
- if (!ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES) {
- final int w = getMeasuredWidth();
- final int h = getMeasuredHeight();
- switch (mOrientation) {
- case 0:
- mMatrix.setTranslate(0, 0);
- break;
- case 90:
- mMatrix.setTranslate(0, -h);
- break;
- case 180:
- mMatrix.setTranslate(-w, -h);
- break;
- case 270:
- mMatrix.setTranslate(-w, 0);
- break;
- }
- mMatrix.postRotate(mOrientation);
- event = MotionEventHelper.transformEvent(event, mMatrix);
- }
- return super.dispatchTouchEvent(event);
- }
-
- @Override
- protected void dispatchDraw(Canvas canvas) {
- if (ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES) {
- super.dispatchDraw(canvas);
- } else {
- canvas.save();
- int w = getMeasuredWidth();
- int h = getMeasuredHeight();
- switch (mOrientation) {
- case 0:
- canvas.translate(0, 0);
- break;
- case 90:
- canvas.translate(0, h);
- break;
- case 180:
- canvas.translate(w, h);
- break;
- case 270:
- canvas.translate(w, 0);
- break;
- }
- canvas.rotate(-mOrientation, 0, 0);
- super.dispatchDraw(canvas);
- canvas.restore();
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- int w = 0, h = 0;
- switch(mOrientation) {
- case 0:
- case 180:
- measureChild(mChild, widthSpec, heightSpec);
- w = mChild.getMeasuredWidth();
- h = mChild.getMeasuredHeight();
- break;
- case 90:
- case 270:
- measureChild(mChild, heightSpec, widthSpec);
- w = mChild.getMeasuredHeight();
- h = mChild.getMeasuredWidth();
- break;
- }
- setMeasuredDimension(w, h);
-
- if (ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES) {
- switch (mOrientation) {
- case 0:
- mChild.setTranslationX(0);
- mChild.setTranslationY(0);
- break;
- case 90:
- mChild.setTranslationX(0);
- mChild.setTranslationY(h);
- break;
- case 180:
- mChild.setTranslationX(w);
- mChild.setTranslationY(h);
- break;
- case 270:
- mChild.setTranslationX(w);
- mChild.setTranslationY(0);
- break;
- }
- mChild.setRotation(-mOrientation);
- }
- }
-
- @Override
- public boolean shouldDelayChildPressedState() {
- return false;
- }
-
- // Rotate the view counter-clockwise
- @Override
- public void setOrientation(int orientation, boolean animation) {
- orientation = orientation % 360;
- if (mOrientation == orientation) return;
- mOrientation = orientation;
- requestLayout();
- }
-
- public int getOrientation() {
- return mOrientation;
- }
-
- @Override
- public ViewParent invalidateChildInParent(int[] location, Rect r) {
- if (!ApiHelper.HAS_VIEW_TRANSFORM_PROPERTIES && mOrientation != 0) {
- // The workaround invalidates the entire rotate layout. After
- // rotation, the correct area to invalidate may be larger than the
- // size of the child. Ex: ListView. There is no way to invalidate
- // only the necessary area.
- r.set(0, 0, getWidth(), getHeight());
- }
- return super.invalidateChildInParent(location, r);
- }
-}
diff --git a/src/com/android/camera/ui/RotateTextToast.java b/src/com/android/camera/ui/RotateTextToast.java
deleted file mode 100644
index c78a258..0000000
--- a/src/com/android/camera/ui/RotateTextToast.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.android.camera.Util;
-import com.android.gallery3d.R;
-
-public class RotateTextToast {
- private static final int TOAST_DURATION = 5000; // milliseconds
- ViewGroup mLayoutRoot;
- RotateLayout mToast;
- Handler mHandler;
-
- public RotateTextToast(Activity activity, int textResourceId, int orientation) {
- mLayoutRoot = (ViewGroup) activity.getWindow().getDecorView();
- LayoutInflater inflater = activity.getLayoutInflater();
- View v = inflater.inflate(R.layout.rotate_text_toast, mLayoutRoot);
- mToast = (RotateLayout) v.findViewById(R.id.rotate_toast);
- TextView tv = (TextView) mToast.findViewById(R.id.message);
- tv.setText(textResourceId);
- mToast.setOrientation(orientation, false);
- mHandler = new Handler();
- }
-
- private final Runnable mRunnable = new Runnable() {
- @Override
- public void run() {
- Util.fadeOut(mToast);
- mLayoutRoot.removeView(mToast);
- mToast = null;
- }
- };
-
- public void show() {
- mToast.setVisibility(View.VISIBLE);
- mHandler.postDelayed(mRunnable, TOAST_DURATION);
- }
-}
diff --git a/src/com/android/camera/ui/Switch.java b/src/com/android/camera/ui/Switch.java
deleted file mode 100644
index ac21758..0000000
--- a/src/com/android/camera/ui/Switch.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
-import android.text.Layout;
-import android.text.StaticLayout;
-import android.text.TextPaint;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.MotionEvent;
-import android.view.VelocityTracker;
-import android.view.ViewConfiguration;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityNodeInfo;
-import android.widget.CompoundButton;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.ApiHelper;
-
-import java.util.Arrays;
-
-/**
- * A Switch is a two-state toggle switch widget that can select between two
- * options. The user may drag the "thumb" back and forth to choose the selected option,
- * or simply tap to toggle as if it were a checkbox.
- */
-public class Switch extends CompoundButton {
- private static final int TOUCH_MODE_IDLE = 0;
- private static final int TOUCH_MODE_DOWN = 1;
- private static final int TOUCH_MODE_DRAGGING = 2;
-
- private Drawable mThumbDrawable;
- private Drawable mTrackDrawable;
- private int mThumbTextPadding;
- private int mSwitchMinWidth;
- private int mSwitchTextMaxWidth;
- private int mSwitchPadding;
- private CharSequence mTextOn;
- private CharSequence mTextOff;
-
- private int mTouchMode;
- private int mTouchSlop;
- private float mTouchX;
- private float mTouchY;
- private VelocityTracker mVelocityTracker = VelocityTracker.obtain();
- private int mMinFlingVelocity;
-
- private float mThumbPosition;
- private int mSwitchWidth;
- private int mSwitchHeight;
- private int mThumbWidth; // Does not include padding
-
- private int mSwitchLeft;
- private int mSwitchTop;
- private int mSwitchRight;
- private int mSwitchBottom;
-
- private TextPaint mTextPaint;
- private ColorStateList mTextColors;
- private Layout mOnLayout;
- private Layout mOffLayout;
-
- @SuppressWarnings("hiding")
- private final Rect mTempRect = new Rect();
-
- private static final int[] CHECKED_STATE_SET = {
- android.R.attr.state_checked
- };
-
- /**
- * Construct a new Switch with default styling, overriding specific style
- * attributes as requested.
- *
- * @param context The Context that will determine this widget's theming.
- * @param attrs Specification of attributes that should deviate from default styling.
- */
- public Switch(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.switchStyle);
- }
-
- /**
- * Construct a new Switch with a default style determined by the given theme attribute,
- * overriding specific style attributes as requested.
- *
- * @param context The Context that will determine this widget's theming.
- * @param attrs Specification of attributes that should deviate from the default styling.
- * @param defStyle An attribute ID within the active theme containing a reference to the
- * default style for this widget. e.g. android.R.attr.switchStyle.
- */
- public Switch(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
- Resources res = getResources();
- DisplayMetrics dm = res.getDisplayMetrics();
- mTextPaint.density = dm.density;
- mThumbDrawable = res.getDrawable(R.drawable.switch_inner_holo_dark);
- mTrackDrawable = res.getDrawable(R.drawable.switch_track_holo_dark);
- mTextOn = res.getString(R.string.capital_on);
- mTextOff = res.getString(R.string.capital_off);
- mThumbTextPadding = res.getDimensionPixelSize(R.dimen.thumb_text_padding);
- mSwitchMinWidth = res.getDimensionPixelSize(R.dimen.switch_min_width);
- mSwitchTextMaxWidth = res.getDimensionPixelSize(R.dimen.switch_text_max_width);
- mSwitchPadding = res.getDimensionPixelSize(R.dimen.switch_padding);
- setSwitchTextAppearance(context, android.R.style.TextAppearance_Holo_Small);
-
- ViewConfiguration config = ViewConfiguration.get(context);
- mTouchSlop = config.getScaledTouchSlop();
- mMinFlingVelocity = config.getScaledMinimumFlingVelocity();
-
- // Refresh display with current params
- refreshDrawableState();
- setChecked(isChecked());
- }
-
- /**
- * Sets the switch text color, size, style, hint color, and highlight color
- * from the specified TextAppearance resource.
- */
- public void setSwitchTextAppearance(Context context, int resid) {
- Resources res = getResources();
- mTextColors = getTextColors();
- int ts = res.getDimensionPixelSize(R.dimen.thumb_text_size);
- if (ts != mTextPaint.getTextSize()) {
- mTextPaint.setTextSize(ts);
- requestLayout();
- }
- }
-
- @Override
- public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- int widthSize = MeasureSpec.getSize(widthMeasureSpec);
- if (mOnLayout == null) {
- mOnLayout = makeLayout(mTextOn, mSwitchTextMaxWidth);
- }
- if (mOffLayout == null) {
- mOffLayout = makeLayout(mTextOff, mSwitchTextMaxWidth);
- }
-
- mTrackDrawable.getPadding(mTempRect);
- final int maxTextWidth = Math.min(mSwitchTextMaxWidth,
- Math.max(mOnLayout.getWidth(), mOffLayout.getWidth()));
- final int switchWidth = Math.max(mSwitchMinWidth,
- maxTextWidth * 2 + mThumbTextPadding * 4 + mTempRect.left + mTempRect.right);
- final int switchHeight = mTrackDrawable.getIntrinsicHeight();
-
- mThumbWidth = maxTextWidth + mThumbTextPadding * 2;
-
- mSwitchWidth = switchWidth;
- mSwitchHeight = switchHeight;
-
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- final int measuredHeight = getMeasuredHeight();
- final int measuredWidth = getMeasuredWidth();
- if (measuredHeight < switchHeight) {
- setMeasuredDimension(measuredWidth, switchHeight);
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- @Override
- public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
- super.onPopulateAccessibilityEvent(event);
- CharSequence text = isChecked() ? mOnLayout.getText() : mOffLayout.getText();
- if (!TextUtils.isEmpty(text)) {
- event.getText().add(text);
- }
- }
-
- private Layout makeLayout(CharSequence text, int maxWidth) {
- int actual_width = (int) Math.ceil(Layout.getDesiredWidth(text, mTextPaint));
- StaticLayout l = new StaticLayout(text, 0, text.length(), mTextPaint,
- actual_width,
- Layout.Alignment.ALIGN_NORMAL, 1.f, 0, true,
- TextUtils.TruncateAt.END,
- (int) Math.min(actual_width, maxWidth));
- return l;
- }
-
- /**
- * @return true if (x, y) is within the target area of the switch thumb
- */
- private boolean hitThumb(float x, float y) {
- mThumbDrawable.getPadding(mTempRect);
- final int thumbTop = mSwitchTop - mTouchSlop;
- final int thumbLeft = mSwitchLeft + (int) (mThumbPosition + 0.5f) - mTouchSlop;
- final int thumbRight = thumbLeft + mThumbWidth +
- mTempRect.left + mTempRect.right + mTouchSlop;
- final int thumbBottom = mSwitchBottom + mTouchSlop;
- return x > thumbLeft && x < thumbRight && y > thumbTop && y < thumbBottom;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- mVelocityTracker.addMovement(ev);
- final int action = ev.getActionMasked();
- switch (action) {
- case MotionEvent.ACTION_DOWN: {
- final float x = ev.getX();
- final float y = ev.getY();
- if (isEnabled() && hitThumb(x, y)) {
- mTouchMode = TOUCH_MODE_DOWN;
- mTouchX = x;
- mTouchY = y;
- }
- break;
- }
-
- case MotionEvent.ACTION_MOVE: {
- switch (mTouchMode) {
- case TOUCH_MODE_IDLE:
- // Didn't target the thumb, treat normally.
- break;
-
- case TOUCH_MODE_DOWN: {
- final float x = ev.getX();
- final float y = ev.getY();
- if (Math.abs(x - mTouchX) > mTouchSlop ||
- Math.abs(y - mTouchY) > mTouchSlop) {
- mTouchMode = TOUCH_MODE_DRAGGING;
- getParent().requestDisallowInterceptTouchEvent(true);
- mTouchX = x;
- mTouchY = y;
- return true;
- }
- break;
- }
-
- case TOUCH_MODE_DRAGGING: {
- final float x = ev.getX();
- final float dx = x - mTouchX;
- float newPos = Math.max(0,
- Math.min(mThumbPosition + dx, getThumbScrollRange()));
- if (newPos != mThumbPosition) {
- mThumbPosition = newPos;
- mTouchX = x;
- invalidate();
- }
- return true;
- }
- }
- break;
- }
-
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_CANCEL: {
- if (mTouchMode == TOUCH_MODE_DRAGGING) {
- stopDrag(ev);
- return true;
- }
- mTouchMode = TOUCH_MODE_IDLE;
- mVelocityTracker.clear();
- break;
- }
- }
-
- return super.onTouchEvent(ev);
- }
-
- private void cancelSuperTouch(MotionEvent ev) {
- MotionEvent cancel = MotionEvent.obtain(ev);
- cancel.setAction(MotionEvent.ACTION_CANCEL);
- super.onTouchEvent(cancel);
- cancel.recycle();
- }
-
- /**
- * Called from onTouchEvent to end a drag operation.
- *
- * @param ev Event that triggered the end of drag mode - ACTION_UP or ACTION_CANCEL
- */
- private void stopDrag(MotionEvent ev) {
- mTouchMode = TOUCH_MODE_IDLE;
- // Up and not canceled, also checks the switch has not been disabled during the drag
- boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP && isEnabled();
-
- cancelSuperTouch(ev);
-
- if (commitChange) {
- boolean newState;
- mVelocityTracker.computeCurrentVelocity(1000);
- float xvel = mVelocityTracker.getXVelocity();
- if (Math.abs(xvel) > mMinFlingVelocity) {
- newState = xvel > 0;
- } else {
- newState = getTargetCheckedState();
- }
- animateThumbToCheckedState(newState);
- } else {
- animateThumbToCheckedState(isChecked());
- }
- }
-
- private void animateThumbToCheckedState(boolean newCheckedState) {
- setChecked(newCheckedState);
- }
-
- private boolean getTargetCheckedState() {
- return mThumbPosition >= getThumbScrollRange() / 2;
- }
-
- private void setThumbPosition(boolean checked) {
- mThumbPosition = checked ? getThumbScrollRange() : 0;
- }
-
- @Override
- public void setChecked(boolean checked) {
- super.setChecked(checked);
- setThumbPosition(checked);
- invalidate();
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
-
- setThumbPosition(isChecked());
-
- int switchRight;
- int switchLeft;
-
- switchRight = getWidth() - getPaddingRight();
- switchLeft = switchRight - mSwitchWidth;
-
- int switchTop = 0;
- int switchBottom = 0;
- switch (getGravity() & Gravity.VERTICAL_GRAVITY_MASK) {
- default:
- case Gravity.TOP:
- switchTop = getPaddingTop();
- switchBottom = switchTop + mSwitchHeight;
- break;
-
- case Gravity.CENTER_VERTICAL:
- switchTop = (getPaddingTop() + getHeight() - getPaddingBottom()) / 2 -
- mSwitchHeight / 2;
- switchBottom = switchTop + mSwitchHeight;
- break;
-
- case Gravity.BOTTOM:
- switchBottom = getHeight() - getPaddingBottom();
- switchTop = switchBottom - mSwitchHeight;
- break;
- }
-
- mSwitchLeft = switchLeft;
- mSwitchTop = switchTop;
- mSwitchBottom = switchBottom;
- mSwitchRight = switchRight;
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- // Draw the switch
- int switchLeft = mSwitchLeft;
- int switchTop = mSwitchTop;
- int switchRight = mSwitchRight;
- int switchBottom = mSwitchBottom;
-
- mTrackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom);
- mTrackDrawable.draw(canvas);
-
- canvas.save();
-
- mTrackDrawable.getPadding(mTempRect);
- int switchInnerLeft = switchLeft + mTempRect.left;
- int switchInnerTop = switchTop + mTempRect.top;
- int switchInnerRight = switchRight - mTempRect.right;
- int switchInnerBottom = switchBottom - mTempRect.bottom;
- canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom);
-
- mThumbDrawable.getPadding(mTempRect);
- final int thumbPos = (int) (mThumbPosition + 0.5f);
- int thumbLeft = switchInnerLeft - mTempRect.left + thumbPos;
- int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + mTempRect.right;
-
- mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);
- mThumbDrawable.draw(canvas);
-
- // mTextColors should not be null, but just in case
- if (mTextColors != null) {
- mTextPaint.setColor(mTextColors.getColorForState(getDrawableState(),
- mTextColors.getDefaultColor()));
- }
- mTextPaint.drawableState = getDrawableState();
-
- Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
-
- canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getEllipsizedWidth() / 2,
- (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
- switchText.draw(canvas);
-
- canvas.restore();
- }
-
- @Override
- public int getCompoundPaddingRight() {
- int padding = super.getCompoundPaddingRight() + mSwitchWidth;
- if (!TextUtils.isEmpty(getText())) {
- padding += mSwitchPadding;
- }
- return padding;
- }
-
- private int getThumbScrollRange() {
- if (mTrackDrawable == null) {
- return 0;
- }
- mTrackDrawable.getPadding(mTempRect);
- return mSwitchWidth - mThumbWidth - mTempRect.left - mTempRect.right;
- }
-
- @Override
- protected int[] onCreateDrawableState(int extraSpace) {
- final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
-
- if (isChecked()) {
- mergeDrawableStates(drawableState, CHECKED_STATE_SET);
- }
- return drawableState;
- }
-
- @Override
- protected void drawableStateChanged() {
- super.drawableStateChanged();
-
- int[] myDrawableState = getDrawableState();
-
- // Set the state of the Drawable
- // Drawable may be null when checked state is set from XML, from super constructor
- if (mThumbDrawable != null) mThumbDrawable.setState(myDrawableState);
- if (mTrackDrawable != null) mTrackDrawable.setState(myDrawableState);
-
- invalidate();
- }
-
- @Override
- protected boolean verifyDrawable(Drawable who) {
- return super.verifyDrawable(who) || who == mThumbDrawable || who == mTrackDrawable;
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
- @Override
- public void jumpDrawablesToCurrentState() {
- super.jumpDrawablesToCurrentState();
- mThumbDrawable.jumpToCurrentState();
- mTrackDrawable.jumpToCurrentState();
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- @Override
- public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
- super.onInitializeAccessibilityEvent(event);
- event.setClassName(Switch.class.getName());
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- @Override
- public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
- super.onInitializeAccessibilityNodeInfo(info);
- info.setClassName(Switch.class.getName());
- CharSequence switchText = isChecked() ? mTextOn : mTextOff;
- if (!TextUtils.isEmpty(switchText)) {
- CharSequence oldText = info.getText();
- if (TextUtils.isEmpty(oldText)) {
- info.setText(switchText);
- } else {
- StringBuilder newText = new StringBuilder();
- newText.append(oldText).append(' ').append(switchText);
- info.setText(newText);
- }
- }
- }
-}
diff --git a/src/com/android/camera/ui/TimeIntervalPopup.java b/src/com/android/camera/ui/TimeIntervalPopup.java
deleted file mode 100644
index 18ad9f5..0000000
--- a/src/com/android/camera/ui/TimeIntervalPopup.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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.
- */
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CompoundButton;
-import android.widget.NumberPicker;
-import android.widget.Switch;
-import android.widget.TextView;
-
-import com.android.camera.IconListPreference;
-import com.android.camera.ListPreference;
-import com.android.gallery3d.R;
-
-/**
- * This is a popup window that allows users to turn on/off time lapse feature,
- * and to select a time interval for taking a time lapse video.
- */
-public class TimeIntervalPopup extends AbstractSettingPopup {
- private static final String TAG = "TimeIntervalPopup";
- private NumberPicker mNumberSpinner;
- private NumberPicker mUnitSpinner;
- private Switch mTimeLapseSwitch;
- private final String[] mUnits;
- private final String[] mDurations;
- private IconListPreference mPreference;
- private Listener mListener;
- private Button mConfirmButton;
- private TextView mHelpText;
- private View mTimePicker;
-
- static public interface Listener {
- public void onListPrefChanged(ListPreference pref);
- }
-
- public void setSettingChangedListener(Listener listener) {
- mListener = listener;
- }
-
- public TimeIntervalPopup(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- Resources res = context.getResources();
- mUnits = res.getStringArray(R.array.pref_video_time_lapse_frame_interval_units);
- mDurations = res
- .getStringArray(R.array.pref_video_time_lapse_frame_interval_duration_values);
- }
-
- public void initialize(IconListPreference preference) {
- mPreference = preference;
-
- // Set title.
- mTitle.setText(mPreference.getTitle());
-
- // Duration
- int durationCount = mDurations.length;
- mNumberSpinner = (NumberPicker) findViewById(R.id.duration);
- mNumberSpinner.setMinValue(0);
- mNumberSpinner.setMaxValue(durationCount - 1);
- mNumberSpinner.setDisplayedValues(mDurations);
- mNumberSpinner.setWrapSelectorWheel(false);
-
- // Units for duration (i.e. seconds, minutes, etc)
- mUnitSpinner = (NumberPicker) findViewById(R.id.duration_unit);
- mUnitSpinner.setMinValue(0);
- mUnitSpinner.setMaxValue(mUnits.length - 1);
- mUnitSpinner.setDisplayedValues(mUnits);
- mUnitSpinner.setWrapSelectorWheel(false);
-
- mTimePicker = findViewById(R.id.time_interval_picker);
- mTimeLapseSwitch = (Switch) findViewById(R.id.time_lapse_switch);
- mHelpText = (TextView) findViewById(R.id.set_time_interval_help_text);
- mConfirmButton = (Button) findViewById(R.id.time_lapse_interval_set_button);
-
- // Disable focus on the spinners to prevent keyboard from coming up
- mNumberSpinner.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
- mUnitSpinner.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
-
- mTimeLapseSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- setTimeSelectionEnabled(isChecked);
- }
- });
- mConfirmButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- updateInputState();
- }
- });
- }
-
- private void restoreSetting() {
- int index = mPreference.findIndexOfValue(mPreference.getValue());
- if (index == -1) {
- Log.e(TAG, "Invalid preference value.");
- mPreference.print();
- throw new IllegalArgumentException();
- } else if (index == 0) {
- // default choice: time lapse off
- mTimeLapseSwitch.setChecked(false);
- setTimeSelectionEnabled(false);
- } else {
- mTimeLapseSwitch.setChecked(true);
- setTimeSelectionEnabled(true);
- int durationCount = mNumberSpinner.getMaxValue() + 1;
- int unit = (index - 1) / durationCount;
- int number = (index - 1) % durationCount;
- mUnitSpinner.setValue(unit);
- mNumberSpinner.setValue(number);
- }
- }
-
- @Override
- public void setVisibility(int visibility) {
- if (visibility == View.VISIBLE) {
- if (getVisibility() != View.VISIBLE) {
- // Set the number pickers and on/off switch to be consistent
- // with the preference
- restoreSetting();
- }
- }
- super.setVisibility(visibility);
- }
-
- protected void setTimeSelectionEnabled(boolean enabled) {
- mHelpText.setVisibility(enabled ? GONE : VISIBLE);
- mTimePicker.setVisibility(enabled ? VISIBLE : GONE);
- }
-
- @Override
- public void reloadPreference() {
- }
-
- private void updateInputState() {
- if (mTimeLapseSwitch.isChecked()) {
- int newId = mUnitSpinner.getValue() * (mNumberSpinner.getMaxValue() + 1)
- + mNumberSpinner.getValue() + 1;
- mPreference.setValueIndex(newId);
- } else {
- mPreference.setValueIndex(0);
- }
-
- if (mListener != null) {
- mListener.onListPrefChanged(mPreference);
- }
- }
-}
diff --git a/src/com/android/camera/ui/TwoStateImageView.java b/src/com/android/camera/ui/TwoStateImageView.java
deleted file mode 100644
index cd5b27f..0000000
--- a/src/com/android/camera/ui/TwoStateImageView.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.ImageView;
-
-/**
- * A @{code ImageView} which change the opacity of the icon if disabled.
- */
-public class TwoStateImageView extends ImageView {
- private static final int ENABLED_ALPHA = 255;
- private static final int DISABLED_ALPHA = (int) (255 * 0.4);
- private boolean mFilterEnabled = true;
-
- public TwoStateImageView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public TwoStateImageView(Context context) {
- this(context, null);
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- if (mFilterEnabled) {
- if (enabled) {
- setAlpha(ENABLED_ALPHA);
- } else {
- setAlpha(DISABLED_ALPHA);
- }
- }
- }
-
- public void enableFilter(boolean enabled) {
- mFilterEnabled = enabled;
- }
-}
diff --git a/src/com/android/camera/ui/ZoomRenderer.java b/src/com/android/camera/ui/ZoomRenderer.java
deleted file mode 100644
index 86b82b4..0000000
--- a/src/com/android/camera/ui/ZoomRenderer.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.view.ScaleGestureDetector;
-
-import com.android.gallery3d.R;
-
-public class ZoomRenderer extends OverlayRenderer
- implements ScaleGestureDetector.OnScaleGestureListener {
-
- private static final String TAG = "CAM_Zoom";
-
- private int mMaxZoom;
- private int mMinZoom;
- private OnZoomChangedListener mListener;
-
- private ScaleGestureDetector mDetector;
- private Paint mPaint;
- private Paint mTextPaint;
- private int mCircleSize;
- private int mCenterX;
- private int mCenterY;
- private float mMaxCircle;
- private float mMinCircle;
- private int mInnerStroke;
- private int mOuterStroke;
- private int mZoomSig;
- private int mZoomFraction;
- private Rect mTextBounds;
-
- public interface OnZoomChangedListener {
- void onZoomStart();
- void onZoomEnd();
- void onZoomValueChanged(int index); // only for immediate zoom
- }
-
- public ZoomRenderer(Context ctx) {
- Resources res = ctx.getResources();
- mPaint = new Paint();
- mPaint.setAntiAlias(true);
- mPaint.setColor(Color.WHITE);
- mPaint.setStyle(Paint.Style.STROKE);
- mTextPaint = new Paint(mPaint);
- mTextPaint.setStyle(Paint.Style.FILL);
- mTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.zoom_font_size));
- mTextPaint.setTextAlign(Paint.Align.LEFT);
- mTextPaint.setAlpha(192);
- mInnerStroke = res.getDimensionPixelSize(R.dimen.focus_inner_stroke);
- mOuterStroke = res.getDimensionPixelSize(R.dimen.focus_outer_stroke);
- mDetector = new ScaleGestureDetector(ctx, this);
- mMinCircle = res.getDimensionPixelSize(R.dimen.zoom_ring_min);
- mTextBounds = new Rect();
- setVisible(false);
- }
-
- // set from module
- public void setZoomMax(int zoomMaxIndex) {
- mMaxZoom = zoomMaxIndex;
- mMinZoom = 0;
- }
-
- public void setZoom(int index) {
- mCircleSize = (int) (mMinCircle + index * (mMaxCircle - mMinCircle) / (mMaxZoom - mMinZoom));
- }
-
- public void setZoomValue(int value) {
- value = value / 10;
- mZoomSig = value / 10;
- mZoomFraction = value % 10;
- }
-
- public void setOnZoomChangeListener(OnZoomChangedListener listener) {
- mListener = listener;
- }
-
- @Override
- public void layout(int l, int t, int r, int b) {
- super.layout(l, t, r, b);
- mCenterX = (r - l) / 2;
- mCenterY = (b - t) / 2;
- mMaxCircle = Math.min(getWidth(), getHeight());
- mMaxCircle = (mMaxCircle - mMinCircle) / 2;
- }
-
- public boolean isScaling() {
- return mDetector.isInProgress();
- }
-
- @Override
- public void onDraw(Canvas canvas) {
- mPaint.setStrokeWidth(mInnerStroke);
- canvas.drawCircle(mCenterX, mCenterY, mMinCircle, mPaint);
- canvas.drawCircle(mCenterX, mCenterY, mMaxCircle, mPaint);
- canvas.drawLine(mCenterX - mMinCircle, mCenterY,
- mCenterX - mMaxCircle - 4, mCenterY, mPaint);
- mPaint.setStrokeWidth(mOuterStroke);
- canvas.drawCircle((float) mCenterX, (float) mCenterY,
- (float) mCircleSize, mPaint);
- String txt = mZoomSig+"."+mZoomFraction+"x";
- mTextPaint.getTextBounds(txt, 0, txt.length(), mTextBounds);
- canvas.drawText(txt, mCenterX - mTextBounds.centerX(), mCenterY - mTextBounds.centerY(),
- mTextPaint);
- }
-
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- final float sf = detector.getScaleFactor();
- float circle = (int) (mCircleSize * sf * sf);
- circle = Math.max(mMinCircle, circle);
- circle = Math.min(mMaxCircle, circle);
- if (mListener != null && (int) circle != mCircleSize) {
- mCircleSize = (int) circle;
- int zoom = mMinZoom + (int) ((mCircleSize - mMinCircle) * (mMaxZoom - mMinZoom) / (mMaxCircle - mMinCircle));
- mListener.onZoomValueChanged(zoom);
- }
- return true;
- }
-
- @Override
- public boolean onScaleBegin(ScaleGestureDetector detector) {
- setVisible(true);
- if (mListener != null) {
- mListener.onZoomStart();
- }
- update();
- return true;
- }
-
- @Override
- public void onScaleEnd(ScaleGestureDetector detector) {
- setVisible(false);
- if (mListener != null) {
- mListener.onZoomEnd();
- }
- }
-
-}
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
index ac39aa5..9af1fb8 100644
--- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java
+++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
@@ -29,8 +29,10 @@
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.res.Configuration;
+import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
+import android.support.v4.print.PrintHelper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
@@ -40,14 +42,16 @@
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.ui.GLRootView;
-import com.android.gallery3d.util.LightCycleHelper.PanoramaViewHelper;
+import com.android.gallery3d.util.PanoramaViewHelper;
import com.android.gallery3d.util.ThreadPool;
import com.android.photos.data.GalleryBitmapPool;
+import java.io.FileNotFoundException;
+
public class AbstractGalleryActivity extends Activity implements GalleryContext {
- @SuppressWarnings("unused")
private static final String TAG = "AbstractGalleryActivity";
private GLRootView mGLRootView;
private StateManager mStateManager;
@@ -311,10 +315,12 @@
private BatchService mBatchService;
private boolean mBatchServiceIsBound = false;
private ServiceConnection mBatchServiceConnection = new ServiceConnection() {
+ @Override
public void onServiceConnected(ComponentName className, IBinder service) {
mBatchService = ((BatchService.LocalBinder)service).getService();
}
+ @Override
public void onServiceDisconnected(ComponentName className) {
mBatchService = null;
}
@@ -340,4 +346,23 @@
throw new RuntimeException("Batch service unavailable");
}
}
+
+ public void printSelectedImage(Uri uri) {
+ if (uri == null) {
+ return;
+ }
+ String path = ImageLoader.getLocalPathFromUri(this, uri);
+ if (path != null) {
+ Uri localUri = Uri.parse(path);
+ path = localUri.getLastPathSegment();
+ } else {
+ path = uri.getLastPathSegment();
+ }
+ PrintHelper printer = new PrintHelper(this);
+ try {
+ printer.printBitmap(path, uri);
+ } catch (FileNotFoundException fnfe) {
+ Log.e(TAG, "Error printing an image", fnfe);
+ }
+ }
}
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 001ce87..44f2404 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -39,7 +39,7 @@
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
-import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.crop.CropActivity;
import com.android.gallery3d.filtershow.crop.CropExtras;
import com.android.gallery3d.glrenderer.FadeTexture;
import com.android.gallery3d.glrenderer.GLCanvas;
@@ -316,9 +316,9 @@
private void onGetContent(final MediaItem item) {
DataManager dm = mActivity.getDataManager();
Activity activity = mActivity;
- if (mData.getString(Gallery.EXTRA_CROP) != null) {
+ if (mData.getString(GalleryActivity.EXTRA_CROP) != null) {
Uri uri = dm.getContentUri(item.getPath());
- Intent intent = new Intent(FilterShowActivity.CROP_ACTION, uri)
+ Intent intent = new Intent(CropActivity.CROP_ACTION, uri)
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
.putExtras(getData());
if (mData.getParcelable(MediaStore.EXTRA_OUTPUT) == null) {
@@ -367,7 +367,7 @@
mUserDistance = GalleryUtils.meterToPixel(USER_DISTANCE_METER);
initializeViews();
initializeData(data);
- mGetContent = data.getBoolean(Gallery.KEY_GET_CONTENT, false);
+ mGetContent = data.getBoolean(GalleryActivity.KEY_GET_CONTENT, false);
mShowClusterMenu = data.getBoolean(KEY_SHOW_CLUSTER_MENU, false);
mDetailsSource = new MyDetailsSource();
Context context = mActivity.getAndroidContext();
@@ -544,7 +544,7 @@
MenuInflater inflator = getSupportMenuInflater();
if (mGetContent) {
inflator.inflate(R.menu.pickup, menu);
- int typeBits = mData.getInt(Gallery.KEY_TYPE_BITS,
+ int typeBits = mData.getInt(GalleryActivity.KEY_TYPE_BITS,
DataManager.INCLUDE_IMAGE);
actionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
} else {
diff --git a/src/com/android/gallery3d/app/AlbumPicker.java b/src/com/android/gallery3d/app/AlbumPicker.java
index 65eb772..8c2d09a 100644
--- a/src/com/android/gallery3d/app/AlbumPicker.java
+++ b/src/com/android/gallery3d/app/AlbumPicker.java
@@ -32,7 +32,7 @@
Bundle extras = intent.getExtras();
Bundle data = extras == null ? new Bundle() : new Bundle(extras);
- data.putBoolean(Gallery.KEY_GET_ALBUM, true);
+ data.putBoolean(GalleryActivity.KEY_GET_ALBUM, true);
data.putString(AlbumSetPage.KEY_MEDIA_PATH,
getDataManager().getTopSetPath(DataManager.INCLUDE_IMAGE));
getStateManager().startState(AlbumSetPage.class, data);
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index 4708e6f..d56b5b8 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -322,8 +322,8 @@
initializeViews();
initializeData(data);
Context context = mActivity.getAndroidContext();
- mGetContent = data.getBoolean(Gallery.KEY_GET_CONTENT, false);
- mGetAlbum = data.getBoolean(Gallery.KEY_GET_ALBUM, false);
+ mGetContent = data.getBoolean(GalleryActivity.KEY_GET_CONTENT, false);
+ mGetAlbum = data.getBoolean(GalleryActivity.KEY_GET_ALBUM, false);
mTitle = data.getString(AlbumSetPage.KEY_SET_TITLE);
mSubtitle = data.getString(AlbumSetPage.KEY_SET_SUBTITLE);
mEyePosition = new EyePosition(context, this);
@@ -534,7 +534,7 @@
if (mGetContent) {
inflater.inflate(R.menu.pickup, menu);
int typeBits = mData.getInt(
- Gallery.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE);
+ GalleryActivity.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE);
mActionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
} else if (mGetAlbum) {
inflater.inflate(R.menu.pickup, menu);
@@ -554,7 +554,7 @@
FilterUtils.setupMenuItems(mActionBar, mMediaSet.getPath(), false);
- Intent helpIntent = HelpUtils.getHelpIntent(activity, R.string.help_url_gallery_main);
+ Intent helpIntent = HelpUtils.getHelpIntent(activity);
MenuItem helpItem = menu.findItem(R.id.action_general_help);
helpItem.setVisible(helpIntent != null);
diff --git a/src/com/android/gallery3d/app/CommonControllerOverlay.java b/src/com/android/gallery3d/app/CommonControllerOverlay.java
index a4f5807..9adb4e7 100644
--- a/src/com/android/gallery3d/app/CommonControllerOverlay.java
+++ b/src/com/android/gallery3d/app/CommonControllerOverlay.java
@@ -66,6 +66,10 @@
protected boolean mCanReplay = true;
+ public void setSeekable(boolean canSeek) {
+ mTimeBar.setSeekable(canSeek);
+ }
+
public CommonControllerOverlay(Context context) {
super(context);
diff --git a/src/com/android/gallery3d/app/DialogPicker.java b/src/com/android/gallery3d/app/DialogPicker.java
index 7ca86e5..1de3324 100644
--- a/src/com/android/gallery3d/app/DialogPicker.java
+++ b/src/com/android/gallery3d/app/DialogPicker.java
@@ -33,7 +33,7 @@
Bundle extras = intent.getExtras();
Bundle data = extras == null ? new Bundle() : new Bundle(extras);
- data.putBoolean(Gallery.KEY_GET_CONTENT, true);
+ data.putBoolean(GalleryActivity.KEY_GET_CONTENT, true);
data.putString(AlbumSetPage.KEY_MEDIA_PATH,
getDataManager().getTopSetPath(typeBits));
getStateManager().startState(AlbumSetPage.class, data);
diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java
index baef56b..a1b6d01 100644
--- a/src/com/android/gallery3d/app/Gallery.java
+++ b/src/com/android/gallery3d/app/Gallery.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * 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.
@@ -13,262 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.android.gallery3d.app;
-import android.app.Dialog;
-import android.content.ContentResolver;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnCancelListener;
+import com.android.gallery3d.util.IntentHelper;
+
+import android.app.Activity;
import android.content.Intent;
-import android.net.Uri;
import android.os.Bundle;
-import android.view.InputDevice;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.Toast;
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaSet;
-import com.android.gallery3d.data.Path;
-import com.android.gallery3d.picasasource.PicasaSource;
-import com.android.gallery3d.util.GalleryUtils;
-
-public final class Gallery extends AbstractGalleryActivity implements OnCancelListener {
- public static final String EXTRA_SLIDESHOW = "slideshow";
- public static final String EXTRA_DREAM = "dream";
- public static final String EXTRA_CROP = "crop";
-
- public static final String ACTION_REVIEW = "com.android.camera.action.REVIEW";
- public static final String KEY_GET_CONTENT = "get-content";
- public static final String KEY_GET_ALBUM = "get-album";
- public static final String KEY_TYPE_BITS = "type-bits";
- public static final String KEY_MEDIA_TYPES = "mediaTypes";
- public static final String KEY_DISMISS_KEYGUARD = "dismiss-keyguard";
-
- private static final String TAG = "Gallery";
- private Dialog mVersionCheckDialog;
-
+/** Trampoline activity that launches the Gallery activity defined in IntentHelper. */
+public class Gallery extends Activity {
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_ACTION_BAR);
- requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
-
- if (getIntent().getBooleanExtra(KEY_DISMISS_KEYGUARD, false)) {
- getWindow().addFlags(
- WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
- }
-
- setContentView(R.layout.main);
-
- if (savedInstanceState != null) {
- getStateManager().restoreFromState(savedInstanceState);
- } else {
- initializeByIntent();
- }
- }
-
- private void initializeByIntent() {
- Intent intent = getIntent();
- String action = intent.getAction();
-
- if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) {
- startGetContent(intent);
- } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) {
- // We do NOT really support the PICK intent. Handle it as
- // the GET_CONTENT. However, we need to translate the type
- // in the intent here.
- Log.w(TAG, "action PICK is not supported");
- String type = Utils.ensureNotNull(intent.getType());
- if (type.startsWith("vnd.android.cursor.dir/")) {
- if (type.endsWith("/image")) intent.setType("image/*");
- if (type.endsWith("/video")) intent.setType("video/*");
- }
- startGetContent(intent);
- } else if (Intent.ACTION_VIEW.equalsIgnoreCase(action)
- || ACTION_REVIEW.equalsIgnoreCase(action)){
- startViewAction(intent);
- } else {
- startDefaultPage();
- }
- }
-
- public void startDefaultPage() {
- PicasaSource.showSignInReminder(this);
- Bundle data = new Bundle();
- data.putString(AlbumSetPage.KEY_MEDIA_PATH,
- getDataManager().getTopSetPath(DataManager.INCLUDE_ALL));
- getStateManager().startState(AlbumSetPage.class, data);
- mVersionCheckDialog = PicasaSource.getVersionCheckDialog(this);
- if (mVersionCheckDialog != null) {
- mVersionCheckDialog.setOnCancelListener(this);
- }
- }
-
- private void startGetContent(Intent intent) {
- Bundle data = intent.getExtras() != null
- ? new Bundle(intent.getExtras())
- : new Bundle();
- data.putBoolean(KEY_GET_CONTENT, true);
- int typeBits = GalleryUtils.determineTypeBits(this, intent);
- data.putInt(KEY_TYPE_BITS, typeBits);
- data.putString(AlbumSetPage.KEY_MEDIA_PATH,
- getDataManager().getTopSetPath(typeBits));
- getStateManager().startState(AlbumSetPage.class, data);
- }
-
- private String getContentType(Intent intent) {
- String type = intent.getType();
- if (type != null) {
- return GalleryUtils.MIME_TYPE_PANORAMA360.equals(type)
- ? MediaItem.MIME_TYPE_JPEG : type;
- }
-
- Uri uri = intent.getData();
- try {
- return getContentResolver().getType(uri);
- } catch (Throwable t) {
- Log.w(TAG, "get type fail", t);
- return null;
- }
- }
-
- private void startViewAction(Intent intent) {
- Boolean slideshow = intent.getBooleanExtra(EXTRA_SLIDESHOW, false);
- if (slideshow) {
- getActionBar().hide();
- DataManager manager = getDataManager();
- Path path = manager.findPathByUri(intent.getData(), intent.getType());
- if (path == null || manager.getMediaObject(path)
- instanceof MediaItem) {
- path = Path.fromString(
- manager.getTopSetPath(DataManager.INCLUDE_IMAGE));
- }
- Bundle data = new Bundle();
- data.putString(SlideshowPage.KEY_SET_PATH, path.toString());
- data.putBoolean(SlideshowPage.KEY_RANDOM_ORDER, true);
- data.putBoolean(SlideshowPage.KEY_REPEAT, true);
- if (intent.getBooleanExtra(EXTRA_DREAM, false)) {
- data.putBoolean(SlideshowPage.KEY_DREAM, true);
- }
- getStateManager().startState(SlideshowPage.class, data);
- } else {
- Bundle data = new Bundle();
- DataManager dm = getDataManager();
- Uri uri = intent.getData();
- String contentType = getContentType(intent);
- if (contentType == null) {
- Toast.makeText(this,
- R.string.no_such_item, Toast.LENGTH_LONG).show();
- finish();
- return;
- }
- if (uri == null) {
- int typeBits = GalleryUtils.determineTypeBits(this, intent);
- data.putInt(KEY_TYPE_BITS, typeBits);
- data.putString(AlbumSetPage.KEY_MEDIA_PATH,
- getDataManager().getTopSetPath(typeBits));
- getStateManager().startState(AlbumSetPage.class, data);
- } else if (contentType.startsWith(
- ContentResolver.CURSOR_DIR_BASE_TYPE)) {
- int mediaType = intent.getIntExtra(KEY_MEDIA_TYPES, 0);
- if (mediaType != 0) {
- uri = uri.buildUpon().appendQueryParameter(
- KEY_MEDIA_TYPES, String.valueOf(mediaType))
- .build();
- }
- Path setPath = dm.findPathByUri(uri, null);
- MediaSet mediaSet = null;
- if (setPath != null) {
- mediaSet = (MediaSet) dm.getMediaObject(setPath);
- }
- if (mediaSet != null) {
- if (mediaSet.isLeafAlbum()) {
- data.putString(AlbumPage.KEY_MEDIA_PATH, setPath.toString());
- data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH,
- dm.getTopSetPath(DataManager.INCLUDE_ALL));
- getStateManager().startState(AlbumPage.class, data);
- } else {
- data.putString(AlbumSetPage.KEY_MEDIA_PATH, setPath.toString());
- getStateManager().startState(AlbumSetPage.class, data);
- }
- } else {
- startDefaultPage();
- }
- } else {
- Path itemPath = dm.findPathByUri(uri, contentType);
- Path albumPath = dm.getDefaultSetOf(itemPath);
-
- data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());
-
- // TODO: Make the parameter "SingleItemOnly" public so other
- // activities can reference it.
- boolean singleItemOnly = (albumPath == null)
- || intent.getBooleanExtra("SingleItemOnly", false);
- if (!singleItemOnly) {
- data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString());
- // when FLAG_ACTIVITY_NEW_TASK is set, (e.g. when intent is fired
- // from notification), back button should behave the same as up button
- // rather than taking users back to the home screen
- if (intent.getBooleanExtra(PhotoPage.KEY_TREAT_BACK_AS_UP, false)
- || ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0)) {
- data.putBoolean(PhotoPage.KEY_TREAT_BACK_AS_UP, true);
- }
- }
-
- getStateManager().startState(SinglePhotoPage.class, data);
- }
- }
- }
-
- @Override
- protected void onResume() {
- Utils.assertTrue(getStateManager().getStateCount() > 0);
- super.onResume();
- if (mVersionCheckDialog != null) {
- mVersionCheckDialog.show();
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- if (mVersionCheckDialog != null) {
- mVersionCheckDialog.dismiss();
- }
- }
-
- @Override
- public void onCancel(DialogInterface dialog) {
- if (dialog == mVersionCheckDialog) {
- mVersionCheckDialog = null;
- }
- }
-
- @Override
- public boolean onGenericMotionEvent(MotionEvent event) {
- final boolean isTouchPad = (event.getSource()
- & InputDevice.SOURCE_CLASS_POSITION) != 0;
- if (isTouchPad) {
- float maxX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax();
- float maxY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax();
- View decor = getWindow().getDecorView();
- float scaleX = decor.getWidth() / maxX;
- float scaleY = decor.getHeight() / maxY;
- float x = event.getX() * scaleX;
- //x = decor.getWidth() - x; // invert x
- float y = event.getY() * scaleY;
- //y = decor.getHeight() - y; // invert y
- MotionEvent touchEvent = MotionEvent.obtain(event.getDownTime(),
- event.getEventTime(), event.getAction(), x, y, event.getMetaState());
- return dispatchTouchEvent(touchEvent);
- }
- return super.onGenericMotionEvent(event);
+ Intent intent = IntentHelper.getGalleryIntent(Gallery.this);
+ // Since this is being launched from a homescreen shortcut,
+ // it's already in a new task. Start Gallery activity and
+ // reset the task to its initial state if needed.
+ intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ startActivity(intent);
+ finish();
}
}
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
new file mode 100644
index 0000000..bb2a6b8
--- /dev/null
+++ b/src/com/android/gallery3d/app/GalleryActivity.java
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2009 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.app;
+
+import android.app.Dialog;
+import android.content.ContentResolver;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.InputDevice;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.data.DataManager;
+import com.android.gallery3d.data.MediaItem;
+import com.android.gallery3d.data.MediaSet;
+import com.android.gallery3d.data.Path;
+import com.android.gallery3d.picasasource.PicasaSource;
+import com.android.gallery3d.util.GalleryUtils;
+
+public final class GalleryActivity extends AbstractGalleryActivity implements OnCancelListener {
+ public static final String EXTRA_SLIDESHOW = "slideshow";
+ public static final String EXTRA_DREAM = "dream";
+ public static final String EXTRA_CROP = "crop";
+
+ public static final String ACTION_REVIEW = "com.android.camera.action.REVIEW";
+ public static final String KEY_GET_CONTENT = "get-content";
+ public static final String KEY_GET_ALBUM = "get-album";
+ public static final String KEY_TYPE_BITS = "type-bits";
+ public static final String KEY_MEDIA_TYPES = "mediaTypes";
+ public static final String KEY_DISMISS_KEYGUARD = "dismiss-keyguard";
+
+ private static final String TAG = "GalleryActivity";
+ private Dialog mVersionCheckDialog;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_ACTION_BAR);
+ requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
+
+ if (getIntent().getBooleanExtra(KEY_DISMISS_KEYGUARD, false)) {
+ getWindow().addFlags(
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
+ }
+
+ setContentView(R.layout.main);
+
+ if (savedInstanceState != null) {
+ getStateManager().restoreFromState(savedInstanceState);
+ } else {
+ initializeByIntent();
+ }
+ }
+
+ private void initializeByIntent() {
+ Intent intent = getIntent();
+ String action = intent.getAction();
+
+ if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) {
+ startGetContent(intent);
+ } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) {
+ // We do NOT really support the PICK intent. Handle it as
+ // the GET_CONTENT. However, we need to translate the type
+ // in the intent here.
+ Log.w(TAG, "action PICK is not supported");
+ String type = Utils.ensureNotNull(intent.getType());
+ if (type.startsWith("vnd.android.cursor.dir/")) {
+ if (type.endsWith("/image")) intent.setType("image/*");
+ if (type.endsWith("/video")) intent.setType("video/*");
+ }
+ startGetContent(intent);
+ } else if (Intent.ACTION_VIEW.equalsIgnoreCase(action)
+ || ACTION_REVIEW.equalsIgnoreCase(action)){
+ startViewAction(intent);
+ } else {
+ startDefaultPage();
+ }
+ }
+
+ public void startDefaultPage() {
+ PicasaSource.showSignInReminder(this);
+ Bundle data = new Bundle();
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH,
+ getDataManager().getTopSetPath(DataManager.INCLUDE_ALL));
+ getStateManager().startState(AlbumSetPage.class, data);
+ mVersionCheckDialog = PicasaSource.getVersionCheckDialog(this);
+ if (mVersionCheckDialog != null) {
+ mVersionCheckDialog.setOnCancelListener(this);
+ }
+ }
+
+ private void startGetContent(Intent intent) {
+ Bundle data = intent.getExtras() != null
+ ? new Bundle(intent.getExtras())
+ : new Bundle();
+ data.putBoolean(KEY_GET_CONTENT, true);
+ int typeBits = GalleryUtils.determineTypeBits(this, intent);
+ data.putInt(KEY_TYPE_BITS, typeBits);
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH,
+ getDataManager().getTopSetPath(typeBits));
+ getStateManager().startState(AlbumSetPage.class, data);
+ }
+
+ private String getContentType(Intent intent) {
+ String type = intent.getType();
+ if (type != null) {
+ return GalleryUtils.MIME_TYPE_PANORAMA360.equals(type)
+ ? MediaItem.MIME_TYPE_JPEG : type;
+ }
+
+ Uri uri = intent.getData();
+ try {
+ return getContentResolver().getType(uri);
+ } catch (Throwable t) {
+ Log.w(TAG, "get type fail", t);
+ return null;
+ }
+ }
+
+ private void startViewAction(Intent intent) {
+ Boolean slideshow = intent.getBooleanExtra(EXTRA_SLIDESHOW, false);
+ if (slideshow) {
+ getActionBar().hide();
+ DataManager manager = getDataManager();
+ Path path = manager.findPathByUri(intent.getData(), intent.getType());
+ if (path == null || manager.getMediaObject(path)
+ instanceof MediaItem) {
+ path = Path.fromString(
+ manager.getTopSetPath(DataManager.INCLUDE_IMAGE));
+ }
+ Bundle data = new Bundle();
+ data.putString(SlideshowPage.KEY_SET_PATH, path.toString());
+ data.putBoolean(SlideshowPage.KEY_RANDOM_ORDER, true);
+ data.putBoolean(SlideshowPage.KEY_REPEAT, true);
+ if (intent.getBooleanExtra(EXTRA_DREAM, false)) {
+ data.putBoolean(SlideshowPage.KEY_DREAM, true);
+ }
+ getStateManager().startState(SlideshowPage.class, data);
+ } else {
+ Bundle data = new Bundle();
+ DataManager dm = getDataManager();
+ Uri uri = intent.getData();
+ String contentType = getContentType(intent);
+ if (contentType == null) {
+ Toast.makeText(this,
+ R.string.no_such_item, Toast.LENGTH_LONG).show();
+ finish();
+ return;
+ }
+ if (uri == null) {
+ int typeBits = GalleryUtils.determineTypeBits(this, intent);
+ data.putInt(KEY_TYPE_BITS, typeBits);
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH,
+ getDataManager().getTopSetPath(typeBits));
+ getStateManager().startState(AlbumSetPage.class, data);
+ } else if (contentType.startsWith(
+ ContentResolver.CURSOR_DIR_BASE_TYPE)) {
+ int mediaType = intent.getIntExtra(KEY_MEDIA_TYPES, 0);
+ if (mediaType != 0) {
+ uri = uri.buildUpon().appendQueryParameter(
+ KEY_MEDIA_TYPES, String.valueOf(mediaType))
+ .build();
+ }
+ Path setPath = dm.findPathByUri(uri, null);
+ MediaSet mediaSet = null;
+ if (setPath != null) {
+ mediaSet = (MediaSet) dm.getMediaObject(setPath);
+ }
+ if (mediaSet != null) {
+ if (mediaSet.isLeafAlbum()) {
+ data.putString(AlbumPage.KEY_MEDIA_PATH, setPath.toString());
+ data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH,
+ dm.getTopSetPath(DataManager.INCLUDE_ALL));
+ getStateManager().startState(AlbumPage.class, data);
+ } else {
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH, setPath.toString());
+ getStateManager().startState(AlbumSetPage.class, data);
+ }
+ } else {
+ startDefaultPage();
+ }
+ } else {
+ Path itemPath = dm.findPathByUri(uri, contentType);
+ Path albumPath = dm.getDefaultSetOf(itemPath);
+
+ data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());
+ data.putBoolean(PhotoPage.KEY_READONLY, true);
+
+ // TODO: Make the parameter "SingleItemOnly" public so other
+ // activities can reference it.
+ boolean singleItemOnly = (albumPath == null)
+ || intent.getBooleanExtra("SingleItemOnly", false);
+ if (!singleItemOnly) {
+ data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString());
+ // when FLAG_ACTIVITY_NEW_TASK is set, (e.g. when intent is fired
+ // from notification), back button should behave the same as up button
+ // rather than taking users back to the home screen
+ if (intent.getBooleanExtra(PhotoPage.KEY_TREAT_BACK_AS_UP, false)
+ || ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0)) {
+ data.putBoolean(PhotoPage.KEY_TREAT_BACK_AS_UP, true);
+ }
+ }
+
+ getStateManager().startState(SinglePhotoPage.class, data);
+ }
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ Utils.assertTrue(getStateManager().getStateCount() > 0);
+ super.onResume();
+ if (mVersionCheckDialog != null) {
+ mVersionCheckDialog.show();
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if (mVersionCheckDialog != null) {
+ mVersionCheckDialog.dismiss();
+ }
+ }
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ if (dialog == mVersionCheckDialog) {
+ mVersionCheckDialog = null;
+ }
+ }
+
+ @Override
+ public boolean onGenericMotionEvent(MotionEvent event) {
+ final boolean isTouchPad = (event.getSource()
+ & InputDevice.SOURCE_CLASS_POSITION) != 0;
+ if (isTouchPad) {
+ float maxX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax();
+ float maxY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax();
+ View decor = getWindow().getDecorView();
+ float scaleX = decor.getWidth() / maxX;
+ float scaleY = decor.getHeight() / maxY;
+ float x = event.getX() * scaleX;
+ //x = decor.getWidth() - x; // invert x
+ float y = event.getY() * scaleY;
+ //y = decor.getHeight() - y; // invert y
+ MotionEvent touchEvent = MotionEvent.obtain(event.getDownTime(),
+ event.getEventTime(), event.getAction(), x, y, event.getMetaState());
+ return dispatchTouchEvent(touchEvent);
+ }
+ return super.onGenericMotionEvent(event);
+ }
+}
diff --git a/src/com/android/gallery3d/app/GalleryApp.java b/src/com/android/gallery3d/app/GalleryApp.java
index b56b8a8..98bf75b 100644
--- a/src/com/android/gallery3d/app/GalleryApp.java
+++ b/src/com/android/gallery3d/app/GalleryApp.java
@@ -29,7 +29,6 @@
public interface GalleryApp {
public DataManager getDataManager();
- public StitchingProgressManager getStitchingProgressManager();
public ImageCacheService getImageCacheService();
public DownloadCache getDownloadCache();
public ThreadPool getThreadPool();
diff --git a/src/com/android/gallery3d/app/GalleryAppImpl.java b/src/com/android/gallery3d/app/GalleryAppImpl.java
index 2abdaa0..c6e7a0b 100644
--- a/src/com/android/gallery3d/app/GalleryAppImpl.java
+++ b/src/com/android/gallery3d/app/GalleryAppImpl.java
@@ -29,7 +29,6 @@
import com.android.gallery3d.util.LightCycleHelper;
import com.android.gallery3d.util.ThreadPool;
import com.android.gallery3d.util.UsageStatistics;
-import com.android.photos.data.MediaCache;
import java.io.File;
@@ -43,23 +42,15 @@
private DataManager mDataManager;
private ThreadPool mThreadPool;
private DownloadCache mDownloadCache;
- private StitchingProgressManager mStitchingProgressManager;
@Override
public void onCreate() {
super.onCreate();
- com.android.camera.Util.initialize(this);
initializeAsyncTask();
GalleryUtils.initialize(this);
WidgetUtils.initialize(this);
PicasaSource.initialize(this);
UsageStatistics.initialize(this);
- MediaCache.initialize(this);
-
- mStitchingProgressManager = LightCycleHelper.createStitchingManagerInstance(this);
- if (mStitchingProgressManager != null) {
- mStitchingProgressManager.addChangeListener(getDataManager());
- }
}
@Override
@@ -76,10 +67,6 @@
return mDataManager;
}
- @Override
- public StitchingProgressManager getStitchingProgressManager() {
- return mStitchingProgressManager;
- }
@Override
public ImageCacheService getImageCacheService() {
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index 40edbbe..1547f6f 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -198,7 +198,7 @@
if (mTreatUpAsBack) {
finish();
} else {
- startActivity(new Intent(this, Gallery.class));
+ startActivity(new Intent(this, GalleryActivity.class));
finish();
}
return true;
diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java
index 513d052..f6bd367 100644
--- a/src/com/android/gallery3d/app/MoviePlayer.java
+++ b/src/com/android/gallery3d/app/MoviePlayer.java
@@ -25,7 +25,6 @@
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
-import android.graphics.Color;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.audiofx.AudioEffect;
@@ -133,29 +132,16 @@
mVideoView.setOnErrorListener(this);
mVideoView.setOnCompletionListener(this);
mVideoView.setVideoURI(mUri);
- if (mVirtualizer != null) {
- mVirtualizer.release();
- mVirtualizer = null;
- }
Intent ai = movieActivity.getIntent();
boolean virtualize = ai.getBooleanExtra(VIRTUALIZE_EXTRA, false);
if (virtualize) {
int session = mVideoView.getAudioSessionId();
if (session != 0) {
- Virtualizer virt = new Virtualizer(0, session);
- AudioEffect.Descriptor descriptor = virt.getDescriptor();
- String uuid = descriptor.uuid.toString();
- if (uuid.equals("36103c52-8514-11e2-9e96-0800200c9a66") ||
- uuid.equals("36103c50-8514-11e2-9e96-0800200c9a66")) {
- mVirtualizer = virt;
- mVirtualizer.setEnabled(true);
- } else {
- // This is not the audio virtualizer we're looking for
- virt.release();
- }
+ mVirtualizer = new Virtualizer(0, session);
+ mVirtualizer.setEnabled(true);
} else {
- Log.w(TAG, "no session");
+ Log.w(TAG, "no audio session to virtualize");
}
}
mVideoView.setOnTouchListener(new View.OnTouchListener() {
@@ -165,6 +151,17 @@
return true;
}
});
+ mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
+ @Override
+ public void onPrepared(MediaPlayer player) {
+ if (!mVideoView.canSeekForward() || !mVideoView.canSeekBackward()) {
+ mController.setSeekable(false);
+ } else {
+ mController.setSeekable(true);
+ }
+ setProgress();
+ }
+ });
// The SurfaceView is transparent before drawing the first frame.
// This makes the UI flashing when open a video. (black -> old screen
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 7a71e91..915fdab 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -35,12 +35,11 @@
import android.os.SystemClock;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import android.widget.RelativeLayout;
import android.widget.ShareActionProvider;
import android.widget.Toast;
-import com.android.camera.CameraActivity;
-import com.android.camera.ProxyLauncher;
import com.android.gallery3d.R;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.ComboAlbum;
@@ -65,6 +64,7 @@
import com.android.gallery3d.ui.DetailsHelper;
import com.android.gallery3d.ui.DetailsHelper.CloseListener;
import com.android.gallery3d.ui.DetailsHelper.DetailsSource;
+import com.android.gallery3d.ui.GLRootView;
import com.android.gallery3d.ui.GLView;
import com.android.gallery3d.ui.MenuExecutor;
import com.android.gallery3d.ui.PhotoView;
@@ -88,7 +88,6 @@
private static final int MSG_ON_PICTURE_CENTER = 10;
private static final int MSG_REFRESH_IMAGE = 11;
private static final int MSG_UPDATE_PHOTO_UI = 12;
- private static final int MSG_UPDATE_PROGRESS = 13;
private static final int MSG_UPDATE_DEFERRED = 14;
private static final int MSG_UPDATE_SHARE_URI = 15;
private static final int MSG_UPDATE_PANORAMA_UI = 16;
@@ -113,6 +112,7 @@
public static final String KEY_RETURN_INDEX_HINT = "return-index-hint";
public static final String KEY_SHOW_WHEN_LOCKED = "show_when_locked";
public static final String KEY_IN_CAMERA_ROLL = "in_camera_roll";
+ public static final String KEY_READONLY = "read-only";
public static final String KEY_ALBUMPAGE_TRANSITION = "albumpage-transition";
public static final int MSG_ALBUMPAGE_NONE = 0;
@@ -146,13 +146,13 @@
private boolean mIsMenuVisible;
private boolean mHaveImageEditor;
private PhotoPageBottomControls mBottomControls;
- private PhotoPageProgressBar mProgressBar;
private MediaItem mCurrentPhoto = null;
private MenuExecutor mMenuExecutor;
private boolean mIsActive;
private boolean mShowSpinner;
private String mSetPathString;
// This is the original mSetPathString before adding the camera preview item.
+ private boolean mReadOnlyView = false;
private String mOriginalSetPathString;
private AppBridge mAppBridge;
private SnailItem mScreenNailItem;
@@ -183,7 +183,8 @@
private final MyMenuVisibilityListener mMenuVisibilityListener =
new MyMenuVisibilityListener();
- private UpdateProgressListener mProgressListener;
+
+ private int mLastSystemUiVis = 0;
private final PanoramaSupportCallback mUpdatePanoramaMenuItemsCallback = new PanoramaSupportCallback() {
@Override
@@ -233,33 +234,6 @@
}
}
- private class UpdateProgressListener implements StitchingChangeListener {
-
- @Override
- public void onStitchingResult(Uri uri) {
- sendUpdate(uri, MSG_REFRESH_IMAGE);
- }
-
- @Override
- public void onStitchingQueued(Uri uri) {
- sendUpdate(uri, MSG_UPDATE_PROGRESS);
- }
-
- @Override
- public void onStitchingProgress(Uri uri, final int progress) {
- sendUpdate(uri, MSG_UPDATE_PROGRESS);
- }
-
- private void sendUpdate(Uri uri, int message) {
- MediaObject currentPhoto = mCurrentPhoto;
- boolean isCurrentPhoto = currentPhoto instanceof LocalImage
- && currentPhoto.getContentUri().equals(uri);
- if (isCurrentPhoto) {
- mHandler.sendEmptyMessage(message);
- }
- }
- };
-
@Override
protected int getBackgroundColorId() {
return R.color.photo_background;
@@ -379,10 +353,6 @@
updateUIForCurrentPhoto();
break;
}
- case MSG_UPDATE_PROGRESS: {
- updateProgressBar();
- break;
- }
case MSG_UPDATE_SHARE_URI: {
if (mCurrentPhoto == message.obj) {
boolean isPanorama360 = message.arg1 != 0;
@@ -411,6 +381,7 @@
};
mSetPathString = data.getString(KEY_MEDIA_SET_PATH);
+ mReadOnlyView = data.getBoolean(KEY_READONLY);
mOriginalSetPathString = mSetPathString;
setupNfcBeamPush();
String itemPathString = data.getString(KEY_MEDIA_ITEM_PATH);
@@ -577,16 +548,20 @@
if (mSecureAlbum == null) {
mBottomControls = new PhotoPageBottomControls(this, mActivity, galleryRoot);
}
- StitchingProgressManager progressManager = mApplication.getStitchingProgressManager();
- if (progressManager != null) {
- mProgressBar = new PhotoPageProgressBar(mActivity, galleryRoot);
- mProgressListener = new UpdateProgressListener();
- progressManager.addChangeListener(mProgressListener);
- if (mSecureAlbum != null) {
- progressManager.addChangeListener(mSecureAlbum);
- }
- }
}
+
+ ((GLRootView) mActivity.getGLRoot()).setOnSystemUiVisibilityChangeListener(
+ new View.OnSystemUiVisibilityChangeListener() {
+ @Override
+ public void onSystemUiVisibilityChange(int visibility) {
+ int diff = mLastSystemUiVis ^ visibility;
+ mLastSystemUiVis = visibility;
+ if ((diff & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0
+ && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
+ showBars();
+ }
+ }
+ });
}
@Override
@@ -610,7 +585,7 @@
}
switch(control) {
case R.id.photopage_bottom_control_edit:
- return mHaveImageEditor && mShowBars
+ return mHaveImageEditor && mShowBars && !mReadOnlyView
&& !mPhotoView.getFilmMode()
&& (mCurrentPhoto.getSupportedOperations() & MediaItem.SUPPORT_EDIT) != 0
&& mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE;
@@ -696,10 +671,8 @@
}
private void launchCamera() {
- Intent intent = new Intent(mActivity, CameraActivity.class)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mRecenterCameraOnResume = false;
- mActivity.startActivity(intent);
+ GalleryUtils.startCameraActivity(mActivity);
}
private void launchPhotoEditor() {
@@ -774,7 +747,6 @@
&& (mCurrentPhoto.getSupportedOperations() & MediaItem.SUPPORT_SHARE) != 0) {
mCurrentPhoto.getPanoramaSupport(mUpdateShareURICallback);
}
- updateProgressBar();
}
private void updateCurrentPhoto(MediaItem photo) {
@@ -787,19 +759,6 @@
}
}
- private void updateProgressBar() {
- if (mProgressBar != null) {
- mProgressBar.hideProgress();
- StitchingProgressManager progressManager = mApplication.getStitchingProgressManager();
- if (progressManager != null && mCurrentPhoto instanceof LocalImage) {
- Integer progress = progressManager.getProgress(mCurrentPhoto.getContentUri());
- if (progress != null) {
- mProgressBar.setProgress(progress);
- }
- }
- }
- }
-
private void updateMenuOperations() {
Menu menu = mActionBar.getMenu();
@@ -813,6 +772,9 @@
if (mCurrentPhoto == null) return;
int supportedOperations = mCurrentPhoto.getSupportedOperations();
+ if (mReadOnlyView) {
+ supportedOperations ^= MediaObject.SUPPORT_EDIT;
+ }
if (mSecureAlbum != null) {
supportedOperations &= MediaObject.SUPPORT_DELETE;
} else {
@@ -900,6 +862,7 @@
@Override
protected void onBackPressed() {
+ showBars();
if (mShowDetails) {
hideDetails();
} else if (mAppBridge == null || !switchWithCaptureAnimation(-1)) {
@@ -1016,10 +979,6 @@
onUpPressed();
} else {
if (mOriginalSetPathString == null) return;
- if (mProgressBar != null) {
- updateCurrentPhoto(null);
- mProgressBar.hideProgress();
- }
Bundle data = new Bundle(getData());
data.putString(AlbumPage.KEY_MEDIA_PATH, mOriginalSetPathString);
data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH,
@@ -1124,6 +1083,10 @@
}
return true;
}
+ case R.id.print: {
+ mActivity.printSelectedImage(manager.getContentUri(path));
+ return true;
+ }
case R.id.action_delete:
confirmMsg = mActivity.getResources().getQuantityString(
R.plurals.delete_selection, 1);
@@ -1198,8 +1161,8 @@
} else if (goBack) {
onBackPressed();
} else if (unlock) {
- Intent intent = new Intent(mActivity, Gallery.class);
- intent.putExtra(Gallery.KEY_DISMISS_KEYGUARD, true);
+ Intent intent = new Intent(mActivity, GalleryActivity.class);
+ intent.putExtra(GalleryActivity.KEY_DISMISS_KEYGUARD, true);
mActivity.startActivity(intent);
} else if (launchCamera) {
launchCamera();
@@ -1276,6 +1239,9 @@
.findPathByUri(intent.getData(), intent.getType());
if (path != null) {
Path albumPath = mApplication.getDataManager().getDefaultSetOf(path);
+ if (albumPath == null) {
+ return;
+ }
if (!albumPath.equalsIgnoreCase(mOriginalSetPathString)) {
// If the edited image is stored in a different album, we need
// to start a new activity state to show the new image
@@ -1295,10 +1261,6 @@
// This is a reset, not a canceled
return;
}
- if (resultCode == ProxyLauncher.RESULT_USER_CANCELED) {
- // Unmap reset vs. canceled
- resultCode = Activity.RESULT_CANCELED;
- }
mRecenterCameraOnResume = false;
switch (requestCode) {
case REQUEST_EDIT:
diff --git a/src/com/android/gallery3d/app/PhotoPageBottomControls.java b/src/com/android/gallery3d/app/PhotoPageBottomControls.java
index 24b8ceb..57f8b6f 100644
--- a/src/com/android/gallery3d/app/PhotoPageBottomControls.java
+++ b/src/com/android/gallery3d/app/PhotoPageBottomControls.java
@@ -130,7 +130,8 @@
@Override
public void onClick(View view) {
- if (mContainerVisible && mControlsVisible.get(view).booleanValue()) {
+ Boolean controlVisible = mControlsVisible.get(view);
+ if (mContainerVisible && controlVisible != null && controlVisible.booleanValue()) {
mDelegate.onBottomControlClicked(view.getId());
}
}
diff --git a/src/com/android/gallery3d/app/StateManager.java b/src/com/android/gallery3d/app/StateManager.java
index c0c84c9..aa372a8 100644
--- a/src/com/android/gallery3d/app/StateManager.java
+++ b/src/com/android/gallery3d/app/StateManager.java
@@ -24,7 +24,6 @@
import android.view.Menu;
import android.view.MenuItem;
-import com.android.camera.CameraActivity;
import com.android.gallery3d.anim.StateTransitionAnimation;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.util.UsageStatistics;
@@ -64,14 +63,10 @@
StateTransitionAnimation.Transition.Incoming);
if (mIsResumed) top.onPause();
}
- // Ignore the filmstrip used for the root of the camera app
- boolean ignoreHit = (mActivity instanceof CameraActivity)
- && mStack.isEmpty();
- if (!ignoreHit) {
- UsageStatistics.onContentViewChanged(
- UsageStatistics.COMPONENT_GALLERY,
- klass.getSimpleName());
- }
+
+ UsageStatistics.onContentViewChanged(
+ UsageStatistics.COMPONENT_GALLERY,
+ klass.getSimpleName());
state.initialize(mActivity, data);
mStack.push(new StateEntry(data, state));
diff --git a/src/com/android/gallery3d/app/TimeBar.java b/src/com/android/gallery3d/app/TimeBar.java
index 402dfcf..246346a 100644
--- a/src/com/android/gallery3d/app/TimeBar.java
+++ b/src/com/android/gallery3d/app/TimeBar.java
@@ -259,4 +259,8 @@
}
}
+ public void setSeekable(boolean canSeek) {
+ mShowScrubber = canSeek;
+ }
+
}
diff --git a/src/com/android/gallery3d/app/TrimVideo.java b/src/com/android/gallery3d/app/TrimVideo.java
index 1e77281..b0ed8e6 100644
--- a/src/com/android/gallery3d/app/TrimVideo.java
+++ b/src/com/android/gallery3d/app/TrimVideo.java
@@ -197,6 +197,8 @@
mTrimEndTime = duration;
}
mController.setTimes(mVideoPosition, duration, mTrimStartTime, mTrimEndTime);
+ // Enable save if there's modifications
+ mSaveVideoTextView.setEnabled(isModified());
return mVideoPosition;
}
@@ -307,8 +309,6 @@
mTrimStartTime = start;
mTrimEndTime = end;
setProgress();
- // Enable save if there's modifications
- mSaveVideoTextView.setEnabled(isModified());
}
@Override
diff --git a/src/com/android/gallery3d/app/VideoUtils.java b/src/com/android/gallery3d/app/VideoUtils.java
index a3c3ef2..359cf76 100644
--- a/src/com/android/gallery3d/app/VideoUtils.java
+++ b/src/com/android/gallery3d/app/VideoUtils.java
@@ -192,33 +192,38 @@
int trackIndex = -1;
ByteBuffer dstBuf = ByteBuffer.allocate(bufferSize);
BufferInfo bufferInfo = new BufferInfo();
-
- muxer.start();
- while (true) {
- bufferInfo.offset = offset;
- bufferInfo.size = extractor.readSampleData(dstBuf, offset);
- if (bufferInfo.size < 0) {
- Log.d(LOGTAG, "Saw input EOS.");
- bufferInfo.size = 0;
- break;
- } else {
- bufferInfo.presentationTimeUs = extractor.getSampleTime();
- if (endMs > 0 && bufferInfo.presentationTimeUs > (endMs * 1000)) {
- Log.d(LOGTAG, "The current sample is over the trim end time.");
+ try {
+ muxer.start();
+ while (true) {
+ bufferInfo.offset = offset;
+ bufferInfo.size = extractor.readSampleData(dstBuf, offset);
+ if (bufferInfo.size < 0) {
+ Log.d(LOGTAG, "Saw input EOS.");
+ bufferInfo.size = 0;
break;
} else {
- bufferInfo.flags = extractor.getSampleFlags();
- trackIndex = extractor.getSampleTrackIndex();
+ bufferInfo.presentationTimeUs = extractor.getSampleTime();
+ if (endMs > 0 && bufferInfo.presentationTimeUs > (endMs * 1000)) {
+ Log.d(LOGTAG, "The current sample is over the trim end time.");
+ break;
+ } else {
+ bufferInfo.flags = extractor.getSampleFlags();
+ trackIndex = extractor.getSampleTrackIndex();
- muxer.writeSampleData(indexMap.get(trackIndex), dstBuf,
- bufferInfo);
- extractor.advance();
+ muxer.writeSampleData(indexMap.get(trackIndex), dstBuf,
+ bufferInfo);
+ extractor.advance();
+ }
}
}
- }
- muxer.stop();
- muxer.release();
+ muxer.stop();
+ } catch (IllegalStateException e) {
+ // Swallow the exception due to malformed source.
+ Log.w(LOGTAG, "The source video file is malformed");
+ } finally {
+ muxer.release();
+ }
return;
}
diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java
index 91bc772..2022f5a 100644
--- a/src/com/android/gallery3d/app/Wallpaper.java
+++ b/src/com/android/gallery3d/app/Wallpaper.java
@@ -18,6 +18,8 @@
import android.annotation.TargetApi;
import android.app.Activity;
+import android.app.WallpaperManager;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Point;
import android.net.Uri;
@@ -26,9 +28,11 @@
import android.view.Display;
import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.crop.CropActivity;
import com.android.gallery3d.filtershow.crop.CropExtras;
+import java.lang.IllegalArgumentException;
+
/**
* Wallpaper picker for the gallery application. This just redirects to the
* standard pick action.
@@ -95,24 +99,40 @@
// fall-through
}
case STATE_PHOTO_PICKED: {
+ Intent cropAndSetWallpaperIntent;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ WallpaperManager wpm = WallpaperManager.getInstance(getApplicationContext());
+ try {
+ cropAndSetWallpaperIntent = wpm.getCropAndSetWallpaperIntent(mPickedItem);
+ startActivity(cropAndSetWallpaperIntent);
+ finish();
+ return;
+ } catch (ActivityNotFoundException anfe) {
+ // ignored; fallthru to existing crop activity
+ } catch (IllegalArgumentException iae) {
+ // ignored; fallthru to existing crop activity
+ }
+ }
+
int width = getWallpaperDesiredMinimumWidth();
int height = getWallpaperDesiredMinimumHeight();
Point size = getDefaultDisplaySize(new Point());
float spotlightX = (float) size.x / width;
float spotlightY = (float) size.y / height;
- Intent request = new Intent(FilterShowActivity.CROP_ACTION)
- .setDataAndType(mPickedItem, IMAGE_TYPE)
- .addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
- .putExtra(CropExtras.KEY_OUTPUT_X, width)
- .putExtra(CropExtras.KEY_OUTPUT_Y, height)
- .putExtra(CropExtras.KEY_ASPECT_X, width)
- .putExtra(CropExtras.KEY_ASPECT_Y, height)
- .putExtra(CropExtras.KEY_SPOTLIGHT_X, spotlightX)
- .putExtra(CropExtras.KEY_SPOTLIGHT_Y, spotlightY)
- .putExtra(CropExtras.KEY_SCALE, true)
- .putExtra(CropExtras.KEY_SCALE_UP_IF_NEEDED, true)
- .putExtra(CropExtras.KEY_SET_AS_WALLPAPER, true);
- startActivity(request);
+ cropAndSetWallpaperIntent = new Intent(CropActivity.CROP_ACTION)
+ .setClass(this, CropActivity.class)
+ .setDataAndType(mPickedItem, IMAGE_TYPE)
+ .addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
+ .putExtra(CropExtras.KEY_OUTPUT_X, width)
+ .putExtra(CropExtras.KEY_OUTPUT_Y, height)
+ .putExtra(CropExtras.KEY_ASPECT_X, width)
+ .putExtra(CropExtras.KEY_ASPECT_Y, height)
+ .putExtra(CropExtras.KEY_SPOTLIGHT_X, spotlightX)
+ .putExtra(CropExtras.KEY_SPOTLIGHT_Y, spotlightY)
+ .putExtra(CropExtras.KEY_SCALE, true)
+ .putExtra(CropExtras.KEY_SCALE_UP_IF_NEEDED, true)
+ .putExtra(CropExtras.KEY_SET_AS_WALLPAPER, true);
+ startActivity(cropAndSetWallpaperIntent);
finish();
}
}
diff --git a/src/com/android/gallery3d/data/Exif.java b/src/com/android/gallery3d/data/Exif.java
index 950e7de..20f0724 100644
--- a/src/com/android/gallery3d/data/Exif.java
+++ b/src/com/android/gallery3d/data/Exif.java
@@ -24,9 +24,11 @@
import java.io.InputStream;
public class Exif {
- private static final String TAG = "CameraExif";
+ private static final String TAG = "GalleryExif";
- // Returns the degrees in clockwise. Values are 0, 90, 180, or 270.
+ /**
+ * Returns the degrees in clockwise. Values are 0, 90, 180, or 270.
+ */
public static int getOrientation(InputStream is) {
if (is == null) {
return 0;
@@ -45,4 +47,42 @@
return 0;
}
}
+
+ /**
+ * Returns an exif interface instance for the given JPEG image.
+ *
+ * @param jpegData a valid JPEG image containing EXIF data
+ */
+ public static ExifInterface getExif(byte[] jpegData) {
+ ExifInterface exif = new ExifInterface();
+ try {
+ exif.readExif(jpegData);
+ } catch (IOException e) {
+ Log.w(TAG, "Failed to read EXIF data", e);
+ }
+ return exif;
+ }
+
+ /**
+ * Returns the degrees in clockwise. Values are 0, 90, 180, or 270.
+ */
+ public static int getOrientation(ExifInterface exif) {
+ Integer val = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION);
+ if (val == null) {
+ return 0;
+ } else {
+ return ExifInterface.getRotationForOrientationValue(val.shortValue());
+ }
+ }
+
+ /**
+ * See {@link #getOrientation(byte[])}, but using the picture bytes instead.
+ */
+ public static int getOrientation(byte[] jpegData) {
+ if (jpegData == null)
+ return 0;
+
+ ExifInterface exif = getExif(jpegData);
+ return getOrientation(exif);
+ }
}
diff --git a/src/com/android/gallery3d/data/ImageCacheRequest.java b/src/com/android/gallery3d/data/ImageCacheRequest.java
index 4756149..6cbc5c5 100644
--- a/src/com/android/gallery3d/data/ImageCacheRequest.java
+++ b/src/com/android/gallery3d/data/ImageCacheRequest.java
@@ -32,17 +32,19 @@
private Path mPath;
private int mType;
private int mTargetSize;
+ private long mTimeModified;
public ImageCacheRequest(GalleryApp application,
- Path path, int type, int targetSize) {
+ Path path, long timeModified, int type, int targetSize) {
mApplication = application;
mPath = path;
mType = type;
mTargetSize = targetSize;
+ mTimeModified = timeModified;
}
private String debugTag() {
- return mPath + "," +
+ return mPath + "," + mTimeModified + "," +
((mType == MediaItem.TYPE_THUMBNAIL) ? "THUMB" :
(mType == MediaItem.TYPE_MICROTHUMBNAIL) ? "MICROTHUMB" : "?");
}
@@ -53,7 +55,7 @@
BytesBuffer buffer = MediaItem.getBytesBufferPool().get();
try {
- boolean found = cacheService.getImageData(mPath, mType, buffer);
+ boolean found = cacheService.getImageData(mPath, mTimeModified, mType, buffer);
if (jc.isCancelled()) return null;
if (found) {
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -92,7 +94,7 @@
byte[] array = BitmapUtils.compressToBytes(bitmap);
if (jc.isCancelled()) return null;
- cacheService.putImageData(mPath, mType, array);
+ cacheService.putImageData(mPath, mTimeModified, mType, array);
return bitmap;
}
diff --git a/src/com/android/gallery3d/data/ImageCacheService.java b/src/com/android/gallery3d/data/ImageCacheService.java
index 527d6c8..1c7cb8c 100644
--- a/src/com/android/gallery3d/data/ImageCacheService.java
+++ b/src/com/android/gallery3d/data/ImageCacheService.java
@@ -46,7 +46,8 @@
}
/**
- * Gets the cached image data for the given <code>path</code> and <code>type</code>.
+ * Gets the cached image data for the given <code>path</code>,
+ * <code>timeModified</code> and <code>type</code>.
*
* The image data will be stored in <code>buffer.data</code>, started from
* <code>buffer.offset</code> for <code>buffer.length</code> bytes. If the
@@ -54,8 +55,8 @@
*
* @return true if the image data is found; false if not found.
*/
- public boolean getImageData(Path path, int type, BytesBuffer buffer) {
- byte[] key = makeKey(path, type);
+ public boolean getImageData(Path path, long timeModified, int type, BytesBuffer buffer) {
+ byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
try {
LookupRequest request = new LookupRequest();
@@ -76,8 +77,8 @@
return false;
}
- public void putImageData(Path path, int type, byte[] value) {
- byte[] key = makeKey(path, type);
+ public void putImageData(Path path, long timeModified, int type, byte[] value) {
+ byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
ByteBuffer buffer = ByteBuffer.allocate(key.length + value.length);
buffer.put(key);
@@ -91,8 +92,8 @@
}
}
- public void clearImageData(Path path, int type) {
- byte[] key = makeKey(path, type);
+ public void clearImageData(Path path, long timeModified, int type) {
+ byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
synchronized (mCache) {
try {
@@ -103,8 +104,8 @@
}
}
- private static byte[] makeKey(Path path, int type) {
- return GalleryUtils.getBytes(path.toString() + "+" + type);
+ private static byte[] makeKey(Path path, long timeModified, int type) {
+ return GalleryUtils.getBytes(path.toString() + "+" + timeModified + "+" + type);
}
private static boolean isSameKey(byte[] key, byte[] buffer) {
diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java
index 1ed67ec..2b01c1e 100644
--- a/src/com/android/gallery3d/data/LocalImage.java
+++ b/src/com/android/gallery3d/data/LocalImage.java
@@ -32,12 +32,11 @@
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.app.PanoramaMetadataSupport;
-import com.android.gallery3d.app.StitchingProgressManager;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.BitmapUtils;
-import com.android.gallery3d.common.Utils;
import com.android.gallery3d.exif.ExifInterface;
import com.android.gallery3d.exif.ExifTag;
+import com.android.gallery3d.filtershow.tools.SaveImage;
import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.ThreadPool.Job;
import com.android.gallery3d.util.ThreadPool.JobContext;
@@ -46,8 +45,6 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel.MapMode;
// LocalImage represents an image in the local storage.
public class LocalImage extends LocalMediaItem {
@@ -175,15 +172,17 @@
@Override
public Job<Bitmap> requestImage(int type) {
- return new LocalImageRequest(mApplication, mPath, type, filePath);
+ return new LocalImageRequest(mApplication, mPath, dateModifiedInSec,
+ type, filePath);
}
public static class LocalImageRequest extends ImageCacheRequest {
private String mLocalFilePath;
- LocalImageRequest(GalleryApp application, Path path, int type,
- String localFilePath) {
- super(application, path, type, MediaItem.getTargetSize(type));
+ LocalImageRequest(GalleryApp application, Path path, long timeModified,
+ int type, String localFilePath) {
+ super(application, path, timeModified, type,
+ MediaItem.getTargetSize(type));
mLocalFilePath = localFilePath;
}
@@ -237,14 +236,10 @@
@Override
public int getSupportedOperations() {
- StitchingProgressManager progressManager = mApplication.getStitchingProgressManager();
- if (progressManager != null && progressManager.getProgress(getContentUri()) != null) {
- return 0; // doesn't support anything while stitching!
- }
int operation = SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_CROP
- | SUPPORT_SETAS | SUPPORT_EDIT | SUPPORT_INFO;
+ | SUPPORT_SETAS | SUPPORT_PRINT | SUPPORT_INFO;
if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) {
- operation |= SUPPORT_FULL_IMAGE;
+ operation |= SUPPORT_FULL_IMAGE | SUPPORT_EDIT;
}
if (BitmapUtils.isRotationSupported(mimeType)) {
@@ -271,7 +266,9 @@
public void delete() {
GalleryUtils.assertNotInRenderThread();
Uri baseUri = Images.Media.EXTERNAL_CONTENT_URI;
- mApplication.getContentResolver().delete(baseUri, "_id=?",
+ ContentResolver contentResolver = mApplication.getContentResolver();
+ SaveImage.deleteAuxFiles(contentResolver, getContentUri());
+ contentResolver.delete(baseUri, "_id=?",
new String[]{String.valueOf(id)});
}
diff --git a/src/com/android/gallery3d/data/LocalSource.java b/src/com/android/gallery3d/data/LocalSource.java
index a2e3d14..810aef4 100644
--- a/src/com/android/gallery3d/data/LocalSource.java
+++ b/src/com/android/gallery3d/data/LocalSource.java
@@ -22,7 +22,7 @@
import android.net.Uri;
import android.provider.MediaStore;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.data.MediaSet.ItemConsumer;
@@ -130,7 +130,7 @@
private Path getAlbumPath(Uri uri, int defaultType) {
int mediaType = getMediaType(
- uri.getQueryParameter(Gallery.KEY_MEDIA_TYPES),
+ uri.getQueryParameter(GalleryActivity.KEY_MEDIA_TYPES),
defaultType);
String bucketId = uri.getQueryParameter(KEY_BUCKET_ID);
int id = 0;
diff --git a/src/com/android/gallery3d/data/LocalVideo.java b/src/com/android/gallery3d/data/LocalVideo.java
index b1e1cb3..4b8774c 100644
--- a/src/com/android/gallery3d/data/LocalVideo.java
+++ b/src/com/android/gallery3d/data/LocalVideo.java
@@ -152,15 +152,17 @@
@Override
public Job<Bitmap> requestImage(int type) {
- return new LocalVideoRequest(mApplication, getPath(), type, filePath);
+ return new LocalVideoRequest(mApplication, getPath(), dateModifiedInSec,
+ type, filePath);
}
public static class LocalVideoRequest extends ImageCacheRequest {
private String mLocalFilePath;
- LocalVideoRequest(GalleryApp application, Path path, int type,
- String localFilePath) {
- super(application, path, type, MediaItem.getTargetSize(type));
+ LocalVideoRequest(GalleryApp application, Path path, long timeModified,
+ int type, String localFilePath) {
+ super(application, path, timeModified, type,
+ MediaItem.getTargetSize(type));
mLocalFilePath = localFilePath;
}
diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java
index 270d4cf..530ee30 100644
--- a/src/com/android/gallery3d/data/MediaObject.java
+++ b/src/com/android/gallery3d/data/MediaObject.java
@@ -41,6 +41,7 @@
public static final int SUPPORT_ACTION = 1 << 14;
public static final int SUPPORT_CAMERA_SHORTCUT = 1 << 15;
public static final int SUPPORT_MUTE = 1 << 16;
+ public static final int SUPPORT_PRINT = 1 << 17;
public static final int SUPPORT_ALL = 0xffffffff;
// These are the bits returned from getMediaType():
diff --git a/src/com/android/gallery3d/data/UriImage.java b/src/com/android/gallery3d/data/UriImage.java
index e8875b5..b3fe1de 100644
--- a/src/com/android/gallery3d/data/UriImage.java
+++ b/src/com/android/gallery3d/data/UriImage.java
@@ -211,10 +211,10 @@
@Override
public int getSupportedOperations() {
- int supported = SUPPORT_EDIT | SUPPORT_SETAS;
+ int supported = SUPPORT_PRINT | SUPPORT_SETAS;
if (isSharable()) supported |= SUPPORT_SHARE;
if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
- supported |= SUPPORT_FULL_IMAGE;
+ supported |= SUPPORT_EDIT | SUPPORT_FULL_IMAGE;
}
return supported;
}
diff --git a/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java b/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
index 30d4dde..95fc56d 100644
--- a/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
+++ b/src/com/android/gallery3d/filtershow/EditorPlaceHolder.java
@@ -18,7 +18,6 @@
private FrameLayout mContainer = null;
private HashMap<Integer, Editor> mEditors = new HashMap<Integer, Editor>();
private Vector<ImageShow> mOldViews = new Vector<ImageShow>();
- private ImageLoader mImageLoader = null;
public EditorPlaceHolder(FilterShowActivity activity) {
mActivity = activity;
@@ -45,26 +44,21 @@
return null;
}
- try {
- editor.createEditor(mActivity, mContainer);
- editor.setImageLoader(mImageLoader);
- mContainer.setVisibility(View.VISIBLE);
- mContainer.removeAllViews();
- View eview = editor.getTopLevelView();
- ViewParent parent = eview.getParent();
+ editor.createEditor(mActivity, mContainer);
+ editor.getImageShow().attach();
+ mContainer.setVisibility(View.VISIBLE);
+ mContainer.removeAllViews();
+ View eview = editor.getTopLevelView();
+ ViewParent parent = eview.getParent();
- if (parent != null && parent instanceof FrameLayout) {
- ((FrameLayout) parent).removeAllViews();
- }
-
- mContainer.addView(eview);
- hideOldViews();
- editor.setVisibility(View.VISIBLE);
- return editor;
- } catch (Exception e) {
- e.printStackTrace();
+ if (parent != null && parent instanceof FrameLayout) {
+ ((FrameLayout) parent).removeAllViews();
}
- return null;
+
+ mContainer.addView(eview);
+ hideOldViews();
+ editor.setVisibility(View.VISIBLE);
+ return editor;
}
public void setOldViews(Vector<ImageShow> views) {
@@ -81,10 +75,6 @@
}
}
- public void setImageLoader(ImageLoader imageLoader) {
- mImageLoader = imageLoader;
- }
-
public Editor getEditor(int editorId) {
return mEditors.get(editorId);
}
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 67ae3b5..e627a61 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -19,72 +19,119 @@
import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.ProgressDialog;
-import android.app.WallpaperManager;
+import android.content.ComponentName;
import android.content.ContentValues;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.Matrix;
import android.graphics.Point;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.CancellationSignal;
+import android.os.Handler;
+import android.os.IBinder;
+import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
+import android.support.v4.print.PrintHelper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
-import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.ViewPropertyAnimator;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
+import android.widget.PopupMenu;
import android.widget.ShareActionProvider;
import android.widget.ShareActionProvider.OnShareTargetSelectedListener;
-
+import android.widget.Spinner;
import android.widget.Toast;
+
import com.android.gallery3d.R;
+import com.android.gallery3d.app.PhotoPage;
import com.android.gallery3d.data.LocalAlbum;
-import com.android.gallery3d.filtershow.cache.CachingPipeline;
-import com.android.gallery3d.filtershow.cache.FilteringPipeline;
import com.android.gallery3d.filtershow.cache.ImageLoader;
-import com.android.gallery3d.filtershow.category.*;
-import com.android.gallery3d.filtershow.crop.CropExtras;
-import com.android.gallery3d.filtershow.editors.*;
-import com.android.gallery3d.filtershow.filters.*;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.imageshow.ImageCrop;
+import com.android.gallery3d.filtershow.category.Action;
+import com.android.gallery3d.filtershow.category.CategoryAdapter;
+import com.android.gallery3d.filtershow.category.CategorySelected;
+import com.android.gallery3d.filtershow.category.CategoryView;
+import com.android.gallery3d.filtershow.category.MainPanel;
+import com.android.gallery3d.filtershow.category.SwipableView;
+import com.android.gallery3d.filtershow.data.UserPresetsManager;
+import com.android.gallery3d.filtershow.editors.BasicEditor;
+import com.android.gallery3d.filtershow.editors.Editor;
+import com.android.gallery3d.filtershow.editors.EditorChanSat;
+import com.android.gallery3d.filtershow.editors.EditorColorBorder;
+import com.android.gallery3d.filtershow.editors.EditorCrop;
+import com.android.gallery3d.filtershow.editors.EditorDraw;
+import com.android.gallery3d.filtershow.editors.EditorGrad;
+import com.android.gallery3d.filtershow.editors.EditorManager;
+import com.android.gallery3d.filtershow.editors.EditorMirror;
+import com.android.gallery3d.filtershow.editors.EditorPanel;
+import com.android.gallery3d.filtershow.editors.EditorRedEye;
+import com.android.gallery3d.filtershow.editors.EditorRotate;
+import com.android.gallery3d.filtershow.editors.EditorStraighten;
+import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
+import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation;
+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.history.HistoryItem;
+import com.android.gallery3d.filtershow.history.HistoryManager;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.imageshow.Spline;
+import com.android.gallery3d.filtershow.info.InfoPanel;
+import com.android.gallery3d.filtershow.pipeline.CachingPipeline;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.ProcessingService;
+import com.android.gallery3d.filtershow.presets.PresetManagementDialog;
+import com.android.gallery3d.filtershow.presets.UserPresetsAdapter;
import com.android.gallery3d.filtershow.provider.SharedImageProvider;
import com.android.gallery3d.filtershow.state.StateAdapter;
-import com.android.gallery3d.filtershow.tools.BitmapTask;
-import com.android.gallery3d.filtershow.tools.SaveCopyTask;
+import com.android.gallery3d.filtershow.tools.SaveImage;
+import com.android.gallery3d.filtershow.tools.XmpPresets;
+import com.android.gallery3d.filtershow.tools.XmpPresets.XMresults;
+import com.android.gallery3d.filtershow.ui.ExportDialog;
import com.android.gallery3d.filtershow.ui.FramedTextButton;
-import com.android.gallery3d.filtershow.ui.Spline;
import com.android.gallery3d.util.GalleryUtils;
import com.android.photos.data.GalleryBitmapPool;
import java.io.File;
-import java.io.IOException;
+import java.io.FileDescriptor;
+import java.io.FileOutputStream;
import java.lang.ref.WeakReference;
+import java.util.ArrayList;
import java.util.Vector;
public class FilterShowActivity extends FragmentActivity implements OnItemClickListener,
- OnShareTargetSelectedListener {
+ OnShareTargetSelectedListener, DialogInterface.OnShowListener,
+ DialogInterface.OnDismissListener, PopupMenu.OnDismissListener{
- // fields for supporting crop action
- public static final String CROP_ACTION = "com.android.camera.action.CROP";
- private CropExtras mCropExtras = null;
private String mAction = "";
MasterImage mMasterImage = null;
@@ -92,20 +139,20 @@
public static final String TINY_PLANET_ACTION = "com.android.camera.action.TINY_PLANET";
public static final String LAUNCH_FULLSCREEN = "launch-fullscreen";
- public static final int MAX_BMAP_IN_INTENT = 990000;
- private ImageLoader mImageLoader = null;
+ public static final boolean RESET_TO_LOADED = false;
private ImageShow mImageShow = null;
private View mSaveButton = null;
private EditorPlaceHolder mEditorPlaceHolder = new EditorPlaceHolder(this);
+ private Editor mCurrentEditor = null;
private static final int SELECT_PICTURE = 1;
private static final String LOGTAG = "FilterShowActivity";
- protected static final boolean ANIMATE_PANELS = true;
private boolean mShowingTinyPlanet = false;
private boolean mShowingImageStatePanel = false;
+ private boolean mShowingVersionsPanel = false;
private final Vector<ImageShow> mImageViews = new Vector<ImageShow>();
@@ -117,13 +164,111 @@
private WeakReference<ProgressDialog> mSavingProgressDialog;
private LoadBitmapTask mLoadBitmapTask;
- private boolean mLoading = true;
+ private Uri mOriginalImageUri = null;
+ private ImagePreset mOriginalPreset = null;
+
+ private Uri mSelectedImageUri = null;
+
+ private ArrayList<Action> mActions = new ArrayList<Action>();
+ private UserPresetsManager mUserPresetsManager = null;
+ private UserPresetsAdapter mUserPresetsAdapter = null;
private CategoryAdapter mCategoryLooksAdapter = null;
private CategoryAdapter mCategoryBordersAdapter = null;
private CategoryAdapter mCategoryGeometryAdapter = null;
private CategoryAdapter mCategoryFiltersAdapter = null;
+ private CategoryAdapter mCategoryVersionsAdapter = null;
private int mCurrentPanel = MainPanel.LOOKS;
+ private Vector<FilterUserPresetRepresentation> mVersions =
+ new Vector<FilterUserPresetRepresentation>();
+ private int mVersionsCounter = 0;
+
+ private boolean mHandlingSwipeButton = false;
+ private View mHandledSwipeView = null;
+ private float mHandledSwipeViewLastDelta = 0;
+ private float mSwipeStartX = 0;
+ private float mSwipeStartY = 0;
+
+ private ProcessingService mBoundService;
+ private boolean mIsBound = false;
+ private Menu mMenu;
+ private DialogInterface mCurrentDialog = null;
+ private PopupMenu mCurrentMenu = null;
+ private boolean mLoadingVisible = true;
+
+ public ProcessingService getProcessingService() {
+ return mBoundService;
+ }
+
+ public boolean isSimpleEditAction() {
+ return !PhotoPage.ACTION_NEXTGEN_EDIT.equalsIgnoreCase(mAction);
+ }
+
+ private ServiceConnection mConnection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName className, IBinder service) {
+ /*
+ * This is called when the connection with the service has been
+ * established, giving us the service object we can use to
+ * interact with the service. Because we have bound to a explicit
+ * service that we know is running in our own process, we can
+ * cast its IBinder to a concrete class and directly access it.
+ */
+ mBoundService = ((ProcessingService.LocalBinder)service).getService();
+ mBoundService.setFiltershowActivity(FilterShowActivity.this);
+ mBoundService.onStart();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName className) {
+ /*
+ * This is called when the connection with the service has been
+ * unexpectedly disconnected -- that is, its process crashed.
+ * Because it is running in our same process, we should never
+ * see this happen.
+ */
+ mBoundService = null;
+ }
+ };
+
+ void doBindService() {
+ /*
+ * Establish a connection with the service. We use an explicit
+ * class name because we want a specific service implementation that
+ * we know will be running in our own process (and thus won't be
+ * supporting component replacement by other applications).
+ */
+ bindService(new Intent(FilterShowActivity.this, ProcessingService.class),
+ mConnection, Context.BIND_AUTO_CREATE);
+ mIsBound = true;
+ }
+
+ void doUnbindService() {
+ if (mIsBound) {
+ // Detach our existing connection.
+ unbindService(mConnection);
+ mIsBound = false;
+ }
+ }
+
+ public void updateUIAfterServiceStarted() {
+ MasterImage.setMaster(mMasterImage);
+ ImageFilter.setActivityForMemoryToasts(this);
+ mUserPresetsManager = new UserPresetsManager(this);
+ mUserPresetsAdapter = new UserPresetsAdapter(this);
+
+ setupMasterImage();
+ setupMenu();
+ setDefaultValues();
+ fillEditors();
+ getWindow().setBackgroundDrawable(new ColorDrawable(0));
+ loadXML();
+
+ fillCategories();
+ loadMainPanel();
+ extractXMPData();
+ processIntent();
+ }
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -133,21 +278,11 @@
if (onlyUsePortrait) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
- MasterImage.setMaster(mMasterImage);
clearGalleryBitmapPool();
-
- CachingPipeline.createRenderscriptContext(this);
- setupMasterImage();
- setDefaultValues();
- fillEditors();
-
- loadXML();
- loadMainPanel();
-
- setDefaultPreset();
-
- processIntent();
+ doBindService();
+ getWindow().setBackgroundDrawable(new ColorDrawable(Color.GRAY));
+ setContentView(R.layout.filtershow_splashscreen);
}
public boolean isShowingImageStatePanel() {
@@ -161,13 +296,12 @@
MainPanel panel = new MainPanel();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
- transaction.commit();
+ transaction.commitAllowingStateLoss();
}
public void loadEditorPanel(FilterRepresentation representation,
final Editor currentEditor) {
if (representation.getEditorId() == ImageOnlyEditor.ID) {
- currentEditor.getImageShow().select();
currentEditor.reflectCurrentFilter();
return;
}
@@ -194,18 +328,31 @@
View container = mainPanel.getView().findViewById(R.id.category_panel_container);
View bottom = mainPanel.getView().findViewById(R.id.bottom_panel);
int panelHeight = container.getHeight() + bottom.getHeight();
- mainPanel.getView().animate().translationY(panelHeight).withEndAction(showEditor).start();
+ ViewPropertyAnimator anim = mainPanel.getView().animate();
+ anim.translationY(panelHeight).start();
+ final Handler handler = new Handler();
+ handler.postDelayed(showEditor, anim.getDuration());
} else {
showEditor.run();
}
}
+ public void toggleInformationPanel() {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left);
+
+ InfoPanel panel = new InfoPanel();
+ panel.show(transaction, InfoPanel.FRAGMENT_TAG);
+ }
+
private void loadXML() {
setContentView(R.layout.filtershow_activity);
ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.filtershow_actionbar);
+ actionBar.setBackgroundDrawable(new ColorDrawable(
+ getResources().getColor(R.color.background_screen)));
mSaveButton = actionBar.getCustomView();
mSaveButton.setOnClickListener(new OnClickListener() {
@@ -221,26 +368,97 @@
setupEditors();
mEditorPlaceHolder.hide();
-
- mImageShow.setImageLoader(mImageLoader);
-
- fillFx();
- fillBorders();
- fillGeometry();
- fillFilters();
+ mImageShow.attach();
setupStatePanel();
}
- public void setupStatePanel() {
- mImageLoader.setAdapter(mMasterImage.getHistory());
+ public void fillCategories() {
+ fillLooks();
+ loadUserPresets();
+ fillBorders();
+ fillTools();
+ fillEffects();
+ fillVersions();
}
- private void fillFilters() {
- Vector<FilterRepresentation> filtersRepresentations = new Vector<FilterRepresentation>();
- FiltersManager filtersManager = FiltersManager.getManager();
- filtersManager.addEffects(filtersRepresentations);
+ public void setupStatePanel() {
+ MasterImage.getImage().setHistoryManager(mMasterImage.getHistory());
+ }
+ private void fillVersions() {
+ if (mCategoryVersionsAdapter != null) {
+ mCategoryVersionsAdapter.clear();
+ }
+ mCategoryVersionsAdapter = new CategoryAdapter(this);
+ mCategoryVersionsAdapter.setShowAddButton(true);
+ }
+
+ public void registerAction(Action action) {
+ if (mActions.contains(action)) {
+ return;
+ }
+ mActions.add(action);
+ }
+
+ private void loadActions() {
+ for (int i = 0; i < mActions.size(); i++) {
+ Action action = mActions.get(i);
+ action.setImageFrame(new Rect(0, 0, 96, 96), 0);
+ }
+ }
+
+ public void updateVersions() {
+ mCategoryVersionsAdapter.clear();
+ FilterUserPresetRepresentation originalRep = new FilterUserPresetRepresentation(
+ getString(R.string.filtershow_version_original), new ImagePreset(), -1);
+ mCategoryVersionsAdapter.add(
+ new Action(this, originalRep, Action.FULL_VIEW));
+ ImagePreset current = new ImagePreset(MasterImage.getImage().getPreset());
+ FilterUserPresetRepresentation currentRep = new FilterUserPresetRepresentation(
+ getString(R.string.filtershow_version_current), current, -1);
+ mCategoryVersionsAdapter.add(
+ new Action(this, currentRep, Action.FULL_VIEW));
+ if (mVersions.size() > 0) {
+ mCategoryVersionsAdapter.add(new Action(this, Action.SPACER));
+ }
+ for (FilterUserPresetRepresentation rep : mVersions) {
+ mCategoryVersionsAdapter.add(
+ new Action(this, rep, Action.FULL_VIEW, true));
+ }
+ mCategoryVersionsAdapter.notifyDataSetInvalidated();
+ }
+
+ public void addCurrentVersion() {
+ ImagePreset current = new ImagePreset(MasterImage.getImage().getPreset());
+ mVersionsCounter++;
+ FilterUserPresetRepresentation rep = new FilterUserPresetRepresentation(
+ "" + mVersionsCounter, current, -1);
+ mVersions.add(rep);
+ updateVersions();
+ }
+
+ public void removeVersion(Action action) {
+ mVersions.remove(action.getRepresentation());
+ updateVersions();
+ }
+
+ public void removeLook(Action action) {
+ FilterUserPresetRepresentation rep =
+ (FilterUserPresetRepresentation) action.getRepresentation();
+ if (rep == null) {
+ return;
+ }
+ mUserPresetsManager.delete(rep.getId());
+ updateUserPresetsFromManager();
+ }
+
+ private void fillEffects() {
+ FiltersManager filtersManager = FiltersManager.getManager();
+ ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getEffects();
+ if (mCategoryFiltersAdapter != null) {
+ mCategoryFiltersAdapter.clear();
+ }
mCategoryFiltersAdapter = new CategoryAdapter(this);
for (FilterRepresentation representation : filtersRepresentations) {
if (representation.getTextId() != 0) {
@@ -250,31 +468,25 @@
}
}
- private void fillGeometry() {
- Vector<FilterRepresentation> filtersRepresentations = new Vector<FilterRepresentation>();
+ private void fillTools() {
FiltersManager filtersManager = FiltersManager.getManager();
-
- GeometryMetadata geo = new GeometryMetadata();
- int[] editorsId = geo.getEditorIds();
- for (int i = 0; i < editorsId.length; i++) {
- int editorId = editorsId[i];
- GeometryMetadata geometry = new GeometryMetadata(geo);
- geometry.setEditorId(editorId);
- EditorInfo editorInfo = (EditorInfo) mEditorPlaceHolder.getEditor(editorId);
- geometry.setTextId(editorInfo.getTextId());
- geometry.setOverlayId(editorInfo.getOverlayId());
- geometry.setOverlayOnly(editorInfo.getOverlayOnly());
- if (geometry.getTextId() != 0) {
- geometry.setName(getString(geometry.getTextId()));
- }
- filtersRepresentations.add(geometry);
+ ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getTools();
+ if (mCategoryGeometryAdapter != null) {
+ mCategoryGeometryAdapter.clear();
}
-
- filtersManager.addTools(filtersRepresentations);
-
mCategoryGeometryAdapter = new CategoryAdapter(this);
+ boolean found = false;
for (FilterRepresentation representation : filtersRepresentations) {
mCategoryGeometryAdapter.add(new Action(this, representation));
+ if (representation instanceof FilterDrawRepresentation) {
+ found = true;
+ }
+ }
+ if (!found) {
+ FilterRepresentation representation = new FilterDrawRepresentation();
+ Action action = new Action(this, representation);
+ action.setIsDoubleAction(true);
+ mCategoryGeometryAdapter.add(action);
}
}
@@ -285,9 +497,13 @@
}
mAction = intent.getAction();
-
- if (intent.getData() != null) {
- startLoadBitmap(intent.getData());
+ mSelectedImageUri = intent.getData();
+ Uri loadUri = mSelectedImageUri;
+ if (mOriginalImageUri != null) {
+ loadUri = mOriginalImageUri;
+ }
+ if (loadUri != null) {
+ startLoadBitmap(loadUri);
} else {
pickImage();
}
@@ -297,78 +513,63 @@
mEditorPlaceHolder.setContainer((FrameLayout) findViewById(R.id.editorContainer));
EditorManager.addEditors(mEditorPlaceHolder);
mEditorPlaceHolder.setOldViews(mImageViews);
- mEditorPlaceHolder.setImageLoader(mImageLoader);
}
private void fillEditors() {
+ mEditorPlaceHolder.addEditor(new EditorChanSat());
+ mEditorPlaceHolder.addEditor(new EditorGrad());
mEditorPlaceHolder.addEditor(new EditorDraw());
+ mEditorPlaceHolder.addEditor(new EditorColorBorder());
mEditorPlaceHolder.addEditor(new BasicEditor());
mEditorPlaceHolder.addEditor(new ImageOnlyEditor());
mEditorPlaceHolder.addEditor(new EditorTinyPlanet());
mEditorPlaceHolder.addEditor(new EditorRedEye());
mEditorPlaceHolder.addEditor(new EditorCrop());
- mEditorPlaceHolder.addEditor(new EditorFlip());
+ mEditorPlaceHolder.addEditor(new EditorMirror());
mEditorPlaceHolder.addEditor(new EditorRotate());
mEditorPlaceHolder.addEditor(new EditorStraighten());
}
private void setDefaultValues() {
- ImageFilter.setActivityForMemoryToasts(this);
-
Resources res = getResources();
- FiltersManager.setResources(res);
- CategoryView.setMargin((int) getPixelsFromDip(8));
- CategoryView.setTextSize((int) getPixelsFromDip(16));
-
- ImageShow.setDefaultBackgroundColor(res.getColor(R.color.background_screen));
// TODO: get those values from XML.
FramedTextButton.setTextSize((int) getPixelsFromDip(14));
FramedTextButton.setTrianglePadding((int) getPixelsFromDip(4));
FramedTextButton.setTriangleSize((int) getPixelsFromDip(10));
- ImageShow.setTextSize((int) getPixelsFromDip(12));
- ImageShow.setTextPadding((int) getPixelsFromDip(10));
- ImageShow.setOriginalTextMargin((int) getPixelsFromDip(4));
- ImageShow.setOriginalTextSize((int) getPixelsFromDip(18));
- ImageShow.setOriginalText(res.getString(R.string.original_picture_text));
Drawable curveHandle = res.getDrawable(R.drawable.camera_crop);
int curveHandleSize = (int) res.getDimension(R.dimen.crop_indicator_size);
Spline.setCurveHandle(curveHandle, curveHandleSize);
Spline.setCurveWidth((int) getPixelsFromDip(3));
- ImageCrop.setAspectTextSize((int) getPixelsFromDip(18));
- ImageCrop.setTouchTolerance((int) getPixelsFromDip(25));
- ImageCrop.setMinCropSize((int) getPixelsFromDip(55));
+ mOriginalImageUri = null;
}
private void startLoadBitmap(Uri uri) {
- mLoading = true;
- final View loading = findViewById(R.id.loading);
final View imageShow = findViewById(R.id.imageShow);
imageShow.setVisibility(View.INVISIBLE);
- loading.setVisibility(View.VISIBLE);
+ startLoadingIndicator();
mShowingTinyPlanet = false;
mLoadBitmapTask = new LoadBitmapTask();
mLoadBitmapTask.execute(uri);
}
private void fillBorders() {
- Vector<FilterRepresentation> borders = new Vector<FilterRepresentation>();
-
- // The "no border" implementation
- borders.add(new FilterImageBorderRepresentation(0));
-
- // Google-build borders
- FiltersManager.getManager().addBorders(this, borders);
+ FiltersManager filtersManager = FiltersManager.getManager();
+ ArrayList<FilterRepresentation> borders = filtersManager.getBorders();
for (int i = 0; i < borders.size(); i++) {
- FilterRepresentation filter = borders.elementAt(i);
+ FilterRepresentation filter = borders.get(i);
+ filter.setName(getString(R.string.borders));
if (i == 0) {
filter.setName(getString(R.string.none));
}
}
+ if (mCategoryBordersAdapter != null) {
+ mCategoryBordersAdapter.clear();
+ }
mCategoryBordersAdapter = new CategoryAdapter(this);
for (FilterRepresentation representation : borders) {
if (representation.getTextId() != 0) {
@@ -378,6 +579,10 @@
}
}
+ public UserPresetsAdapter getUserPresetsAdapter() {
+ return mUserPresetsAdapter;
+ }
+
public CategoryAdapter getCategoryLooksAdapter() {
return mCategoryLooksAdapter;
}
@@ -394,6 +599,10 @@
return mCategoryFiltersAdapter;
}
+ public CategoryAdapter getCategoryVersionsAdapter() {
+ return mCategoryVersionsAdapter;
+ }
+
public void removeFilterRepresentation(FilterRepresentation filterRepresentation) {
if (filterRepresentation == null) {
return;
@@ -401,7 +610,7 @@
ImagePreset oldPreset = MasterImage.getImage().getPreset();
ImagePreset copy = new ImagePreset(oldPreset);
copy.removeFilter(filterRepresentation);
- MasterImage.getImage().setPreset(copy, true);
+ MasterImage.getImage().setPreset(copy, copy.getLastRepresentation(), true);
if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
FilterRepresentation lastRepresentation = copy.getLastRepresentation();
MasterImage.getImage().setCurrentFilterRepresentation(lastRepresentation);
@@ -412,23 +621,36 @@
if (filterRepresentation == null) {
return;
}
- if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
+ if (!(filterRepresentation instanceof FilterRotateRepresentation)
+ && !(filterRepresentation instanceof FilterMirrorRepresentation)
+ && MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
return;
}
+ if (filterRepresentation instanceof FilterUserPresetRepresentation
+ || filterRepresentation instanceof FilterRotateRepresentation
+ || filterRepresentation instanceof FilterMirrorRepresentation) {
+ MasterImage.getImage().onNewLook(filterRepresentation);
+ }
ImagePreset oldPreset = MasterImage.getImage().getPreset();
ImagePreset copy = new ImagePreset(oldPreset);
FilterRepresentation representation = copy.getRepresentation(filterRepresentation);
if (representation == null) {
+ filterRepresentation = filterRepresentation.copy();
copy.addFilter(filterRepresentation);
} else {
- if (filterRepresentation.allowsMultipleInstances()) {
- representation.updateTempParametersFrom(filterRepresentation);
- copy.setHistoryName(filterRepresentation.getName());
- representation.synchronizeRepresentation();
+ if (filterRepresentation.allowsSingleInstanceOnly()) {
+ // Don't just update the filter representation. Centralize the
+ // logic in the addFilter(), such that we can keep "None" as
+ // null.
+ if (!representation.equals(filterRepresentation)) {
+ // Only do this if the filter isn't the same
+ // (state panel clicks can lead us here)
+ copy.removeFilter(representation);
+ copy.addFilter(filterRepresentation);
+ }
}
- filterRepresentation = representation;
}
- MasterImage.getImage().setPreset(copy, true);
+ MasterImage.getImage().setPreset(copy, filterRepresentation, true);
MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation);
}
@@ -436,10 +658,34 @@
if (representation == null) {
return;
}
+
+ if (representation instanceof FilterRotateRepresentation) {
+ FilterRotateRepresentation r = (FilterRotateRepresentation) representation;
+ r.rotateCW();
+ }
+ if (representation instanceof FilterMirrorRepresentation) {
+ FilterMirrorRepresentation r = (FilterMirrorRepresentation) representation;
+ r.cycle();
+ }
+ if (representation.isBooleanFilter()) {
+ ImagePreset preset = MasterImage.getImage().getPreset();
+ if (preset.getRepresentation(representation) != null) {
+ // remove
+ ImagePreset copy = new ImagePreset(preset);
+ copy.removeFilter(representation);
+ FilterRepresentation filterRepresentation = representation.copy();
+ MasterImage.getImage().setPreset(copy, filterRepresentation, true);
+ MasterImage.getImage().setCurrentFilterRepresentation(null);
+ return;
+ }
+ }
useFilterRepresentation(representation);
// show representation
- Editor mCurrentEditor = mEditorPlaceHolder.showEditor(representation.getEditorId());
+ if (mCurrentEditor != null) {
+ mCurrentEditor.detach();
+ }
+ mCurrentEditor = mEditorPlaceHolder.showEditor(representation.getEditorId());
loadEditorPanel(representation, mCurrentEditor);
}
@@ -455,6 +701,93 @@
return mCurrentPanel;
}
+ public void updateCategories() {
+ if (mMasterImage == null) {
+ return;
+ }
+ ImagePreset preset = mMasterImage.getPreset();
+ mCategoryLooksAdapter.reflectImagePreset(preset);
+ mCategoryBordersAdapter.reflectImagePreset(preset);
+ }
+
+ public View getMainStatePanelContainer(int id) {
+ return findViewById(id);
+ }
+
+ public void onShowMenu(PopupMenu menu) {
+ mCurrentMenu = menu;
+ menu.setOnDismissListener(this);
+ }
+
+ @Override
+ public void onDismiss(PopupMenu popupMenu){
+ if (mCurrentMenu == null) {
+ return;
+ }
+ mCurrentMenu.setOnDismissListener(null);
+ mCurrentMenu = null;
+ }
+
+ @Override
+ public void onShow(DialogInterface dialog) {
+ mCurrentDialog = dialog;
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dialogInterface) {
+ mCurrentDialog = null;
+ }
+
+ private class LoadHighresBitmapTask extends AsyncTask<Void, Void, Boolean> {
+ @Override
+ protected Boolean doInBackground(Void... params) {
+ MasterImage master = MasterImage.getImage();
+ Rect originalBounds = master.getOriginalBounds();
+ if (master.supportsHighRes()) {
+ int highresPreviewSize = master.getOriginalBitmapLarge().getWidth() * 2;
+ if (highresPreviewSize > originalBounds.width()) {
+ highresPreviewSize = originalBounds.width();
+ }
+ Rect bounds = new Rect();
+ Bitmap originalHires = ImageLoader.loadOrientedConstrainedBitmap(master.getUri(),
+ master.getActivity(), highresPreviewSize,
+ master.getOrientation(), bounds);
+ master.setOriginalBounds(bounds);
+ master.setOriginalBitmapHighres(originalHires);
+ mBoundService.setOriginalBitmapHighres(originalHires);
+ master.warnListeners();
+ }
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean result) {
+ Bitmap highresBitmap = MasterImage.getImage().getOriginalBitmapHighres();
+ if (highresBitmap != null) {
+ float highResPreviewScale = (float) highresBitmap.getWidth()
+ / (float) MasterImage.getImage().getOriginalBounds().width();
+ mBoundService.setHighresPreviewScaleFactor(highResPreviewScale);
+ }
+ MasterImage.getImage().warnListeners();
+ }
+ }
+
+ public boolean isLoadingVisible() {
+ return mLoadingVisible;
+ }
+
+ public void startLoadingIndicator() {
+ final View loading = findViewById(R.id.loading);
+ mLoadingVisible = true;
+ loading.setVisibility(View.VISIBLE);
+ }
+
+ public void stopLoadingIndicator() {
+ final View loading = findViewById(R.id.loading);
+ loading.setVisibility(View.GONE);
+ mLoadingVisible = false;
+ }
+
private class LoadBitmapTask extends AsyncTask<Uri, Boolean, Boolean> {
int mBitmapSize;
@@ -464,10 +797,10 @@
@Override
protected Boolean doInBackground(Uri... params) {
- if (!mImageLoader.loadBitmap(params[0], mBitmapSize)) {
+ if (!MasterImage.getImage().loadBitmap(params[0], mBitmapSize)) {
return false;
}
- publishProgress(mImageLoader.queryLightCycle360());
+ publishProgress(ImageLoader.queryLightCycle360(MasterImage.getImage().getActivity()));
return true;
}
@@ -490,39 +823,62 @@
}
if (!result) {
- cannotLoadImage();
+ if (mOriginalImageUri != null
+ && !mOriginalImageUri.equals(mSelectedImageUri)) {
+ mOriginalImageUri = mSelectedImageUri;
+ mOriginalPreset = null;
+ Toast.makeText(FilterShowActivity.this,
+ R.string.cannot_edit_original, Toast.LENGTH_SHORT).show();
+ startLoadBitmap(mOriginalImageUri);
+ } else {
+ cannotLoadImage();
+ }
+ return;
}
- final View loading = findViewById(R.id.loading);
- loading.setVisibility(View.GONE);
+ if (null == CachingPipeline.getRenderScriptContext()){
+ Log.v(LOGTAG,"RenderScript context destroyed during load");
+ return;
+ }
final View imageShow = findViewById(R.id.imageShow);
imageShow.setVisibility(View.VISIBLE);
- Bitmap largeBitmap = mImageLoader.getOriginalBitmapLarge();
- FilteringPipeline pipeline = FilteringPipeline.getPipeline();
- pipeline.setOriginal(largeBitmap);
- float previewScale = (float) largeBitmap.getWidth() / (float) mImageLoader.getOriginalBounds().width();
- pipeline.setPreviewScaleFactor(previewScale);
- Bitmap highresBitmap = mImageLoader.getOriginalBitmapHighres();
- if (highresBitmap != null) {
- float highResPreviewScale = (float) highresBitmap.getWidth() / (float) mImageLoader.getOriginalBounds().width();
- pipeline.setHighResPreviewScaleFactor(highResPreviewScale);
- }
+
+ Bitmap largeBitmap = MasterImage.getImage().getOriginalBitmapLarge();
+ mBoundService.setOriginalBitmap(largeBitmap);
+
+ float previewScale = (float) largeBitmap.getWidth()
+ / (float) MasterImage.getImage().getOriginalBounds().width();
+ mBoundService.setPreviewScaleFactor(previewScale);
if (!mShowingTinyPlanet) {
mCategoryFiltersAdapter.removeTinyPlanet();
}
- pipeline.turnOnPipeline(true);
- MasterImage.getImage().setOriginalGeometry(largeBitmap);
mCategoryLooksAdapter.imageLoaded();
mCategoryBordersAdapter.imageLoaded();
mCategoryGeometryAdapter.imageLoaded();
mCategoryFiltersAdapter.imageLoaded();
mLoadBitmapTask = null;
+ MasterImage.getImage().warnListeners();
+ loadActions();
+
+ if (mOriginalPreset != null) {
+ MasterImage.getImage().setLoadedPreset(mOriginalPreset);
+ MasterImage.getImage().setPreset(mOriginalPreset,
+ mOriginalPreset.getLastRepresentation(), true);
+ mOriginalPreset = null;
+ } else {
+ setDefaultPreset();
+ }
+
+ MasterImage.getImage().resetGeometryImages(true);
+
if (mAction == TINY_PLANET_ACTION) {
showRepresentation(mCategoryFiltersAdapter.getTinyPlanet());
}
- mLoading = false;
+ LoadHighresBitmapTask highresLoad = new LoadHighresBitmapTask();
+ highresLoad.execute();
+ MasterImage.getImage().warnListeners();
super.onPostExecute(result);
}
@@ -544,27 +900,17 @@
if (mLoadBitmapTask != null) {
mLoadBitmapTask.cancel(false);
}
- // TODO: refactor, don't use so many singletons.
- FilteringPipeline.getPipeline().turnOnPipeline(false);
- MasterImage.reset();
- FilteringPipeline.reset();
- ImageFilter.resetStatics();
- FiltersManager.getPreviewManager().freeRSFilterScripts();
- FiltersManager.getManager().freeRSFilterScripts();
- FiltersManager.getHighresManager().freeRSFilterScripts();
- FiltersManager.reset();
- CachingPipeline.destroyRenderScriptContext();
+ mUserPresetsManager.close();
+ doUnbindService();
super.onDestroy();
}
+ // TODO: find a more robust way of handling image size selection
+ // for high screen densities.
private int getScreenImageSize() {
- DisplayMetrics metrics = new DisplayMetrics();
- Display display = getWindowManager().getDefaultDisplay();
- Point size = new Point();
- display.getSize(size);
- display.getMetrics(metrics);
- int msize = Math.min(size.x, size.y);
- return (133 * msize) / metrics.densityDpi;
+ DisplayMetrics outMetrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
+ return Math.max(outMetrics.heightPixels, outMetrics.widthPixels);
}
private void showSavingProgress(String albumName) {
@@ -631,7 +977,7 @@
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType(SharedImageProvider.MIME_TYPE);
- mSharedOutputFile = SaveCopyTask.getNewFile(this, mImageLoader.getUri());
+ mSharedOutputFile = SaveImage.getNewFile(this, MasterImage.getImage().getUri());
Uri uri = Uri.withAppendedPath(SharedImageProvider.CONTENT_URI,
Uri.encode(mSharedOutputFile.getAbsolutePath()));
intent.putExtra(Intent.EXTRA_STREAM, uri);
@@ -651,18 +997,28 @@
.getActionProvider();
mShareActionProvider.setShareIntent(getDefaultShareIntent());
mShareActionProvider.setOnShareTargetSelectedListener(this);
-
- MenuItem undoItem = menu.findItem(R.id.undoButton);
- MenuItem redoItem = menu.findItem(R.id.redoButton);
- MenuItem resetItem = menu.findItem(R.id.resetHistoryButton);
- mMasterImage.getHistory().setMenuItems(undoItem, redoItem, resetItem);
+ mMenu = menu;
+ setupMenu();
return true;
}
+ private void setupMenu(){
+ if (mMenu == null || mMasterImage == null) {
+ return;
+ }
+ MenuItem undoItem = mMenu.findItem(R.id.undoButton);
+ MenuItem redoItem = mMenu.findItem(R.id.redoButton);
+ MenuItem resetItem = mMenu.findItem(R.id.resetHistoryButton);
+ MenuItem printItem = mMenu.findItem(R.id.printButton);
+ if (!PrintHelper.systemSupportsPrint()) {
+ printItem.setVisible(false);
+ }
+ mMasterImage.getHistory().setMenuItems(undoItem, redoItem, resetItem);
+ }
+
@Override
public void onPause() {
super.onPause();
- rsPause();
if (mShareActionProvider != null) {
mShareActionProvider.setOnShareTargetSelectedListener(null);
}
@@ -671,65 +1027,26 @@
@Override
public void onResume() {
super.onResume();
- rsResume();
if (mShareActionProvider != null) {
mShareActionProvider.setOnShareTargetSelectedListener(this);
}
}
- private void rsResume() {
- ImageFilter.setActivityForMemoryToasts(this);
- MasterImage.setMaster(mMasterImage);
- if (CachingPipeline.getRenderScriptContext() == null) {
- CachingPipeline.createRenderscriptContext(this);
- }
- FiltersManager.setResources(getResources());
- if (!mLoading) {
- Bitmap largeBitmap = mImageLoader.getOriginalBitmapLarge();
- FilteringPipeline pipeline = FilteringPipeline.getPipeline();
- pipeline.setOriginal(largeBitmap);
- float previewScale = (float) largeBitmap.getWidth() /
- (float) mImageLoader.getOriginalBounds().width();
- pipeline.setPreviewScaleFactor(previewScale);
- Bitmap highresBitmap = mImageLoader.getOriginalBitmapHighres();
- if (highresBitmap != null) {
- float highResPreviewScale = (float) highresBitmap.getWidth() /
- (float) mImageLoader.getOriginalBounds().width();
- pipeline.setHighResPreviewScaleFactor(highResPreviewScale);
- }
- pipeline.turnOnPipeline(true);
- MasterImage.getImage().setOriginalGeometry(largeBitmap);
- }
- }
-
- private void rsPause() {
- FilteringPipeline.getPipeline().turnOnPipeline(false);
- FilteringPipeline.reset();
- ImageFilter.resetStatics();
- FiltersManager.getPreviewManager().freeRSFilterScripts();
- FiltersManager.getManager().freeRSFilterScripts();
- FiltersManager.getHighresManager().freeRSFilterScripts();
- FiltersManager.reset();
- CachingPipeline.destroyRenderScriptContext();
- }
-
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.undoButton: {
- HistoryAdapter adapter = mMasterImage.getHistory();
+ HistoryManager adapter = mMasterImage.getHistory();
int position = adapter.undo();
mMasterImage.onHistoryItemClick(position);
- mImageShow.showToast("Undo");
backToMain();
invalidateViews();
return true;
}
case R.id.redoButton: {
- HistoryAdapter adapter = mMasterImage.getHistory();
+ HistoryManager adapter = mMasterImage.getHistory();
int position = adapter.redo();
mMasterImage.onHistoryItemClick(position);
- mImageShow.showToast("Redo");
invalidateViews();
return true;
}
@@ -741,40 +1058,146 @@
toggleImageStatePanel();
return true;
}
+ case R.id.exportFlattenButton: {
+ showExportOptionsDialog();
+ return true;
+ }
case android.R.id.home: {
saveImage();
return true;
}
+ case R.id.manageUserPresets: {
+ manageUserPresets();
+ return true;
+ }
+ case R.id.showInfoPanel: {
+ toggleInformationPanel();
+ return true;
+ }
+ case R.id.printButton: {
+ print();
+ return true;
+ }
}
return false;
}
- public void enableSave(boolean enable) {
- if (mSaveButton != null)
- mSaveButton.setEnabled(enable);
+ public void print() {
+ Bitmap bitmap = MasterImage.getImage().getHighresImage();
+ PrintHelper printer = new PrintHelper(this);
+ printer.printBitmap("ImagePrint", bitmap);
}
- private void fillFx() {
- FilterFxRepresentation nullFx =
- new FilterFxRepresentation(getString(R.string.none), 0, R.string.none);
- Vector<FilterRepresentation> filtersRepresentations = new Vector<FilterRepresentation>();
- FiltersManager.getManager().addLooks(this, filtersRepresentations);
+ public void addNewPreset() {
+ DialogFragment dialog = new PresetManagementDialog();
+ dialog.show(getSupportFragmentManager(), "NoticeDialogFragment");
+ }
+ private void manageUserPresets() {
+ DialogFragment dialog = new PresetManagementDialog();
+ dialog.show(getSupportFragmentManager(), "NoticeDialogFragment");
+ }
+
+ private void showExportOptionsDialog() {
+ DialogFragment dialog = new ExportDialog();
+ dialog.show(getSupportFragmentManager(), "ExportDialogFragment");
+ }
+
+ public void updateUserPresetsFromAdapter(UserPresetsAdapter adapter) {
+ ArrayList<FilterUserPresetRepresentation> representations =
+ adapter.getDeletedRepresentations();
+ for (FilterUserPresetRepresentation representation : representations) {
+ deletePreset(representation.getId());
+ }
+ ArrayList<FilterUserPresetRepresentation> changedRepresentations =
+ adapter.getChangedRepresentations();
+ for (FilterUserPresetRepresentation representation : changedRepresentations) {
+ updatePreset(representation);
+ }
+ adapter.clearDeletedRepresentations();
+ adapter.clearChangedRepresentations();
+ loadUserPresets();
+ }
+
+ public void loadUserPresets() {
+ mUserPresetsManager.load();
+ updateUserPresetsFromManager();
+ }
+
+ public void updateUserPresetsFromManager() {
+ ArrayList<FilterUserPresetRepresentation> presets = mUserPresetsManager.getRepresentations();
+ if (presets == null) {
+ return;
+ }
+ if (mCategoryLooksAdapter != null) {
+ fillLooks();
+ }
+ if (presets.size() > 0) {
+ mCategoryLooksAdapter.add(new Action(this, Action.SPACER));
+ }
+ mUserPresetsAdapter.clear();
+ for (int i = 0; i < presets.size(); i++) {
+ FilterUserPresetRepresentation representation = presets.get(i);
+ mCategoryLooksAdapter.add(
+ new Action(this, representation, Action.FULL_VIEW, true));
+ mUserPresetsAdapter.add(new Action(this, representation, Action.FULL_VIEW));
+ }
+ if (presets.size() > 0) {
+ mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
+ }
+ mCategoryLooksAdapter.notifyDataSetChanged();
+ mCategoryLooksAdapter.notifyDataSetInvalidated();
+ }
+
+ public void saveCurrentImagePreset(String name) {
+ mUserPresetsManager.save(MasterImage.getImage().getPreset(), name);
+ }
+
+ private void deletePreset(int id) {
+ mUserPresetsManager.delete(id);
+ }
+
+ private void updatePreset(FilterUserPresetRepresentation representation) {
+ mUserPresetsManager.update(representation);
+ }
+
+ public void enableSave(boolean enable) {
+ if (mSaveButton != null) {
+ mSaveButton.setEnabled(enable);
+ }
+ }
+
+ private void fillLooks() {
+ FiltersManager filtersManager = FiltersManager.getManager();
+ ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getLooks();
+
+ if (mCategoryLooksAdapter != null) {
+ mCategoryLooksAdapter.clear();
+ }
mCategoryLooksAdapter = new CategoryAdapter(this);
int verticalItemHeight = (int) getResources().getDimension(R.dimen.action_item_height);
mCategoryLooksAdapter.setItemHeight(verticalItemHeight);
- mCategoryLooksAdapter.add(new Action(this, nullFx, Action.FULL_VIEW));
for (FilterRepresentation representation : filtersRepresentations) {
mCategoryLooksAdapter.add(new Action(this, representation, Action.FULL_VIEW));
}
+ if (mUserPresetsManager.getRepresentations() == null
+ || mUserPresetsManager.getRepresentations().size() == 0) {
+ mCategoryLooksAdapter.add(new Action(this, Action.ADD_ACTION));
+ }
+
+ Fragment panel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
+ if (panel != null) {
+ if (panel instanceof MainPanel) {
+ MainPanel mainPanel = (MainPanel) panel;
+ mainPanel.loadCategoryLookPanel(true);
+ }
+ }
}
public void setDefaultPreset() {
// Default preset (original)
- ImagePreset preset = new ImagePreset(getString(R.string.history_original)); // empty
- preset.setImageLoader(mImageLoader);
-
- mMasterImage.setPreset(preset, true);
+ ImagePreset preset = new ImagePreset(); // empty
+ mMasterImage.setPreset(preset, preset.getLastRepresentation(), true);
}
// //////////////////////////////////////////////////////////////////////////////
@@ -783,7 +1206,6 @@
public void invalidateViews() {
for (ImageShow views : mImageViews) {
- views.invalidate();
views.updateImage();
}
}
@@ -813,36 +1235,52 @@
}
}
+ public void toggleVersionsPanel() {
+ mShowingVersionsPanel = !mShowingVersionsPanel;
+ Fragment panel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
+ if (panel != null && panel instanceof MainPanel) {
+ MainPanel mainPanel = (MainPanel) panel;
+ mainPanel.loadCategoryVersionsPanel();
+ }
+ }
+
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
+
setDefaultValues();
+ if (mMasterImage == null) {
+ return;
+ }
loadXML();
+ fillCategories();
loadMainPanel();
+ if (mCurrentMenu != null) {
+ mCurrentMenu.dismiss();
+ mCurrentMenu = null;
+ }
+ if (mCurrentDialog != null) {
+ mCurrentDialog.dismiss();
+ mCurrentDialog = null;
+ }
// mLoadBitmapTask==null implies you have looked at the intent
if (!mShowingTinyPlanet && (mLoadBitmapTask == null)) {
mCategoryFiltersAdapter.removeTinyPlanet();
}
- final View loading = findViewById(R.id.loading);
- loading.setVisibility(View.GONE);
+ stopLoadingIndicator();
}
public void setupMasterImage() {
- mImageLoader = new ImageLoader(this, getApplicationContext());
- HistoryAdapter mHistoryAdapter = new HistoryAdapter(
- this, R.layout.filtershow_history_operation_row,
- R.id.rowTextView);
-
- StateAdapter mImageStateAdapter = new StateAdapter(this, 0);
+ HistoryManager historyManager = new HistoryManager();
+ StateAdapter imageStateAdapter = new StateAdapter(this, 0);
MasterImage.reset();
mMasterImage = MasterImage.getImage();
- mMasterImage.setHistoryAdapter(mHistoryAdapter);
- mMasterImage.setStateAdapter(mImageStateAdapter);
+ mMasterImage.setHistoryManager(historyManager);
+ mMasterImage.setStateAdapter(imageStateAdapter);
mMasterImage.setActivity(this);
- mMasterImage.setImageLoader(mImageLoader);
if (Runtime.getRuntime().maxMemory() > LIMIT_SUPPORTS_HIGHRES) {
mMasterImage.setSupportsHighRes(true);
@@ -852,10 +1290,20 @@
}
void resetHistory() {
- HistoryAdapter adapter = mMasterImage.getHistory();
+ HistoryManager adapter = mMasterImage.getHistory();
adapter.reset();
- ImagePreset original = new ImagePreset(adapter.getItem(0));
- mMasterImage.setPreset(original, true);
+ HistoryItem historyItem = adapter.getItem(0);
+ ImagePreset original = null;
+ if (RESET_TO_LOADED) {
+ original = new ImagePreset(historyItem.getImagePreset());
+ } else {
+ original = new ImagePreset();
+ }
+ FilterRepresentation rep = null;
+ if (historyItem != null) {
+ rep = historyItem.getFilterRepresentation();
+ }
+ mMasterImage.setPreset(original, rep, true);
invalidateViews();
backToMain();
}
@@ -886,11 +1334,13 @@
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.unsaved).setTitle(R.string.save_before_exit);
builder.setPositiveButton(R.string.save_and_exit, new DialogInterface.OnClickListener() {
+ @Override
public void onClick(DialogInterface dialog, int id) {
saveImage();
}
});
builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
+ @Override
public void onClick(DialogInterface dialog, int id) {
done();
}
@@ -903,9 +1353,7 @@
}
public void cannotLoadImage() {
- CharSequence text = getString(R.string.cannot_load_image);
- Toast toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
- toast.show();
+ Toast.makeText(this, R.string.cannot_load_image, Toast.LENGTH_SHORT).show();
finish();
}
@@ -942,116 +1390,128 @@
}
}
- private boolean mSaveToExtraUri = false;
- private boolean mSaveAsWallpaper = false;
- private boolean mReturnAsExtra = false;
- private boolean mOutputted = false;
public void saveImage() {
- handleSpecialExitCases();
- if (!mOutputted) {
- if (mImageShow.hasModifications()) {
- // Get the name of the album, to which the image will be saved
- File saveDir = SaveCopyTask.getFinalSaveDirectory(this, mImageLoader.getUri());
- int bucketId = GalleryUtils.getBucketId(saveDir.getPath());
- String albumName = LocalAlbum.getLocalizedName(getResources(), bucketId, null);
- showSavingProgress(albumName);
- mImageShow.saveImage(this, null);
- } else {
- done();
- }
- }
- }
-
- public boolean detectSpecialExitCases() {
- return mCropExtras != null && (mCropExtras.getExtraOutput() != null
- || mCropExtras.getSetAsWallpaper() || mCropExtras.getReturnData());
- }
-
- public void handleSpecialExitCases() {
- if (mCropExtras != null) {
- if (mCropExtras.getExtraOutput() != null) {
- mSaveToExtraUri = true;
- mOutputted = true;
- }
- if (mCropExtras.getSetAsWallpaper()) {
- mSaveAsWallpaper = true;
- mOutputted = true;
- }
- if (mCropExtras.getReturnData()) {
- mReturnAsExtra = true;
- mOutputted = true;
- }
- if (mOutputted) {
- mImageShow.getImagePreset().mGeoData.setUseCropExtrasFlag(true);
- showSavingProgress(null);
- mImageShow.returnFilteredResult(this);
- }
- }
- }
-
- public void onFilteredResult(Bitmap filtered) {
- Intent intent = new Intent();
- intent.putExtra(CropExtras.KEY_CROPPED_RECT, mImageShow.getImageCropBounds());
- if (mSaveToExtraUri) {
- mImageShow.saveToUri(filtered, mCropExtras.getExtraOutput(),
- mCropExtras.getOutputFormat(), this);
- }
- if (mSaveAsWallpaper) {
- setWallpaperInBackground(filtered);
- }
- if (mReturnAsExtra) {
- if (filtered != null) {
- int bmapSize = filtered.getRowBytes() * filtered.getHeight();
- /*
- * Max size of Binder transaction buffer is 1Mb, so constrain
- * Bitmap to be somewhat less than this, otherwise we get
- * TransactionTooLargeExceptions.
- */
- if (bmapSize > MAX_BMAP_IN_INTENT) {
- Log.w(LOGTAG, "Bitmap too large to be returned via intent");
- } else {
- intent.putExtra(CropExtras.KEY_DATA, filtered);
- }
- }
- }
- setResult(RESULT_OK, intent);
- if (!mSaveToExtraUri) {
+ if (mImageShow.hasModifications()) {
+ // Get the name of the album, to which the image will be saved
+ File saveDir = SaveImage.getFinalSaveDirectory(this, mSelectedImageUri);
+ int bucketId = GalleryUtils.getBucketId(saveDir.getPath());
+ String albumName = LocalAlbum.getLocalizedName(getResources(), bucketId, null);
+ showSavingProgress(albumName);
+ mImageShow.saveImage(this, null);
+ } else {
done();
}
}
- void setWallpaperInBackground(final Bitmap bmap) {
- Toast.makeText(this, R.string.setting_wallpaper, Toast.LENGTH_LONG).show();
- BitmapTask.Callbacks<FilterShowActivity> cb = new BitmapTask.Callbacks<FilterShowActivity>() {
- @Override
- public void onComplete(Bitmap result) {}
-
- @Override
- public void onCancel() {}
-
- @Override
- public Bitmap onExecute(FilterShowActivity param) {
- try {
- WallpaperManager.getInstance(param).setBitmap(bmap);
- } catch (IOException e) {
- Log.w(LOGTAG, "fail to set wall paper", e);
- }
- return null;
- }
- };
- (new BitmapTask<FilterShowActivity>(cb)).execute(this);
- }
public void done() {
- if (mOutputted) {
- hideSavingProgress();
+ hideSavingProgress();
+ if (mLoadBitmapTask != null) {
+ mLoadBitmapTask.cancel(false);
}
finish();
}
- static {
- System.loadLibrary("jni_filtershow_filters");
+ private void extractXMPData() {
+ XMresults res = XmpPresets.extractXMPData(
+ getBaseContext(), mMasterImage, getIntent().getData());
+ if (res == null)
+ return;
+
+ mOriginalImageUri = res.originalimage;
+ mOriginalPreset = res.preset;
}
+ public Uri getSelectedImageUri() {
+ return mSelectedImageUri;
+ }
+
+ public void setHandlesSwipeForView(View view, float startX, float startY) {
+ if (view != null) {
+ mHandlingSwipeButton = true;
+ } else {
+ mHandlingSwipeButton = false;
+ }
+ mHandledSwipeView = view;
+ int[] location = new int[2];
+ view.getLocationInWindow(location);
+ mSwipeStartX = location[0] + startX;
+ mSwipeStartY = location[1] + startY;
+ }
+
+ public boolean dispatchTouchEvent (MotionEvent ev) {
+ if (mHandlingSwipeButton) {
+ int direction = CategoryView.HORIZONTAL;
+ if (mHandledSwipeView instanceof CategoryView) {
+ direction = ((CategoryView) mHandledSwipeView).getOrientation();
+ }
+ if (ev.getActionMasked() == MotionEvent.ACTION_MOVE) {
+ float delta = ev.getY() - mSwipeStartY;
+ float distance = mHandledSwipeView.getHeight();
+ if (direction == CategoryView.VERTICAL) {
+ delta = ev.getX() - mSwipeStartX;
+ mHandledSwipeView.setTranslationX(delta);
+ distance = mHandledSwipeView.getWidth();
+ } else {
+ mHandledSwipeView.setTranslationY(delta);
+ }
+ delta = Math.abs(delta);
+ float transparency = Math.min(1, delta / distance);
+ mHandledSwipeView.setAlpha(1.f - transparency);
+ mHandledSwipeViewLastDelta = delta;
+ }
+ if (ev.getActionMasked() == MotionEvent.ACTION_CANCEL
+ || ev.getActionMasked() == MotionEvent.ACTION_UP) {
+ mHandledSwipeView.setTranslationX(0);
+ mHandledSwipeView.setTranslationY(0);
+ mHandledSwipeView.setAlpha(1.f);
+ mHandlingSwipeButton = false;
+ float distance = mHandledSwipeView.getHeight();
+ if (direction == CategoryView.VERTICAL) {
+ distance = mHandledSwipeView.getWidth();
+ }
+ if (mHandledSwipeViewLastDelta > distance) {
+ ((SwipableView) mHandledSwipeView).delete();
+ }
+ }
+ return true;
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+
+ public Point mHintTouchPoint = new Point();
+
+ public Point hintTouchPoint(View view) {
+ int location[] = new int[2];
+ view.getLocationOnScreen(location);
+ int x = mHintTouchPoint.x - location[0];
+ int y = mHintTouchPoint.y - location[1];
+ return new Point(x, y);
+ }
+
+ public void startTouchAnimation(View target, float x, float y) {
+ final CategorySelected hint =
+ (CategorySelected) findViewById(R.id.categorySelectedIndicator);
+ int location[] = new int[2];
+ target.getLocationOnScreen(location);
+ mHintTouchPoint.x = (int) (location[0] + x);
+ mHintTouchPoint.y = (int) (location[1] + y);
+ int locationHint[] = new int[2];
+ ((View)hint.getParent()).getLocationOnScreen(locationHint);
+ int dx = (int) (x - (hint.getWidth())/2);
+ int dy = (int) (y - (hint.getHeight())/2);
+ hint.setTranslationX(location[0] - locationHint[0] + dx);
+ hint.setTranslationY(location[1] - locationHint[1] + dy);
+ hint.setVisibility(View.VISIBLE);
+ hint.animate().scaleX(2).scaleY(2).alpha(0).withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ hint.setVisibility(View.INVISIBLE);
+ hint.setScaleX(1);
+ hint.setScaleY(1);
+ hint.setAlpha(1);
+ }
+ });
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/HistoryAdapter.java b/src/com/android/gallery3d/filtershow/HistoryAdapter.java
deleted file mode 100644
index 79460be..0000000
--- a/src/com/android/gallery3d/filtershow/HistoryAdapter.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-
-import java.util.Vector;
-
-public class HistoryAdapter extends ArrayAdapter<ImagePreset> {
- private static final String LOGTAG = "HistoryAdapter";
- private int mCurrentPresetPosition = 0;
- private String mBorders = null;
- private String mCrop = null;
- private String mRotate = null;
- private String mStraighten = null;
- private String mMirror = null;
- private MenuItem mUndoMenuItem = null;
- private MenuItem mRedoMenuItem = null;
- private MenuItem mResetMenuItem = null;
-
- private Bitmap mOriginalBitmap = null;
-
- public HistoryAdapter(Context context, int resource, int textViewResourceId) {
- super(context, resource, textViewResourceId);
- FilterShowActivity activity = (FilterShowActivity) context;
- mBorders = context.getString(R.string.borders);
- mCrop = context.getString(R.string.crop);
- mRotate = context.getString(R.string.rotate);
- mStraighten = context.getString(R.string.straighten);
- mMirror = context.getString(R.string.mirror);
- }
-
- public void setMenuItems(MenuItem undoItem, MenuItem redoItem, MenuItem resetItem) {
- mUndoMenuItem = undoItem;
- mRedoMenuItem = redoItem;
- mResetMenuItem = resetItem;
- updateMenuItems();
- }
-
- public boolean canReset() {
- if (getCount() <= 1) {
- return false;
- }
- return true;
- }
-
- public boolean canUndo() {
- if (mCurrentPresetPosition == getCount() - 1) {
- return false;
- }
- return true;
- }
-
- public boolean canRedo() {
- if (mCurrentPresetPosition == 0) {
- return false;
- }
- return true;
- }
-
- public void updateMenuItems() {
- if (mUndoMenuItem != null) {
- setEnabled(mUndoMenuItem, canUndo());
- }
- if (mRedoMenuItem != null) {
- setEnabled(mRedoMenuItem, canRedo());
- }
- if (mResetMenuItem != null) {
- setEnabled(mResetMenuItem, canReset());
- }
- }
-
- private void setEnabled(MenuItem item, boolean enabled) {
- item.setEnabled(enabled);
- Drawable drawable = item.getIcon();
- if (drawable != null) {
- drawable.setAlpha(enabled ? 255 : 80);
- }
- }
-
- public void setCurrentPreset(int n) {
- mCurrentPresetPosition = n;
- updateMenuItems();
- this.notifyDataSetChanged();
- }
-
- public void reset() {
- if (getCount() == 0) {
- return;
- }
- ImagePreset first = getItem(getCount() - 1);
- clear();
- addHistoryItem(first);
- updateMenuItems();
- }
-
- public ImagePreset getLast() {
- if (getCount() == 0) {
- return null;
- }
- return getItem(0);
- }
-
- public ImagePreset getCurrent() {
- return getItem(mCurrentPresetPosition);
- }
-
- public void addHistoryItem(ImagePreset preset) {
- insert(preset, 0);
- updateMenuItems();
- }
-
- @Override
- public void insert(ImagePreset preset, int position) {
- if (mCurrentPresetPosition != 0) {
- // in this case, let's discount the presets before the current one
- Vector<ImagePreset> oldItems = new Vector<ImagePreset>();
- for (int i = mCurrentPresetPosition; i < getCount(); i++) {
- oldItems.add(getItem(i));
- }
- clear();
- for (int i = 0; i < oldItems.size(); i++) {
- add(oldItems.elementAt(i));
- }
- mCurrentPresetPosition = position;
- this.notifyDataSetChanged();
- }
- super.insert(preset, position);
- mCurrentPresetPosition = position;
- this.notifyDataSetChanged();
- }
-
- public int redo() {
- mCurrentPresetPosition--;
- if (mCurrentPresetPosition < 0) {
- mCurrentPresetPosition = 0;
- }
- this.notifyDataSetChanged();
- updateMenuItems();
- return mCurrentPresetPosition;
- }
-
- public int undo() {
- mCurrentPresetPosition++;
- if (mCurrentPresetPosition >= getCount()) {
- mCurrentPresetPosition = getCount() - 1;
- }
- this.notifyDataSetChanged();
- updateMenuItems();
- return mCurrentPresetPosition;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View view = convertView;
- if (view == null) {
- LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- view = inflater.inflate(R.layout.filtershow_history_operation_row, null);
- }
-
- ImagePreset item = getItem(position);
- if (item != null) {
- TextView itemView = (TextView) view.findViewById(R.id.rowTextView);
- if (itemView != null) {
- itemView.setText(item.historyName());
- }
- ImageView preview = (ImageView) view.findViewById(R.id.preview);
- Bitmap bmp = item.getPreviewImage();
- if (position == getCount()-1 && mOriginalBitmap != null) {
- bmp = mOriginalBitmap;
- }
- if (bmp != null) {
- preview.setImageBitmap(bmp);
- } else {
- preview.setImageResource(android.R.color.transparent);
- }
- if (position == mCurrentPresetPosition) {
- view.setBackgroundColor(Color.WHITE);
- } else {
- view.setBackgroundResource(R.color.background_main_toolbar);
- }
- }
-
- return view;
- }
-
-
- public void setOriginalBitmap(Bitmap originalBitmap) {
- mOriginalBitmap = originalBitmap;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/cache/BitmapCache.java b/src/com/android/gallery3d/filtershow/cache/BitmapCache.java
new file mode 100644
index 0000000..cd63d30
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/cache/BitmapCache.java
@@ -0,0 +1,216 @@
+/*
+ * 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.cache;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.util.Log;
+import com.android.gallery3d.filtershow.pipeline.Buffer;
+import com.android.gallery3d.filtershow.pipeline.CacheProcessing;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+public class BitmapCache {
+ private static final String LOGTAG = "BitmapCache";
+ private HashMap<Long, ArrayList<WeakReference<Bitmap>>>
+ mBitmapCache = new HashMap<Long, ArrayList<WeakReference<Bitmap>>>();
+ private final int mMaxItemsPerKey = 4;
+
+ private static final boolean DEBUG = false;
+ private CacheProcessing mCacheProcessing;
+
+ public final static int PREVIEW_CACHE = 1;
+ public final static int NEW_LOOK = 2;
+ public final static int ICON = 3;
+ public final static int FILTERS = 4;
+ public final static int GEOMETRY = 5;
+ public final static int HIGHRES = 6;
+ public final static int UTIL_GEOMETRY = 7;
+ public final static int RENDERING_REQUEST = 8;
+ public final static int REGION = 9;
+ public final static int TINY_PLANET = 10;
+ public final static int PREVIEW_CACHE_NO_FILTERS = 11;
+ public final static int PREVIEW_CACHE_NO_ROOT = 12;
+ public static final int PREVIEW_CACHE_NO_APPLY = 13;
+ public final static int TRACKING_COUNT = 14;
+ private int[] mTracking = new int[TRACKING_COUNT];
+
+ class BitmapTracking {
+ Bitmap bitmap;
+ int type;
+ }
+
+ private ArrayList<BitmapTracking> mBitmapTracking = new ArrayList<BitmapTracking>();
+
+ private void track(Bitmap bitmap, int type) {
+ for (int i = 0; i < mBitmapTracking.size(); i++) {
+ BitmapTracking tracking = mBitmapTracking.get(i);
+ if (tracking.bitmap == bitmap) {
+ Log.e(LOGTAG, "giving a bitmap already given!!!");
+ }
+ }
+ BitmapTracking tracking = new BitmapTracking();
+ tracking.bitmap = bitmap;
+ tracking.type = type;
+ mBitmapTracking.add(tracking);
+ mTracking[tracking.type] ++;
+ }
+
+ private void untrack(Bitmap bitmap) {
+ for (int i = 0; i < mBitmapTracking.size(); i++) {
+ BitmapTracking tracking = mBitmapTracking.get(i);
+ if (tracking.bitmap == bitmap) {
+ mTracking[tracking.type] --;
+ mBitmapTracking.remove(i);
+ return;
+ }
+ }
+ }
+
+ public String getTrackingName(int i) {
+ switch (i) {
+ case PREVIEW_CACHE: return "PREVIEW_CACHE";
+ case PREVIEW_CACHE_NO_FILTERS: return "PREVIEW_CACHE_NO_FILTERS";
+ case PREVIEW_CACHE_NO_ROOT: return "PREVIEW_CACHE_NO_ROOT";
+ case PREVIEW_CACHE_NO_APPLY: return "PREVIEW_CACHE_NO_APPLY";
+ case NEW_LOOK: return "NEW_LOOK";
+ case ICON: return "ICON";
+ case FILTERS: return "FILTERS";
+ case GEOMETRY: return "GEOMETRY";
+ case HIGHRES: return "HIGHRES";
+ case UTIL_GEOMETRY: return "UTIL_GEOMETRY";
+ case RENDERING_REQUEST: return "RENDERING_REQUEST";
+ case REGION: return "REGION";
+ case TINY_PLANET: return "TINY_PLANET";
+ }
+ return "UNKNOWN";
+ }
+
+ public void showBitmapCounts() {
+ if (!DEBUG) {
+ return;
+ }
+ Log.v(LOGTAG, "\n--- showBitmap --- ");
+ for (int i = 0; i < TRACKING_COUNT; i++) {
+ if (mTracking[i] != 0) {
+ Log.v(LOGTAG, getTrackingName(i) + " => " + mTracking[i]);
+ }
+ }
+ }
+
+ public void setCacheProcessing(CacheProcessing cache) {
+ mCacheProcessing = cache;
+ }
+
+ public void cache(Buffer buffer) {
+ if (buffer == null) {
+ return;
+ }
+ Bitmap bitmap = buffer.getBitmap();
+ cache(bitmap);
+ }
+
+ public synchronized boolean cache(Bitmap bitmap) {
+ if (bitmap == null) {
+ return true;
+ }
+ if (mCacheProcessing != null && mCacheProcessing.contains(bitmap)) {
+ Log.e(LOGTAG, "Trying to cache a bitmap still used in the pipeline");
+ return false;
+ }
+ if (DEBUG) {
+ untrack(bitmap);
+ }
+ if (!bitmap.isMutable()) {
+ Log.e(LOGTAG, "Trying to cache a non mutable bitmap");
+ return true;
+ }
+ Long key = calcKey(bitmap.getWidth(), bitmap.getHeight());
+ ArrayList<WeakReference<Bitmap>> list = mBitmapCache.get(key);
+ if (list == null) {
+ list = new ArrayList<WeakReference<Bitmap>>();
+ mBitmapCache.put(key, list);
+ }
+ int i = 0;
+ while (i < list.size()) {
+ if (list.get(i).get() == null) {
+ list.remove(i);
+ } else {
+ i++;
+ }
+ }
+ for (i = 0; i < list.size(); i++) {
+ if (list.get(i).get() == null) {
+ list.remove(i);
+ }
+ }
+ if (list.size() < mMaxItemsPerKey) {
+ for (i = 0; i < list.size(); i++) {
+ WeakReference<Bitmap> ref = list.get(i);
+ if (ref.get() == bitmap) {
+ return true; // bitmap already in the cache
+ }
+ }
+ list.add(new WeakReference<Bitmap>(bitmap));
+ }
+ return true;
+ }
+
+ public synchronized Bitmap getBitmap(int w, int h, int type) {
+ Long key = calcKey(w, h);
+ WeakReference<Bitmap> ref = null;
+ ArrayList<WeakReference<Bitmap>> list = mBitmapCache.get(key);
+ if (list != null && list.size() > 0) {
+ ref = list.remove(0);
+ if (list.size() == 0) {
+ mBitmapCache.remove(key);
+ }
+ }
+ Bitmap bitmap = null;
+ if (ref != null) {
+ bitmap = ref.get();
+ }
+ if (bitmap == null
+ || bitmap.getWidth() != w
+ || bitmap.getHeight() != h) {
+ bitmap = Bitmap.createBitmap(
+ w, h, Bitmap.Config.ARGB_8888);
+ showBitmapCounts();
+ }
+
+ if (DEBUG) {
+ track(bitmap, type);
+ if (mCacheProcessing != null && mCacheProcessing.contains(bitmap)) {
+ Log.e(LOGTAG, "Trying to give a bitmap used in the pipeline");
+ }
+ }
+ return bitmap;
+ }
+
+ public synchronized Bitmap getBitmapCopy(Bitmap source, int type) {
+ Bitmap bitmap = getBitmap(source.getWidth(), source.getHeight(), type);
+ Canvas canvas = new Canvas(bitmap);
+ canvas.drawBitmap(source, 0, 0, null);
+ return bitmap;
+ }
+
+ private Long calcKey(long w, long h) {
+ return (w << 32) | h;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java b/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java
deleted file mode 100644
index 8760c4a..0000000
--- a/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * 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.cache;
-
-import android.app.Activity;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.support.v8.renderscript.Allocation;
-import android.support.v8.renderscript.RenderScript;
-import android.util.Log;
-
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.filters.ImageFilterGeometry;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.FilterEnvironment;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-
-public class CachingPipeline {
- private static final String LOGTAG = "CachingPipeline";
- private boolean DEBUG = false;
-
- private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
-
- private static volatile RenderScript sRS = null;
- private static volatile Resources sResources = null;
-
- private FiltersManager mFiltersManager = null;
- private volatile Bitmap mOriginalBitmap = null;
- private volatile Bitmap mResizedOriginalBitmap = null;
-
- private FilterEnvironment mEnvironment = new FilterEnvironment();
-
- private volatile Allocation mOriginalAllocation = null;
- private volatile Allocation mFiltersOnlyOriginalAllocation = null;
-
- protected volatile Allocation mInPixelsAllocation;
- protected volatile Allocation mOutPixelsAllocation;
- private volatile int mWidth = 0;
- private volatile int mHeight = 0;
-
- private volatile GeometryMetadata mPreviousGeometry = null;
- private volatile float mPreviewScaleFactor = 1.0f;
- private volatile float mHighResPreviewScaleFactor = 1.0f;
- private volatile String mName = "";
-
- private ImageFilterGeometry mGeometry = null;
-
- public CachingPipeline(FiltersManager filtersManager, String name) {
- mFiltersManager = filtersManager;
- mName = name;
- }
-
- public static synchronized Resources getResources() {
- return sResources;
- }
-
- public static synchronized void setResources(Resources resources) {
- sResources = resources;
- }
-
- public static synchronized RenderScript getRenderScriptContext() {
- return sRS;
- }
-
- public static synchronized void setRenderScriptContext(RenderScript RS) {
- sRS = RS;
- }
-
- public static synchronized void createRenderscriptContext(Activity context) {
- if (sRS != null) {
- Log.w(LOGTAG, "A prior RS context exists when calling setRenderScriptContext");
- destroyRenderScriptContext();
- }
- sRS = RenderScript.create(context);
- sResources = context.getResources();
- }
-
- public static synchronized void destroyRenderScriptContext() {
- if (sRS != null) {
- sRS.destroy();
- }
- sRS = null;
- sResources = null;
- }
-
- public void stop() {
- mEnvironment.setStop(true);
- }
-
- public synchronized void reset() {
- synchronized (CachingPipeline.class) {
- if (getRenderScriptContext() == null) {
- return;
- }
- mOriginalBitmap = null; // just a reference to the bitmap in ImageLoader
- if (mResizedOriginalBitmap != null) {
- mResizedOriginalBitmap.recycle();
- mResizedOriginalBitmap = null;
- }
- if (mOriginalAllocation != null) {
- mOriginalAllocation.destroy();
- mOriginalAllocation = null;
- }
- if (mFiltersOnlyOriginalAllocation != null) {
- mFiltersOnlyOriginalAllocation.destroy();
- mFiltersOnlyOriginalAllocation = null;
- }
- mPreviousGeometry = null;
- mPreviewScaleFactor = 1.0f;
- mHighResPreviewScaleFactor = 1.0f;
-
- destroyPixelAllocations();
- }
- }
-
- private synchronized void destroyPixelAllocations() {
- if (DEBUG) {
- Log.v(LOGTAG, "destroyPixelAllocations in " + getName());
- }
- if (mInPixelsAllocation != null) {
- mInPixelsAllocation.destroy();
- mInPixelsAllocation = null;
- }
- if (mOutPixelsAllocation != null) {
- mOutPixelsAllocation.destroy();
- mOutPixelsAllocation = null;
- }
- mWidth = 0;
- mHeight = 0;
- }
-
- private String getType(RenderingRequest request) {
- if (request.getType() == RenderingRequest.ICON_RENDERING) {
- return "ICON_RENDERING";
- }
- if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
- return "FILTERS_RENDERING";
- }
- if (request.getType() == RenderingRequest.FULL_RENDERING) {
- return "FULL_RENDERING";
- }
- if (request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
- return "GEOMETRY_RENDERING";
- }
- if (request.getType() == RenderingRequest.PARTIAL_RENDERING) {
- return "PARTIAL_RENDERING";
- }
- if (request.getType() == RenderingRequest.HIGHRES_RENDERING) {
- return "HIGHRES_RENDERING";
- }
- return "UNKNOWN TYPE!";
- }
-
- private void setupEnvironment(ImagePreset preset, boolean highResPreview) {
- mEnvironment.setCachingPipeline(this);
- mEnvironment.setFiltersManager(mFiltersManager);
- if (highResPreview) {
- mEnvironment.setScaleFactor(mHighResPreviewScaleFactor);
- } else {
- mEnvironment.setScaleFactor(mPreviewScaleFactor);
- }
- mEnvironment.setQuality(ImagePreset.QUALITY_PREVIEW);
- mEnvironment.setImagePreset(preset);
- mEnvironment.setStop(false);
- }
-
- public void setOriginal(Bitmap bitmap) {
- mOriginalBitmap = bitmap;
- Log.v(LOGTAG,"setOriginal, size " + bitmap.getWidth() + " x " + bitmap.getHeight());
- ImagePreset preset = MasterImage.getImage().getPreset();
- setupEnvironment(preset, false);
- updateOriginalAllocation(preset);
- }
-
- private synchronized boolean updateOriginalAllocation(ImagePreset preset) {
- Bitmap originalBitmap = mOriginalBitmap;
-
- if (originalBitmap == null) {
- return false;
- }
-
- GeometryMetadata geometry = preset.getGeometry();
- if (mPreviousGeometry != null && geometry.equals(mPreviousGeometry)) {
- return false;
- }
-
- if (DEBUG) {
- Log.v(LOGTAG, "geometry has changed");
- }
-
- RenderScript RS = getRenderScriptContext();
-
- Allocation filtersOnlyOriginalAllocation = mFiltersOnlyOriginalAllocation;
- mFiltersOnlyOriginalAllocation = Allocation.createFromBitmap(RS, originalBitmap,
- Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
- if (filtersOnlyOriginalAllocation != null) {
- filtersOnlyOriginalAllocation.destroy();
- }
-
- Allocation originalAllocation = mOriginalAllocation;
- mResizedOriginalBitmap = preset.applyGeometry(originalBitmap, mEnvironment);
- mOriginalAllocation = Allocation.createFromBitmap(RS, mResizedOriginalBitmap,
- Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
- if (originalAllocation != null) {
- originalAllocation.destroy();
- }
-
- mPreviousGeometry = new GeometryMetadata(geometry);
- return true;
- }
-
- public synchronized void render(RenderingRequest request) {
- synchronized (CachingPipeline.class) {
- if (getRenderScriptContext() == null) {
- return;
- }
- if (((request.getType() != RenderingRequest.PARTIAL_RENDERING
- && request.getType() != RenderingRequest.HIGHRES_RENDERING)
- && request.getBitmap() == null)
- || request.getImagePreset() == null) {
- return;
- }
-
- if (DEBUG) {
- Log.v(LOGTAG, "render image of type " + getType(request));
- }
-
- Bitmap bitmap = request.getBitmap();
- ImagePreset preset = request.getImagePreset();
- setupEnvironment(preset,
- request.getType() != RenderingRequest.HIGHRES_RENDERING);
- mFiltersManager.freeFilterResources(preset);
-
- if (request.getType() == RenderingRequest.PARTIAL_RENDERING) {
- ImageLoader loader = MasterImage.getImage().getImageLoader();
- if (loader == null) {
- Log.w(LOGTAG, "loader not yet setup, cannot handle: " + getType(request));
- return;
- }
- bitmap = loader.getScaleOneImageForPreset(request.getBounds(),
- request.getDestination());
- if (bitmap == null) {
- Log.w(LOGTAG, "could not get bitmap for: " + getType(request));
- return;
- }
- }
-
- if (request.getType() == RenderingRequest.HIGHRES_RENDERING) {
- ImageLoader loader = MasterImage.getImage().getImageLoader();
- bitmap = loader.getOriginalBitmapHighres();
- bitmap = preset.applyGeometry(bitmap, mEnvironment);
- }
-
- if (request.getType() == RenderingRequest.FULL_RENDERING
- || request.getType() == RenderingRequest.GEOMETRY_RENDERING
- || request.getType() == RenderingRequest.FILTERS_RENDERING) {
- updateOriginalAllocation(preset);
- }
-
- if (DEBUG) {
- Log.v(LOGTAG, "after update, req bitmap (" + bitmap.getWidth() + "x" + bitmap.getHeight()
- + " ? resizeOriginal (" + mResizedOriginalBitmap.getWidth() + "x"
- + mResizedOriginalBitmap.getHeight());
- }
-
- if (request.getType() == RenderingRequest.FULL_RENDERING
- || request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
- mOriginalAllocation.copyTo(bitmap);
- } else if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
- mFiltersOnlyOriginalAllocation.copyTo(bitmap);
- }
-
- if (request.getType() == RenderingRequest.FULL_RENDERING
- || request.getType() == RenderingRequest.FILTERS_RENDERING
- || request.getType() == RenderingRequest.ICON_RENDERING
- || request.getType() == RenderingRequest.PARTIAL_RENDERING
- || request.getType() == RenderingRequest.HIGHRES_RENDERING
- || request.getType() == RenderingRequest.STYLE_ICON_RENDERING) {
-
- if (request.getType() == RenderingRequest.ICON_RENDERING) {
- mEnvironment.setQuality(ImagePreset.QUALITY_ICON);
- } else if (request.getType() == RenderingRequest.STYLE_ICON_RENDERING) {
- mEnvironment.setQuality(ImagePreset.STYLE_ICON);
- } else {
- mEnvironment.setQuality(ImagePreset.QUALITY_PREVIEW);
- }
-
- Bitmap bmp = preset.apply(bitmap, mEnvironment);
- if (!mEnvironment.needsStop()) {
- request.setBitmap(bmp);
- }
- mFiltersManager.freeFilterResources(preset);
- }
- }
- }
-
- public synchronized void renderImage(ImagePreset preset, Allocation in, Allocation out) {
- synchronized (CachingPipeline.class) {
- if (getRenderScriptContext() == null) {
- return;
- }
- setupEnvironment(preset, false);
- mFiltersManager.freeFilterResources(preset);
- preset.applyFilters(-1, -1, in, out, mEnvironment);
- // TODO: we should render the border onto a different bitmap instead
- preset.applyBorder(in, out, mEnvironment);
- }
- }
-
- public synchronized Bitmap renderFinalImage(Bitmap bitmap, ImagePreset preset) {
- synchronized (CachingPipeline.class) {
- if (getRenderScriptContext() == null) {
- return bitmap;
- }
- setupEnvironment(preset, false);
- mEnvironment.setQuality(ImagePreset.QUALITY_FINAL);
- mEnvironment.setScaleFactor(1.0f);
- mFiltersManager.freeFilterResources(preset);
- bitmap = preset.applyGeometry(bitmap, mEnvironment);
- bitmap = preset.apply(bitmap, mEnvironment);
- return bitmap;
- }
- }
-
- public Bitmap renderGeometryIcon(Bitmap bitmap, ImagePreset preset) {
- // Called by RenderRequest on the main thread
- // TODO: change this -- we should reuse a pool of bitmaps instead...
- if (mGeometry == null) {
- mGeometry = new ImageFilterGeometry();
- }
- mGeometry.useRepresentation(preset.getGeometry());
- return mGeometry.apply(bitmap, mPreviewScaleFactor,
- ImagePreset.QUALITY_PREVIEW);
- }
-
- public synchronized void compute(TripleBufferBitmap buffer, ImagePreset preset, int type) {
- synchronized (CachingPipeline.class) {
- if (getRenderScriptContext() == null) {
- return;
- }
- if (DEBUG) {
- Log.v(LOGTAG, "compute preset " + preset);
- preset.showFilters();
- }
-
- String thread = Thread.currentThread().getName();
- long time = System.currentTimeMillis();
- setupEnvironment(preset, false);
- mFiltersManager.freeFilterResources(preset);
-
- Bitmap resizedOriginalBitmap = mResizedOriginalBitmap;
- if (updateOriginalAllocation(preset)) {
- resizedOriginalBitmap = mResizedOriginalBitmap;
- mEnvironment.cache(buffer.getProducer());
- buffer.updateProducerBitmap(resizedOriginalBitmap);
- }
- Bitmap bitmap = buffer.getProducer();
- long time2 = System.currentTimeMillis();
-
- if (bitmap == null || (bitmap.getWidth() != resizedOriginalBitmap.getWidth())
- || (bitmap.getHeight() != resizedOriginalBitmap.getHeight())) {
- mEnvironment.cache(buffer.getProducer());
- buffer.updateProducerBitmap(resizedOriginalBitmap);
- bitmap = buffer.getProducer();
- }
- mOriginalAllocation.copyTo(bitmap);
-
- Bitmap tmpbitmap = preset.apply(bitmap, mEnvironment);
- if (tmpbitmap != bitmap) {
- mEnvironment.cache(buffer.getProducer());
- buffer.setProducer(tmpbitmap);
- }
-
- mFiltersManager.freeFilterResources(preset);
-
- time = System.currentTimeMillis() - time;
- time2 = System.currentTimeMillis() - time2;
- if (DEBUG) {
- Log.v(LOGTAG, "Applying type " + type + " filters to bitmap "
- + bitmap + " (" + bitmap.getWidth() + " x " + bitmap.getHeight()
- + ") took " + time + " ms, " + time2 + " ms for the filter, on thread " + thread);
- }
- }
- }
-
- public boolean needsRepaint() {
- TripleBufferBitmap buffer = MasterImage.getImage().getDoubleBuffer();
- return buffer.checkRepaintNeeded();
- }
-
- public void setPreviewScaleFactor(float previewScaleFactor) {
- mPreviewScaleFactor = previewScaleFactor;
- }
-
- public void setHighResPreviewScaleFactor(float highResPreviewScaleFactor) {
- mHighResPreviewScaleFactor = highResPreviewScaleFactor;
- }
-
- public synchronized boolean isInitialized() {
- return getRenderScriptContext() != null && mOriginalBitmap != null;
- }
-
- public boolean prepareRenderscriptAllocations(Bitmap bitmap) {
- RenderScript RS = getRenderScriptContext();
- boolean needsUpdate = false;
- if (mOutPixelsAllocation == null || mInPixelsAllocation == null ||
- bitmap.getWidth() != mWidth || bitmap.getHeight() != mHeight) {
- destroyPixelAllocations();
- Bitmap bitmapBuffer = bitmap;
- if (bitmap.getConfig() == null || bitmap.getConfig() != BITMAP_CONFIG) {
- bitmapBuffer = bitmap.copy(BITMAP_CONFIG, true);
- }
- mOutPixelsAllocation = Allocation.createFromBitmap(RS, bitmapBuffer,
- Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
- mInPixelsAllocation = Allocation.createTyped(RS,
- mOutPixelsAllocation.getType());
- needsUpdate = true;
- }
- if (RS != null) {
- mInPixelsAllocation.copyFrom(bitmap);
- }
- if (bitmap.getWidth() != mWidth
- || bitmap.getHeight() != mHeight) {
- mWidth = bitmap.getWidth();
- mHeight = bitmap.getHeight();
- needsUpdate = true;
- }
- if (DEBUG) {
- Log.v(LOGTAG, "prepareRenderscriptAllocations: " + needsUpdate + " in " + getName());
- }
- return needsUpdate;
- }
-
- public synchronized Allocation getInPixelsAllocation() {
- return mInPixelsAllocation;
- }
-
- public synchronized Allocation getOutPixelsAllocation() {
- return mOutPixelsAllocation;
- }
-
- public String getName() {
- return mName;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
deleted file mode 100644
index a0b2897..0000000
--- a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * 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.cache;
-
-import android.graphics.Bitmap;
-import android.os.*;
-import android.os.Process;
-import android.support.v8.renderscript.*;
-import android.util.Log;
-
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.filters.ImageFilterRS;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-
-public class FilteringPipeline implements Handler.Callback {
-
- private static volatile FilteringPipeline sPipeline = null;
- private static final String LOGTAG = "FilteringPipeline";
- private boolean DEBUG = false;
-
- private static long HIRES_DELAY = 300; // in ms
-
- private volatile boolean mPipelineIsOn = false;
-
- private CachingPipeline mAccessoryPipeline = null;
- private CachingPipeline mPreviewPipeline = null;
- private CachingPipeline mHighresPreviewPipeline = null;
-
- private HandlerThread mHandlerThread = null;
- private final static int NEW_PRESET = 0;
- private final static int NEW_RENDERING_REQUEST = 1;
- private final static int COMPUTE_PRESET = 2;
- private final static int COMPUTE_RENDERING_REQUEST = 3;
- private final static int COMPUTE_PARTIAL_RENDERING_REQUEST = 4;
- private final static int COMPUTE_HIGHRES_RENDERING_REQUEST = 5;
-
- private volatile boolean mHasUnhandledPreviewRequest = false;
-
- private String getType(int value) {
- if (value == COMPUTE_RENDERING_REQUEST) {
- return "COMPUTE_RENDERING_REQUEST";
- }
- if (value == COMPUTE_PARTIAL_RENDERING_REQUEST) {
- return "COMPUTE_PARTIAL_RENDERING_REQUEST";
- }
- if (value == COMPUTE_HIGHRES_RENDERING_REQUEST) {
- return "COMPUTE_HIGHRES_RENDERING_REQUEST";
- }
- return "UNKNOWN TYPE";
- }
-
- private Handler mProcessingHandler = null;
- private final Handler mUIHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case NEW_PRESET: {
- TripleBufferBitmap buffer = MasterImage.getImage().getDoubleBuffer();
- buffer.swapConsumer();
- MasterImage.getImage().notifyObservers();
- if (mHasUnhandledPreviewRequest) {
- updatePreviewBuffer();
- }
- break;
- }
- case NEW_RENDERING_REQUEST: {
- RenderingRequest request = (RenderingRequest) msg.obj;
- request.markAvailable();
- break;
- }
- }
- }
- };
-
- @Override
- public boolean handleMessage(Message msg) {
- if (!mPipelineIsOn) {
- return false;
- }
- switch (msg.what) {
- case COMPUTE_PRESET: {
- ImagePreset preset = (ImagePreset) msg.obj;
- TripleBufferBitmap buffer = MasterImage.getImage().getDoubleBuffer();
- mPreviewPipeline.compute(buffer, preset, COMPUTE_PRESET);
- buffer.swapProducer();
- Message uimsg = mUIHandler.obtainMessage(NEW_PRESET);
- mUIHandler.sendMessage(uimsg);
- break;
- }
- case COMPUTE_RENDERING_REQUEST:
- case COMPUTE_PARTIAL_RENDERING_REQUEST:
- case COMPUTE_HIGHRES_RENDERING_REQUEST: {
-
- if (DEBUG) {
- Log.v(LOGTAG, "Compute Request: " + getType(msg.what));
- }
-
- RenderingRequest request = (RenderingRequest) msg.obj;
- if (msg.what == COMPUTE_HIGHRES_RENDERING_REQUEST) {
- mHighresPreviewPipeline.render(request);
- } else {
- mAccessoryPipeline.render(request);
- }
- if (request.getBitmap() != null) {
- Message uimsg = mUIHandler.obtainMessage(NEW_RENDERING_REQUEST);
- uimsg.obj = request;
- mUIHandler.sendMessage(uimsg);
- }
- break;
- }
- }
- return false;
- }
-
- private FilteringPipeline() {
- mHandlerThread = new HandlerThread("FilteringPipeline",
- Process.THREAD_PRIORITY_FOREGROUND);
- mHandlerThread.start();
- mProcessingHandler = new Handler(mHandlerThread.getLooper(), this);
- mAccessoryPipeline = new CachingPipeline(
- FiltersManager.getManager(), "Accessory");
- mPreviewPipeline = new CachingPipeline(
- FiltersManager.getPreviewManager(), "Preview");
- mHighresPreviewPipeline = new CachingPipeline(
- FiltersManager.getHighresManager(), "Highres");
- }
-
- public synchronized static FilteringPipeline getPipeline() {
- if (sPipeline == null) {
- sPipeline = new FilteringPipeline();
- }
- return sPipeline;
- }
-
- public void setOriginal(Bitmap bitmap) {
- if (mPipelineIsOn) {
- Log.e(LOGTAG, "setOriginal called after pipeline initialization!");
- return;
- }
- mAccessoryPipeline.setOriginal(bitmap);
- mPreviewPipeline.setOriginal(bitmap);
- mHighresPreviewPipeline.setOriginal(bitmap);
- }
-
- public void postRenderingRequest(RenderingRequest request) {
- if (!mPipelineIsOn) {
- return;
- }
- int type = COMPUTE_RENDERING_REQUEST;
- if (request.getType() == RenderingRequest.PARTIAL_RENDERING) {
- type = COMPUTE_PARTIAL_RENDERING_REQUEST;
- }
- if (request.getType() == RenderingRequest.HIGHRES_RENDERING) {
- type = COMPUTE_HIGHRES_RENDERING_REQUEST;
- }
- Message msg = mProcessingHandler.obtainMessage(type);
- msg.obj = request;
- if (type == COMPUTE_PARTIAL_RENDERING_REQUEST
- || type == COMPUTE_HIGHRES_RENDERING_REQUEST) {
- if (mProcessingHandler.hasMessages(msg.what)) {
- mProcessingHandler.removeMessages(msg.what);
- }
- mProcessingHandler.sendMessageDelayed(msg, HIRES_DELAY);
- } else {
- mProcessingHandler.sendMessage(msg);
- }
- }
-
- public void updatePreviewBuffer() {
- if (!mPipelineIsOn) {
- return;
- }
- mHasUnhandledPreviewRequest = true;
- mHighresPreviewPipeline.stop();
- if (mProcessingHandler.hasMessages(COMPUTE_PRESET)) {
- return;
- }
- if (!mPreviewPipeline.needsRepaint()) {
- return;
- }
- if (MasterImage.getImage().getPreset() == null) {
- return;
- }
- Message msg = mProcessingHandler.obtainMessage(COMPUTE_PRESET);
- msg.obj = MasterImage.getImage().getPreset();
- mHasUnhandledPreviewRequest = false;
- mProcessingHandler.sendMessageAtFrontOfQueue(msg);
- }
-
- public void setPreviewScaleFactor(float previewScaleFactor) {
- mAccessoryPipeline.setPreviewScaleFactor(previewScaleFactor);
- mPreviewPipeline.setPreviewScaleFactor(previewScaleFactor);
- mHighresPreviewPipeline.setPreviewScaleFactor(previewScaleFactor);
- }
-
- public void setHighResPreviewScaleFactor(float highResPreviewScaleFactor) {
- mAccessoryPipeline.setHighResPreviewScaleFactor(highResPreviewScaleFactor);
- mPreviewPipeline.setHighResPreviewScaleFactor(highResPreviewScaleFactor);
- mHighresPreviewPipeline.setHighResPreviewScaleFactor(highResPreviewScaleFactor);
- }
-
- public static synchronized void reset() {
- sPipeline.mAccessoryPipeline.reset();
- sPipeline.mPreviewPipeline.reset();
- sPipeline.mHighresPreviewPipeline.reset();
- sPipeline.mHandlerThread.quit();
- sPipeline = null;
- }
-
- public void turnOnPipeline(boolean t) {
- mPipelineIsOn = t;
- if (mPipelineIsOn) {
- assert(mPreviewPipeline.isInitialized());
- assert(mAccessoryPipeline.isInitialized());
- assert(mHighresPreviewPipeline.isInitialized());
- updatePreviewBuffer();
- }
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
index b4e98e1..69edd60 100644
--- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
+++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java
@@ -22,65 +22,37 @@
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap;
-import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.BitmapRegionDecoder;
+import android.graphics.Canvas;
import android.graphics.Matrix;
+import android.graphics.Paint;
import android.graphics.Rect;
-import android.graphics.Bitmap.CompressFormat;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Log;
+import android.webkit.MimeTypeMap;
import com.adobe.xmp.XMPException;
import com.adobe.xmp.XMPMeta;
-import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.exif.ExifTag;
import com.android.gallery3d.exif.ExifInterface;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.HistoryAdapter;
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.imageshow.ImageShow;
+import com.android.gallery3d.exif.ExifTag;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-import com.android.gallery3d.filtershow.tools.BitmapTask;
-import com.android.gallery3d.filtershow.tools.SaveCopyTask;
-import com.android.gallery3d.util.InterruptableOutputStream;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
+import com.android.gallery3d.filtershow.tools.XmpPresets;
import com.android.gallery3d.util.XmpUtilHelper;
-import java.io.ByteArrayInputStream;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Vector;
-import java.util.concurrent.locks.ReentrantLock;
+import java.util.List;
-
-// TODO: this class has waaaay to much bitmap copying. Cleanup.
-public class ImageLoader {
+public final class ImageLoader {
private static final String LOGTAG = "ImageLoader";
- private final Vector<ImageShow> mListeners = new Vector<ImageShow>();
- private Bitmap mOriginalBitmapSmall = null;
- private Bitmap mOriginalBitmapLarge = null;
- private Bitmap mOriginalBitmapHighres = null;
- private Bitmap mBackgroundBitmap = null;
-
- private final ZoomCache mZoomCache = new ZoomCache();
-
- private int mOrientation = 0;
- private HistoryAdapter mAdapter = null;
-
- private FilterShowActivity mActivity = null;
public static final String JPEG_MIME_TYPE = "image/jpeg";
-
- public static final String DEFAULT_SAVE_DIRECTORY = "EditedOnlinePhotos";
public static final int DEFAULT_COMPRESS_QUALITY = 95;
public static final int ORI_NORMAL = ExifInterface.Orientation.TOP_LEFT;
@@ -93,96 +65,51 @@
public static final int ORI_TRANSVERSE = ExifInterface.Orientation.LEFT_BOTTOM;
private static final int BITMAP_LOAD_BACKOUT_ATTEMPTS = 5;
- private Context mContext = null;
- private Uri mUri = null;
+ private static final float OVERDRAW_ZOOM = 1.2f;
+ private ImageLoader() {}
- private Rect mOriginalBounds = null;
- private static int mZoomOrientation = ORI_NORMAL;
-
- static final int MAX_BITMAP_DIM = 900;
-
- private ReentrantLock mLoadingLock = new ReentrantLock();
-
- public ImageLoader(FilterShowActivity activity, Context context) {
- mActivity = activity;
- mContext = context;
- }
-
- public static int getZoomOrientation() {
- return mZoomOrientation;
- }
-
- public FilterShowActivity getActivity() {
- return mActivity;
- }
-
- public boolean loadBitmap(Uri uri, int size) {
- mLoadingLock.lock();
- mUri = uri;
- mOrientation = getOrientation(mContext, uri);
- mOriginalBitmapSmall = loadScaledBitmap(uri, 160);
- if (mOriginalBitmapSmall == null) {
- // Couldn't read the bitmap, let's exit
- mLoadingLock.unlock();
- return false;
+ /**
+ * Returns the Mime type for a Url. Safe to use with Urls that do not
+ * come from Gallery's content provider.
+ */
+ public static String getMimeType(Uri src) {
+ String postfix = MimeTypeMap.getFileExtensionFromUrl(src.toString());
+ String ret = null;
+ if (postfix != null) {
+ ret = MimeTypeMap.getSingleton().getMimeTypeFromExtension(postfix);
}
- mOriginalBitmapLarge = loadScaledBitmap(uri, size);
- if (mOriginalBitmapLarge == null) {
- mLoadingLock.unlock();
- return false;
- }
- if (MasterImage.getImage().supportsHighRes()) {
- int highresPreviewSize = mOriginalBitmapLarge.getWidth() * 2;
- if (highresPreviewSize > mOriginalBounds.width()) {
- highresPreviewSize = mOriginalBounds.width();
- }
- mOriginalBitmapHighres = loadScaledBitmap(uri, highresPreviewSize, false);
- }
- updateBitmaps();
- mLoadingLock.unlock();
- return true;
+ return ret;
}
- public Uri getUri() {
- return mUri;
- }
-
- public Rect getOriginalBounds() {
- return mOriginalBounds;
- }
-
- public static int getOrientation(Context context, Uri uri) {
- if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
- String mimeType = context.getContentResolver().getType(uri);
- if (mimeType != ImageLoader.JPEG_MIME_TYPE) {
- return -1;
- }
- String path = uri.getPath();
- int orientation = -1;
- InputStream is = null;
- ExifInterface exif = new ExifInterface();
- try {
- exif.readExif(path);
- orientation = ExifInterface.getRotationForOrientationValue(
- exif.getTagIntValue(ExifInterface.TAG_ORIENTATION).shortValue());
- } catch (IOException e) {
- Log.w(LOGTAG, "Failed to read EXIF orientation", e);
- }
- return orientation;
+ public static String getLocalPathFromUri(Context context, Uri uri) {
+ Cursor cursor = context.getContentResolver().query(uri,
+ new String[]{MediaStore.Images.Media.DATA}, null, null, null);
+ if (cursor == null) {
+ return null;
}
+ int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+ cursor.moveToFirst();
+ return cursor.getString(index);
+ }
+
+ /**
+ * Returns the image's orientation flag. Defaults to ORI_NORMAL if no valid
+ * orientation was found.
+ */
+ public static int getMetadataOrientation(Context context, Uri uri) {
+ if (uri == null || context == null) {
+ throw new IllegalArgumentException("bad argument to getOrientation");
+ }
+
+ // First try to find orientation data in Gallery's ContentProvider.
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri,
- new String[] {
- MediaStore.Images.ImageColumns.ORIENTATION
- },
+ new String[] { MediaStore.Images.ImageColumns.ORIENTATION },
null, null, null);
- if (cursor.moveToNext()) {
+ if (cursor != null && cursor.moveToNext()) {
int ori = cursor.getInt(0);
-
switch (ori) {
- case 0:
- return ORI_NORMAL;
case 90:
return ORI_ROTATE_90;
case 270:
@@ -190,37 +117,76 @@
case 180:
return ORI_ROTATE_180;
default:
- return -1;
+ return ORI_NORMAL;
}
- } else {
- return -1;
}
} catch (SQLiteException e) {
- return -1;
+ // Do nothing
} catch (IllegalArgumentException e) {
- return -1;
+ // Do nothing
+ } catch (IllegalStateException e) {
+ // Do nothing
} finally {
Utils.closeSilently(cursor);
}
- }
- private void updateBitmaps() {
- if (mOrientation > 1) {
- mOriginalBitmapSmall = rotateToPortrait(mOriginalBitmapSmall, mOrientation);
- mOriginalBitmapLarge = rotateToPortrait(mOriginalBitmapLarge, mOrientation);
- if (mOriginalBitmapHighres != null) {
- mOriginalBitmapHighres = rotateToPortrait(mOriginalBitmapHighres, mOrientation);
+ // Fall back to checking EXIF tags in file.
+ if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
+ String mimeType = getMimeType(uri);
+ if (!JPEG_MIME_TYPE.equals(mimeType)) {
+ return ORI_NORMAL;
+ }
+ String path = uri.getPath();
+ ExifInterface exif = new ExifInterface();
+ try {
+ exif.readExif(path);
+ Integer tagval = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION);
+ if (tagval != null) {
+ int orientation = tagval;
+ switch(orientation) {
+ case ORI_NORMAL:
+ case ORI_ROTATE_90:
+ case ORI_ROTATE_180:
+ case ORI_ROTATE_270:
+ case ORI_FLIP_HOR:
+ case ORI_FLIP_VERT:
+ case ORI_TRANSPOSE:
+ case ORI_TRANSVERSE:
+ return orientation;
+ default:
+ return ORI_NORMAL;
+ }
+ }
+ } catch (IOException e) {
+ Log.w(LOGTAG, "Failed to read EXIF orientation", e);
}
}
- mZoomOrientation = mOrientation;
- warnListeners();
+ return ORI_NORMAL;
}
- public Bitmap decodeImage(int id, BitmapFactory.Options options) {
- return BitmapFactory.decodeResource(mContext.getResources(), id, options);
+ /**
+ * Returns the rotation of image at the given URI as one of 0, 90, 180,
+ * 270. Defaults to 0.
+ */
+ public static int getMetadataRotation(Context context, Uri uri) {
+ int orientation = getMetadataOrientation(context, uri);
+ switch(orientation) {
+ case ORI_ROTATE_90:
+ return 90;
+ case ORI_ROTATE_180:
+ return 180;
+ case ORI_ROTATE_270:
+ return 270;
+ default:
+ return 0;
+ }
}
- public static Bitmap rotateToPortrait(Bitmap bitmap, int ori) {
+ /**
+ * Takes an orientation and a bitmap, and returns the bitmap transformed
+ * to that orientation.
+ */
+ public static Bitmap orientBitmap(Bitmap bitmap, int ori) {
Matrix matrix = new Matrix();
int w = bitmap.getWidth();
int h = bitmap.getHeight();
@@ -260,229 +226,244 @@
default:
return bitmap;
}
-
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, true);
}
- private Bitmap loadRegionBitmap(Uri uri, BitmapFactory.Options options, Rect bounds) {
+ /**
+ * Returns the bitmap for the rectangular region given by "bounds"
+ * if it is a subset of the bitmap stored at uri. Otherwise returns
+ * null.
+ */
+ public static Bitmap loadRegionBitmap(Context context, BitmapCache cache,
+ Uri uri, BitmapFactory.Options options,
+ Rect bounds) {
InputStream is = null;
+ int w = 0;
+ int h = 0;
+ if (options.inSampleSize != 0) {
+ return null;
+ }
try {
- is = mContext.getContentResolver().openInputStream(uri);
+ is = context.getContentResolver().openInputStream(uri);
BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(is, false);
Rect r = new Rect(0, 0, decoder.getWidth(), decoder.getHeight());
+ w = decoder.getWidth();
+ h = decoder.getHeight();
+ Rect imageBounds = new Rect(bounds);
// return null if bounds are not entirely within the bitmap
- if (!r.contains(bounds)) {
- return null;
+ if (!r.contains(imageBounds)) {
+ imageBounds.intersect(r);
+ bounds.left = imageBounds.left;
+ bounds.top = imageBounds.top;
}
- return decoder.decodeRegion(bounds, options);
+ Bitmap reuse = cache.getBitmap(imageBounds.width(),
+ imageBounds.height(), BitmapCache.REGION);
+ options.inBitmap = reuse;
+ Bitmap bitmap = decoder.decodeRegion(imageBounds, options);
+ if (bitmap != reuse) {
+ cache.cache(reuse); // not reused, put back in cache
+ }
+ return bitmap;
} catch (FileNotFoundException e) {
- Log.e(LOGTAG, "FileNotFoundException: " + uri);
- } catch (Exception e) {
- e.printStackTrace();
+ Log.e(LOGTAG, "FileNotFoundException for " + uri, e);
+ } catch (IOException e) {
+ Log.e(LOGTAG, "FileNotFoundException for " + uri, e);
+ } catch (IllegalArgumentException e) {
+ Log.e(LOGTAG, "exc, image decoded " + w + " x " + h + " bounds: "
+ + bounds.left + "," + bounds.top + " - "
+ + bounds.width() + "x" + bounds.height() + " exc: " + e);
} finally {
Utils.closeSilently(is);
}
return null;
}
- private Bitmap loadScaledBitmap(Uri uri, int size) {
- return loadScaledBitmap(uri, size, true);
+ /**
+ * Returns the bounds of the bitmap stored at a given Url.
+ */
+ public static Rect loadBitmapBounds(Context context, Uri uri) {
+ BitmapFactory.Options o = new BitmapFactory.Options();
+ o.inJustDecodeBounds = true;
+ loadBitmap(context, uri, o);
+ return new Rect(0, 0, o.outWidth, o.outHeight);
}
- private Bitmap loadScaledBitmap(Uri uri, int size, boolean enforceSize) {
+ /**
+ * Loads a bitmap that has been downsampled using sampleSize from a given url.
+ */
+ public static Bitmap loadDownsampledBitmap(Context context, Uri uri, int sampleSize) {
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inMutable = true;
+ options.inSampleSize = sampleSize;
+ return loadBitmap(context, uri, options);
+ }
+
+
+ /**
+ * Returns the bitmap from the given uri loaded using the given options.
+ * Returns null on failure.
+ */
+ public static Bitmap loadBitmap(Context context, Uri uri, BitmapFactory.Options o) {
+ if (uri == null || context == null) {
+ throw new IllegalArgumentException("bad argument to loadBitmap");
+ }
InputStream is = null;
try {
- is = mContext.getContentResolver().openInputStream(uri);
- Log.v(LOGTAG, "loading uri " + uri.getPath() + " input stream: "
- + is);
- BitmapFactory.Options o = new BitmapFactory.Options();
- o.inJustDecodeBounds = true;
- BitmapFactory.decodeStream(is, null, o);
-
- int width_tmp = o.outWidth;
- int height_tmp = o.outHeight;
-
- mOriginalBounds = new Rect(0, 0, width_tmp, height_tmp);
-
- int scale = 1;
- while (true) {
- if (width_tmp <= 2 || height_tmp <= 2) {
- break;
- }
- if (!enforceSize
- || (width_tmp <= MAX_BITMAP_DIM
- && height_tmp <= MAX_BITMAP_DIM)) {
- if (width_tmp / 2 < size || height_tmp / 2 < size) {
- break;
- }
- }
- width_tmp /= 2;
- height_tmp /= 2;
- scale *= 2;
- }
-
- // decode with inSampleSize
- BitmapFactory.Options o2 = new BitmapFactory.Options();
- o2.inSampleSize = scale;
- o2.inMutable = true;
-
- Utils.closeSilently(is);
- is = mContext.getContentResolver().openInputStream(uri);
- return BitmapFactory.decodeStream(is, null, o2);
+ is = context.getContentResolver().openInputStream(uri);
+ return BitmapFactory.decodeStream(is, null, o);
} catch (FileNotFoundException e) {
- Log.e(LOGTAG, "FileNotFoundException: " + uri);
- } catch (Exception e) {
- e.printStackTrace();
+ Log.e(LOGTAG, "FileNotFoundException for " + uri, e);
} finally {
Utils.closeSilently(is);
}
return null;
}
- public Bitmap getBackgroundBitmap(Resources resources) {
- if (mBackgroundBitmap == null) {
- mBackgroundBitmap = BitmapFactory.decodeResource(resources,
- R.drawable.filtershow_background);
+ /**
+ * Loads a bitmap at a given URI that is downsampled so that both sides are
+ * smaller than maxSideLength. The Bitmap's original dimensions are stored
+ * in the rect originalBounds.
+ *
+ * @param uri URI of image to open.
+ * @param context context whose ContentResolver to use.
+ * @param maxSideLength max side length of returned bitmap.
+ * @param originalBounds If not null, set to the actual bounds of the stored bitmap.
+ * @param useMin use min or max side of the original image
+ * @return downsampled bitmap or null if this operation failed.
+ */
+ public static Bitmap loadConstrainedBitmap(Uri uri, Context context, int maxSideLength,
+ Rect originalBounds, boolean useMin) {
+ if (maxSideLength <= 0 || uri == null || context == null) {
+ throw new IllegalArgumentException("bad argument to getScaledBitmap");
}
- return mBackgroundBitmap;
-
- }
-
- public Bitmap getOriginalBitmapSmall() {
- return mOriginalBitmapSmall;
- }
-
- public Bitmap getOriginalBitmapLarge() {
- return mOriginalBitmapLarge;
- }
-
- public Bitmap getOriginalBitmapHighres() {
- return mOriginalBitmapHighres;
- }
-
- public void addListener(ImageShow imageShow) {
- mLoadingLock.lock();
- if (!mListeners.contains(imageShow)) {
- mListeners.add(imageShow);
+ // Get width and height of stored bitmap
+ Rect storedBounds = loadBitmapBounds(context, uri);
+ if (originalBounds != null) {
+ originalBounds.set(storedBounds);
}
- mLoadingLock.unlock();
+ int w = storedBounds.width();
+ int h = storedBounds.height();
+
+ // If bitmap cannot be decoded, return null
+ if (w <= 0 || h <= 0) {
+ return null;
+ }
+
+ // Find best downsampling size
+ int imageSide = 0;
+ if (useMin) {
+ imageSide = Math.min(w, h);
+ } else {
+ imageSide = Math.max(w, h);
+ }
+ int sampleSize = 1;
+ while (imageSide > maxSideLength) {
+ imageSide >>>= 1;
+ sampleSize <<= 1;
+ }
+
+ // Make sure sample size is reasonable
+ if (sampleSize <= 0 ||
+ 0 >= (int) (Math.min(w, h) / sampleSize)) {
+ return null;
+ }
+ return loadDownsampledBitmap(context, uri, sampleSize);
}
- private void warnListeners() {
- mActivity.runOnUiThread(mWarnListenersRunnable);
- }
-
- private Runnable mWarnListenersRunnable = new Runnable() {
-
- @Override
- public void run() {
- for (int i = 0; i < mListeners.size(); i++) {
- ImageShow imageShow = mListeners.elementAt(i);
- imageShow.imageLoaded();
+ /**
+ * Loads a bitmap at a given URI that is downsampled so that both sides are
+ * smaller than maxSideLength. The Bitmap's original dimensions are stored
+ * in the rect originalBounds. The output is also transformed to the given
+ * orientation.
+ *
+ * @param uri URI of image to open.
+ * @param context context whose ContentResolver to use.
+ * @param maxSideLength max side length of returned bitmap.
+ * @param orientation the orientation to transform the bitmap to.
+ * @param originalBounds set to the actual bounds of the stored bitmap.
+ * @return downsampled bitmap or null if this operation failed.
+ */
+ public static Bitmap loadOrientedConstrainedBitmap(Uri uri, Context context, int maxSideLength,
+ int orientation, Rect originalBounds) {
+ Bitmap bmap = loadConstrainedBitmap(uri, context, maxSideLength, originalBounds, false);
+ if (bmap != null) {
+ bmap = orientBitmap(bmap, orientation);
+ if (bmap.getConfig()!= Bitmap.Config.ARGB_8888){
+ bmap = bmap.copy( Bitmap.Config.ARGB_8888,true);
}
}
- };
+ return bmap;
+ }
- public Bitmap getScaleOneImageForPreset(Rect bounds, Rect destination) {
- mLoadingLock.lock();
+ public static Bitmap getScaleOneImageForPreset(Context context,
+ BitmapCache cache,
+ Uri uri, Rect bounds,
+ Rect destination) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inMutable = true;
if (destination != null) {
- if (bounds.width() > destination.width()) {
+ int thresholdWidth = (int) (destination.width() * OVERDRAW_ZOOM);
+ if (bounds.width() > thresholdWidth) {
int sampleSize = 1;
int w = bounds.width();
- while (w > destination.width()) {
+ while (w > thresholdWidth) {
sampleSize *= 2;
w /= sampleSize;
}
options.inSampleSize = sampleSize;
}
}
- Bitmap bmp = loadRegionBitmap(mUri, options, bounds);
- mLoadingLock.unlock();
- return bmp;
+ return loadRegionBitmap(context, cache, uri, options, bounds);
}
- public void saveImage(ImagePreset preset, final FilterShowActivity filterShowActivity,
- File destination) {
- new SaveCopyTask(mContext, mUri, destination, new SaveCopyTask.Callback() {
-
- @Override
- public void onComplete(Uri result) {
- filterShowActivity.completeSaveImage(result);
- }
-
- }).execute(preset);
- }
-
- public static Bitmap loadMutableBitmap(Context context, Uri sourceUri) {
- BitmapFactory.Options options = new BitmapFactory.Options();
- return loadMutableBitmap(context, sourceUri, options);
- }
-
- public static Bitmap loadMutableBitmap(Context context, Uri sourceUri,
- BitmapFactory.Options options) {
- // TODO: on <3.x we need a copy of the bitmap (inMutable doesn't
- // exist)
- options.inMutable = true;
-
- Bitmap bitmap = decodeUriWithBackouts(context, sourceUri, options);
- if (bitmap == null) {
- return null;
- }
- int orientation = ImageLoader.getOrientation(context, sourceUri);
- bitmap = ImageLoader.rotateToPortrait(bitmap, orientation);
- return bitmap;
- }
-
- public static Bitmap decodeUriWithBackouts(Context context, Uri sourceUri,
- BitmapFactory.Options options) {
+ /**
+ * Loads a bitmap that is downsampled by at least the input sample size. In
+ * low-memory situations, the bitmap may be downsampled further.
+ */
+ public static Bitmap loadBitmapWithBackouts(Context context, Uri sourceUri, int sampleSize) {
boolean noBitmap = true;
int num_tries = 0;
- InputStream is = getInputStream(context, sourceUri);
-
- if (options.inSampleSize < 1) {
- options.inSampleSize = 1;
+ if (sampleSize <= 0) {
+ sampleSize = 1;
}
- // Stopgap fix for low-memory devices.
Bitmap bmap = null;
while (noBitmap) {
- if (is == null) {
- return null;
- }
try {
// Try to decode, downsample if low-memory.
- bmap = BitmapFactory.decodeStream(is, null, options);
+ bmap = loadDownsampledBitmap(context, sourceUri, sampleSize);
noBitmap = false;
} catch (java.lang.OutOfMemoryError e) {
- // Try 5 times before failing for good.
+ // Try with more downsampling before failing for good.
if (++num_tries >= BITMAP_LOAD_BACKOUT_ATTEMPTS) {
throw e;
}
- is = null;
bmap = null;
System.gc();
- is = getInputStream(context, sourceUri);
- options.inSampleSize *= 2;
+ sampleSize *= 2;
}
}
- Utils.closeSilently(is);
return bmap;
}
- private static InputStream getInputStream(Context context, Uri sourceUri) {
- InputStream is = null;
- try {
- is = context.getContentResolver().openInputStream(sourceUri);
- } catch (FileNotFoundException e) {
- Log.w(LOGTAG, "could not load bitmap ", e);
- Utils.closeSilently(is);
- is = null;
+ /**
+ * Loads an oriented bitmap that is downsampled by at least the input sample
+ * size. In low-memory situations, the bitmap may be downsampled further.
+ */
+ public static Bitmap loadOrientedBitmapWithBackouts(Context context, Uri sourceUri,
+ int sampleSize) {
+ Bitmap bitmap = loadBitmapWithBackouts(context, sourceUri, sampleSize);
+ if (bitmap == null) {
+ return null;
}
- return is;
+ int orientation = getMetadataOrientation(context, sourceUri);
+ bitmap = orientBitmap(bitmap, orientation);
+ return bitmap;
}
+ /**
+ * Loads bitmap from a resource that may be downsampled in low-memory situations.
+ */
public static Bitmap decodeResourceWithBackouts(Resources res, BitmapFactory.Options options,
int id) {
boolean noBitmap = true;
@@ -499,7 +480,7 @@
res, id, options);
noBitmap = false;
} catch (java.lang.OutOfMemoryError e) {
- // Try 5 times before failing for good.
+ // Retry before failing for good.
if (++num_tries >= BITMAP_LOAD_BACKOUT_ATTEMPTS) {
throw e;
}
@@ -511,127 +492,10 @@
return bmap;
}
- public void returnFilteredResult(ImagePreset preset,
- final FilterShowActivity filterShowActivity) {
- BitmapTask.Callbacks<ImagePreset> cb = new BitmapTask.Callbacks<ImagePreset>() {
-
- @Override
- public void onComplete(Bitmap result) {
- filterShowActivity.onFilteredResult(result);
- }
-
- @Override
- public void onCancel() {
- }
-
- @Override
- public Bitmap onExecute(ImagePreset param) {
- if (param == null || mUri == null) {
- return null;
- }
- BitmapFactory.Options options = new BitmapFactory.Options();
- boolean noBitmap = true;
- int num_tries = 0;
- if (options.inSampleSize < 1) {
- options.inSampleSize = 1;
- }
- Bitmap bitmap = null;
- // Stopgap fix for low-memory devices.
- while (noBitmap) {
- try {
- // Try to do bitmap operations, downsample if low-memory
- bitmap = loadMutableBitmap(mContext, mUri, options);
- if (bitmap == null) {
- Log.w(LOGTAG, "Failed to save image!");
- return null;
- }
- CachingPipeline pipeline = new CachingPipeline(
- FiltersManager.getManager(), "Saving");
- bitmap = pipeline.renderFinalImage(bitmap, param);
- noBitmap = false;
- } catch (java.lang.OutOfMemoryError e) {
- // Try 5 times before failing for good.
- if (++num_tries >= 5) {
- throw e;
- }
- bitmap = null;
- System.gc();
- options.inSampleSize *= 2;
- }
- }
- return bitmap;
- }
- };
-
- (new BitmapTask<ImagePreset>(cb)).execute(preset);
- }
-
- private String getFileExtension(String requestFormat) {
- String outputFormat = (requestFormat == null)
- ? "jpg"
- : requestFormat;
- outputFormat = outputFormat.toLowerCase();
- return (outputFormat.equals("png") || outputFormat.equals("gif"))
- ? "png" // We don't support gif compression.
- : "jpg";
- }
-
- private CompressFormat convertExtensionToCompressFormat(String extension) {
- return extension.equals("png") ? CompressFormat.PNG : CompressFormat.JPEG;
- }
-
- public void saveToUri(Bitmap bmap, Uri uri, final String outputFormat,
- final FilterShowActivity filterShowActivity) {
-
- OutputStream out = null;
+ public static XMPMeta getXmpObject(Context context) {
try {
- out = filterShowActivity.getContentResolver().openOutputStream(uri);
- } catch (FileNotFoundException e) {
- Log.w(LOGTAG, "cannot write output", e);
- out = null;
- } finally {
- if (bmap == null || out == null) {
- return;
- }
- }
-
- final InterruptableOutputStream ios = new InterruptableOutputStream(out);
-
- BitmapTask.Callbacks<Bitmap> cb = new BitmapTask.Callbacks<Bitmap>() {
-
- @Override
- public void onComplete(Bitmap result) {
- filterShowActivity.done();
- }
-
- @Override
- public void onCancel() {
- ios.interrupt();
- }
-
- @Override
- public Bitmap onExecute(Bitmap param) {
- CompressFormat cf = convertExtensionToCompressFormat(getFileExtension(outputFormat));
- param.compress(cf, DEFAULT_COMPRESS_QUALITY, ios);
- Utils.closeSilently(ios);
- return null;
- }
- };
-
- (new BitmapTask<Bitmap>(cb)).execute(bmap);
- }
-
- public void setAdapter(HistoryAdapter adapter) {
- mAdapter = adapter;
- }
-
- public HistoryAdapter getHistory() {
- return mAdapter;
- }
-
- public XMPMeta getXmpObject() {
- try {
- InputStream is = mContext.getContentResolver().openInputStream(getUri());
+ InputStream is = context.getContentResolver().openInputStream(
+ MasterImage.getImage().getUri());
return XmpUtilHelper.extractXMPMeta(is);
} catch (FileNotFoundException e) {
return null;
@@ -643,15 +507,14 @@
*
* @return true if it is a light Cycle image that is full 360
*/
- public boolean queryLightCycle360() {
+ public static boolean queryLightCycle360(Context context) {
InputStream is = null;
try {
- is = mContext.getContentResolver().openInputStream(getUri());
+ is = context.getContentResolver().openInputStream(MasterImage.getImage().getUri());
XMPMeta meta = XmpUtilHelper.extractXMPMeta(is);
if (meta == null) {
return false;
}
- String name = meta.getPacketHeader();
String namespace = "http://ns.google.com/photos/1.0/panorama/";
String cropWidthName = "GPano:CroppedAreaImageWidthPixels";
String fullWidthName = "GPano:FullPanoWidthPixels";
@@ -681,4 +544,24 @@
Utils.closeSilently(is);
}
}
+
+ public static List<ExifTag> getExif(Context context, Uri uri) {
+ String path = getLocalPathFromUri(context, uri);
+ if (path != null) {
+ Uri localUri = Uri.parse(path);
+ String mimeType = getMimeType(localUri);
+ if (!JPEG_MIME_TYPE.equals(mimeType)) {
+ return null;
+ }
+ try {
+ ExifInterface exif = new ExifInterface();
+ exif.readExif(path);
+ List<ExifTag> taglist = exif.getAllTags();
+ return taglist;
+ } catch (IOException e) {
+ Log.w(LOGTAG, "Failed to read EXIF tags", e);
+ }
+ }
+ return null;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java b/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java
deleted file mode 100644
index e5bc411..0000000
--- a/src/com/android/gallery3d/filtershow/cache/RenderingRequest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.cache;
-
-import android.graphics.Bitmap;
-import android.graphics.Rect;
-import com.android.gallery3d.app.Log;
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.FilterEnvironment;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-
-public class RenderingRequest {
- private static final String LOGTAG = "RenderingRequest";
- private boolean mIsDirect = false;
- private Bitmap mBitmap = null;
- private ImagePreset mImagePreset = null;
- private ImagePreset mOriginalImagePreset = null;
- private RenderingRequestCaller mCaller = null;
- private float mScaleFactor = 1.0f;
- private Rect mBounds = null;
- private Rect mDestination = null;
- private int mType = FULL_RENDERING;
- public static final int FULL_RENDERING = 0;
- public static final int FILTERS_RENDERING = 1;
- public static final int GEOMETRY_RENDERING = 2;
- public static final int ICON_RENDERING = 3;
- public static final int PARTIAL_RENDERING = 4;
- public static final int HIGHRES_RENDERING = 5;
- public static final int STYLE_ICON_RENDERING = 6;
-
- private static final Bitmap.Config mConfig = Bitmap.Config.ARGB_8888;
-
- public static void post(Bitmap source, ImagePreset preset, int type, RenderingRequestCaller caller) {
- RenderingRequest.post(source, preset, type, caller, null, null);
- }
-
- public static void post(Bitmap source, ImagePreset preset, int type,
- RenderingRequestCaller caller, Rect bounds, Rect destination) {
- if (((type != PARTIAL_RENDERING && type != HIGHRES_RENDERING) && source == null)
- || preset == null || caller == null) {
- Log.v(LOGTAG, "something null: source: " + source
- + " or preset: " + preset + " or caller: " + caller);
- return;
- }
- RenderingRequest request = new RenderingRequest();
- Bitmap bitmap = null;
- if (type == FULL_RENDERING
- || type == GEOMETRY_RENDERING
- || type == ICON_RENDERING
- || type == STYLE_ICON_RENDERING) {
- CachingPipeline pipeline = new CachingPipeline(
- FiltersManager.getManager(), "Icon");
- bitmap = pipeline.renderGeometryIcon(source, preset);
- } else if (type != PARTIAL_RENDERING && type != HIGHRES_RENDERING) {
- bitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(), mConfig);
- }
-
- request.setBitmap(bitmap);
- ImagePreset passedPreset = new ImagePreset(preset);
- passedPreset.setImageLoader(MasterImage.getImage().getImageLoader());
- request.setOriginalImagePreset(preset);
- request.setScaleFactor(MasterImage.getImage().getScaleFactor());
-
- if (type == PARTIAL_RENDERING) {
- request.setBounds(bounds);
- request.setDestination(destination);
- passedPreset.setPartialRendering(true, bounds);
- }
-
- request.setImagePreset(passedPreset);
- request.setType(type);
- request.setCaller(caller);
- request.post();
- }
-
- public void post() {
- FilteringPipeline.getPipeline().postRenderingRequest(this);
- }
-
- public void markAvailable() {
- if (mBitmap == null || mImagePreset == null
- || mCaller == null) {
- return;
- }
- mCaller.available(this);
- }
-
- public boolean isDirect() {
- return mIsDirect;
- }
-
- public void setDirect(boolean isDirect) {
- mIsDirect = isDirect;
- }
-
- public Bitmap getBitmap() {
- return mBitmap;
- }
-
- public void setBitmap(Bitmap bitmap) {
- mBitmap = bitmap;
- }
-
- public ImagePreset getImagePreset() {
- return mImagePreset;
- }
-
- public void setImagePreset(ImagePreset imagePreset) {
- mImagePreset = imagePreset;
- }
-
- public int getType() {
- return mType;
- }
-
- public void setType(int type) {
- mType = type;
- }
-
- public void setCaller(RenderingRequestCaller caller) {
- mCaller = caller;
- }
-
- public Rect getBounds() {
- return mBounds;
- }
-
- public void setBounds(Rect bounds) {
- mBounds = bounds;
- }
-
- public void setScaleFactor(float scaleFactor) {
- mScaleFactor = scaleFactor;
- }
-
- public float getScaleFactor() {
- return mScaleFactor;
- }
-
- public Rect getDestination() {
- return mDestination;
- }
-
- public void setDestination(Rect destination) {
- mDestination = destination;
- }
-
- public ImagePreset getOriginalImagePreset() {
- return mOriginalImagePreset;
- }
-
- public void setOriginalImagePreset(ImagePreset originalImagePreset) {
- mOriginalImagePreset = originalImagePreset;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/cache/RenderingRequestCaller.java b/src/com/android/gallery3d/filtershow/cache/RenderingRequestCaller.java
deleted file mode 100644
index 240eb8f..0000000
--- a/src/com/android/gallery3d/filtershow/cache/RenderingRequestCaller.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.cache;
-
-public interface RenderingRequestCaller {
- public void available(RenderingRequest request);
-}
diff --git a/src/com/android/gallery3d/filtershow/cache/TripleBufferBitmap.java b/src/com/android/gallery3d/filtershow/cache/TripleBufferBitmap.java
deleted file mode 100644
index ba7b769..0000000
--- a/src/com/android/gallery3d/filtershow/cache/TripleBufferBitmap.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.cache;
-
-import android.graphics.Bitmap;
-
-public class TripleBufferBitmap {
-
- private static String LOGTAG = "TripleBufferBitmap";
-
- private volatile Bitmap mBitmaps[] = new Bitmap[3];
- private volatile Bitmap mProducer = null;
- private volatile Bitmap mConsumer = null;
- private volatile Bitmap mIntermediate = null;
- private volatile boolean mNeedsSwap = false;
-
- private final Bitmap.Config mBitmapConfig = Bitmap.Config.ARGB_8888;
- private volatile boolean mNeedsRepaint = true;
-
- public TripleBufferBitmap() {
-
- }
-
- public synchronized void updateBitmaps(Bitmap bitmap) {
- mBitmaps[0] = bitmap.copy(mBitmapConfig, true);
- mBitmaps[1] = bitmap.copy(mBitmapConfig, true);
- mBitmaps[2] = bitmap.copy(mBitmapConfig, true);
- mProducer = mBitmaps[0];
- mConsumer = mBitmaps[1];
- mIntermediate = mBitmaps[2];
- }
-
- public synchronized void updateProducerBitmap(Bitmap bitmap) {
- mProducer = bitmap.copy(mBitmapConfig, true);
- }
-
- public synchronized void setProducer(Bitmap producer) {
- mProducer = producer;
- }
-
- public synchronized Bitmap getProducer() {
- return mProducer;
- }
-
- public synchronized Bitmap getConsumer() {
- return mConsumer;
- }
-
- public synchronized void swapProducer() {
- Bitmap intermediate = mIntermediate;
- mIntermediate = mProducer;
- mProducer = intermediate;
- mNeedsSwap = true;
- }
-
- public synchronized void swapConsumer() {
- if (!mNeedsSwap) {
- return;
- }
- Bitmap intermediate = mIntermediate;
- mIntermediate = mConsumer;
- mConsumer = intermediate;
- mNeedsSwap = false;
- }
-
- public synchronized void invalidate() {
- mNeedsRepaint = true;
- }
-
- public synchronized boolean checkRepaintNeeded() {
- if (mNeedsRepaint) {
- mNeedsRepaint = false;
- return true;
- }
- return false;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/cache/ZoomCache.java b/src/com/android/gallery3d/filtershow/cache/ZoomCache.java
deleted file mode 100644
index dbd0751..0000000
--- a/src/com/android/gallery3d/filtershow/cache/ZoomCache.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.cache;
-
-import android.graphics.Bitmap;
-import android.graphics.Rect;
-
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-
-public class ZoomCache {
-
- private ImagePreset mImagePreset = null;
- private Bitmap mBitmap = null;
- private Rect mBounds = null;
-
- // TODO: move the processing to a background thread...
- public Bitmap getImage(ImagePreset preset, Rect bounds) {
- if (mBounds != bounds) {
- return null;
- }
- if (mImagePreset == null) {
- return null;
- }
- if (!mImagePreset.same(preset)) {
- return null;
- }
- return mBitmap;
- }
-
- public void setImage(ImagePreset preset, Rect bounds, Bitmap bitmap) {
- mBitmap = bitmap;
- mBounds = bounds;
- mImagePreset = preset;
- }
-
- public void reset(ImagePreset imagePreset) {
- if (imagePreset == mImagePreset) {
- mBitmap = null;
- }
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/category/Action.java b/src/com/android/gallery3d/filtershow/category/Action.java
index 4f2c128..b3a4148 100644
--- a/src/com/android/gallery3d/filtershow/category/Action.java
+++ b/src/com/android/gallery3d/filtershow/category/Action.java
@@ -24,11 +24,19 @@
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
-import com.android.gallery3d.filtershow.cache.RenderingRequest;
-import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
+import android.util.Log;
+import android.widget.ArrayAdapter;
+import android.widget.ListAdapter;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequest;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
public class Action implements RenderingRequestCaller {
@@ -37,24 +45,58 @@
private String mName;
private Rect mImageFrame;
private Bitmap mImage;
- private CategoryAdapter mAdapter;
+ private ArrayAdapter mAdapter;
public static final int FULL_VIEW = 0;
public static final int CROP_VIEW = 1;
+ public static final int ADD_ACTION = 2;
+ public static final int SPACER = 3;
private int mType = CROP_VIEW;
private Bitmap mPortraitImage;
private Bitmap mOverlayBitmap;
- private Context mContext;
+ private FilterShowActivity mContext;
+ private boolean mCanBeRemoved = false;
+ private int mTextSize = 32;
+ private boolean mIsDoubleAction = false;
- public Action(Context context, FilterRepresentation representation, int type) {
- mContext = context;
- setRepresentation(representation);
- setType(type);
+ public Action(FilterShowActivity context, FilterRepresentation representation, int type,
+ boolean canBeRemoved) {
+ this(context, representation, type);
+ mCanBeRemoved = canBeRemoved;
+ mTextSize = context.getResources().getDimensionPixelSize(
+ R.dimen.category_panel_text_size);
}
- public Action(Context context, FilterRepresentation representation) {
+ public Action(FilterShowActivity context, FilterRepresentation representation, int type) {
+ this(context, type);
+ setRepresentation(representation);
+ }
+
+ public Action(FilterShowActivity context, int type) {
+ mContext = context;
+ setType(type);
+ mContext.registerAction(this);
+ }
+
+ public Action(FilterShowActivity context, FilterRepresentation representation) {
this(context, representation, CROP_VIEW);
}
+ public boolean isDoubleAction() {
+ return mIsDoubleAction;
+ }
+
+ public void setIsDoubleAction(boolean value) {
+ mIsDoubleAction = value;
+ }
+
+ public boolean canBeRemoved() {
+ return mCanBeRemoved;
+ }
+
+ public int getType() {
+ return mType;
+ }
+
public FilterRepresentation getRepresentation() {
return mRepresentation;
}
@@ -72,22 +114,23 @@
mName = name;
}
- public void setImageFrame(Rect imageFrame) {
+ public void setImageFrame(Rect imageFrame, int orientation) {
if (mImageFrame != null && mImageFrame.equals(imageFrame)) {
return;
}
- Bitmap bitmap = MasterImage.getImage().getLargeThumbnailBitmap();
+ if (getType() == Action.ADD_ACTION) {
+ return;
+ }
+ Bitmap temp = MasterImage.getImage().getTemporaryThumbnailBitmap();
+ if (temp != null) {
+ mImage = temp;
+ }
+ Bitmap bitmap = MasterImage.getImage().getThumbnailBitmap();
if (bitmap != null) {
mImageFrame = imageFrame;
int w = mImageFrame.width();
int h = mImageFrame.height();
- if (mType == CROP_VIEW) {
- w /= 2;
- }
- Bitmap bitmapCrop = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- drawCenteredImage(bitmap, bitmapCrop, true);
-
- postNewIconRenderRequest(bitmapCrop);
+ postNewIconRenderRequest(w, h);
}
}
@@ -99,7 +142,7 @@
mImage = image;
}
- public void setAdapter(CategoryAdapter adapter) {
+ public void setAdapter(ArrayAdapter adapter) {
mAdapter = adapter;
}
@@ -107,40 +150,37 @@
mType = type;
}
- private void postNewIconRenderRequest(Bitmap bitmap) {
- if (bitmap != null && mRepresentation != null) {
+ private void postNewIconRenderRequest(int w, int h) {
+ if (mRepresentation != null) {
ImagePreset preset = new ImagePreset();
preset.addFilter(mRepresentation);
- RenderingRequest.post(bitmap,
- preset, RenderingRequest.ICON_RENDERING, this);
+ RenderingRequest.postIconRequest(mContext, w, h, preset, this);
}
}
private void drawCenteredImage(Bitmap source, Bitmap destination, boolean scale) {
- RectF image = new RectF(0, 0, source.getWidth(), source.getHeight());
- int border = 0;
- if (!scale) {
- border = destination.getWidth() - destination.getHeight();
- if (border < 0) {
- border = 0;
- }
- }
- RectF frame = new RectF(border, 0,
- destination.getWidth() - border,
- destination.getHeight());
+ int minSide = Math.min(destination.getWidth(), destination.getHeight());
Matrix m = new Matrix();
- m.setRectToRect(frame, image, Matrix.ScaleToFit.CENTER);
- image.set(frame);
- m.mapRect(image);
- m.setRectToRect(image, frame, Matrix.ScaleToFit.FILL);
+ float scaleFactor = minSide / (float) Math.min(source.getWidth(), source.getHeight());
+
+ float dx = (destination.getWidth() - source.getWidth() * scaleFactor) / 2.0f;
+ float dy = (destination.getHeight() - source.getHeight() * scaleFactor) / 2.0f;
+ if (mImageFrame.height() > mImageFrame.width()) {
+ // if portrait
+ dy -= mTextSize;
+ }
+ m.setScale(scaleFactor, scaleFactor);
+ m.postTranslate(dx, dy);
Canvas canvas = new Canvas(destination);
- canvas.drawBitmap(source, m, new Paint());
+ canvas.drawBitmap(source, m, new Paint(Paint.FILTER_BITMAP_FLAG));
}
@Override
public void available(RenderingRequest request) {
+ clearBitmap();
mImage = request.getBitmap();
if (mImage == null) {
+ mImageFrame = null;
return;
}
if (mRepresentation.getOverlayId() != 0 && mOverlayBitmap == null) {
@@ -149,7 +189,7 @@
mRepresentation.getOverlayId());
}
if (mOverlayBitmap != null) {
- if (getRepresentation().getPriority() == FilterRepresentation.TYPE_BORDER) {
+ if (getRepresentation().getFilterType() == FilterRepresentation.TYPE_BORDER) {
Canvas canvas = new Canvas(mImage);
canvas.drawBitmap(mOverlayBitmap, new Rect(0, 0, mOverlayBitmap.getWidth(), mOverlayBitmap.getHeight()),
new Rect(0, 0, mImage.getWidth(), mImage.getHeight()), new Paint());
@@ -179,4 +219,12 @@
public void setOverlayBitmap(Bitmap overlayBitmap) {
mOverlayBitmap = overlayBitmap;
}
+
+ public void clearBitmap() {
+ if (mImage != null
+ && mImage != MasterImage.getImage().getTemporaryThumbnailBitmap()) {
+ MasterImage.getImage().getBitmapCache().cache(mImage);
+ }
+ mImage = null;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
index cfa64bc..09f02dd 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
@@ -17,19 +17,16 @@
package com.android.gallery3d.filtershow.category;
import android.content.Context;
-import android.util.Log;
-import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.filters.ImageFilterTinyPlanet;
-import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-import com.android.gallery3d.filtershow.ui.FilterIconButton;
+import com.android.gallery3d.filtershow.filters.FilterTinyPlanetRepresentation;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
public class CategoryAdapter extends ArrayAdapter<Action> {
@@ -37,9 +34,11 @@
private int mItemHeight;
private View mContainer;
private int mItemWidth = ListView.LayoutParams.MATCH_PARENT;
- private boolean mUseFilterIconButton = false;
private int mSelectedPosition;
int mCategory;
+ private int mOrientation;
+ private boolean mShowAddButton = false;
+ private String mAddButtonText;
public CategoryAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
@@ -50,6 +49,15 @@
this(context, 0);
}
+ @Override
+ public void clear() {
+ for (int i = 0; i < getCount(); i++) {
+ Action action = getItem(i);
+ action.clearBitmap();
+ }
+ super.clear();
+ }
+
public void setItemHeight(int height) {
mItemHeight = height;
}
@@ -66,48 +74,45 @@
public void initializeSelection(int category) {
mCategory = category;
- if (category == MainPanel.LOOKS || category == MainPanel.BORDERS) {
- ImagePreset preset = MasterImage.getImage().getPreset();
- if (preset != null) {
- for (int i = 0; i < getCount(); i++) {
- if (preset.historyName().equals(getItem(i).getRepresentation().getName())) {
- mSelectedPosition = i;
- }
- }
- }
- } else {
- mSelectedPosition = -1;
+ mSelectedPosition = -1;
+ if (category == MainPanel.LOOKS) {
+ mSelectedPosition = 0;
+ mAddButtonText = getContext().getString(R.string.filtershow_add_button_looks);
+ }
+ if (category == MainPanel.BORDERS) {
+ mSelectedPosition = 0;
+ }
+ if (category == MainPanel.VERSIONS) {
+ mAddButtonText = getContext().getString(R.string.filtershow_add_button_versions);
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- if (mUseFilterIconButton) {
- if (convertView == null) {
- LayoutInflater inflater =
- (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- convertView = inflater.inflate(R.layout.filtericonbutton, parent, false);
- }
- FilterIconButton view = (FilterIconButton) convertView;
- Action action = getItem(position);
- view.setAction(action);
- view.setup(action.getName(), null, this);
- view.setLayoutParams(
- new ListView.LayoutParams(mItemWidth, mItemHeight));
- view.setTag(position);
- if (mCategory == MainPanel.LOOKS || mCategory == MainPanel.BORDERS) {
- view.setBackgroundResource(0);
- }
- return view;
- }
if (convertView == null) {
convertView = new CategoryView(getContext());
}
CategoryView view = (CategoryView) convertView;
- view.setAction(getItem(position), this);
+ view.setOrientation(mOrientation);
+ Action action = getItem(position);
+ view.setAction(action, this);
+ int width = mItemWidth;
+ int height = mItemHeight;
+ if (action.getType() == Action.SPACER) {
+ if (mOrientation == CategoryView.HORIZONTAL) {
+ width = width / 2;
+ } else {
+ height = height / 2;
+ }
+ }
+ if (action.getType() == Action.ADD_ACTION
+ && mOrientation == CategoryView.VERTICAL) {
+ height = height / 2;
+ }
view.setLayoutParams(
- new ListView.LayoutParams(mItemWidth, mItemHeight));
+ new ListView.LayoutParams(width, height));
view.setTag(position);
+ view.invalidate();
return view;
}
@@ -146,20 +151,12 @@
notifyDataSetChanged();
}
- public void setUseFilterIconButton(boolean useFilterIconButton) {
- mUseFilterIconButton = useFilterIconButton;
- }
-
- public boolean isUseFilterIconButton() {
- return mUseFilterIconButton;
- }
-
public FilterRepresentation getTinyPlanet() {
for (int i = 0; i < getCount(); i++) {
Action action = getItem(i);
if (action.getRepresentation() != null
- && action.getRepresentation().getFilterClass()
- == ImageFilterTinyPlanet.class) {
+ && action.getRepresentation()
+ instanceof FilterTinyPlanetRepresentation) {
return action.getRepresentation();
}
}
@@ -170,11 +167,78 @@
for (int i = 0; i < getCount(); i++) {
Action action = getItem(i);
if (action.getRepresentation() != null
- && action.getRepresentation().getFilterClass()
- == ImageFilterTinyPlanet.class) {
- remove(action);
+ && action.getRepresentation()
+ instanceof FilterTinyPlanetRepresentation) {
+ super.remove(action);
return;
}
}
}
+
+ @Override
+ public void remove(Action action) {
+ if (!(mCategory == MainPanel.VERSIONS
+ || mCategory == MainPanel.LOOKS)) {
+ return;
+ }
+ super.remove(action);
+ FilterShowActivity activity = (FilterShowActivity) getContext();
+ if (mCategory == MainPanel.LOOKS) {
+ activity.removeLook(action);
+ } else if (mCategory == MainPanel.VERSIONS) {
+ activity.removeVersion(action);
+ }
+ }
+
+ public void setOrientation(int orientation) {
+ mOrientation = orientation;
+ }
+
+ public void reflectImagePreset(ImagePreset preset) {
+ if (preset == null) {
+ return;
+ }
+ int selected = 0; // if nothing found, select "none" (first element)
+ FilterRepresentation rep = null;
+ if (mCategory == MainPanel.LOOKS) {
+ int pos = preset.getPositionForType(FilterRepresentation.TYPE_FX);
+ if (pos != -1) {
+ rep = preset.getFilterRepresentation(pos);
+ }
+ } else if (mCategory == MainPanel.BORDERS) {
+ int pos = preset.getPositionForType(FilterRepresentation.TYPE_BORDER);
+ if (pos != -1) {
+ rep = preset.getFilterRepresentation(pos);
+ }
+ }
+ if (rep != null) {
+ for (int i = 0; i < getCount(); i++) {
+ FilterRepresentation itemRep = getItem(i).getRepresentation();
+ if (itemRep == null) {
+ continue;
+ }
+ if (rep.getName().equalsIgnoreCase(
+ itemRep.getName())) {
+ selected = i;
+ break;
+ }
+ }
+ }
+ if (mSelectedPosition != selected) {
+ mSelectedPosition = selected;
+ this.notifyDataSetChanged();
+ }
+ }
+
+ public boolean showAddButton() {
+ return mShowAddButton;
+ }
+
+ public void setShowAddButton(boolean showAddButton) {
+ mShowAddButton = showAddButton;
+ }
+
+ public String getAddButtonText() {
+ return mAddButtonText;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
index abae80f..fb51bf5 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
@@ -17,23 +17,27 @@
package com.android.gallery3d.filtershow.category;
import android.app.Activity;
+import android.graphics.Rect;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
+import android.widget.TextView;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
-public class CategoryPanel extends Fragment {
+public class CategoryPanel extends Fragment implements View.OnClickListener {
public static final String FRAGMENT_TAG = "CategoryPanel";
private static final String PARAMETER_TAG = "currentPanel";
private int mCurrentAdapter = MainPanel.LOOKS;
private CategoryAdapter mAdapter;
+ private IconView mAddButton;
public void setAdapter(int value) {
mCurrentAdapter = value;
@@ -45,30 +49,48 @@
loadAdapter(mCurrentAdapter);
}
- private void loadAdapter(int adapter) {
+ public void loadAdapter(int adapter) {
FilterShowActivity activity = (FilterShowActivity) getActivity();
switch (adapter) {
case MainPanel.LOOKS: {
mAdapter = activity.getCategoryLooksAdapter();
- mAdapter.initializeSelection(MainPanel.LOOKS);
+ if (mAdapter != null) {
+ mAdapter.initializeSelection(MainPanel.LOOKS);
+ }
+ activity.updateCategories();
break;
}
case MainPanel.BORDERS: {
mAdapter = activity.getCategoryBordersAdapter();
- mAdapter.initializeSelection(MainPanel.BORDERS);
+ if (mAdapter != null) {
+ mAdapter.initializeSelection(MainPanel.BORDERS);
+ }
+ activity.updateCategories();
break;
}
case MainPanel.GEOMETRY: {
mAdapter = activity.getCategoryGeometryAdapter();
- mAdapter.initializeSelection(MainPanel.GEOMETRY);
+ if (mAdapter != null) {
+ mAdapter.initializeSelection(MainPanel.GEOMETRY);
+ }
break;
}
case MainPanel.FILTERS: {
mAdapter = activity.getCategoryFiltersAdapter();
- mAdapter.initializeSelection(MainPanel.FILTERS);
+ if (mAdapter != null) {
+ mAdapter.initializeSelection(MainPanel.FILTERS);
+ }
+ break;
+ }
+ case MainPanel.VERSIONS: {
+ mAdapter = activity.getCategoryVersionsAdapter();
+ if (mAdapter != null) {
+ mAdapter.initializeSelection(MainPanel.VERSIONS);
+ }
break;
}
}
+ updateAddButtonVisibility();
}
@Override
@@ -92,15 +114,47 @@
View panelView = main.findViewById(R.id.listItems);
if (panelView instanceof CategoryTrack) {
CategoryTrack panel = (CategoryTrack) panelView;
- mAdapter.setUseFilterIconButton(true);
- panel.setAdapter(mAdapter);
- mAdapter.setContainer(panel);
- } else {
+ if (mAdapter != null) {
+ mAdapter.setOrientation(CategoryView.HORIZONTAL);
+ panel.setAdapter(mAdapter);
+ mAdapter.setContainer(panel);
+ }
+ } else if (mAdapter != null) {
ListView panel = (ListView) main.findViewById(R.id.listItems);
panel.setAdapter(mAdapter);
mAdapter.setContainer(panel);
}
+
+ mAddButton = (IconView) main.findViewById(R.id.addButton);
+ if (mAddButton != null) {
+ mAddButton.setOnClickListener(this);
+ updateAddButtonVisibility();
+ }
return main;
}
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.addButton:
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ activity.addCurrentVersion();
+ break;
+ }
+ }
+
+ public void updateAddButtonVisibility() {
+ if (mAddButton == null) {
+ return;
+ }
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ if (activity.isShowingImageStatePanel() && mAdapter.showAddButton()) {
+ mAddButton.setVisibility(View.VISIBLE);
+ if (mAdapter != null) {
+ mAddButton.setText(mAdapter.getAddButtonText());
+ }
+ } else {
+ mAddButton.setVisibility(View.GONE);
+ }
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategorySelected.java b/src/com/android/gallery3d/filtershow/category/CategorySelected.java
new file mode 100644
index 0000000..42058c0
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/category/CategorySelected.java
@@ -0,0 +1,31 @@
+package com.android.gallery3d.filtershow.category;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.view.View;
+
+import com.android.gallery3d.R;
+
+public class CategorySelected extends View {
+ private Paint mPaint = new Paint();
+ private int mMargin = 20;
+
+ public CategorySelected(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mMargin = getResources().getDimensionPixelSize(R.dimen.touch_circle_size);
+ }
+
+ public void onDraw(Canvas canvas) {
+ mPaint.reset();
+ mPaint.setStrokeWidth(mMargin);
+ mPaint.setAntiAlias(true);
+ mPaint.setStyle(Paint.Style.STROKE);
+ mPaint.setColor(Color.argb(128, 128, 128, 128));
+ canvas.drawCircle(getWidth()/2, getHeight()/2,
+ getWidth()/2 - mMargin, mPaint);
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryTrack.java b/src/com/android/gallery3d/filtershow/category/CategoryTrack.java
index e0a8a2f..1371fe8 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryTrack.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryTrack.java
@@ -18,7 +18,11 @@
import android.content.Context;
import android.content.res.TypedArray;
+import android.database.DataSetObserver;
+import android.graphics.Rect;
import android.util.AttributeSet;
+import android.util.Log;
+import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import com.android.gallery3d.R;
@@ -27,6 +31,24 @@
private CategoryAdapter mAdapter;
private int mElemSize;
+ private View mSelectedView;
+ private float mStartTouchY;
+ private DataSetObserver mDataSetObserver = new DataSetObserver() {
+ @Override
+ public void onChanged() {
+ super.onChanged();
+ if (getChildCount() != mAdapter.getCount()) {
+ fillContent();
+ } else {
+ invalidate();
+ }
+ }
+ @Override
+ public void onInvalidated() {
+ super.onInvalidated();
+ fillContent();
+ }
+ };
public CategoryTrack(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -36,13 +58,14 @@
public void setAdapter(CategoryAdapter adapter) {
mAdapter = adapter;
- mAdapter.setItemWidth(mElemSize);
- mAdapter.setItemHeight(LayoutParams.MATCH_PARENT);
+ mAdapter.registerDataSetObserver(mDataSetObserver);
fillContent();
}
public void fillContent() {
removeAllViews();
+ mAdapter.setItemWidth(mElemSize);
+ mAdapter.setItemHeight(LayoutParams.MATCH_PARENT);
int n = mAdapter.getCount();
for (int i = 0; i < n; i++) {
View view = mAdapter.getView(i, null, this);
@@ -51,4 +74,12 @@
requestLayout();
}
+ @Override
+ public void invalidate() {
+ for (int i = 0; i < this.getChildCount(); i++) {
+ View child = getChildAt(i);
+ child.invalidate();
+ }
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryView.java b/src/com/android/gallery3d/filtershow/category/CategoryView.java
index 059eb10..1570517 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryView.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryView.java
@@ -19,114 +19,183 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
-import android.graphics.Typeface;
-import android.util.Log;
+import android.view.MotionEvent;
import android.view.View;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.ui.SelectionRenderer;
-public class CategoryView extends View implements View.OnClickListener {
+public class CategoryView extends IconView
+ implements View.OnClickListener, SwipableView{
private static final String LOGTAG = "CategoryView";
+ public static final int VERTICAL = 0;
+ public static final int HORIZONTAL = 1;
private Paint mPaint = new Paint();
private Action mAction;
- private Rect mTextBounds = new Rect();
- private static int sMargin = 16;
- private static int sTextSize = 32;
- private int mTextColor;
- private int mBackgroundColor;
private Paint mSelectPaint;
CategoryAdapter mAdapter;
private int mSelectionStroke;
private Paint mBorderPaint;
private int mBorderStroke;
-
- public static void setTextSize(int size) {
- sTextSize = size;
- }
-
- public static void setMargin(int margin) {
- sMargin = margin;
- }
+ private float mStartTouchX = 0;
+ private float mStartTouchY = 0;
+ private float mDeleteSlope = 20;
+ private int mSelectionColor = Color.WHITE;
+ private int mSpacerColor = Color.WHITE;
+ private boolean mCanBeRemoved = false;
+ private long mDoubleActionLast = 0;
+ private long mDoubleTapDelay = 250;
public CategoryView(Context context) {
super(context);
setOnClickListener(this);
Resources res = getResources();
- mBackgroundColor = res.getColor(R.color.filtershow_categoryview_background);
- mTextColor = res.getColor(R.color.filtershow_categoryview_text);
mSelectionStroke = res.getDimensionPixelSize(R.dimen.thumbnail_margin);
mSelectPaint = new Paint();
mSelectPaint.setStyle(Paint.Style.FILL);
- mSelectPaint.setColor(res.getColor(R.color.filtershow_category_selection));
+ mSelectionColor = res.getColor(R.color.filtershow_category_selection);
+ mSpacerColor = res.getColor(R.color.filtershow_categoryview_text);
+
+ mSelectPaint.setColor(mSelectionColor);
mBorderPaint = new Paint(mSelectPaint);
mBorderPaint.setColor(Color.BLACK);
mBorderStroke = mSelectionStroke / 3;
}
- public void drawText(Canvas canvas, String text) {
- if (text == null) {
- return;
+ @Override
+ public boolean isHalfImage() {
+ if (mAction == null) {
+ return false;
}
- text = text.toUpperCase();
- mPaint.setTextSize(sTextSize);
- mPaint.setTypeface(Typeface.DEFAULT_BOLD);
- float textWidth = mPaint.measureText(text);
- mPaint.getTextBounds(text, 0, text.length(), mTextBounds);
- int x = (int) (canvas.getWidth() - textWidth - sMargin);
- int y = canvas.getHeight() - sMargin;
- canvas.drawText(text, x, y, mPaint);
+ if (mAction.getType() == Action.CROP_VIEW) {
+ return true;
+ }
+ if (mAction.getType() == Action.ADD_ACTION) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean canBeRemoved() {
+ return mCanBeRemoved;
+ }
+
+ private void drawSpacer(Canvas canvas) {
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setColor(mSpacerColor);
+ if (getOrientation() == CategoryView.VERTICAL) {
+ canvas.drawCircle(getWidth() / 2, getHeight() / 2, getHeight() / 5, mPaint);
+ } else {
+ canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 5, mPaint);
+ }
}
@Override
+ public boolean needsCenterText() {
+ if (mAction != null && mAction.getType() == Action.ADD_ACTION) {
+ return true;
+ }
+ return super.needsCenterText();
+ }
+
public void onDraw(Canvas canvas) {
- canvas.drawColor(mBackgroundColor);
if (mAction != null) {
- mPaint.reset();
- mPaint.setAntiAlias(true);
- if (mAction.getImage() == null) {
- mAction.setImageFrame(new Rect(0, 0, canvas.getWidth(), canvas.getHeight()));
- } else {
- Bitmap bitmap = mAction.getImage();
- canvas.drawBitmap(bitmap, 0, 0, mPaint);
- if (mAdapter.isSelected(this)) {
- SelectionRenderer.drawSelection(canvas, 0, 0,
- Math.min(bitmap.getWidth(), getWidth()),
- Math.min(bitmap.getHeight(), getHeight()),
- mSelectionStroke, mSelectPaint, mBorderStroke, mBorderPaint);
- }
+ if (mAction.getType() == Action.SPACER) {
+ drawSpacer(canvas);
+ return;
}
- mPaint.setColor(mBackgroundColor);
- mPaint.setStyle(Paint.Style.STROKE);
- mPaint.setStrokeWidth(3);
- drawText(canvas, mAction.getName());
- mPaint.setColor(mTextColor);
- mPaint.setStyle(Paint.Style.FILL);
- mPaint.setStrokeWidth(1);
- drawText(canvas, mAction.getName());
+ if (mAction.isDoubleAction()) {
+ return;
+ }
+ mAction.setImageFrame(new Rect(0, 0, getWidth(), getHeight()), getOrientation());
+ if (mAction.getImage() != null) {
+ setBitmap(mAction.getImage());
+ }
+ }
+ super.onDraw(canvas);
+ if (mAdapter.isSelected(this)) {
+ SelectionRenderer.drawSelection(canvas, 0, 0,
+ getWidth(), getHeight(),
+ mSelectionStroke, mSelectPaint, mBorderStroke, mBorderPaint);
}
}
public void setAction(Action action, CategoryAdapter adapter) {
mAction = action;
+ setText(mAction.getName());
mAdapter = adapter;
+ mCanBeRemoved = action.canBeRemoved();
+ setUseOnlyDrawable(false);
+ if (mAction.getType() == Action.ADD_ACTION) {
+ Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.filtershow_add);
+ setBitmap(bitmap);
+ setUseOnlyDrawable(true);
+ setText(getResources().getString(R.string.filtershow_add_button_looks));
+ } else {
+ setBitmap(mAction.getImage());
+ }
invalidate();
}
- public FilterRepresentation getRepresentation() {
- return mAction.getRepresentation();
- }
-
@Override
public void onClick(View view) {
FilterShowActivity activity = (FilterShowActivity) getContext();
- activity.showRepresentation(mAction.getRepresentation());
- mAdapter.setSelected(this);
+ if (mAction.getType() == Action.ADD_ACTION) {
+ activity.addNewPreset();
+ } else if (mAction.getType() != Action.SPACER) {
+ if (mAction.isDoubleAction()) {
+ long current = System.currentTimeMillis() - mDoubleActionLast;
+ if (current < mDoubleTapDelay) {
+ activity.showRepresentation(mAction.getRepresentation());
+ }
+ mDoubleActionLast = System.currentTimeMillis();
+ } else {
+ activity.showRepresentation(mAction.getRepresentation());
+ }
+ mAdapter.setSelected(this);
+ }
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ boolean ret = super.onTouchEvent(event);
+ FilterShowActivity activity = (FilterShowActivity) getContext();
+
+ if (event.getActionMasked() == MotionEvent.ACTION_UP) {
+ activity.startTouchAnimation(this, event.getX(), event.getY());
+ }
+ if (!canBeRemoved()) {
+ return ret;
+ }
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ mStartTouchY = event.getY();
+ mStartTouchX = event.getX();
+ }
+ if (event.getActionMasked() == MotionEvent.ACTION_UP) {
+ setTranslationX(0);
+ setTranslationY(0);
+ }
+ if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
+ float delta = event.getY() - mStartTouchY;
+ if (getOrientation() == CategoryView.VERTICAL) {
+ delta = event.getX() - mStartTouchX;
+ }
+ if (Math.abs(delta) > mDeleteSlope) {
+ activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void delete() {
+ mAdapter.remove(mAction);
}
}
diff --git a/src/com/android/gallery3d/filtershow/category/IconView.java b/src/com/android/gallery3d/filtershow/category/IconView.java
new file mode 100644
index 0000000..cba2d79
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/category/IconView.java
@@ -0,0 +1,241 @@
+/*
+ * 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.category;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.LinearGradient;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.Shader;
+import android.graphics.Typeface;
+import android.util.AttributeSet;
+import android.view.View;
+import com.android.gallery3d.R;
+
+public class IconView extends View {
+
+ public static final int VERTICAL = 0;
+ public static final int HORIZONTAL = 1;
+
+ private Paint mPaint = new Paint();
+ private int mTextColor;
+ private int mBackgroundColor;
+ private int mMargin = 16;
+ private int mOrientation = HORIZONTAL;
+ private int mTextSize = 32;
+ private Rect mTextBounds = new Rect();
+ private Bitmap mBitmap;
+ private Rect mBitmapBounds;
+ private String mText;
+ private boolean mUseOnlyDrawable = false;
+
+ public IconView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setup(context);
+ int bitmapRsc = attrs.getAttributeResourceValue(
+ "http://schemas.android.com/apk/res/android", "src", 0);
+ Resources res = context.getResources();
+ Bitmap bitmap = BitmapFactory.decodeStream(res.openRawResource(bitmapRsc));
+ setBitmap(bitmap);
+ setUseOnlyDrawable(true);
+ }
+
+ public IconView(Context context) {
+ super(context);
+ setup(context);
+ }
+
+ private void setup(Context context) {
+ Resources res = getResources();
+ mTextColor = res.getColor(R.color.filtershow_categoryview_text);
+ mBackgroundColor = res.getColor(R.color.filtershow_categoryview_background);
+ mMargin = res.getDimensionPixelOffset(R.dimen.category_panel_margin);
+ mTextSize = res.getDimensionPixelSize(R.dimen.category_panel_text_size);
+ }
+
+ protected void computeTextPosition(String text) {
+ if (text == null) {
+ return;
+ }
+ mPaint.setTextSize(mTextSize);
+ if (getOrientation() == VERTICAL) {
+ text = text.toUpperCase();
+ // TODO: set this in xml
+ mPaint.setTypeface(Typeface.DEFAULT_BOLD);
+ }
+ mPaint.getTextBounds(text, 0, text.length(), mTextBounds);
+ }
+
+ public boolean needsCenterText() {
+ if (mOrientation == HORIZONTAL) {
+ return true;
+ }
+ return false;
+ }
+
+ protected void drawText(Canvas canvas, String text) {
+ if (text == null) {
+ return;
+ }
+ float textWidth = mPaint.measureText(text);
+ int x = (int) (canvas.getWidth() - textWidth - 2*mMargin);
+ if (needsCenterText()) {
+ x = (int) ((canvas.getWidth() - textWidth) / 2.0f);
+ }
+ if (x < 0) {
+ // If the text takes more than the view width,
+ // justify to the left.
+ x = mMargin;
+ }
+ int y = canvas.getHeight() - 2*mMargin;
+ canvas.drawText(text, x, y, mPaint);
+ }
+
+ protected void drawOutlinedText(Canvas canvas, String text) {
+ mPaint.setColor(getBackgroundColor());
+ mPaint.setStyle(Paint.Style.STROKE);
+ mPaint.setStrokeWidth(3);
+ drawText(canvas, text);
+ mPaint.setColor(getTextColor());
+ mPaint.setStyle(Paint.Style.FILL);
+ mPaint.setStrokeWidth(1);
+ drawText(canvas, text);
+ }
+
+ public int getOrientation() {
+ return mOrientation;
+ }
+
+ public void setOrientation(int orientation) {
+ mOrientation = orientation;
+ }
+
+ public int getMargin() {
+ return mMargin;
+ }
+
+ public int getTextSize() {
+ return mTextSize;
+ }
+
+ public int getTextColor() {
+ return mTextColor;
+ }
+
+ public int getBackgroundColor() {
+ return mBackgroundColor;
+ }
+
+ public void setText(String text) {
+ mText = text;
+ }
+
+ public String getText() {
+ return mText;
+ }
+
+ public void setBitmap(Bitmap bitmap) {
+ mBitmap = bitmap;
+ }
+
+ public void setUseOnlyDrawable(boolean value) {
+ mUseOnlyDrawable = value;
+ }
+
+ public Rect getBitmapBounds() {
+ return mBitmapBounds;
+ }
+
+ @Override
+ public CharSequence getContentDescription () {
+ return mText;
+ }
+
+ public boolean isHalfImage() {
+ return false;
+ }
+
+ public void computeBitmapBounds() {
+ if (mUseOnlyDrawable) {
+ mBitmapBounds = new Rect(mMargin/2, mMargin, getWidth() - mMargin/2,
+ getHeight() - mTextSize - 2*mMargin);
+ } else {
+ if (getOrientation() == VERTICAL && isHalfImage()) {
+ mBitmapBounds = new Rect(mMargin/2, mMargin, getWidth()/2, getHeight());
+ } else {
+ mBitmapBounds = new Rect(mMargin/2, mMargin, getWidth() - mMargin/2, getHeight());
+ }
+ }
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setFilterBitmap(true);
+ canvas.drawColor(mBackgroundColor);
+ computeBitmapBounds();
+ computeTextPosition(getText());
+ if (mBitmap != null) {
+ canvas.save();
+ canvas.clipRect(mBitmapBounds);
+ Matrix m = new Matrix();
+ if (mUseOnlyDrawable) {
+ mPaint.setFilterBitmap(true);
+ m.setRectToRect(new RectF(0, 0, mBitmap.getWidth(), mBitmap.getHeight()),
+ new RectF(mBitmapBounds), Matrix.ScaleToFit.CENTER);
+ } else {
+ float scaleWidth = mBitmapBounds.width() / (float) mBitmap.getWidth();
+ float scaleHeight = mBitmapBounds.height() / (float) mBitmap.getHeight();
+ float scale = Math.max(scaleWidth, scaleHeight);
+ float dx = (mBitmapBounds.width() - (mBitmap.getWidth() * scale)) / 2f;
+ float dy = (mBitmapBounds.height() - (mBitmap.getHeight() * scale)) / 2f;
+ dx += mBitmapBounds.left;
+ dy += mBitmapBounds.top;
+ m.postScale(scale, scale);
+ m.postTranslate(dx, dy);
+ }
+
+ canvas.drawBitmap(mBitmap, m, mPaint);
+ canvas.restore();
+ }
+
+ if (!mUseOnlyDrawable) {
+ int startColor = Color.argb(0, 0, 0, 0);
+ int endColor = Color.argb(200, 0, 0, 0);
+ float start = getHeight() - 2 * mMargin - 2 * mTextSize;
+ float end = getHeight();
+ Shader shader = new LinearGradient(0, start, 0, end, startColor,
+ endColor, Shader.TileMode.CLAMP);
+ mPaint.setShader(shader);
+ float startGradient = 0;
+ if (getOrientation() == VERTICAL && isHalfImage()) {
+ startGradient = getWidth()/2;
+ }
+ canvas.drawRect(new RectF(startGradient, start, getWidth(), end), mPaint);
+ mPaint.setShader(null);
+ }
+ drawOutlinedText(canvas, getText());
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java
index 9a64ffb..eb1ce2b 100644
--- a/src/com/android/gallery3d/filtershow/category/MainPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java
@@ -44,8 +44,10 @@
public static final int BORDERS = 1;
public static final int GEOMETRY = 2;
public static final int FILTERS = 3;
+ public static final int VERSIONS = 4;
private int mCurrentSelected = -1;
+ private int mPreviousToggleVersions = -1;
private void selection(int position, boolean value) {
if (value) {
@@ -141,11 +143,11 @@
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left);
}
transaction.replace(R.id.category_panel_container, category, CategoryPanel.FRAGMENT_TAG);
- transaction.commit();
+ transaction.commitAllowingStateLoss();
}
- public void loadCategoryLookPanel() {
- if (mCurrentSelected == LOOKS) {
+ public void loadCategoryLookPanel(boolean force) {
+ if (!force && mCurrentSelected == LOOKS) {
return;
}
boolean fromRight = isRightAnimation(LOOKS);
@@ -196,10 +198,25 @@
selection(mCurrentSelected, true);
}
+ public void loadCategoryVersionsPanel() {
+ if (mCurrentSelected == VERSIONS) {
+ return;
+ }
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ activity.updateVersions();
+ boolean fromRight = isRightAnimation(VERSIONS);
+ selection(mCurrentSelected, false);
+ CategoryPanel categoryPanel = new CategoryPanel();
+ categoryPanel.setAdapter(VERSIONS);
+ setCategoryFragment(categoryPanel, fromRight);
+ mCurrentSelected = VERSIONS;
+ selection(mCurrentSelected, true);
+ }
+
public void showPanel(int currentPanel) {
switch (currentPanel) {
case LOOKS: {
- loadCategoryLookPanel();
+ loadCategoryLookPanel(false);
break;
}
case BORDERS: {
@@ -214,18 +231,51 @@
loadCategoryFiltersPanel();
break;
}
+ case VERSIONS: {
+ loadCategoryVersionsPanel();
+ break;
+ }
}
}
- public void showImageStatePanel(boolean show) {
- if (mMainView.findViewById(R.id.state_panel_container) == null) {
+ public void setToggleVersionsPanelButton(ImageButton button) {
+ if (button == null) {
return;
}
- FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
- final View container = mMainView.findViewById(R.id.state_panel_container);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mCurrentSelected == VERSIONS) {
+ showPanel(mPreviousToggleVersions);
+ } else {
+ mPreviousToggleVersions = mCurrentSelected;
+ showPanel(VERSIONS);
+ }
+ }
+ });
+ }
+
+ public void showImageStatePanel(boolean show) {
+ View container = mMainView.findViewById(R.id.state_panel_container);
+ FragmentTransaction transaction = null;
+ if (container == null) {
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ container = activity.getMainStatePanelContainer(R.id.state_panel_container);
+ } else {
+ transaction = getChildFragmentManager().beginTransaction();
+ }
+ if (container == null) {
+ return;
+ } else {
+ transaction = getFragmentManager().beginTransaction();
+ }
+ int currentPanel = mCurrentSelected;
if (show) {
container.setVisibility(View.VISIBLE);
StatePanel statePanel = new StatePanel();
+ statePanel.setMainPanel(this);
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ activity.updateVersions();
transaction.replace(R.id.state_panel_container, statePanel, StatePanel.FRAGMENT_TAG);
} else {
container.setVisibility(View.GONE);
@@ -233,7 +283,12 @@
if (statePanel != null) {
transaction.remove(statePanel);
}
+ if (currentPanel == VERSIONS) {
+ currentPanel = LOOKS;
+ }
}
+ mCurrentSelected = -1;
+ showPanel(currentPanel);
transaction.commit();
}
}
diff --git a/src/com/android/gallery3d/filtershow/category/SwipableView.java b/src/com/android/gallery3d/filtershow/category/SwipableView.java
new file mode 100644
index 0000000..cb69f0c
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/category/SwipableView.java
@@ -0,0 +1,21 @@
+/*
+ * 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.category;
+
+public interface SwipableView {
+ public void delete();
+}
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorBrightnessView.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorBrightnessView.java
new file mode 100644
index 0000000..9b955ef
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorBrightnessView.java
@@ -0,0 +1,203 @@
+/*
+ * 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.colorpicker;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.LinearGradient;
+import android.graphics.Paint;
+import android.graphics.RadialGradient;
+import android.graphics.Shader;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.MotionEvent;
+import android.view.View;
+
+import com.android.gallery3d.R;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class ColorBrightnessView extends View implements ColorListener {
+
+ private float mRadius;
+ private float mWidth;
+ private Paint mBarPaint1;
+ private Paint mLinePaint1;
+ private Paint mLinePaint2;
+ private Paint mCheckPaint;
+
+ private float mHeight;
+ private Paint mDotPaint;
+ private int mBgcolor = 0;
+
+ private float mDotRadius;
+ private float mBorder;
+
+ private float[] mHSVO = new float[4];
+ private int mSliderColor;
+ private float mDotX = mBorder;
+ private float mDotY = mBorder;
+ private final static float DOT_SIZE = ColorRectView.DOT_SIZE;
+ public final static float BORDER_SIZE = 20;;
+
+ private ArrayList<ColorListener> mColorListeners = new ArrayList<ColorListener>();
+
+ public ColorBrightnessView(Context ctx, AttributeSet attrs) {
+ super(ctx, attrs);
+ DisplayMetrics metrics = ctx.getResources().getDisplayMetrics();
+ float mDpToPix = metrics.density;
+ mDotRadius = DOT_SIZE * mDpToPix;
+ mBorder = BORDER_SIZE * mDpToPix;
+ mBarPaint1 = new Paint();
+
+ mDotPaint = new Paint();
+
+ mDotPaint.setStyle(Paint.Style.FILL);
+ mDotPaint.setColor(ctx.getResources().getColor(R.color.slider_dot_color));
+ mSliderColor = ctx.getResources().getColor(R.color.slider_line_color);
+
+ mBarPaint1.setStyle(Paint.Style.FILL);
+
+ mLinePaint1 = new Paint();
+ mLinePaint1.setColor(Color.GRAY);
+ mLinePaint2 = new Paint();
+ mLinePaint2.setColor(mSliderColor);
+ mLinePaint2.setStrokeWidth(4);
+
+ int[] colors = new int[16 * 16];
+ for (int i = 0; i < colors.length; i++) {
+ int y = i / (16 * 8);
+ int x = (i / 8) % 2;
+ colors[i] = (x == y) ? 0xFFAAAAAA : 0xFF444444;
+ }
+ Bitmap bitmap = Bitmap.createBitmap(colors, 16, 16, Bitmap.Config.ARGB_8888);
+ BitmapShader bs = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+ mCheckPaint = new Paint();
+ mCheckPaint.setShader(bs);
+ }
+
+ public boolean onDown(MotionEvent e) {
+ return true;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ float ox = mDotX;
+ float oy = mDotY;
+
+ float x = event.getX();
+ float y = event.getY();
+
+ mDotX = x;
+
+ if (mDotX < mBorder) {
+ mDotX = mBorder;
+ }
+
+ if (mDotX > mWidth - mBorder) {
+ mDotX = mWidth - mBorder;
+ }
+ mHSVO[3] = (mDotX - mBorder) / (mWidth - mBorder * 2);
+ notifyColorListeners(mHSVO);
+ setupButton();
+ invalidate((int) (ox - mDotRadius), (int) (oy - mDotRadius), (int) (ox + mDotRadius),
+ (int) (oy + mDotRadius));
+ invalidate(
+ (int) (mDotX - mDotRadius), (int) (mDotY - mDotRadius), (int) (mDotX + mDotRadius),
+ (int) (mDotY + mDotRadius));
+
+ return true;
+ }
+
+ private void setupButton() {
+ float pos = mHSVO[3] * (mWidth - mBorder * 2);
+ mDotX = pos + mBorder;
+
+ int[] colors3 = new int[] {
+ mSliderColor, mSliderColor, 0x66000000, 0 };
+ RadialGradient g = new RadialGradient(mDotX, mDotY, mDotRadius, colors3, new float[] {
+ 0, .3f, .31f, 1 }, Shader.TileMode.CLAMP);
+ mDotPaint.setShader(g);
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ mWidth = w;
+ mHeight = h;
+ mDotY = mHeight / 2;
+ updatePaint();
+ setupButton();
+ }
+
+ private void updatePaint() {
+ float[] hsvo = Arrays.copyOf(mHSVO, 4);
+ hsvo[2] = 1;
+ hsvo[1] = 1;
+ hsvo[3] = 1;
+ int color2 = Color.HSVToColor(hsvo);
+ hsvo[2] = 0;
+ int color1 = Color.HSVToColor(hsvo);
+
+ Shader sg = new LinearGradient(
+ mBorder, mBorder, mWidth - mBorder, mBorder,
+ color1, color2, Shader.TileMode.CLAMP);
+ mBarPaint1.setShader(sg);
+
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ canvas.drawColor(mBgcolor);
+ canvas.drawRect(mBorder, mBorder, mWidth - mBorder, mHeight - mBorder, mCheckPaint);
+ canvas.drawRect(mBorder, mBorder, mWidth - mBorder, mHeight - mBorder, mBarPaint1);
+ canvas.drawLine(mDotX, mDotY, mWidth - mBorder, mDotY, mLinePaint1);
+ canvas.drawLine(mBorder, mDotY, mDotX, mDotY, mLinePaint2);
+ if (mDotX != Float.NaN) {
+ canvas.drawCircle(mDotX, mDotY, mDotRadius, mDotPaint);
+ }
+ }
+
+ @Override
+ public void setColor(float[] hsv) {
+ System.arraycopy(hsv, 0, mHSVO, 0, mHSVO.length);
+
+ float oy = mDotY;
+
+ updatePaint();
+ setupButton();
+ invalidate();
+ }
+
+ public void notifyColorListeners(float[] hsvo) {
+ for (ColorListener l : mColorListeners) {
+ l.setColor(hsvo);
+ }
+ }
+
+ public void addColorListener(ColorListener l) {
+ mColorListeners.add(l);
+ }
+
+ public void removeColorListener(ColorListener l) {
+ mColorListeners.remove(l);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorCompareView.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorCompareView.java
new file mode 100644
index 0000000..1599671
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorCompareView.java
@@ -0,0 +1,177 @@
+/*
+ * 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.colorpicker;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.Shader;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.MotionEvent;
+import android.view.View;
+
+import com.android.gallery3d.R;
+
+import java.util.ArrayList;
+
+public class ColorCompareView extends View implements ColorListener {
+
+ private float mRadius;
+ private float mWidth;
+ private Paint mBarPaint1;
+ private Paint mOrigBarPaint1;
+ private Paint mCheckPaint;
+
+ private float mHeight;
+
+ private int mBgcolor = 0;
+
+ private float mBorder;
+
+ private float[] mHSVO = new float[4];
+ private float[] mOrigHSVO = new float[4];
+ private Path mRegion;
+ private Path mOrigRegion;
+
+ public final static float BORDER_SIZE = 0;
+ private int mCheckDim = 8;
+
+ public ColorCompareView(Context ctx, AttributeSet attrs) {
+ super(ctx, attrs);
+ DisplayMetrics metrics = ctx.getResources().getDisplayMetrics();
+ float mDpToPix = metrics.density;
+ mBorder = BORDER_SIZE * mDpToPix;
+ mBarPaint1 = new Paint();
+ mOrigBarPaint1 = new Paint();
+ Resources res = ctx.getResources();
+ mCheckDim = res.getDimensionPixelSize(R.dimen.draw_color_check_dim);
+ mBarPaint1.setStyle(Paint.Style.FILL);
+ mOrigBarPaint1.setStyle(Paint.Style.FILL);
+
+ makeCheckPaint();
+ }
+
+ private void makeCheckPaint() {
+ int imgdim = mCheckDim * 2;
+ int[] colors = new int[imgdim * imgdim];
+ for (int i = 0; i < colors.length; i++) {
+ int y = i / (imgdim * mCheckDim);
+ int x = (i / mCheckDim) % 2;
+ colors[i] = (x == y) ? 0xFFAAAAAA : 0xFF444444;
+ }
+ Bitmap bitmap = Bitmap.createBitmap(colors, imgdim, imgdim, Bitmap.Config.ARGB_8888);
+ BitmapShader bs = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+ mCheckPaint = new Paint();
+ mCheckPaint.setShader(bs);
+ }
+
+ public boolean onDown(MotionEvent e) {
+ return true;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (event.getAction() != MotionEvent.ACTION_UP) {
+ return true;
+ }
+ float x = event.getX();
+ float y = event.getY();
+ if (x> mWidth-2*mHeight) {
+ resetToOriginal();
+ }
+ return true;
+ }
+
+ public void resetToOriginal(){
+ System.arraycopy(mOrigHSVO, 0, mHSVO, 0, mOrigHSVO.length);
+ updatePaint();
+ notifyColorListeners(mHSVO);
+ invalidate();
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ mWidth = w;
+ mHeight = h;
+ updatePaint();
+ }
+
+ private void updatePaint() {
+ int color = Color.HSVToColor((int) (mHSVO[3] * 255), mHSVO);
+ mBarPaint1.setColor(color);
+ int origColor = Color.HSVToColor((int) (mOrigHSVO[3] * 255), mOrigHSVO);
+ mOrigBarPaint1.setColor(origColor);
+ mOrigRegion = new Path();
+ mOrigRegion.moveTo(mWidth, 0);
+ mOrigRegion.lineTo(mWidth, mHeight);
+ mOrigRegion.lineTo(mWidth - mHeight * 2, mHeight);
+ mOrigRegion.lineTo(mWidth - mHeight, 0);
+
+ mRegion = new Path();
+ mRegion.moveTo(0, 0);
+ mRegion.lineTo(mWidth - mHeight, 0);
+ mRegion.lineTo(mWidth - mHeight * 2, mHeight);
+ mRegion.lineTo(0, mHeight);
+
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ canvas.drawColor(mBgcolor);
+ canvas.drawRect(mBorder, 0, mWidth, mHeight, mCheckPaint);
+ canvas.drawPath(mRegion, mBarPaint1);
+ canvas.drawPath(mOrigRegion, mOrigBarPaint1);
+ }
+
+ public void setOrigColor(float[] hsv) {
+ System.arraycopy(hsv, 0, mOrigHSVO, 0, mOrigHSVO.length);
+ int color2 = Color.HSVToColor((int) (mOrigHSVO[3] * 255), mOrigHSVO);
+ mOrigBarPaint1.setColor(color2);
+ updatePaint();
+ }
+
+ @Override
+ public void setColor(float[] hsv) {
+ System.arraycopy(hsv, 0, mHSVO, 0, mHSVO.length);
+ updatePaint();
+ invalidate();
+ }
+
+ ArrayList<ColorListener> mColorListeners = new ArrayList<ColorListener>();
+
+ public void notifyColorListeners(float[] hsvo) {
+ for (ColorListener l : mColorListeners) {
+ l.setColor(hsvo);
+ }
+ }
+
+ public void addColorListener(ColorListener l) {
+ mColorListeners.add(l);
+ }
+
+ public void removeColorListener(ColorListener l) {
+ mColorListeners.remove(l);
+ }
+}
+
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorGridDialog.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorGridDialog.java
index dd4df7d..0285994 100644
--- a/src/com/android/gallery3d/filtershow/colorpicker/ColorGridDialog.java
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorGridDialog.java
@@ -92,6 +92,9 @@
c |= alpha << 24;
mCallback.setColor(c);
}
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
};
ColorPickerDialog cpd = new ColorPickerDialog(this.getContext(), cl);
cpd.show();
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorHueView.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorHueView.java
new file mode 100644
index 0000000..498f5a4
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorHueView.java
@@ -0,0 +1,225 @@
+/*
+ * 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.colorpicker;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.LinearGradient;
+import android.graphics.Paint;
+import android.graphics.RadialGradient;
+import android.graphics.RectF;
+import android.graphics.Shader;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.MotionEvent;
+import android.view.View;
+
+import com.android.gallery3d.R;
+
+import java.util.ArrayList;
+
+public class ColorHueView extends View implements ColorListener {
+
+ private float mWidth;
+
+ private Paint mLinePaint1;
+ private Paint mLinePaint2;
+ private Paint mPaint = new Paint();
+ private float mHeight;
+ private Paint mDotPaint;
+ private int mBgcolor = 0;
+ Bitmap mBitmap;
+ private float mDotRadius;
+ private float mBorder;
+
+ private float[] mHSVO = {0.f,0.f,0.f,0.f};
+ private int mSliderColor;
+ private float mDotX = mBorder;
+ private float mDotY = mBorder;
+
+ public final static float DOT_SIZE = 20;
+ public final static float BORDER_SIZE = 20;
+ RectF mRect = new RectF();
+ int[] mTmpBuff;
+ float[] mTmpHSV = new float[3];
+ private Paint mCheckPaint;
+
+ public ColorHueView(Context ctx, AttributeSet attrs) {
+ super(ctx, attrs);
+ DisplayMetrics metrics = ctx.getResources().getDisplayMetrics();
+ float mDpToPix = metrics.density;
+ mDotRadius = DOT_SIZE * mDpToPix;
+ mBorder = BORDER_SIZE * mDpToPix;
+
+ mDotPaint = new Paint();
+
+ mDotPaint.setStyle(Paint.Style.FILL);
+ mDotPaint.setColor(ctx.getResources().getColor(R.color.slider_dot_color));
+ mSliderColor = ctx.getResources().getColor(R.color.slider_line_color);
+
+
+ mLinePaint1 = new Paint();
+ mLinePaint1.setColor(Color.GRAY);
+ mLinePaint2 = new Paint();
+ mLinePaint2.setColor(mSliderColor);
+ mLinePaint2.setStrokeWidth(4);
+
+ mBitmap = Bitmap.createBitmap(256, 2, Bitmap.Config.ARGB_8888);
+ mTmpBuff = new int[mBitmap.getWidth() * mBitmap.getHeight()];
+ mPaint.setAntiAlias(true);
+ mPaint.setFilterBitmap(true);
+ fillBitmap();
+ makeCheckPaint();
+ }
+
+ void fillBitmap() {
+ int w = mBitmap.getWidth();
+ int h = mBitmap.getHeight();
+
+ for (int x = 0; x < w; x++) {
+ float hue = 360 * (x) / (float) w;
+
+ mTmpHSV[0] = hue;
+ mTmpHSV[1] = 1;
+ mTmpHSV[2] = 1;
+ int color = Color.HSVToColor(mTmpHSV);
+ mTmpBuff[x] = color;
+ mTmpBuff[x + w] = color;
+
+ }
+
+ mBitmap.setPixels(mTmpBuff, 0, w, 0, 0, w, h);
+ }
+
+
+ public boolean onDown(MotionEvent e) {
+ return true;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ float ox = mDotX;
+ float oy = mDotY;
+
+ float x = event.getX();
+ float y = event.getY();
+
+ mDotX = x;
+
+ if (mDotX < mBorder) {
+ mDotX = mBorder;
+ }
+
+ if (mDotX > mWidth - mBorder) {
+ mDotX = mWidth - mBorder;
+ }
+ mHSVO[0] = 360 * (mDotX - mBorder) / (mWidth - mBorder * 2);
+ notifyColorListeners(mHSVO);
+ setupButton();
+ fillBitmap();
+// invalidate((int) (ox - mDotRadius), (int) (oy - mDotRadius), (int) (ox + mDotRadius),
+// (int) (oy + mDotRadius));
+// invalidate(
+// (int) (mDotX - mDotRadius), (int) (mDotY - mDotRadius), (int) (mDotX + mDotRadius),
+// (int) (mDotY + mDotRadius));
+ invalidate();
+
+ return true;
+ }
+
+ private void setupButton() {
+ float pos = mHSVO[0] / 360 * (mWidth - mBorder * 2);
+ mDotX = pos + mBorder;
+
+ int[] colors3 = new int[]{
+ mSliderColor, mSliderColor, 0x66000000, 0};
+ RadialGradient g = new RadialGradient(mDotX, mDotY, mDotRadius, colors3, new float[]{
+ 0, .3f, .31f, 1}, Shader.TileMode.CLAMP);
+ mDotPaint.setShader(g);
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ mWidth = w;
+ mHeight = h;
+ mDotY = mHeight / 2;
+ setupButton();
+ }
+
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ canvas.drawColor(mBgcolor);
+
+ mRect.left = mBorder;
+ mRect.right = mWidth - mBorder;
+ mRect.top = 0;
+ mRect.bottom = mHeight;
+ canvas.drawRect(mRect,mCheckPaint);
+ canvas.drawBitmap(mBitmap, null, mRect, mPaint);
+
+
+ canvas.drawLine(mDotX, mDotY, mWidth - mBorder, mDotY, mLinePaint1);
+ canvas.drawLine(mBorder, mDotY, mDotX, mDotY, mLinePaint2);
+ if (mDotX != Float.NaN) {
+ canvas.drawCircle(mDotX, mDotY, mDotRadius, mDotPaint);
+ }
+ }
+
+ private void makeCheckPaint(){
+ int block = 16;
+ int checkdim = block*2;
+ int[] colors = new int[checkdim * checkdim];
+ for (int i = 0; i < colors.length; i++) {
+ int y = i / (checkdim * block);
+ int x = (i / block) % 2;
+ colors[i] = (x == y) ? 0xFFAAAAAA : 0xFF444444;
+ }
+ Bitmap bitmap = Bitmap.createBitmap(colors, 16, 16, Bitmap.Config.ARGB_8888);
+ BitmapShader bs = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+ mCheckPaint = new Paint();
+ mCheckPaint.setShader(bs);
+ }
+
+ @Override
+ public void setColor(float[] hsv) {
+ System.arraycopy(hsv, 0, mHSVO, 0, mHSVO.length);
+ fillBitmap();
+ setupButton();
+ invalidate();
+ }
+
+ ArrayList<ColorListener> mColorListeners = new ArrayList<ColorListener>();
+
+ public void notifyColorListeners(float[] hsvo) {
+ for (ColorListener l : mColorListeners) {
+ l.setColor(hsvo);
+ }
+ }
+
+ public void addColorListener(ColorListener l) {
+ mColorListeners.add(l);
+ }
+
+ public void removeColorListener(ColorListener l) {
+ mColorListeners.remove(l);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorListener.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorListener.java
index 5127dad..22dd424 100644
--- a/src/com/android/gallery3d/filtershow/colorpicker/ColorListener.java
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorListener.java
@@ -18,4 +18,5 @@
public interface ColorListener {
void setColor(float[] hsvo);
+ public void addColorListener(ColorListener l);
}
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorOpacityView.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorOpacityView.java
index 2bff501..ec15b5b 100644
--- a/src/com/android/gallery3d/filtershow/colorpicker/ColorOpacityView.java
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorOpacityView.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.filtershow.colorpicker;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
@@ -54,9 +55,9 @@
private int mSliderColor;
private float mDotX = mBorder;
private float mDotY = mBorder;
- private final static float DOT_SIZE = ColorRectView.DOT_SIZE;
+ private final static float DOT_SIZE = ColorHueView.DOT_SIZE;
public final static float BORDER_SIZE = 20;;
-
+ private int mCheckDim = 8;
public ColorOpacityView(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
DisplayMetrics metrics = ctx.getResources().getDisplayMetrics();
@@ -68,8 +69,10 @@
mDotPaint = new Paint();
mDotPaint.setStyle(Paint.Style.FILL);
- mDotPaint.setColor(ctx.getResources().getColor(R.color.slider_dot_color));
- mSliderColor = ctx.getResources().getColor(R.color.slider_line_color);
+ Resources res = ctx.getResources();
+ mCheckDim = res.getDimensionPixelSize(R.dimen.draw_color_check_dim);
+ mDotPaint.setColor(res.getColor(R.color.slider_dot_color));
+ mSliderColor = res.getColor(R.color.slider_line_color);
mBarPaint1.setStyle(Paint.Style.FILL);
@@ -79,13 +82,18 @@
mLinePaint2.setColor(mSliderColor);
mLinePaint2.setStrokeWidth(4);
- int[] colors = new int[16 * 16];
+ makeCheckPaint();
+ }
+
+ private void makeCheckPaint(){
+ int imgdim = mCheckDim*2;
+ int[] colors = new int[imgdim * imgdim];
for (int i = 0; i < colors.length; i++) {
- int y = i / (16 * 8);
- int x = (i / 8) % 2;
+ int y = i / (imgdim * mCheckDim);
+ int x = (i / mCheckDim) % 2;
colors[i] = (x == y) ? 0xFFAAAAAA : 0xFF444444;
}
- Bitmap bitmap = Bitmap.createBitmap(colors, 16, 16, Bitmap.Config.ARGB_8888);
+ Bitmap bitmap = Bitmap.createBitmap(colors, imgdim, imgdim, Bitmap.Config.ARGB_8888);
BitmapShader bs = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
mCheckPaint = new Paint();
mCheckPaint.setShader(bs);
@@ -129,9 +137,9 @@
mDotX = pos + mBorder;
int[] colors3 = new int[] {
- mSliderColor, mSliderColor, 0x66000000, 0 };
+ mSliderColor, mSliderColor, 0x66000000, 0 };
RadialGradient g = new RadialGradient(mDotX, mDotY, mDotRadius, colors3, new float[] {
- 0, .3f, .31f, 1 }, Shader.TileMode.CLAMP);
+ 0, .3f, .31f, 1 }, Shader.TileMode.CLAMP);
mDotPaint.setShader(g);
}
@@ -159,8 +167,8 @@
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(mBgcolor);
- canvas.drawRect(mBorder, mBorder, mWidth - mBorder, mHeight - mBorder, mCheckPaint);
- canvas.drawRect(mBorder, mBorder, mWidth - mBorder, mHeight - mBorder, mBarPaint1);
+ canvas.drawRect(mBorder, 0, mWidth - mBorder, mHeight, mCheckPaint);
+ canvas.drawRect(mBorder, 0, mWidth - mBorder, mHeight, mBarPaint1);
canvas.drawLine(mDotX, mDotY, mWidth - mBorder, mDotY, mLinePaint1);
canvas.drawLine(mBorder, mDotY, mDotX, mDotY, mLinePaint2);
if (mDotX != Float.NaN) {
@@ -172,8 +180,6 @@
public void setColor(float[] hsv) {
System.arraycopy(hsv, 0, mHSVO, 0, mHSVO.length);
- float oy = mDotY;
-
updatePaint();
setupButton();
invalidate();
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorPickerDialog.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorPickerDialog.java
index 73a5c90..ff36f5a 100644
--- a/src/com/android/gallery3d/filtershow/colorpicker/ColorPickerDialog.java
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorPickerDialog.java
@@ -18,59 +18,94 @@
import android.app.Dialog;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
+import android.util.DisplayMetrics;
import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
import android.widget.Button;
+import android.widget.ImageButton;
import android.widget.ToggleButton;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.photos.views.GalleryThumbnailView;
-public class ColorPickerDialog extends Dialog implements ColorListener {
+public class ColorPickerDialog extends Dialog {
ToggleButton mSelectedButton;
- GradientDrawable mSelectRect;
+ ColorHueView mColorHueView;
+ ColorSVRectView mColorSVRectView;
+ ColorOpacityView mColorOpacityView;
+ ColorCompareView mColorCompareView;
- float[] mHSVO = new float[4];
+ float[] mHSVO = new float[4]; // hue=0..360, sat & val opacity = 0...1
public ColorPickerDialog(Context context, final ColorListener cl) {
super(context);
-
+ DisplayMetrics metrics = new DisplayMetrics();
+ WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ wm.getDefaultDisplay().getMetrics(metrics);
+ int height = metrics.heightPixels*8/10;
+ int width = metrics.widthPixels*8/10;
+ getWindow().setLayout(width, height);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.filtershow_color_picker);
- ColorValueView csv = (ColorValueView) findViewById(R.id.colorValueView);
- ColorRectView cwv = (ColorRectView) findViewById(R.id.colorRectView);
- ColorOpacityView cvv = (ColorOpacityView) findViewById(R.id.colorOpacityView);
+ mColorHueView = (ColorHueView) findViewById(R.id.ColorHueView);
+ mColorSVRectView = (ColorSVRectView) findViewById(R.id.colorRectView);
+ mColorOpacityView = (ColorOpacityView) findViewById(R.id.colorOpacityView);
+ mColorCompareView = (ColorCompareView) findViewById(R.id.btnSelect);
+
float[] hsvo = new float[] {
123, .9f, 1, 1 };
- mSelectRect = (GradientDrawable) getContext()
- .getResources().getDrawable(R.drawable.filtershow_color_picker_roundrect);
- Button selButton = (Button) findViewById(R.id.btnSelect);
- selButton.setCompoundDrawablesWithIntrinsicBounds(null, null, mSelectRect, null);
- Button sel = (Button) findViewById(R.id.btnSelect);
+ ImageButton apply = (ImageButton) findViewById(R.id.applyColorPick);
+ ImageButton cancel = (ImageButton) findViewById(R.id.cancelColorPick);
- sel.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ apply.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ cl.setColor(mHSVO);
ColorPickerDialog.this.dismiss();
- if (cl != null) {
- cl.setColor(mHSVO);
- }
}
});
+ cancel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ ColorPickerDialog.this.dismiss();
+ }
+ });
+ ColorListener [] c = {mColorCompareView,mColorSVRectView,mColorOpacityView,mColorHueView};
+ for (int i = 0; i < c.length; i++) {
+ c[i].setColor(hsvo);
+ for (int j = 0; j < c.length; j++) {
+ if (i==j) {
+ continue;
+ }
+ c[i].addColorListener(c[j]);
+ }
+ }
- cwv.setColor(hsvo);
- cvv.setColor(hsvo);
- csv.setColor(hsvo);
- csv.addColorListener(cwv);
- cwv.addColorListener(csv);
- csv.addColorListener(cvv);
- cwv.addColorListener(cvv);
- cvv.addColorListener(cwv);
- cvv.addColorListener(csv);
- cvv.addColorListener(this);
- csv.addColorListener(this);
- cwv.addColorListener(this);
+ ColorListener colorListener = new ColorListener(){
+ @Override
+ public void setColor(float[] hsvo) {
+ System.arraycopy(hsvo, 0, mHSVO, 0, mHSVO.length);
+ int color = Color.HSVToColor(hsvo);
+ setButtonColor(mSelectedButton, hsvo);
+ }
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
+ };
+
+ for (int i = 0; i < c.length; i++) {
+ c[i].addColorListener(colorListener);
+ }
+ setOnShowListener((FilterShowActivity) context);
+ setOnDismissListener((FilterShowActivity) context);
}
void toggleClick(ToggleButton v, int[] buttons, boolean isChecked) {
@@ -89,20 +124,23 @@
float[] hsv = (float[]) v.getTag();
- ColorValueView csv = (ColorValueView) findViewById(R.id.colorValueView);
- ColorRectView cwv = (ColorRectView) findViewById(R.id.colorRectView);
+ ColorHueView csv = (ColorHueView) findViewById(R.id.ColorHueView);
+ ColorSVRectView cwv = (ColorSVRectView) findViewById(R.id.colorRectView);
ColorOpacityView cvv = (ColorOpacityView) findViewById(R.id.colorOpacityView);
cwv.setColor(hsv);
cvv.setColor(hsv);
csv.setColor(hsv);
}
- @Override
+ public void setOrigColor(float[] hsvo) {
+ mColorCompareView.setOrigColor(hsvo);
+ }
+
public void setColor(float[] hsvo) {
- System.arraycopy(hsvo, 0, mHSVO, 0, mHSVO.length);
- int color = Color.HSVToColor(hsvo);
- mSelectRect.setColor(color);
- setButtonColor(mSelectedButton, hsvo);
+ mColorOpacityView.setColor(hsvo);
+ mColorHueView.setColor(hsvo);
+ mColorSVRectView.setColor(hsvo);
+ mColorCompareView.setColor(hsvo);
}
private void setButtonColor(ToggleButton button, float[] hsv) {
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorSVRectView.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorSVRectView.java
new file mode 100644
index 0000000..fb8b4fc
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorSVRectView.java
@@ -0,0 +1,233 @@
+/*
+ * 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.colorpicker;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.LinearGradient;
+import android.graphics.Paint;
+import android.graphics.RadialGradient;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.Shader;
+import android.graphics.SweepGradient;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.MotionEvent;
+import android.view.View;
+
+import com.android.gallery3d.R;
+
+import java.util.ArrayList;
+
+public class ColorSVRectView extends View implements ColorListener {
+ private float mDpToPix;
+
+ private float mCtrY = 100;
+ private Paint mPaint1;
+
+ private float mCtrX = 100;
+ private Paint mDotPaint = new Paint();
+ private float mDotRadus;
+ private float mBorder;
+
+ private float mDotX = Float.NaN;
+ private float mDotY;
+ private int mSliderColor = 0xFF33B5E5;
+ private float[] mHSVO = new float[]{0, 1, 1, 1};
+ RectF mRect = new RectF();
+
+ private int mWidth;
+ private int mHeight;
+ public final static float DOT_SIZE = 20;
+ public final static float BORDER_SIZE = 20;
+ Bitmap mBitmap;
+
+ public ColorSVRectView(Context ctx, AttributeSet attrs) {
+ super(ctx, attrs);
+
+ DisplayMetrics metrics = ctx.getResources().getDisplayMetrics();
+ mDpToPix = metrics.density;
+ mDotRadus = DOT_SIZE * mDpToPix;
+ mBorder = BORDER_SIZE * mDpToPix;
+
+ mPaint1 = new Paint();
+
+
+ mDotPaint.setStyle(Paint.Style.FILL);
+ if (isInEditMode()) {
+ mDotPaint.setColor(0x646464);
+ mSliderColor = 0x888888;
+ } else {
+ mDotPaint.setColor(ctx.getResources().getColor(R.color.slider_dot_color));
+ mSliderColor = ctx.getResources().getColor(R.color.slider_line_color);
+ }
+ mPaint1.setStyle(Paint.Style.FILL);
+ mPaint1.setAntiAlias(true);
+ mPaint1.setFilterBitmap(true);
+
+ mBitmap = Bitmap.createBitmap(64, 46, Bitmap.Config.ARGB_8888);
+ fillBitmap();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, widthMeasureSpec);
+ }
+
+ void fillBitmap() {
+ int w = mBitmap.getWidth();
+ int h = mBitmap.getHeight();
+ int[] buff = new int[w * h];
+ float[] hsv = new float[3];
+ hsv[0] = mHSVO[0];
+ for (int i = 0; i < w * h; i++) {
+ float sat = (i % w) / (float) w;
+ float val = (w - i / w) / (float) w;
+ hsv[1] = sat;
+ hsv[2] = val;
+ buff[i] = Color.HSVToColor(hsv);
+ }
+ mBitmap.setPixels(buff, 0, w, 0, 0, w, h);
+ }
+
+ private void setUpColorPanel() {
+ updateDot();
+ updateDotPaint();
+ fillBitmap();
+
+ }
+
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ Rect r = canvas.getClipBounds();
+ mRect.set(r);
+ mRect.top += mBorder;
+ mRect.bottom -= mBorder;
+ mRect.left += mBorder;
+ mRect.right -= mBorder;
+ canvas.drawBitmap(mBitmap, null, mRect, mPaint1);
+
+ if (mDotX != Float.NaN) {
+
+ canvas.drawCircle(mDotX, mDotY, mDotRadus, mDotPaint);
+ }
+ }
+
+
+ public boolean onDown(MotionEvent e) {
+ return true;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+
+ invalidate((int) (mDotX - mDotRadus), (int) (mDotY - mDotRadus), (int) (mDotX + mDotRadus),
+ (int) (mDotY + mDotRadus));
+ float x = event.getX();
+ float y = event.getY();
+
+ x = Math.max(Math.min(x, mWidth - mBorder), mBorder);
+ y = Math.max(Math.min(y, mHeight - mBorder), mBorder);
+ mDotX = x;
+ mDotY = y;
+ float sat = 1 - (mDotY - mBorder) / (mHeight - 2 * mBorder);
+ if (sat > 1) {
+ sat = 1;
+ }
+
+ float value = (mDotX - mBorder) / (mHeight - 2 * mBorder);
+ mHSVO[2] = sat;
+ mHSVO[1] = value;
+ notifyColorListeners(mHSVO);
+ updateDotPaint();
+ invalidate((int) (mDotX - mDotRadus), (int) (mDotY - mDotRadus), (int) (mDotX + mDotRadus),
+ (int) (mDotY + mDotRadus));
+
+ return true;
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ mWidth = w;
+ mHeight = h;
+ mCtrY = h / 2f;
+ mCtrX = w / 2f;
+
+ setUpColorPanel();
+ }
+
+
+ private void updateDot() {
+
+ double hue = mHSVO[0];
+ double sat = mHSVO[1];
+ double val = mHSVO[2];
+ double opc = mHSVO[3];
+
+ mDotX = (float) (mBorder + (mHeight - 2 * mBorder) * sat);
+ mDotY = (float) ((1 - val) * (mHeight - 2 * mBorder) + mBorder);
+
+ }
+
+ private void updateDotPaint() {
+ int[] colors3 = new int[]{
+ mSliderColor, mSliderColor, 0x66000000, 0};
+ RadialGradient g = new RadialGradient(mDotX, mDotY, mDotRadus, colors3, new float[]{
+ 0, .3f, .31f, 1}, Shader.TileMode.CLAMP);
+ mDotPaint.setShader(g);
+
+ }
+
+ @Override
+ public void setColor(float[] hsvo) {
+ if (hsvo[0] == mHSVO[0]
+ && hsvo[1] == mHSVO[1]
+ && hsvo[2] == mHSVO[2]) {
+ mHSVO[3] = hsvo[3]; // we don't update if color stays the same
+ return;
+ }
+ System.arraycopy(hsvo, 0, mHSVO, 0, mHSVO.length);
+
+ setUpColorPanel();
+ invalidate();
+
+ updateDot();
+ updateDotPaint();
+
+ }
+
+ ArrayList<ColorListener> mColorListeners = new ArrayList<ColorListener>();
+
+ public void notifyColorListeners(float[] hsv) {
+ for (ColorListener l : mColorListeners) {
+ l.setColor(hsv);
+ }
+ }
+
+ public void addColorListener(ColorListener l) {
+ mColorListeners.add(l);
+ }
+
+ public void removeColorListener(ColorListener l) {
+ mColorListeners.remove(l);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorSaturationView.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorSaturationView.java
new file mode 100644
index 0000000..af4dfda
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorSaturationView.java
@@ -0,0 +1,202 @@
+/*
+ * 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.colorpicker;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.LinearGradient;
+import android.graphics.Paint;
+import android.graphics.RadialGradient;
+import android.graphics.Shader;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.MotionEvent;
+import android.view.View;
+
+import com.android.gallery3d.R;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class ColorSaturationView extends View implements ColorListener {
+
+ private float mRadius;
+ private float mWidth;
+ private Paint mBarPaint1;
+ private Paint mLinePaint1;
+ private Paint mLinePaint2;
+ private Paint mCheckPaint;
+
+ private float mHeight;
+ private Paint mDotPaint;
+ private int mBgcolor = 0;
+
+ private float mDotRadius;
+ private float mBorder;
+
+ private float[] mHSVO = new float[4];
+ private int mSliderColor;
+ private float mDotX = mBorder;
+ private float mDotY = mBorder;
+ private final static float DOT_SIZE = ColorRectView.DOT_SIZE;
+ public final static float BORDER_SIZE = 20;;
+
+ private ArrayList<ColorListener> mColorListeners = new ArrayList<ColorListener>();
+
+ public ColorSaturationView(Context ctx, AttributeSet attrs) {
+ super(ctx, attrs);
+ DisplayMetrics metrics = ctx.getResources().getDisplayMetrics();
+ float mDpToPix = metrics.density;
+ mDotRadius = DOT_SIZE * mDpToPix;
+ mBorder = BORDER_SIZE * mDpToPix;
+ mBarPaint1 = new Paint();
+
+ mDotPaint = new Paint();
+
+ mDotPaint.setStyle(Paint.Style.FILL);
+ mDotPaint.setColor(ctx.getResources().getColor(R.color.slider_dot_color));
+ mSliderColor = ctx.getResources().getColor(R.color.slider_line_color);
+
+ mBarPaint1.setStyle(Paint.Style.FILL);
+
+ mLinePaint1 = new Paint();
+ mLinePaint1.setColor(Color.GRAY);
+ mLinePaint2 = new Paint();
+ mLinePaint2.setColor(mSliderColor);
+ mLinePaint2.setStrokeWidth(4);
+
+ int[] colors = new int[16 * 16];
+ for (int i = 0; i < colors.length; i++) {
+ int y = i / (16 * 8);
+ int x = (i / 8) % 2;
+ colors[i] = (x == y) ? 0xFFAAAAAA : 0xFF444444;
+ }
+ Bitmap bitmap = Bitmap.createBitmap(colors, 16, 16, Bitmap.Config.ARGB_8888);
+ BitmapShader bs = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+ mCheckPaint = new Paint();
+ mCheckPaint.setShader(bs);
+ }
+
+ public boolean onDown(MotionEvent e) {
+ return true;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ float ox = mDotX;
+ float oy = mDotY;
+
+ float x = event.getX();
+ float y = event.getY();
+
+ mDotX = x;
+
+ if (mDotX < mBorder) {
+ mDotX = mBorder;
+ }
+
+ if (mDotX > mWidth - mBorder) {
+ mDotX = mWidth - mBorder;
+ }
+ mHSVO[3] = (mDotX - mBorder) / (mWidth - mBorder * 2);
+ notifyColorListeners(mHSVO);
+ setupButton();
+ invalidate((int) (ox - mDotRadius), (int) (oy - mDotRadius), (int) (ox + mDotRadius),
+ (int) (oy + mDotRadius));
+ invalidate(
+ (int) (mDotX - mDotRadius), (int) (mDotY - mDotRadius), (int) (mDotX + mDotRadius),
+ (int) (mDotY + mDotRadius));
+
+ return true;
+ }
+
+ private void setupButton() {
+ float pos = mHSVO[3] * (mWidth - mBorder * 2);
+ mDotX = pos + mBorder;
+
+ int[] colors3 = new int[] {
+ mSliderColor, mSliderColor, 0x66000000, 0 };
+ RadialGradient g = new RadialGradient(mDotX, mDotY, mDotRadius, colors3, new float[] {
+ 0, .3f, .31f, 1 }, Shader.TileMode.CLAMP);
+ mDotPaint.setShader(g);
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ mWidth = w;
+ mHeight = h;
+ mDotY = mHeight / 2;
+ updatePaint();
+ setupButton();
+ }
+
+ private void updatePaint() {
+ float[]hsvo = Arrays.copyOf(mHSVO, 4);
+ hsvo[3] = 1;
+ hsvo[2] = 1;
+ hsvo[1] = 1;
+ int color2 = Color.HSVToColor(hsvo);
+ hsvo[1] = 0;
+ int color1 = Color.HSVToColor(hsvo);
+ Shader sg = new LinearGradient(
+ mBorder, mBorder, mWidth - mBorder, mBorder,
+ color1, color2, Shader.TileMode.CLAMP);
+ mBarPaint1.setShader(sg);
+
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ canvas.drawColor(mBgcolor);
+ canvas.drawRect(mBorder, mBorder, mWidth - mBorder, mHeight - mBorder, mCheckPaint);
+ canvas.drawRect(mBorder, mBorder, mWidth - mBorder, mHeight - mBorder, mBarPaint1);
+ canvas.drawLine(mDotX, mDotY, mWidth - mBorder, mDotY, mLinePaint1);
+ canvas.drawLine(mBorder, mDotY, mDotX, mDotY, mLinePaint2);
+ if (mDotX != Float.NaN) {
+ canvas.drawCircle(mDotX, mDotY, mDotRadius, mDotPaint);
+ }
+ }
+
+ @Override
+ public void setColor(float[] hsv) {
+ System.arraycopy(hsv, 0, mHSVO, 0, mHSVO.length);
+
+ float oy = mDotY;
+
+ updatePaint();
+ setupButton();
+ invalidate();
+ }
+
+ public void notifyColorListeners(float[] hsvo) {
+ for (ColorListener l : mColorListeners) {
+ l.setColor(hsvo);
+ }
+ }
+
+ public void addColorListener(ColorListener l) {
+ mColorListeners.add(l);
+ }
+
+ public void removeColorListener(ColorListener l) {
+ mColorListeners.remove(l);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/colorpicker/ColorValueView.java b/src/com/android/gallery3d/filtershow/colorpicker/ColorValueView.java
index 13cb44b..bbfd829 100644
--- a/src/com/android/gallery3d/filtershow/colorpicker/ColorValueView.java
+++ b/src/com/android/gallery3d/filtershow/colorpicker/ColorValueView.java
@@ -52,6 +52,8 @@
private final static float DOT_SIZE = ColorRectView.DOT_SIZE;
private final static float BORDER_SIZE = ColorRectView.DOT_SIZE;
+ private ArrayList<ColorListener> mColorListeners = new ArrayList<ColorListener>();
+
public ColorValueView(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
DisplayMetrics metrics = ctx.getResources().getDisplayMetrics();
@@ -162,8 +164,6 @@
}
- ArrayList<ColorListener> mColorListeners = new ArrayList<ColorListener>();
-
public void notifyColorListeners(float[] hsv) {
for (ColorListener l : mColorListeners) {
l.setColor(hsv);
diff --git a/src/com/android/gallery3d/filtershow/controller/BasicParameterInt.java b/src/com/android/gallery3d/filtershow/controller/BasicParameterInt.java
index 777bc43..92145e9 100644
--- a/src/com/android/gallery3d/filtershow/controller/BasicParameterInt.java
+++ b/src/com/android/gallery3d/filtershow/controller/BasicParameterInt.java
@@ -45,6 +45,14 @@
ID = id;
mValue = value;
}
+
+ public BasicParameterInt(int id, int value, int min, int max) {
+ ID = id;
+ mValue = value;
+ mMinimum = min;
+ mMaximum = max;
+ }
+
@Override
public String getParameterName() {
return mParameterName;
diff --git a/src/com/android/gallery3d/filtershow/controller/BasicParameterStyle.java b/src/com/android/gallery3d/filtershow/controller/BasicParameterStyle.java
index 072edd7..498dcc6 100644
--- a/src/com/android/gallery3d/filtershow/controller/BasicParameterStyle.java
+++ b/src/com/android/gallery3d/filtershow/controller/BasicParameterStyle.java
@@ -17,9 +17,8 @@
package com.android.gallery3d.filtershow.controller;
import android.content.Context;
-import android.util.Log;
-import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
public class BasicParameterStyle implements ParameterStyles {
protected String mParameterName;
@@ -91,7 +90,7 @@
}
@Override
- public void getIcon(int index, RenderingRequestCaller caller) {
+ public void getIcon(int index, BitmapCaller caller) {
mEditor.computeIcon(index, caller);
}
@@ -109,5 +108,4 @@
public void setFilterView(FilterView editor) {
mEditor = editor;
}
-
}
diff --git a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java
index df5b6ae..811b474 100644
--- a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java
+++ b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java
@@ -43,7 +43,7 @@
LinearLayout lp = (LinearLayout) inflater.inflate(
R.layout.filtershow_seekbar, container, true);
mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar);
-
+ mSeekBar.setVisibility(View.VISIBLE);
updateUI();
mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@@ -84,5 +84,4 @@
mSeekBar.setMax(mParameter.getMaximum() - mParameter.getMinimum());
mSeekBar.setProgress(mParameter.getValue() - mParameter.getMinimum());
}
-
}
diff --git a/src/com/android/gallery3d/filtershow/controller/BitmapCaller.java b/src/com/android/gallery3d/filtershow/controller/BitmapCaller.java
new file mode 100644
index 0000000..e06c7e2
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/BitmapCaller.java
@@ -0,0 +1,23 @@
+/*
+ * 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.controller;
+
+import android.graphics.Bitmap;
+
+public interface BitmapCaller {
+ public void available(Bitmap bmap);
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ColorChooser.java b/src/com/android/gallery3d/filtershow/controller/ColorChooser.java
new file mode 100644
index 0000000..f9f29bc
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ColorChooser.java
@@ -0,0 +1,177 @@
+package com.android.gallery3d.filtershow.controller;
+
+import android.app.ActionBar.LayoutParams;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.LinearLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.colorpicker.ColorListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorPickerDialog;
+import com.android.gallery3d.filtershow.editors.Editor;
+
+import java.util.Arrays;
+import java.util.Vector;
+
+public class ColorChooser implements Control {
+ private final String LOGTAG = "StyleChooser";
+ protected ParameterColor mParameter;
+ protected LinearLayout mLinearLayout;
+ protected Editor mEditor;
+ private View mTopView;
+ private Vector<Button> mIconButton = new Vector<Button>();
+ protected int mLayoutID = R.layout.filtershow_control_color_chooser;
+ Context mContext;
+ private int mTransparent;
+ private int mSelected;
+ private static final int OPACITY_OFFSET = 3;
+ private int[] mButtonsID = {
+ R.id.draw_color_button01,
+ R.id.draw_color_button02,
+ R.id.draw_color_button03,
+ R.id.draw_color_button04,
+ R.id.draw_color_button05,
+ };
+ private Button[] mButton = new Button[mButtonsID.length];
+
+ int mSelectedButton = 0;
+
+ @Override
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor) {
+ container.removeAllViews();
+ Resources res = container.getContext().getResources();
+ mTransparent = res.getColor(R.color.color_chooser_unslected_border);
+ mSelected = res.getColor(R.color.color_chooser_slected_border);
+ mEditor = editor;
+ mContext = container.getContext();
+ int iconDim = res.getDimensionPixelSize(R.dimen.draw_style_icon_dim);
+ mParameter = (ParameterColor) parameter;
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mTopView = inflater.inflate(mLayoutID, container, true);
+ mLinearLayout = (LinearLayout) mTopView.findViewById(R.id.listStyles);
+ mTopView.setVisibility(View.VISIBLE);
+
+ mIconButton.clear();
+ LayoutParams lp = new LayoutParams(iconDim, iconDim);
+ int [] palette = mParameter.getColorPalette();
+ for (int i = 0; i < mButtonsID.length; i++) {
+ final Button button = (Button) mTopView.findViewById(mButtonsID[i]);
+ mButton[i] = button;
+ float[] hsvo = new float[4];
+ Color.colorToHSV(palette[i], hsvo);
+ hsvo[OPACITY_OFFSET] = (0xFF & (palette[i] >> 24)) / (float) 255;
+ button.setTag(hsvo);
+ GradientDrawable sd = ((GradientDrawable) button.getBackground());
+ sd.setColor(palette[i]);
+ sd.setStroke(3, (mSelectedButton == i) ? mSelected : mTransparent);
+
+ final int buttonNo = i;
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ selectColor(arg0, buttonNo);
+ }
+ });
+ }
+ Button button = (Button) mTopView.findViewById(R.id.draw_color_popupbutton);
+
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ showColorPicker();
+ }
+ });
+
+ }
+
+ public void setColorSet(int[] basColors) {
+ int []palette = mParameter.getColorPalette();
+ for (int i = 0; i < palette.length; i++) {
+ palette[i] = basColors[i];
+ float[] hsvo = new float[4];
+ Color.colorToHSV(palette[i], hsvo);
+ hsvo[OPACITY_OFFSET] = (0xFF & (palette[i] >> 24)) / (float) 255;
+ mButton[i].setTag(hsvo);
+ GradientDrawable sd = ((GradientDrawable) mButton[i].getBackground());
+ sd.setColor(palette[i]);
+ }
+
+ }
+
+ public int[] getColorSet() {
+ return mParameter.getColorPalette();
+ }
+
+ private void resetBorders() {
+ int []palette = mParameter.getColorPalette();
+ for (int i = 0; i < mButtonsID.length; i++) {
+ final Button button = mButton[i];
+ GradientDrawable sd = ((GradientDrawable) button.getBackground());
+ sd.setColor(palette[i]);
+ sd.setStroke(3, (mSelectedButton == i) ? mSelected : mTransparent);
+ }
+ }
+
+ public void selectColor(View button, int buttonNo) {
+ mSelectedButton = buttonNo;
+ float[] hsvo = (float[]) button.getTag();
+ mParameter.setValue(Color.HSVToColor((int) (hsvo[OPACITY_OFFSET] * 255), hsvo));
+ resetBorders();
+ mEditor.commitLocalRepresentation();
+ }
+
+ @Override
+ public View getTopView() {
+ return mTopView;
+ }
+
+ @Override
+ public void setPrameter(Parameter parameter) {
+ mParameter = (ParameterColor) parameter;
+ updateUI();
+ }
+
+ @Override
+ public void updateUI() {
+ if (mParameter == null) {
+ return;
+ }
+ }
+
+ public void changeSelectedColor(float[] hsvo) {
+ int []palette = mParameter.getColorPalette();
+ int c = Color.HSVToColor((int) (hsvo[3] * 255), hsvo);
+ final Button button = mButton[mSelectedButton];
+ GradientDrawable sd = ((GradientDrawable) button.getBackground());
+ sd.setColor(c);
+ palette[mSelectedButton] = c;
+ mParameter.setValue(Color.HSVToColor((int) (hsvo[OPACITY_OFFSET] * 255), hsvo));
+ button.setTag(hsvo);
+ mEditor.commitLocalRepresentation();
+ button.invalidate();
+ }
+
+ public void showColorPicker() {
+ ColorListener cl = new ColorListener() {
+ @Override
+ public void setColor(float[] hsvo) {
+ changeSelectedColor(hsvo);
+ }
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
+ };
+ ColorPickerDialog cpd = new ColorPickerDialog(mContext, cl);
+ float[] c = (float[]) mButton[mSelectedButton].getTag();
+ cpd.setColor(Arrays.copyOf(c, 4));
+ cpd.setOrigColor(Arrays.copyOf(c, 4));
+ cpd.show();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/FilterView.java b/src/com/android/gallery3d/filtershow/controller/FilterView.java
index 2be7f36..9ca0e60 100644
--- a/src/com/android/gallery3d/filtershow/controller/FilterView.java
+++ b/src/com/android/gallery3d/filtershow/controller/FilterView.java
@@ -16,10 +16,10 @@
package com.android.gallery3d.filtershow.controller;
-import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
public interface FilterView {
- public void computeIcon(int index, RenderingRequestCaller caller);
+ public void computeIcon(int index, BitmapCaller caller);
public void commitLocalRepresentation();
}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterBrightness.java b/src/com/android/gallery3d/filtershow/controller/ParameterBrightness.java
new file mode 100644
index 0000000..669df93
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterBrightness.java
@@ -0,0 +1,40 @@
+/*
+ * 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.controller;
+
+public class ParameterBrightness extends BasicParameterInt {
+ public static String sParameterType = "ParameterBrightness";
+ float[] mHSVO = new float[4];
+
+ public ParameterBrightness(int id, int value) {
+ super(id, value, 0, 255);
+ }
+
+ @Override
+ public String getParameterType() {
+ return sParameterType;
+ }
+
+ public void setColor(float[] hsvo) {
+ mHSVO = hsvo;
+ }
+
+ public float[] getColor() {
+ mHSVO[3] = getValue() / (float) getMaximum();
+ return mHSVO;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterColor.java b/src/com/android/gallery3d/filtershow/controller/ParameterColor.java
new file mode 100644
index 0000000..0f1a658
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterColor.java
@@ -0,0 +1,115 @@
+/*
+ * 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.controller;
+
+import android.graphics.Color;
+
+import java.util.Arrays;
+
+public class ParameterColor implements Parameter {
+ public static String sParameterType = "ParameterColor";
+ protected Control mControl;
+ protected FilterView mEditor;
+ float[] mHSVO = new float[4];
+ String mParameterName;
+ int mValue;
+ public final int ID;
+ int[] mBasColors = {
+ Color.RED & 0x80FFFFFF,
+ Color.GREEN & 0x80FFFFFF,
+ Color.BLUE & 0x80FFFFFF,
+ Color.BLACK & 0x80FFFFFF,
+ Color.WHITE & 0x80FFFFFF
+ };
+
+ public ParameterColor(int id, int defaultColor) {
+ ID = id;
+ Color.colorToHSV(defaultColor, mHSVO);
+ mHSVO[3] = ((defaultColor >> 24) & 0xFF) / (float) 255;
+ }
+
+ @Override
+ public String getParameterType() {
+ return sParameterType;
+ }
+
+ public void setColor(float[] hsvo) {
+ mHSVO = hsvo;
+ mValue = Color.HSVToColor((int) (hsvo[3] * 255), mHSVO);
+ }
+
+ public float[] getColor() {
+ return mHSVO;
+ }
+
+ public void copyFrom(Parameter src) {
+ if (!(src instanceof ParameterColor)) {
+ throw new IllegalArgumentException(src.getClass().getName());
+ }
+ ParameterColor p = (ParameterColor) src;
+
+ mValue = p.mValue;
+ System.arraycopy(p.mHSVO, 0, mHSVO, 0, 4);
+ }
+
+ @Override
+ public String getParameterName() {
+ return mParameterName;
+ }
+
+ @Override
+ public String getValueString() {
+ return "(" + Integer.toHexString(mValue) + ")";
+ }
+
+ @Override
+ public void setController(Control control) {
+ mControl = control;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public void setValue(int value) {
+ mValue = value;
+ Color.colorToHSV(mValue, mHSVO);
+ mHSVO[3] = ((mValue >> 24) & 0xFF) / (float) 255;
+ }
+
+ @Override
+ public String toString() {
+ return getValueString();
+ }
+
+ @Override
+ public void setFilterView(FilterView editor) {
+ mEditor = editor;
+ }
+
+ public void copyPalletFrom(ParameterColor parameterColor) {
+ System.arraycopy(parameterColor.mBasColors,0,mBasColors,0,mBasColors.length);
+ }
+
+ public void setColorpalette(int[] palette) {
+ mBasColors = Arrays.copyOf(palette, palette.length);
+ }
+
+ public int[] getColorPalette() {
+ return mBasColors;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterHue.java b/src/com/android/gallery3d/filtershow/controller/ParameterHue.java
new file mode 100644
index 0000000..7682ec9
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterHue.java
@@ -0,0 +1,40 @@
+/*
+ * 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.controller;
+
+public class ParameterHue extends BasicParameterInt {
+ public static String sParameterType = "ParameterHue";
+ float[] mHSVO = new float[4];
+
+ public ParameterHue(int id, int value) {
+ super(id, value, 0, 360);
+ }
+
+ @Override
+ public String getParameterType() {
+ return sParameterType;
+ }
+
+ public void setColor(float[] hsvo) {
+ mHSVO = hsvo;
+ }
+
+ public float[] getColor() {
+ mHSVO[3] = getValue() / (float) getMaximum();
+ return mHSVO;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterIconStyle.java b/src/com/android/gallery3d/filtershow/controller/ParameterIconStyle.java
new file mode 100644
index 0000000..a26ee65
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterIconStyle.java
@@ -0,0 +1,33 @@
+/*
+ * 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.controller;
+
+import android.graphics.Bitmap;
+
+public class ParameterIconStyle extends BasicParameterStyle {
+ Bitmap[] mBitmaps;
+
+ public ParameterIconStyle(int id, Bitmap[] styles) {
+ super(id, styles.length);
+ mBitmaps = styles;
+ }
+
+ @Override
+ public void getIcon(int index, BitmapCaller caller) {
+ caller.available(mBitmaps[index]);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterOpacity.java b/src/com/android/gallery3d/filtershow/controller/ParameterOpacity.java
new file mode 100644
index 0000000..aecbf4a
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterOpacity.java
@@ -0,0 +1,39 @@
+/*
+ * 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.controller;
+
+public class ParameterOpacity extends BasicParameterInt {
+ public static String sParameterType = "ParameterOpacity";
+ float[] mHSVO = new float[4];
+
+ public ParameterOpacity(int id, int value) {
+ super(id, value, 0, 255);
+ }
+
+ @Override
+ public String getParameterType() {
+ return sParameterType;
+ }
+
+ public void setColor(float[] hsvo) {
+ mHSVO = hsvo;
+ }
+
+ public float[] getColor() {
+ mHSVO[3] = getValue() / (float) getMaximum();
+ return mHSVO;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterSaturation.java b/src/com/android/gallery3d/filtershow/controller/ParameterSaturation.java
new file mode 100644
index 0000000..a6a4cb1
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterSaturation.java
@@ -0,0 +1,40 @@
+/*
+ * 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.controller;
+
+public class ParameterSaturation extends BasicParameterInt {
+ public static String sParameterType = "ParameterSaturation";
+ float[] mHSVO = new float[4];
+
+ public ParameterSaturation(int id, int value) {
+ super(id, value, 0, 100);
+ }
+
+ @Override
+ public String getParameterType() {
+ return sParameterType;
+ }
+
+ public void setColor(float[] hsvo) {
+ mHSVO = hsvo;
+ }
+
+ public float[] getColor() {
+ mHSVO[3] = getValue() / (float) getMaximum();
+ return mHSVO;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterStyles.java b/src/com/android/gallery3d/filtershow/controller/ParameterStyles.java
index c267d3d..91d5a00 100644
--- a/src/com/android/gallery3d/filtershow/controller/ParameterStyles.java
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterStyles.java
@@ -18,7 +18,7 @@
import android.content.Context;
-import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
public interface ParameterStyles extends Parameter {
public static String sParameterType = "ParameterStyles";
@@ -31,7 +31,7 @@
void setSelected(int value);
- void getIcon(int index, RenderingRequestCaller caller);
+ void getIcon(int index, BitmapCaller caller);
String getStyleTitle(int index, Context context);
}
diff --git a/src/com/android/gallery3d/filtershow/controller/SliderBrightness.java b/src/com/android/gallery3d/filtershow/controller/SliderBrightness.java
new file mode 100644
index 0000000..2929d68
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/SliderBrightness.java
@@ -0,0 +1,78 @@
+/*
+ * 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.controller;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.colorpicker.ColorBrightnessView;
+import com.android.gallery3d.filtershow.colorpicker.ColorListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorOpacityView;
+import com.android.gallery3d.filtershow.editors.Editor;
+
+public class SliderBrightness implements Control {
+ private ColorBrightnessView mColorOpacityView;
+ private ParameterBrightness mParameter;
+ Editor mEditor;
+
+ @Override
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor) {
+ container.removeAllViews();
+ mEditor = editor;
+ Context context = container.getContext();
+ mParameter = (ParameterBrightness) parameter;
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_brightness, container, true);
+
+ mColorOpacityView = (ColorBrightnessView) lp.findViewById(R.id.brightnessView);
+ updateUI();
+ mColorOpacityView.addColorListener(new ColorListener() {
+ @Override
+ public void setColor(float[] hsvo) {
+ mParameter.setValue((int)(255* hsvo[3]));
+ mEditor.commitLocalRepresentation();
+ }
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
+ });
+ }
+
+ @Override
+ public View getTopView() {
+ return mColorOpacityView;
+ }
+
+ @Override
+ public void setPrameter(Parameter parameter) {
+ mParameter = (ParameterBrightness) parameter;
+ if (mColorOpacityView != null) {
+ updateUI();
+ }
+ }
+
+ @Override
+ public void updateUI() {
+ mColorOpacityView.setColor(mParameter.getColor());
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/SliderHue.java b/src/com/android/gallery3d/filtershow/controller/SliderHue.java
new file mode 100644
index 0000000..1820ce2
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/SliderHue.java
@@ -0,0 +1,89 @@
+/*
+ * 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.controller;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.LinearGradient;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.graphics.Shader;
+import android.graphics.drawable.Drawable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.app.Log;
+import com.android.gallery3d.filtershow.colorpicker.ColorHueView;
+import com.android.gallery3d.filtershow.colorpicker.ColorListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorOpacityView;
+import com.android.gallery3d.filtershow.editors.Editor;
+
+public class SliderHue implements Control {
+ public static String LOGTAG = "SliderHue";
+ private ColorHueView mColorOpacityView;
+ private ParameterHue mParameter;
+ Editor mEditor;
+
+ @Override
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor) {
+ container.removeAllViews();
+ mEditor = editor;
+ Context context = container.getContext();
+ mParameter = (ParameterHue) parameter;
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_hue, container, true);
+
+ mColorOpacityView = (ColorHueView) lp.findViewById(R.id.hueView);
+ updateUI();
+ mColorOpacityView.addColorListener(new ColorListener() {
+ @Override
+ public void setColor(float[] hsvo) {
+ mParameter.setValue((int)(360* hsvo[3]));
+ mEditor.commitLocalRepresentation();
+ }
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
+ });
+ }
+
+ @Override
+ public View getTopView() {
+ return mColorOpacityView;
+ }
+
+ @Override
+ public void setPrameter(Parameter parameter) {
+ mParameter = (ParameterHue) parameter;
+ if (mColorOpacityView != null) {
+ updateUI();
+ }
+ }
+
+ @Override
+ public void updateUI() {
+ mColorOpacityView.setColor(mParameter.getColor());
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/SliderOpacity.java b/src/com/android/gallery3d/filtershow/controller/SliderOpacity.java
new file mode 100644
index 0000000..2a34aad
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/SliderOpacity.java
@@ -0,0 +1,79 @@
+/*
+ * 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.controller;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.colorpicker.ColorListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorOpacityView;
+import com.android.gallery3d.filtershow.editors.Editor;
+
+public class SliderOpacity implements Control {
+ private ColorOpacityView mColorOpacityView;
+ private ParameterOpacity mParameter;
+ private Editor mEditor;
+
+ @Override
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor) {
+ container.removeAllViews();
+ mEditor = editor;
+ Context context = container.getContext();
+ mParameter = (ParameterOpacity) parameter;
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_opacity, container, true);
+
+ mColorOpacityView = (ColorOpacityView) lp.findViewById(R.id.opacityView);
+ updateUI();
+ mColorOpacityView.addColorListener(new ColorListener() {
+ @Override
+ public void setColor(float[] hsvo) {
+ mParameter.setValue((int) (255 * hsvo[3]));
+ mEditor.commitLocalRepresentation();
+ }
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
+ });
+ }
+
+ @Override
+ public View getTopView() {
+ return mColorOpacityView;
+ }
+
+ @Override
+ public void setPrameter(Parameter parameter) {
+ mParameter = (ParameterOpacity) parameter;
+ if (mColorOpacityView != null) {
+ updateUI();
+ }
+ }
+
+ @Override
+ public void updateUI() {
+ mColorOpacityView.setColor(mParameter.getColor());
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/SliderSaturation.java b/src/com/android/gallery3d/filtershow/controller/SliderSaturation.java
new file mode 100644
index 0000000..6f3ae6e
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/SliderSaturation.java
@@ -0,0 +1,80 @@
+/*
+ * 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.controller;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.colorpicker.ColorListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorOpacityView;
+import com.android.gallery3d.filtershow.colorpicker.ColorSaturationView;
+import com.android.gallery3d.filtershow.editors.Editor;
+
+public class SliderSaturation implements Control {
+ private ColorSaturationView mColorOpacityView;
+ private ParameterSaturation mParameter;
+ private Editor mEditor;
+
+ @Override
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor) {
+ container.removeAllViews();
+ mEditor = editor;
+ Context context = container.getContext();
+ mParameter = (ParameterSaturation) parameter;
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_saturation, container, true);
+
+ mColorOpacityView = (ColorSaturationView) lp.findViewById(R.id.saturationView);
+ updateUI();
+ mColorOpacityView.addColorListener(new ColorListener() {
+ @Override
+ public void setColor(float[] hsvo) {
+ mParameter.setValue((int) (255 * hsvo[3]));
+ mEditor.commitLocalRepresentation();
+ }
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
+ });
+ }
+
+ @Override
+ public View getTopView() {
+ return mColorOpacityView;
+ }
+
+ @Override
+ public void setPrameter(Parameter parameter) {
+ mParameter = (ParameterSaturation) parameter;
+ if (mColorOpacityView != null) {
+ updateUI();
+ }
+ }
+
+ @Override
+ public void updateUI() {
+ mColorOpacityView.setColor(mParameter.getColor());
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/StyleChooser.java b/src/com/android/gallery3d/filtershow/controller/StyleChooser.java
index b3d0de7..f5afec9 100644
--- a/src/com/android/gallery3d/filtershow/controller/StyleChooser.java
+++ b/src/com/android/gallery3d/filtershow/controller/StyleChooser.java
@@ -2,6 +2,7 @@
import android.app.ActionBar.LayoutParams;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
@@ -11,8 +12,8 @@
import android.widget.LinearLayout;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.cache.RenderingRequest;
-import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequest;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
import com.android.gallery3d.filtershow.editors.Editor;
import java.util.Vector;
@@ -39,7 +40,9 @@
mTopView.setVisibility(View.VISIBLE);
int n = mParameter.getNumberOfStyles();
mIconButton.clear();
- LayoutParams lp = new LayoutParams(120, 120);
+ Resources res = context.getResources();
+ int dim = res.getDimensionPixelSize(R.dimen.draw_style_icon_dim);
+ LayoutParams lp = new LayoutParams(dim, dim);
for (int i = 0; i < n; i++) {
final ImageButton button = new ImageButton(context);
button.setScaleType(ScaleType.CENTER_CROP);
@@ -54,10 +57,10 @@
}
});
mLinearLayout.addView(button);
- mParameter.getIcon(i, new RenderingRequestCaller() {
+ mParameter.getIcon(i, new BitmapCaller() {
@Override
- public void available(RenderingRequest request) {
- Bitmap bmap = request.getBitmap();
+ public void available(Bitmap bmap) {
+
if (bmap == null) {
return;
}
diff --git a/src/com/android/gallery3d/filtershow/crop/BoundedRect.java b/src/com/android/gallery3d/filtershow/crop/BoundedRect.java
index 74ce7cd..13b8d6d 100644
--- a/src/com/android/gallery3d/filtershow/crop/BoundedRect.java
+++ b/src/com/android/gallery3d/filtershow/crop/BoundedRect.java
@@ -19,7 +19,7 @@
import android.graphics.Rect;
import android.graphics.RectF;
-import com.android.gallery3d.filtershow.imageshow.GeometryMath;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
import java.util.Arrays;
@@ -134,7 +134,7 @@
};
float[] nearestSide = CropMath.closestSide(badCorner, outerCorners);
float[] correctionVec =
- GeometryMath.shortestVectorFromPointToLine(badCorner, nearestSide);
+ GeometryMathUtils.shortestVectorFromPointToLine(badCorner, nearestSide);
correction[0] += correctionVec[0];
correction[1] += correctionVec[1];
}
@@ -195,7 +195,7 @@
newInnerCorners[i], newInnerCorners[i + 1],
oldInnerCorners[i], oldInnerCorners[i + 1]
};
- float[] p = GeometryMath.lineIntersect(pathOfCorner, outerSide);
+ float[] p = GeometryMathUtils.lineIntersect(pathOfCorner, outerSide);
if (p == null) {
// lines are parallel or not well defined, so don't resize
p = new float[2];
@@ -288,7 +288,7 @@
newInnerCorners[i], newInnerCorners[i + 1],
oldInnerCorners[i], oldInnerCorners[i + 1]
};
- float[] p = GeometryMath.lineIntersect(l1, l2);
+ float[] p = GeometryMathUtils.lineIntersect(l1, l2);
if (p == null) {
// lines are parallel or not well defined, so set to old
// corner
diff --git a/src/com/android/gallery3d/filtershow/crop/CropActivity.java b/src/com/android/gallery3d/filtershow/crop/CropActivity.java
index d349d5d..3a78296 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropActivity.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropActivity.java
@@ -44,6 +44,8 @@
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.tools.SaveImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -104,17 +106,18 @@
mCropView = (CropView) findViewById(R.id.cropView);
ActionBar actionBar = getActionBar();
- actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
- actionBar.setCustomView(R.layout.filtershow_actionbar);
+ if (actionBar != null) {
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
+ actionBar.setCustomView(R.layout.filtershow_actionbar);
- View mSaveButton = actionBar.getCustomView();
- mSaveButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- startFinishOutput();
- }
- });
-
+ View mSaveButton = actionBar.getCustomView();
+ mSaveButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ startFinishOutput();
+ }
+ });
+ }
if (intent.getData() != null) {
mSourceUri = intent.getData();
startLoadBitmap(mSourceUri);
@@ -261,9 +264,9 @@
@Override
protected Bitmap doInBackground(Uri... params) {
Uri uri = params[0];
- Bitmap bmap = CropLoader.getConstrainedBitmap(uri, mContext, mBitmapSize,
- mOriginalBounds);
- mOrientation = CropLoader.getMetadataRotation(uri, mContext);
+ Bitmap bmap = ImageLoader.loadConstrainedBitmap(uri, mContext, mBitmapSize,
+ mOriginalBounds, false);
+ mOrientation = ImageLoader.getMetadataRotation(mContext, uri);
return bmap;
}
@@ -273,7 +276,7 @@
}
}
- private void startFinishOutput() {
+ protected void startFinishOutput() {
if (finalIOGuard) {
return;
} else {
@@ -297,7 +300,7 @@
}
}
if (flags == 0) {
- destinationUri = CropLoader.makeAndInsertUri(this, mSourceUri);
+ destinationUri = SaveImage.makeAndInsertUri(this, mSourceUri);
if (destinationUri != null) {
flags |= DO_EXTRA_OUTPUT;
}
diff --git a/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java b/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java
index b0d324c..df0f14f 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java
@@ -54,6 +54,24 @@
canvas.drawRect(bounds, p);
}
+ public static void drawShade(Canvas canvas, RectF bounds) {
+ int w = canvas.getWidth();
+ int h = canvas.getHeight();
+ Paint p = new Paint();
+ p.setStyle(Paint.Style.FILL);
+ p.setColor(Color.BLACK & 0x88000000);
+
+ RectF r = new RectF();
+ r.set(0,0,w,bounds.top);
+ canvas.drawRect(r, p);
+ r.set(0,bounds.top,bounds.left,h);
+ canvas.drawRect(r, p);
+ r.set(bounds.left,bounds.bottom,w,h);
+ canvas.drawRect(r, p);
+ r.set(bounds.right,bounds.top,w,bounds.bottom);
+ canvas.drawRect(r, p);
+ }
+
public static void drawIndicator(Canvas canvas, Drawable indicator, int indicatorSize,
float centerX, float centerY) {
int left = (int) centerX - indicatorSize / 2;
diff --git a/src/com/android/gallery3d/filtershow/crop/CropLoader.java b/src/com/android/gallery3d/filtershow/crop/CropLoader.java
deleted file mode 100644
index 430647e..0000000
--- a/src/com/android/gallery3d/filtershow/crop/CropLoader.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * 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.crop;
-
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteException;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Rect;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.provider.MediaStore.Images;
-import android.provider.MediaStore.Images.ImageColumns;
-import android.util.Log;
-
-import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.exif.ExifInterface;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * This class contains static methods for loading a bitmap and
- * maintains no instance state.
- */
-public abstract class CropLoader {
- public static final String LOGTAG = "CropLoader";
- public static final String JPEG_MIME_TYPE = "image/jpeg";
-
- private static final String TIME_STAMP_NAME = "'IMG'_yyyyMMdd_HHmmss";
- public static final String DEFAULT_SAVE_DIRECTORY = "EditedOnlinePhotos";
-
- /**
- * Returns the orientation of image at the given URI as one of 0, 90, 180,
- * 270.
- *
- * @param uri URI of image to open.
- * @param context context whose ContentResolver to use.
- * @return the orientation of the image. Defaults to 0.
- */
- public static int getMetadataRotation(Uri uri, Context context) {
- if (uri == null || context == null) {
- throw new IllegalArgumentException("bad argument to getScaledBitmap");
- }
- if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
- String mimeType = context.getContentResolver().getType(uri);
- if (mimeType != JPEG_MIME_TYPE) {
- return 0;
- }
- String path = uri.getPath();
- int orientation = 0;
- ExifInterface exif = new ExifInterface();
- try {
- exif.readExif(path);
- orientation = ExifInterface.getRotationForOrientationValue(
- exif.getTagIntValue(ExifInterface.TAG_ORIENTATION).shortValue());
- } catch (IOException e) {
- Log.w(LOGTAG, "Failed to read EXIF orientation", e);
- }
- return orientation;
- }
- Cursor cursor = null;
- try {
- cursor = context.getContentResolver().query(uri,
- new String[] { MediaStore.Images.ImageColumns.ORIENTATION },
- null, null, null);
- if (cursor.moveToNext()) {
- int ori = cursor.getInt(0);
- return (ori < 0) ? 0 : ori;
- }
- } catch (SQLiteException e) {
- return 0;
- } catch (IllegalArgumentException e) {
- return 0;
- } finally {
- Utils.closeSilently(cursor);
- }
- return 0;
- }
-
- /**
- * Gets a bitmap at a given URI that is downsampled so that both sides are
- * smaller than maxSideLength. The Bitmap's original dimensions are stored
- * in the rect originalBounds.
- *
- * @param uri URI of image to open.
- * @param context context whose ContentResolver to use.
- * @param maxSideLength max side length of returned bitmap.
- * @param originalBounds set to the actual bounds of the stored bitmap.
- * @return downsampled bitmap or null if this operation failed.
- */
- public static Bitmap getConstrainedBitmap(Uri uri, Context context, int maxSideLength,
- Rect originalBounds) {
- if (maxSideLength <= 0 || originalBounds == null || uri == null || context == null) {
- throw new IllegalArgumentException("bad argument to getScaledBitmap");
- }
- InputStream is = null;
- try {
- // Get width and height of stored bitmap
- is = context.getContentResolver().openInputStream(uri);
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inJustDecodeBounds = true;
- BitmapFactory.decodeStream(is, null, options);
- int w = options.outWidth;
- int h = options.outHeight;
- originalBounds.set(0, 0, w, h);
-
- // If bitmap cannot be decoded, return null
- if (w <= 0 || h <= 0) {
- return null;
- }
-
- options = new BitmapFactory.Options();
-
- // Find best downsampling size
- int imageSide = Math.max(w, h);
- options.inSampleSize = 1;
- if (imageSide > maxSideLength) {
- int shifts = 1 + Integer.numberOfLeadingZeros(maxSideLength)
- - Integer.numberOfLeadingZeros(imageSide);
- options.inSampleSize <<= shifts;
- }
-
- // Make sure sample size is reasonable
- if (options.inSampleSize <= 0 ||
- 0 >= (int) (Math.min(w, h) / options.inSampleSize)) {
- return null;
- }
-
- // Decode actual bitmap.
- options.inMutable = true;
- is.close();
- is = context.getContentResolver().openInputStream(uri);
- return BitmapFactory.decodeStream(is, null, options);
- } catch (FileNotFoundException e) {
- Log.e(LOGTAG, "FileNotFoundException: " + uri, e);
- } catch (IOException e) {
- Log.e(LOGTAG, "IOException: " + uri, e);
- } finally {
- Utils.closeSilently(is);
- }
- return null;
- }
-
- /**
- * Gets a bitmap that has been downsampled using sampleSize.
- *
- * @param uri URI of image to open.
- * @param context context whose ContentResolver to use.
- * @param sampleSize downsampling amount.
- * @return downsampled bitmap.
- */
- public static Bitmap getBitmap(Uri uri, Context context, int sampleSize) {
- if (uri == null || context == null) {
- throw new IllegalArgumentException("bad argument to getScaledBitmap");
- }
- InputStream is = null;
- try {
- is = context.getContentResolver().openInputStream(uri);
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inMutable = true;
- options.inSampleSize = sampleSize;
- return BitmapFactory.decodeStream(is, null, options);
- } catch (FileNotFoundException e) {
- Log.e(LOGTAG, "FileNotFoundException: " + uri, e);
- } finally {
- Utils.closeSilently(is);
- }
- return null;
- }
-
- // TODO: Super gnarly (copied from SaveCopyTask.java), do cleanup.
-
- public static File getFinalSaveDirectory(Context context, Uri sourceUri) {
- File saveDirectory = getSaveDirectory(context, sourceUri);
- if ((saveDirectory == null) || !saveDirectory.canWrite()) {
- saveDirectory = new File(Environment.getExternalStorageDirectory(),
- DEFAULT_SAVE_DIRECTORY);
- }
- // Create the directory if it doesn't exist
- if (!saveDirectory.exists())
- saveDirectory.mkdirs();
- return saveDirectory;
- }
-
-
-
- public static String getNewFileName(long time) {
- return new SimpleDateFormat(TIME_STAMP_NAME).format(new Date(time));
- }
-
- public static File getNewFile(Context context, Uri sourceUri, String filename) {
- File saveDirectory = getFinalSaveDirectory(context, sourceUri);
- return new File(saveDirectory, filename + ".JPG");
- }
-
- private interface ContentResolverQueryCallback {
-
- void onCursorResult(Cursor cursor);
- }
-
- private static void querySource(Context context, Uri sourceUri, String[] projection,
- ContentResolverQueryCallback callback) {
- ContentResolver contentResolver = context.getContentResolver();
- Cursor cursor = null;
- try {
- cursor = contentResolver.query(sourceUri, projection, null, null,
- null);
- if ((cursor != null) && cursor.moveToNext()) {
- callback.onCursorResult(cursor);
- }
- } catch (Exception e) {
- // Ignore error for lacking the data column from the source.
- } finally {
- if (cursor != null) {
- cursor.close();
- }
- }
- }
-
- private static File getSaveDirectory(Context context, Uri sourceUri) {
- final File[] dir = new File[1];
- querySource(context, sourceUri, new String[] {
- ImageColumns.DATA }, new ContentResolverQueryCallback() {
- @Override
- public void onCursorResult(Cursor cursor) {
- dir[0] = new File(cursor.getString(0)).getParentFile();
- }
- });
- return dir[0];
- }
-
- public static Uri insertContent(Context context, Uri sourceUri, File file, String saveFileName,
- long time) {
- time /= 1000;
-
- final ContentValues values = new ContentValues();
- values.put(Images.Media.TITLE, saveFileName);
- values.put(Images.Media.DISPLAY_NAME, file.getName());
- values.put(Images.Media.MIME_TYPE, "image/jpeg");
- values.put(Images.Media.DATE_TAKEN, time);
- values.put(Images.Media.DATE_MODIFIED, time);
- values.put(Images.Media.DATE_ADDED, time);
- values.put(Images.Media.ORIENTATION, 0);
- values.put(Images.Media.DATA, file.getAbsolutePath());
- values.put(Images.Media.SIZE, file.length());
-
- final String[] projection = new String[] {
- ImageColumns.DATE_TAKEN,
- ImageColumns.LATITUDE, ImageColumns.LONGITUDE,
- };
- querySource(context, sourceUri, projection,
- new ContentResolverQueryCallback() {
-
- @Override
- public void onCursorResult(Cursor cursor) {
- values.put(Images.Media.DATE_TAKEN, cursor.getLong(0));
-
- double latitude = cursor.getDouble(1);
- double longitude = cursor.getDouble(2);
- // TODO: Change || to && after the default location
- // issue is fixed.
- if ((latitude != 0f) || (longitude != 0f)) {
- values.put(Images.Media.LATITUDE, latitude);
- values.put(Images.Media.LONGITUDE, longitude);
- }
- }
- });
-
- return context.getContentResolver().insert(
- Images.Media.EXTERNAL_CONTENT_URI, values);
- }
-
- public static Uri makeAndInsertUri(Context context, Uri sourceUri) {
- long time = System.currentTimeMillis();
- String filename = getNewFileName(time);
- File file = getNewFile(context, sourceUri, filename);
- return insertContent(context, sourceUri, file, filename, time);
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/crop/CropMath.java b/src/com/android/gallery3d/filtershow/crop/CropMath.java
index 849ac60..02c6531 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropMath.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropMath.java
@@ -20,7 +20,7 @@
import android.graphics.Matrix;
import android.graphics.RectF;
-import com.android.gallery3d.filtershow.imageshow.GeometryMath;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
import java.util.Arrays;
@@ -97,8 +97,8 @@
if (array.length < 2)
return;
for (int x = 0; x < array.length; x += 2) {
- array[x] = GeometryMath.clamp(array[x], imageBound.left, imageBound.right);
- array[x + 1] = GeometryMath.clamp(array[x + 1], imageBound.top, imageBound.bottom);
+ array[x] = GeometryMathUtils.clamp(array[x], imageBound.left, imageBound.right);
+ array[x + 1] = GeometryMathUtils.clamp(array[x + 1], imageBound.top, imageBound.bottom);
}
}
@@ -119,8 +119,8 @@
corners[i], corners[(i + 1) % len],
corners[(i + 2) % len], corners[(i + 3) % len]
};
- float mag = GeometryMath.vectorLength(
- GeometryMath.shortestVectorFromPointToLine(point, line));
+ float mag = GeometryMathUtils.vectorLength(
+ GeometryMathUtils.shortestVectorFromPointToLine(point, line));
if (mag < oldMag) {
oldMag = mag;
bestLine = line;
@@ -196,14 +196,13 @@
float finalH = origH;
if (origA < a) {
finalH = origW / a;
+ r.top = r.centerY() - finalH / 2;
+ r.bottom = r.top + finalH;
} else {
finalW = origH * a;
+ r.left = r.centerX() - finalW / 2;
+ r.right = r.left + finalW;
}
- float centX = r.centerX();
- float centY = r.centerY();
- float hw = finalW / 2;
- float hh = finalH / 2;
- r.set(centX - hw, centY - hh, centX + hw, centY + hh);
}
/**
diff --git a/src/com/android/gallery3d/filtershow/crop/CropObject.java b/src/com/android/gallery3d/filtershow/crop/CropObject.java
index bea3ffa..b98ed1b 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropObject.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropObject.java
@@ -19,10 +19,9 @@
import android.graphics.Rect;
import android.graphics.RectF;
-import com.android.gallery3d.filtershow.imageshow.GeometryMath;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
public class CropObject {
-
private BoundedRect mBoundedRect;
private float mAspectWidth = 1;
private float mAspectHeight = 1;
@@ -234,8 +233,8 @@
float[] disp = {
dx, dy
};
- float[] bUnit = GeometryMath.normalize(b);
- float sp = GeometryMath.scalarProjection(disp, bUnit);
+ float[] bUnit = GeometryMathUtils.normalize(b);
+ float sp = GeometryMathUtils.scalarProjection(disp, bUnit);
dx = sp * bUnit[0];
dy = sp * bUnit[1];
RectF newCrop = fixedCornerResize(crop, movingEdges, dx, dy);
diff --git a/src/com/android/gallery3d/filtershow/crop/CropView.java b/src/com/android/gallery3d/filtershow/crop/CropView.java
index 87e4542..bbb7cfd 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropView.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropView.java
@@ -20,7 +20,6 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Matrix;
import android.graphics.Paint;
@@ -50,8 +49,8 @@
private NinePatchDrawable mShadow;
private CropObject mCropObj = null;
- private final Drawable mCropIndicator;
- private final int mIndicatorSize;
+ private Drawable mCropIndicator;
+ private int mIndicatorSize;
private int mRotation = 0;
private boolean mMovingBlock = false;
private Matrix mDisplayMatrix = null;
@@ -80,8 +79,22 @@
private Mode mState = Mode.NONE;
+ public CropView(Context context) {
+ super(context);
+ setup(context);
+ }
+
public CropView(Context context, AttributeSet attrs) {
super(context, attrs);
+ setup(context);
+ }
+
+ public CropView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ setup(context);
+ }
+
+ private void setup(Context context) {
Resources rsc = context.getResources();
mShadow = (NinePatchDrawable) rsc.getDrawable(R.drawable.geometry_shadow);
mCropIndicator = rsc.getDrawable(R.drawable.camera_crop);
@@ -327,6 +340,8 @@
mShadow.draw(canvas);
}
+ mPaint.setAntiAlias(true);
+ mPaint.setFilterBitmap(true);
// Draw actual bitmap
canvas.drawBitmap(mBitmap, mDisplayMatrix, mPaint);
diff --git a/src/com/android/gallery3d/filtershow/data/FilterStackDBHelper.java b/src/com/android/gallery3d/filtershow/data/FilterStackDBHelper.java
new file mode 100644
index 0000000..e18d310
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/data/FilterStackDBHelper.java
@@ -0,0 +1,101 @@
+/*
+ * 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.data;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+public class FilterStackDBHelper extends SQLiteOpenHelper {
+
+ public static final int DATABASE_VERSION = 1;
+ public static final String DATABASE_NAME = "filterstacks.db";
+ private static final String SQL_CREATE_TABLE = "CREATE TABLE ";
+
+ public static interface FilterStack {
+ /** The row uid */
+ public static final String _ID = "_id";
+ /** The table name */
+ public static final String TABLE = "filterstack";
+ /** The stack name */
+ public static final String STACK_ID = "stack_id";
+ /** A serialized stack of filters. */
+ public static final String FILTER_STACK= "stack";
+ }
+
+ private static final String[][] CREATE_FILTER_STACK = {
+ { FilterStack._ID, "INTEGER PRIMARY KEY AUTOINCREMENT" },
+ { FilterStack.STACK_ID, "TEXT" },
+ { FilterStack.FILTER_STACK, "BLOB" },
+ };
+
+ public FilterStackDBHelper(Context context, String name, int version) {
+ super(context, name, null, version);
+ }
+
+ public FilterStackDBHelper(Context context, String name) {
+ this(context, name, DATABASE_VERSION);
+ }
+
+ public FilterStackDBHelper(Context context) {
+ this(context, DATABASE_NAME);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ createTable(db, FilterStack.TABLE, CREATE_FILTER_STACK);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ dropTable(db, FilterStack.TABLE);
+ onCreate(db);
+ }
+
+ protected static void createTable(SQLiteDatabase db, String table, String[][] columns) {
+ StringBuilder create = new StringBuilder(SQL_CREATE_TABLE);
+ create.append(table).append('(');
+ boolean first = true;
+ for (String[] column : columns) {
+ if (!first) {
+ create.append(',');
+ }
+ first = false;
+ for (String val : column) {
+ create.append(val).append(' ');
+ }
+ }
+ create.append(')');
+ db.beginTransaction();
+ try {
+ db.execSQL(create.toString());
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ }
+
+ protected static void dropTable(SQLiteDatabase db, String table) {
+ db.beginTransaction();
+ try {
+ db.execSQL("drop table if exists " + table);
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/data/FilterStackSource.java b/src/com/android/gallery3d/filtershow/data/FilterStackSource.java
new file mode 100644
index 0000000..d283771
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/data/FilterStackSource.java
@@ -0,0 +1,197 @@
+/*
+ * 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.data;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteException;
+import android.util.Log;
+import android.util.Pair;
+
+import com.android.gallery3d.filtershow.data.FilterStackDBHelper.FilterStack;
+import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class FilterStackSource {
+ private static final String LOGTAG = "FilterStackSource";
+
+ private SQLiteDatabase database = null;
+ private final FilterStackDBHelper dbHelper;
+
+ public FilterStackSource(Context context) {
+ dbHelper = new FilterStackDBHelper(context);
+ }
+
+ public void open() {
+ try {
+ database = dbHelper.getWritableDatabase();
+ } catch (SQLiteException e) {
+ Log.w(LOGTAG, "could not open database", e);
+ }
+ }
+
+ public void close() {
+ database = null;
+ dbHelper.close();
+ }
+
+ public boolean insertStack(String stackName, byte[] stackBlob) {
+ boolean ret = true;
+ ContentValues val = new ContentValues();
+ val.put(FilterStack.STACK_ID, stackName);
+ val.put(FilterStack.FILTER_STACK, stackBlob);
+ database.beginTransaction();
+ try {
+ ret = (-1 != database.insert(FilterStack.TABLE, null, val));
+ database.setTransactionSuccessful();
+ } finally {
+ database.endTransaction();
+ }
+ return ret;
+ }
+
+ public void updateStackName(int id, String stackName) {
+ ContentValues val = new ContentValues();
+ val.put(FilterStack.STACK_ID, stackName);
+ database.beginTransaction();
+ try {
+ database.update(FilterStack.TABLE, val, FilterStack._ID + " = ?",
+ new String[] { "" + id});
+ database.setTransactionSuccessful();
+ } finally {
+ database.endTransaction();
+ }
+ }
+
+ public boolean removeStack(int id) {
+ boolean ret = true;
+ database.beginTransaction();
+ try {
+ ret = (0 != database.delete(FilterStack.TABLE, FilterStack._ID + " = ?",
+ new String[] { "" + id }));
+ database.setTransactionSuccessful();
+ } finally {
+ database.endTransaction();
+ }
+ return ret;
+ }
+
+ public void removeAllStacks() {
+ database.beginTransaction();
+ try {
+ database.delete(FilterStack.TABLE, null, null);
+ database.setTransactionSuccessful();
+ } finally {
+ database.endTransaction();
+ }
+ }
+
+ public byte[] getStack(String stackName) {
+ byte[] ret = null;
+ Cursor c = null;
+ database.beginTransaction();
+ try {
+ c = database.query(FilterStack.TABLE,
+ new String[] { FilterStack.FILTER_STACK },
+ FilterStack.STACK_ID + " = ?",
+ new String[] { stackName }, null, null, null, null);
+ if (c != null && c.moveToFirst() && !c.isNull(0)) {
+ ret = c.getBlob(0);
+ }
+ database.setTransactionSuccessful();
+ } finally {
+ if (c != null) {
+ c.close();
+ }
+ database.endTransaction();
+ }
+ return ret;
+ }
+
+ public ArrayList<FilterUserPresetRepresentation> getAllUserPresets() {
+ ArrayList<FilterUserPresetRepresentation> ret =
+ new ArrayList<FilterUserPresetRepresentation>();
+
+ Cursor c = null;
+ database.beginTransaction();
+ try {
+ c = database.query(FilterStack.TABLE,
+ new String[] { FilterStack._ID,
+ FilterStack.STACK_ID,
+ FilterStack.FILTER_STACK },
+ null, null, null, null, null, null);
+ if (c != null) {
+ boolean loopCheck = c.moveToFirst();
+ while (loopCheck) {
+ int id = c.getInt(0);
+ String name = (c.isNull(1)) ? null : c.getString(1);
+ byte[] b = (c.isNull(2)) ? null : c.getBlob(2);
+ String json = new String(b);
+
+ ImagePreset preset = new ImagePreset();
+ preset.readJsonFromString(json);
+ FilterUserPresetRepresentation representation =
+ new FilterUserPresetRepresentation(name, preset, id);
+ ret.add(representation);
+ loopCheck = c.moveToNext();
+ }
+ }
+ database.setTransactionSuccessful();
+ } finally {
+ if (c != null) {
+ c.close();
+ }
+ database.endTransaction();
+ }
+
+ return ret;
+ }
+
+ public List<Pair<String, byte[]>> getAllStacks() {
+ List<Pair<String, byte[]>> ret = new ArrayList<Pair<String, byte[]>>();
+ Cursor c = null;
+ database.beginTransaction();
+ try {
+ c = database.query(FilterStack.TABLE,
+ new String[] { FilterStack.STACK_ID, FilterStack.FILTER_STACK },
+ null, null, null, null, null, null);
+ if (c != null) {
+ boolean loopCheck = c.moveToFirst();
+ while (loopCheck) {
+ String name = (c.isNull(0)) ? null : c.getString(0);
+ byte[] b = (c.isNull(1)) ? null : c.getBlob(1);
+ ret.add(new Pair<String, byte[]>(name, b));
+ loopCheck = c.moveToNext();
+ }
+ }
+ database.setTransactionSuccessful();
+ } finally {
+ if (c != null) {
+ c.close();
+ }
+ database.endTransaction();
+ }
+ if (ret.size() <= 0) {
+ return null;
+ }
+ return ret;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/data/UserPresetsManager.java b/src/com/android/gallery3d/filtershow/data/UserPresetsManager.java
new file mode 100644
index 0000000..6232a2d
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/data/UserPresetsManager.java
@@ -0,0 +1,149 @@
+package com.android.gallery3d.filtershow.data;
+
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Message;
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+import java.util.ArrayList;
+
+public class UserPresetsManager implements Handler.Callback {
+
+ private static final String LOGTAG = "UserPresetsManager";
+
+ private FilterShowActivity mActivity;
+ private HandlerThread mHandlerThread = null;
+ private Handler mProcessingHandler = null;
+ private FilterStackSource mUserPresets;
+
+ private static final int LOAD = 1;
+ private static final int LOAD_RESULT = 2;
+ private static final int SAVE = 3;
+ private static final int DELETE = 4;
+ private static final int UPDATE = 5;
+
+ private ArrayList<FilterUserPresetRepresentation> mRepresentations;
+
+ private final Handler mResultHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case LOAD_RESULT:
+ resultLoad(msg);
+ break;
+ }
+ }
+ };
+
+ @Override
+ public boolean handleMessage(Message msg) {
+ switch (msg.what) {
+ case LOAD:
+ processLoad();
+ return true;
+ case SAVE:
+ processSave(msg);
+ return true;
+ case DELETE:
+ processDelete(msg);
+ return true;
+ case UPDATE:
+ processUpdate(msg);
+ return true;
+ }
+ return false;
+ }
+
+ public UserPresetsManager(FilterShowActivity context) {
+ mActivity = context;
+ mHandlerThread = new HandlerThread(LOGTAG,
+ android.os.Process.THREAD_PRIORITY_BACKGROUND);
+ mHandlerThread.start();
+ mProcessingHandler = new Handler(mHandlerThread.getLooper(), this);
+ mUserPresets = new FilterStackSource(mActivity);
+ mUserPresets.open();
+ }
+
+ public ArrayList<FilterUserPresetRepresentation> getRepresentations() {
+ return mRepresentations;
+ }
+
+ public void load() {
+ Message msg = mProcessingHandler.obtainMessage(LOAD);
+ mProcessingHandler.sendMessage(msg);
+ }
+
+ public void close() {
+ mUserPresets.close();
+ mHandlerThread.quit();
+ }
+
+ static class SaveOperation {
+ String json;
+ String name;
+ }
+
+ public void save(ImagePreset preset, String name) {
+ Message msg = mProcessingHandler.obtainMessage(SAVE);
+ SaveOperation op = new SaveOperation();
+ op.json = preset.getJsonString(ImagePreset.JASON_SAVED);
+ op.name = name;
+ msg.obj = op;
+ mProcessingHandler.sendMessage(msg);
+ }
+
+ public void delete(int id) {
+ Message msg = mProcessingHandler.obtainMessage(DELETE);
+ msg.arg1 = id;
+ mProcessingHandler.sendMessage(msg);
+ }
+
+ static class UpdateOperation {
+ int id;
+ String name;
+ }
+
+ public void update(FilterUserPresetRepresentation representation) {
+ Message msg = mProcessingHandler.obtainMessage(UPDATE);
+ UpdateOperation op = new UpdateOperation();
+ op.id = representation.getId();
+ op.name = representation.getName();
+ msg.obj = op;
+ mProcessingHandler.sendMessage(msg);
+ }
+
+ private void processLoad() {
+ ArrayList<FilterUserPresetRepresentation> list = mUserPresets.getAllUserPresets();
+ Message msg = mResultHandler.obtainMessage(LOAD_RESULT);
+ msg.obj = list;
+ mResultHandler.sendMessage(msg);
+ }
+
+ private void resultLoad(Message msg) {
+ mRepresentations =
+ (ArrayList<FilterUserPresetRepresentation>) msg.obj;
+ mActivity.updateUserPresetsFromManager();
+ }
+
+ private void processSave(Message msg) {
+ SaveOperation op = (SaveOperation) msg.obj;
+ mUserPresets.insertStack(op.name, op.json.getBytes());
+ processLoad();
+ }
+
+ private void processDelete(Message msg) {
+ int id = msg.arg1;
+ mUserPresets.removeStack(id);
+ processLoad();
+ }
+
+ private void processUpdate(Message msg) {
+ UpdateOperation op = (UpdateOperation) msg.obj;
+ mUserPresets.updateStackName(op.id, op.name);
+ processLoad();
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java
index 02bbcde..e3eec39 100644
--- a/src/com/android/gallery3d/filtershow/editors/Editor.java
+++ b/src/com/android/gallery3d/filtershow/editors/Editor.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
+import android.content.res.Configuration;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
@@ -32,12 +33,14 @@
import android.widget.SeekBar.OnSeekBarChangeListener;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.controller.Control;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+import java.util.ArrayList;
+import java.util.Collection;
/**
* Base class for Editors Must contain a mImageShow and a top level view
@@ -52,6 +55,7 @@
protected Button mFilterTitle;
protected int mID;
private final String LOGTAG = "Editor";
+ protected boolean mChangesGeometry = false;
protected FilterRepresentation mLocalRepresentation = null;
protected byte mShowParameter = SHOW_VALUE_UNDEFINED;
private Button mButton;
@@ -92,12 +96,12 @@
mEditTitle = editTitle;
mFilterTitle = stateButton;
mButton = editTitle;
- setMenuIcon(true);
+ MasterImage.getImage().resetGeometryImages(false);
setUtilityPanelUI(actionButton, editControl);
}
public boolean showsPopupIndicator() {
- return true;
+ return false;
}
/**
@@ -114,21 +118,16 @@
R.layout.filtershow_seekbar, (ViewGroup) editControl, true);
mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar);
mSeekBar.setOnSeekBarChangeListener(this);
-
- if (showsSeekBar()) {
- mSeekBar.setOnSeekBarChangeListener(this);
- mSeekBar.setVisibility(View.VISIBLE);
- } else {
- mSeekBar.setVisibility(View.INVISIBLE);
+ mSeekBar.setVisibility(View.GONE);
+ if (context.getResources().getConfiguration().orientation
+ == Configuration.ORIENTATION_PORTRAIT) {
+ if (showsSeekBar()) {
+ mSeekBar.setVisibility(View.VISIBLE);
+ }
}
if (mButton != null) {
- if (showsPopupIndicator()) {
- mButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0,
- R.drawable.filtershow_menu_marker, 0);
- } else {
- mButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
- }
+ setMenuIcon(showsPopupIndicator());
}
}
@@ -141,7 +140,7 @@
}
- public void createEditor(Context context,FrameLayout frameLayout) {
+ public void createEditor(Context context, FrameLayout frameLayout) {
mContext = context;
mFrameLayout = frameLayout;
mLocalRepresentation = null;
@@ -189,10 +188,6 @@
return mImageShow;
}
- public void setImageLoader(ImageLoader imageLoader) {
- mImageShow.setImageLoader(imageLoader);
- }
-
public void setVisibility(int visible) {
mView.setVisibility(visible);
}
@@ -202,7 +197,7 @@
ImagePreset preset = MasterImage.getImage().getPreset();
FilterRepresentation filterRepresentation = MasterImage.getImage().getCurrentFilterRepresentation();
mLocalRepresentation = preset.getFilterRepresentationCopyFrom(filterRepresentation);
- if (mShowParameter == SHOW_VALUE_UNDEFINED) {
+ if (mShowParameter == SHOW_VALUE_UNDEFINED && filterRepresentation != null) {
boolean show = filterRepresentation.showParameterValue();
mShowParameter = show ? SHOW_VALUE_INT : SHOW_VALUE_OFF;
}
@@ -211,12 +206,49 @@
return mLocalRepresentation;
}
+ /**
+ * Call this to update the preset in MasterImage with the current representation
+ * returned by getLocalRepresentation. This causes the preview bitmap to be
+ * regenerated.
+ */
public void commitLocalRepresentation() {
+ commitLocalRepresentation(getLocalRepresentation());
+ }
+
+ /**
+ * Call this to update the preset in MasterImage with a given representation.
+ * This causes the preview bitmap to be regenerated.
+ */
+ public void commitLocalRepresentation(FilterRepresentation rep) {
+ ArrayList<FilterRepresentation> filter = new ArrayList<FilterRepresentation>(1);
+ filter.add(rep);
+ commitLocalRepresentation(filter);
+ }
+
+ /**
+ * Call this to update the preset in MasterImage with a collection of FilterRepresentations.
+ * This causes the preview bitmap to be regenerated.
+ */
+ public void commitLocalRepresentation(Collection<FilterRepresentation> reps) {
ImagePreset preset = MasterImage.getImage().getPreset();
- preset.updateFilterRepresentation(getLocalRepresentation());
+ preset.updateFilterRepresentations(reps);
if (mButton != null) {
updateText();
}
+ if (mChangesGeometry) {
+ // Regenerate both the filtered and the geometry-only bitmaps
+ MasterImage.getImage().resetGeometryImages(true);
+ }
+ // Regenerate the filtered bitmap.
+ MasterImage.getImage().invalidateFiltersOnly();
+ preset.fillImageStateAdapter(MasterImage.getImage().getState());
+ }
+
+ /**
+ * This is called in response to a click to apply and leave the editor.
+ */
+ public void finalApplyCalled() {
+ commitLocalRepresentation();
}
protected void updateText() {
@@ -245,7 +277,7 @@
}
public void openUtilityPanel(LinearLayout mAccessoryViewList) {
- setMenuIcon(false);
+ setMenuIcon(showsPopupIndicator());
if (mImageShow != null) {
mImageShow.openUtilityPanel(mAccessoryViewList);
}
@@ -253,7 +285,7 @@
protected void setMenuIcon(boolean on) {
mEditTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
- 0, 0, on ? R.drawable.filtershow_menu_marker : 0, 0);
+ 0, 0, on ? R.drawable.filtershow_menu_marker_rtl : 0, 0);
}
protected void createMenu(int[] strId, View button) {
@@ -269,6 +301,7 @@
public Control[] getControls() {
return null;
}
+
@Override
public void onStartTrackingTouch(SeekBar arg0) {
@@ -291,7 +324,7 @@
public void detach() {
if (mImageShow != null) {
- mImageShow.unselect();
+ mImageShow.detach();
}
}
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorChanSat.java b/src/com/android/gallery3d/filtershow/editors/EditorChanSat.java
new file mode 100644
index 0000000..abf0a69
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorChanSat.java
@@ -0,0 +1,383 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.os.Handler;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.PopupMenu;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+
+import android.widget.TextView;
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.controller.BasicParameterStyle;
+import com.android.gallery3d.filtershow.controller.BitmapCaller;
+import com.android.gallery3d.filtershow.controller.FilterView;
+import com.android.gallery3d.filtershow.controller.Parameter;
+import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterChanSatRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+public class EditorChanSat extends ParametricEditor implements OnSeekBarChangeListener, FilterView {
+ public static final int ID = R.id.editorChanSat;
+ private final String LOGTAG = "EditorGrunge";
+ private SwapButton mButton;
+ private final Handler mHandler = new Handler();
+
+ private SeekBar mMainBar;
+ private SeekBar mRedBar;
+ private SeekBar mYellowBar;
+ private SeekBar mGreenBar;
+ private SeekBar mCyanBar;
+ private SeekBar mBlueBar;
+ private SeekBar mMagentaBar;
+ private TextView mMainValue;
+ private TextView mRedValue;
+ private TextView mYellowValue;
+ private TextView mGreenValue;
+ private TextView mCyanValue;
+ private TextView mBlueValue;
+ private TextView mMagentaValue;
+
+ int[] mMenuStrings = {
+ R.string.editor_chan_sat_main,
+ R.string.editor_chan_sat_red,
+ R.string.editor_chan_sat_yellow,
+ R.string.editor_chan_sat_green,
+ R.string.editor_chan_sat_cyan,
+ R.string.editor_chan_sat_blue,
+ R.string.editor_chan_sat_magenta
+ };
+
+ String mCurrentlyEditing = null;
+
+ public EditorChanSat() {
+ super(ID, R.layout.filtershow_default_editor, R.id.basicEditor);
+ }
+
+ @Override
+ public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep == null || !(rep instanceof FilterChanSatRepresentation)) {
+ return "";
+ }
+ FilterChanSatRepresentation csrep = (FilterChanSatRepresentation) rep;
+ int mode = csrep.getParameterMode();
+ String paramString;
+
+ paramString = mContext.getString(mMenuStrings[mode]);
+
+ int val = csrep.getCurrentParameter();
+ return paramString + ((val > 0) ? " +" : " ") + val;
+ }
+
+ @Override
+ public void openUtilityPanel(final LinearLayout accessoryViewList) {
+ mButton = (SwapButton) accessoryViewList.findViewById(R.id.applyEffect);
+ mButton.setText(mContext.getString(R.string.editor_chan_sat_main));
+
+ if (useCompact(mContext)) {
+ final PopupMenu popupMenu = new PopupMenu(mImageShow.getActivity(), mButton);
+
+ popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_chan_sat,
+ popupMenu.getMenu());
+
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ selectMenuItem(item);
+ return true;
+ }
+ });
+ mButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ popupMenu.show();
+ ((FilterShowActivity)mContext).onShowMenu(popupMenu);
+ }
+ });
+ mButton.setListener(this);
+
+ FilterChanSatRepresentation csrep = getChanSatRep();
+ String menuString = mContext.getString(mMenuStrings[0]);
+ switchToMode(csrep, FilterChanSatRepresentation.MODE_MASTER, menuString);
+ } else {
+ mButton.setText(mContext.getString(R.string.saturation));
+ }
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ if (useCompact(mContext)) {
+ super.reflectCurrentFilter();
+ updateText();
+ return;
+ }
+ mLocalRepresentation = null;
+ if (getLocalRepresentation() != null
+ && getLocalRepresentation() instanceof FilterChanSatRepresentation) {
+ FilterChanSatRepresentation rep =
+ (FilterChanSatRepresentation) getLocalRepresentation();
+ int value = rep.getValue(FilterChanSatRepresentation.MODE_MASTER);
+ mMainBar.setProgress(value + 100);
+ mMainValue.setText("" + value);
+ value = rep.getValue(FilterChanSatRepresentation.MODE_RED);
+ mRedBar.setProgress(value + 100);
+ mRedValue.setText("" + value);
+ value = rep.getValue(FilterChanSatRepresentation.MODE_YELLOW);
+ mYellowBar.setProgress(value + 100);
+ mYellowValue.setText("" + value);
+ value = rep.getValue(FilterChanSatRepresentation.MODE_GREEN);
+ mGreenBar.setProgress(value + 100);
+ mGreenValue.setText("" + value);
+ value = rep.getValue(FilterChanSatRepresentation.MODE_CYAN);
+ mCyanBar.setProgress(value + 100);
+ mCyanValue.setText("" + value);
+ value = rep.getValue(FilterChanSatRepresentation.MODE_BLUE);
+ mBlueBar.setProgress(value + 100);
+ mBlueValue.setText("" + value);
+ value = rep.getValue(FilterChanSatRepresentation.MODE_MAGENTA);
+ mMagentaBar.setProgress(value + 100);
+ mMagentaValue.setText("" + value);
+ String text = mContext.getString(rep.getTextId()).toUpperCase();
+ mFilterTitle.setText(text);
+ updateText();
+ }
+ }
+
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ if (useCompact(mContext)) {
+ super.setUtilityPanelUI(actionButton, editControl);
+ return;
+ }
+ mActionButton = actionButton;
+ mEditControl = editControl;
+ mEditTitle.setCompoundDrawables(null, null, null, null);
+ LinearLayout group = (LinearLayout) editControl;
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout controls = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_saturation_controls, group, false);
+ ViewGroup.LayoutParams lp = new LinearLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ controls.setLayoutParams(lp);
+ group.removeAllViews();
+ group.addView(controls);
+ mMainBar = (SeekBar) controls.findViewById(R.id.mainSeekbar);
+ mMainBar.setMax(200);
+ mMainBar.setOnSeekBarChangeListener(this);
+ mMainValue = (TextView) controls.findViewById(R.id.mainValue);
+ mRedBar = (SeekBar) controls.findViewById(R.id.redSeekBar);
+ mRedBar.setMax(200);
+ mRedBar.setOnSeekBarChangeListener(this);
+ mRedValue = (TextView) controls.findViewById(R.id.redValue);
+ mYellowBar = (SeekBar) controls.findViewById(R.id.yellowSeekBar);
+ mYellowBar.setMax(200);
+ mYellowBar.setOnSeekBarChangeListener(this);
+ mYellowValue = (TextView) controls.findViewById(R.id.yellowValue);
+ mGreenBar = (SeekBar) controls.findViewById(R.id.greenSeekBar);
+ mGreenBar.setMax(200);
+ mGreenBar.setOnSeekBarChangeListener(this);
+ mGreenValue = (TextView) controls.findViewById(R.id.greenValue);
+ mCyanBar = (SeekBar) controls.findViewById(R.id.cyanSeekBar);
+ mCyanBar.setMax(200);
+ mCyanBar.setOnSeekBarChangeListener(this);
+ mCyanValue = (TextView) controls.findViewById(R.id.cyanValue);
+ mBlueBar = (SeekBar) controls.findViewById(R.id.blueSeekBar);
+ mBlueBar.setMax(200);
+ mBlueBar.setOnSeekBarChangeListener(this);
+ mBlueValue = (TextView) controls.findViewById(R.id.blueValue);
+ mMagentaBar = (SeekBar) controls.findViewById(R.id.magentaSeekBar);
+ mMagentaBar.setMax(200);
+ mMagentaBar.setOnSeekBarChangeListener(this);
+ mMagentaValue = (TextView) controls.findViewById(R.id.magentaValue);
+ }
+
+ public int getParameterIndex(int id) {
+ switch (id) {
+ case R.id.editor_chan_sat_main:
+ return FilterChanSatRepresentation.MODE_MASTER;
+ case R.id.editor_chan_sat_red:
+ return FilterChanSatRepresentation.MODE_RED;
+ case R.id.editor_chan_sat_yellow:
+ return FilterChanSatRepresentation.MODE_YELLOW;
+ case R.id.editor_chan_sat_green:
+ return FilterChanSatRepresentation.MODE_GREEN;
+ case R.id.editor_chan_sat_cyan:
+ return FilterChanSatRepresentation.MODE_CYAN;
+ case R.id.editor_chan_sat_blue:
+ return FilterChanSatRepresentation.MODE_BLUE;
+ case R.id.editor_chan_sat_magenta:
+ return FilterChanSatRepresentation.MODE_MAGENTA;
+ }
+ return -1;
+ }
+
+ @Override
+ public void detach() {
+ if (mButton == null) {
+ return;
+ }
+ mButton.setListener(null);
+ mButton.setOnClickListener(null);
+ }
+
+ private void updateSeekBar(FilterChanSatRepresentation rep) {
+ mControl.updateUI();
+ }
+
+ @Override
+ protected Parameter getParameterToEdit(FilterRepresentation rep) {
+ if (rep instanceof FilterChanSatRepresentation) {
+ FilterChanSatRepresentation csrep = (FilterChanSatRepresentation) rep;
+ Parameter param = csrep.getFilterParameter(csrep.getParameterMode());
+ if (param instanceof BasicParameterStyle) {
+ param.setFilterView(EditorChanSat.this);
+ }
+ return param;
+ }
+ return null;
+ }
+
+ private FilterChanSatRepresentation getChanSatRep() {
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep != null
+ && rep instanceof FilterChanSatRepresentation) {
+ FilterChanSatRepresentation csrep = (FilterChanSatRepresentation) rep;
+ return csrep;
+ }
+ return null;
+ }
+
+ @Override
+ public void computeIcon(int n, BitmapCaller caller) {
+ FilterChanSatRepresentation rep = getChanSatRep();
+ if (rep == null) return;
+ rep = (FilterChanSatRepresentation) rep.copy();
+ ImagePreset preset = new ImagePreset();
+ preset.addFilter(rep);
+ Bitmap src = MasterImage.getImage().getThumbnailBitmap();
+ caller.available(src);
+ }
+
+ protected void selectMenuItem(MenuItem item) {
+ if (getLocalRepresentation() != null
+ && getLocalRepresentation() instanceof FilterChanSatRepresentation) {
+ FilterChanSatRepresentation csrep =
+ (FilterChanSatRepresentation) getLocalRepresentation();
+
+ switchToMode(csrep, getParameterIndex(item.getItemId()), item.getTitle().toString());
+
+ }
+ }
+
+ protected void switchToMode(FilterChanSatRepresentation csrep, int mode, String title) {
+ if (csrep == null) {
+ return;
+ }
+ csrep.setParameterMode(mode);
+ mCurrentlyEditing = title;
+ mButton.setText(mCurrentlyEditing);
+ {
+ Parameter param = getParameterToEdit(csrep);
+
+ control(param, mEditControl);
+ }
+ updateSeekBar(csrep);
+ mView.invalidate();
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) {
+ FilterChanSatRepresentation rep = getChanSatRep();
+ int value = progress - 100;
+ switch (sbar.getId()) {
+ case R.id.mainSeekbar:
+ rep.setParameterMode(FilterChanSatRepresentation.MODE_MASTER);
+ mMainValue.setText("" + value);
+ break;
+ case R.id.redSeekBar:
+ rep.setParameterMode(FilterChanSatRepresentation.MODE_RED);
+ mRedValue.setText("" + value);
+ break;
+ case R.id.yellowSeekBar:
+ rep.setParameterMode(FilterChanSatRepresentation.MODE_YELLOW);
+ mYellowValue.setText("" + value);
+ break;
+ case R.id.greenSeekBar:
+ rep.setParameterMode(FilterChanSatRepresentation.MODE_GREEN);
+ mGreenValue.setText("" + value);
+ break;
+ case R.id.cyanSeekBar:
+ rep.setParameterMode(FilterChanSatRepresentation.MODE_CYAN);
+ mCyanValue.setText("" + value);
+ break;
+ case R.id.blueSeekBar:
+ rep.setParameterMode(FilterChanSatRepresentation.MODE_BLUE);
+ mBlueValue.setText("" + value);
+ break;
+ case R.id.magentaSeekBar:
+ rep.setParameterMode(FilterChanSatRepresentation.MODE_MAGENTA);
+ mMagentaValue.setText("" + value);
+ break;
+ }
+ rep.setCurrentParameter(value);
+ commitLocalRepresentation();
+ }
+
+ @Override
+ public void swapLeft(MenuItem item) {
+ super.swapLeft(item);
+ mButton.setTranslationX(0);
+ mButton.animate().translationX(mButton.getWidth()).setDuration(SwapButton.ANIM_DURATION);
+ Runnable updateButton = new Runnable() {
+ @Override
+ public void run() {
+ mButton.animate().cancel();
+ mButton.setTranslationX(0);
+ }
+ };
+ mHandler.postDelayed(updateButton, SwapButton.ANIM_DURATION);
+ selectMenuItem(item);
+ }
+
+ @Override
+ public void swapRight(MenuItem item) {
+ super.swapRight(item);
+ mButton.setTranslationX(0);
+ mButton.animate().translationX(-mButton.getWidth()).setDuration(SwapButton.ANIM_DURATION);
+ Runnable updateButton = new Runnable() {
+ @Override
+ public void run() {
+ mButton.animate().cancel();
+ mButton.setTranslationX(0);
+ }
+ };
+ mHandler.postDelayed(updateButton, SwapButton.ANIM_DURATION);
+ selectMenuItem(item);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorColorBorder.java b/src/com/android/gallery3d/filtershow/editors/EditorColorBorder.java
new file mode 100644
index 0000000..98659df
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorColorBorder.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.editors;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.PopupMenu;
+import android.widget.SeekBar;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.controller.BitmapCaller;
+import com.android.gallery3d.filtershow.controller.ColorChooser;
+import com.android.gallery3d.filtershow.controller.FilterView;
+import com.android.gallery3d.filtershow.filters.FilterColorBorderRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.ImageFilterColorBorder;
+import com.android.gallery3d.filtershow.imageshow.ImageShow;
+
+public class EditorColorBorder extends ParametricEditor {
+ private static final String LOGTAG = "EditorColorBorder";
+ public static final int ID = R.id.editorColorBorder;
+
+ int[] mBasColors = {
+ FilterColorBorderRepresentation.DEFAULT_MENU_COLOR1,
+ FilterColorBorderRepresentation.DEFAULT_MENU_COLOR2,
+ FilterColorBorderRepresentation.DEFAULT_MENU_COLOR3,
+ FilterColorBorderRepresentation.DEFAULT_MENU_COLOR4,
+ FilterColorBorderRepresentation.DEFAULT_MENU_COLOR5,
+ };
+ private EditorColorBorderTabletUI mTabletUI;
+ private String mParameterString;
+ private int mSelectedColorButton;
+
+ public EditorColorBorder() {
+ super(ID);
+ }
+
+ @Override
+ public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
+ FilterColorBorderRepresentation rep = getColorBorderRep();
+ if (rep == null) {
+ return "";
+ }
+ if (mParameterString == null) {
+ mParameterString = "";
+ }
+ String paramString;
+ String val = rep.getValueString();
+ return mParameterString + val;
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ mView = mImageShow = new ImageShow(context);
+ super.createEditor(context, frameLayout);
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ super.reflectCurrentFilter();
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep != null && getLocalRepresentation() instanceof FilterColorBorderRepresentation) {
+ FilterColorBorderRepresentation cbRep =
+ (FilterColorBorderRepresentation) getLocalRepresentation();
+ if (!ParametricEditor.useCompact(mContext)) {
+ if (mTabletUI != null) {
+ mTabletUI.setColorBorderRepresentation(cbRep);
+ }
+
+ }
+ cbRep.setPramMode(FilterColorBorderRepresentation.PARAM_SIZE);
+ mParameterString = mContext.getString(R.string.color_border_size);
+ if (mEditControl != null) {
+ control(cbRep.getCurrentParam(), mEditControl);
+ }
+ }
+ }
+
+ @Override
+ public void openUtilityPanel(final LinearLayout accessoryViewList) {
+ Button view = (Button) accessoryViewList.findViewById(R.id.applyEffect);
+ view.setText(mContext.getString(R.string.color_border_size));
+ view.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View arg0) {
+ showPopupMenu(accessoryViewList);
+ }
+ });
+ }
+
+ @Override
+ public boolean showsSeekBar() {
+ return false;
+ }
+
+ private void showPopupMenu(LinearLayout accessoryViewList) {
+ final Button button = (Button) accessoryViewList.findViewById(
+ R.id.applyEffect);
+ if (button == null) {
+ return;
+ }
+ final PopupMenu popupMenu = new PopupMenu(mImageShow.getActivity(), button);
+ popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_color_border,
+ popupMenu.getMenu());
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ selectMenuItem(item);
+ return true;
+ }
+ });
+ popupMenu.show();
+ ((FilterShowActivity)mContext).onShowMenu(popupMenu);
+ }
+
+ protected void selectMenuItem(MenuItem item) {
+ ImageFilterColorBorder filter = (ImageFilterColorBorder) mImageShow.getCurrentFilter();
+ FilterColorBorderRepresentation rep = getColorBorderRep();
+ if (rep == null) {
+ return;
+ }
+ switch (item.getItemId()) {
+ case R.id.color_border_menu_clear:
+ clearFrame();
+ break;
+ case R.id.color_border_menu_size:
+ rep.setPramMode(FilterColorBorderRepresentation.PARAM_SIZE);
+ break;
+ case R.id.color_border_menu_corner_size:
+ rep.setPramMode(FilterColorBorderRepresentation.PARAM_RADIUS);
+ break;
+ case R.id.color_border_menu_color:
+ rep.setPramMode(FilterColorBorderRepresentation.PARAM_COLOR);
+ break;
+ }
+ if (item.getItemId() != R.id.color_border_menu_clear) {
+ mParameterString = item.getTitle().toString();
+ }
+ if (mControl instanceof ColorChooser) {
+ ColorChooser c = (ColorChooser) mControl;
+ mBasColors = c.getColorSet();
+ }
+ if (mEditControl != null) {
+ control(rep.getCurrentParam(), mEditControl);
+ }
+ if (mControl instanceof ColorChooser) {
+ ColorChooser c = (ColorChooser) mControl;
+ c.setColorSet(mBasColors);
+ }
+ updateText();
+ mControl.updateUI();
+ mView.invalidate();
+ }
+
+ public void clearFrame() {
+ commitLocalRepresentation();
+ }
+
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ if (ParametricEditor.useCompact(mContext)) {
+ super.setUtilityPanelUI(actionButton, editControl);
+ return;
+ }
+ mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+ if (mSeekBar != null) {
+ mSeekBar.setVisibility(View.GONE);
+ }
+
+ mTabletUI = new EditorColorBorderTabletUI(this, mContext, editControl);
+
+ }
+
+ FilterColorBorderRepresentation getColorBorderRep() {
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep instanceof FilterColorBorderRepresentation) {
+ return (FilterColorBorderRepresentation) rep;
+ }
+ return null;
+ }
+
+
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java b/src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java
new file mode 100644
index 0000000..9f1a11b
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.colorpicker.ColorCompareView;
+import com.android.gallery3d.filtershow.colorpicker.ColorHueView;
+import com.android.gallery3d.filtershow.colorpicker.ColorListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorOpacityView;
+import com.android.gallery3d.filtershow.colorpicker.ColorSVRectView;
+import com.android.gallery3d.filtershow.controller.BasicParameterInt;
+import com.android.gallery3d.filtershow.controller.ParameterColor;
+import com.android.gallery3d.filtershow.filters.FilterColorBorderRepresentation;
+
+import java.util.Arrays;
+
+public class EditorColorBorderTabletUI {
+ private EditorColorBorder mEditorDraw;
+ private static int sIconDim = 120;
+ private int mSelectedColorButton;
+ private FilterColorBorderRepresentation mRep;
+ private Button[] mColorButton;
+ private ColorHueView mHueView;
+ private ColorSVRectView mSatValView;
+ private ColorOpacityView mOpacityView;
+ private ColorCompareView mColorCompareView;
+
+ private int[] mBasColors;
+ private int mSelected;
+ private int mTransparent;
+ private SeekBar mCBSizeSeekBar;
+ private SeekBar mCBCornerSizeSeekBar;
+ TextView mCBCornerSizeValue;
+ TextView mCBSizeValue;
+
+ private int[] ids = {
+ R.id.draw_color_button01,
+ R.id.draw_color_button02,
+ R.id.draw_color_button03,
+ R.id.draw_color_button04,
+ R.id.draw_color_button05,
+ };
+
+ public void setColorBorderRepresentation(FilterColorBorderRepresentation rep) {
+ mRep = rep;
+ BasicParameterInt size;
+ size = (BasicParameterInt) mRep.getParam(FilterColorBorderRepresentation.PARAM_SIZE);
+ mCBSizeSeekBar.setMax(size.getMaximum() - size.getMinimum());
+ mCBSizeSeekBar.setProgress(size.getValue());
+
+ BasicParameterInt radius;
+ radius = (BasicParameterInt) mRep.getParam(FilterColorBorderRepresentation.PARAM_RADIUS);
+ mCBCornerSizeSeekBar.setMax(radius.getMaximum() - radius.getMinimum());
+ mCBCornerSizeSeekBar.setProgress(radius.getValue());
+
+ ParameterColor color;
+ color = (ParameterColor) mRep.getParam(FilterColorBorderRepresentation.PARAM_COLOR);
+ mBasColors = color.getColorPalette();
+ color.setValue(mBasColors[mSelectedColorButton]);
+ }
+
+ public EditorColorBorderTabletUI(EditorColorBorder editorDraw, Context context, View base) {
+ mEditorDraw = editorDraw;
+ mBasColors = editorDraw.mBasColors;
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_color_border_ui, (ViewGroup) base, true);
+
+ Resources res = context.getResources();
+ sIconDim = res.getDimensionPixelSize(R.dimen.draw_style_icon_dim);
+ LinearLayout buttonContainer = (LinearLayout) lp.findViewById(R.id.listStyles);
+
+ mCBCornerSizeSeekBar = (SeekBar) lp.findViewById(R.id.colorBorderCornerSizeSeekBar);
+ mCBCornerSizeValue = (TextView) lp.findViewById(R.id.colorBorderCornerValue);
+ mCBSizeSeekBar = (SeekBar) lp.findViewById(R.id.colorBorderSizeSeekBar);
+
+ mCBSizeValue = (TextView) lp.findViewById(R.id.colorBorderSizeValue);
+ setupCBSizeSeekBar(lp);
+ setupCBCornerSizeSeekBar(lp);
+ setupColor(lp, res);
+ }
+
+ private void setupCBSizeSeekBar(LinearLayout lp) {
+ mCBSizeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ int type = FilterColorBorderRepresentation.PARAM_SIZE;
+ BasicParameterInt size = (BasicParameterInt) mRep.getParam(type);
+ size.setValue(progress + size.getMinimum());
+ mCBSizeValue.setText(Integer.toString(size.getValue()));
+ mEditorDraw.commitLocalRepresentation();
+ }
+ });
+
+ }
+
+ private void setupCBCornerSizeSeekBar(LinearLayout lp) {
+ mCBCornerSizeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ int type = FilterColorBorderRepresentation.PARAM_RADIUS;
+ BasicParameterInt size = (BasicParameterInt) mRep.getParam(type);
+ size.setValue(progress + size.getMinimum());
+ mCBCornerSizeValue.setText(size.getValue() + "");
+ mEditorDraw.commitLocalRepresentation();
+ }
+ });
+
+ }
+
+ private void setupColor(LinearLayout lp, Resources res) {
+ final LinearLayout ctls = (LinearLayout) lp.findViewById(R.id.controls);
+ final LinearLayout pick = (LinearLayout) lp.findViewById(R.id.colorPicker);
+ Button b = (Button) lp.findViewById(R.id.draw_color_popupbutton);
+ b.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View view) {
+ boolean b = ctls.getVisibility() == View.VISIBLE;
+ ctls.setVisibility((b) ? View.GONE : View.VISIBLE);
+ pick.setVisibility((!b) ? View.GONE : View.VISIBLE);
+ }
+ }
+ );
+
+ mTransparent = res.getColor(R.color.color_chooser_unslected_border);
+ mSelected = res.getColor(R.color.color_chooser_slected_border);
+
+ mColorButton = new Button[ids.length];
+ for (int i = 0; i < ids.length; i++) {
+ mColorButton[i] = (Button) lp.findViewById(ids[i]);
+ float[] hsvo = new float[4];
+ Color.colorToHSV(mBasColors[i], hsvo);
+ hsvo[3] = (0xFF & (mBasColors[i] >> 24)) / (float) 255;
+ mColorButton[i].setTag(hsvo);
+ GradientDrawable sd = ((GradientDrawable) mColorButton[i].getBackground());
+ sd.setColor(mBasColors[i]);
+ sd.setStroke(3, (0 == i) ? mSelected : mTransparent);
+ final int buttonNo = i;
+ mColorButton[i].setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ mSelectedColorButton = buttonNo;
+ float[] hsvo = Arrays.copyOf((float[]) mColorButton[buttonNo].getTag(), 4);
+ resetBorders();
+ if (mRep == null) {
+ return;
+ }
+ int type = FilterColorBorderRepresentation.PARAM_COLOR;
+ ParameterColor pram = (ParameterColor) mRep.getParam(type);
+ pram.setValue(mBasColors[mSelectedColorButton]);
+ mEditorDraw.commitLocalRepresentation();
+ mHueView.setColor(hsvo);
+ mSatValView.setColor(hsvo);
+ mOpacityView.setColor(hsvo);
+ mColorCompareView.setOrigColor(hsvo);
+
+ }
+ });
+ }
+ mHueView = (ColorHueView) lp.findViewById(R.id.ColorHueView);
+ mSatValView = (ColorSVRectView) lp.findViewById(R.id.colorRectView);
+ mOpacityView = (ColorOpacityView) lp.findViewById(R.id.colorOpacityView);
+ mColorCompareView = (ColorCompareView) lp.findViewById(R.id.btnSelect);
+
+ float[] hsvo = new float[4];
+ Color.colorToHSV(mBasColors[0], hsvo);
+ hsvo[3] = (0xFF & (mBasColors[0] >> 24)) / (float) 255;
+ mColorCompareView.setOrigColor(hsvo);
+
+ ColorListener[] colorViews = {mHueView, mSatValView, mOpacityView, mColorCompareView};
+ for (int i = 0; i < colorViews.length; i++) {
+ colorViews[i].setColor(hsvo);
+ for (int j = 0; j < colorViews.length; j++) {
+ if (i == j) {
+ continue;
+ }
+ colorViews[i].addColorListener(colorViews[j]);
+ }
+ }
+
+ ColorListener colorListener = new ColorListener() {
+ @Override
+ public void setColor(float[] hsvo) {
+ int color = Color.HSVToColor((int) (hsvo[3] * 255), hsvo);
+ Button b = mColorButton[mSelectedColorButton];
+ float[] f = (float[]) b.getTag();
+ System.arraycopy(hsvo, 0, f, 0, 4);
+ mBasColors[mSelectedColorButton] = color;
+ GradientDrawable sd = ((GradientDrawable) b.getBackground());
+ sd.setColor(color);
+ resetBorders();
+ ParameterColor pram;
+ pram = (ParameterColor) mRep.getParam(FilterColorBorderRepresentation.PARAM_COLOR);
+ pram.setValue(color);
+ mEditorDraw.commitLocalRepresentation();
+ }
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
+ };
+
+ for (int i = 0; i < colorViews.length; i++) {
+ colorViews[i].addColorListener(colorListener);
+ }
+ }
+
+ private void resetBorders() {
+ for (int i = 0; i < ids.length; i++) {
+ final Button button = mColorButton[i];
+ GradientDrawable sd = ((GradientDrawable) button.getBackground());
+ sd.setColor(mBasColors[i]);
+ sd.setStroke(3, (mSelectedColorButton == i) ? mSelected : mTransparent);
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorCrop.java b/src/com/android/gallery3d/filtershow/editors/EditorCrop.java
index 24a83cd..6b19d3c 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorCrop.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorCrop.java
@@ -17,6 +17,8 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
+import android.util.Log;
+import android.util.SparseArray;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
@@ -26,44 +28,78 @@
import android.widget.PopupMenu;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.crop.CropExtras;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.filters.FilterCropRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.ImageCrop;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
public class EditorCrop extends Editor implements EditorInfo {
+ public static final String TAG = EditorCrop.class.getSimpleName();
public static final int ID = R.id.editorCrop;
- private static final String LOGTAG = "EditorCrop";
- ImageCrop mImageCrop;
+ // Holder for an aspect ratio it's string id
+ protected static final class AspectInfo {
+ int mAspectX;
+ int mAspectY;
+ int mStringId;
+ AspectInfo(int stringID, int x, int y) {
+ mStringId = stringID;
+ mAspectX = x;
+ mAspectY = y;
+ }
+ };
+
+ // Mapping from menu id to aspect ratio
+ protected static final SparseArray<AspectInfo> sAspects;
+ static {
+ sAspects = new SparseArray<AspectInfo>();
+ sAspects.put(R.id.crop_menu_1to1, new AspectInfo(R.string.aspect1to1_effect, 1, 1));
+ sAspects.put(R.id.crop_menu_4to3, new AspectInfo(R.string.aspect4to3_effect, 4, 3));
+ sAspects.put(R.id.crop_menu_3to4, new AspectInfo(R.string.aspect3to4_effect, 3, 4));
+ sAspects.put(R.id.crop_menu_5to7, new AspectInfo(R.string.aspect5to7_effect, 5, 7));
+ sAspects.put(R.id.crop_menu_7to5, new AspectInfo(R.string.aspect7to5_effect, 7, 5));
+ sAspects.put(R.id.crop_menu_none, new AspectInfo(R.string.aspectNone_effect, 0, 0));
+ sAspects.put(R.id.crop_menu_original, new AspectInfo(R.string.aspectOriginal_effect, 0, 0));
+ }
+
+ protected ImageCrop mImageCrop;
private String mAspectString = "";
- private boolean mCropActionFlag = false;
- private CropExtras mCropExtras = null;
public EditorCrop() {
super(ID);
+ mChangesGeometry = true;
}
@Override
public void createEditor(Context context, FrameLayout frameLayout) {
super.createEditor(context, frameLayout);
if (mImageCrop == null) {
- // TODO: need this for now because there's extra state in ImageCrop.
- // all the state instead should be in the representation.
- // Same thing for the other geometry editors.
mImageCrop = new ImageCrop(context);
}
mView = mImageShow = mImageCrop;
- mImageCrop.setImageLoader(MasterImage.getImage().getImageLoader());
mImageCrop.setEditor(this);
- mImageCrop.syncLocalToMasterGeometry();
- mImageCrop.setCropActionFlag(mCropActionFlag);
- if (mCropActionFlag) {
- mImageCrop.setExtras(mCropExtras);
- mImageCrop.setAspectString(mAspectString);
- mImageCrop.clear();
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ MasterImage master = MasterImage.getImage();
+ master.setCurrentFilterRepresentation(master.getPreset()
+ .getFilterWithSerializationName(FilterCropRepresentation.SERIALIZATION_NAME));
+ super.reflectCurrentFilter();
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep == null || rep instanceof FilterCropRepresentation) {
+ mImageCrop.setFilterCropRepresentation((FilterCropRepresentation) rep);
} else {
- mImageCrop.setExtras(null);
+ Log.w(TAG, "Could not reflect current filter, not of type: "
+ + FilterCropRepresentation.class.getSimpleName());
}
+ mImageCrop.invalidate();
+ }
+
+ @Override
+ public void finalApplyCalled() {
+ commitLocalRepresentation(mImageCrop.getFinalRepresentation());
}
@Override
@@ -71,31 +107,47 @@
Button view = (Button) accessoryViewList.findViewById(R.id.applyEffect);
view.setText(mContext.getString(R.string.crop));
view.setOnClickListener(new OnClickListener() {
-
- @Override
+ @Override
public void onClick(View arg0) {
showPopupMenu(accessoryViewList);
}
});
}
- private void showPopupMenu(LinearLayout accessoryViewList) {
- final Button button = (Button) accessoryViewList.findViewById(
- R.id.applyEffect);
- if (button == null) {
- return;
+ private void changeCropAspect(int itemId) {
+ AspectInfo info = sAspects.get(itemId);
+ if (info == null) {
+ throw new IllegalArgumentException("Invalid resource ID: " + itemId);
}
+ if (itemId == R.id.crop_menu_original) {
+ mImageCrop.applyOriginalAspect();
+ } else if (itemId == R.id.crop_menu_none) {
+ mImageCrop.applyFreeAspect();
+ } else {
+ mImageCrop.applyAspect(info.mAspectX, info.mAspectY);
+ }
+ setAspectString(mContext.getString(info.mStringId));
+ }
+
+ private void showPopupMenu(LinearLayout accessoryViewList) {
+ final Button button = (Button) accessoryViewList.findViewById(R.id.applyEffect);
final PopupMenu popupMenu = new PopupMenu(mImageShow.getActivity(), button);
popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_crop, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
-
@Override
public boolean onMenuItemClick(MenuItem item) {
- mImageCrop.setAspectButton(item.getItemId());
+ changeCropAspect(item.getItemId());
return true;
}
});
popupMenu.show();
+ ((FilterShowActivity)mContext).onShowMenu(popupMenu);
+ }
+
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ super.setUtilityPanelUI(actionButton,editControl);
+ setMenuIcon(true);
}
@Override
@@ -118,16 +170,7 @@
return true;
}
- public void setExtras(CropExtras cropExtras) {
- mCropExtras = cropExtras;
- }
-
- public void setAspectString(String s) {
+ private void setAspectString(String s) {
mAspectString = s;
}
-
- public void setCropActionFlag(boolean b) {
- mCropActionFlag = b;
- }
-
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorCurves.java b/src/com/android/gallery3d/filtershow/editors/EditorCurves.java
index d84d9fc..35ac359 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorCurves.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorCurves.java
@@ -23,7 +23,7 @@
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.filters.FilterCurvesRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.ui.ImageCurves;
+import com.android.gallery3d.filtershow.imageshow.ImageCurves;
public class EditorCurves extends Editor {
public static final int ID = R.id.imageCurves;
@@ -31,6 +31,17 @@
public EditorCurves() {
super(ID);
+ int k =R.menu.filtershow_menu_curves;
+ }
+
+ @Override
+ protected void updateText() {
+
+ }
+
+ @Override
+ public boolean showsPopupIndicator() {
+ return true;
}
@Override
@@ -49,6 +60,11 @@
mImageCurves.setFilterDrawRepresentation(drawRep);
}
}
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ super.setUtilityPanelUI(actionButton,editControl);
+ setMenuIcon(true);
+ }
@Override
public boolean showsSeekBar() {
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorDraw.java b/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
index 4b09051..58bde12 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
@@ -16,40 +16,101 @@
package com.android.gallery3d.filtershow.editors;
-import android.app.Dialog;
+import android.app.ActionBar;
import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.view.LayoutInflater;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.WindowManager.LayoutParams;
+import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
+import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.SeekBar;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.colorpicker.ColorGridDialog;
-import com.android.gallery3d.filtershow.colorpicker.RGBListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorHueView;
+import com.android.gallery3d.filtershow.colorpicker.ColorListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorOpacityView;
+import com.android.gallery3d.filtershow.colorpicker.ColorSVRectView;
+import com.android.gallery3d.filtershow.controller.BitmapCaller;
+import com.android.gallery3d.filtershow.controller.ColorChooser;
+import com.android.gallery3d.filtershow.controller.FilterView;
+import com.android.gallery3d.filtershow.controller.ParameterColor;
import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilterDraw;
import com.android.gallery3d.filtershow.imageshow.ImageDraw;
-public class EditorDraw extends Editor {
+public class EditorDraw extends ParametricEditor implements FilterView {
private static final String LOGTAG = "EditorDraw";
public static final int ID = R.id.editorDraw;
public ImageDraw mImageDraw;
+ private static final int MODE_SIZE = FilterDrawRepresentation.PARAM_SIZE;
+ private static final int MODE_SIZEE = FilterDrawRepresentation.PARAM_SIZE;
+ private static final int MODE_STYLE = FilterDrawRepresentation.PARAM_STYLE;
+ private static final int MODE_COLOR = FilterDrawRepresentation.PARAM_COLOR;
+ int[] brushIcons = {
+ R.drawable.brush_flat,
+ R.drawable.brush_round,
+ R.drawable.brush_gauss,
+ R.drawable.brush_marker,
+ R.drawable.brush_spatter
+ };
+
+ int[] mBasColors = {
+ FilterDrawRepresentation.DEFAULT_MENU_COLOR1,
+ FilterDrawRepresentation.DEFAULT_MENU_COLOR2,
+ FilterDrawRepresentation.DEFAULT_MENU_COLOR3,
+ FilterDrawRepresentation.DEFAULT_MENU_COLOR4,
+ FilterDrawRepresentation.DEFAULT_MENU_COLOR5,
+ };
+ private EditorDrawTabletUI mTabletUI;
+ private String mParameterString;
+ private int mSelectedColorButton;
+ private String mDrawString = null;
public EditorDraw() {
super(ID);
}
@Override
+ public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
+ FilterDrawRepresentation rep = getDrawRep();
+ if (mDrawString != null) {
+ mImageDraw.displayDrawLook();
+ return mDrawString;
+ }
+ if (rep == null) {
+ return "";
+ }
+ if (!ParametricEditor.useCompact(mContext)) {
+
+ }
+ if (mParameterString == null) {
+ mParameterString = "";
+ }
+ String paramString;
+ String val = rep.getValueString();
+
+ mImageDraw.displayDrawLook();
+ return mParameterString + val;
+ }
+
+ @Override
public void createEditor(Context context, FrameLayout frameLayout) {
- super.createEditor(context, frameLayout);
mView = mImageShow = mImageDraw = new ImageDraw(context);
+ super.createEditor(context, frameLayout);
mImageDraw.setEditor(this);
}
@@ -58,24 +119,37 @@
public void reflectCurrentFilter() {
super.reflectCurrentFilter();
FilterRepresentation rep = getLocalRepresentation();
-
if (rep != null && getLocalRepresentation() instanceof FilterDrawRepresentation) {
FilterDrawRepresentation drawRep = (FilterDrawRepresentation) getLocalRepresentation();
mImageDraw.setFilterDrawRepresentation(drawRep);
+ if (!ParametricEditor.useCompact(mContext)) {
+ if (mTabletUI != null) {
+
+ mTabletUI.setDrawRepresentation(drawRep);
+ }
+ return;
+ }
+
+ drawRep.getParam(FilterDrawRepresentation.PARAM_STYLE).setFilterView(this);
+ drawRep.setPramMode(FilterDrawRepresentation.PARAM_COLOR);
+ mParameterString = mContext.getString(R.string.draw_color);
+ control(drawRep.getCurrentParam(), mEditControl);
}
}
@Override
public void openUtilityPanel(final LinearLayout accessoryViewList) {
Button view = (Button) accessoryViewList.findViewById(R.id.applyEffect);
- view.setText(mContext.getString(R.string.draw_style));
+
+ view.setText(mContext.getString(R.string.draw_color));
view.setOnClickListener(new OnClickListener() {
- @Override
+ @Override
public void onClick(View arg0) {
showPopupMenu(accessoryViewList);
}
});
+
}
@Override
@@ -91,68 +165,119 @@
}
final PopupMenu popupMenu = new PopupMenu(mImageShow.getActivity(), button);
popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_draw, popupMenu.getMenu());
- popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
-
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- ImageFilterDraw filter = (ImageFilterDraw) mImageShow.getCurrentFilter();
- if (item.getItemId() == R.id.draw_menu_color) {
- showColorGrid(item);
- } else if (item.getItemId() == R.id.draw_menu_size) {
- showSizeDialog(item);
- } else if (item.getItemId() == R.id.draw_menu_style_brush_marker) {
- ImageDraw idraw = (ImageDraw) mImageShow;
- idraw.setStyle(ImageFilterDraw.BRUSH_STYLE_MARKER);
- } else if (item.getItemId() == R.id.draw_menu_style_brush_spatter) {
- ImageDraw idraw = (ImageDraw) mImageShow;
- idraw.setStyle(ImageFilterDraw.BRUSH_STYLE_SPATTER);
- } else if (item.getItemId() == R.id.draw_menu_style_line) {
- ImageDraw idraw = (ImageDraw) mImageShow;
- idraw.setStyle(ImageFilterDraw.SIMPLE_STYLE);
- } else if (item.getItemId() == R.id.draw_menu_clear) {
- ImageDraw idraw = (ImageDraw) mImageShow;
- idraw.resetParameter();
- commitLocalRepresentation();
+ if (!ParametricEditor.useCompact(mContext)) {
+ Menu menu = popupMenu.getMenu();
+ int count = menu.size();
+ for (int i = 0; i < count; i++) {
+ MenuItem item = menu.getItem(i);
+ if (item.getItemId() != R.id.draw_menu_clear) {
+ item.setVisible(false);
}
- mView.invalidate();
- return true;
}
- });
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ clearDrawing();
+ return true;
+ }
+ });
+ } else {
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ selectMenuItem(item);
+ return true;
+ }
+ });
+ }
popupMenu.show();
+ ((FilterShowActivity)mContext).onShowMenu(popupMenu);
}
- public void showSizeDialog(final MenuItem item) {
- FilterShowActivity ctx = mImageShow.getActivity();
- final Dialog dialog = new Dialog(ctx);
- dialog.setTitle(R.string.draw_size_title);
- dialog.setContentView(R.layout.filtershow_draw_size);
- final SeekBar bar = (SeekBar) dialog.findViewById(R.id.sizeSeekBar);
+ protected void selectMenuItem(MenuItem item) {
+ ImageFilterDraw filter = (ImageFilterDraw) mImageShow.getCurrentFilter();
+ FilterDrawRepresentation rep = getDrawRep();
+ if (rep == null) {
+ return;
+ }
+
+ switch (item.getItemId()) {
+ case R.id.draw_menu_clear:
+ clearDrawing();
+ break;
+ case R.id.draw_menu_size:
+ rep.setPramMode(FilterDrawRepresentation.PARAM_SIZE);
+ break;
+ case R.id.draw_menu_style:
+ rep.setPramMode(FilterDrawRepresentation.PARAM_STYLE);
+ break;
+ case R.id.draw_menu_color:
+ rep.setPramMode(FilterDrawRepresentation.PARAM_COLOR);
+ break;
+ }
+ if (item.getItemId() != R.id.draw_menu_clear) {
+ mParameterString = item.getTitle().toString();
+ updateText();
+ }
+ if (mControl instanceof ColorChooser) {
+ ColorChooser c = (ColorChooser) mControl;
+ mBasColors = c.getColorSet();
+ }
+ control(rep.getCurrentParam(), mEditControl);
+ if (mControl instanceof ColorChooser) {
+ ColorChooser c = (ColorChooser) mControl;
+ c.setColorSet(mBasColors);
+ }
+ mControl.updateUI();
+ mView.invalidate();
+ }
+
+ public void clearDrawing(){
ImageDraw idraw = (ImageDraw) mImageShow;
- bar.setProgress(idraw.getSize());
- Button button = (Button) dialog.findViewById(R.id.sizeAcceptButton);
- button.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View arg0) {
- int p = bar.getProgress();
- ImageDraw idraw = (ImageDraw) mImageShow;
- idraw.setSize(p + 1);
- dialog.dismiss();
- }
- });
- dialog.show();
+ idraw.resetParameter();
+ commitLocalRepresentation();
}
- public void showColorGrid(final MenuItem item) {
- RGBListener cl = new RGBListener() {
- @Override
- public void setColor(int rgb) {
- ImageDraw idraw = (ImageDraw) mImageShow;
- idraw.setColor(rgb);
- }
- };
- ColorGridDialog cpd = new ColorGridDialog(mImageShow.getActivity(), cl);
- cpd.show();
- LayoutParams params = cpd.getWindow().getAttributes();
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ if (ParametricEditor.useCompact(mContext)) {
+ super.setUtilityPanelUI(actionButton, editControl);
+ return;
+ }
+
+ mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+ if (mSeekBar != null) {
+ mSeekBar.setVisibility(View.GONE);
+ }
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_draw_ui, (ViewGroup) editControl, true);
+
+ mTabletUI = new EditorDrawTabletUI(this, mContext, lp);
+ mDrawString = mContext.getResources().getString(R.string.imageDraw).toUpperCase();
+ setMenuIcon(true);
+
}
+
+ FilterDrawRepresentation getDrawRep() {
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep instanceof FilterDrawRepresentation) {
+ return (FilterDrawRepresentation) rep;
+ }
+ return null;
+ }
+
+ @Override
+ public void computeIcon(int index, BitmapCaller caller) {
+ Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), brushIcons[index]);
+ caller.available(bitmap);
+ }
+
+ public int getBrushIcon(int type) {
+ return brushIcons[type];
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorDrawTabletUI.java b/src/com/android/gallery3d/filtershow/editors/EditorDrawTabletUI.java
new file mode 100644
index 0000000..83d89c9
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorDrawTabletUI.java
@@ -0,0 +1,278 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.app.ActionBar;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.colorpicker.ColorCompareView;
+import com.android.gallery3d.filtershow.colorpicker.ColorHueView;
+import com.android.gallery3d.filtershow.colorpicker.ColorListener;
+import com.android.gallery3d.filtershow.colorpicker.ColorOpacityView;
+import com.android.gallery3d.filtershow.colorpicker.ColorSVRectView;
+import com.android.gallery3d.filtershow.controller.BasicParameterInt;
+import com.android.gallery3d.filtershow.controller.BasicParameterStyle;
+import com.android.gallery3d.filtershow.controller.ParameterColor;
+import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
+
+import java.util.Arrays;
+
+public class EditorDrawTabletUI {
+ private EditorDraw mEditorDraw;
+ private int[] mBrushIcons;
+ private static int sIconDim = 120;
+ private int mSelectedColorButton;
+ private int mSelectedStyleButton;
+ private FilterDrawRepresentation mRep;
+ private Button[] mColorButton;
+ private ImageButton[] mStyleButton;
+ private ColorHueView mHueView;
+ private ColorSVRectView mSatValView;
+ private ColorOpacityView mOpacityView;
+ private ColorCompareView mColorCompareView;
+ private TextView mDrawSizeValue;
+
+ private int[] mBasColors;
+ private int mSelected;
+ private int mTransparent;
+ private SeekBar mdrawSizeSeekBar;
+ private int[] ids = {
+ R.id.draw_color_button01,
+ R.id.draw_color_button02,
+ R.id.draw_color_button03,
+ R.id.draw_color_button04,
+ R.id.draw_color_button05,
+ };
+
+ public void setDrawRepresentation(FilterDrawRepresentation rep) {
+ mRep = rep;
+ BasicParameterInt size;
+ size = (BasicParameterInt) mRep.getParam(FilterDrawRepresentation.PARAM_SIZE);
+ mdrawSizeSeekBar.setMax(size.getMaximum() - size.getMinimum());
+ mdrawSizeSeekBar.setProgress(size.getValue());
+
+ ParameterColor color;
+ color = (ParameterColor) mRep.getParam(FilterDrawRepresentation.PARAM_COLOR);
+ color.setValue(mBasColors[mSelectedColorButton]);
+ BasicParameterStyle style;
+ style = (BasicParameterStyle) mRep.getParam(FilterDrawRepresentation.PARAM_STYLE);
+ style.setSelected(mSelectedStyleButton);
+ }
+
+ public EditorDrawTabletUI(EditorDraw editorDraw, Context context, LinearLayout lp) {
+ mEditorDraw = editorDraw;
+ mBasColors = editorDraw.mBasColors;
+ mBrushIcons = editorDraw.brushIcons;
+ Resources res = context.getResources();
+ sIconDim = res.getDimensionPixelSize(R.dimen.draw_style_icon_dim);
+ LinearLayout buttonContainer = (LinearLayout) lp.findViewById(R.id.listStyles);
+
+ mdrawSizeSeekBar = (SeekBar) lp.findViewById(R.id.drawSizeSeekBar);
+ mDrawSizeValue = (TextView) lp.findViewById(R.id.drawSizeValue);
+
+ Button clearButton = (Button) lp.findViewById(R.id.clearButton);
+ clearButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mEditorDraw.clearDrawing();
+ }
+ });
+
+ mdrawSizeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ BasicParameterInt size;
+ size = (BasicParameterInt) mRep.getParam(FilterDrawRepresentation.PARAM_SIZE);
+ size.setValue(progress + size.getMinimum());
+ mEditorDraw.commitLocalRepresentation();
+ int val = progress + size.getMinimum();
+ mDrawSizeValue.setText(((val>0)?"+":"")+val);
+ }
+ });
+
+ ActionBar.LayoutParams params = new ActionBar.LayoutParams(sIconDim, sIconDim);
+ mStyleButton = new ImageButton[mBrushIcons.length];
+ for (int i = 0; i < mBrushIcons.length; i++) {
+ final ImageButton button = new ImageButton(context);
+ mStyleButton[i] = button;
+ button.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ button.setLayoutParams(params);
+ Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), mBrushIcons[i]);
+ button.setImageBitmap(bitmap);
+ button.setBackgroundResource(android.R.color.transparent);
+ buttonContainer.addView(button);
+ final int current = i;
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mSelectedStyleButton = current;
+ if (mRep == null) {
+ return;
+ }
+ BasicParameterStyle style = (BasicParameterStyle)
+ mRep.getParam(FilterDrawRepresentation.PARAM_STYLE);
+ style.setSelected(current);
+ resetStyle();
+ mEditorDraw.commitLocalRepresentation();
+ }
+ });
+ }
+
+ final LinearLayout ctls = (LinearLayout) lp.findViewById(R.id.controls);
+ final LinearLayout pick = (LinearLayout) lp.findViewById(R.id.colorPicker);
+ Button b = (Button) lp.findViewById(R.id.draw_color_popupbutton);
+ b.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ boolean b = ctls.getVisibility() == View.VISIBLE;
+ ctls.setVisibility((b) ? View.GONE : View.VISIBLE);
+ pick.setVisibility((!b) ? View.GONE : View.VISIBLE);
+ }
+ }
+ );
+
+ mTransparent = res.getColor(R.color.color_chooser_unslected_border);
+ mSelected = res.getColor(R.color.color_chooser_slected_border);
+
+ mColorButton = new Button[ids.length];
+ for (int i = 0; i < ids.length; i++) {
+ mColorButton[i] = (Button) lp.findViewById(ids[i]);
+
+ float[] hsvo = new float[4];
+ Color.colorToHSV(mBasColors[i], hsvo);
+ hsvo[3] = (0xFF & (mBasColors[i] >> 24)) / (float) 255;
+ mColorButton[i].setTag(hsvo);
+ GradientDrawable sd = ((GradientDrawable) mColorButton[i].getBackground());
+
+ sd.setColor(mBasColors[i]);
+ sd.setStroke(3, (0 == i) ? mSelected : mTransparent);
+
+ final int buttonNo = i;
+ mColorButton[i].setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+
+ mSelectedColorButton = buttonNo;
+ float[] hsvo = Arrays.copyOf((float[]) mColorButton[buttonNo].getTag(), 4);
+ resetBorders();
+ if (mRep == null) {
+ return;
+ }
+ ParameterColor pram;
+ pram = (ParameterColor) mRep.getParam(FilterDrawRepresentation.PARAM_COLOR);
+ pram.setValue(mBasColors[mSelectedColorButton]);
+ mEditorDraw.commitLocalRepresentation();
+ mHueView.setColor(hsvo);
+ mSatValView.setColor(hsvo);
+ mOpacityView.setColor(hsvo);
+ mColorCompareView.setColor(hsvo);
+ mColorCompareView.setOrigColor(hsvo);
+ }
+ });
+ }
+
+ mHueView = (ColorHueView) lp.findViewById(R.id.ColorHueView);
+ mSatValView = (ColorSVRectView) lp.findViewById(R.id.colorRectView);
+ mOpacityView = (ColorOpacityView) lp.findViewById(R.id.colorOpacityView);
+ mColorCompareView = (ColorCompareView) lp.findViewById(R.id.btnSelect);
+
+ float[] hsvo = new float[4];
+ Color.colorToHSV(mBasColors[0], hsvo);
+ hsvo[3] = (0xFF & (mBasColors[0] >> 24)) / (float) 255;
+
+ mColorCompareView.setOrigColor(hsvo);
+ ColorListener[] colorViews = {mHueView, mSatValView, mOpacityView, mColorCompareView};
+ for (int i = 0; i < colorViews.length; i++) {
+ colorViews[i].setColor(hsvo);
+
+ for (int j = 0; j < colorViews.length; j++) {
+ if (i == j) {
+ continue;
+ }
+ colorViews[i].addColorListener(colorViews[j]);
+ }
+ }
+ ColorListener colorListener = new ColorListener() {
+
+ @Override
+ public void setColor(float[] hsvo) {
+ int color = Color.HSVToColor((int) (hsvo[3] * 255), hsvo);
+ Button b = mColorButton[mSelectedColorButton];
+ float[] f = (float[]) b.getTag();
+ System.arraycopy(hsvo, 0, f, 0, 4);
+ mBasColors[mSelectedColorButton] = color;
+ GradientDrawable sd = ((GradientDrawable) b.getBackground());
+ sd.setColor(color);
+ resetBorders();
+ ParameterColor pram;
+ pram = (ParameterColor) mRep.getParam(FilterDrawRepresentation.PARAM_COLOR);
+ pram.setValue(color);
+ mEditorDraw.commitLocalRepresentation();
+ }
+
+ @Override
+ public void addColorListener(ColorListener l) {
+ }
+ };
+
+ for (int i = 0; i < colorViews.length; i++) {
+ colorViews[i].addColorListener(colorListener);
+ }
+
+ }
+
+ public void resetStyle() {
+ for (int i = 0; i < mStyleButton.length; i++) {
+ int rid = (i == mSelectedStyleButton) ? android.R.color.holo_blue_light :
+ android.R.color.transparent;
+ mStyleButton[i].setBackgroundResource(rid);
+
+ }
+ }
+
+ private void resetBorders() {
+ for (int i = 0; i < ids.length; i++) {
+ final Button button = mColorButton[i];
+
+ GradientDrawable sd = ((GradientDrawable) button.getBackground());
+ sd.setColor(mBasColors[i]);
+ sd.setStroke(3, (mSelectedColorButton == i) ? mSelected : mTransparent);
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorFlip.java b/src/com/android/gallery3d/filtershow/editors/EditorFlip.java
deleted file mode 100644
index de6240c..0000000
--- a/src/com/android/gallery3d/filtershow/editors/EditorFlip.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.editors;
-
-import android.content.Context;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.imageshow.ImageFlip;
-import com.android.gallery3d.filtershow.imageshow.MasterImage;
-
-public class EditorFlip extends Editor implements EditorInfo {
- public static final String LOGTAG = "EditorFlip";
- public static final int ID = R.id.editorFlip;
- ImageFlip mImageFlip;
-
- public EditorFlip() {
- super(ID);
- }
-
- @Override
- public void createEditor(Context context, FrameLayout frameLayout) {
- super.createEditor(context, frameLayout);
- if (mImageFlip == null) {
- mImageFlip = new ImageFlip(context);
- }
- mView = mImageShow = mImageFlip;
- mImageFlip.setImageLoader(MasterImage.getImage().getImageLoader());
- mImageFlip.setEditor(this);
- mImageFlip.syncLocalToMasterGeometry();
- }
-
- @Override
- public void openUtilityPanel(final LinearLayout accessoryViewList) {
- final Button button = (Button) accessoryViewList.findViewById(R.id.applyEffect);
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- mImageFlip.flip();
- mImageFlip.saveAndSetPreset();
- }
- });
- }
-
- @Override
- public int getTextId() {
- return R.string.mirror;
- }
-
- @Override
- public int getOverlayId() {
- return R.drawable.filtershow_button_geometry_flip;
- }
-
- @Override
- public boolean getOverlayOnly() {
- return true;
- }
-
- @Override
- public boolean showsSeekBar() {
- return false;
- }
-
- @Override
- public boolean showsPopupIndicator() {
- return false;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorGrad.java b/src/com/android/gallery3d/filtershow/editors/EditorGrad.java
new file mode 100644
index 0000000..0591216
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorGrad.java
@@ -0,0 +1,433 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.PopupMenu;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+import android.widget.ToggleButton;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.controller.Control;
+import com.android.gallery3d.filtershow.controller.FilterView;
+import com.android.gallery3d.filtershow.controller.Parameter;
+import com.android.gallery3d.filtershow.controller.ParameterActionAndInt;
+import com.android.gallery3d.filtershow.filters.FilterGradRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.imageshow.ImageGrad;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class EditorGrad extends ParametricEditor
+ implements OnSeekBarChangeListener, ParameterActionAndInt {
+ private static final String LOGTAG = "EditorGrad";
+ public static final int ID = R.id.editorGrad;
+ PopupMenu mPopupMenu;
+ ToggleButton mAddModeButton;
+ String mEffectName = "";
+ private static final int MODE_BRIGHTNESS = FilterGradRepresentation.PARAM_BRIGHTNESS;
+ private static final int MODE_SATURATION = FilterGradRepresentation.PARAM_SATURATION;
+ private static final int MODE_CONTRAST = FilterGradRepresentation.PARAM_CONTRAST;
+ private static final int ADD_ICON = R.drawable.ic_grad_add;
+ private static final int DEL_ICON = R.drawable.ic_grad_del;
+ private int mSliderMode = MODE_BRIGHTNESS;
+ ImageGrad mImageGrad;
+ ParamAdapter []mAdapters = new ParamAdapter[3];
+ public EditorGrad() {
+ super(ID, R.layout.filtershow_grad_editor, R.id.gradEditor);
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ mImageGrad = (ImageGrad) mImageShow;
+ mImageGrad.setEditor(this);
+
+ }
+
+ public void clearAddMode() {
+ mAddModeButton.setChecked(false);
+ FilterRepresentation tmpRep = getLocalRepresentation();
+ if (tmpRep instanceof FilterGradRepresentation) {
+ updateMenuItems((FilterGradRepresentation) tmpRep);
+ }
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ super.reflectCurrentFilter();
+ FilterRepresentation tmpRep = getLocalRepresentation();
+ if (tmpRep instanceof FilterGradRepresentation) {
+ FilterGradRepresentation rep = (FilterGradRepresentation) tmpRep;
+ boolean f = rep.showParameterValue();
+
+ mImageGrad.setRepresentation(rep);
+ }
+ }
+
+ public void updateSeekBar(FilterGradRepresentation rep) {
+ if (ParametricEditor.useCompact(mContext)) {
+ mControl.updateUI();
+ } else {
+ updateParameters();
+ }
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) {
+ FilterRepresentation tmpRep = getLocalRepresentation();
+ if (tmpRep instanceof FilterGradRepresentation) {
+ FilterGradRepresentation rep = (FilterGradRepresentation) tmpRep;
+ int min = rep.getParameterMin(mSliderMode);
+ int value = progress + min;
+ rep.setParameter(mSliderMode, value);
+ mView.invalidate();
+ commitLocalRepresentation();
+ }
+ }
+
+ @Override
+ public void openUtilityPanel(final LinearLayout accessoryViewList) {
+ Button view = (Button) accessoryViewList.findViewById(R.id.applyEffect);
+ if (useCompact(mContext)) {
+ view.setText(mContext.getString(R.string.editor_grad_brightness));
+ view.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ showPopupMenu(accessoryViewList);
+ }
+ });
+
+ setUpPopupMenu(view);
+ setEffectName();
+ } else {
+ view.setText(mContext.getString(R.string.grad));
+ }
+ }
+
+ private void updateMenuItems(FilterGradRepresentation rep) {
+ int n = rep.getNumberOfBands();
+ }
+
+ public void setEffectName() {
+ if (mPopupMenu != null) {
+ MenuItem item = mPopupMenu.getMenu().findItem(R.id.editor_grad_brightness);
+ mEffectName = item.getTitle().toString();
+ }
+ }
+
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ if (ParametricEditor.useCompact(mContext)) {
+ super.setUtilityPanelUI(actionButton, editControl);
+ return;
+ }
+ mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+ if (mSeekBar != null) {
+ mSeekBar.setVisibility(View.GONE);
+ }
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_grad_ui, (ViewGroup) editControl, true);
+
+ mAdapters[0] = new ParamAdapter(R.id.gradContrastSeekBar, R.id.gradContrastValue,
+ lp, MODE_CONTRAST);
+ mAdapters[1] = new ParamAdapter(R.id.gradBrightnessSeekBar, R.id.gradBrightnessValue,
+ lp, MODE_BRIGHTNESS);
+ mAdapters[2] = new ParamAdapter(R.id.gradSaturationSeekBar, R.id.gradSaturationValue,
+ lp, MODE_SATURATION);
+ lp.findViewById(R.id.gradAddButton).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ fireLeftAction();
+ }
+ });
+ lp.findViewById(R.id.gradDelButton).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ fireRightAction();
+ }
+ });
+ setMenuIcon(false);
+ }
+
+ public void updateParameters() {
+ FilterGradRepresentation rep = getGradRepresentation();
+ for (int i = 0; i < mAdapters.length; i++) {
+ mAdapters[i].updateValues(rep);
+ }
+ }
+
+ private class ParamAdapter implements OnSeekBarChangeListener {
+ SeekBar mSlider;
+ TextView mTextView;
+ int mMin = -100;
+ int mMax = 100;
+ int mMode;
+
+ public ParamAdapter(int seekId, int textId, LinearLayout layout, int mode) {
+ mSlider = (SeekBar) layout.findViewById(seekId);
+ mTextView = (TextView) layout.findViewById(textId);
+ mSlider.setMax(mMax - mMin);
+ mMode = mode;
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep != null){
+ updateValues(rep);
+ }
+ mSlider.setOnSeekBarChangeListener(this);
+ }
+
+ public void updateValues(FilterGradRepresentation rep) {
+ int value = rep.getParameter(mMode);
+ mTextView.setText(Integer.toString(value));
+ mSlider.setProgress(value - mMin);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ FilterGradRepresentation rep = getGradRepresentation();
+ int value = progress + mMin;
+ rep.setParameter(mMode, value);
+ if (mSliderMode != mMode) {
+ mSliderMode = mMode;
+ mEffectName = mContext.getResources().getString(getModeNameid(mMode));
+ mEffectName = mEffectName.toUpperCase();
+ }
+ mTextView.setText(Integer.toString(value));
+ mView.invalidate();
+ commitLocalRepresentation();
+ }
+
+ private int getModeNameid(int mode) {
+ switch (mode) {
+ case MODE_CONTRAST:
+ return R.string.editor_grad_contrast;
+ case MODE_BRIGHTNESS:
+ return R.string.editor_grad_brightness;
+ case MODE_SATURATION:
+ return R.string.editor_grad_saturation;
+ }
+ return 0;
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+
+ }
+ }
+
+ private void showPopupMenu(LinearLayout accessoryViewList) {
+ Button button = (Button) accessoryViewList.findViewById(R.id.applyEffect);
+ if (button == null) {
+ return;
+ }
+
+ if (mPopupMenu == null) {
+ setUpPopupMenu(button);
+ }
+ mPopupMenu.show();
+ ((FilterShowActivity)mContext).onShowMenu(mPopupMenu);
+ }
+
+ private void setUpPopupMenu(Button button) {
+ mPopupMenu = new PopupMenu(mImageShow.getActivity(), button);
+ mPopupMenu.getMenuInflater()
+ .inflate(R.menu.filtershow_menu_grad, mPopupMenu.getMenu());
+ FilterGradRepresentation rep = (FilterGradRepresentation) getLocalRepresentation();
+ if (rep == null) {
+ return;
+ }
+ updateMenuItems(rep);
+ hackFixStrings(mPopupMenu.getMenu());
+ setEffectName();
+ updateText();
+
+ mPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ FilterRepresentation tmpRep = getLocalRepresentation();
+
+ if (tmpRep instanceof FilterGradRepresentation) {
+ FilterGradRepresentation rep = (FilterGradRepresentation) tmpRep;
+ int cmdID = item.getItemId();
+ switch (cmdID) {
+ case R.id.editor_grad_brightness:
+ mSliderMode = MODE_BRIGHTNESS;
+ mEffectName = item.getTitle().toString();
+ break;
+ case R.id.editor_grad_contrast:
+ mSliderMode = MODE_CONTRAST;
+ mEffectName = item.getTitle().toString();
+ break;
+ case R.id.editor_grad_saturation:
+ mSliderMode = MODE_SATURATION;
+ mEffectName = item.getTitle().toString();
+ break;
+ }
+ updateMenuItems(rep);
+ updateSeekBar(rep);
+
+ commitLocalRepresentation();
+ mView.invalidate();
+ }
+ return true;
+ }
+ });
+ }
+
+ @Override
+ public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep == null) {
+ return mEffectName;
+ }
+ int val = rep.getParameter(mSliderMode);
+ return mEffectName.toUpperCase() + ((val > 0) ? " +" : " ") + val;
+ }
+
+ private FilterGradRepresentation getGradRepresentation() {
+ FilterRepresentation tmpRep = getLocalRepresentation();
+ if (tmpRep instanceof FilterGradRepresentation) {
+ return (FilterGradRepresentation) tmpRep;
+ }
+ return null;
+ }
+
+ @Override
+ public int getMaximum() {
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep == null) {
+ return 0;
+ }
+ return rep.getParameterMax(mSliderMode);
+ }
+
+ @Override
+ public int getMinimum() {
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep == null) {
+ return 0;
+ }
+ return rep.getParameterMin(mSliderMode);
+ }
+
+ @Override
+ public int getDefaultValue() {
+ return 0;
+ }
+
+ @Override
+ public int getValue() {
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep == null) {
+ return 0;
+ }
+ return rep.getParameter(mSliderMode);
+ }
+
+ @Override
+ public String getValueString() {
+ return null;
+ }
+
+ @Override
+ public void setValue(int value) {
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep == null) {
+ return;
+ }
+ rep.setParameter(mSliderMode, value);
+ }
+
+ @Override
+ public String getParameterName() {
+ return mEffectName;
+ }
+
+ @Override
+ public String getParameterType() {
+ return sParameterType;
+ }
+
+ @Override
+ public void setController(Control c) {
+
+ }
+
+ @Override
+ public void fireLeftAction() {
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep == null) {
+ return;
+ }
+ rep.addBand(MasterImage.getImage().getOriginalBounds());
+ updateMenuItems(rep);
+ updateSeekBar(rep);
+
+ commitLocalRepresentation();
+ mView.invalidate();
+ }
+
+ @Override
+ public int getLeftIcon() {
+ return ADD_ICON;
+ }
+
+ @Override
+ public void fireRightAction() {
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep == null) {
+ return;
+ }
+ rep.deleteCurrentBand();
+
+ updateMenuItems(rep);
+ updateSeekBar(rep);
+ commitLocalRepresentation();
+ mView.invalidate();
+ }
+
+ @Override
+ public int getRightIcon() {
+ return DEL_ICON;
+ }
+
+ @Override
+ public void setFilterView(FilterView editor) {
+
+ }
+
+ @Override
+ public void copyFrom(Parameter src) {
+
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorMirror.java b/src/com/android/gallery3d/filtershow/editors/EditorMirror.java
new file mode 100644
index 0000000..d6d9ee7
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorMirror.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.imageshow.ImageMirror;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class EditorMirror extends Editor implements EditorInfo {
+ public static final String TAG = EditorMirror.class.getSimpleName();
+ public static final int ID = R.id.editorFlip;
+ ImageMirror mImageMirror;
+
+ public EditorMirror() {
+ super(ID);
+ mChangesGeometry = true;
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ if (mImageMirror == null) {
+ mImageMirror = new ImageMirror(context);
+ }
+ mView = mImageShow = mImageMirror;
+ mImageMirror.setEditor(this);
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ MasterImage master = MasterImage.getImage();
+ master.setCurrentFilterRepresentation(master.getPreset()
+ .getFilterWithSerializationName(FilterMirrorRepresentation.SERIALIZATION_NAME));
+ super.reflectCurrentFilter();
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep == null || rep instanceof FilterMirrorRepresentation) {
+ mImageMirror.setFilterMirrorRepresentation((FilterMirrorRepresentation) rep);
+ } else {
+ Log.w(TAG, "Could not reflect current filter, not of type: "
+ + FilterMirrorRepresentation.class.getSimpleName());
+ }
+ mImageMirror.invalidate();
+ }
+
+ @Override
+ public void openUtilityPanel(final LinearLayout accessoryViewList) {
+ final Button button = (Button) accessoryViewList.findViewById(R.id.applyEffect);
+ button.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ mImageMirror.flip();
+ }
+ });
+ }
+
+ @Override
+ public void finalApplyCalled() {
+ commitLocalRepresentation(mImageMirror.getFinalRepresentation());
+ }
+
+ @Override
+ public int getTextId() {
+ return R.string.mirror;
+ }
+
+ @Override
+ public int getOverlayId() {
+ return R.drawable.filtershow_button_geometry_flip;
+ }
+
+ @Override
+ public boolean getOverlayOnly() {
+ return true;
+ }
+
+ @Override
+ public boolean showsSeekBar() {
+ return false;
+ }
+
+ @Override
+ public boolean showsPopupIndicator() {
+ return false;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
index e35bc8f..a60b672 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
@@ -28,7 +28,7 @@
import android.widget.LinearLayout;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.HistoryAdapter;
+import com.android.gallery3d.filtershow.history.HistoryManager;
import com.android.gallery3d.filtershow.category.MainPanel;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.state.StatePanel;
@@ -54,7 +54,7 @@
public void cancelCurrentFilter() {
MasterImage masterImage = MasterImage.getImage();
- HistoryAdapter adapter = masterImage.getHistory();
+ HistoryManager adapter = masterImage.getHistory();
int position = adapter.undo();
masterImage.onHistoryItemClick(position);
@@ -88,26 +88,24 @@
activity.backToMain();
}
});
- applyButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- MasterImage.getImage().invalidateFiltersOnly();
- FilterShowActivity activity = (FilterShowActivity) getActivity();
- activity.backToMain();
- }
- });
Button toggleState = (Button) mMainView.findViewById(R.id.toggle_state);
-
mEditor = activity.getEditor(mEditorID);
if (mEditor != null) {
mEditor.setUpEditorUI(actionControl, editControl, editTitle, toggleState);
- mEditor.getImageShow().select();
mEditor.reflectCurrentFilter();
if (mEditor.useUtilityPanel()) {
mEditor.openUtilityPanel((LinearLayout) actionControl);
}
}
+ applyButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ mEditor.finalApplyCalled();
+ activity.backToMain();
+ }
+ });
showImageStatePanel(activity.isShowingImageStatePanel());
return mMainView;
@@ -122,20 +120,35 @@
}
public void showImageStatePanel(boolean show) {
- if (mMainView.findViewById(R.id.state_panel_container) == null) {
- return;
+ View container = mMainView.findViewById(R.id.state_panel_container);
+ FragmentTransaction transaction = null;
+ boolean child = false;
+ if (container == null) {
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ container = activity.getMainStatePanelContainer(R.id.state_panel_container);
+ } else {
+ transaction = getChildFragmentManager().beginTransaction();
+ child = true;
}
- FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
+ if (container == null) {
+ return;
+ } else {
+ transaction = getFragmentManager().beginTransaction();
+ }
Fragment panel = getActivity().getSupportFragmentManager().findFragmentByTag(
MainPanel.FRAGMENT_TAG);
if (panel == null || panel instanceof MainPanel) {
transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
}
if (show) {
+ container.setVisibility(View.VISIBLE);
StatePanel statePanel = new StatePanel();
transaction.replace(R.id.state_panel_container, statePanel, StatePanel.FRAGMENT_TAG);
} else {
Fragment statePanel = getChildFragmentManager().findFragmentByTag(StatePanel.FRAGMENT_TAG);
+ if (child) {
+ statePanel = getFragmentManager().findFragmentByTag(StatePanel.FRAGMENT_TAG);
+ }
if (statePanel != null) {
transaction.remove(statePanel);
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorRotate.java b/src/com/android/gallery3d/filtershow/editors/EditorRotate.java
index a637c08..9452bf0 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorRotate.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorRotate.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
+import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -24,16 +25,19 @@
import android.widget.LinearLayout;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
import com.android.gallery3d.filtershow.imageshow.ImageRotate;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
public class EditorRotate extends Editor implements EditorInfo {
- public static final String LOGTAG = "EditorRotate";
+ public static final String TAG = EditorRotate.class.getSimpleName();
public static final int ID = R.id.editorRotate;
ImageRotate mImageRotate;
public EditorRotate() {
super(ID);
+ mChangesGeometry = true;
}
@Override
@@ -43,9 +47,23 @@
mImageRotate = new ImageRotate(context);
}
mView = mImageShow = mImageRotate;
- mImageRotate.setImageLoader(MasterImage.getImage().getImageLoader());
mImageRotate.setEditor(this);
- mImageRotate.syncLocalToMasterGeometry();
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ MasterImage master = MasterImage.getImage();
+ master.setCurrentFilterRepresentation(master.getPreset()
+ .getFilterWithSerializationName(FilterRotateRepresentation.SERIALIZATION_NAME));
+ super.reflectCurrentFilter();
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep == null || rep instanceof FilterRotateRepresentation) {
+ mImageRotate.setFilterRotateRepresentation((FilterRotateRepresentation) rep);
+ } else {
+ Log.w(TAG, "Could not reflect current filter, not of type: "
+ + FilterRotateRepresentation.class.getSimpleName());
+ }
+ mImageRotate.invalidate();
}
@Override
@@ -55,13 +73,19 @@
@Override
public void onClick(View arg0) {
mImageRotate.rotate();
- button.setText(mContext.getString(getTextId()) + " " + mImageRotate.getLocalValue());
- mImageRotate.saveAndSetPreset();
+ String displayVal = mContext.getString(getTextId()) + " "
+ + mImageRotate.getLocalValue();
+ button.setText(displayVal);
}
});
}
@Override
+ public void finalApplyCalled() {
+ commitLocalRepresentation(mImageRotate.getFinalRepresentation());
+ }
+
+ @Override
public int getTextId() {
return R.string.rotate;
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
index dbc6ca0..ff84ba8 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
@@ -17,25 +17,26 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
-import android.view.View;
+import android.util.Log;
import android.widget.FrameLayout;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation;
import com.android.gallery3d.filtershow.imageshow.ImageStraighten;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
public class EditorStraighten extends Editor implements EditorInfo {
+ public static final String TAG = EditorStraighten.class.getSimpleName();
public static final int ID = R.id.editorStraighten;
ImageStraighten mImageStraighten;
- GeometryMetadata mGeometryMetadata;
public EditorStraighten() {
super(ID);
mShowParameter = SHOW_VALUE_INT;
+ mChangesGeometry = true;
}
- // TODO use filter reflection like
@Override
public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
String apply = context.getString(R.string.apply_effect);
@@ -50,9 +51,29 @@
mImageStraighten = new ImageStraighten(context);
}
mView = mImageShow = mImageStraighten;
- mImageStraighten.setImageLoader(MasterImage.getImage().getImageLoader());
mImageStraighten.setEditor(this);
- mImageStraighten.syncLocalToMasterGeometry();
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ MasterImage master = MasterImage.getImage();
+ master.setCurrentFilterRepresentation(master.getPreset().getFilterWithSerializationName(
+ FilterStraightenRepresentation.SERIALIZATION_NAME));
+ super.reflectCurrentFilter();
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep == null || rep instanceof FilterStraightenRepresentation) {
+ mImageStraighten
+ .setFilterStraightenRepresentation((FilterStraightenRepresentation) rep);
+ } else {
+ Log.w(TAG, "Could not reflect current filter, not of type: "
+ + FilterStraightenRepresentation.class.getSimpleName());
+ }
+ mImageStraighten.invalidate();
+ }
+
+ @Override
+ public void finalApplyCalled() {
+ commitLocalRepresentation(mImageStraighten.getFinalRepresentation());
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorVignette.java b/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
index 7127b21..630a1a9 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
@@ -17,11 +17,23 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
+import android.os.Handler;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.PopupMenu;
+import android.widget.SeekBar;
+import android.widget.TextView;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.controller.BasicParameterInt;
+import com.android.gallery3d.filtershow.controller.Parameter;
import com.android.gallery3d.filtershow.filters.FilterVignetteRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.ImageVignette;
public class EditorVignette extends ParametricEditor {
@@ -29,6 +41,33 @@
private static final String LOGTAG = "EditorVignettePlanet";
ImageVignette mImageVignette;
+ private SeekBar mVignetteBar;
+ private SeekBar mExposureBar;
+ private SeekBar mSaturationBar;
+ private SeekBar mContrastBar;
+ private SeekBar mFalloffBar;
+
+
+ private TextView mVignetteValue;
+ private TextView mExposureValue;
+ private TextView mSaturationValue;
+ private TextView mContrastValue;
+ private TextView mFalloffValue;
+
+ private SwapButton mButton;
+ private final Handler mHandler = new Handler();
+
+ int[] mMenuStrings = {
+ R.string.vignette_main,
+ R.string.vignette_exposure,
+ R.string.vignette_saturation,
+ R.string.vignette_contrast,
+ R.string.vignette_falloff,
+ };
+
+ String mCurrentlyEditing = null;
+
+
public EditorVignette() {
super(ID, R.layout.filtershow_vignette_editor, R.id.imageVignette);
}
@@ -42,12 +81,300 @@
@Override
public void reflectCurrentFilter() {
- super.reflectCurrentFilter();
+ if (useCompact(mContext)) {
+ super.reflectCurrentFilter();
- FilterRepresentation rep = getLocalRepresentation();
- if (rep != null && getLocalRepresentation() instanceof FilterVignetteRepresentation) {
- FilterVignetteRepresentation drawRep = (FilterVignetteRepresentation) rep;
- mImageVignette.setRepresentation(drawRep);
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep != null && getLocalRepresentation() instanceof FilterVignetteRepresentation) {
+ FilterVignetteRepresentation drawRep = (FilterVignetteRepresentation) rep;
+ mImageVignette.setRepresentation(drawRep);
+ }
+ updateText();
+ return;
}
+ mLocalRepresentation = null;
+ if (getLocalRepresentation() != null
+ && getLocalRepresentation() instanceof FilterVignetteRepresentation) {
+ FilterVignetteRepresentation rep =
+ (FilterVignetteRepresentation) getLocalRepresentation();
+ int min;
+ int []mode = {
+ FilterVignetteRepresentation.MODE_VIGNETTE,
+ FilterVignetteRepresentation.MODE_EXPOSURE,
+ FilterVignetteRepresentation.MODE_SATURATION,
+ FilterVignetteRepresentation.MODE_CONTRAST,
+ FilterVignetteRepresentation.MODE_FALLOFF
+ };
+ SeekBar []sliders = {
+ mVignetteBar,
+ mExposureBar,
+ mSaturationBar,
+ mContrastBar,
+ mFalloffBar
+ };
+ TextView []label = {
+ mVignetteValue,
+ mExposureValue,
+ mSaturationValue,
+ mContrastValue,
+ mFalloffValue
+ };
+ for (int i = 0; i < mode.length; i++) {
+ BasicParameterInt p = (BasicParameterInt) rep.getFilterParameter(mode[i]);
+ int value = p.getValue();
+ sliders[i].setMax(p.getMaximum() - p.getMinimum());
+ sliders[i].setProgress(value - p.getMinimum());
+ label[i].setText("" + value);
+ }
+
+ mImageVignette.setRepresentation(rep);
+ String text = mContext.getString(rep.getTextId()).toUpperCase();
+ mFilterTitle.setText(text);
+ updateText();
+ }
+ }
+
+
+
+ @Override
+ public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep == null || !(rep instanceof FilterVignetteRepresentation)) {
+ return "";
+ }
+ FilterVignetteRepresentation csrep = (FilterVignetteRepresentation) rep;
+ int mode = csrep.getParameterMode();
+ String paramString;
+
+ paramString = mContext.getString(mMenuStrings[mode]);
+
+ int val = csrep.getCurrentParameter();
+ return paramString + ((val > 0) ? " +" : " ") + val;
+ }
+
+ @Override
+ public void openUtilityPanel(final LinearLayout accessoryViewList) {
+ mButton = (SwapButton) accessoryViewList.findViewById(R.id.applyEffect);
+ mButton.setText(mContext.getString(R.string.vignette_main));
+
+ if (useCompact(mContext)) {
+ final PopupMenu popupMenu = new PopupMenu(mImageShow.getActivity(), mButton);
+
+ popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_vignette,
+ popupMenu.getMenu());
+
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ selectMenuItem(item);
+ return true;
+ }
+ });
+ mButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ popupMenu.show();
+ ((FilterShowActivity)mContext).onShowMenu(popupMenu);
+ }
+ });
+ mButton.setListener(this);
+
+ FilterVignetteRepresentation csrep = getVignetteRep();
+ String menuString = mContext.getString(mMenuStrings[0]);
+ switchToMode(csrep, FilterVignetteRepresentation.MODE_VIGNETTE, menuString);
+ } else {
+ mButton.setText(mContext.getString(R.string.vignette_main));
+ }
+ }
+
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ if (useCompact(mContext)) {
+ super.setUtilityPanelUI(actionButton, editControl);
+ return;
+ }
+ mActionButton = actionButton;
+ mEditControl = editControl;
+ mEditTitle.setCompoundDrawables(null, null, null, null);
+ LinearLayout group = (LinearLayout) editControl;
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout controls = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_vignette_controls, group, false);
+ ViewGroup.LayoutParams lp = new LinearLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ controls.setLayoutParams(lp);
+ group.removeAllViews();
+ group.addView(controls);
+
+ mVignetteBar = (SeekBar) controls.findViewById(R.id.mainVignetteSeekbar);
+ mVignetteBar.setMax(200);
+ mVignetteBar.setOnSeekBarChangeListener(this);
+ mVignetteValue = (TextView) controls.findViewById(R.id.mainVignetteValue);
+ mExposureBar = (SeekBar) controls.findViewById(R.id.exposureSeekBar);
+ mExposureBar.setMax(200);
+ mExposureBar.setOnSeekBarChangeListener(this);
+ mExposureValue = (TextView) controls.findViewById(R.id.exposureValue);
+ mSaturationBar = (SeekBar) controls.findViewById(R.id.saturationSeekBar);
+ mSaturationBar.setMax(200);
+ mSaturationBar.setOnSeekBarChangeListener(this);
+ mSaturationValue = (TextView) controls.findViewById(R.id.saturationValue);
+ mContrastBar = (SeekBar) controls.findViewById(R.id.contrastSeekBar);
+ mContrastBar.setMax(200);
+ mContrastBar.setOnSeekBarChangeListener(this);
+ mContrastValue = (TextView) controls.findViewById(R.id.contrastValue);
+ mFalloffBar = (SeekBar) controls.findViewById(R.id.falloffSeekBar);
+ mFalloffBar.setMax(200);
+ mFalloffBar.setOnSeekBarChangeListener(this);
+ mFalloffValue = (TextView) controls.findViewById(R.id.falloffValue);
+ }
+
+ public int getParameterIndex(int id) {
+ switch (id) {
+ case R.id.editor_vignette_main:
+ return FilterVignetteRepresentation.MODE_VIGNETTE;
+ case R.id.editor_vignette_saturation:
+ return FilterVignetteRepresentation.MODE_SATURATION;
+ case R.id.editor_vignette_contrast:
+ return FilterVignetteRepresentation.MODE_CONTRAST;
+ case R.id.editor_vignette_exposure:
+ return FilterVignetteRepresentation.MODE_EXPOSURE;
+ case R.id.editor_vignette_falloff:
+ return FilterVignetteRepresentation.MODE_FALLOFF;
+ }
+ return -1;
+ }
+
+ @Override
+ public void detach() {
+ if (mButton == null) {
+ return;
+ }
+ mButton.setListener(null);
+ mButton.setOnClickListener(null);
+ }
+
+ private void updateSeekBar(FilterVignetteRepresentation rep) {
+ mControl.updateUI();
+ }
+
+ @Override
+ protected Parameter getParameterToEdit(FilterRepresentation rep) {
+ if (rep instanceof FilterVignetteRepresentation) {
+ FilterVignetteRepresentation csrep = (FilterVignetteRepresentation) rep;
+ Parameter param = csrep.getFilterParameter(csrep.getParameterMode());
+
+ return param;
+ }
+ return null;
+ }
+
+ private FilterVignetteRepresentation getVignetteRep() {
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep != null
+ && rep instanceof FilterVignetteRepresentation) {
+ FilterVignetteRepresentation csrep = (FilterVignetteRepresentation) rep;
+ return csrep;
+ }
+ return null;
+ }
+
+ protected void selectMenuItem(MenuItem item) {
+ if (getLocalRepresentation() != null
+ && getLocalRepresentation() instanceof FilterVignetteRepresentation) {
+ FilterVignetteRepresentation csrep =
+ (FilterVignetteRepresentation) getLocalRepresentation();
+
+ switchToMode(csrep, getParameterIndex(item.getItemId()), item.getTitle().toString());
+ }
+ }
+
+ protected void switchToMode(FilterVignetteRepresentation csrep, int mode, String title) {
+ if (csrep == null) {
+ return;
+ }
+ csrep.setParameterMode(mode);
+ mCurrentlyEditing = title;
+ mButton.setText(mCurrentlyEditing);
+ {
+ Parameter param = getParameterToEdit(csrep);
+
+ control(param, mEditControl);
+ }
+ updateSeekBar(csrep);
+ mView.invalidate();
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) {
+ FilterVignetteRepresentation rep = getVignetteRep();
+ int value = progress;
+ BasicParameterInt p;
+ switch (sbar.getId()) {
+ case R.id.mainVignetteSeekbar:
+ rep.setParameterMode(FilterVignetteRepresentation.MODE_VIGNETTE);
+ p = rep.getFilterParameter(rep.getParameterMode());
+ value += p.getMinimum();
+ mVignetteValue.setText("" + value);
+ break;
+ case R.id.exposureSeekBar:
+ rep.setParameterMode(FilterVignetteRepresentation.MODE_EXPOSURE);
+ p = rep.getFilterParameter(rep.getParameterMode());
+ value += p.getMinimum();
+ mExposureValue.setText("" + value);
+ break;
+ case R.id.saturationSeekBar:
+ rep.setParameterMode(FilterVignetteRepresentation.MODE_SATURATION);
+ p = rep.getFilterParameter(rep.getParameterMode());
+ value += p.getMinimum();
+ mSaturationValue.setText("" + value);
+ break;
+ case R.id.contrastSeekBar:
+ rep.setParameterMode(FilterVignetteRepresentation.MODE_CONTRAST);
+ p = rep.getFilterParameter(rep.getParameterMode());
+ value += p.getMinimum();
+ mContrastValue.setText("" + value);
+ break;
+ case R.id.falloffSeekBar:
+ rep.setParameterMode(FilterVignetteRepresentation.MODE_FALLOFF);
+ p = rep.getFilterParameter(rep.getParameterMode());
+ value += p.getMinimum();
+ mFalloffValue.setText("" + value);
+ break;
+ }
+ rep.setCurrentParameter(value);
+ commitLocalRepresentation();
+ }
+
+ @Override
+ public void swapLeft(MenuItem item) {
+ super.swapLeft(item);
+ mButton.setTranslationX(0);
+ mButton.animate().translationX(mButton.getWidth()).setDuration(SwapButton.ANIM_DURATION);
+ Runnable updateButton = new Runnable() {
+ @Override
+ public void run() {
+ mButton.animate().cancel();
+ mButton.setTranslationX(0);
+ }
+ };
+ mHandler.postDelayed(updateButton, SwapButton.ANIM_DURATION);
+ selectMenuItem(item);
+ }
+
+ @Override
+ public void swapRight(MenuItem item) {
+ super.swapRight(item);
+ mButton.setTranslationX(0);
+ mButton.animate().translationX(-mButton.getWidth()).setDuration(SwapButton.ANIM_DURATION);
+ Runnable updateButton = new Runnable() {
+ @Override
+ public void run() {
+ mButton.animate().cancel();
+ mButton.setTranslationX(0);
+ }
+ };
+ mHandler.postDelayed(updateButton, SwapButton.ANIM_DURATION);
+ selectMenuItem(item);
}
}
diff --git a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
index 9ec858c..c168657 100644
--- a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
+++ b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Point;
import android.util.Log;
import android.view.View;
@@ -30,11 +31,21 @@
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.controller.ActionSlider;
import com.android.gallery3d.filtershow.controller.BasicSlider;
+import com.android.gallery3d.filtershow.controller.ColorChooser;
import com.android.gallery3d.filtershow.controller.Control;
import com.android.gallery3d.filtershow.controller.Parameter;
import com.android.gallery3d.filtershow.controller.ParameterActionAndInt;
+import com.android.gallery3d.filtershow.controller.ParameterBrightness;
+import com.android.gallery3d.filtershow.controller.ParameterColor;
+import com.android.gallery3d.filtershow.controller.ParameterHue;
import com.android.gallery3d.filtershow.controller.ParameterInteger;
+import com.android.gallery3d.filtershow.controller.ParameterOpacity;
+import com.android.gallery3d.filtershow.controller.ParameterSaturation;
import com.android.gallery3d.filtershow.controller.ParameterStyles;
+import com.android.gallery3d.filtershow.controller.SliderBrightness;
+import com.android.gallery3d.filtershow.controller.SliderHue;
+import com.android.gallery3d.filtershow.controller.SliderOpacity;
+import com.android.gallery3d.filtershow.controller.SliderSaturation;
import com.android.gallery3d.filtershow.controller.StyleChooser;
import com.android.gallery3d.filtershow.controller.TitledSlider;
import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
@@ -56,6 +67,17 @@
static HashMap<String, Class> portraitMap = new HashMap<String, Class>();
static HashMap<String, Class> landscapeMap = new HashMap<String, Class>();
static {
+ portraitMap.put(ParameterSaturation.sParameterType, SliderSaturation.class);
+ landscapeMap.put(ParameterSaturation.sParameterType, SliderSaturation.class);
+ portraitMap.put(ParameterHue.sParameterType, SliderHue.class);
+ landscapeMap.put(ParameterHue.sParameterType, SliderHue.class);
+ portraitMap.put(ParameterOpacity.sParameterType, SliderOpacity.class);
+ landscapeMap.put(ParameterOpacity.sParameterType, SliderOpacity.class);
+ portraitMap.put(ParameterBrightness.sParameterType, SliderBrightness.class);
+ landscapeMap.put(ParameterBrightness.sParameterType, SliderBrightness.class);
+ portraitMap.put(ParameterColor.sParameterType, ColorChooser.class);
+ landscapeMap.put(ParameterColor.sParameterType, ColorChooser.class);
+
portraitMap.put(ParameterInteger.sParameterType, BasicSlider.class);
landscapeMap.put(ParameterInteger.sParameterType, TitledSlider.class);
portraitMap.put(ParameterActionAndInt.sParameterType, ActionSlider.class);
@@ -127,21 +149,9 @@
};
}
- // TODO: need a better way to decide which representation
- static boolean useCompact(Context context) {
- WindowManager w = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE));
- Point size = new Point();
- w.getDefaultDisplay().getSize(size);
- if (size.x < size.y) { // if tall than wider
- return true;
- }
- if (size.x < MINIMUM_WIDTH) {
- return true;
- }
- if (size.y < MINIMUM_HEIGHT) {
- return true;
- }
- return false;
+ protected static boolean useCompact(Context context) {
+ return context.getResources().getConfiguration().orientation
+ == Configuration.ORIENTATION_PORTRAIT;
}
protected Parameter getParameterToEdit(FilterRepresentation rep) {
diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
index 9927a0a..64b4974 100644
--- a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
+++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
@@ -17,18 +17,30 @@
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Color;
+import android.util.Log;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Vector;
-public abstract class BaseFiltersManager {
+public abstract class BaseFiltersManager implements FiltersManagerInterface {
protected HashMap<Class, ImageFilter> mFilters = null;
+ protected HashMap<String, FilterRepresentation> mRepresentationLookup = null;
+ private static final String LOGTAG = "BaseFiltersManager";
+
+ protected ArrayList<FilterRepresentation> mLooks = new ArrayList<FilterRepresentation>();
+ protected ArrayList<FilterRepresentation> mBorders = new ArrayList<FilterRepresentation>();
+ protected ArrayList<FilterRepresentation> mTools = new ArrayList<FilterRepresentation>();
+ protected ArrayList<FilterRepresentation> mEffects = new ArrayList<FilterRepresentation>();
+ private static int mImageBorderSize = 4; // in percent
protected void init() {
mFilters = new HashMap<Class, ImageFilter>();
+ mRepresentationLookup = new HashMap<String, FilterRepresentation>();
Vector<Class> filters = new Vector<Class>();
addFilterClasses(filters);
for (Class filterClass : filters) {
@@ -36,6 +48,12 @@
Object filterInstance = filterClass.newInstance();
if (filterInstance instanceof ImageFilter) {
mFilters.put(filterClass, (ImageFilter) filterInstance);
+
+ FilterRepresentation rep =
+ ((ImageFilter) filterInstance).getDefaultRepresentation();
+ if (rep != null) {
+ addRepresentation(rep);
+ }
}
} catch (InstantiationException e) {
e.printStackTrace();
@@ -45,18 +63,29 @@
}
}
+ public void addRepresentation(FilterRepresentation rep) {
+ mRepresentationLookup.put(rep.getSerializationName(), rep);
+ }
+
+ public FilterRepresentation createFilterFromName(String name) {
+ try {
+ return mRepresentationLookup.get(name).copy();
+ } catch (Exception e) {
+ Log.v(LOGTAG, "unable to generate a filter representation for \"" + name + "\"");
+ e.printStackTrace();
+ }
+ return null;
+ }
+
public ImageFilter getFilter(Class c) {
return mFilters.get(c);
}
+ @Override
public ImageFilter getFilterForRepresentation(FilterRepresentation representation) {
return mFilters.get(representation.getFilterClass());
}
- public void addFilter(Class filterClass, ImageFilter filter) {
- mFilters.put(filterClass, filter);
- }
-
public FilterRepresentation getRepresentation(Class c) {
ImageFilter filter = mFilters.get(c);
if (filter != null) {
@@ -89,18 +118,20 @@
protected void addFilterClasses(Vector<Class> filters) {
filters.add(ImageFilterTinyPlanet.class);
- //filters.add(ImageFilterRedEye.class);
+ filters.add(ImageFilterRedEye.class);
filters.add(ImageFilterWBalance.class);
filters.add(ImageFilterExposure.class);
filters.add(ImageFilterVignette.class);
+ filters.add(ImageFilterGrad.class);
filters.add(ImageFilterContrast.class);
filters.add(ImageFilterShadows.class);
filters.add(ImageFilterHighlights.class);
filters.add(ImageFilterVibrance.class);
filters.add(ImageFilterSharpen.class);
filters.add(ImageFilterCurves.class);
- // filters.add(ImageFilterDraw.class);
+ filters.add(ImageFilterDraw.class);
filters.add(ImageFilterHue.class);
+ filters.add(ImageFilterChanSat.class);
filters.add(ImageFilterSaturated.class);
filters.add(ImageFilterBwFilter.class);
filters.add(ImageFilterNegative.class);
@@ -108,15 +139,97 @@
filters.add(ImageFilterKMeans.class);
filters.add(ImageFilterFx.class);
filters.add(ImageFilterBorder.class);
- filters.add(ImageFilterParametricBorder.class);
- filters.add(ImageFilterGeometry.class);
+ filters.add(ImageFilterColorBorder.class);
}
- public void addBorders(Context context, Vector<FilterRepresentation> representations) {
+ public ArrayList<FilterRepresentation> getLooks() {
+ return mLooks;
+ }
+
+ public ArrayList<FilterRepresentation> getBorders() {
+ return mBorders;
+ }
+
+ public ArrayList<FilterRepresentation> getTools() {
+ return mTools;
+ }
+
+ public ArrayList<FilterRepresentation> getEffects() {
+ return mEffects;
+ }
+
+ public void addBorders(Context context) {
+
+ // Do not localize
+ String[] serializationNames = {
+ "FRAME_4X5",
+ "FRAME_BRUSH",
+ "FRAME_GRUNGE",
+ "FRAME_SUMI_E",
+ "FRAME_TAPE",
+ "FRAME_BLACK",
+ "FRAME_BLACK_ROUNDED",
+ "FRAME_WHITE",
+ "FRAME_WHITE_ROUNDED",
+ "FRAME_CREAM",
+ "FRAME_CREAM_ROUNDED"
+ };
+
+ // The "no border" implementation
+ int i = 0;
+ FilterRepresentation rep = new FilterImageBorderRepresentation(0);
+ mBorders.add(rep);
+
+ // Regular borders
+ ArrayList <FilterRepresentation> borderList = new ArrayList<FilterRepresentation>();
+
+
+ rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_4x5);
+ borderList.add(rep);
+
+ rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_brush);
+ borderList.add(rep);
+
+ rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_grunge);
+ borderList.add(rep);
+
+ rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_sumi_e);
+ borderList.add(rep);
+
+ rep = new FilterImageBorderRepresentation(R.drawable.filtershow_border_tape);
+ borderList.add(rep);
+
+ rep = new FilterColorBorderRepresentation(Color.BLACK, mImageBorderSize, 0);
+ borderList.add(rep);
+
+ rep = new FilterColorBorderRepresentation(Color.BLACK, mImageBorderSize,
+ mImageBorderSize);
+ borderList.add(rep);
+
+ rep = new FilterColorBorderRepresentation(Color.WHITE, mImageBorderSize, 0);
+ borderList.add(rep);
+
+ rep = new FilterColorBorderRepresentation(Color.WHITE, mImageBorderSize,
+ mImageBorderSize);
+ borderList.add(rep);
+
+ int creamColor = Color.argb(255, 237, 237, 227);
+ rep = new FilterColorBorderRepresentation(creamColor, mImageBorderSize, 0);
+ borderList.add(rep);
+
+ rep = new FilterColorBorderRepresentation(creamColor, mImageBorderSize,
+ mImageBorderSize);
+ borderList.add(rep);
+
+ for (FilterRepresentation filter : borderList) {
+ filter.setSerializationName(serializationNames[i++]);
+ addRepresentation(filter);
+ mBorders.add(filter);
+ }
}
- public void addLooks(Context context, Vector<FilterRepresentation> representations) {
+ public void addLooks(Context context) {
int[] drawid = {
R.drawable.filtershow_fx_0005_punch,
R.drawable.filtershow_fx_0000_vintage,
@@ -141,35 +254,104 @@
R.string.ffx_x_process
};
+ // Do not localize.
+ String[] serializationNames = {
+ "LUT3D_PUNCH",
+ "LUT3D_VINTAGE",
+ "LUT3D_BW",
+ "LUT3D_BLEACH",
+ "LUT3D_INSTANT",
+ "LUT3D_WASHOUT",
+ "LUT3D_BLUECRUSH",
+ "LUT3D_WASHOUT",
+ "LUT3D_XPROCESS"
+ };
+
+ FilterFxRepresentation nullFx =
+ new FilterFxRepresentation(context.getString(R.string.none),
+ 0, R.string.none);
+ mLooks.add(nullFx);
+
for (int i = 0; i < drawid.length; i++) {
FilterFxRepresentation fx = new FilterFxRepresentation(
context.getString(fxNameid[i]), drawid[i], fxNameid[i]);
- representations.add(fx);
+ fx.setSerializationName(serializationNames[i]);
+ ImagePreset preset = new ImagePreset();
+ preset.addFilter(fx);
+ FilterUserPresetRepresentation rep = new FilterUserPresetRepresentation(
+ context.getString(fxNameid[i]), preset, -1);
+ mLooks.add(rep);
+ addRepresentation(fx);
}
}
- public void addEffects(Vector<FilterRepresentation> representations) {
- representations.add(getRepresentation(ImageFilterTinyPlanet.class));
- representations.add(getRepresentation(ImageFilterWBalance.class));
- representations.add(getRepresentation(ImageFilterExposure.class));
- representations.add(getRepresentation(ImageFilterVignette.class));
- representations.add(getRepresentation(ImageFilterContrast.class));
- representations.add(getRepresentation(ImageFilterShadows.class));
- representations.add(getRepresentation(ImageFilterHighlights.class));
- representations.add(getRepresentation(ImageFilterVibrance.class));
- representations.add(getRepresentation(ImageFilterSharpen.class));
- representations.add(getRepresentation(ImageFilterCurves.class));
- representations.add(getRepresentation(ImageFilterHue.class));
- representations.add(getRepresentation(ImageFilterSaturated.class));
- representations.add(getRepresentation(ImageFilterBwFilter.class));
- representations.add(getRepresentation(ImageFilterNegative.class));
- representations.add(getRepresentation(ImageFilterEdge.class));
- representations.add(getRepresentation(ImageFilterKMeans.class));
+ public void addEffects() {
+ mEffects.add(getRepresentation(ImageFilterTinyPlanet.class));
+ mEffects.add(getRepresentation(ImageFilterWBalance.class));
+ mEffects.add(getRepresentation(ImageFilterExposure.class));
+ mEffects.add(getRepresentation(ImageFilterVignette.class));
+ mEffects.add(getRepresentation(ImageFilterGrad.class));
+ mEffects.add(getRepresentation(ImageFilterContrast.class));
+ mEffects.add(getRepresentation(ImageFilterShadows.class));
+ mEffects.add(getRepresentation(ImageFilterHighlights.class));
+ mEffects.add(getRepresentation(ImageFilterVibrance.class));
+ mEffects.add(getRepresentation(ImageFilterSharpen.class));
+ mEffects.add(getRepresentation(ImageFilterCurves.class));
+ mEffects.add(getRepresentation(ImageFilterHue.class));
+ mEffects.add(getRepresentation(ImageFilterChanSat.class));
+ mEffects.add(getRepresentation(ImageFilterBwFilter.class));
+ mEffects.add(getRepresentation(ImageFilterNegative.class));
+ mEffects.add(getRepresentation(ImageFilterEdge.class));
+ mEffects.add(getRepresentation(ImageFilterKMeans.class));
}
- public void addTools(Vector<FilterRepresentation> representations) {
- //representations.add(getRepresentation(ImageFilterRedEye.class));
- // representations.add(getRepresentation(ImageFilterDraw.class));
+ public void addTools(Context context) {
+
+ int[] textId = {
+ R.string.crop,
+ R.string.straighten,
+ R.string.rotate,
+ R.string.mirror
+ };
+
+ int[] overlayId = {
+ R.drawable.filtershow_button_geometry_crop,
+ R.drawable.filtershow_button_geometry_straighten,
+ R.drawable.filtershow_button_geometry_rotate,
+ R.drawable.filtershow_button_geometry_flip
+ };
+
+ FilterRepresentation[] geometryFilters = {
+ new FilterCropRepresentation(),
+ new FilterStraightenRepresentation(),
+ new FilterRotateRepresentation(),
+ new FilterMirrorRepresentation()
+ };
+
+ for (int i = 0; i < textId.length; i++) {
+ FilterRepresentation geometry = geometryFilters[i];
+ geometry.setTextId(textId[i]);
+ geometry.setOverlayId(overlayId[i]);
+ geometry.setOverlayOnly(true);
+ if (geometry.getTextId() != 0) {
+ geometry.setName(context.getString(geometry.getTextId()));
+ }
+ mTools.add(geometry);
+ }
+
+ //mTools.add(getRepresentation(ImageFilterRedEye.class));
+ mTools.add(getRepresentation(ImageFilterDraw.class));
+ }
+
+ public void removeRepresentation(ArrayList<FilterRepresentation> list,
+ FilterRepresentation representation) {
+ for (int i = 0; i < list.size(); i++) {
+ FilterRepresentation r = list.get(i);
+ if (r.getFilterClass() == representation.getFilterClass()) {
+ list.remove(i);
+ break;
+ }
+ }
}
public void setFilterResources(Resources resources) {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
index 4d0651e..1eebdb5 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
@@ -31,6 +31,8 @@
private int mMaximum;
private int mDefaultValue;
private int mPreviewValue;
+ public static final String SERIAL_NAME = "Name";
+ public static final String SERIAL_VALUE = "Value";
private boolean mLogVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
public FilterBasicRepresentation(String name, int minimum, int value, int maximum) {
@@ -46,18 +48,19 @@
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterBasicRepresentation representation = (FilterBasicRepresentation) super.clone();
- representation.setMinimum(getMinimum());
- representation.setMaximum(getMaximum());
- representation.setValue(getValue());
- if (mLogVerbose) {
- Log.v(LOGTAG, "cloning from <" + this + "> to <" + representation + ">");
- }
+ public FilterRepresentation copy() {
+ FilterBasicRepresentation representation = new FilterBasicRepresentation(getName(),0,0,0);
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterBasicRepresentation) {
FilterBasicRepresentation representation = (FilterBasicRepresentation) a;
@@ -171,4 +174,23 @@
public void copyFrom(Parameter src) {
useParametersFrom((FilterBasicRepresentation) src);
}
+
+ @Override
+ public String[][] serializeRepresentation() {
+ String[][] ret = {
+ {SERIAL_NAME , getName() },
+ {SERIAL_VALUE , Integer.toString(mValue)}};
+ return ret;
+ }
+
+ @Override
+ public void deSerializeRepresentation(String[][] rep) {
+ super.deSerializeRepresentation(rep);
+ for (int i = 0; i < rep.length; i++) {
+ if (SERIAL_VALUE.equals(rep[i][0])) {
+ mValue = Integer.parseInt(rep[i][1]);
+ break;
+ }
+ }
+ }
}
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 0000000..6c5274d
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterChanSatRepresentation.java
@@ -0,0 +1,212 @@
+/*
+ * 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);
+ setSupportsPartialRendering(true);
+ }
+
+ 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/FilterColorBorderRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java
index b2664a3..5162927 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java
@@ -16,26 +16,58 @@
package com.android.gallery3d.filtershow.filters;
+import android.graphics.Color;
+import android.util.JsonReader;
+import android.util.JsonWriter;
+
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+import com.android.gallery3d.filtershow.controller.BasicParameterInt;
+import com.android.gallery3d.filtershow.controller.Parameter;
+import com.android.gallery3d.filtershow.controller.ParameterColor;
+import com.android.gallery3d.filtershow.editors.EditorColorBorder;
+
+import java.io.IOException;
public class FilterColorBorderRepresentation extends FilterRepresentation {
- private int mColor;
- private int mBorderSize;
- private int mBorderRadius;
+ private static final String LOGTAG = "FilterColorBorderRepresentation";
+ private static final String SERIALIZATION_NAME = "COLORBORDER";
+
+ public static final int PARAM_SIZE = 0;
+ public static final int PARAM_RADIUS = 1;
+ public static final int PARAM_COLOR = 2;
+ public static int DEFAULT_MENU_COLOR1 = Color.WHITE;
+ public static int DEFAULT_MENU_COLOR2 = Color.BLACK;
+ public static int DEFAULT_MENU_COLOR3 = Color.GRAY;
+ public static int DEFAULT_MENU_COLOR4 = 0xFFFFCCAA;
+ public static int DEFAULT_MENU_COLOR5 = 0xFFAAAAAA;
+ private BasicParameterInt mParamSize = new BasicParameterInt(PARAM_SIZE, 3, 2, 30);
+ private BasicParameterInt mParamRadius = new BasicParameterInt(PARAM_RADIUS, 2, 0, 100);
+ private ParameterColor mParamColor = new ParameterColor(PARAM_COLOR, DEFAULT_MENU_COLOR1);
+
+ private Parameter[] mAllParam = {
+ mParamSize,
+ mParamRadius,
+ mParamColor
+ };
+ private int mPramMode;
public FilterColorBorderRepresentation(int color, int size, int radius) {
super("ColorBorder");
- mColor = color;
- mBorderSize = size;
- mBorderRadius = radius;
- setFilterClass(ImageFilterParametricBorder.class);
- setPriority(FilterRepresentation.TYPE_BORDER);
+ setSerializationName(SERIALIZATION_NAME);
+ setFilterType(FilterRepresentation.TYPE_BORDER);
setTextId(R.string.borders);
- setEditorId(ImageOnlyEditor.ID);
- setShowEditingControls(false);
+ setEditorId(EditorColorBorder.ID);
setShowParameterValue(false);
- setShowUtilityPanel(false);
+ setFilterClass(ImageFilterColorBorder.class);
+ mParamColor.setValue(color);
+ mParamSize.setValue(size);
+ mParamRadius.setValue(radius);
+ mParamColor.setColorpalette(new int[]{
+ DEFAULT_MENU_COLOR1,
+ DEFAULT_MENU_COLOR2,
+ DEFAULT_MENU_COLOR3,
+ DEFAULT_MENU_COLOR4,
+ DEFAULT_MENU_COLOR5});
}
public String toString() {
@@ -43,20 +75,25 @@
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) super.clone();
- representation.setName(getName());
- representation.setColor(getColor());
- representation.setBorderSize(getBorderSize());
- representation.setBorderRadius(getBorderRadius());
+ public FilterRepresentation copy() {
+ FilterColorBorderRepresentation representation =
+ new FilterColorBorderRepresentation(0, 0, 0);
+ copyAllParameters(representation);
return representation;
}
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
public void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterColorBorderRepresentation) {
FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) a;
setName(representation.getName());
setColor(representation.getColor());
+ mParamColor.copyPalletFrom(representation.mParamColor);
setBorderSize(representation.getBorderSize());
setBorderRadius(representation.getBorderRadius());
}
@@ -69,45 +106,97 @@
}
if (representation instanceof FilterColorBorderRepresentation) {
FilterColorBorderRepresentation border = (FilterColorBorderRepresentation) representation;
- if (border.mColor == mColor
- && border.mBorderSize == mBorderSize
- && border.mBorderRadius == mBorderRadius) {
+ if (border.mParamColor.getValue() == mParamColor.getValue()
+ && border.mParamRadius.getValue() == mParamRadius.getValue()
+ && border.mParamSize.getValue() == mParamSize.getValue()) {
+
return true;
}
}
return false;
}
- public boolean allowsMultipleInstances() {
+ public boolean allowsSingleInstanceOnly() {
return true;
}
+ public Parameter getParam(int mode) {
+ return mAllParam[mode];
+ }
+
@Override
public int getTextId() {
- return R.string.borders;
+ if (super.getTextId() == 0) {
+ return R.string.borders;
+ }
+ return super.getTextId();
}
public int getColor() {
- return mColor;
+ return mParamColor.getValue();
}
public void setColor(int color) {
- mColor = color;
+ mParamColor.setValue(color);
}
public int getBorderSize() {
- return mBorderSize;
+ return mParamSize.getValue();
}
public void setBorderSize(int borderSize) {
- mBorderSize = borderSize;
+ mParamSize.setValue(borderSize);
}
public int getBorderRadius() {
- return mBorderRadius;
+ return mParamRadius.getValue();
}
public void setBorderRadius(int borderRadius) {
- mBorderRadius = borderRadius;
+ mParamRadius.setValue(borderRadius);
+ }
+
+ public void setPramMode(int pramMode) {
+ this.mPramMode = pramMode;
+ }
+
+ public Parameter getCurrentParam() {
+ return mAllParam[mPramMode];
+ }
+
+ public String getValueString() {
+ return "";
+ }
+
+ // Serialization...
+
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ {
+ writer.name("size");
+ writer.value(mParamSize.getValue());
+ writer.name("radius");
+ writer.value(mParamRadius.getValue());
+ writer.name("color");
+ writer.value(mParamColor.getValue());
+ }
+ writer.endObject();
+ }
+
+ public void deSerializeRepresentation(JsonReader reader) throws IOException {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+ if (name.equalsIgnoreCase("size")) {
+ mParamSize.setValue(reader.nextInt());
+ } else if (name.equalsIgnoreCase("radius")) {
+ mParamRadius.setValue(reader.nextInt());
+ } else if (name.equalsIgnoreCase("color")) {
+ mParamColor.setValue(reader.nextInt());
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
}
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterCropRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterCropRepresentation.java
new file mode 100644
index 0000000..ba697d8
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterCropRepresentation.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.RectF;
+import android.util.JsonReader;
+import android.util.JsonWriter;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorCrop;
+
+import java.io.IOException;
+
+public class FilterCropRepresentation extends FilterRepresentation {
+ public static final String SERIALIZATION_NAME = "CROP";
+ public static final String[] BOUNDS = {
+ "C0", "C1", "C2", "C3"
+ };
+ private static final String TAG = FilterCropRepresentation.class.getSimpleName();
+
+ RectF mCrop = getNil();
+
+ public FilterCropRepresentation(RectF crop) {
+ super(SERIALIZATION_NAME);
+ setSerializationName(SERIALIZATION_NAME);
+ setShowParameterValue(true);
+ setFilterClass(FilterCropRepresentation.class);
+ setFilterType(FilterRepresentation.TYPE_GEOMETRY);
+ setSupportsPartialRendering(true);
+ setTextId(R.string.crop);
+ setEditorId(EditorCrop.ID);
+ setCrop(crop);
+ }
+
+ public FilterCropRepresentation(FilterCropRepresentation m) {
+ this(m.mCrop);
+ setName(m.getName());
+ }
+
+ public FilterCropRepresentation() {
+ this(sNilRect);
+ }
+
+ public void set(FilterCropRepresentation r) {
+ mCrop.set(r.mCrop);
+ }
+
+ @Override
+ public boolean equals(FilterRepresentation rep) {
+ if (!(rep instanceof FilterCropRepresentation)) {
+ return false;
+ }
+ FilterCropRepresentation crop = (FilterCropRepresentation) rep;
+ if (mCrop.bottom != crop.mCrop.bottom
+ || mCrop.left != crop.mCrop.left
+ || mCrop.right != crop.mCrop.right
+ || mCrop.top != crop.mCrop.top) {
+ return false;
+ }
+ return true;
+ }
+
+ public RectF getCrop() {
+ return new RectF(mCrop);
+ }
+
+ public void getCrop(RectF r) {
+ r.set(mCrop);
+ }
+
+ public void setCrop(RectF crop) {
+ if (crop == null) {
+ throw new IllegalArgumentException("Argument to setCrop is null");
+ }
+ mCrop.set(crop);
+ }
+
+ /**
+ * Takes a crop rect contained by [0, 0, 1, 1] and scales it by the height
+ * and width of the image rect.
+ */
+ public static void findScaledCrop(RectF crop, int bitmapWidth, int bitmapHeight) {
+ crop.left *= bitmapWidth;
+ crop.top *= bitmapHeight;
+ crop.right *= bitmapWidth;
+ crop.bottom *= bitmapHeight;
+ }
+
+ /**
+ * Takes crop rect and normalizes it by scaling down by the height and width
+ * of the image rect.
+ */
+ public static void findNormalizedCrop(RectF crop, int bitmapWidth, int bitmapHeight) {
+ crop.left /= bitmapWidth;
+ crop.top /= bitmapHeight;
+ crop.right /= bitmapWidth;
+ crop.bottom /= bitmapHeight;
+ }
+
+ @Override
+ public boolean allowsSingleInstanceOnly() {
+ return true;
+ }
+
+ @Override
+ public FilterRepresentation copy() {
+ return new FilterCropRepresentation(this);
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ if (!(representation instanceof FilterCropRepresentation)) {
+ throw new IllegalArgumentException("calling copyAllParameters with incompatible types!");
+ }
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ if (!(a instanceof FilterCropRepresentation)) {
+ throw new IllegalArgumentException("calling useParametersFrom with incompatible types!");
+ }
+ setCrop(((FilterCropRepresentation) a).mCrop);
+ }
+
+ private static final RectF sNilRect = new RectF(0, 0, 1, 1);
+
+ @Override
+ public boolean isNil() {
+ return mCrop.equals(sNilRect);
+ }
+
+ public static RectF getNil() {
+ return new RectF(sNilRect);
+ }
+
+ @Override
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ writer.name(BOUNDS[0]).value(mCrop.left);
+ writer.name(BOUNDS[1]).value(mCrop.top);
+ writer.name(BOUNDS[2]).value(mCrop.right);
+ writer.name(BOUNDS[3]).value(mCrop.bottom);
+ writer.endObject();
+ }
+
+ @Override
+ public void deSerializeRepresentation(JsonReader reader) throws IOException {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+ if (BOUNDS[0].equals(name)) {
+ mCrop.left = (float) reader.nextDouble();
+ } else if (BOUNDS[1].equals(name)) {
+ mCrop.top = (float) reader.nextDouble();
+ } else if (BOUNDS[2].equals(name)) {
+ mCrop.right = (float) reader.nextDouble();
+ } else if (BOUNDS[3].equals(name)) {
+ mCrop.bottom = (float) reader.nextDouble();
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
index cbcae4b..edab2a0 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
@@ -1,37 +1,48 @@
package com.android.gallery3d.filtershow.filters;
+import android.util.JsonReader;
+import android.util.JsonWriter;
import android.util.Log;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.ui.Spline;
+import com.android.gallery3d.filtershow.imageshow.ControlPoint;
+import com.android.gallery3d.filtershow.imageshow.Spline;
+
+import java.io.IOException;
/**
* TODO: Insert description here. (generated by hoford)
*/
public class FilterCurvesRepresentation extends FilterRepresentation {
private static final String LOGTAG = "FilterCurvesRepresentation";
+ public static final String SERIALIZATION_NAME = "Curve";
+ private static final int MAX_SPLINE_NUMBER = 4;
- private Spline[] mSplines = new Spline[4];
+ private Spline[] mSplines = new Spline[MAX_SPLINE_NUMBER];
public FilterCurvesRepresentation() {
super("Curves");
+ setSerializationName("CURVES");
setFilterClass(ImageFilterCurves.class);
setTextId(R.string.curvesRGB);
- setButtonId(R.id.curvesButtonRGB);
setOverlayId(R.drawable.filtershow_button_colors_curve);
setEditorId(R.id.imageCurves);
- setShowEditingControls(false);
setShowParameterValue(false);
- setShowUtilityPanel(true);
setSupportsPartialRendering(true);
reset();
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterCurvesRepresentation rep = new FilterCurvesRepresentation();
- rep.useParametersFrom(this);
- return rep;
+ public FilterRepresentation copy() {
+ FilterCurvesRepresentation representation = new FilterCurvesRepresentation();
+ copyAllParameters(representation);
+ return representation;
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
}
@Override
@@ -41,7 +52,7 @@
return;
}
FilterCurvesRepresentation representation = (FilterCurvesRepresentation) a;
- Spline[] spline = new Spline[4];
+ Spline[] spline = new Spline[MAX_SPLINE_NUMBER];
for (int i = 0; i < spline.length; i++) {
Spline sp = representation.mSplines[i];
if (sp != null) {
@@ -53,8 +64,9 @@
mSplines = spline;
}
+ @Override
public boolean isNil() {
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < MAX_SPLINE_NUMBER; i++) {
if (getSpline(i) != null && !getSpline(i).isOriginal()) {
return false;
}
@@ -62,13 +74,34 @@
return true;
}
+ @Override
+ public boolean equals(FilterRepresentation representation) {
+ if (!super.equals(representation)) {
+ return false;
+ }
+
+ if (!(representation instanceof FilterCurvesRepresentation)) {
+ return false;
+ } else {
+ FilterCurvesRepresentation curve =
+ (FilterCurvesRepresentation) representation;
+ for (int i = 0; i < MAX_SPLINE_NUMBER; i++) {
+ if (!getSpline(i).sameValues(curve.getSpline(i))) {
+ return false;
+ }
+ }
+ }
+ // Every spline matches, therefore they are the same.
+ return true;
+ }
+
public void reset() {
Spline spline = new Spline();
spline.addPoint(0.0f, 1.0f);
spline.addPoint(1.0f, 0.0f);
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < MAX_SPLINE_NUMBER; i++) {
mSplines[i] = new Spline(spline);
}
}
@@ -76,7 +109,62 @@
public void setSpline(int splineIndex, Spline s) {
mSplines[splineIndex] = s;
}
+
public Spline getSpline(int splineIndex) {
return mSplines[splineIndex];
}
+
+ @Override
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ {
+ writer.name(NAME_TAG);
+ writer.value(getName());
+ for (int i = 0; i < mSplines.length; i++) {
+ writer.name(SERIALIZATION_NAME + i);
+ writer.beginArray();
+ int nop = mSplines[i].getNbPoints();
+ for (int j = 0; j < nop; j++) {
+ ControlPoint p = mSplines[i].getPoint(j);
+ writer.beginArray();
+ writer.value(p.x);
+ writer.value(p.y);
+ writer.endArray();
+ }
+ writer.endArray();
+ }
+
+ }
+ writer.endObject();
+ }
+
+ @Override
+ public void deSerializeRepresentation(JsonReader sreader) throws IOException {
+ sreader.beginObject();
+ Spline[] spline = new Spline[MAX_SPLINE_NUMBER];
+ while (sreader.hasNext()) {
+ String name = sreader.nextName();
+ if (NAME_TAG.equals(name)) {
+ setName(sreader.nextString());
+ } else if (name.startsWith(SERIALIZATION_NAME)) {
+ int curveNo = Integer.parseInt(name.substring(SERIALIZATION_NAME.length()));
+ spline[curveNo] = new Spline();
+ sreader.beginArray();
+ while (sreader.hasNext()) {
+ sreader.beginArray();
+ sreader.hasNext();
+ float x = (float) sreader.nextDouble();
+ sreader.hasNext();
+ float y = (float) sreader.nextDouble();
+ sreader.endArray();
+ spline[curveNo].addPoint(x, y);
+ }
+ sreader.endArray();
+
+ }
+ }
+ mSplines = spline;
+ sreader.endObject();
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java
index 3807ee1..ac0cb74 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java
@@ -18,12 +18,21 @@
public class FilterDirectRepresentation extends FilterRepresentation {
- public FilterDirectRepresentation(String name) {
- super(name);
+ @Override
+ public FilterRepresentation copy() {
+ FilterDirectRepresentation representation = new FilterDirectRepresentation(getName());
+ copyAllParameters(representation);
+ return representation;
}
- public boolean isNil() {
- return true;
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ public FilterDirectRepresentation(String name) {
+ super(name);
}
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
index dc59b0c..48d3d90 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
@@ -16,43 +16,153 @@
package com.android.gallery3d.filtershow.filters;
+import android.graphics.Color;
import android.graphics.Path;
+import android.graphics.PathMeasure;
+import android.util.JsonReader;
+import android.util.JsonWriter;
import android.util.Log;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.controller.BasicParameterInt;
+import com.android.gallery3d.filtershow.controller.BasicParameterStyle;
+import com.android.gallery3d.filtershow.controller.Parameter;
+import com.android.gallery3d.filtershow.controller.ParameterBrightness;
+import com.android.gallery3d.filtershow.controller.ParameterColor;
+import com.android.gallery3d.filtershow.controller.ParameterHue;
+import com.android.gallery3d.filtershow.controller.ParameterOpacity;
+import com.android.gallery3d.filtershow.controller.ParameterSaturation;
import com.android.gallery3d.filtershow.editors.EditorDraw;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
import java.util.Vector;
public class FilterDrawRepresentation extends FilterRepresentation {
private static final String LOGTAG = "FilterDrawRepresentation";
+ public static final int PARAM_SIZE = 0;
+ public static final int PARAM_STYLE = 1;
+ public static final int PARAM_COLOR = 2;
+ private BasicParameterInt mParamSize = new BasicParameterInt(PARAM_SIZE, 30, 2, 300);
+ private BasicParameterStyle mParamStyle = new BasicParameterStyle(PARAM_STYLE, 5);
+ public static int DEFAULT_MENU_COLOR1 = Color.RED & 0x80FFFFFF;
+ public static int DEFAULT_MENU_COLOR2 = Color.GREEN & 0x80FFFFFF;
+ public static int DEFAULT_MENU_COLOR3 = Color.BLUE & 0x80FFFFFF;
+ public static int DEFAULT_MENU_COLOR4 = Color.BLACK & 0x80FFFFFF;
+ public static int DEFAULT_MENU_COLOR5 = Color.WHITE & 0x80FFFFFF;
+ ParameterColor mParamColor = new ParameterColor(PARAM_COLOR,DEFAULT_MENU_COLOR1);
+ int mParamMode;
+ Parameter mCurrentParam = mParamSize;
+ private static final String SERIAL_COLOR = "color";
+ private static final String SERIAL_RADIUS = "radius";
+ private static final String SERIAL_TYPE = "type";
+ private static final String SERIAL_POINTS_COUNT = "point_count";
+ private static final String SERIAL_POINTS = "points";
+ private static final String SERIAL_PATH = "path";
+
+
+ private Parameter[] mAllParam = {
+ mParamSize,
+ mParamStyle,
+ mParamColor
+ };
+
+ public void setPramMode(int mode) {
+ mParamMode = mode;
+ mCurrentParam = mAllParam[mParamMode];
+ }
+
+ public int getParamMode() {
+ return mParamMode;
+ }
+
+ public Parameter getCurrentParam() {
+ return mAllParam[mParamMode];
+ }
+
+ public Parameter getParam(int type) {
+ return mAllParam[type];
+ }
+
public static class StrokeData implements Cloneable {
public byte mType;
public Path mPath;
public float mRadius;
public int mColor;
public int noPoints = 0;
+ public float[] mPoints = new float[20];
+
+ public StrokeData() {
+ }
+
+ public StrokeData(StrokeData copy) {
+ mType = copy.mType;
+ mPath = new Path(copy.mPath);
+ mRadius = copy.mRadius;
+ mColor = copy.mColor;
+ noPoints = copy.noPoints;
+ mPoints = Arrays.copyOf(copy.mPoints, copy.mPoints.length);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof StrokeData)) {
+ return false;
+ }
+ StrokeData sd = (StrokeData) o;
+ if (mType != sd.mType
+ || mRadius != sd.mRadius
+ || noPoints != sd.noPoints
+ || mColor != sd.mColor) {
+ return false;
+ }
+ return mPath.equals(sd.mPath);
+ }
+
@Override
public String toString() {
return "stroke(" + mType + ", path(" + (mPath) + "), " + mRadius + " , "
+ Integer.toHexString(mColor) + ")";
}
+
@Override
public StrokeData clone() throws CloneNotSupportedException {
return (StrokeData) super.clone();
}
}
+ static String colorHexString(int val) {
+ String str = "00000000" + Integer.toHexString(val);
+ str = "0x" + str.substring(str.length() - 8);
+ return str;
+ }
+
+ public String getValueString() {
+ int val;
+ switch (mParamMode) {
+ case PARAM_COLOR:
+ val = ((ParameterColor) mAllParam[mParamMode]).getValue();
+ return "";
+ case PARAM_SIZE:
+ val = ((BasicParameterInt) mAllParam[mParamMode]).getValue();
+ return ((val > 0) ? " +" : " ") + val;
+ case PARAM_STYLE:
+ return "";
+ }
+ return "";
+ }
+
private Vector<StrokeData> mDrawing = new Vector<StrokeData>();
private StrokeData mCurrent; // used in the currently drawing style
public FilterDrawRepresentation() {
super("Draw");
setFilterClass(ImageFilterDraw.class);
- setPriority(FilterRepresentation.TYPE_VIGNETTE);
+ setSerializationName("DRAW");
+ setFilterType(FilterRepresentation.TYPE_VIGNETTE);
setTextId(R.string.imageDraw);
- setButtonId(R.id.drawOnImageButton);
setEditorId(EditorDraw.ID);
setOverlayId(R.drawable.filtershow_drawing);
setOverlayOnly(true);
@@ -62,7 +172,7 @@
public String toString() {
return getName() + " : strokes=" + mDrawing.size()
+ ((mCurrent == null) ? " no current "
- : ("draw=" + mCurrent.mType + " " + mCurrent.noPoints));
+ : ("draw=" + mCurrent.mType + " " + mCurrent.noPoints));
}
public Vector<StrokeData> getDrawing() {
@@ -74,12 +184,19 @@
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterDrawRepresentation representation = (FilterDrawRepresentation) super.clone();
+ public FilterRepresentation copy() {
+ FilterDrawRepresentation representation = new FilterDrawRepresentation();
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public boolean isNil() {
return getDrawing().isEmpty();
}
@@ -88,6 +205,7 @@
public void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterDrawRepresentation) {
FilterDrawRepresentation representation = (FilterDrawRepresentation) a;
+ mParamColor.copyPalletFrom(representation.mParamColor);
try {
if (representation.mCurrent != null) {
mCurrent = (StrokeData) representation.mCurrent.clone();
@@ -95,7 +213,11 @@
mCurrent = null;
}
if (representation.mDrawing != null) {
- mDrawing = (Vector<StrokeData>) representation.mDrawing.clone();
+ mDrawing = new Vector<StrokeData>();
+ for (Iterator<StrokeData> elem = representation.mDrawing.iterator(); elem.hasNext(); ) {
+ StrokeData next = elem.next();
+ mDrawing.add(new StrokeData(next));
+ }
} else {
mDrawing = null;
}
@@ -117,37 +239,67 @@
FilterDrawRepresentation fdRep = (FilterDrawRepresentation) representation;
if (fdRep.mDrawing.size() != mDrawing.size())
return false;
- if (fdRep.mCurrent == null && mCurrent.mPath == null) {
- return true;
+ if (fdRep.mCurrent == null ^ (mCurrent == null || mCurrent.mPath == null)) {
+ return false;
}
- if (fdRep.mCurrent != null && mCurrent.mPath != null) {
+
+
+ if (fdRep.mCurrent != null && mCurrent != null && mCurrent.mPath != null) {
if (fdRep.mCurrent.noPoints == mCurrent.noPoints) {
return true;
}
return false;
}
+
+ int n = mDrawing.size();
+ for (int i = 0; i < n; i++) {
+ StrokeData a = mDrawing.get(i);
+ StrokeData b = mDrawing.get(i);
+ if (!a.equals(b)){
+ return false;
+ }
+ }
+ return true;
}
return false;
}
- public void startNewSection(byte type, int color, float size, float x, float y) {
+ private int computeCurrentColor(){
+ return mParamColor.getValue();
+ }
+
+ public void fillStrokeParameters(StrokeData sd){
+ byte type = (byte) mParamStyle.getSelected();
+ int color = computeCurrentColor();
+ float size = mParamSize.getValue();
+ sd.mColor = color;
+ sd.mRadius = size;
+ sd.mType = type;
+ }
+
+ public void startNewSection(float x, float y) {
mCurrent = new StrokeData();
- mCurrent.mColor = color;
- mCurrent.mRadius = size;
- mCurrent.mType = type;
+ fillStrokeParameters(mCurrent);
mCurrent.mPath = new Path();
mCurrent.mPath.moveTo(x, y);
- mCurrent.noPoints = 0;
+ mCurrent.mPoints[0] = x;
+ mCurrent.mPoints[1] = y;
+ mCurrent.noPoints = 1;
}
public void addPoint(float x, float y) {
- mCurrent.noPoints++;
+ int len = mCurrent.noPoints * 2;
mCurrent.mPath.lineTo(x, y);
+ if ((len+2) > mCurrent.mPoints.length) {
+ mCurrent.mPoints = Arrays.copyOf(mCurrent.mPoints, mCurrent.mPoints.length * 2);
+ }
+ mCurrent.mPoints[len] = x;
+ mCurrent.mPoints[len + 1] = y;
+ mCurrent.noPoints++;
}
public void endSection(float x, float y) {
- mCurrent.mPath.lineTo(x, y);
- mCurrent.noPoints++;
+ addPoint(x, y);
mDrawing.add(mCurrent);
mCurrent = null;
}
@@ -161,4 +313,82 @@
mDrawing.clear();
}
+ @Override
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ int len = mDrawing.size();
+ int count = 0;
+ float[] mPosition = new float[2];
+ float[] mTan = new float[2];
+
+ PathMeasure mPathMeasure = new PathMeasure();
+ for (int i = 0; i < len; i++) {
+ writer.name(SERIAL_PATH + i);
+ writer.beginObject();
+ StrokeData mark = mDrawing.get(i);
+ writer.name(SERIAL_COLOR).value(mark.mColor);
+ writer.name(SERIAL_RADIUS).value(mark.mRadius);
+ writer.name(SERIAL_TYPE).value(mark.mType);
+ writer.name(SERIAL_POINTS_COUNT).value(mark.noPoints);
+ writer.name(SERIAL_POINTS);
+
+ writer.beginArray();
+ int npoints = mark.noPoints * 2;
+ for (int j = 0; j < npoints; j++) {
+ writer.value(mark.mPoints[j]);
+ }
+ writer.endArray();
+ writer.endObject();
+ }
+ writer.endObject();
+ }
+
+ @Override
+ public void deSerializeRepresentation(JsonReader sreader) throws IOException {
+ sreader.beginObject();
+ Vector<StrokeData> strokes = new Vector<StrokeData>();
+
+ while (sreader.hasNext()) {
+ sreader.nextName();
+ sreader.beginObject();
+ StrokeData stroke = new StrokeData();
+
+ while (sreader.hasNext()) {
+ String name = sreader.nextName();
+ if (name.equals(SERIAL_COLOR)) {
+ stroke.mColor = sreader.nextInt();
+ } else if (name.equals(SERIAL_RADIUS)) {
+ stroke.mRadius = (float) sreader.nextDouble();
+ } else if (name.equals(SERIAL_TYPE)) {
+ stroke.mType = (byte) sreader.nextInt();
+ } else if (name.equals(SERIAL_POINTS_COUNT)) {
+ stroke.noPoints = sreader.nextInt();
+ } else if (name.equals(SERIAL_POINTS)) {
+
+ int count = 0;
+ sreader.beginArray();
+ while (sreader.hasNext()) {
+ if ((count + 1) > stroke.mPoints.length) {
+ stroke.mPoints = Arrays.copyOf(stroke.mPoints, count * 2);
+ }
+ stroke.mPoints[count++] = (float) sreader.nextDouble();
+ }
+ stroke.mPath = new Path();
+ stroke.mPath.moveTo(stroke.mPoints[0], stroke.mPoints[1]);
+ for (int i = 0; i < count; i += 2) {
+ stroke.mPath.lineTo(stroke.mPoints[i], stroke.mPoints[i + 1]);
+ }
+ sreader.endArray();
+ strokes.add(stroke);
+ } else {
+ sreader.skipValue();
+ }
+ }
+ sreader.endObject();
+ }
+
+ mDrawing = strokes;
+
+ sreader.endObject();
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
index 6e2e7ea..e5a6fdd 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
@@ -16,12 +16,10 @@
package com.android.gallery3d.filtershow.filters;
-import android.graphics.Bitmap;
-import com.android.gallery3d.app.Log;
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
public class FilterFxRepresentation extends FilterRepresentation {
- private static final String LOGTAG = "FilterFxRepresentation";
+ private static final String LOGTAG = "FilterFxRepresentation";
// TODO: When implementing serialization, we should find a unique way of
// specifying bitmaps / names (the resource IDs being random)
private int mBitmapResource = 0;
@@ -29,35 +27,40 @@
public FilterFxRepresentation(String name, int bitmapResource, int nameResource) {
super(name);
+ setFilterClass(ImageFilterFx.class);
mBitmapResource = bitmapResource;
mNameResource = nameResource;
- setFilterClass(ImageFilterFx.class);
- setPriority(FilterRepresentation.TYPE_FX);
+ setFilterType(FilterRepresentation.TYPE_FX);
setTextId(nameResource);
setEditorId(ImageOnlyEditor.ID);
- setShowEditingControls(false);
setShowParameterValue(false);
- setShowUtilityPanel(false);
setSupportsPartialRendering(true);
}
+ @Override
public String toString() {
return "FilterFx: " + hashCode() + " : " + getName() + " bitmap rsc: " + mBitmapResource;
}
@Override
- public synchronized FilterRepresentation clone() throws CloneNotSupportedException {
- FilterFxRepresentation representation = (FilterFxRepresentation) super.clone();
- representation.setName(getName());
- representation.setBitmapResource(getBitmapResource());
- representation.setNameResource(getNameResource());
+ public FilterRepresentation copy() {
+ FilterFxRepresentation representation = new FilterFxRepresentation(getName(),0,0);
+ copyAllParameters(representation);
return representation;
}
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public synchronized void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterFxRepresentation) {
FilterFxRepresentation representation = (FilterFxRepresentation) a;
setName(representation.getName());
+ setSerializationName(representation.getSerializationName());
setBitmapResource(representation.getBitmapResource());
setNameResource(representation.getNameResource());
}
@@ -78,6 +81,7 @@
return false;
}
+ @Override
public boolean same(FilterRepresentation representation) {
if (!super.same(representation)) {
return false;
@@ -85,7 +89,8 @@
return equals(representation);
}
- public boolean allowsMultipleInstances() {
+ @Override
+ public boolean allowsSingleInstanceOnly() {
return true;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java
new file mode 100644
index 0000000..a3a7e95
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterGradRepresentation.java
@@ -0,0 +1,497 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Rect;
+import android.util.JsonReader;
+import android.util.JsonWriter;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorGrad;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.imageshow.Line;
+
+import java.io.IOException;
+import java.util.Vector;
+
+public class FilterGradRepresentation extends FilterRepresentation
+ implements Line {
+ private static final String LOGTAG = "FilterGradRepresentation";
+ public static final int MAX_POINTS = 16;
+ public static final int PARAM_BRIGHTNESS = 0;
+ public static final int PARAM_SATURATION = 1;
+ public static final int PARAM_CONTRAST = 2;
+ private static final double ADD_MIN_DIST = .05;
+ private static String LINE_NAME = "Point";
+ private static final String SERIALIZATION_NAME = "grad";
+
+ public FilterGradRepresentation() {
+ super("Grad");
+ setSerializationName(SERIALIZATION_NAME);
+ creatExample();
+ setOverlayId(R.drawable.filtershow_button_grad);
+ setFilterClass(ImageFilterGrad.class);
+ setTextId(R.string.grad);
+ setEditorId(EditorGrad.ID);
+ }
+
+ public void trimVector(){
+ int n = mBands.size();
+ for (int i = n; i < MAX_POINTS; i++) {
+ mBands.add(new Band());
+ }
+ for (int i = MAX_POINTS; i < n; i++) {
+ mBands.remove(i);
+ }
+ }
+
+ Vector<Band> mBands = new Vector<Band>();
+ Band mCurrentBand;
+
+ static class Band {
+ private boolean mask = true;
+
+ private int xPos1 = -1;
+ private int yPos1 = 100;
+ private int xPos2 = -1;
+ private int yPos2 = 100;
+ private int brightness = -40;
+ private int contrast = 0;
+ private int saturation = 0;
+
+
+ public Band() {
+ }
+
+ public Band(int x, int y) {
+ xPos1 = x;
+ yPos1 = y+30;
+ xPos2 = x;
+ yPos2 = y-30;
+ }
+
+ public Band(Band copy) {
+ mask = copy.mask;
+ xPos1 = copy.xPos1;
+ yPos1 = copy.yPos1;
+ xPos2 = copy.xPos2;
+ yPos2 = copy.yPos2;
+ brightness = copy.brightness;
+ contrast = copy.contrast;
+ saturation = copy.saturation;
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ int count = 0;
+ for (Band point : mBands) {
+ if (!point.mask) {
+ count++;
+ }
+ }
+ return "c=" + mBands.indexOf(mBands) + "[" + mBands.size() + "]" + count;
+ }
+
+ private void creatExample() {
+ Band p = new Band();
+ p.mask = false;
+ p.xPos1 = -1;
+ p.yPos1 = 100;
+ p.xPos2 = -1;
+ p.yPos2 = 100;
+ p.brightness = -50;
+ p.contrast = 0;
+ p.saturation = 0;
+ mBands.add(0, p);
+ mCurrentBand = p;
+ trimVector();
+ }
+
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ FilterGradRepresentation rep = (FilterGradRepresentation) a;
+ Vector<Band> tmpBands = new Vector<Band>();
+ int n = (rep.mCurrentBand == null) ? 0 : rep.mBands.indexOf(rep.mCurrentBand);
+ for (Band band : rep.mBands) {
+ tmpBands.add(new Band(band));
+ }
+ mCurrentBand = null;
+ mBands = tmpBands;
+ mCurrentBand = mBands.elementAt(n);
+ }
+
+ @Override
+ public FilterRepresentation copy() {
+ FilterGradRepresentation representation = new FilterGradRepresentation();
+ copyAllParameters(representation);
+ return representation;
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
+ public boolean equals(FilterRepresentation representation) {
+ if (representation instanceof FilterGradRepresentation) {
+ FilterGradRepresentation rep = (FilterGradRepresentation) representation;
+ int n = getNumberOfBands();
+ if (rep.getNumberOfBands() != n) {
+ return false;
+ }
+ for (int i = 0; i < mBands.size(); i++) {
+ Band b1 = mBands.get(i);
+ Band b2 = rep.mBands.get(i);
+ if (b1.mask != b2.mask
+ || b1.brightness != b2.brightness
+ || b1.contrast != b2.contrast
+ || b1.saturation != b2.saturation
+ || b1.xPos1 != b2.xPos1
+ || b1.xPos2 != b2.xPos2
+ || b1.yPos1 != b2.yPos1
+ || b1.yPos2 != b2.yPos2) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public int getNumberOfBands() {
+ int count = 0;
+ for (Band point : mBands) {
+ if (!point.mask) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public int addBand(Rect rect) {
+ mBands.add(0, mCurrentBand = new Band(rect.centerX(), rect.centerY()));
+ mCurrentBand.mask = false;
+ int x = (mCurrentBand.xPos1 + mCurrentBand.xPos2)/2;
+ int y = (mCurrentBand.yPos1 + mCurrentBand.yPos2)/2;
+ double addDelta = ADD_MIN_DIST * Math.max(rect.width(), rect.height());
+ boolean moved = true;
+ int count = 0;
+ int toMove = mBands.indexOf(mCurrentBand);
+
+ while (moved) {
+ moved = false;
+ count++;
+ if (count > 14) {
+ break;
+ }
+
+ for (Band point : mBands) {
+ if (point.mask) {
+ break;
+ }
+ }
+
+ for (Band point : mBands) {
+ if (point.mask) {
+ break;
+ }
+ int index = mBands.indexOf(point);
+
+ if (toMove != index) {
+ double dist = Math.hypot(point.xPos1 - x, point.yPos1 - y);
+ if (dist < addDelta) {
+ moved = true;
+ mCurrentBand.xPos1 += addDelta;
+ mCurrentBand.yPos1 += addDelta;
+ mCurrentBand.xPos2 += addDelta;
+ mCurrentBand.yPos2 += addDelta;
+ x = (mCurrentBand.xPos1 + mCurrentBand.xPos2)/2;
+ y = (mCurrentBand.yPos1 + mCurrentBand.yPos2)/2;
+
+ if (mCurrentBand.yPos1 > rect.bottom) {
+ mCurrentBand.yPos1 = (int) (rect.top + addDelta);
+ }
+ if (mCurrentBand.xPos1 > rect.right) {
+ mCurrentBand.xPos1 = (int) (rect.left + addDelta);
+ }
+ }
+ }
+ }
+ }
+ trimVector();
+ return 0;
+ }
+
+ public void deleteCurrentBand() {
+ int index = mBands.indexOf(mCurrentBand);
+ mBands.remove(mCurrentBand);
+ trimVector();
+ if (getNumberOfBands() == 0) {
+ addBand(MasterImage.getImage().getOriginalBounds());
+ }
+ mCurrentBand = mBands.get(0);
+ }
+
+ public void nextPoint(){
+ int index = mBands.indexOf(mCurrentBand);
+ int tmp = index;
+ Band point;
+ int k = 0;
+ do {
+ index = (index+1)% mBands.size();
+ point = mBands.get(index);
+ if (k++ >= mBands.size()) {
+ break;
+ }
+ }
+ while (point.mask == true);
+ mCurrentBand = mBands.get(index);
+ }
+
+ public void setSelectedPoint(int pos) {
+ mCurrentBand = mBands.get(pos);
+ }
+
+ public int getSelectedPoint() {
+ return mBands.indexOf(mCurrentBand);
+ }
+
+ public boolean[] getMask() {
+ boolean[] ret = new boolean[mBands.size()];
+ int i = 0;
+ for (Band point : mBands) {
+ ret[i++] = !point.mask;
+ }
+ return ret;
+ }
+
+ public int[] getXPos1() {
+ int[] ret = new int[mBands.size()];
+ int i = 0;
+ for (Band point : mBands) {
+ ret[i++] = point.xPos1;
+ }
+ return ret;
+ }
+
+ public int[] getYPos1() {
+ int[] ret = new int[mBands.size()];
+ int i = 0;
+ for (Band point : mBands) {
+ ret[i++] = point.yPos1;
+ }
+ return ret;
+ }
+
+ public int[] getXPos2() {
+ int[] ret = new int[mBands.size()];
+ int i = 0;
+ for (Band point : mBands) {
+ ret[i++] = point.xPos2;
+ }
+ return ret;
+ }
+
+ public int[] getYPos2() {
+ int[] ret = new int[mBands.size()];
+ int i = 0;
+ for (Band point : mBands) {
+ ret[i++] = point.yPos2;
+ }
+ return ret;
+ }
+
+ public int[] getBrightness() {
+ int[] ret = new int[mBands.size()];
+ int i = 0;
+ for (Band point : mBands) {
+ ret[i++] = point.brightness;
+ }
+ return ret;
+ }
+
+ public int[] getContrast() {
+ int[] ret = new int[mBands.size()];
+ int i = 0;
+ for (Band point : mBands) {
+ ret[i++] = point.contrast;
+ }
+ return ret;
+ }
+
+ public int[] getSaturation() {
+ int[] ret = new int[mBands.size()];
+ int i = 0;
+ for (Band point : mBands) {
+ ret[i++] = point.saturation;
+ }
+ return ret;
+ }
+
+ public int getParameter(int type) {
+ switch (type){
+ case PARAM_BRIGHTNESS:
+ return mCurrentBand.brightness;
+ case PARAM_SATURATION:
+ return mCurrentBand.saturation;
+ case PARAM_CONTRAST:
+ return mCurrentBand.contrast;
+ }
+ throw new IllegalArgumentException("no such type " + type);
+ }
+
+ public int getParameterMax(int type) {
+ switch (type) {
+ case PARAM_BRIGHTNESS:
+ return 100;
+ case PARAM_SATURATION:
+ return 100;
+ case PARAM_CONTRAST:
+ return 100;
+ }
+ throw new IllegalArgumentException("no such type " + type);
+ }
+
+ public int getParameterMin(int type) {
+ switch (type) {
+ case PARAM_BRIGHTNESS:
+ return -100;
+ case PARAM_SATURATION:
+ return -100;
+ case PARAM_CONTRAST:
+ return -100;
+ }
+ throw new IllegalArgumentException("no such type " + type);
+ }
+
+ public void setParameter(int type, int value) {
+ mCurrentBand.mask = false;
+ switch (type) {
+ case PARAM_BRIGHTNESS:
+ mCurrentBand.brightness = value;
+ break;
+ case PARAM_SATURATION:
+ mCurrentBand.saturation = value;
+ break;
+ case PARAM_CONTRAST:
+ mCurrentBand.contrast = value;
+ break;
+ default:
+ throw new IllegalArgumentException("no such type " + type);
+ }
+ }
+
+ @Override
+ public void setPoint1(float x, float y) {
+ mCurrentBand.xPos1 = (int)x;
+ mCurrentBand.yPos1 = (int)y;
+ }
+
+ @Override
+ public void setPoint2(float x, float y) {
+ mCurrentBand.xPos2 = (int)x;
+ mCurrentBand.yPos2 = (int)y;
+ }
+
+ @Override
+ public float getPoint1X() {
+ return mCurrentBand.xPos1;
+ }
+
+ @Override
+ public float getPoint1Y() {
+ return mCurrentBand.yPos1;
+ }
+ @Override
+ public float getPoint2X() {
+ return mCurrentBand.xPos2;
+ }
+
+ @Override
+ public float getPoint2Y() {
+ return mCurrentBand.yPos2;
+ }
+
+ @Override
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ int len = mBands.size();
+ int count = 0;
+
+ for (int i = 0; i < len; i++) {
+ Band point = mBands.get(i);
+ if (point.mask) {
+ continue;
+ }
+ writer.name(LINE_NAME + count);
+ count++;
+ writer.beginArray();
+ writer.value(point.xPos1);
+ writer.value(point.yPos1);
+ writer.value(point.xPos2);
+ writer.value(point.yPos2);
+ writer.value(point.brightness);
+ writer.value(point.contrast);
+ writer.value(point.saturation);
+ writer.endArray();
+ }
+ writer.endObject();
+ }
+
+ @Override
+ public void deSerializeRepresentation(JsonReader sreader) throws IOException {
+ sreader.beginObject();
+ Vector<Band> points = new Vector<Band>();
+
+ while (sreader.hasNext()) {
+ String name = sreader.nextName();
+ if (name.startsWith(LINE_NAME)) {
+ int pointNo = Integer.parseInt(name.substring(LINE_NAME.length()));
+ sreader.beginArray();
+ Band p = new Band();
+ p.mask = false;
+ sreader.hasNext();
+ p.xPos1 = sreader.nextInt();
+ sreader.hasNext();
+ p.yPos1 = sreader.nextInt();
+ sreader.hasNext();
+ p.xPos2 = sreader.nextInt();
+ sreader.hasNext();
+ p.yPos2 = sreader.nextInt();
+ sreader.hasNext();
+ p.brightness = sreader.nextInt();
+ sreader.hasNext();
+ p.contrast = sreader.nextInt();
+ sreader.hasNext();
+ p.saturation = sreader.nextInt();
+ sreader.hasNext();
+ sreader.endArray();
+ points.add(p);
+
+ } else {
+ sreader.skipValue();
+ }
+ }
+ mBands = points;
+ trimVector();
+ mCurrentBand = mBands.get(0);
+ sreader.endObject();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java
index f67254c..f310a2b 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java
@@ -24,14 +24,12 @@
public FilterImageBorderRepresentation(int drawableResource) {
super("ImageBorder");
- mDrawableResource = drawableResource;
setFilterClass(ImageFilterBorder.class);
- setPriority(FilterRepresentation.TYPE_BORDER);
+ mDrawableResource = drawableResource;
+ setFilterType(FilterRepresentation.TYPE_BORDER);
setTextId(R.string.borders);
setEditorId(ImageOnlyEditor.ID);
- setShowEditingControls(false);
setShowParameterValue(false);
- setShowUtilityPanel(false);
}
public String toString() {
@@ -39,13 +37,19 @@
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterImageBorderRepresentation representation = (FilterImageBorderRepresentation) super.clone();
- representation.setName(getName());
- representation.setDrawableResource(getDrawableResource());
+ public FilterRepresentation copy() {
+ FilterImageBorderRepresentation representation =
+ new FilterImageBorderRepresentation(mDrawableResource);
+ copyAllParameters(representation);
return representation;
}
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
public void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterImageBorderRepresentation) {
FilterImageBorderRepresentation representation = (FilterImageBorderRepresentation) a;
@@ -73,7 +77,7 @@
return R.string.none;
}
- public boolean allowsMultipleInstances() {
+ public boolean allowsSingleInstanceOnly() {
return true;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterMirrorRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterMirrorRepresentation.java
new file mode 100644
index 0000000..c281443
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterMirrorRepresentation.java
@@ -0,0 +1,213 @@
+/*
+ * 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 android.util.Log;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorMirror;
+import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class FilterMirrorRepresentation extends FilterRepresentation {
+ public static final String SERIALIZATION_NAME = "MIRROR";
+ private static final String SERIALIZATION_MIRROR_VALUE = "value";
+ private static final String TAG = FilterMirrorRepresentation.class.getSimpleName();
+
+ Mirror mMirror;
+
+ public enum Mirror {
+ NONE('N'), VERTICAL('V'), HORIZONTAL('H'), BOTH('B');
+ char mValue;
+
+ private Mirror(char value) {
+ mValue = value;
+ }
+
+ public char value() {
+ return mValue;
+ }
+
+ public static Mirror fromValue(char value) {
+ switch (value) {
+ case 'N':
+ return NONE;
+ case 'V':
+ return VERTICAL;
+ case 'H':
+ return HORIZONTAL;
+ case 'B':
+ return BOTH;
+ default:
+ return null;
+ }
+ }
+ }
+
+ public FilterMirrorRepresentation(Mirror mirror) {
+ super(SERIALIZATION_NAME);
+ setSerializationName(SERIALIZATION_NAME);
+ setShowParameterValue(false);
+ setFilterClass(FilterMirrorRepresentation.class);
+ setFilterType(FilterRepresentation.TYPE_GEOMETRY);
+ setSupportsPartialRendering(true);
+ setTextId(R.string.mirror);
+ setEditorId(ImageOnlyEditor.ID);
+ setMirror(mirror);
+ }
+
+ public FilterMirrorRepresentation(FilterMirrorRepresentation m) {
+ this(m.getMirror());
+ setName(m.getName());
+ }
+
+ public FilterMirrorRepresentation() {
+ this(getNil());
+ }
+
+ @Override
+ public boolean equals(FilterRepresentation rep) {
+ if (!(rep instanceof FilterMirrorRepresentation)) {
+ return false;
+ }
+ FilterMirrorRepresentation mirror = (FilterMirrorRepresentation) rep;
+ if (mMirror != mirror.mMirror) {
+ return false;
+ }
+ return true;
+ }
+
+ public Mirror getMirror() {
+ return mMirror;
+ }
+
+ public void set(FilterMirrorRepresentation r) {
+ mMirror = r.mMirror;
+ }
+
+ public void setMirror(Mirror mirror) {
+ if (mirror == null) {
+ throw new IllegalArgumentException("Argument to setMirror is null");
+ }
+ mMirror = mirror;
+ }
+
+ public boolean isHorizontal() {
+ if (mMirror == Mirror.BOTH
+ || mMirror == Mirror.HORIZONTAL) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isVertical() {
+ if (mMirror == Mirror.BOTH
+ || mMirror == Mirror.VERTICAL) {
+ return true;
+ }
+ return false;
+ }
+
+ public void cycle() {
+ switch (mMirror) {
+ case NONE:
+ mMirror = Mirror.HORIZONTAL;
+ break;
+ case HORIZONTAL:
+ mMirror = Mirror.BOTH;
+ break;
+ case BOTH:
+ mMirror = Mirror.VERTICAL;
+ break;
+ case VERTICAL:
+ mMirror = Mirror.NONE;
+ break;
+ }
+ }
+
+ @Override
+ public boolean allowsSingleInstanceOnly() {
+ return true;
+ }
+
+ @Override
+ public FilterRepresentation copy() {
+ return new FilterMirrorRepresentation(this);
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ if (!(representation instanceof FilterMirrorRepresentation)) {
+ throw new IllegalArgumentException("calling copyAllParameters with incompatible types!");
+ }
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ if (!(a instanceof FilterMirrorRepresentation)) {
+ throw new IllegalArgumentException("calling useParametersFrom with incompatible types!");
+ }
+ setMirror(((FilterMirrorRepresentation) a).getMirror());
+ }
+
+ @Override
+ public boolean isNil() {
+ return mMirror == getNil();
+ }
+
+ public static Mirror getNil() {
+ return Mirror.NONE;
+ }
+
+ @Override
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ writer.name(SERIALIZATION_MIRROR_VALUE).value(mMirror.value());
+ writer.endObject();
+ }
+
+ @Override
+ public void deSerializeRepresentation(JsonReader reader) throws IOException {
+ boolean unset = true;
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+ if (SERIALIZATION_MIRROR_VALUE.equals(name)) {
+ Mirror r = Mirror.fromValue((char) reader.nextInt());
+ if (r != null) {
+ setMirror(r);
+ unset = false;
+ }
+ } else {
+ reader.skipValue();
+ }
+ }
+ if (unset) {
+ Log.w(TAG, "WARNING: bad value when deserializing " + SERIALIZATION_NAME);
+ }
+ reader.endObject();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java
index fc01650..9bd1699 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java
@@ -25,17 +25,18 @@
public FilterPointRepresentation(String type, int textid, int editorID) {
super(type);
setFilterClass(ImageFilterRedEye.class);
- setPriority(FilterRepresentation.TYPE_NORMAL);
+ setFilterType(FilterRepresentation.TYPE_NORMAL);
setTextId(textid);
setEditorId(editorID);
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterPointRepresentation representation = (FilterPointRepresentation) super
- .clone();
- representation.mCandidates = (Vector<FilterPoint>) mCandidates.clone();
- return representation;
+ public abstract FilterRepresentation copy();
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
}
public boolean hasCandidates() {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
index 3f823ea..dd06a97 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
@@ -28,11 +28,25 @@
public FilterRedEyeRepresentation() {
super("RedEye",R.string.redeye,EditorRedEye.ID);
+ setSerializationName("REDEYE");
setFilterClass(ImageFilterRedEye.class);
setOverlayId(R.drawable.photoeditor_effect_redeye);
setOverlayOnly(true);
}
+ @Override
+ public FilterRepresentation copy() {
+ FilterRedEyeRepresentation representation = new FilterRedEyeRepresentation();
+ copyAllParameters(representation);
+ return representation;
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
public void addRect(RectF rect, RectF bounds) {
Vector<RedEyeCandidate> intersects = new Vector<RedEyeCandidate>();
for (int i = 0; i < getCandidates().size(); i++) {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index 82012b9..0fb157d 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -16,82 +16,94 @@
package com.android.gallery3d.filtershow.filters;
-import com.android.gallery3d.app.Log;
+import android.util.JsonReader;
+import android.util.JsonWriter;
+import android.util.Log;
+
import com.android.gallery3d.filtershow.editors.BasicEditor;
-public class FilterRepresentation implements Cloneable {
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class FilterRepresentation {
private static final String LOGTAG = "FilterRepresentation";
private static final boolean DEBUG = false;
private String mName;
private int mPriority = TYPE_NORMAL;
- private Class mFilterClass;
+ private Class<?> mFilterClass;
private boolean mSupportsPartialRendering = false;
private int mTextId = 0;
private int mEditorId = BasicEditor.ID;
private int mButtonId = 0;
private int mOverlayId = 0;
private boolean mOverlayOnly = false;
- private boolean mShowEditingControls = true;
private boolean mShowParameterValue = true;
- private boolean mShowUtilityPanel = true;
-
+ private boolean mIsBooleanFilter = false;
+ private String mSerializationName;
public static final byte TYPE_BORDER = 1;
public static final byte TYPE_FX = 2;
public static final byte TYPE_WBALANCE = 3;
public static final byte TYPE_VIGNETTE = 4;
public static final byte TYPE_NORMAL = 5;
public static final byte TYPE_TINYPLANET = 6;
-
- private FilterRepresentation mTempRepresentation = null;
+ public static final byte TYPE_GEOMETRY = 7;
+ protected static final String NAME_TAG = "Name";
public FilterRepresentation(String name) {
mName = name;
}
- @Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterRepresentation representation = (FilterRepresentation) super.clone();
+ public FilterRepresentation copy(){
+ FilterRepresentation representation = new FilterRepresentation(mName);
+ representation.useParametersFrom(this);
+ return representation;
+ }
+
+ protected void copyAllParameters(FilterRepresentation representation) {
representation.setName(getName());
- representation.setPriority(getPriority());
representation.setFilterClass(getFilterClass());
+ representation.setFilterType(getFilterType());
representation.setSupportsPartialRendering(supportsPartialRendering());
representation.setTextId(getTextId());
representation.setEditorId(getEditorId());
- representation.setButtonId(getButtonId());
representation.setOverlayId(getOverlayId());
representation.setOverlayOnly(getOverlayOnly());
- representation.setShowEditingControls(showEditingControls());
representation.setShowParameterValue(showParameterValue());
- representation.setShowUtilityPanel(showUtilityPanel());
- representation.mTempRepresentation =
- mTempRepresentation != null ? mTempRepresentation.clone() : null;
- if (DEBUG) {
- Log.v(LOGTAG, "cloning from <" + this + "> to <" + representation + ">");
- }
- return representation;
+ representation.mSerializationName = mSerializationName;
+ representation.setIsBooleanFilter(isBooleanFilter());
}
public boolean equals(FilterRepresentation representation) {
if (representation == null) {
return false;
}
- if (representation.mFilterClass == representation.mFilterClass
+ if (representation.mFilterClass == mFilterClass
&& representation.mName.equalsIgnoreCase(mName)
&& representation.mPriority == mPriority
- && representation.mSupportsPartialRendering == mSupportsPartialRendering
+ // TODO: After we enable partial rendering, we can switch back
+ // to use member variable here.
+ && representation.supportsPartialRendering() == supportsPartialRendering()
&& representation.mTextId == mTextId
&& representation.mEditorId == mEditorId
&& representation.mButtonId == mButtonId
&& representation.mOverlayId == mOverlayId
&& representation.mOverlayOnly == mOverlayOnly
- && representation.mShowEditingControls == mShowEditingControls
&& representation.mShowParameterValue == mShowParameterValue
- && representation.mShowUtilityPanel == mShowUtilityPanel) {
+ && representation.mIsBooleanFilter == mIsBooleanFilter) {
return true;
}
return false;
}
+ public boolean isBooleanFilter() {
+ return mIsBooleanFilter;
+ }
+
+ public void setIsBooleanFilter(boolean value) {
+ mIsBooleanFilter = value;
+ }
+
+ @Override
public String toString() {
return mName;
}
@@ -104,11 +116,19 @@
return mName;
}
- public void setPriority(int priority) {
+ public void setSerializationName(String sname) {
+ mSerializationName = sname;
+ }
+
+ public String getSerializationName() {
+ return mSerializationName;
+ }
+
+ public void setFilterType(int priority) {
mPriority = priority;
}
- public int getPriority() {
+ public int getFilterType() {
return mPriority;
}
@@ -117,7 +137,7 @@
}
public boolean supportsPartialRendering() {
- return false && mSupportsPartialRendering; // disable for now
+ return mSupportsPartialRendering;
}
public void setSupportsPartialRendering(boolean value) {
@@ -127,40 +147,21 @@
public void useParametersFrom(FilterRepresentation a) {
}
- public void clearTempRepresentation() {
- mTempRepresentation = null;
- }
-
- public synchronized void updateTempParametersFrom(FilterRepresentation representation) {
- if (mTempRepresentation == null) {
- try {
- mTempRepresentation = representation.clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
- } else {
- mTempRepresentation.useParametersFrom(representation);
- }
- }
-
- public synchronized void synchronizeRepresentation() {
- if (mTempRepresentation != null) {
- useParametersFrom(mTempRepresentation);
- }
- }
-
- public boolean allowsMultipleInstances() {
+ public boolean allowsSingleInstanceOnly() {
return false;
}
- public Class getFilterClass() {
+ public Class<?> getFilterClass() {
return mFilterClass;
}
- public void setFilterClass(Class filterClass) {
+ public void setFilterClass(Class<?> filterClass) {
mFilterClass = filterClass;
}
+ // This same() function is different from equals(), basically it checks
+ // whether 2 FilterRepresentations are the same type. It doesn't care about
+ // the values.
public boolean same(FilterRepresentation b) {
if (b == null) {
return false;
@@ -176,14 +177,6 @@
mTextId = textId;
}
- public int getButtonId() {
- return mButtonId;
- }
-
- public void setButtonId(int buttonId) {
- mButtonId = buttonId;
- }
-
public int getOverlayId() {
return mOverlayId;
}
@@ -213,14 +206,6 @@
mEditorId = editorId;
}
- public boolean showEditingControls() {
- return mShowEditingControls;
- }
-
- public void setShowEditingControls(boolean showEditingControls) {
- mShowEditingControls = showEditingControls;
- }
-
public boolean showParameterValue() {
return mShowParameterValue;
}
@@ -229,16 +214,67 @@
mShowParameterValue = showParameterValue;
}
- public boolean showUtilityPanel() {
- return mShowUtilityPanel;
- }
-
- public void setShowUtilityPanel(boolean showUtilityPanel) {
- mShowUtilityPanel = showUtilityPanel;
- }
-
public String getStateRepresentation() {
return "";
}
+ /**
+ * Method must "beginObject()" add its info and "endObject()"
+ * @param writer
+ * @throws IOException
+ */
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ {
+ String[][] rep = serializeRepresentation();
+ for (int k = 0; k < rep.length; k++) {
+ writer.name(rep[k][0]);
+ writer.value(rep[k][1]);
+ }
+ }
+ writer.endObject();
+ }
+
+ // this is the old way of doing this and will be removed soon
+ public String[][] serializeRepresentation() {
+ String[][] ret = {{NAME_TAG, getName()}};
+ return ret;
+ }
+
+ public void deSerializeRepresentation(JsonReader reader) throws IOException {
+ ArrayList<String[]> al = new ArrayList<String[]>();
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String[] kv = {reader.nextName(), reader.nextString()};
+ al.add(kv);
+
+ }
+ reader.endObject();
+ String[][] oldFormat = al.toArray(new String[al.size()][]);
+
+ deSerializeRepresentation(oldFormat);
+ }
+
+ // this is the old way of doing this and will be removed soon
+ public void deSerializeRepresentation(String[][] rep) {
+ for (int i = 0; i < rep.length; i++) {
+ if (NAME_TAG.equals(rep[i][0])) {
+ mName = rep[i][1];
+ break;
+ }
+ }
+ }
+
+ // Override this in subclasses
+ public int getStyle() {
+ return -1;
+ }
+
+ public boolean canMergeWith(FilterRepresentation representation) {
+ if (getFilterType() == FilterRepresentation.TYPE_GEOMETRY
+ && representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRotateRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRotateRepresentation.java
new file mode 100644
index 0000000..4299dd3
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRotateRepresentation.java
@@ -0,0 +1,193 @@
+/*
+ * 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 android.util.Log;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorRotate;
+import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+
+import java.io.IOException;
+
+public class FilterRotateRepresentation extends FilterRepresentation {
+ public static final String SERIALIZATION_NAME = "ROTATION";
+ public static final String SERIALIZATION_ROTATE_VALUE = "value";
+ private static final String TAG = FilterRotateRepresentation.class.getSimpleName();
+
+ Rotation mRotation;
+
+ public enum Rotation {
+ ZERO(0), NINETY(90), ONE_EIGHTY(180), TWO_SEVENTY(270);
+ private final int mValue;
+
+ private Rotation(int value) {
+ mValue = value;
+ }
+
+ public int value() {
+ return mValue;
+ }
+
+ public static Rotation fromValue(int value) {
+ switch (value) {
+ case 0:
+ return ZERO;
+ case 90:
+ return NINETY;
+ case 180:
+ return ONE_EIGHTY;
+ case 270:
+ return TWO_SEVENTY;
+ default:
+ return null;
+ }
+ }
+ }
+
+ public FilterRotateRepresentation(Rotation rotation) {
+ super(SERIALIZATION_NAME);
+ setSerializationName(SERIALIZATION_NAME);
+ setShowParameterValue(false);
+ setFilterClass(FilterRotateRepresentation.class);
+ setFilterType(FilterRepresentation.TYPE_GEOMETRY);
+ setSupportsPartialRendering(true);
+ setTextId(R.string.rotate);
+ setEditorId(ImageOnlyEditor.ID);
+ setRotation(rotation);
+ }
+
+ public FilterRotateRepresentation(FilterRotateRepresentation r) {
+ this(r.getRotation());
+ setName(r.getName());
+ }
+
+ public FilterRotateRepresentation() {
+ this(getNil());
+ }
+
+ public Rotation getRotation() {
+ return mRotation;
+ }
+
+ public void rotateCW() {
+ switch(mRotation) {
+ case ZERO:
+ mRotation = Rotation.NINETY;
+ break;
+ case NINETY:
+ mRotation = Rotation.ONE_EIGHTY;
+ break;
+ case ONE_EIGHTY:
+ mRotation = Rotation.TWO_SEVENTY;
+ break;
+ case TWO_SEVENTY:
+ mRotation = Rotation.ZERO;
+ break;
+ }
+ }
+
+ public void set(FilterRotateRepresentation r) {
+ mRotation = r.mRotation;
+ }
+
+ public void setRotation(Rotation rotation) {
+ if (rotation == null) {
+ throw new IllegalArgumentException("Argument to setRotation is null");
+ }
+ mRotation = rotation;
+ }
+
+ @Override
+ public boolean allowsSingleInstanceOnly() {
+ return true;
+ }
+
+ @Override
+ public FilterRepresentation copy() {
+ return new FilterRotateRepresentation(this);
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ if (!(representation instanceof FilterRotateRepresentation)) {
+ throw new IllegalArgumentException("calling copyAllParameters with incompatible types!");
+ }
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ if (!(a instanceof FilterRotateRepresentation)) {
+ throw new IllegalArgumentException("calling useParametersFrom with incompatible types!");
+ }
+ setRotation(((FilterRotateRepresentation) a).getRotation());
+ }
+
+ @Override
+ public boolean isNil() {
+ return mRotation == getNil();
+ }
+
+ public static Rotation getNil() {
+ return Rotation.ZERO;
+ }
+
+ @Override
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ writer.name(SERIALIZATION_ROTATE_VALUE).value(mRotation.value());
+ writer.endObject();
+ }
+
+ @Override
+ public boolean equals(FilterRepresentation rep) {
+ if (!(rep instanceof FilterRotateRepresentation)) {
+ return false;
+ }
+ FilterRotateRepresentation rotate = (FilterRotateRepresentation) rep;
+ if (rotate.mRotation.value() != mRotation.value()) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void deSerializeRepresentation(JsonReader reader) throws IOException {
+ boolean unset = true;
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+ if (SERIALIZATION_ROTATE_VALUE.equals(name)) {
+ Rotation r = Rotation.fromValue(reader.nextInt());
+ if (r != null) {
+ setRotation(r);
+ unset = false;
+ }
+ } else {
+ reader.skipValue();
+ }
+ }
+ if (unset) {
+ Log.w(TAG, "WARNING: bad value when deserializing " + SERIALIZATION_NAME);
+ }
+ reader.endObject();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java
new file mode 100644
index 0000000..1ba80e8
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java
@@ -0,0 +1,156 @@
+/*
+ * 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 android.util.Log;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorStraighten;
+
+import java.io.IOException;
+
+public class FilterStraightenRepresentation extends FilterRepresentation {
+ public static final String SERIALIZATION_NAME = "STRAIGHTEN";
+ public static final String SERIALIZATION_STRAIGHTEN_VALUE = "value";
+ private static final String TAG = FilterStraightenRepresentation.class.getSimpleName();
+ public static final int MAX_STRAIGHTEN_ANGLE = 45;
+ public static final int MIN_STRAIGHTEN_ANGLE = -45;
+
+ float mStraighten;
+
+ public FilterStraightenRepresentation(float straighten) {
+ super(SERIALIZATION_NAME);
+ setSerializationName(SERIALIZATION_NAME);
+ setShowParameterValue(true);
+ setFilterClass(FilterStraightenRepresentation.class);
+ setFilterType(FilterRepresentation.TYPE_GEOMETRY);
+ setSupportsPartialRendering(true);
+ setTextId(R.string.straighten);
+ setEditorId(EditorStraighten.ID);
+ setStraighten(straighten);
+ }
+
+ public FilterStraightenRepresentation(FilterStraightenRepresentation s) {
+ this(s.getStraighten());
+ setName(s.getName());
+ }
+
+ public FilterStraightenRepresentation() {
+ this(getNil());
+ }
+
+ public void set(FilterStraightenRepresentation r) {
+ mStraighten = r.mStraighten;
+ }
+
+ @Override
+ public boolean equals(FilterRepresentation rep) {
+ if (!(rep instanceof FilterStraightenRepresentation)) {
+ return false;
+ }
+ FilterStraightenRepresentation straighten = (FilterStraightenRepresentation) rep;
+ if (straighten.mStraighten != mStraighten) {
+ return false;
+ }
+ return true;
+ }
+
+ public float getStraighten() {
+ return mStraighten;
+ }
+
+ public void setStraighten(float straighten) {
+ if (!rangeCheck(straighten)) {
+ straighten = Math.min(Math.max(straighten, MIN_STRAIGHTEN_ANGLE), MAX_STRAIGHTEN_ANGLE);
+ }
+ mStraighten = straighten;
+ }
+
+ @Override
+ public boolean allowsSingleInstanceOnly() {
+ return true;
+ }
+
+ @Override
+ public FilterRepresentation copy() {
+ return new FilterStraightenRepresentation(this);
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ if (!(representation instanceof FilterStraightenRepresentation)) {
+ throw new IllegalArgumentException("calling copyAllParameters with incompatible types!");
+ }
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ if (!(a instanceof FilterStraightenRepresentation)) {
+ throw new IllegalArgumentException("calling useParametersFrom with incompatible types!");
+ }
+ setStraighten(((FilterStraightenRepresentation) a).getStraighten());
+ }
+
+ @Override
+ public boolean isNil() {
+ return mStraighten == getNil();
+ }
+
+ public static float getNil() {
+ return 0;
+ }
+
+ @Override
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ writer.name(SERIALIZATION_STRAIGHTEN_VALUE).value(mStraighten);
+ writer.endObject();
+ }
+
+ @Override
+ public void deSerializeRepresentation(JsonReader reader) throws IOException {
+ boolean unset = true;
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+ if (SERIALIZATION_STRAIGHTEN_VALUE.equals(name)) {
+ float s = (float) reader.nextDouble();
+ if (rangeCheck(s)) {
+ setStraighten(s);
+ unset = false;
+ }
+ } else {
+ reader.skipValue();
+ }
+ }
+ if (unset) {
+ Log.w(TAG, "WARNING: bad value when deserializing " + SERIALIZATION_NAME);
+ }
+ reader.endObject();
+ }
+
+ private boolean rangeCheck(double s) {
+ if (s < -45 || s > 45) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
index ac5e046..4f7bc6a 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
@@ -20,30 +20,37 @@
import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
+ private static final String SERIALIZATION_NAME = "TINYPLANET";
private static final String LOGTAG = "FilterTinyPlanetRepresentation";
+ private static final String SERIAL_ANGLE = "Angle";
private float mAngle = 0;
public FilterTinyPlanetRepresentation() {
super("TinyPlanet", 0, 50, 100);
+ setSerializationName(SERIALIZATION_NAME);
setShowParameterValue(true);
setFilterClass(ImageFilterTinyPlanet.class);
- setPriority(FilterRepresentation.TYPE_TINYPLANET);
+ setFilterType(FilterRepresentation.TYPE_TINYPLANET);
setTextId(R.string.tinyplanet);
- setButtonId(R.id.tinyplanetButton);
setEditorId(EditorTinyPlanet.ID);
setMinimum(1);
+ setSupportsPartialRendering(false);
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterTinyPlanetRepresentation representation = (FilterTinyPlanetRepresentation) super
- .clone();
- representation.mAngle = mAngle;
- representation.setZoom(getZoom());
+ public FilterRepresentation copy() {
+ FilterTinyPlanetRepresentation representation = new FilterTinyPlanetRepresentation();
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public void useParametersFrom(FilterRepresentation a) {
FilterTinyPlanetRepresentation representation = (FilterTinyPlanetRepresentation) a;
super.useParametersFrom(a);
@@ -71,4 +78,35 @@
// TinyPlanet always has an effect
return false;
}
+
+ public boolean equals(FilterRepresentation representation) {
+ if (!super.equals(representation)) {
+ return false;
+ }
+ if (mAngle == ((FilterTinyPlanetRepresentation) representation).mAngle) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String[][] serializeRepresentation() {
+ String[][] ret = {
+ {SERIAL_NAME , getName() },
+ {SERIAL_VALUE , Integer.toString(getValue())},
+ {SERIAL_ANGLE , Float.toString(mAngle)}};
+ return ret;
+ }
+
+ @Override
+ public void deSerializeRepresentation(String[][] rep) {
+ super.deSerializeRepresentation(rep);
+ for (int i = 0; i < rep.length; i++) {
+ if (SERIAL_VALUE.equals(rep[i][0])) {
+ setValue(Integer.parseInt(rep[i][1]));
+ } else if (SERIAL_ANGLE.equals(rep[i][0])) {
+ setAngle(Float.parseFloat(rep[i][1]));
+ }
+ }
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterUserPresetRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterUserPresetRepresentation.java
new file mode 100644
index 0000000..9f3fb45
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterUserPresetRepresentation.java
@@ -0,0 +1,54 @@
+/*
+ * 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 com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+public class FilterUserPresetRepresentation extends FilterRepresentation {
+
+ private ImagePreset mPreset;
+ private int mId;
+
+ public FilterUserPresetRepresentation(String name, ImagePreset preset, int id) {
+ super(name);
+ setEditorId(ImageOnlyEditor.ID);
+ setFilterType(FilterRepresentation.TYPE_FX);
+ setSupportsPartialRendering(true);
+ mPreset = preset;
+ mId = id;
+ }
+
+ public ImagePreset getImagePreset() {
+ return mPreset;
+ }
+
+ public int getId() {
+ return mId;
+ }
+
+ public FilterRepresentation copy(){
+ FilterRepresentation representation = new FilterUserPresetRepresentation(getName(),
+ new ImagePreset(mPreset), mId);
+ return representation;
+ }
+
+ @Override
+ public boolean allowsSingleInstanceOnly() {
+ return true;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
index eef54ef..d316ade 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
@@ -16,52 +16,99 @@
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.editors.EditorVignette;
import com.android.gallery3d.filtershow.imageshow.Oval;
-public class FilterVignetteRepresentation extends FilterBasicRepresentation implements Oval {
+import java.io.IOException;
+
+public class FilterVignetteRepresentation extends FilterRepresentation implements Oval {
private static final String LOGTAG = "FilterVignetteRepresentation";
- private float mCenterX = Float.NaN;
- private float mCenterY;
- private float mRadiusX = Float.NaN;
- private float mRadiusY;
+
+ private float mCenterX = .5f;
+ private float mCenterY = .5f;
+ private float mRadiusX = .5f;
+ private float mRadiusY = .5f;
+ public static final int MODE_VIGNETTE = 0;
+ public static final int MODE_EXPOSURE = 1;
+ public static final int MODE_SATURATION = 2;
+ public static final int MODE_CONTRAST = 3;
+ public static final int MODE_FALLOFF = 4;
+ private static int MIN = -100;
+ private static int MAX = 100;
+ private static int MAXFALLOF = 200;
+
+ private BasicParameterInt mParamVignette = new BasicParameterInt(MODE_VIGNETTE, 50, MIN, MAX);
+ private BasicParameterInt mParamExposure = new BasicParameterInt(MODE_EXPOSURE, 0, MIN, MAX);
+ private BasicParameterInt mParamSaturation = new BasicParameterInt(MODE_SATURATION, 0, MIN, MAX);
+ private BasicParameterInt mParamContrast = new BasicParameterInt(MODE_CONTRAST, 0, MIN, MAX);
+ private BasicParameterInt mParamFalloff = new BasicParameterInt(MODE_FALLOFF, 40, 0, MAXFALLOF);
+ private BasicParameterInt[] mAllParam = {
+ mParamVignette,
+ mParamExposure,
+ mParamSaturation,
+ mParamContrast,
+ mParamFalloff};
+ private int mParameterMode;
public FilterVignetteRepresentation() {
- super("Vignette", -100, 50, 100);
+ super("Vignette");
+ setSerializationName("VIGNETTE");
setShowParameterValue(true);
- setPriority(FilterRepresentation.TYPE_VIGNETTE);
+ setFilterType(FilterRepresentation.TYPE_VIGNETTE);
setTextId(R.string.vignette);
- setButtonId(R.id.vignetteEditor);
setEditorId(EditorVignette.ID);
setName("Vignette");
setFilterClass(ImageFilterVignette.class);
-
- setMinimum(-100);
- setMaximum(100);
- setDefaultValue(0);
}
@Override
public void useParametersFrom(FilterRepresentation a) {
super.useParametersFrom(a);
- mCenterX = ((FilterVignetteRepresentation) a).mCenterX;
- mCenterY = ((FilterVignetteRepresentation) a).mCenterY;
- mRadiusX = ((FilterVignetteRepresentation) a).mRadiusX;
- mRadiusY = ((FilterVignetteRepresentation) a).mRadiusY;
+ FilterVignetteRepresentation rep = (FilterVignetteRepresentation) a;
+ mCenterX = rep.mCenterX;
+ mCenterY = rep.mCenterY;
+ mRadiusX = rep.mRadiusX;
+ mRadiusY = rep.mRadiusY;
+ mParamVignette.setValue(rep.mParamVignette.getValue());
+ mParamExposure.setValue(rep.mParamExposure.getValue());
+ mParamSaturation.setValue(rep.mParamSaturation.getValue());
+ mParamContrast.setValue(rep.mParamContrast.getValue());
+ mParamFalloff.setValue(rep.mParamFalloff.getValue());
+ }
+
+ public int getValue(int mode) {
+ return mAllParam[mode].getValue();
+ }
+
+ public void setValue(int mode, int value) {
+ mAllParam[mode].setValue(value);
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterVignetteRepresentation representation = (FilterVignetteRepresentation) super
- .clone();
- representation.mCenterX = mCenterX;
- representation.mCenterY = mCenterY;
+ public String toString() {
+ return getName() + " : " + mCenterX + ", " + mCenterY + " radius: " + mRadiusX;
+ }
+ @Override
+ public FilterRepresentation copy() {
+ FilterVignetteRepresentation representation = new FilterVignetteRepresentation();
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public void setCenter(float centerX, float centerY) {
mCenterX = centerX;
mCenterY = centerY;
@@ -109,6 +156,111 @@
@Override
public boolean isNil() {
- return getValue() == 0;
+ return false;
}
+
+ @Override
+ public boolean equals(FilterRepresentation representation) {
+ if (!super.equals(representation)) {
+ return false;
+ }
+ if (representation instanceof FilterVignetteRepresentation) {
+ FilterVignetteRepresentation rep = (FilterVignetteRepresentation) representation;
+ for (int i = 0; i < mAllParam.length; i++) {
+ if (mAllParam[i].getValue() != rep.mAllParam[i].getValue())
+ return false;
+ }
+ if (rep.getCenterX() == getCenterX()
+ && rep.getCenterY() == getCenterY()
+ && rep.getRadiusX() == getRadiusX()
+ && rep.getRadiusY() == getRadiusY()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static final String ELLIPSE = "ellipse";
+ private static final String ARGS = "adjust";
+ @Override
+ public void serializeRepresentation(JsonWriter writer) throws IOException {
+ writer.beginObject();
+ writer.name(ELLIPSE);
+ writer.beginArray();
+ writer.value(mCenterX);
+ writer.value(mCenterY);
+ writer.value(mRadiusX);
+ writer.value(mRadiusY);
+ writer.endArray();
+
+ writer.name(ARGS);
+ writer.beginArray();
+ writer.value(mParamVignette.getValue());
+ writer.value(mParamExposure.getValue());
+ writer.value(mParamSaturation.getValue());
+ writer.value(mParamContrast.getValue());
+ writer.value(mParamFalloff.getValue());
+ writer.endArray();
+ writer.endObject();
+ }
+
+
+ @Override
+ public void deSerializeRepresentation(JsonReader sreader) throws IOException {
+ sreader.beginObject();
+
+ while (sreader.hasNext()) {
+ String name = sreader.nextName();
+ if (name.startsWith(ELLIPSE)) {
+ sreader.beginArray();
+ sreader.hasNext();
+ mCenterX = (float) sreader.nextDouble();
+ sreader.hasNext();
+ mCenterY = (float) sreader.nextDouble();
+ sreader.hasNext();
+ mRadiusX = (float) sreader.nextDouble();
+ sreader.hasNext();
+ mRadiusY = (float) sreader.nextDouble();
+ sreader.hasNext();
+ sreader.endArray();
+ } else if (name.startsWith(ARGS)) {
+ sreader.beginArray();
+ sreader.hasNext();
+ mParamVignette.setValue(sreader.nextInt());
+ sreader.hasNext();
+ mParamExposure.setValue(sreader.nextInt());
+ sreader.hasNext();
+ mParamSaturation.setValue(sreader.nextInt());
+ sreader.hasNext();
+ mParamContrast.setValue(sreader.nextInt());
+ sreader.hasNext();
+ mParamFalloff.setValue(sreader.nextInt());
+ sreader.hasNext();
+ sreader.endArray();
+ } else {
+ sreader.skipValue();
+ }
+ }
+ sreader.endObject();
+ }
+ 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);
+ }
+
+ public BasicParameterInt getFilterParameter(int index) {
+ return mAllParam[index];
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FiltersManagerInterface.java b/src/com/android/gallery3d/filtershow/filters/FiltersManagerInterface.java
new file mode 100644
index 0000000..710128f
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FiltersManagerInterface.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+public interface FiltersManagerInterface {
+ ImageFilter getFilterForRepresentation(FilterRepresentation representation);
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/IconUtilities.java b/src/com/android/gallery3d/filtershow/filters/IconUtilities.java
index 38211f3..e2a0147 100644
--- a/src/com/android/gallery3d/filtershow/filters/IconUtilities.java
+++ b/src/com/android/gallery3d/filtershow/filters/IconUtilities.java
@@ -64,8 +64,9 @@
int h = bitmap.getHeight();
int fxw = fxBitmap.getWidth();
int fxh = fxBitmap.getHeight();
-
- nativeApplyFilter(bitmap, w, h, fxBitmap, fxw, fxh);
+ int start = 0;
+ int end = w * h * 4;
+ nativeApplyFilter(bitmap, w, h, fxBitmap, fxw, fxh, start, end);
return bitmap;
}
};
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
index 96ab84f..4371374 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
@@ -16,15 +16,15 @@
package com.android.gallery3d.filtershow.filters;
+import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.support.v8.renderscript.Allocation;
import android.widget.Toast;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.presets.FilterEnvironment;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
public abstract class ImageFilter implements Cloneable {
private FilterEnvironment mEnvironment = null;
@@ -35,9 +35,9 @@
// TODO: Temporary, for dogfood note memory issues with toasts for better
// feedback. Remove this when filters actually work in low memory
// situations.
- private static FilterShowActivity sActivity = null;
+ private static Activity sActivity = null;
- public static void setActivityForMemoryToasts(FilterShowActivity activity) {
+ public static void setActivityForMemoryToasts(Activity activity) {
sActivity = activity;
}
@@ -69,17 +69,15 @@
public boolean supportsAllocationInput() { return false; }
public void apply(Allocation in, Allocation out) {
+ setGeneralParameters();
}
public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
// do nothing here, subclasses will implement filtering here
+ setGeneralParameters();
return bitmap;
}
- public ImagePreset getImagePreset() {
- return getEnvironment().getImagePreset();
- }
-
public abstract void useRepresentation(FilterRepresentation representation);
native protected void nativeApplyGradientFilter(Bitmap bitmap, int w, int h,
@@ -90,12 +88,8 @@
}
protected Matrix getOriginalToScreenMatrix(int w, int h) {
- GeometryMetadata geo = getImagePreset().mGeoData;
- Matrix originalToScreen = geo.getOriginalToScreen(true,
- getImagePreset().getImageLoader().getOriginalBounds().width(),
- getImagePreset().getImageLoader().getOriginalBounds().height(),
- w, h);
- return originalToScreen;
+ return GeometryMathUtils.getImageToScreenMatrix(getEnvironment().getImagePreset()
+ .getGeometryFilters(), true, MasterImage.getImage().getOriginalBounds(), w, h);
}
public void setEnvironment(FilterEnvironment environment) {
@@ -105,4 +99,11 @@
public FilterEnvironment getEnvironment() {
return mEnvironment;
}
+
+ public void setGeneralParameters() {
+ // should implement in subclass which like to transport
+ // some information to other filters. (like the style setting from RetroLux
+ // and Film to FixedFrame)
+ mEnvironment.clearGeneralParameters();
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java
index a4626cd..50837ca 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBwFilter.java
@@ -23,6 +23,7 @@
public class ImageFilterBwFilter extends SimpleImageFilter {
+ private static final String SERIALIZATION_NAME = "BWFILTER";
public ImageFilterBwFilter() {
mName = "BW Filter";
@@ -31,11 +32,12 @@
public FilterRepresentation getDefaultRepresentation() {
FilterBasicRepresentation representation = (FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("BW Filter");
+ representation.setSerializationName(SERIALIZATION_NAME);
+
representation.setFilterClass(ImageFilterBwFilter.class);
representation.setMaximum(180);
representation.setMinimum(-180);
representation.setTextId(R.string.bwfilter);
- representation.setButtonId(R.id.bwfilterButton);
representation.setSupportsPartialRendering(true);
return representation;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterChanSat.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterChanSat.java
new file mode 100644
index 0000000..1ea8edf
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterChanSat.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+import android.graphics.Matrix;
+import android.support.v8.renderscript.Allocation;
+import android.support.v8.renderscript.Element;
+import android.support.v8.renderscript.RenderScript;
+import android.support.v8.renderscript.Script.LaunchOptions;
+import android.support.v8.renderscript.Type;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
+
+public class ImageFilterChanSat extends ImageFilterRS {
+ private static final String LOGTAG = "ImageFilterChanSat";
+ private ScriptC_saturation mScript;
+ private Bitmap mSourceBitmap;
+
+ private static final int STRIP_SIZE = 64;
+
+ FilterChanSatRepresentation mParameters = new FilterChanSatRepresentation();
+ private Bitmap mOverlayBitmap;
+
+ public ImageFilterChanSat() {
+ mName = "ChannelSat";
+ }
+
+ @Override
+ public FilterRepresentation getDefaultRepresentation() {
+ return new FilterChanSatRepresentation();
+ }
+
+ @Override
+ public void useRepresentation(FilterRepresentation representation) {
+ mParameters = (FilterChanSatRepresentation) representation;
+ }
+
+ @Override
+ protected void resetAllocations() {
+
+ }
+
+ @Override
+ public void resetScripts() {
+ if (mScript != null) {
+ mScript.destroy();
+ mScript = null;
+ }
+ }
+ @Override
+ protected void createFilter(android.content.res.Resources res, float scaleFactor,
+ int quality) {
+ createFilter(res, scaleFactor, quality, getInPixelsAllocation());
+ }
+
+ @Override
+ protected void createFilter(android.content.res.Resources res, float scaleFactor,
+ int quality, Allocation in) {
+ RenderScript rsCtx = getRenderScriptContext();
+
+ Type.Builder tb_float = new Type.Builder(rsCtx, Element.F32_4(rsCtx));
+ tb_float.setX(in.getType().getX());
+ tb_float.setY(in.getType().getY());
+ mScript = new ScriptC_saturation(rsCtx, res, R.raw.saturation);
+ }
+
+
+ private Bitmap getSourceBitmap() {
+ assert (mSourceBitmap != null);
+ return mSourceBitmap;
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
+ if (SIMPLE_ICONS && FilterEnvironment.QUALITY_ICON == quality) {
+ return bitmap;
+ }
+
+ mSourceBitmap = bitmap;
+ Bitmap ret = super.apply(bitmap, scaleFactor, quality);
+ mSourceBitmap = null;
+
+ return ret;
+ }
+
+ @Override
+ protected void bindScriptValues() {
+ int width = getInPixelsAllocation().getType().getX();
+ int height = getInPixelsAllocation().getType().getY();
+ }
+
+
+
+ @Override
+ protected void runFilter() {
+ int []sat = new int[7];
+ for(int i = 0;i<sat.length ;i ++){
+ sat[i] = mParameters.getValue(i);
+ }
+
+
+ int width = getInPixelsAllocation().getType().getX();
+ int height = getInPixelsAllocation().getType().getY();
+ Matrix m = getOriginalToScreenMatrix(width, height);
+
+
+ mScript.set_saturation(sat);
+
+ mScript.invoke_setupGradParams();
+ runSelectiveAdjust(
+ getInPixelsAllocation(), getOutPixelsAllocation());
+
+ }
+
+ private void runSelectiveAdjust(Allocation in, Allocation out) {
+ int width = in.getType().getX();
+ int height = in.getType().getY();
+
+ LaunchOptions options = new LaunchOptions();
+ int ty;
+ options.setX(0, width);
+
+ for (ty = 0; ty < height; ty += STRIP_SIZE) {
+ int endy = ty + STRIP_SIZE;
+ if (endy > height) {
+ endy = height;
+ }
+ options.setY(ty, endy);
+ mScript.forEach_selectiveAdjust(in, out, options);
+ if (checkStop()) {
+ return;
+ }
+ }
+ }
+
+ private boolean checkStop() {
+ RenderScript rsCtx = getRenderScriptContext();
+ rsCtx.finish();
+ if (getEnvironment().needsStop()) {
+ return true;
+ }
+ return false;
+ }
+}
+
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterColorBorder.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterColorBorder.java
new file mode 100644
index 0000000..5cc7c3d
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterColorBorder.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.RectF;
+
+public class ImageFilterColorBorder extends ImageFilter {
+ private static final String LOGTAG = "ImageFilterColorBorder";
+ private FilterColorBorderRepresentation mParameters = null;
+ Paint mPaint = new Paint();
+ RectF mBounds = new RectF();
+ RectF mInsideBounds = new RectF();
+ Path mBorderPath = new Path();
+
+ public ImageFilterColorBorder() {
+ mName = "Border";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ return new FilterColorBorderRepresentation(Color.WHITE, 3, 2);
+ }
+
+ public void useRepresentation(FilterRepresentation representation) {
+ FilterColorBorderRepresentation parameters =
+ (FilterColorBorderRepresentation) representation;
+ mParameters = parameters;
+ }
+
+ public FilterColorBorderRepresentation getParameters() {
+ return mParameters;
+ }
+
+ private void applyHelper(Canvas canvas, int w, int h) {
+ if (getParameters() == null) {
+ return;
+ }
+ float size = getParameters().getBorderSize();
+ float radius = getParameters().getBorderRadius();
+
+ mPaint.reset();
+ mPaint.setColor(getParameters().getColor());
+ mPaint.setAntiAlias(true);
+ mBounds.set(0, 0, w, h);
+ mBorderPath.reset();
+ mBorderPath.moveTo(0, 0);
+
+ float bs = size / 100.f * mBounds.width();
+ float r = radius / 100.f * mBounds.width();
+
+ mInsideBounds.set(mBounds.left + bs,
+ mBounds.top + bs, mBounds.right - bs,
+ mBounds.bottom - bs);
+
+ mBorderPath.moveTo(mBounds.left, mBounds.top);
+ mBorderPath.lineTo(mBounds.right, mBounds.top);
+ mBorderPath.lineTo(mBounds.right, mBounds.bottom);
+ mBorderPath.lineTo(mBounds.left, mBounds.bottom);
+ mBorderPath.addRoundRect(mInsideBounds,
+ r, r, Path.Direction.CCW);
+
+ canvas.drawPath(mBorderPath, mPaint);
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
+ Canvas canvas = new Canvas(bitmap);
+ applyHelper(canvas, bitmap.getWidth(), bitmap.getHeight());
+ return bitmap;
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java
index 2097f0d..27c0e08 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterContrast.java
@@ -21,6 +21,7 @@
import android.graphics.Bitmap;
public class ImageFilterContrast extends SimpleImageFilter {
+ private static final String SERIALIZATION_NAME = "CONTRAST";
public ImageFilterContrast() {
mName = "Contrast";
@@ -30,10 +31,10 @@
FilterBasicRepresentation representation =
(FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("Contrast");
+ representation.setSerializationName(SERIALIZATION_NAME);
+
representation.setFilterClass(ImageFilterContrast.class);
representation.setTextId(R.string.contrast);
- representation.setButtonId(R.id.contrastButton);
-
representation.setMinimum(-100);
representation.setMaximum(100);
representation.setDefaultValue(0);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
index daa1cd3..61b60d2 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
@@ -18,7 +18,7 @@
import android.graphics.Bitmap;
-import com.android.gallery3d.filtershow.ui.Spline;
+import com.android.gallery3d.filtershow.imageshow.Spline;
public class ImageFilterCurves extends ImageFilter {
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
index 0b02fc4..efb9cde 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
@@ -22,8 +22,10 @@
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
public class ImageFilterDownsample extends SimpleImageFilter {
+ private static final String SERIALIZATION_NAME = "DOWNSAMPLE";
private static final int ICON_DOWNSAMPLE_FRACTION = 8;
private ImageLoader mImageLoader;
@@ -35,6 +37,8 @@
public FilterRepresentation getDefaultRepresentation() {
FilterBasicRepresentation representation = (FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("Downsample");
+ representation.setSerializationName(SERIALIZATION_NAME);
+
representation.setFilterClass(ImageFilterDownsample.class);
representation.setMaximum(100);
representation.setMinimum(1);
@@ -42,7 +46,6 @@
representation.setDefaultValue(50);
representation.setPreviewValue(3);
representation.setTextId(R.string.downsample);
- representation.setButtonId(R.id.downsampleButton);
return representation;
}
@@ -56,7 +59,7 @@
int p = getParameters().getValue();
// size of original precached image
- Rect size = mImageLoader.getOriginalBounds();
+ Rect size = MasterImage.getImage().getOriginalBounds();
int orig_w = size.width();
int orig_h = size.height();
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
index 1fd9071..8fd5b02 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
@@ -29,9 +29,11 @@
import android.graphics.PorterDuffColorFilter;
import com.android.gallery3d.R;
+import com.android.gallery3d.app.Log;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation.StrokeData;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
import java.util.Vector;
@@ -52,7 +54,9 @@
}
DrawStyle[] mDrawingsTypes = new DrawStyle[] {
- new SimpleDraw(),
+ new SimpleDraw(0),
+ new SimpleDraw(1),
+ new Brush(R.drawable.brush_gauss),
new Brush(R.drawable.brush_marker),
new Brush(R.drawable.brush_spatter)
};
@@ -90,6 +94,11 @@
class SimpleDraw implements DrawStyle {
byte mType;
+ int mMode;
+
+ public SimpleDraw(int mode) {
+ mMode = mode;
+ }
@Override
public void setType(byte type) {
@@ -108,6 +117,12 @@
Paint paint = new Paint();
paint.setStyle(Style.STROKE);
+ if (mMode == 0) {
+ paint.setStrokeCap(Paint.Cap.SQUARE);
+ } else {
+ paint.setStrokeCap(Paint.Cap.ROUND);
+ }
+ paint.setAntiAlias(true);
paint.setColor(sd.mColor);
paint.setStrokeWidth(toScrMatrix.mapRadius(sd.mRadius));
@@ -127,18 +142,21 @@
public Brush(int brushID) {
mBrushID = brushID;
}
+
public Bitmap getBrush() {
if (mBrush == null) {
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.ALPHA_8;
- mBrush = MasterImage.getImage().getImageLoader().decodeImage(mBrushID, opt);
+ mBrush = BitmapFactory.decodeResource(MasterImage.getImage().getActivity()
+ .getResources(), mBrushID, opt);
mBrush = mBrush.extractAlpha();
}
return mBrush;
}
@Override
- public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
+ public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas,
+ Matrix toScrMatrix,
int quality) {
if (sd == null || sd.mPath == null) {
return;
@@ -204,7 +222,7 @@
public void drawData(Canvas canvas, Matrix originalRotateToScreen, int quality) {
Paint paint = new Paint();
- if (quality == ImagePreset.QUALITY_FINAL) {
+ if (quality == FilterEnvironment.QUALITY_FINAL) {
paint.setAntiAlias(true);
}
paint.setStyle(Style.STROKE);
@@ -212,9 +230,12 @@
paint.setStrokeWidth(40);
if (mParameters.getDrawing().isEmpty() && mParameters.getCurrentDrawing() == null) {
+ mOverlayBitmap = null;
+ mCachedStrokes = -1;
return;
}
- if (quality == ImagePreset.QUALITY_FINAL) {
+ if (quality == FilterEnvironment.QUALITY_FINAL) {
+
for (FilterDrawRepresentation.StrokeData strokeData : mParameters.getDrawing()) {
paint(strokeData, canvas, originalRotateToScreen, quality);
}
@@ -248,17 +269,17 @@
int n = v.size();
for (int i = mCachedStrokes; i < n; i++) {
- paint(v.get(i), drawCache, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
+ paint(v.get(i), drawCache, originalRotateToScreen, FilterEnvironment.QUALITY_PREVIEW);
}
mCachedStrokes = n;
}
public void draw(Canvas canvas, Matrix originalRotateToScreen) {
for (FilterDrawRepresentation.StrokeData strokeData : mParameters.getDrawing()) {
- paint(strokeData, canvas, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
+ paint(strokeData, canvas, originalRotateToScreen, FilterEnvironment.QUALITY_PREVIEW);
}
mDrawingsTypes[mCurrentStyle].paint(
- null, canvas, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
+ null, canvas, originalRotateToScreen, FilterEnvironment.QUALITY_PREVIEW);
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java
index 46a9a29..2d0d765 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterEdge.java
@@ -21,7 +21,7 @@
import com.android.gallery3d.R;
public class ImageFilterEdge extends SimpleImageFilter {
-
+ private static final String SERIALIZATION_NAME = "EDGE";
public ImageFilterEdge() {
mName = "Edge";
}
@@ -29,9 +29,9 @@
public FilterRepresentation getDefaultRepresentation() {
FilterRepresentation representation = super.getDefaultRepresentation();
representation.setName("Edge");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterEdge.class);
representation.setTextId(R.string.edge);
- representation.setButtonId(R.id.edgeButton);
representation.setSupportsPartialRendering(true);
return representation;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java
index b0b0b2d..69eab73 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java
@@ -21,7 +21,7 @@
import android.graphics.Bitmap;
public class ImageFilterExposure extends SimpleImageFilter {
-
+ private static final String SERIALIZATION_NAME = "EXPOSURE";
public ImageFilterExposure() {
mName = "Exposure";
}
@@ -30,9 +30,9 @@
FilterBasicRepresentation representation =
(FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("Exposure");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterExposure.class);
representation.setTextId(R.string.exposure);
- representation.setButtonId(R.id.exposureButton);
representation.setMinimum(-100);
representation.setMaximum(100);
representation.setDefaultValue(0);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
index 68e8a7c..19bea59 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
@@ -37,6 +37,11 @@
mFxBitmap = null;
}
+ @Override
+ public FilterRepresentation getDefaultRepresentation() {
+ return null;
+ }
+
public void useRepresentation(FilterRepresentation representation) {
FilterFxRepresentation parameters = (FilterFxRepresentation) representation;
mParameters = parameters;
@@ -46,7 +51,9 @@
return mParameters;
}
- native protected void nativeApplyFilter(Bitmap bitmap, int w, int h,Bitmap fxBitmap, int fxw, int fxh);
+ native protected void nativeApplyFilter(Bitmap bitmap, int w, int h,
+ Bitmap fxBitmap, int fxw, int fxh,
+ int start, int end);
@Override
public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
@@ -80,11 +87,25 @@
int fxw = mFxBitmap.getWidth();
int fxh = mFxBitmap.getHeight();
- nativeApplyFilter(bitmap, w, h, mFxBitmap, fxw, fxh);
+ int stride = w * 4;
+ int max = stride * h;
+ int increment = stride * 256; // 256 lines
+ for (int i = 0; i < max; i += increment) {
+ int start = i;
+ int end = i + increment;
+ if (end > max) {
+ end = max;
+ }
+ if (!getEnvironment().needsStop()) {
+ nativeApplyFilter(bitmap, w, h, mFxBitmap, fxw, fxh, start, end);
+ }
+ }
+
return bitmap;
}
public void setResources(Resources resources) {
mResources = resources;
}
+
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
deleted file mode 100644
index 4f46eed..0000000
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.filters;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.util.Log;
-
-import com.android.gallery3d.filtershow.crop.CropExtras;
-import com.android.gallery3d.filtershow.imageshow.GeometryMath;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-
-public class ImageFilterGeometry extends ImageFilter {
- private final Bitmap.Config mConfig = Bitmap.Config.ARGB_8888;
- private GeometryMetadata mGeometry = null;
- private static final String LOGTAG = "ImageFilterGeometry";
- private static final boolean LOGV = false;
- private static final int BOTH = 3;
- private static final int VERTICAL = 2;
- private static final int HORIZONTAL = 1;
- private static final int NINETY = 1;
- private static final int ONE_EIGHTY = 2;
- private static final int TWO_SEVENTY = 3;
-
- public ImageFilterGeometry() {
- mName = "Geometry";
- }
-
- @Override
- public ImageFilter clone() throws CloneNotSupportedException {
- // FIXME: clone() should not be needed. Remove when we fix geometry.
- ImageFilterGeometry filter = (ImageFilterGeometry) super.clone();
- return filter;
- }
-
- native protected void nativeApplyFilterFlip(Bitmap src, int srcWidth, int srcHeight,
- Bitmap dst, int dstWidth, int dstHeight, int flip);
-
- native protected void nativeApplyFilterRotate(Bitmap src, int srcWidth, int srcHeight,
- Bitmap dst, int dstWidth, int dstHeight, int rotate);
-
- native protected void nativeApplyFilterCrop(Bitmap src, int srcWidth, int srcHeight,
- Bitmap dst, int dstWidth, int dstHeight, int offsetWidth, int offsetHeight);
-
- native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight,
- Bitmap dst, int dstWidth, int dstHeight, float straightenAngle);
-
- @Override
- public void useRepresentation(FilterRepresentation representation) {
- mGeometry = (GeometryMetadata) representation;
- }
-
- @Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
- // TODO: implement bilinear or bicubic here... for now, just use
- // canvas to do a simple implementation...
- // TODO: and be more memory efficient! (do it in native?)
- RectF cb = mGeometry.getPreviewCropBounds();
- RectF pb = mGeometry.getPhotoBounds();
- if (cb.width() == 0 || cb.height() == 0 || pb.width() == 0 || pb.height() == 0) {
- Log.w(LOGTAG, "Cannot apply geometry: geometry metadata has not been initialized");
- return bitmap;
- }
- CropExtras extras = mGeometry.getCropExtras();
- boolean useExtras = mGeometry.getUseCropExtrasFlag();
- int outputX = 0;
- int outputY = 0;
- boolean s = false;
- if (extras != null && useExtras){
- outputX = extras.getOutputX();
- outputY = extras.getOutputY();
- s = extras.getScaleUp();
- }
-
-
- Rect cropBounds = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
- RectF crop = mGeometry.getCropBounds(bitmap);
- if (crop.width() > 0 && crop.height() > 0)
- cropBounds = GeometryMath.roundNearest(crop);
-
- int width = cropBounds.width();
- int height = cropBounds.height();
-
- if (mGeometry.hasSwitchedWidthHeight()){
- int temp = width;
- width = height;
- height = temp;
- }
-
- if(outputX <= 0 || outputY <= 0){
- outputX = width;
- outputY = height;
- }
-
- float scaleX = 1;
- float scaleY = 1;
- if (s){
- scaleX = (float) outputX / width;
- scaleY = (float) outputY / height;
- }
-
- Bitmap temp = null;
- temp = Bitmap.createBitmap(outputX, outputY, mConfig);
-
- float[] displayCenter = {
- temp.getWidth() / 2f, temp.getHeight() / 2f
- };
-
- Matrix m1 = mGeometry.buildTotalXform(bitmap.getWidth(), bitmap.getHeight(), displayCenter);
-
- m1.postScale(scaleX, scaleY, displayCenter[0], displayCenter[1]);
-
- Canvas canvas = new Canvas(temp);
- Paint paint = new Paint();
- paint.setAntiAlias(true);
- paint.setFilterBitmap(true);
- paint.setDither(true);
- canvas.drawBitmap(bitmap, m1, paint);
- return temp;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java
new file mode 100644
index 0000000..cbdfaa6
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.Matrix;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
+
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.Matrix;
+import android.support.v8.renderscript.Allocation;
+import android.support.v8.renderscript.Element;
+import android.support.v8.renderscript.RenderScript;
+import android.support.v8.renderscript.Script.LaunchOptions;
+import android.support.v8.renderscript.Type;
+import android.util.Log;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
+
+public class ImageFilterGrad extends ImageFilterRS {
+ private static final String LOGTAG = "ImageFilterGrad";
+ private ScriptC_grad mScript;
+ private Bitmap mSourceBitmap;
+ private static final int RADIUS_SCALE_FACTOR = 160;
+
+ private static final int STRIP_SIZE = 64;
+
+ FilterGradRepresentation mParameters = new FilterGradRepresentation();
+ private Bitmap mOverlayBitmap;
+
+ public ImageFilterGrad() {
+ mName = "grad";
+ }
+
+ @Override
+ public FilterRepresentation getDefaultRepresentation() {
+ return new FilterGradRepresentation();
+ }
+
+ @Override
+ public void useRepresentation(FilterRepresentation representation) {
+ mParameters = (FilterGradRepresentation) representation;
+ }
+
+ @Override
+ protected void resetAllocations() {
+
+ }
+
+ @Override
+ public void resetScripts() {
+ if (mScript != null) {
+ mScript.destroy();
+ mScript = null;
+ }
+ }
+ @Override
+ protected void createFilter(android.content.res.Resources res, float scaleFactor,
+ int quality) {
+ createFilter(res, scaleFactor, quality, getInPixelsAllocation());
+ }
+
+ @Override
+ protected void createFilter(android.content.res.Resources res, float scaleFactor,
+ int quality, Allocation in) {
+ RenderScript rsCtx = getRenderScriptContext();
+
+ Type.Builder tb_float = new Type.Builder(rsCtx, Element.F32_4(rsCtx));
+ tb_float.setX(in.getType().getX());
+ tb_float.setY(in.getType().getY());
+ mScript = new ScriptC_grad(rsCtx, res, R.raw.grad);
+ }
+
+
+ private Bitmap getSourceBitmap() {
+ assert (mSourceBitmap != null);
+ return mSourceBitmap;
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
+ if (SIMPLE_ICONS && FilterEnvironment.QUALITY_ICON == quality) {
+ return bitmap;
+ }
+
+ mSourceBitmap = bitmap;
+ Bitmap ret = super.apply(bitmap, scaleFactor, quality);
+ mSourceBitmap = null;
+
+ return ret;
+ }
+
+ @Override
+ protected void bindScriptValues() {
+ int width = getInPixelsAllocation().getType().getX();
+ int height = getInPixelsAllocation().getType().getY();
+ mScript.set_inputWidth(width);
+ mScript.set_inputHeight(height);
+ }
+
+ @Override
+ protected void runFilter() {
+ int[] x1 = mParameters.getXPos1();
+ int[] y1 = mParameters.getYPos1();
+ int[] x2 = mParameters.getXPos2();
+ int[] y2 = mParameters.getYPos2();
+
+ int width = getInPixelsAllocation().getType().getX();
+ int height = getInPixelsAllocation().getType().getY();
+ Matrix m = getOriginalToScreenMatrix(width, height);
+ float[] coord = new float[2];
+ for (int i = 0; i < x1.length; i++) {
+ coord[0] = x1[i];
+ coord[1] = y1[i];
+ m.mapPoints(coord);
+ x1[i] = (int) coord[0];
+ y1[i] = (int) coord[1];
+ coord[0] = x2[i];
+ coord[1] = y2[i];
+ m.mapPoints(coord);
+ x2[i] = (int) coord[0];
+ y2[i] = (int) coord[1];
+ }
+
+ mScript.set_mask(mParameters.getMask());
+ mScript.set_xPos1(x1);
+ mScript.set_yPos1(y1);
+ mScript.set_xPos2(x2);
+ mScript.set_yPos2(y2);
+
+ mScript.set_brightness(mParameters.getBrightness());
+ mScript.set_contrast(mParameters.getContrast());
+ mScript.set_saturation(mParameters.getSaturation());
+
+ mScript.invoke_setupGradParams();
+ runSelectiveAdjust(
+ getInPixelsAllocation(), getOutPixelsAllocation());
+
+ }
+
+ private void runSelectiveAdjust(Allocation in, Allocation out) {
+ int width = in.getType().getX();
+ int height = in.getType().getY();
+
+ LaunchOptions options = new LaunchOptions();
+ int ty;
+ options.setX(0, width);
+
+ for (ty = 0; ty < height; ty += STRIP_SIZE) {
+ int endy = ty + STRIP_SIZE;
+ if (endy > height) {
+ endy = height;
+ }
+ options.setY(ty, endy);
+ mScript.forEach_selectiveAdjust(in, out, options);
+ if (checkStop()) {
+ return;
+ }
+ }
+ }
+
+ private boolean checkStop() {
+ RenderScript rsCtx = getRenderScriptContext();
+ rsCtx.finish();
+ if (getEnvironment().needsStop()) {
+ return true;
+ }
+ return false;
+ }
+}
+
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterHighlights.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterHighlights.java
index 0022a9e..4c837e0 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterHighlights.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterHighlights.java
@@ -21,6 +21,7 @@
import com.android.gallery3d.R;
public class ImageFilterHighlights extends SimpleImageFilter {
+ private static final String SERIALIZATION_NAME = "HIGHLIGHTS";
private static final String LOGTAG = "ImageFilterVignette";
public ImageFilterHighlights() {
@@ -33,10 +34,10 @@
public FilterRepresentation getDefaultRepresentation() {
FilterBasicRepresentation representation =
(FilterBasicRepresentation) super.getDefaultRepresentation();
- representation.setName("Shadows");
+ representation.setName("Highlights");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterHighlights.class);
representation.setTextId(R.string.highlight_recovery);
- representation.setButtonId(R.id.highlightRecoveryButton);
representation.setMinimum(-100);
representation.setMaximum(100);
representation.setDefaultValue(0);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java
index b1f9f73..b87c254 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterHue.java
@@ -22,6 +22,7 @@
import android.graphics.Bitmap;
public class ImageFilterHue extends SimpleImageFilter {
+ private static final String SERIALIZATION_NAME = "HUE";
private ColorSpaceMatrix cmatrix = null;
public ImageFilterHue() {
@@ -33,11 +34,11 @@
FilterBasicRepresentation representation =
(FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("Hue");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterHue.class);
representation.setMinimum(-180);
representation.setMaximum(180);
representation.setTextId(R.string.hue);
- representation.setButtonId(R.id.hueButton);
representation.setEditorId(BasicEditor.ID);
representation.setSupportsPartialRendering(true);
return representation;
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java
index 29e6d16..77cdf47 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterKMeans.java
@@ -22,6 +22,7 @@
import com.android.gallery3d.R;
public class ImageFilterKMeans extends SimpleImageFilter {
+ private static final String SERIALIZATION_NAME = "KMEANS";
private int mSeed = 0;
public ImageFilterKMeans() {
@@ -36,6 +37,7 @@
public FilterRepresentation getDefaultRepresentation() {
FilterBasicRepresentation representation = (FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("KMeans");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterKMeans.class);
representation.setMaximum(20);
representation.setMinimum(2);
@@ -43,7 +45,6 @@
representation.setDefaultValue(4);
representation.setPreviewValue(4);
representation.setTextId(R.string.kmeans);
- representation.setButtonId(R.id.kmeansButton);
representation.setSupportsPartialRendering(true);
return representation;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
index c256686..9a1a840 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
@@ -6,20 +6,20 @@
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
public class ImageFilterNegative extends ImageFilter {
-
+ private static final String SERIALIZATION_NAME = "NEGATIVE";
public ImageFilterNegative() {
mName = "Negative";
}
public FilterRepresentation getDefaultRepresentation() {
FilterRepresentation representation = new FilterDirectRepresentation("Negative");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterNegative.class);
representation.setTextId(R.string.negative);
- representation.setButtonId(R.id.negativeButton);
- representation.setShowEditingControls(false);
representation.setShowParameterValue(false);
representation.setEditorId(ImageOnlyEditor.ID);
representation.setSupportsPartialRendering(true);
+ representation.setIsBooleanFilter(true);
return representation;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java
deleted file mode 100644
index 25e5d14..0000000
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterParametricBorder.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.filters;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.RectF;
-
-public class ImageFilterParametricBorder extends ImageFilter {
- private FilterColorBorderRepresentation mParameters = null;
-
- public ImageFilterParametricBorder() {
- mName = "Border";
- }
-
- public void useRepresentation(FilterRepresentation representation) {
- FilterColorBorderRepresentation parameters = (FilterColorBorderRepresentation) representation;
- mParameters = parameters;
- }
-
- public FilterColorBorderRepresentation getParameters() {
- return mParameters;
- }
-
- private void applyHelper(Canvas canvas, int w, int h) {
- if (getParameters() == null) {
- return;
- }
- Path border = new Path();
- border.moveTo(0, 0);
- float bs = getParameters().getBorderSize() / 100.0f * w;
- float r = getParameters().getBorderRadius() / 100.0f * w;
- border.lineTo(0, h);
- border.lineTo(w, h);
- border.lineTo(w, 0);
- border.lineTo(0, 0);
- border.addRoundRect(new RectF(bs, bs, w - bs, h - bs),
- r, r, Path.Direction.CW);
-
- Paint paint = new Paint();
- paint.setAntiAlias(true);
- paint.setColor(getParameters().getColor());
- canvas.drawPath(border, paint);
- }
-
- @Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
- Canvas canvas = new Canvas(bitmap);
- applyHelper(canvas, bitmap.getWidth(), bitmap.getHeight());
- return bitmap;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
index cfbb560..9a494d8 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
@@ -22,13 +22,14 @@
import android.util.Log;
import android.content.res.Resources;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.cache.CachingPipeline;
+import com.android.gallery3d.filtershow.pipeline.PipelineInterface;
public abstract class ImageFilterRS extends ImageFilter {
private static final String LOGTAG = "ImageFilterRS";
private boolean DEBUG = false;
private int mLastInputWidth = 0;
private int mLastInputHeight = 0;
+ private long mLastTimeCalled;
public static boolean PERF_LOGGING = false;
@@ -51,26 +52,36 @@
}
protected RenderScript getRenderScriptContext() {
- return CachingPipeline.getRenderScriptContext();
+ PipelineInterface pipeline = getEnvironment().getPipeline();
+ return pipeline.getRSContext();
}
protected Allocation getInPixelsAllocation() {
- CachingPipeline pipeline = getEnvironment().getCachingPipeline();
+ PipelineInterface pipeline = getEnvironment().getPipeline();
return pipeline.getInPixelsAllocation();
}
protected Allocation getOutPixelsAllocation() {
- CachingPipeline pipeline = getEnvironment().getCachingPipeline();
+ PipelineInterface pipeline = getEnvironment().getPipeline();
return pipeline.getOutPixelsAllocation();
}
@Override
public void apply(Allocation in, Allocation out) {
long startOverAll = System.nanoTime();
+ if (PERF_LOGGING) {
+ long delay = (startOverAll - mLastTimeCalled) / 1000;
+ String msg = String.format("%s; image size %dx%d; ", getName(),
+ in.getType().getX(), in.getType().getY());
+ msg += String.format("called after %.2f ms (%.2f FPS); ",
+ delay / 1000.f, 1000000.f / delay);
+ Log.i(LOGTAG, msg);
+ }
+ mLastTimeCalled = startOverAll;
long startFilter = 0;
long endFilter = 0;
if (!mResourcesLoaded) {
- CachingPipeline pipeline = getEnvironment().getCachingPipeline();
+ PipelineInterface pipeline = getEnvironment().getPipeline();
createFilter(pipeline.getResources(), getEnvironment().getScaleFactor(),
getEnvironment().getQuality(), in);
mResourcesLoaded = true;
@@ -102,7 +113,7 @@
return bitmap;
}
try {
- CachingPipeline pipeline = getEnvironment().getCachingPipeline();
+ PipelineInterface pipeline = getEnvironment().getPipeline();
if (DEBUG) {
Log.v(LOGTAG, "apply filter " + getName() + " in pipeline " + pipeline.getName());
}
@@ -137,18 +148,16 @@
displayLowMemoryToast();
Log.e(LOGTAG, "not enough memory for filter " + getName(), e);
}
-
return bitmap;
}
- protected static Allocation convertBitmap(Bitmap bitmap) {
- return Allocation.createFromBitmap(CachingPipeline.getRenderScriptContext(), bitmap,
+ protected static Allocation convertBitmap(RenderScript RS, Bitmap bitmap) {
+ return Allocation.createFromBitmap(RS, bitmap,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT | Allocation.USAGE_GRAPHICS_TEXTURE);
}
- private static Allocation convertRGBAtoA(Bitmap bitmap) {
- RenderScript RS = CachingPipeline.getRenderScriptContext();
+ private static Allocation convertRGBAtoA(RenderScript RS, Bitmap bitmap) {
if (RS != mRScache || mGreyConvert == null) {
mGreyConvert = new ScriptC_grey(RS, RS.getApplicationContext().getResources(),
R.raw.grey);
@@ -157,7 +166,7 @@
Type.Builder tb_a8 = new Type.Builder(RS, Element.A_8(RS));
- Allocation bitmapTemp = convertBitmap(bitmap);
+ Allocation bitmapTemp = convertBitmap(RS, bitmap);
if (bitmapTemp.getType().getElement().isCompatible(Element.A_8(RS))) {
return bitmapTemp;
}
@@ -173,28 +182,26 @@
}
public Allocation loadScaledResourceAlpha(int resource, int inSampleSize) {
- Resources res = CachingPipeline.getResources();
+ Resources res = getEnvironment().getPipeline().getResources();
final BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ALPHA_8;
options.inSampleSize = inSampleSize;
Bitmap bitmap = BitmapFactory.decodeResource(
res,
resource, options);
- Allocation ret = convertRGBAtoA(bitmap);
+ Allocation ret = convertRGBAtoA(getRenderScriptContext(), bitmap);
bitmap.recycle();
return ret;
}
public Allocation loadScaledResourceAlpha(int resource, int w, int h, int inSampleSize) {
- Resources res = CachingPipeline.getResources();
+ Resources res = getEnvironment().getPipeline().getResources();
final BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ALPHA_8;
options.inSampleSize = inSampleSize;
Bitmap bitmap = BitmapFactory.decodeResource(
res,
resource, options);
Bitmap resizeBitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
- Allocation ret = convertRGBAtoA(resizeBitmap);
+ Allocation ret = convertRGBAtoA(getRenderScriptContext(), resizeBitmap);
resizeBitmap.recycle();
bitmap.recycle();
return ret;
@@ -205,13 +212,13 @@
}
public Allocation loadResource(int resource) {
- Resources res = CachingPipeline.getResources();
+ Resources res = getEnvironment().getPipeline().getResources();
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeResource(
res,
resource, options);
- Allocation ret = convertBitmap(bitmap);
+ Allocation ret = convertBitmap(getRenderScriptContext(), bitmap);
bitmap.recycle();
return ret;
}
@@ -232,7 +239,7 @@
/**
* RS Script objects (and all other RS objects) should be cleared here
*/
- abstract protected void resetScripts();
+ public abstract void resetScripts();
/**
* Scripts values should be bound here
@@ -244,6 +251,8 @@
return;
}
resetAllocations();
+ mLastInputWidth = 0;
+ mLastInputHeight = 0;
setResourcesLoaded(false);
}
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java
index 0febe49..c3124ff 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSaturated.java
@@ -21,7 +21,7 @@
import android.graphics.Bitmap;
public class ImageFilterSaturated extends SimpleImageFilter {
-
+ private static final String SERIALIZATION_NAME = "SATURATED";
public ImageFilterSaturated() {
mName = "Saturated";
}
@@ -31,9 +31,9 @@
FilterBasicRepresentation representation =
(FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("Saturated");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterSaturated.class);
representation.setTextId(R.string.saturation);
- representation.setButtonId(R.id.saturationButton);
representation.setMinimum(-100);
representation.setMaximum(100);
representation.setDefaultValue(0);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
index fd67ee8..bd119bb 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
@@ -21,7 +21,7 @@
import android.graphics.Bitmap;
public class ImageFilterShadows extends SimpleImageFilter {
-
+ private static final String SERIALIZATION_NAME = "SHADOWS";
public ImageFilterShadows() {
mName = "Shadows";
@@ -31,9 +31,9 @@
FilterBasicRepresentation representation =
(FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("Shadows");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterShadows.class);
representation.setTextId(R.string.shadow_recovery);
- representation.setButtonId(R.id.shadowRecoveryButton);
representation.setMinimum(-100);
representation.setMaximum(100);
representation.setDefaultValue(0);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
index 76ae475..3bd7944 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
@@ -19,7 +19,7 @@
import com.android.gallery3d.R;
public class ImageFilterSharpen extends ImageFilterRS {
-
+ private static final String SERIALIZATION_NAME = "SHARPEN";
private static final String LOGTAG = "ImageFilterSharpen";
private ScriptC_convolve3x3 mScript;
@@ -31,10 +31,10 @@
public FilterRepresentation getDefaultRepresentation() {
FilterRepresentation representation = new FilterBasicRepresentation("Sharpen", 0, 0, 100);
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setShowParameterValue(true);
representation.setFilterClass(ImageFilterSharpen.class);
representation.setTextId(R.string.sharpness);
- representation.setButtonId(R.id.sharpenButton);
representation.setOverlayId(R.drawable.filtershow_button_colors_sharpen);
representation.setEditorId(R.id.imageShow);
representation.setSupportsPartialRendering(true);
@@ -52,7 +52,7 @@
}
@Override
- protected void resetScripts() {
+ public void resetScripts() {
if (mScript != null) {
mScript.destroy();
mScript = null;
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java
deleted file mode 100644
index a3bb6f9..0000000
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.filters;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Rect;
-
-public class ImageFilterStraighten extends ImageFilter {
- private final Bitmap.Config mConfig = Bitmap.Config.ARGB_8888;
- private float mRotation;
- private float mZoomFactor;
-
- public ImageFilterStraighten() {
- mName = "Straighten";
- }
-
- @Override
- public ImageFilter clone() throws CloneNotSupportedException {
- // FIXME: clone() should not be needed. Remove when we fix geometry.
- ImageFilterStraighten filter = (ImageFilterStraighten) super.clone();
- filter.mRotation = mRotation;
- filter.mZoomFactor = mZoomFactor;
- return filter;
- }
-
- public ImageFilterStraighten(float rotation, float zoomFactor) {
- mRotation = rotation;
- mZoomFactor = zoomFactor;
- }
-
- public void setRotation(float rotation) {
- mRotation = rotation;
- }
-
- public void setRotationZoomFactor(float zoomFactor) {
- mZoomFactor = zoomFactor;
- }
-
- @Override
- public void useRepresentation(FilterRepresentation representation) {
-
- }
-
- @Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
- // TODO: implement bilinear or bicubic here... for now, just use
- // canvas to do a simple implementation...
- // TODO: and be more memory efficient! (do it in native?)
-
- Bitmap temp = bitmap.copy(mConfig, true);
- Canvas canvas = new Canvas(temp);
- canvas.save();
- Rect bounds = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
- float w = temp.getWidth();
- float h = temp.getHeight();
- float mw = temp.getWidth() / 2.0f;
- float mh = temp.getHeight() / 2.0f;
-
- canvas.scale(mZoomFactor, mZoomFactor, mw, mh);
- canvas.rotate(mRotation, mw, mh);
- canvas.drawBitmap(bitmap, bounds, bounds, new Paint());
- canvas.restore();
-
- int[] pixels = new int[(int) (w * h)];
- temp.getPixels(pixels, 0, (int) w, 0, 0, (int) w, (int) h);
- bitmap.setPixels(pixels, 0, (int) w, 0, 0, (int) w, (int) h);
- temp.recycle();
- temp = null;
- pixels = null;
- return bitmap;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
index 37d5739..6cc4970 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
@@ -18,14 +18,15 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Rect;
import android.graphics.RectF;
import com.adobe.xmp.XMPException;
import com.adobe.xmp.XMPMeta;
import com.android.gallery3d.app.Log;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
/**
* An image filter which creates a tiny planet projection.
@@ -76,10 +77,10 @@
int w = bitmapIn.getWidth();
int h = bitmapIn.getHeight();
int outputSize = (int) (w / 2f);
- ImagePreset preset = getImagePreset();
+ ImagePreset preset = getEnvironment().getImagePreset();
Bitmap mBitmapOut = null;
if (preset != null) {
- XMPMeta xmp = preset.getImageLoader().getXmpObject();
+ XMPMeta xmp = ImageLoader.getXmpObject(MasterImage.getImage().getActivity());
// Do nothing, just use bitmapIn as is if we don't have XMP.
if(xmp != null) {
bitmapIn = applyXmp(bitmapIn, xmp, w);
@@ -92,7 +93,8 @@
}
while (mBitmapOut == null) {
try {
- mBitmapOut = getEnvironment().getBitmap(outputSize, outputSize);
+ mBitmapOut = getEnvironment().getBitmap(outputSize,
+ outputSize, BitmapCache.TINY_PLANET);
} catch (java.lang.OutOfMemoryError e) {
System.gc();
outputSize /= 2;
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java
index ea315d3..86be9a1 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVibrance.java
@@ -21,7 +21,7 @@
import android.graphics.Bitmap;
public class ImageFilterVibrance extends SimpleImageFilter {
-
+ private static final String SERIALIZATION_NAME = "VIBRANCE";
public ImageFilterVibrance() {
mName = "Vibrance";
}
@@ -30,9 +30,9 @@
FilterBasicRepresentation representation =
(FilterBasicRepresentation) super.getDefaultRepresentation();
representation.setName("Vibrance");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterVibrance.class);
representation.setTextId(R.string.vibrance);
- representation.setButtonId(R.id.vibranceButton);
representation.setMinimum(-100);
representation.setMaximum(100);
representation.setDefaultValue(0);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
index e06f544..49ac595 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
@@ -22,11 +22,25 @@
import android.graphics.Matrix;
import android.graphics.Rect;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
+import android.support.v8.renderscript.Allocation;
+import android.support.v8.renderscript.Element;
+import android.support.v8.renderscript.RenderScript;
+import android.support.v8.renderscript.Script.LaunchOptions;
+import android.support.v8.renderscript.Type;
+import android.util.Log;
-public class ImageFilterVignette extends SimpleImageFilter {
+public class ImageFilterVignette extends ImageFilterRS {
private static final String LOGTAG = "ImageFilterVignette";
private Bitmap mOverlayBitmap;
+ private ScriptC_vignette mScript;
+ FilterVignetteRepresentation mParameters;
+ public static final int MODE_VIGNETTE = FilterVignetteRepresentation.MODE_VIGNETTE;
+ public static final int MODE_EXPOSURE = FilterVignetteRepresentation.MODE_EXPOSURE;
+ public static final int MODE_SATURATION = FilterVignetteRepresentation.MODE_SATURATION;
+ public static final int MODE_CONTRAST = FilterVignetteRepresentation.MODE_CONTRAST;
+ public static final int MODE_FALLOFF = FilterVignetteRepresentation.MODE_FALLOFF;
public ImageFilterVignette() {
mName = "Vignette";
@@ -38,8 +52,14 @@
return representation;
}
+ @Override
+ public void useRepresentation(FilterRepresentation representation) {
+ mParameters = (FilterVignetteRepresentation) representation;
+ }
+
native protected void nativeApplyFilter(
- Bitmap bitmap, int w, int h, int cx, int cy, float radx, float rady, float strength);
+ Bitmap bitmap, int w, int h, int cx, int cy, float radx, float rady,
+ float strength, float finalValue);
private float calcRadius(float cx, float cy, int w, int h) {
float d = cx;
@@ -56,43 +76,91 @@
}
@Override
+ protected void createFilter(Resources res, float scaleFactor, int quality) {
+ RenderScript rsCtx = getRenderScriptContext();
+
+ mScript = new ScriptC_vignette(rsCtx, res, R.raw.vignette);
+ }
+
+ @Override
+ protected void runFilter() {
+
+ int w = getInPixelsAllocation().getType().getX();
+ int h = getInPixelsAllocation().getType().getY();
+
+ float cx = w / 2;
+ float cy = h / 2;
+ float r = calcRadius(cx, cy, w, h);
+ float rx = r;
+ float ry = r;
+
+ float[]c = new float[2];
+ if (mParameters.isCenterSet()) {
+ Matrix m = getOriginalToScreenMatrix(w, h);
+ Rect bounds = MasterImage.getImage().getOriginalBounds();
+ c[0] = bounds.right * mParameters.getCenterX();
+ c[1] = bounds.bottom * mParameters.getCenterY();
+ m.mapPoints(c);
+ cx = c[0];
+ cy = c[1];
+ c[0] = bounds.right * mParameters.getRadiusX();
+ c[1] = bounds.bottom * mParameters.getRadiusY();
+ m.mapVectors(c);
+ rx = c[0];
+ ry = c[1];
+ }
+
+ mScript.set_inputWidth(w);
+ mScript.set_inputHeight(h);
+ int v = mParameters.getValue(MODE_VIGNETTE);
+ mScript.set_finalSubtract((v < 0) ? v : 0);
+ mScript.set_finalBright((v > 0) ? -v : 0);
+ mScript.set_finalSaturation(mParameters.getValue(MODE_SATURATION));
+ mScript.set_finalContrast(mParameters.getValue(MODE_CONTRAST));
+ mScript.set_centerx(cx);
+ mScript.set_centery(cy);
+ mScript.set_radiusx(rx);
+ mScript.set_radiusy(ry);
+ mScript.set_strength(mParameters.getValue(MODE_FALLOFF)/10.f);
+ mScript.invoke_setupVignetteParams();
+ mScript.forEach_vignette(getInPixelsAllocation(), getOutPixelsAllocation());
+ }
+
+ @Override
public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
- if (SIMPLE_ICONS && ImagePreset.QUALITY_ICON == quality) {
+ if (SIMPLE_ICONS && FilterEnvironment.QUALITY_ICON == quality) {
if (mOverlayBitmap == null) {
- Resources res = getEnvironment().getCachingPipeline().getResources();
+ Resources res = getEnvironment().getPipeline().getResources();
mOverlayBitmap = IconUtilities.getFXBitmap(res,
R.drawable.filtershow_icon_vignette);
}
+
Canvas c = new Canvas(bitmap);
int dim = Math.max(bitmap.getWidth(), bitmap.getHeight());
Rect r = new Rect(0, 0, dim, dim);
c.drawBitmap(mOverlayBitmap, null, r, null);
return bitmap;
}
- FilterVignetteRepresentation rep = (FilterVignetteRepresentation) getParameters();
- if (rep == null) {
- return bitmap;
- }
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- float value = rep.getValue() / 100.0f;
- float cx = w / 2;
- float cy = h / 2;
- float r = calcRadius(cx, cy, w, h);
- float rx = r;
- float ry = r;
- if (rep.isCenterSet()) {
- Matrix m = getOriginalToScreenMatrix(w, h);
- cx = rep.getCenterX();
- cy = rep.getCenterY();
- float[] center = new float[] { cx, cy };
- m.mapPoints(center);
- cx = center[0];
- cy = center[1];
- rx = m.mapRadius(rep.getRadiusX());
- ry = m.mapRadius(rep.getRadiusY());
- }
- nativeApplyFilter(bitmap, w, h, (int) cx, (int) cy, rx, ry, value);
+ Bitmap ret = super.apply(bitmap, scaleFactor, quality);
return bitmap;
}
+
+
+ @Override
+ protected void resetAllocations() {
+
+ }
+
+ @Override
+ public void resetScripts() {
+
+ }
+
+ @Override
+ protected void bindScriptValues() {
+ int width = getInPixelsAllocation().getType().getX();
+ int height = getInPixelsAllocation().getType().getY();
+ mScript.set_inputWidth(width);
+ mScript.set_inputHeight(height);
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
index c4c293a..7aa19a4 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
@@ -22,6 +22,7 @@
import android.graphics.Bitmap;
public class ImageFilterWBalance extends ImageFilter {
+ private static final String SERIALIZATION_NAME = "WBALANCE";
private static final String TAG = "ImageFilterWBalance";
public ImageFilterWBalance() {
@@ -30,14 +31,14 @@
public FilterRepresentation getDefaultRepresentation() {
FilterRepresentation representation = new FilterDirectRepresentation("WBalance");
+ representation.setSerializationName(SERIALIZATION_NAME);
representation.setFilterClass(ImageFilterWBalance.class);
- representation.setPriority(FilterRepresentation.TYPE_WBALANCE);
+ representation.setFilterType(FilterRepresentation.TYPE_WBALANCE);
representation.setTextId(R.string.wbalance);
- representation.setButtonId(R.id.wbalanceButton);
- representation.setShowEditingControls(false);
representation.setShowParameterValue(false);
representation.setEditorId(ImageOnlyEditor.ID);
representation.setSupportsPartialRendering(true);
+ representation.setIsBooleanFilter(true);
return representation;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ParametericFilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/ParametericFilterRepresentation.java
new file mode 100644
index 0000000..9c50257
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ParametericFilterRepresentation.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * Class to simplify creating representations that use Parametric controllers
+ */
+public class ParametericFilterRepresentation extends FilterRepresentation {
+ public ParametericFilterRepresentation(String name) {
+ super(name);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/grad.rs b/src/com/android/gallery3d/filtershow/filters/grad.rs
new file mode 100644
index 0000000..ddbafd3
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/grad.rs
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2012 Unknown
+ *
+ * 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.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.android.gallery3d.filtershow.filters)
+
+#define MAX_POINTS 16
+
+uint32_t inputWidth;
+uint32_t inputHeight;
+static const float Rf = 0.2999f;
+static const float Gf = 0.587f;
+static const float Bf = 0.114f;
+//static const float size_scale = 0.01f;
+
+typedef struct {
+ rs_matrix3x3 colorMatrix;
+ float rgbOff;
+ float dx;
+ float dy;
+ float off;
+} UPointData;
+int mNumberOfLines;
+// input data
+bool mask[MAX_POINTS];
+int xPos1[MAX_POINTS];
+int yPos1[MAX_POINTS];
+int xPos2[MAX_POINTS];
+int yPos2[MAX_POINTS];
+int size[MAX_POINTS];
+int brightness[MAX_POINTS];
+int contrast[MAX_POINTS];
+int saturation[MAX_POINTS];
+
+// generated data
+static UPointData grads[MAX_POINTS];
+
+void setupGradParams() {
+ int k = 0;
+ for (int i = 0; i < MAX_POINTS; i++) {
+ if (!mask[i]) {
+ continue;
+ }
+ float x1 = xPos1[i];
+ float y1 = yPos1[i];
+ float x2 = xPos2[i];
+ float y2 = yPos2[i];
+
+ float denom = (y2 * y2 - 2 * y1 * y2 + x2 * x2 - 2 * x1 * x2 + y1 * y1 + x1 * x1);
+ if (denom == 0) {
+ continue;
+ }
+ grads[k].dy = (y1 - y2) / denom;
+ grads[k].dx = (x1 - x2) / denom;
+ grads[k].off = (y2 * y2 + x2 * x2 - x1 * x2 - y1 * y2) / denom;
+
+ float S = 1+saturation[i]/100.f;
+ float MS = 1-S;
+ float Rt = Rf * MS;
+ float Gt = Gf * MS;
+ float Bt = Bf * MS;
+
+ float b = 1+brightness[i]/100.f;
+ float c = 1+contrast[i]/100.f;
+ b *= c;
+ grads[k].rgbOff = .5f - c/2.f;
+ rsMatrixSet(&grads[i].colorMatrix, 0, 0, b * (Rt + S));
+ rsMatrixSet(&grads[i].colorMatrix, 1, 0, b * Gt);
+ rsMatrixSet(&grads[i].colorMatrix, 2, 0, b * Bt);
+ rsMatrixSet(&grads[i].colorMatrix, 0, 1, b * Rt);
+ rsMatrixSet(&grads[i].colorMatrix, 1, 1, b * (Gt + S));
+ rsMatrixSet(&grads[i].colorMatrix, 2, 1, b * Bt);
+ rsMatrixSet(&grads[i].colorMatrix, 0, 2, b * Rt);
+ rsMatrixSet(&grads[i].colorMatrix, 1, 2, b * Gt);
+ rsMatrixSet(&grads[i].colorMatrix, 2, 2, b * (Bt + S));
+
+ k++;
+ }
+ mNumberOfLines = k;
+}
+
+void init() {
+
+}
+
+uchar4 __attribute__((kernel)) selectiveAdjust(const uchar4 in, uint32_t x,
+ uint32_t y) {
+ float4 pixel = rsUnpackColor8888(in);
+
+ float4 wsum = pixel;
+ wsum.a = 0.f;
+ for (int i = 0; i < mNumberOfLines; i++) {
+ UPointData* grad = &grads[i];
+ float t = clamp(x*grad->dx+y*grad->dy+grad->off,0.f,1.0f);
+ wsum.xyz = wsum.xyz*(1-t)+
+ t*(rsMatrixMultiply(&grad->colorMatrix ,wsum.xyz)+grad->rgbOff);
+
+ }
+
+ pixel.rgb = wsum.rgb;
+ pixel.a = 1.0f;
+
+ uchar4 out = rsPackColorTo8888(clamp(pixel, 0.f, 1.0f));
+ return out;
+}
+
+
+
diff --git a/src/com/android/gallery3d/filtershow/filters/saturation.rs b/src/com/android/gallery3d/filtershow/filters/saturation.rs
new file mode 100644
index 0000000..5210e34
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/saturation.rs
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2012 Unknown
+ *
+ * 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.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.android.gallery3d.filtershow.filters)
+
+#define MAX_CHANELS 7
+#define MAX_HUE 4096
+static const int ABITS = 4;
+static const int HSCALE = 256;
+static const int k1=255 << ABITS;
+static const int k2=HSCALE << ABITS;
+
+static const float Rf = 0.2999f;
+static const float Gf = 0.587f;
+static const float Bf = 0.114f;
+
+rs_matrix3x3 colorMatrix_min;
+rs_matrix3x3 colorMatrix_max;
+
+int mNumberOfLines;
+// input data
+int saturation[MAX_CHANELS];
+float sat[MAX_CHANELS];
+
+float satLut[MAX_HUE];
+// generated data
+
+
+void setupGradParams() {
+
+ int master = saturation[0];
+ int max = master+saturation[1];
+ int min = max;
+
+ // calculate the minimum and maximum saturation
+ for (int i = 1; i < MAX_CHANELS; i++) {
+ int v = master+saturation[i];
+ if (max < v) {
+ max = v;
+ }
+ else if (min > v) {
+ min = v;
+ }
+ }
+ // generate a lookup table for all hue 0 to 4K which goes from 0 to 1 0=min sat 1 = max sat
+ min = min - 1;
+ for(int i = 0; i < MAX_HUE ; i++) {
+ float p = i * 6 / (float)MAX_HUE;
+ int ip = ((int)(p + .5f)) % 6;
+ int v = master + saturation[ip + 1];
+ satLut[i] = (v - min)/(float)(max - min);
+ }
+
+ float S = 1 + max / 100.f;
+ float MS = 1 - S;
+ float Rt = Rf * MS;
+ float Gt = Gf * MS;
+ float Bt = Bf * MS;
+ float b = 1.f;
+
+ // Generate 2 color matrix one at min sat and one at max
+ rsMatrixSet(&colorMatrix_max, 0, 0, b * (Rt + S));
+ rsMatrixSet(&colorMatrix_max, 1, 0, b * Gt);
+ rsMatrixSet(&colorMatrix_max, 2, 0, b * Bt);
+ rsMatrixSet(&colorMatrix_max, 0, 1, b * Rt);
+ rsMatrixSet(&colorMatrix_max, 1, 1, b * (Gt + S));
+ rsMatrixSet(&colorMatrix_max, 2, 1, b * Bt);
+ rsMatrixSet(&colorMatrix_max, 0, 2, b * Rt);
+ rsMatrixSet(&colorMatrix_max, 1, 2, b * Gt);
+ rsMatrixSet(&colorMatrix_max, 2, 2, b * (Bt + S));
+
+ S = 1 + min / 100.f;
+ MS = 1-S;
+ Rt = Rf * MS;
+ Gt = Gf * MS;
+ Bt = Bf * MS;
+ b = 1;
+
+ rsMatrixSet(&colorMatrix_min, 0, 0, b * (Rt + S));
+ rsMatrixSet(&colorMatrix_min, 1, 0, b * Gt);
+ rsMatrixSet(&colorMatrix_min, 2, 0, b * Bt);
+ rsMatrixSet(&colorMatrix_min, 0, 1, b * Rt);
+ rsMatrixSet(&colorMatrix_min, 1, 1, b * (Gt + S));
+ rsMatrixSet(&colorMatrix_min, 2, 1, b * Bt);
+ rsMatrixSet(&colorMatrix_min, 0, 2, b * Rt);
+ rsMatrixSet(&colorMatrix_min, 1, 2, b * Gt);
+ rsMatrixSet(&colorMatrix_min, 2, 2, b * (Bt + S));
+}
+
+static ushort rgb2hue( uchar4 rgb)
+{
+ int iMin,iMax,chroma;
+
+ int ri = rgb.r;
+ int gi = rgb.g;
+ int bi = rgb.b;
+ short rv,rs,rh;
+
+ if (ri > gi) {
+ iMax = max (ri, bi);
+ iMin = min (gi, bi);
+ } else {
+ iMax = max (gi, bi);
+ iMin = min (ri, bi);
+ }
+
+ rv = (short) (iMax << ABITS);
+
+ if (rv == 0) {
+ return 0;
+ }
+
+ chroma = iMax - iMin;
+ rs = (short) ((k1 * chroma) / iMax);
+ if (rs == 0) {
+ return 0;
+ }
+
+ if ( ri == iMax ) {
+ rh = (short) ((k2 * (6 * chroma + gi - bi))/(6 * chroma));
+ if (rh >= k2) {
+ rh -= k2;
+ }
+ return rh;
+ }
+
+ if (gi == iMax) {
+ return(short) ((k2 * (2 * chroma + bi - ri)) / (6 * chroma));
+ }
+
+ return (short) ((k2 * (4 * chroma + ri - gi)) / (6 * chroma));
+}
+
+uchar4 __attribute__((kernel)) selectiveAdjust(const uchar4 in, uint32_t x,
+ uint32_t y) {
+ float4 pixel = rsUnpackColor8888(in);
+
+ float4 wsum = pixel;
+ int hue = rgb2hue(in);
+
+ float t = satLut[hue];
+ pixel.xyz = rsMatrixMultiply(&colorMatrix_min ,pixel.xyz) * (1 - t) +
+ t * (rsMatrixMultiply(&colorMatrix_max ,pixel.xyz));
+
+ pixel.a = 1.0f;
+ return rsPackColorTo8888(clamp(pixel, 0.f, 1.0f));
+}
\ No newline at end of file
diff --git a/src/com/android/gallery3d/filtershow/filters/vignette.rs b/src/com/android/gallery3d/filtershow/filters/vignette.rs
new file mode 100644
index 0000000..709b220
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/vignette.rs
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2013 Unknown
+ *
+ * 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.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.android.gallery3d.filtershow.filters)
+
+uint32_t inputWidth;
+uint32_t inputHeight;
+float centerx;
+float centery;
+float radiusx;
+float radiusy;
+float strength;
+float finalBright;
+float finalSaturation;
+float finalContrast;
+float finalSubtract;
+rs_matrix3x3 colorMatrix;
+float scalex;
+float scaley;
+float offset;
+static const float Rf = 0.2999f;
+static const float Gf = 0.587f;
+static const float Bf = 0.114f;
+
+
+void setupVignetteParams() {
+ int k = 0;
+
+ scalex = 1.f / radiusx;
+ scaley = 1.f / radiusy;
+
+ float S = 1 + finalSaturation / 100.f;
+ float MS = 1 - S;
+ float Rt = Rf * MS;
+ float Gt = Gf * MS;
+ float Bt = Bf * MS;
+
+ float b = 1 + finalBright / 100.f;
+ float c = 1 + finalContrast / 100.f;
+ b *= c;
+ offset = .5f - c / 2.f - finalSubtract / 100.f;
+ rsMatrixSet(&colorMatrix, 0, 0, b * (Rt + S));
+ rsMatrixSet(&colorMatrix, 1, 0, b * Gt);
+ rsMatrixSet(&colorMatrix, 2, 0, b * Bt);
+ rsMatrixSet(&colorMatrix, 0, 1, b * Rt);
+ rsMatrixSet(&colorMatrix, 1, 1, b * (Gt + S));
+ rsMatrixSet(&colorMatrix, 2, 1, b * Bt);
+ rsMatrixSet(&colorMatrix, 0, 2, b * Rt);
+ rsMatrixSet(&colorMatrix, 1, 2, b * Gt);
+ rsMatrixSet(&colorMatrix, 2, 2, b * (Bt + S));
+}
+
+uchar4 __attribute__((kernel)) vignette(const uchar4 in, uint32_t x, uint32_t y) {
+ float4 pixel = rsUnpackColor8888(in);
+ float radx = (x - centerx) * scalex;
+ float rady = (y - centery) * scaley;
+ float dist = strength * (sqrt(radx * radx + rady * rady) - 1.f);
+ float t = (1.f + dist / sqrt(1.f + dist* dist)) * .5f;
+ float4 wsum = pixel;
+ wsum.xyz = wsum.xyz * (1 - t) + t * (rsMatrixMultiply(&colorMatrix, wsum.xyz) + offset);
+ wsum.a = 1.0f;
+ uchar4 out = rsPackColorTo8888(clamp(wsum, 0.f, 1.0f));
+ return out;
+}
\ No newline at end of file
diff --git a/src/com/android/gallery3d/filtershow/history/HistoryItem.java b/src/com/android/gallery3d/filtershow/history/HistoryItem.java
new file mode 100644
index 0000000..80da330
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/history/HistoryItem.java
@@ -0,0 +1,53 @@
+/*
+ * 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.history;
+
+import android.graphics.Bitmap;
+import android.util.Log;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+public class HistoryItem {
+ private static final String LOGTAG = "HistoryItem";
+ private ImagePreset mImagePreset;
+ private FilterRepresentation mFilterRepresentation;
+ private Bitmap mPreviewImage;
+
+ public HistoryItem(ImagePreset preset, FilterRepresentation representation) {
+ mImagePreset = preset; // just keep a pointer to the current preset
+ if (representation != null) {
+ mFilterRepresentation = representation.copy();
+ }
+ }
+
+ public ImagePreset getImagePreset() {
+ return mImagePreset;
+ }
+
+ public FilterRepresentation getFilterRepresentation() {
+ return mFilterRepresentation;
+ }
+
+ public Bitmap getPreviewImage() {
+ return mPreviewImage;
+ }
+
+ public void setPreviewImage(Bitmap previewImage) {
+ mPreviewImage = previewImage;
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/history/HistoryManager.java b/src/com/android/gallery3d/filtershow/history/HistoryManager.java
new file mode 100644
index 0000000..569b299
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/history/HistoryManager.java
@@ -0,0 +1,173 @@
+/*
+ * 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.history;
+
+import android.graphics.drawable.Drawable;
+import android.view.MenuItem;
+
+import java.util.Vector;
+
+public class HistoryManager {
+ private static final String LOGTAG = "HistoryManager";
+
+ private Vector<HistoryItem> mHistoryItems = new Vector<HistoryItem>();
+ private int mCurrentPresetPosition = 0;
+ private MenuItem mUndoMenuItem = null;
+ private MenuItem mRedoMenuItem = null;
+ private MenuItem mResetMenuItem = null;
+
+ public void setMenuItems(MenuItem undoItem, MenuItem redoItem, MenuItem resetItem) {
+ mUndoMenuItem = undoItem;
+ mRedoMenuItem = redoItem;
+ mResetMenuItem = resetItem;
+ updateMenuItems();
+ }
+
+ private int getCount() {
+ return mHistoryItems.size();
+ }
+
+ public HistoryItem getItem(int position) {
+ if (position > mHistoryItems.size() - 1) {
+ return null;
+ }
+ return mHistoryItems.elementAt(position);
+ }
+
+ private void clear() {
+ mHistoryItems.clear();
+ }
+
+ private void add(HistoryItem item) {
+ mHistoryItems.add(item);
+ }
+
+ private void notifyDataSetChanged() {
+ // TODO
+ }
+
+ public boolean canReset() {
+ if (getCount() <= 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean canUndo() {
+ if (mCurrentPresetPosition == getCount() - 1) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean canRedo() {
+ if (mCurrentPresetPosition == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public void updateMenuItems() {
+ if (mUndoMenuItem != null) {
+ setEnabled(mUndoMenuItem, canUndo());
+ }
+ if (mRedoMenuItem != null) {
+ setEnabled(mRedoMenuItem, canRedo());
+ }
+ if (mResetMenuItem != null) {
+ setEnabled(mResetMenuItem, canReset());
+ }
+ }
+
+ private void setEnabled(MenuItem item, boolean enabled) {
+ item.setEnabled(enabled);
+ Drawable drawable = item.getIcon();
+ if (drawable != null) {
+ drawable.setAlpha(enabled ? 255 : 80);
+ }
+ }
+
+ public void setCurrentPreset(int n) {
+ mCurrentPresetPosition = n;
+ updateMenuItems();
+ notifyDataSetChanged();
+ }
+
+ public void reset() {
+ if (getCount() == 0) {
+ return;
+ }
+ clear();
+ updateMenuItems();
+ }
+
+ public HistoryItem getLast() {
+ if (getCount() == 0) {
+ return null;
+ }
+ return getItem(0);
+ }
+
+ public HistoryItem getCurrent() {
+ return getItem(mCurrentPresetPosition);
+ }
+
+ public void addHistoryItem(HistoryItem preset) {
+ insert(preset, 0);
+ updateMenuItems();
+ }
+
+ private void insert(HistoryItem preset, int position) {
+ if (mCurrentPresetPosition != 0) {
+ // in this case, let's discount the presets before the current one
+ Vector<HistoryItem> oldItems = new Vector<HistoryItem>();
+ for (int i = mCurrentPresetPosition; i < getCount(); i++) {
+ oldItems.add(getItem(i));
+ }
+ clear();
+ for (int i = 0; i < oldItems.size(); i++) {
+ add(oldItems.elementAt(i));
+ }
+ mCurrentPresetPosition = position;
+ notifyDataSetChanged();
+ }
+ mHistoryItems.insertElementAt(preset, position);
+ mCurrentPresetPosition = position;
+ notifyDataSetChanged();
+ }
+
+ public int redo() {
+ mCurrentPresetPosition--;
+ if (mCurrentPresetPosition < 0) {
+ mCurrentPresetPosition = 0;
+ }
+ notifyDataSetChanged();
+ updateMenuItems();
+ return mCurrentPresetPosition;
+ }
+
+ public int undo() {
+ mCurrentPresetPosition++;
+ if (mCurrentPresetPosition >= getCount()) {
+ mCurrentPresetPosition = getCount() - 1;
+ }
+ notifyDataSetChanged();
+ updateMenuItems();
+ return mCurrentPresetPosition;
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ControlPoint.java b/src/com/android/gallery3d/filtershow/imageshow/ControlPoint.java
new file mode 100644
index 0000000..aaec728
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/ControlPoint.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+public class ControlPoint implements Comparable {
+ public float x;
+ public float y;
+
+ public ControlPoint(float px, float py) {
+ x = px;
+ y = py;
+ }
+
+ public ControlPoint(ControlPoint point) {
+ x = point.x;
+ y = point.y;
+ }
+
+ public boolean sameValues(ControlPoint other) {
+ if (this == other) {
+ return true;
+ }
+ if (other == null) {
+ return false;
+ }
+
+ if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x)) {
+ return false;
+ }
+ if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y)) {
+ return false;
+ }
+ return true;
+ }
+
+ public ControlPoint copy() {
+ return new ControlPoint(x, y);
+ }
+
+ @Override
+ public int compareTo(Object another) {
+ ControlPoint p = (ControlPoint) another;
+ if (p.x < x) {
+ return 1;
+ } else if (p.x > x) {
+ return -1;
+ }
+ return 0;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/EclipseControl.java b/src/com/android/gallery3d/filtershow/imageshow/EclipseControl.java
index 8ceb375..b94e52e 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/EclipseControl.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/EclipseControl.java
@@ -22,8 +22,10 @@
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.RadialGradient;
+import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
+import android.util.Log;
import com.android.gallery3d.R;
@@ -33,7 +35,7 @@
private float mRadiusX = 200;
private float mRadiusY = 300;
private static int MIN_TOUCH_DIST = 80;// should be a resource & in dips
-
+ private static String LOGTAG = "EclipseControl";
private float[] handlex = new float[9];
private float[] handley = new float[9];
private int mSliderColor;
@@ -56,6 +58,7 @@
public final static int HAN_SW = 4;
public final static int HAN_WEST = 5;
public final static int HAN_NW = 6;
+ private Rect mImageBounds;
public EclipseControl(Context context) {
mSliderColor = Color.WHITE;
@@ -96,13 +99,18 @@
return -1;
}
- public void setScrToImageMatrix(Matrix scrToImg) {
+ public void setScrImageInfo(Matrix scrToImg, Rect imageBounds) {
mScrToImg = scrToImg;
+ mImageBounds = new Rect(imageBounds);
}
- public void actionDown(float x, float y, Oval oval) {
- float[] point = new float[] {
- x, y };
+ private boolean centerIsOutside(float x1, float y1) {
+ return (!mImageBounds.contains((int) x1, (int) y1));
+ }
+
+ public void actionDown(float x, float y, Oval oval) {
+ float[] point = new float[]{
+ x, y};
mScrToImg.mapPoints(point);
mDownX = point[0];
mDownY = point[1];
@@ -112,9 +120,10 @@
mDownRadiusY = oval.getRadiusY();
}
+
public void actionMove(int handle, float x, float y, Oval oval) {
- float[] point = new float[] {
- x, y };
+ float[] point = new float[]{
+ x, y};
mScrToImg.mapPoints(point);
x = point[0];
y = point[1];
@@ -130,7 +139,10 @@
case HAN_CENTER:
float ctrdx = mDownX - mDownCenterX;
float ctrdy = mDownY - mDownCenterY;
- oval.setCenter(x - ctrdx, y - ctrdy);
+ if (centerIsOutside(x - ctrdx, y - ctrdy)) {
+ break;
+ }
+ oval.setCenter((x - ctrdx), (y - ctrdy));
// setRepresentation(mVignetteRep);
break;
case HAN_NORTH:
@@ -152,7 +164,7 @@
oval.setRadiusX(Math.abs(y - oval.getCenterX() + sign * raddy));
} else {
float raddx = mDownRadiusX - Math.abs(mDownX - mDownCenterX);
- oval.setRadiusX(Math.abs(x - oval.getCenterX() - sign * raddx));
+ oval.setRadiusX(Math.abs(x - oval.getCenterX() - sign * raddx));
}
break;
case HAN_SE:
@@ -170,7 +182,7 @@
float dx = x - oval.getCenterX();
float dy = y - oval.getCenterY();
float nr = Math.abs(Math.abs(dx) + Math.abs(dy) - downRad);
- oval.setRadius(rx * nr / r, ry * nr / r);
+ oval.setRadius((rx * nr / r), (ry * nr / r));
break;
}
@@ -185,10 +197,10 @@
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.BLUE);
- int[] colors3 = new int[] {
- Color.GRAY, Color.LTGRAY, 0x66000000, 0 };
- RadialGradient g = new RadialGradient(x, y, mCenterDotSize, colors3, new float[] {
- 0, .3f, .31f, 1 }, Shader.TileMode.CLAMP);
+ int[] colors3 = new int[]{
+ Color.GRAY, Color.LTGRAY, 0x66000000, 0};
+ RadialGradient g = new RadialGradient(x, y, mCenterDotSize, colors3, new float[]{
+ 0, .3f, .31f, 1}, Shader.TileMode.CLAMP);
paint.setShader(g);
canvas.drawCircle(x, y, mCenterDotSize, paint);
}
@@ -202,10 +214,10 @@
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.BLUE);
- int[] colors3 = new int[] {
- mSliderColor, mSliderColor, 0x66000000, 0 };
- RadialGradient g = new RadialGradient(x, y, mCenterDotSize, colors3, new float[] {
- 0, .3f, .31f, 1 }, Shader.TileMode.CLAMP);
+ int[] colors3 = new int[]{
+ mSliderColor, mSliderColor, 0x66000000, 0};
+ RadialGradient g = new RadialGradient(x, y, mCenterDotSize, colors3, new float[]{
+ 0, .3f, .31f, 1}, Shader.TileMode.CLAMP);
paint.setShader(g);
canvas.drawCircle(x, y, mCenterDotSize, paint);
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryListener.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryListener.java
deleted file mode 100644
index 549c2e7..0000000
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryListener.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.imageshow;
-
-public interface GeometryListener {
- public void geometryChanged();
-}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java
deleted file mode 100644
index 568dadf..0000000
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.imageshow;
-
-import android.graphics.Rect;
-import android.graphics.RectF;
-
-public class GeometryMath {
-
- // Math operations for 2d vectors
- public static float clamp(float i, float low, float high) {
- return Math.max(Math.min(i, high), low);
- }
-
- public static float[] lineIntersect(float[] line1, float[] line2) {
- float a0 = line1[0];
- float a1 = line1[1];
- float b0 = line1[2];
- float b1 = line1[3];
- float c0 = line2[0];
- float c1 = line2[1];
- float d0 = line2[2];
- float d1 = line2[3];
- float t0 = a0 - b0;
- float t1 = a1 - b1;
- float t2 = b0 - d0;
- float t3 = d1 - b1;
- float t4 = c0 - d0;
- float t5 = c1 - d1;
-
- float denom = t1 * t4 - t0 * t5;
- if (denom == 0)
- return null;
- float u = (t3 * t4 + t5 * t2) / denom;
- float[] intersect = {
- b0 + u * t0, b1 + u * t1
- };
- return intersect;
- }
-
- public static float[] shortestVectorFromPointToLine(float[] point, float[] line) {
- float x1 = line[0];
- float x2 = line[2];
- float y1 = line[1];
- float y2 = line[3];
- float xdelt = x2 - x1;
- float ydelt = y2 - y1;
- if (xdelt == 0 && ydelt == 0)
- return null;
- float u = ((point[0] - x1) * xdelt + (point[1] - y1) * ydelt)
- / (xdelt * xdelt + ydelt * ydelt);
- float[] ret = {
- (x1 + u * (x2 - x1)), (y1 + u * (y2 - y1))
- };
- float[] vec = {
- ret[0] - point[0], ret[1] - point[1]
- };
- return vec;
- }
-
- // A . B
- public static float dotProduct(float[] a, float[] b) {
- return a[0] * b[0] + a[1] * b[1];
- }
-
- public static float[] normalize(float[] a) {
- float length = (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]);
- float[] b = {
- a[0] / length, a[1] / length
- };
- return b;
- }
-
- // A onto B
- public static float scalarProjection(float[] a, float[] b) {
- float length = (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]);
- return dotProduct(a, b) / length;
- }
-
- public static float[] getVectorFromPoints(float[] point1, float[] point2) {
- float[] p = {
- point2[0] - point1[0], point2[1] - point1[1]
- };
- return p;
- }
-
- public static float[] getUnitVectorFromPoints(float[] point1, float[] point2) {
- float[] p = {
- point2[0] - point1[0], point2[1] - point1[1]
- };
- float length = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1]);
- p[0] = p[0] / length;
- p[1] = p[1] / length;
- return p;
- }
-
- public static RectF scaleRect(RectF r, float scale) {
- return new RectF(r.left * scale, r.top * scale, r.right * scale, r.bottom * scale);
- }
-
- // A - B
- public static float[] vectorSubtract(float[] a, float[] b) {
- int len = a.length;
- if (len != b.length)
- return null;
- float[] ret = new float[len];
- for (int i = 0; i < len; i++) {
- ret[i] = a[i] - b[i];
- }
- return ret;
- }
-
- public static float vectorLength(float[] a) {
- return (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]);
- }
-
- public static float scale(float oldWidth, float oldHeight, float newWidth, float newHeight) {
- if (oldHeight == 0 || oldWidth == 0)
- return 1;
- return Math.min(newWidth / oldWidth, newHeight / oldHeight);
- }
-
- public static Rect roundNearest(RectF r) {
- Rect q = new Rect(Math.round(r.left), Math.round(r.top), Math.round(r.right),
- Math.round(r.bottom));
- return q;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
new file mode 100644
index 0000000..dada7dc
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
@@ -0,0 +1,490 @@
+/*
+ * 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.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.util.Log;
+
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.FilterCropRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation.Mirror;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation.Rotation;
+import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+public final class GeometryMathUtils {
+ private static final String TAG = "GeometryMathUtils";
+ public static final float SHOW_SCALE = .9f;
+
+ private GeometryMathUtils() {};
+
+ // Holder class for Geometry data.
+ public static final class GeometryHolder {
+ public Rotation rotation = FilterRotateRepresentation.getNil();
+ public float straighten = FilterStraightenRepresentation.getNil();
+ public RectF crop = FilterCropRepresentation.getNil();
+ public Mirror mirror = FilterMirrorRepresentation.getNil();
+
+ public void set(GeometryHolder h) {
+ rotation = h.rotation;
+ straighten = h.straighten;
+ crop.set(h.crop);
+ mirror = h.mirror;
+ }
+
+ public void wipe() {
+ rotation = FilterRotateRepresentation.getNil();
+ straighten = FilterStraightenRepresentation.getNil();
+ crop = FilterCropRepresentation.getNil();
+ mirror = FilterMirrorRepresentation.getNil();
+ }
+
+ public boolean isNil() {
+ return rotation == FilterRotateRepresentation.getNil() &&
+ straighten == FilterStraightenRepresentation.getNil() &&
+ crop.equals(FilterCropRepresentation.getNil()) &&
+ mirror == FilterMirrorRepresentation.getNil();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof GeometryHolder)) {
+ return false;
+ }
+ GeometryHolder h = (GeometryHolder) o;
+ return rotation == h.rotation && straighten == h.straighten &&
+ ((crop == null && h.crop == null) || (crop != null && crop.equals(h.crop))) &&
+ mirror == h.mirror;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[" + "rotation:" + rotation.value()
+ + ",straighten:" + straighten + ",crop:" + crop.toString()
+ + ",mirror:" + mirror.value() + "]";
+ }
+ }
+
+ // Math operations for 2d vectors
+ public static float clamp(float i, float low, float high) {
+ return Math.max(Math.min(i, high), low);
+ }
+
+ public static float[] lineIntersect(float[] line1, float[] line2) {
+ float a0 = line1[0];
+ float a1 = line1[1];
+ float b0 = line1[2];
+ float b1 = line1[3];
+ float c0 = line2[0];
+ float c1 = line2[1];
+ float d0 = line2[2];
+ float d1 = line2[3];
+ float t0 = a0 - b0;
+ float t1 = a1 - b1;
+ float t2 = b0 - d0;
+ float t3 = d1 - b1;
+ float t4 = c0 - d0;
+ float t5 = c1 - d1;
+
+ float denom = t1 * t4 - t0 * t5;
+ if (denom == 0)
+ return null;
+ float u = (t3 * t4 + t5 * t2) / denom;
+ float[] intersect = {
+ b0 + u * t0, b1 + u * t1
+ };
+ return intersect;
+ }
+
+ public static float[] shortestVectorFromPointToLine(float[] point, float[] line) {
+ float x1 = line[0];
+ float x2 = line[2];
+ float y1 = line[1];
+ float y2 = line[3];
+ float xdelt = x2 - x1;
+ float ydelt = y2 - y1;
+ if (xdelt == 0 && ydelt == 0)
+ return null;
+ float u = ((point[0] - x1) * xdelt + (point[1] - y1) * ydelt)
+ / (xdelt * xdelt + ydelt * ydelt);
+ float[] ret = {
+ (x1 + u * (x2 - x1)), (y1 + u * (y2 - y1))
+ };
+ float[] vec = {
+ ret[0] - point[0], ret[1] - point[1]
+ };
+ return vec;
+ }
+
+ // A . B
+ public static float dotProduct(float[] a, float[] b) {
+ return a[0] * b[0] + a[1] * b[1];
+ }
+
+ public static float[] normalize(float[] a) {
+ float length = (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]);
+ float[] b = {
+ a[0] / length, a[1] / length
+ };
+ return b;
+ }
+
+ // A onto B
+ public static float scalarProjection(float[] a, float[] b) {
+ float length = (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]);
+ return dotProduct(a, b) / length;
+ }
+
+ public static float[] getVectorFromPoints(float[] point1, float[] point2) {
+ float[] p = {
+ point2[0] - point1[0], point2[1] - point1[1]
+ };
+ return p;
+ }
+
+ public static float[] getUnitVectorFromPoints(float[] point1, float[] point2) {
+ float[] p = {
+ point2[0] - point1[0], point2[1] - point1[1]
+ };
+ float length = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1]);
+ p[0] = p[0] / length;
+ p[1] = p[1] / length;
+ return p;
+ }
+
+ public static void scaleRect(RectF r, float scale) {
+ r.set(r.left * scale, r.top * scale, r.right * scale, r.bottom * scale);
+ }
+
+ // A - B
+ public static float[] vectorSubtract(float[] a, float[] b) {
+ int len = a.length;
+ if (len != b.length)
+ return null;
+ float[] ret = new float[len];
+ for (int i = 0; i < len; i++) {
+ ret[i] = a[i] - b[i];
+ }
+ return ret;
+ }
+
+ public static float vectorLength(float[] a) {
+ return (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]);
+ }
+
+ public static float scale(float oldWidth, float oldHeight, float newWidth, float newHeight) {
+ if (oldHeight == 0 || oldWidth == 0 || (oldWidth == newWidth && oldHeight == newHeight)) {
+ return 1;
+ }
+ return Math.min(newWidth / oldWidth, newHeight / oldHeight);
+ }
+
+ public static Rect roundNearest(RectF r) {
+ Rect q = new Rect(Math.round(r.left), Math.round(r.top), Math.round(r.right),
+ Math.round(r.bottom));
+ return q;
+ }
+
+ private static void concatMirrorMatrix(Matrix m, GeometryHolder holder) {
+ Mirror type = holder.mirror;
+ if (type == Mirror.HORIZONTAL) {
+ if (holder.rotation.value() == 90
+ || holder.rotation.value() == 270) {
+ type = Mirror.VERTICAL;
+ }
+ } else if (type == Mirror.VERTICAL) {
+ if (holder.rotation.value() == 90
+ || holder.rotation.value() == 270) {
+ type = Mirror.HORIZONTAL;
+ }
+ }
+ if (type == Mirror.HORIZONTAL) {
+ m.postScale(-1, 1);
+ } else if (type == Mirror.VERTICAL) {
+ m.postScale(1, -1);
+ } else if (type == Mirror.BOTH) {
+ m.postScale(1, -1);
+ m.postScale(-1, 1);
+ }
+ }
+
+ private static int getRotationForOrientation(int orientation) {
+ switch (orientation) {
+ case ImageLoader.ORI_ROTATE_90:
+ return 90;
+ case ImageLoader.ORI_ROTATE_180:
+ return 180;
+ case ImageLoader.ORI_ROTATE_270:
+ return 270;
+ default:
+ return 0;
+ }
+ }
+
+ public static GeometryHolder unpackGeometry(Collection<FilterRepresentation> geometry) {
+ GeometryHolder holder = new GeometryHolder();
+ unpackGeometry(holder, geometry);
+ return holder;
+ }
+
+ public static void unpackGeometry(GeometryHolder out,
+ Collection<FilterRepresentation> geometry) {
+ out.wipe();
+ // Get geometry data from filters
+ for (FilterRepresentation r : geometry) {
+ if (r.isNil()) {
+ continue;
+ }
+ if (r.getSerializationName() == FilterRotateRepresentation.SERIALIZATION_NAME) {
+ out.rotation = ((FilterRotateRepresentation) r).getRotation();
+ } else if (r.getSerializationName() ==
+ FilterStraightenRepresentation.SERIALIZATION_NAME) {
+ out.straighten = ((FilterStraightenRepresentation) r).getStraighten();
+ } else if (r.getSerializationName() == FilterCropRepresentation.SERIALIZATION_NAME) {
+ ((FilterCropRepresentation) r).getCrop(out.crop);
+ } else if (r.getSerializationName() == FilterMirrorRepresentation.SERIALIZATION_NAME) {
+ out.mirror = ((FilterMirrorRepresentation) r).getMirror();
+ }
+ }
+ }
+
+ public static void replaceInstances(Collection<FilterRepresentation> geometry,
+ FilterRepresentation rep) {
+ Iterator<FilterRepresentation> iter = geometry.iterator();
+ while (iter.hasNext()) {
+ FilterRepresentation r = iter.next();
+ if (ImagePreset.sameSerializationName(rep, r)) {
+ iter.remove();
+ }
+ }
+ if (!rep.isNil()) {
+ geometry.add(rep);
+ }
+ }
+
+ public static void initializeHolder(GeometryHolder outHolder,
+ FilterRepresentation currentLocal) {
+ Collection<FilterRepresentation> geometry = MasterImage.getImage().getPreset()
+ .getGeometryFilters();
+ replaceInstances(geometry, currentLocal);
+ unpackGeometry(outHolder, geometry);
+ }
+
+ public static Rect finalGeometryRect(int width, int height,
+ Collection<FilterRepresentation> geometry) {
+ GeometryHolder holder = unpackGeometry(geometry);
+ RectF crop = getTrueCropRect(holder, width, height);
+ Rect frame = new Rect();
+ crop.roundOut(frame);
+ return frame;
+ }
+
+ private static Bitmap applyFullGeometryMatrix(Bitmap image, GeometryHolder holder) {
+ int width = image.getWidth();
+ int height = image.getHeight();
+ RectF crop = getTrueCropRect(holder, width, height);
+ Rect frame = new Rect();
+ crop.roundOut(frame);
+ Matrix m = getCropSelectionToScreenMatrix(null, holder, width, height, frame.width(),
+ frame.height());
+ BitmapCache bitmapCache = MasterImage.getImage().getBitmapCache();
+ Bitmap temp = bitmapCache.getBitmap(frame.width(),
+ frame.height(), BitmapCache.UTIL_GEOMETRY);
+ Canvas canvas = new Canvas(temp);
+ Paint paint = new Paint();
+ paint.setAntiAlias(true);
+ paint.setFilterBitmap(true);
+ paint.setDither(true);
+ canvas.drawBitmap(image, m, paint);
+ return temp;
+ }
+
+ public static Matrix getImageToScreenMatrix(Collection<FilterRepresentation> geometry,
+ boolean reflectRotation, Rect bmapDimens, float viewWidth, float viewHeight) {
+ GeometryHolder h = unpackGeometry(geometry);
+ return GeometryMathUtils.getOriginalToScreen(h, reflectRotation, bmapDimens.width(),
+ bmapDimens.height(), viewWidth, viewHeight);
+ }
+
+ public static Matrix getPartialToScreenMatrix(Collection<FilterRepresentation> geometry,
+ Rect originalBounds, float w, float h,
+ float pw, float ph) {
+ GeometryHolder holder = unpackGeometry(geometry);
+ RectF rCrop = new RectF(0, 0, originalBounds.width(), originalBounds.height());
+ float angle = holder.straighten;
+ int rotation = holder.rotation.value();
+
+ ImageStraighten.getUntranslatedStraightenCropBounds(rCrop, angle);
+ float dx = (w - pw) / 2f;
+ float dy = (h - ph) / 2f;
+ Matrix compensation = new Matrix();
+ compensation.postTranslate(dx, dy);
+ float cScale = originalBounds.width() / rCrop.width();
+ if (rCrop.width() < rCrop.height()) {
+ cScale = originalBounds.height() / rCrop.height();
+ }
+ float scale = w / pw;
+ if (w < h) {
+ scale = h / ph;
+ }
+ scale = scale * cScale;
+ float cx = w / 2f;
+ float cy = h / 2f;
+
+ compensation.postScale(scale, scale, cx, cy);
+ compensation.postRotate(angle, cx, cy);
+ compensation.postRotate(rotation, cx, cy);
+ compensation.postTranslate(-cx, -cy);
+ concatMirrorMatrix(compensation, holder);
+ compensation.postTranslate(cx, cy);
+ return compensation;
+ }
+
+ public static Matrix getOriginalToScreen(GeometryHolder holder, boolean rotate,
+ float originalWidth,
+ float originalHeight, float viewWidth, float viewHeight) {
+ int orientation = MasterImage.getImage().getZoomOrientation();
+ int rotation = getRotationForOrientation(orientation);
+ Rotation prev = holder.rotation;
+ rotation = (rotation + prev.value()) % 360;
+ holder.rotation = Rotation.fromValue(rotation);
+ Matrix m = getCropSelectionToScreenMatrix(null, holder, (int) originalWidth,
+ (int) originalHeight, (int) viewWidth, (int) viewHeight);
+ holder.rotation = prev;
+ return m;
+ }
+
+ public static Bitmap applyGeometryRepresentations(Collection<FilterRepresentation> res,
+ Bitmap image) {
+ GeometryHolder holder = unpackGeometry(res);
+ Bitmap bmap = image;
+ // If there are geometry changes, apply them to the image
+ if (!holder.isNil()) {
+ bmap = applyFullGeometryMatrix(bmap, holder);
+ if (bmap != image) {
+ BitmapCache cache = MasterImage.getImage().getBitmapCache();
+ cache.cache(image);
+ }
+ }
+ return bmap;
+ }
+
+ public static RectF drawTransformedCropped(GeometryHolder holder, Canvas canvas,
+ Bitmap photo, int viewWidth, int viewHeight) {
+ if (photo == null) {
+ return null;
+ }
+ RectF crop = new RectF();
+ Matrix m = getCropSelectionToScreenMatrix(crop, holder, photo.getWidth(), photo.getHeight(),
+ viewWidth, viewHeight);
+ canvas.save();
+ canvas.clipRect(crop);
+ Paint p = new Paint();
+ p.setAntiAlias(true);
+ canvas.drawBitmap(photo, m, p);
+ canvas.restore();
+ return crop;
+ }
+
+ public static boolean needsDimensionSwap(Rotation rotation) {
+ switch (rotation) {
+ case NINETY:
+ case TWO_SEVENTY:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ // Gives matrix for rotated, straightened, mirrored bitmap centered at 0,0.
+ private static Matrix getFullGeometryMatrix(GeometryHolder holder, int bitmapWidth,
+ int bitmapHeight) {
+ float centerX = bitmapWidth / 2f;
+ float centerY = bitmapHeight / 2f;
+ Matrix m = new Matrix();
+ m.setTranslate(-centerX, -centerY);
+ m.postRotate(holder.straighten + holder.rotation.value());
+ concatMirrorMatrix(m, holder);
+ return m;
+ }
+
+ public static Matrix getFullGeometryToScreenMatrix(GeometryHolder holder, int bitmapWidth,
+ int bitmapHeight, int viewWidth, int viewHeight) {
+ int bh = bitmapHeight;
+ int bw = bitmapWidth;
+ if (GeometryMathUtils.needsDimensionSwap(holder.rotation)) {
+ bh = bitmapWidth;
+ bw = bitmapHeight;
+ }
+ float scale = GeometryMathUtils.scale(bw, bh, viewWidth, viewHeight);
+ scale *= SHOW_SCALE;
+ float s = Math.min(viewWidth / (float) bitmapWidth, viewHeight / (float) bitmapHeight);
+ Matrix m = getFullGeometryMatrix(holder, bitmapWidth, bitmapHeight);
+ m.postScale(scale, scale);
+ m.postTranslate(viewWidth / 2f, viewHeight / 2f);
+ return m;
+ }
+
+ public static RectF getTrueCropRect(GeometryHolder holder, int bitmapWidth, int bitmapHeight) {
+ RectF r = new RectF(holder.crop);
+ FilterCropRepresentation.findScaledCrop(r, bitmapWidth, bitmapHeight);
+ float s = holder.straighten;
+ holder.straighten = 0;
+ Matrix m1 = getFullGeometryMatrix(holder, bitmapWidth, bitmapHeight);
+ holder.straighten = s;
+ m1.mapRect(r);
+ return r;
+ }
+
+ public static Matrix getCropSelectionToScreenMatrix(RectF outCrop, GeometryHolder holder,
+ int bitmapWidth, int bitmapHeight, int viewWidth, int viewHeight) {
+ Matrix m = getFullGeometryMatrix(holder, bitmapWidth, bitmapHeight);
+ RectF crop = getTrueCropRect(holder, bitmapWidth, bitmapHeight);
+ float scale = GeometryMathUtils.scale(crop.width(), crop.height(), viewWidth, viewHeight);
+ m.postScale(scale, scale);
+ GeometryMathUtils.scaleRect(crop, scale);
+ m.postTranslate(viewWidth / 2f - crop.centerX(), viewHeight / 2f - crop.centerY());
+ if (outCrop != null) {
+ crop.offset(viewWidth / 2f - crop.centerX(), viewHeight / 2f - crop.centerY());
+ outCrop.set(crop);
+ }
+ return m;
+ }
+
+ public static Matrix getCropSelectionToScreenMatrix(RectF outCrop,
+ Collection<FilterRepresentation> res, int bitmapWidth, int bitmapHeight, int viewWidth,
+ int viewHeight) {
+ GeometryHolder holder = unpackGeometry(res);
+ return getCropSelectionToScreenMatrix(outCrop, holder, bitmapWidth, bitmapHeight,
+ viewWidth, viewHeight);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
deleted file mode 100644
index e5820a8..0000000
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.imageshow;
-
-import android.graphics.Bitmap;
-import android.graphics.Matrix;
-import android.graphics.Rect;
-import android.graphics.RectF;
-
-import com.android.gallery3d.filtershow.cache.ImageLoader;
-import com.android.gallery3d.filtershow.crop.CropExtras;
-import com.android.gallery3d.filtershow.editors.EditorCrop;
-import com.android.gallery3d.filtershow.editors.EditorFlip;
-import com.android.gallery3d.filtershow.editors.EditorRotate;
-import com.android.gallery3d.filtershow.editors.EditorStraighten;
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.filters.ImageFilterGeometry;
-
-public class GeometryMetadata extends FilterRepresentation {
- private static final String LOGTAG = "GeometryMetadata";
- private float mScaleFactor = 1.0f;
- private float mRotation = 0;
- private float mStraightenRotation = 0;
- private final RectF mCropBounds = new RectF();
- private final RectF mPhotoBounds = new RectF();
- private FLIP mFlip = FLIP.NONE;
-
- public enum FLIP {
- NONE, VERTICAL, HORIZONTAL, BOTH
- }
-
- // Output format data from intent extras
- private boolean mUseCropExtras = false;
- private CropExtras mCropExtras = null;
- public void setUseCropExtrasFlag(boolean f){
- mUseCropExtras = f;
- }
-
- public boolean getUseCropExtrasFlag(){
- return mUseCropExtras;
- }
-
- public void setCropExtras(CropExtras e){
- mCropExtras = e;
- }
-
- public CropExtras getCropExtras(){
- return mCropExtras;
- }
-
- public GeometryMetadata() {
- super("GeometryMetadata");
- setFilterClass(ImageFilterGeometry.class);
- setEditorId(EditorCrop.ID);
- setTextId(0);
- setShowParameterValue(true);
- }
-
- @Override
- public int[] getEditorIds() {
- return new int[] {
- EditorCrop.ID,
- EditorStraighten.ID,
- EditorRotate.ID,
- EditorFlip.ID
- };
- }
-
- public GeometryMetadata(GeometryMetadata g) {
- super("GeometryMetadata");
- set(g);
- }
-
- public boolean hasModifications() {
- if (mScaleFactor != 1.0f) {
- return true;
- }
- if (mRotation != 0) {
- return true;
- }
- if (mStraightenRotation != 0) {
- return true;
- }
- Rect cropBounds = GeometryMath.roundNearest(mCropBounds);
- Rect photoBounds = GeometryMath.roundNearest(mPhotoBounds);
- if (!cropBounds.equals(photoBounds)) {
- return true;
- }
- if (!mFlip.equals(FLIP.NONE)) {
- return true;
- }
- return false;
- }
-
- public void set(GeometryMetadata g) {
- mScaleFactor = g.mScaleFactor;
- mRotation = g.mRotation;
- mStraightenRotation = g.mStraightenRotation;
- mCropBounds.set(g.mCropBounds);
- mPhotoBounds.set(g.mPhotoBounds);
- mFlip = g.mFlip;
-
- mUseCropExtras = g.mUseCropExtras;
- if (g.mCropExtras != null){
- mCropExtras = new CropExtras(g.mCropExtras);
- }
- }
-
- public float getScaleFactor() {
- return mScaleFactor;
- }
-
- public float getRotation() {
- return mRotation;
- }
-
- public float getStraightenRotation() {
- return mStraightenRotation;
- }
-
- public RectF getPreviewCropBounds() {
- return new RectF(mCropBounds);
- }
-
- public RectF getCropBounds(Bitmap bitmap) {
- float scale = 1.0f;
- scale = GeometryMath.scale(mPhotoBounds.width(), mPhotoBounds.height(), bitmap.getWidth(),
- bitmap.getHeight());
- RectF croppedRegion = new RectF(mCropBounds.left * scale, mCropBounds.top * scale,
- mCropBounds.right * scale, mCropBounds.bottom * scale);
-
- // If no crop has been applied, make sure to use the exact size values.
- // Multiplying using scale will introduce rounding errors that modify
- // even un-cropped images.
- if (mCropBounds.left == 0 && mCropBounds.right == mPhotoBounds.right) {
- croppedRegion.left = 0;
- croppedRegion.right = bitmap.getWidth();
- }
- if (mCropBounds.top == 0 && mCropBounds.bottom == mPhotoBounds.bottom) {
- croppedRegion.top = 0;
- croppedRegion.bottom = bitmap.getHeight();
- }
- return croppedRegion;
- }
-
- public FLIP getFlipType() {
- return mFlip;
- }
-
- public RectF getPhotoBounds() {
- return new RectF(mPhotoBounds);
- }
-
- public void setScaleFactor(float scale) {
- mScaleFactor = scale;
- }
-
- public void setFlipType(FLIP flip) {
- mFlip = flip;
- }
-
- public void setRotation(float rotation) {
- mRotation = rotation;
- }
-
- public void setStraightenRotation(float straighten) {
- mStraightenRotation = straighten;
- }
-
- public void setCropBounds(RectF newCropBounds) {
- mCropBounds.set(newCropBounds);
- }
-
- public void setPhotoBounds(RectF newPhotoBounds) {
- mPhotoBounds.set(newPhotoBounds);
- }
-
- public boolean cropFitsInPhoto(RectF cropBounds) {
- return mPhotoBounds.contains(cropBounds);
- }
-
- private boolean compareRectF(RectF a, RectF b) {
- return ((int) a.left == (int) b.left)
- && ((int) a.right == (int) b.right)
- && ((int) a.top == (int) b.top)
- && ((int) a.bottom == (int) b.bottom);
- }
-
- @Override
- public boolean equals(FilterRepresentation o) {
- if (this == o)
- return true;
- if (o == null || !(o instanceof GeometryMetadata))
- return false;
-
- GeometryMetadata d = (GeometryMetadata) o;
- return (mScaleFactor == d.mScaleFactor
- && mRotation == d.mRotation
- && mStraightenRotation == d.mStraightenRotation
- && mFlip == d.mFlip
- && compareRectF(mCropBounds, d.mCropBounds)
- && compareRectF(mPhotoBounds, d.mPhotoBounds));
- }
-
- @Override
- public int hashCode() {
- int result = 23;
- result = 31 * result + Float.floatToIntBits(mRotation);
- result = 31 * result + Float.floatToIntBits(mStraightenRotation);
- result = 31 * result + Float.floatToIntBits(mScaleFactor);
- result = 31 * result + mFlip.hashCode();
- result = 31 * result + mCropBounds.hashCode();
- result = 31 * result + mPhotoBounds.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return getClass().getName() + "[" + "scale=" + mScaleFactor
- + ",rotation=" + mRotation + ",flip=" + mFlip + ",straighten="
- + mStraightenRotation + ",cropRect=" + mCropBounds.toShortString()
- + ",photoRect=" + mPhotoBounds.toShortString() + "]";
- }
-
- protected static void concatHorizontalMatrix(Matrix m, float width) {
- m.postScale(-1, 1);
- m.postTranslate(width, 0);
- }
-
- protected static void concatVerticalMatrix(Matrix m, float height) {
- m.postScale(1, -1);
- m.postTranslate(0, height);
- }
-
-
- public static void concatMirrorMatrix(Matrix m, float width, float height, FLIP type) {
- if (type == FLIP.HORIZONTAL) {
- concatHorizontalMatrix(m, width);
- } else if (type == FLIP.VERTICAL) {
- concatVerticalMatrix(m, height);
- } else if (type == FLIP.BOTH) {
- concatVerticalMatrix(m, height);
- concatHorizontalMatrix(m, width);
- }
- }
-
- public Matrix getMatrixOriginalOrientation(int orientation, float originalWidth,
- float originalHeight) {
- Matrix imageRotation = new Matrix();
- switch (orientation) {
- case ImageLoader.ORI_ROTATE_90: {
- imageRotation.setRotate(90, originalWidth / 2f, originalHeight / 2f);
- imageRotation.postTranslate(-(originalWidth - originalHeight) / 2f,
- -(originalHeight - originalWidth) / 2f);
- break;
- }
- case ImageLoader.ORI_ROTATE_180: {
- imageRotation.setRotate(180, originalWidth / 2f, originalHeight / 2f);
- break;
- }
- case ImageLoader.ORI_ROTATE_270: {
- imageRotation.setRotate(270, originalWidth / 2f, originalHeight / 2f);
- imageRotation.postTranslate(-(originalWidth - originalHeight) / 2f,
- -(originalHeight - originalWidth) / 2f);
- break;
- }
- case ImageLoader.ORI_FLIP_HOR: {
- imageRotation.preScale(-1, 1);
- break;
- }
- case ImageLoader.ORI_FLIP_VERT: {
- imageRotation.preScale(1, -1);
- break;
- }
- case ImageLoader.ORI_TRANSPOSE: {
- imageRotation.setRotate(90, originalWidth / 2f, originalHeight / 2f);
- imageRotation.postTranslate(-(originalWidth - originalHeight) / 2f,
- -(originalHeight - originalWidth) / 2f);
- imageRotation.preScale(1, -1);
- break;
- }
- case ImageLoader.ORI_TRANSVERSE: {
- imageRotation.setRotate(270, originalWidth / 2f, originalHeight / 2f);
- imageRotation.postTranslate(-(originalWidth - originalHeight) / 2f,
- -(originalHeight - originalWidth) / 2f);
- imageRotation.preScale(1, -1);
- break;
- }
- }
- return imageRotation;
- }
-
- public Matrix getOriginalToScreen(boolean rotate, float originalWidth, float originalHeight,
- float viewWidth, float viewHeight) {
- RectF photoBounds = getPhotoBounds();
- RectF cropBounds = getPreviewCropBounds();
- float imageWidth = cropBounds.width();
- float imageHeight = cropBounds.height();
-
- int orientation = ImageLoader.getZoomOrientation();
- Matrix imageRotation = getMatrixOriginalOrientation(orientation, originalWidth,
- originalHeight);
- if (orientation == ImageLoader.ORI_ROTATE_90 ||
- orientation == ImageLoader.ORI_ROTATE_270 ||
- orientation == ImageLoader.ORI_TRANSPOSE ||
- orientation == ImageLoader.ORI_TRANSVERSE) {
- float tmp = originalWidth;
- originalWidth = originalHeight;
- originalHeight = tmp;
- }
-
- float preScale = GeometryMath.scale(originalWidth, originalHeight,
- photoBounds.width(), photoBounds.height());
- float scale = GeometryMath.scale(imageWidth, imageHeight, viewWidth, viewHeight);
- // checks if local rotation is an odd multiple of 90.
- if (((int) (getRotation() / 90)) % 2 != 0) {
- scale = GeometryMath.scale(imageWidth, imageHeight, viewHeight, viewWidth);
- }
- // put in screen coordinates
- RectF scaledCrop = GeometryMath.scaleRect(cropBounds, scale);
- RectF scaledPhoto = GeometryMath.scaleRect(photoBounds, scale);
- float[] displayCenter = {
- viewWidth / 2f, viewHeight / 2f
- };
- Matrix m1 = GeometryMetadata.buildWanderingCropMatrix(scaledPhoto, scaledCrop,
- getRotation(), getStraightenRotation(), getFlipType(), displayCenter);
- float[] cropCenter = {
- scaledCrop.centerX(), scaledCrop.centerY()
- };
- m1.mapPoints(cropCenter);
- GeometryMetadata.concatRecenterMatrix(m1, cropCenter, displayCenter);
- m1.preRotate(getStraightenRotation(), scaledPhoto.centerX(), scaledPhoto.centerY());
- m1.preScale(scale, scale);
- m1.preScale(preScale, preScale);
- m1.preConcat(imageRotation);
-
- return m1;
- }
-
- public boolean hasSwitchedWidthHeight() {
- return (((int) (mRotation / 90)) % 2) != 0;
- }
-
- public static Matrix buildPhotoMatrix(RectF photo, RectF crop, float rotation,
- float straighten, FLIP type) {
- Matrix m = new Matrix();
- m.setRotate(straighten, photo.centerX(), photo.centerY());
- concatMirrorMatrix(m, photo.right, photo.bottom, type);
- m.postRotate(rotation, crop.centerX(), crop.centerY());
-
- return m;
- }
-
- public static Matrix buildCropMatrix(RectF crop, float rotation) {
- Matrix m = new Matrix();
- m.setRotate(rotation, crop.centerX(), crop.centerY());
- return m;
- }
-
- public static void concatRecenterMatrix(Matrix m, float[] currentCenter, float[] newCenter) {
- m.postTranslate(newCenter[0] - currentCenter[0], newCenter[1] - currentCenter[1]);
- }
-
- /**
- * Builds a matrix to transform a bitmap of width bmWidth and height
- * bmHeight so that the region of the bitmap being cropped to is oriented
- * and centered at displayCenter.
- *
- * @param bmWidth
- * @param bmHeight
- * @param displayCenter
- * @return
- */
- public Matrix buildTotalXform(float bmWidth, float bmHeight, float[] displayCenter) {
- RectF rp = getPhotoBounds();
- RectF rc = getPreviewCropBounds();
- float scale = GeometryMath.scale(rp.width(), rp.height(), bmWidth, bmHeight);
- RectF scaledCrop = GeometryMath.scaleRect(rc, scale);
- RectF scaledPhoto = GeometryMath.scaleRect(rp, scale);
-
- // If no crop has been applied, make sure to use the exact size values.
- // Multiplying using scale will introduce rounding errors that modify
- // even un-cropped images.
- if (rc.left == 0 && rc.right == rp.right) {
- scaledCrop.left = scaledPhoto.left = 0;
- scaledCrop.right = scaledPhoto.right = bmWidth;
- }
- if (rc.top == 0 && rc.bottom == rp.bottom) {
- scaledCrop.top = scaledPhoto.top = 0;
- scaledCrop.bottom = scaledPhoto.bottom = bmHeight;
- }
-
- Matrix m1 = GeometryMetadata.buildWanderingCropMatrix(scaledPhoto, scaledCrop,
- getRotation(), getStraightenRotation(),
- getFlipType(), displayCenter);
- float[] cropCenter = {
- scaledCrop.centerX(), scaledCrop.centerY()
- };
- m1.mapPoints(cropCenter);
-
- GeometryMetadata.concatRecenterMatrix(m1, cropCenter, displayCenter);
- m1.preRotate(getStraightenRotation(), scaledPhoto.centerX(),
- scaledPhoto.centerY());
- return m1;
- }
-
- /**
- * Builds a matrix that rotates photo rect about it's center by the
- * straighten angle, mirrors it about the crop center, and rotates it about
- * the crop center by the rotation angle, and re-centers the photo rect.
- *
- * @param photo
- * @param crop
- * @param rotation
- * @param straighten
- * @param type
- * @param newCenter
- * @return
- */
- public static Matrix buildCenteredPhotoMatrix(RectF photo, RectF crop, float rotation,
- float straighten, FLIP type, float[] newCenter) {
- Matrix m = buildPhotoMatrix(photo, crop, rotation, straighten, type);
- float[] center = {
- photo.centerX(), photo.centerY()
- };
- m.mapPoints(center);
- concatRecenterMatrix(m, center, newCenter);
- return m;
- }
-
- /**
- * Builds a matrix that rotates a crop rect about it's center by rotation
- * angle, then re-centers the crop rect.
- *
- * @param crop
- * @param rotation
- * @param newCenter
- * @return
- */
- public static Matrix buildCenteredCropMatrix(RectF crop, float rotation, float[] newCenter) {
- Matrix m = buildCropMatrix(crop, rotation);
- float[] center = {
- crop.centerX(), crop.centerY()
- };
- m.mapPoints(center);
- concatRecenterMatrix(m, center, newCenter);
- return m;
- }
-
- /**
- * Builds a matrix that transforms the crop rect to its view coordinates
- * inside the photo rect.
- *
- * @param photo
- * @param crop
- * @param rotation
- * @param straighten
- * @param type
- * @param newCenter
- * @return
- */
- public static Matrix buildWanderingCropMatrix(RectF photo, RectF crop, float rotation,
- float straighten, FLIP type, float[] newCenter) {
- Matrix m = buildCenteredPhotoMatrix(photo, crop, rotation, straighten, type, newCenter);
- m.preRotate(-straighten, photo.centerX(), photo.centerY());
- return m;
- }
-
- @Override
- public void useParametersFrom(FilterRepresentation a) {
- GeometryMetadata data = (GeometryMetadata) a;
- set(data);
- }
-
- @Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- GeometryMetadata representation = (GeometryMetadata) super.clone();
- representation.useParametersFrom(this);
- return representation;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GradControl.java b/src/com/android/gallery3d/filtershow/imageshow/GradControl.java
new file mode 100644
index 0000000..964da99
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/GradControl.java
@@ -0,0 +1,274 @@
+/*
+ * 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.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.DashPathEffect;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.RadialGradient;
+import android.graphics.Rect;
+import android.graphics.Shader;
+
+import com.android.gallery3d.R;
+
+public class GradControl {
+ private float mPoint1X = Float.NaN; // used to flag parameters have not been set
+ private float mPoint1Y = 0;
+ private float mPoint2X = 200;
+ private float mPoint2Y = 300;
+ private int mMinTouchDist = 80;// should be a resource & in dips
+
+ private float[] handlex = new float[3];
+ private float[] handley = new float[3];
+ private int mSliderColor;
+ private int mCenterDotSize;
+ private float mDownX;
+ private float mDownY;
+ private float mDownPoint1X;
+ private float mDownPoint1Y;
+ private float mDownPoint2X;
+ private float mDownPoint2Y;
+ Rect mImageBounds;
+ int mImageHeight;
+ private Matrix mScrToImg;
+ Paint mPaint = new Paint();
+ DashPathEffect mDash = new DashPathEffect(new float[]{30, 30}, 0);
+ private boolean mShowReshapeHandles = true;
+ public final static int HAN_CENTER = 0;
+ public final static int HAN_NORTH = 2;
+ public final static int HAN_SOUTH = 1;
+ private int[] mPointColorPatern;
+ private int[] mGrayPointColorPatern;
+ private float[] mPointRadialPos = new float[]{0, .3f, .31f, 1};
+ private int mLineColor;
+ private int mlineShadowColor;
+
+ public GradControl(Context context) {
+
+ Resources res = context.getResources();
+ mCenterDotSize = (int) res.getDimension(R.dimen.gradcontrol_dot_size);
+ mMinTouchDist = (int) res.getDimension(R.dimen.gradcontrol_min_touch_dist);
+ int grayPointCenterColor = res.getColor(R.color.gradcontrol_graypoint_center);
+ int grayPointEdgeColor = res.getColor(R.color.gradcontrol_graypoint_edge);
+ int pointCenterColor = res.getColor(R.color.gradcontrol_point_center);
+ int pointEdgeColor = res.getColor(R.color.gradcontrol_point_edge);
+ int pointShadowStartColor = res.getColor(R.color.gradcontrol_point_shadow_start);
+ int pointShadowEndColor = res.getColor(R.color.gradcontrol_point_shadow_end);
+ mPointColorPatern = new int[]{
+ pointCenterColor, pointEdgeColor, pointShadowStartColor, pointShadowEndColor};
+ mGrayPointColorPatern = new int[]{
+ grayPointCenterColor, grayPointEdgeColor, pointShadowStartColor, pointShadowEndColor};
+ mSliderColor = Color.WHITE;
+ mLineColor = res.getColor(R.color.gradcontrol_line_color);
+ mlineShadowColor = res.getColor(R.color.gradcontrol_line_shadow);
+ }
+
+ public void setPoint2(float x, float y) {
+ mPoint2X = x;
+ mPoint2Y = y;
+ }
+
+ public void setPoint1(float x, float y) {
+ mPoint1X = x;
+ mPoint1Y = y;
+ }
+
+ public int getCloseHandle(float x, float y) {
+ float min = Float.MAX_VALUE;
+ int handle = -1;
+ for (int i = 0; i < handlex.length; i++) {
+ float dx = handlex[i] - x;
+ float dy = handley[i] - y;
+ float dist = dx * dx + dy * dy;
+ if (dist < min) {
+ min = dist;
+ handle = i;
+ }
+ }
+
+ if (min < mMinTouchDist * mMinTouchDist) {
+ return handle;
+ }
+ for (int i = 0; i < handlex.length; i++) {
+ float dx = handlex[i] - x;
+ float dy = handley[i] - y;
+ float dist = (float) Math.sqrt(dx * dx + dy * dy);
+ }
+
+ return -1;
+ }
+
+ public void setScrImageInfo(Matrix scrToImg, Rect imageBounds) {
+ mScrToImg = scrToImg;
+ mImageBounds = new Rect(imageBounds);
+ }
+
+ private boolean centerIsOutside(float x1, float y1, float x2, float y2) {
+ return (!mImageBounds.contains((int) ((x1 + x2) / 2), (int) ((y1 + y2) / 2)));
+ }
+
+ public void actionDown(float x, float y, Line line) {
+ float[] point = new float[]{
+ x, y};
+ mScrToImg.mapPoints(point);
+ mDownX = point[0];
+ mDownY = point[1];
+ mDownPoint1X = line.getPoint1X();
+ mDownPoint1Y = line.getPoint1Y();
+ mDownPoint2X = line.getPoint2X();
+ mDownPoint2Y = line.getPoint2Y();
+ }
+
+ public void actionMove(int handle, float x, float y, Line line) {
+ float[] point = new float[]{
+ x, y};
+ mScrToImg.mapPoints(point);
+ x = point[0];
+ y = point[1];
+
+ // Test if the matrix is swapping x and y
+ point[0] = 0;
+ point[1] = 1;
+ mScrToImg.mapVectors(point);
+ boolean swapxy = (point[0] > 0.0f);
+
+ int sign = 1;
+
+ float dx = x - mDownX;
+ float dy = y - mDownY;
+ switch (handle) {
+ case HAN_CENTER:
+ if (centerIsOutside(mDownPoint1X + dx, mDownPoint1Y + dy,
+ mDownPoint2X + dx, mDownPoint2Y + dy)) {
+ break;
+ }
+ line.setPoint1(mDownPoint1X + dx, mDownPoint1Y + dy);
+ line.setPoint2(mDownPoint2X + dx, mDownPoint2Y + dy);
+ break;
+ case HAN_SOUTH:
+ if (centerIsOutside(mDownPoint1X + dx, mDownPoint1Y + dy,
+ mDownPoint2X, mDownPoint2Y)) {
+ break;
+ }
+ line.setPoint1(mDownPoint1X + dx, mDownPoint1Y + dy);
+ break;
+ case HAN_NORTH:
+ if (centerIsOutside(mDownPoint1X, mDownPoint1Y,
+ mDownPoint2X + dx, mDownPoint2Y + dy)) {
+ break;
+ }
+ line.setPoint2(mDownPoint2X + dx, mDownPoint2Y + dy);
+ break;
+ }
+ }
+
+ public void paintGrayPoint(Canvas canvas, float x, float y) {
+ if (isUndefined()) {
+ return;
+ }
+
+ Paint paint = new Paint();
+ paint.setStyle(Paint.Style.FILL);
+ RadialGradient g = new RadialGradient(x, y, mCenterDotSize, mGrayPointColorPatern,
+ mPointRadialPos, Shader.TileMode.CLAMP);
+ paint.setShader(g);
+ canvas.drawCircle(x, y, mCenterDotSize, paint);
+ }
+
+ public void paintPoint(Canvas canvas, float x, float y) {
+ if (isUndefined()) {
+ return;
+ }
+
+ Paint paint = new Paint();
+ paint.setStyle(Paint.Style.FILL);
+ RadialGradient g = new RadialGradient(x, y, mCenterDotSize, mPointColorPatern,
+ mPointRadialPos, Shader.TileMode.CLAMP);
+ paint.setShader(g);
+ canvas.drawCircle(x, y, mCenterDotSize, paint);
+ }
+
+ void paintLines(Canvas canvas, float p1x, float p1y, float p2x, float p2y) {
+ if (isUndefined()) {
+ return;
+ }
+
+ mPaint.setAntiAlias(true);
+ mPaint.setStyle(Paint.Style.STROKE);
+
+ mPaint.setStrokeWidth(6);
+ mPaint.setColor(mlineShadowColor);
+ mPaint.setPathEffect(mDash);
+ paintOvallines(canvas, mPaint, p1x, p1y, p2x, p2y);
+
+ mPaint.setStrokeWidth(3);
+ mPaint.setColor(mLineColor);
+ mPaint.setPathEffect(mDash);
+ paintOvallines(canvas, mPaint, p1x, p1y, p2x, p2y);
+ }
+
+ public void paintOvallines(
+ Canvas canvas, Paint paint, float p1x, float p1y, float p2x, float p2y) {
+
+
+
+ canvas.drawLine(p1x, p1y, p2x, p2y, paint);
+
+ float cx = (p1x + p2x) / 2;
+ float cy = (p1y + p2y) / 2;
+ float dx = p1x - p2x;
+ float dy = p1y - p2y;
+ float len = (float) Math.sqrt(dx * dx + dy * dy);
+ dx *= 2048 / len;
+ dy *= 2048 / len;
+
+ canvas.drawLine(p1x + dy, p1y - dx, p1x - dy, p1y + dx, paint);
+ canvas.drawLine(p2x + dy, p2y - dx, p2x - dy, p2y + dx, paint);
+ }
+
+ public void fillHandles(Canvas canvas, float p1x, float p1y, float p2x, float p2y) {
+ float cx = (p1x + p2x) / 2;
+ float cy = (p1y + p2y) / 2;
+ handlex[0] = cx;
+ handley[0] = cy;
+ handlex[1] = p1x;
+ handley[1] = p1y;
+ handlex[2] = p2x;
+ handley[2] = p2y;
+
+ }
+
+ public void draw(Canvas canvas) {
+ paintLines(canvas, mPoint1X, mPoint1Y, mPoint2X, mPoint2Y);
+ fillHandles(canvas, mPoint1X, mPoint1Y, mPoint2X, mPoint2Y);
+ paintPoint(canvas, mPoint2X, mPoint2Y);
+ paintPoint(canvas, mPoint1X, mPoint1Y);
+ paintPoint(canvas, (mPoint1X + mPoint2X) / 2, (mPoint1Y + mPoint2Y) / 2);
+ }
+
+ public boolean isUndefined() {
+ return Float.isNaN(mPoint1X);
+ }
+
+ public void setShowReshapeHandles(boolean showReshapeHandles) {
+ this.mShowReshapeHandles = showReshapeHandles;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
index f6271c6..4b03991 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * 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.
@@ -20,717 +20,308 @@
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.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.PopupMenu;
+import android.util.Log;
+import android.view.MotionEvent;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.crop.BoundedRect;
-import com.android.gallery3d.filtershow.crop.CropExtras;
+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.EditorCrop;
-import com.android.gallery3d.filtershow.ui.FramedTextButton;
+import com.android.gallery3d.filtershow.filters.FilterCropRepresentation;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder;
-public class ImageCrop extends ImageGeometry {
- private static final boolean LOGV = false;
-
- // Sides
- private static final int MOVE_LEFT = 1;
- private static final int MOVE_TOP = 2;
- private static final int MOVE_RIGHT = 4;
- private static final int MOVE_BOTTOM = 8;
- private static final int MOVE_BLOCK = 16;
-
- // Corners
- private static final int TOP_LEFT = MOVE_TOP | MOVE_LEFT;
- private static final int TOP_RIGHT = MOVE_TOP | MOVE_RIGHT;
- private static final int BOTTOM_RIGHT = MOVE_BOTTOM | MOVE_RIGHT;
- private static final int BOTTOM_LEFT = MOVE_BOTTOM | MOVE_LEFT;
-
- private static int mMinSideSize = 100;
- private static int mTouchTolerance = 45;
-
- private boolean mFirstDraw = true;
- private float mAspectWidth = 1;
- private float mAspectHeight = 1;
- private boolean mFixAspectRatio = false;
-
- private float mLastRot = 0;
-
- private BoundedRect mBounded = null;
- private int movingEdges;
- private final Drawable cropIndicator;
- private final int indicatorSize;
- private final int mBorderColor = Color.argb(128, 255, 255, 255);
-
- // Offset between crop center and photo center
- private float[] mOffset = {
- 0, 0
- };
- private CropExtras mCropExtras = null;
- private boolean mDoingCropIntentAction = false;
-
- private static final String LOGTAG = "ImageCrop";
-
- private String mAspect = "";
- private static int mAspectTextSize = 24;
-
- private boolean mFixedAspect = false;
-
- private EditorCrop mEditorCrop;
-
- public static void setAspectTextSize(int textSize) {
- mAspectTextSize = textSize;
+public class ImageCrop extends ImageShow {
+ private static final String TAG = ImageCrop.class.getSimpleName();
+ private RectF mImageBounds = new RectF();
+ private RectF mScreenCropBounds = new RectF();
+ private Paint mPaint = new Paint();
+ private CropObject mCropObj = null;
+ private GeometryHolder mGeometry = new GeometryHolder();
+ private GeometryHolder mUpdateHolder = new GeometryHolder();
+ private Drawable mCropIndicator;
+ private int mIndicatorSize;
+ private boolean mMovingBlock = false;
+ private Matrix mDisplayMatrix = null;
+ private Matrix mDisplayCropMatrix = null;
+ private Matrix mDisplayMatrixInverse = null;
+ private float mPrevX = 0;
+ private float mPrevY = 0;
+ private int mMinSideSize = 90;
+ private int mTouchTolerance = 40;
+ private enum Mode {
+ NONE, MOVE
}
-
- public void setAspectString(String a) {
- mAspect = a;
- }
-
- private static final Paint gPaint = new Paint();
+ private Mode mState = Mode.NONE;
+ private boolean mValidDraw = false;
+ FilterCropRepresentation mLocalRep = new FilterCropRepresentation();
+ EditorCrop mEditorCrop;
public ImageCrop(Context context) {
super(context);
- Resources resources = context.getResources();
- cropIndicator = resources.getDrawable(R.drawable.camera_crop);
- indicatorSize = (int) resources.getDimension(R.dimen.crop_indicator_size);
+ setup(context);
}
public ImageCrop(Context context, AttributeSet attrs) {
super(context, attrs);
- Resources resources = context.getResources();
- cropIndicator = resources.getDrawable(R.drawable.camera_crop);
- indicatorSize = (int) resources.getDimension(R.dimen.crop_indicator_size);
+ setup(context);
+ }
+
+ public ImageCrop(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ setup(context);
+ }
+
+ private void setup(Context context) {
+ Resources rsc = context.getResources();
+ mCropIndicator = rsc.getDrawable(R.drawable.camera_crop);
+ mIndicatorSize = (int) rsc.getDimension(R.dimen.crop_indicator_size);
+ mMinSideSize = (int) rsc.getDimension(R.dimen.crop_min_side);
+ mTouchTolerance = (int) rsc.getDimension(R.dimen.crop_touch_tolerance);
+ }
+
+ public void setFilterCropRepresentation(FilterCropRepresentation crop) {
+ mLocalRep = (crop == null) ? new FilterCropRepresentation() : crop;
+ GeometryMathUtils.initializeHolder(mUpdateHolder, mLocalRep);
+ mValidDraw = true;
+ }
+
+ public FilterCropRepresentation getFinalRepresentation() {
+ return mLocalRep;
+ }
+
+ private void internallyUpdateLocalRep(RectF crop, RectF image) {
+ FilterCropRepresentation
+ .findNormalizedCrop(crop, (int) image.width(), (int) image.height());
+ mGeometry.crop.set(crop);
+ mUpdateHolder.set(mGeometry);
+ mLocalRep.setCrop(crop);
}
@Override
- public String getName() {
- return getContext().getString(R.string.crop);
- }
-
- private void swapAspect() {
- if (mDoingCropIntentAction) {
- return;
+ public boolean onTouchEvent(MotionEvent event) {
+ float x = event.getX();
+ float y = event.getY();
+ if (mDisplayMatrix == null || mDisplayMatrixInverse == null) {
+ return true;
}
- float temp = mAspectWidth;
- mAspectWidth = mAspectHeight;
- mAspectHeight = temp;
- }
-
- /**
- * Set tolerance for crop marker selection (in pixels)
- */
- public static void setTouchTolerance(int tolerance) {
- mTouchTolerance = tolerance;
- }
-
- /**
- * Set minimum side length for crop box (in pixels)
- */
- public static void setMinCropSize(int minHeightWidth) {
- mMinSideSize = minHeightWidth;
- }
-
- public void setExtras(CropExtras e) {
- mCropExtras = e;
- }
-
- public void setCropActionFlag(boolean f) {
- mDoingCropIntentAction = f;
- }
-
- public void apply(float w, float h) {
- mFixAspectRatio = true;
- mAspectWidth = w;
- mAspectHeight = h;
- setLocalCropBounds(getUntranslatedStraightenCropBounds(getLocalPhotoBounds(),
- getLocalStraighten()));
- cropSetup();
- saveAndSetPreset();
- invalidate();
- }
-
- public void applyOriginal() {
- mFixAspectRatio = true;
- RectF photobounds = getLocalPhotoBounds();
- float w = photobounds.width();
- float h = photobounds.height();
- float scale = Math.min(w, h);
- mAspectWidth = w / scale;
- mAspectHeight = h / scale;
- setLocalCropBounds(getUntranslatedStraightenCropBounds(photobounds,
- getLocalStraighten()));
- cropSetup();
- saveAndSetPreset();
- invalidate();
- }
-
- public void applyClear() {
- mFixAspectRatio = false;
- mAspectWidth = 1;
- mAspectHeight = 1;
- setLocalCropBounds(getUntranslatedStraightenCropBounds(getLocalPhotoBounds(),
- getLocalStraighten()));
- cropSetup();
- saveAndSetPreset();
- invalidate();
- }
-
- public void clear() {
- if (mCropExtras != null) {
- int x = mCropExtras.getAspectX();
- int y = mCropExtras.getAspectY();
- if (mDoingCropIntentAction && x > 0 && y > 0) {
- apply(x, y);
- }
- } else {
- applyClear();
+ float[] touchPoint = {
+ x, y
+ };
+ mDisplayMatrixInverse.mapPoints(touchPoint);
+ x = touchPoint[0];
+ y = touchPoint[1];
+ switch (event.getActionMasked()) {
+ case (MotionEvent.ACTION_DOWN):
+ if (mState == Mode.NONE) {
+ if (!mCropObj.selectEdge(x, y)) {
+ mMovingBlock = mCropObj.selectEdge(CropObject.MOVE_BLOCK);
+ }
+ mPrevX = x;
+ mPrevY = y;
+ mState = Mode.MOVE;
+ }
+ break;
+ case (MotionEvent.ACTION_UP):
+ if (mState == Mode.MOVE) {
+ mCropObj.selectEdge(CropObject.MOVE_NONE);
+ mMovingBlock = false;
+ mPrevX = x;
+ mPrevY = y;
+ mState = Mode.NONE;
+ internallyUpdateLocalRep(mCropObj.getInnerBounds(), mCropObj.getOuterBounds());
+ }
+ break;
+ case (MotionEvent.ACTION_MOVE):
+ if (mState == Mode.MOVE) {
+ float dx = x - mPrevX;
+ float dy = y - mPrevY;
+ mCropObj.moveCurrentSelection(dx, dy);
+ mPrevX = x;
+ mPrevY = y;
+ }
+ break;
+ default:
+ break;
}
- }
-
- private Matrix getPhotoBoundDisplayedMatrix() {
- float[] displayCenter = new float[2];
- RectF scaledCrop = new RectF();
- RectF scaledPhoto = new RectF();
- float scale = getTransformState(scaledPhoto, scaledCrop, displayCenter);
- Matrix m = GeometryMetadata.buildCenteredPhotoMatrix(scaledPhoto, scaledCrop,
- getLocalRotation(), getLocalStraighten(), getLocalFlip(), displayCenter);
- m.preScale(scale, scale);
- return m;
- }
-
- private Matrix getCropBoundDisplayedMatrix() {
- float[] displayCenter = new float[2];
- RectF scaledCrop = new RectF();
- RectF scaledPhoto = new RectF();
- float scale = getTransformState(scaledPhoto, scaledCrop, displayCenter);
- Matrix m1 = GeometryMetadata.buildWanderingCropMatrix(scaledPhoto, scaledCrop,
- getLocalRotation(), getLocalStraighten(), getLocalFlip(), displayCenter);
- m1.preScale(scale, scale);
- return m1;
- }
-
- /**
- * Takes the rotated corners of a rectangle and returns the angle; sets
- * unrotated to be the unrotated version of the rectangle.
- */
- private static float getUnrotated(float[] rotatedRect, float[] center, RectF unrotated) {
- float dy = rotatedRect[1] - rotatedRect[3];
- float dx = rotatedRect[0] - rotatedRect[2];
- float angle = (float) (Math.atan(dy / dx) * 180 / Math.PI);
- Matrix m = new Matrix();
- m.setRotate(-angle, center[0], center[1]);
- float[] unrotatedRect = new float[rotatedRect.length];
- m.mapPoints(unrotatedRect, rotatedRect);
- unrotated.set(CropMath.trapToRect(unrotatedRect));
- return angle;
- }
-
- /**
- * Sets cropped bounds; modifies the bounds if it's smaller than the allowed
- * dimensions.
- */
- public boolean setCropBounds(RectF bounds) {
- RectF cbounds = new RectF(bounds);
- Matrix mc = getCropBoundDisplayedMatrix();
- Matrix mcInv = new Matrix();
- mc.invert(mcInv);
- mcInv.mapRect(cbounds);
- // Avoid cropping smaller than minimum
- float newWidth = cbounds.width();
- float newHeight = cbounds.height();
- float scale = getTransformState(null, null, null);
- float minWidthHeight = mMinSideSize / scale;
- RectF pbounds = getLocalPhotoBounds();
-
- // if photo is smaller than minimum, refuse to set crop bounds
- if (pbounds.width() < minWidthHeight || pbounds.height() < minWidthHeight) {
- return false;
- }
-
- // if incoming crop is smaller than minimum, refuse to set crop bounds
- if (newWidth < minWidthHeight || newHeight < minWidthHeight) {
- return false;
- }
-
- float newX = bounds.centerX() - (getWidth() / 2f);
- float newY = bounds.centerY() - (getHeight() / 2f);
- mOffset[0] = newX;
- mOffset[1] = newY;
-
- setLocalCropBounds(cbounds);
invalidate();
return true;
}
- private BoundedRect getBoundedCrop(RectF crop) {
- RectF photo = getLocalPhotoBounds();
- Matrix mp = getPhotoBoundDisplayedMatrix();
- float[] photoCorners = CropMath.getCornersFromRect(photo);
- float[] photoCenter = {
- photo.centerX(), photo.centerY()
- };
- mp.mapPoints(photoCorners);
- mp.mapPoints(photoCenter);
- RectF scaledPhoto = new RectF();
- float angle = getUnrotated(photoCorners, photoCenter, scaledPhoto);
- return new BoundedRect(angle, scaledPhoto, crop);
+ private void clearDisplay() {
+ mDisplayMatrix = null;
+ mDisplayMatrixInverse = null;
+ invalidate();
}
- private void detectMovingEdges(float x, float y) {
- Matrix m = getCropBoundDisplayedMatrix();
- RectF cropped = getLocalCropBounds();
- m.mapRect(cropped);
- mBounded = getBoundedCrop(cropped);
- movingEdges = 0;
+ public void applyFreeAspect() {
+ mCropObj.unsetAspectRatio();
+ invalidate();
+ }
- float left = Math.abs(x - cropped.left);
- float right = Math.abs(x - cropped.right);
- float top = Math.abs(y - cropped.top);
- float bottom = Math.abs(y - cropped.bottom);
-
- // Check left or right.
- if ((left <= mTouchTolerance) && ((y + mTouchTolerance) >= cropped.top)
- && ((y - mTouchTolerance) <= cropped.bottom) && (left < right)) {
- movingEdges |= MOVE_LEFT;
- }
- else if ((right <= mTouchTolerance) && ((y + mTouchTolerance) >= cropped.top)
- && ((y - mTouchTolerance) <= cropped.bottom)) {
- movingEdges |= MOVE_RIGHT;
- }
-
- // Check top or bottom.
- if ((top <= mTouchTolerance) && ((x + mTouchTolerance) >= cropped.left)
- && ((x - mTouchTolerance) <= cropped.right) && (top < bottom)) {
- movingEdges |= MOVE_TOP;
- }
- else if ((bottom <= mTouchTolerance) && ((x + mTouchTolerance) >= cropped.left)
- && ((x - mTouchTolerance) <= cropped.right)) {
- movingEdges |= MOVE_BOTTOM;
- }
- if (movingEdges == 0) {
- movingEdges = MOVE_BLOCK;
- }
- if (mFixAspectRatio && (movingEdges != MOVE_BLOCK)) {
- movingEdges = fixEdgeToCorner(movingEdges);
+ public void applyOriginalAspect() {
+ RectF outer = mCropObj.getOuterBounds();
+ float w = outer.width();
+ float h = outer.height();
+ if (w > 0 && h > 0) {
+ applyAspect(w, h);
+ mCropObj.resetBoundsTo(outer, outer);
+ internallyUpdateLocalRep(mCropObj.getInnerBounds(), mCropObj.getOuterBounds());
+ } else {
+ Log.w(TAG, "failed to set aspect ratio original");
}
invalidate();
}
- private int fixEdgeToCorner(int moving_edges) {
- if (moving_edges == MOVE_LEFT) {
- moving_edges |= MOVE_TOP;
+ public void applyAspect(float x, float y) {
+ if (x <= 0 || y <= 0) {
+ throw new IllegalArgumentException("Bad arguments to applyAspect");
}
- if (moving_edges == MOVE_TOP) {
- moving_edges |= MOVE_LEFT;
+ // If we are rotated by 90 degrees from horizontal, swap x and y
+ if (GeometryMathUtils.needsDimensionSwap(mGeometry.rotation)) {
+ float tmp = x;
+ x = y;
+ y = tmp;
}
- if (moving_edges == MOVE_RIGHT) {
- moving_edges |= MOVE_BOTTOM;
+ if (!mCropObj.setInnerAspectRatio(x, y)) {
+ Log.w(TAG, "failed to set aspect ratio");
}
- if (moving_edges == MOVE_BOTTOM) {
- moving_edges |= MOVE_RIGHT;
- }
- return moving_edges;
+ internallyUpdateLocalRep(mCropObj.getInnerBounds(), mCropObj.getOuterBounds());
+ invalidate();
}
- private RectF fixedCornerResize(RectF r, int moving_corner, float dx, float dy) {
- RectF newCrop = null;
- // Fix opposite corner in place and move sides
- if (moving_corner == BOTTOM_RIGHT) {
- newCrop = new RectF(r.left, r.top, r.left + r.width() + dx, r.top + r.height()
- + dy);
- } else if (moving_corner == BOTTOM_LEFT) {
- newCrop = new RectF(r.right - r.width() + dx, r.top, r.right, r.top + r.height()
- + dy);
- } else if (moving_corner == TOP_LEFT) {
- newCrop = new RectF(r.right - r.width() + dx, r.bottom - r.height() + dy,
- r.right, r.bottom);
- } else if (moving_corner == TOP_RIGHT) {
- newCrop = new RectF(r.left, r.bottom - r.height() + dy, r.left
- + r.width() + dx, r.bottom);
+ /**
+ * Rotates first d bits in integer x to the left some number of times.
+ */
+ private int bitCycleLeft(int x, int times, int d) {
+ int mask = (1 << d) - 1;
+ int mout = x & mask;
+ times %= d;
+ int hi = mout >> (d - times);
+ int low = (mout << times) & mask;
+ int ret = x & ~mask;
+ ret |= low;
+ ret |= hi;
+ return ret;
+ }
+
+ /**
+ * Find the selected edge or corner in screen coordinates.
+ */
+ private int decode(int movingEdges, float rotation) {
+ int rot = CropMath.constrainedRotation(rotation);
+ switch (rot) {
+ case 90:
+ return bitCycleLeft(movingEdges, 1, 4);
+ case 180:
+ return bitCycleLeft(movingEdges, 2, 4);
+ case 270:
+ return bitCycleLeft(movingEdges, 3, 4);
+ default:
+ return movingEdges;
}
- return newCrop;
}
- private void moveEdges(float dX, float dY) {
- RectF crop = mBounded.getInner();
-
- Matrix mc = getCropBoundDisplayedMatrix();
-
- RectF photo = getLocalPhotoBounds();
- Matrix mp = getPhotoBoundDisplayedMatrix();
- float[] photoCorners = CropMath.getCornersFromRect(photo);
- float[] photoCenter = {
- photo.centerX(), photo.centerY()
- };
- mp.mapPoints(photoCorners);
- mp.mapPoints(photoCenter);
-
- float minWidthHeight = mMinSideSize;
-
- if (movingEdges == MOVE_BLOCK) {
- mBounded.moveInner(-dX, -dY);
- RectF r = mBounded.getInner();
- setCropBounds(r);
- return;
- } else {
- float dx = 0;
- float dy = 0;
-
- if ((movingEdges & MOVE_LEFT) != 0) {
- dx = Math.min(crop.left + dX, crop.right - minWidthHeight) - crop.left;
- }
- if ((movingEdges & MOVE_TOP) != 0) {
- dy = Math.min(crop.top + dY, crop.bottom - minWidthHeight) - crop.top;
- }
- if ((movingEdges & MOVE_RIGHT) != 0) {
- dx = Math.max(crop.right + dX, crop.left + minWidthHeight)
- - crop.right;
- }
- if ((movingEdges & MOVE_BOTTOM) != 0) {
- dy = Math.max(crop.bottom + dY, crop.top + minWidthHeight)
- - crop.bottom;
- }
-
- if (mFixAspectRatio) {
- float[] l1 = {
- crop.left, crop.bottom
- };
- float[] l2 = {
- crop.right, crop.top
- };
- if (movingEdges == TOP_LEFT || movingEdges == BOTTOM_RIGHT) {
- l1[1] = crop.top;
- l2[1] = crop.bottom;
- }
- float[] b = {
- l1[0] - l2[0], l1[1] - l2[1]
- };
- float[] disp = {
- dx, dy
- };
- float[] bUnit = GeometryMath.normalize(b);
- float sp = GeometryMath.scalarProjection(disp, bUnit);
- dx = sp * bUnit[0];
- dy = sp * bUnit[1];
- RectF newCrop = fixedCornerResize(crop, movingEdges, dx, dy);
-
- mBounded.fixedAspectResizeInner(newCrop);
- newCrop = mBounded.getInner();
- setCropBounds(newCrop);
- return;
- } else {
- if ((movingEdges & MOVE_LEFT) != 0) {
- crop.left += dx;
- }
- if ((movingEdges & MOVE_TOP) != 0) {
- crop.top += dy;
- }
- if ((movingEdges & MOVE_RIGHT) != 0) {
- crop.right += dx;
- }
- if ((movingEdges & MOVE_BOTTOM) != 0) {
- crop.bottom += dy;
- }
- }
+ private void forceStateConsistency() {
+ MasterImage master = MasterImage.getImage();
+ Bitmap image = master.getFiltersOnlyImage();
+ int width = image.getWidth();
+ int height = image.getHeight();
+ if (mCropObj == null || !mUpdateHolder.equals(mGeometry)
+ || mImageBounds.width() != width || mImageBounds.height() != height
+ || !mLocalRep.getCrop().equals(mUpdateHolder.crop)) {
+ mImageBounds.set(0, 0, width, height);
+ mGeometry.set(mUpdateHolder);
+ mLocalRep.setCrop(mUpdateHolder.crop);
+ RectF scaledCrop = new RectF(mUpdateHolder.crop);
+ FilterCropRepresentation.findScaledCrop(scaledCrop, width, height);
+ mCropObj = new CropObject(mImageBounds, scaledCrop, (int) mUpdateHolder.straighten);
+ mState = Mode.NONE;
+ clearDisplay();
}
- mBounded.resizeInner(crop);
- crop = mBounded.getInner();
- setCropBounds(crop);
- }
-
- private void drawIndicator(Canvas canvas, Drawable indicator, float centerX, float centerY) {
- int left = (int) centerX - indicatorSize / 2;
- int top = (int) centerY - indicatorSize / 2;
- indicator.setBounds(left, top, left + indicatorSize, top + indicatorSize);
- indicator.draw(canvas);
- }
-
- @Override
- protected void setActionDown(float x, float y) {
- super.setActionDown(x, y);
- detectMovingEdges(x + mOffset[0], y + mOffset[1]);
-
- }
-
- @Override
- protected void setActionUp() {
- super.setActionUp();
- movingEdges = 0;
- }
-
- @Override
- protected void setActionMove(float x, float y) {
-
- if (movingEdges != 0) {
- moveEdges(x - mCurrentX, y - mCurrentY);
- }
- super.setActionMove(x, y);
-
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- setActionUp();
- cropSetup();
- invalidate();
- }
-
- private void cropSetup() {
- RectF crop = getLocalCropBounds();
- Matrix m = getCropBoundDisplayedMatrix();
- m.mapRect(crop);
- if (mFixAspectRatio) {
- CropMath.fixAspectRatio(crop, mAspectWidth, mAspectHeight);
- }
- float dCentX = getWidth() / 2;
- float dCentY = getHeight() / 2;
-
- BoundedRect r = getBoundedCrop(crop);
- crop = r.getInner();
- if (!setCropBounds(crop)) {
- float h = mMinSideSize / 2;
- float wScale = 1;
- float hScale = mAspectHeight / mAspectWidth;
- if (hScale < 1) {
- wScale = mAspectWidth / mAspectHeight;
- hScale = 1;
- }
- crop.set(dCentX - h * wScale, dCentY - h * hScale, dCentX + h * wScale, dCentY + h
- * hScale);
- if (mFixAspectRatio) {
- CropMath.fixAspectRatio(crop, mAspectWidth, mAspectHeight);
- }
- r.setInner(crop);
- crop = r.getInner();
- if (!setCropBounds(crop)) {
- crop.set(dCentX - h, dCentY - h, dCentX + h, dCentY + h);
- r.setInner(crop);
- crop = r.getInner();
- setCropBounds(crop);
- }
- }
+ super.onSizeChanged(w, h, oldw, oldh);
+ clearDisplay();
}
@Override
- public void imageLoaded() {
- super.imageLoaded();
- syncLocalToMasterGeometry();
- clear();
- invalidate();
- }
-
- @Override
- protected void gainedVisibility() {
- float rot = getLocalRotation();
- // if has changed orientation via rotate
- if (((int) ((rot - mLastRot) / 90)) % 2 != 0) {
- swapAspect();
+ public void onDraw(Canvas canvas) {
+ Bitmap bitmap = MasterImage.getImage().getFiltersOnlyImage();
+ if (bitmap == null) {
+ MasterImage.getImage().invalidateFiltersOnly();
}
- cropSetup();
- mFirstDraw = true;
- }
-
- @Override
- public void resetParameter() {
- super.resetParameter();
- }
-
- @Override
- protected void lostVisibility() {
- mLastRot = getLocalRotation();
- }
-
- private void drawRuleOfThird(Canvas canvas, RectF bounds, Paint p) {
- float stepX = bounds.width() / 3.0f;
- float stepY = bounds.height() / 3.0f;
- float x = bounds.left + stepX;
- float y = bounds.top + stepY;
- for (int i = 0; i < 2; i++) {
- canvas.drawLine(x, bounds.top, x, bounds.bottom, p);
- x += stepX;
+ if (!mValidDraw || bitmap == null) {
+ return;
}
- for (int j = 0; j < 2; j++) {
- canvas.drawLine(bounds.left, y, bounds.right, y, p);
- y += stepY;
+ forceStateConsistency();
+ mImageBounds.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
+ // If display matrix doesn't exist, create it and its dependencies
+ if (mDisplayCropMatrix == null || mDisplayMatrix == null || mDisplayMatrixInverse == null) {
+ mDisplayMatrix = GeometryMathUtils.getFullGeometryToScreenMatrix(mGeometry,
+ bitmap.getWidth(), bitmap.getHeight(), canvas.getWidth(), canvas.getHeight());
+ float straighten = mGeometry.straighten;
+ mGeometry.straighten = 0;
+ mDisplayCropMatrix = GeometryMathUtils.getFullGeometryToScreenMatrix(mGeometry,
+ bitmap.getWidth(), bitmap.getHeight(), canvas.getWidth(), canvas.getHeight());
+ mGeometry.straighten = straighten;
+ mDisplayMatrixInverse = new Matrix();
+ mDisplayMatrixInverse.reset();
+ if (!mDisplayCropMatrix.invert(mDisplayMatrixInverse)) {
+ Log.w(TAG, "could not invert display matrix");
+ mDisplayMatrixInverse = null;
+ return;
+ }
+ // Scale min side and tolerance by display matrix scale factor
+ mCropObj.setMinInnerSideSize(mDisplayMatrixInverse.mapRadius(mMinSideSize));
+ mCropObj.setTouchTolerance(mDisplayMatrixInverse.mapRadius(mTouchTolerance));
+ // drive Crop engine to clamp to crop bounds
+ int[] sides = {CropObject.MOVE_TOP,
+ CropObject.MOVE_BOTTOM,
+ CropObject.MOVE_LEFT,
+ CropObject.MOVE_RIGHT};
+ int delta = Math.min(canvas.getWidth(), canvas.getHeight()) / 4;
+ int[] dy = {delta, -delta, 0, 0};
+ int[] dx = {0, 0, delta, -delta};
+
+ for (int i = 0; i < sides.length; i++) {
+ mCropObj.selectEdge(sides[i]);
+
+ mCropObj.moveCurrentSelection(dx[i], dy[i]);
+ mCropObj.moveCurrentSelection(-dx[i], -dy[i]);
+ }
+ mCropObj.selectEdge(CropObject.MOVE_NONE);
}
- }
-
- @Override
- protected void drawShape(Canvas canvas, Bitmap image) {
- gPaint.setAntiAlias(true);
- gPaint.setARGB(255, 255, 255, 255);
-
- if (mFirstDraw) {
- cropSetup();
- mFirstDraw = false;
+ // Draw actual bitmap
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setFilterBitmap(true);
+ canvas.drawBitmap(bitmap, mDisplayMatrix, mPaint);
+ mCropObj.getInnerBounds(mScreenCropBounds);
+ RectF outer = mCropObj.getOuterBounds();
+ FilterCropRepresentation.findNormalizedCrop(mScreenCropBounds, (int) outer.width(),
+ (int) outer.height());
+ FilterCropRepresentation.findScaledCrop(mScreenCropBounds, bitmap.getWidth(),
+ bitmap.getHeight());
+ if (mDisplayCropMatrix.mapRect(mScreenCropBounds)) {
+ // Draw crop rect and markers
+ CropDrawingUtils.drawCropRect(canvas, mScreenCropBounds);
+ CropDrawingUtils.drawShade(canvas, mScreenCropBounds);
+ CropDrawingUtils.drawRuleOfThird(canvas, mScreenCropBounds);
+ CropDrawingUtils.drawIndicators(canvas, mCropIndicator, mIndicatorSize,
+ mScreenCropBounds, mCropObj.isFixedAspect(),
+ decode(mCropObj.getSelectState(), mGeometry.rotation.value()));
}
-
- RectF crop = drawTransformed(canvas, image, gPaint, mOffset);
- gPaint.setColor(mBorderColor);
- gPaint.setStrokeWidth(3);
- gPaint.setStyle(Paint.Style.STROKE);
-
- boolean doThirds = true;
-
- if (mFixAspectRatio) {
- float spotlightX = 0;
- float spotlightY = 0;
- if (mCropExtras != null) {
- spotlightX = mCropExtras.getSpotlightX();
- spotlightY = mCropExtras.getSpotlightY();
- }
- if (mDoingCropIntentAction && spotlightX > 0 && spotlightY > 0) {
- float sx = crop.width() * spotlightX;
- float sy = crop.height() * spotlightY;
- float cx = crop.centerX();
- float cy = crop.centerY();
- RectF r1 = new RectF(cx - sx / 2, cy - sy / 2, cx + sx / 2, cy + sy / 2);
- float temp = sx;
- sx = sy;
- sy = temp;
- RectF r2 = new RectF(cx - sx / 2, cy - sy / 2, cx + sx / 2, cy + sy / 2);
- canvas.drawRect(r1, gPaint);
- canvas.drawRect(r2, gPaint);
- doThirds = false;
- } else {
- float w = crop.width();
- float h = crop.height();
- float diag = (float) Math.sqrt(w * w + h * h);
-
- float dash_len = 20;
- int num_intervals = (int) (diag / dash_len);
- float[] tl = {
- crop.left, crop.top
- };
- float centX = tl[0] + w / 2;
- float centY = tl[1] + h / 2 + 5;
- float[] br = {
- crop.right, crop.bottom
- };
- float[] vec = GeometryMath.getUnitVectorFromPoints(tl, br);
-
- float[] counter = tl;
- for (int x = 0; x < num_intervals; x++) {
- float tempX = counter[0] + vec[0] * dash_len;
- float tempY = counter[1] + vec[1] * dash_len;
- if ((x % 2) == 0 && Math.abs(x - num_intervals / 2) > 2) {
- canvas.drawLine(counter[0], counter[1], tempX, tempY, gPaint);
- }
- counter[0] = tempX;
- counter[1] = tempY;
- }
-
- gPaint.setTextAlign(Paint.Align.CENTER);
- gPaint.setTextSize(mAspectTextSize);
- canvas.drawText(mAspect, centX, centY, gPaint);
- }
- }
-
- if (doThirds) {
- drawRuleOfThird(canvas, crop, gPaint);
-
- }
-
- RectF scaledCrop = crop;
- boolean notMoving = (movingEdges == 0);
- if (mFixAspectRatio) {
- if ((movingEdges == TOP_LEFT) || notMoving) {
- drawIndicator(canvas, cropIndicator, scaledCrop.left, scaledCrop.top);
- }
- if ((movingEdges == TOP_RIGHT) || notMoving) {
- drawIndicator(canvas, cropIndicator, scaledCrop.right, scaledCrop.top);
- }
- if ((movingEdges == BOTTOM_LEFT) || notMoving) {
- drawIndicator(canvas, cropIndicator, scaledCrop.left, scaledCrop.bottom);
- }
- if ((movingEdges == BOTTOM_RIGHT) || notMoving) {
- drawIndicator(canvas, cropIndicator, scaledCrop.right, scaledCrop.bottom);
- }
- } else {
- if (((movingEdges & MOVE_TOP) != 0) || notMoving) {
- drawIndicator(canvas, cropIndicator, scaledCrop.centerX(), scaledCrop.top);
- }
- if (((movingEdges & MOVE_BOTTOM) != 0) || notMoving) {
- drawIndicator(canvas, cropIndicator, scaledCrop.centerX(), scaledCrop.bottom);
- }
- if (((movingEdges & MOVE_LEFT) != 0) || notMoving) {
- drawIndicator(canvas, cropIndicator, scaledCrop.left, scaledCrop.centerY());
- }
- if (((movingEdges & MOVE_RIGHT) != 0) || notMoving) {
- drawIndicator(canvas, cropIndicator, scaledCrop.right, scaledCrop.centerY());
- }
- }
- }
-
- public void setAspectButton(int itemId) {
- switch (itemId) {
- case R.id.crop_menu_1to1: {
- String t = getActivity().getString(R.string.aspect1to1_effect);
- apply(1, 1);
- setAspectString(t);
- break;
- }
- case R.id.crop_menu_4to3: {
- String t = getActivity().getString(R.string.aspect4to3_effect);
- apply(4, 3);
- setAspectString(t);
- break;
- }
- case R.id.crop_menu_3to4: {
- String t = getActivity().getString(R.string.aspect3to4_effect);
- apply(3, 4);
- setAspectString(t);
- break;
- }
- case R.id.crop_menu_5to7: {
- String t = getActivity().getString(R.string.aspect5to7_effect);
- apply(5, 7);
- setAspectString(t);
- break;
- }
- case R.id.crop_menu_7to5: {
- String t = getActivity().getString(R.string.aspect7to5_effect);
- apply(7, 5);
- setAspectString(t);
- break;
- }
- case R.id.crop_menu_none: {
- String t = getActivity().getString(R.string.aspectNone_effect);
- applyClear();
- setAspectString(t);
- break;
- }
- case R.id.crop_menu_original: {
- String t = getActivity().getString(R.string.aspectOriginal_effect);
- applyOriginal();
- setAspectString(t);
- break;
- }
- }
- invalidate();
- }
-
- public void setFixedAspect(boolean fixedAspect) {
- mFixedAspect = fixedAspect;
- }
-
- @Override
- public boolean useUtilityPanel() {
- // Only shows the aspect ratio popup if we are not fixed
- return !mFixedAspect;
}
public void setEditor(EditorCrop editorCrop) {
mEditorCrop = editorCrop;
}
-
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java
new file mode 100644
index 0000000..0d20322
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java
@@ -0,0 +1,447 @@
+/*
+ * 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.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
+import android.os.AsyncTask;
+import android.util.AttributeSet;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.PopupMenu;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.editors.Editor;
+import com.android.gallery3d.filtershow.editors.EditorCurves;
+import com.android.gallery3d.filtershow.filters.FilterCurvesRepresentation;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.filters.ImageFilterCurves;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+
+import java.util.HashMap;
+
+public class ImageCurves extends ImageShow {
+
+ private static final String LOGTAG = "ImageCurves";
+ Paint gPaint = new Paint();
+ Path gPathSpline = new Path();
+ HashMap<Integer, String> mIdStrLut;
+
+ private int mCurrentCurveIndex = Spline.RGB;
+ private boolean mDidAddPoint = false;
+ private boolean mDidDelete = false;
+ private ControlPoint mCurrentControlPoint = null;
+ private int mCurrentPick = -1;
+ private ImagePreset mLastPreset = null;
+ int[] redHistogram = new int[256];
+ int[] greenHistogram = new int[256];
+ int[] blueHistogram = new int[256];
+ Path gHistoPath = new Path();
+
+ boolean mDoingTouchMove = false;
+ private EditorCurves mEditorCurves;
+ private FilterCurvesRepresentation mFilterCurvesRepresentation;
+
+ public ImageCurves(Context context) {
+ super(context);
+ setLayerType(LAYER_TYPE_SOFTWARE, gPaint);
+ resetCurve();
+ }
+
+ public ImageCurves(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setLayerType(LAYER_TYPE_SOFTWARE, gPaint);
+ resetCurve();
+ }
+
+ @Override
+ protected boolean enableComparison() {
+ return false;
+ }
+
+ @Override
+ public boolean useUtilityPanel() {
+ return true;
+ }
+
+ private void showPopupMenu(LinearLayout accessoryViewList) {
+ final Button button = (Button) accessoryViewList.findViewById(
+ R.id.applyEffect);
+ if (button == null) {
+ return;
+ }
+ if (mIdStrLut == null){
+ mIdStrLut = new HashMap<Integer, String>();
+ mIdStrLut.put(R.id.curve_menu_rgb,
+ getContext().getString(R.string.curves_channel_rgb));
+ mIdStrLut.put(R.id.curve_menu_red,
+ getContext().getString(R.string.curves_channel_red));
+ mIdStrLut.put(R.id.curve_menu_green,
+ getContext().getString(R.string.curves_channel_green));
+ mIdStrLut.put(R.id.curve_menu_blue,
+ getContext().getString(R.string.curves_channel_blue));
+ }
+ PopupMenu popupMenu = new PopupMenu(getActivity(), button);
+ popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_curves, popupMenu.getMenu());
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ setChannel(item.getItemId());
+ button.setText(mIdStrLut.get(item.getItemId()));
+ return true;
+ }
+ });
+ Editor.hackFixStrings(popupMenu.getMenu());
+ popupMenu.show();
+ ((FilterShowActivity)getContext()).onShowMenu(popupMenu);
+ }
+
+ @Override
+ public void openUtilityPanel(final LinearLayout accessoryViewList) {
+ Context context = accessoryViewList.getContext();
+ Button view = (Button) accessoryViewList.findViewById(R.id.applyEffect);
+ view.setText(context.getString(R.string.curves_channel_rgb));
+ view.setVisibility(View.VISIBLE);
+
+ view.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ showPopupMenu(accessoryViewList);
+ }
+ });
+
+ if (view != null) {
+ view.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void nextChannel() {
+ mCurrentCurveIndex = ((mCurrentCurveIndex + 1) % 4);
+ invalidate();
+ }
+
+ private ImageFilterCurves curves() {
+ String filterName = getFilterName();
+ ImagePreset p = getImagePreset();
+ if (p != null) {
+ return (ImageFilterCurves) FiltersManager.getManager().getFilter(ImageFilterCurves.class);
+ }
+ return null;
+ }
+
+ private Spline getSpline(int index) {
+ return mFilterCurvesRepresentation.getSpline(index);
+ }
+
+ @Override
+ public void resetParameter() {
+ super.resetParameter();
+ resetCurve();
+ mLastPreset = null;
+ invalidate();
+ }
+
+ public void resetCurve() {
+ if (mFilterCurvesRepresentation != null) {
+ mFilterCurvesRepresentation.reset();
+ updateCachedImage();
+ }
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ if (mFilterCurvesRepresentation == null) {
+ return;
+ }
+
+ gPaint.setAntiAlias(true);
+
+ if (getImagePreset() != mLastPreset && getFilteredImage() != null) {
+ new ComputeHistogramTask().execute(getFilteredImage());
+ mLastPreset = getImagePreset();
+ }
+
+ if (curves() == null) {
+ return;
+ }
+
+ if (mCurrentCurveIndex == Spline.RGB || mCurrentCurveIndex == Spline.RED) {
+ drawHistogram(canvas, redHistogram, Color.RED, PorterDuff.Mode.SCREEN);
+ }
+ if (mCurrentCurveIndex == Spline.RGB || mCurrentCurveIndex == Spline.GREEN) {
+ drawHistogram(canvas, greenHistogram, Color.GREEN, PorterDuff.Mode.SCREEN);
+ }
+ if (mCurrentCurveIndex == Spline.RGB || mCurrentCurveIndex == Spline.BLUE) {
+ drawHistogram(canvas, blueHistogram, Color.BLUE, PorterDuff.Mode.SCREEN);
+ }
+ // We only display the other channels curves when showing the RGB curve
+ if (mCurrentCurveIndex == Spline.RGB) {
+ for (int i = 0; i < 4; i++) {
+ Spline spline = getSpline(i);
+ if (i != mCurrentCurveIndex && !spline.isOriginal()) {
+ // And we only display a curve if it has more than two
+ // points
+ spline.draw(canvas, Spline.colorForCurve(i), getWidth(),
+ getHeight(), false, mDoingTouchMove);
+ }
+ }
+ }
+ // ...but we always display the current curve.
+ getSpline(mCurrentCurveIndex)
+ .draw(canvas, Spline.colorForCurve(mCurrentCurveIndex), getWidth(), getHeight(),
+ true, mDoingTouchMove);
+
+ }
+
+ private int pickControlPoint(float x, float y) {
+ int pick = 0;
+ Spline spline = getSpline(mCurrentCurveIndex);
+ float px = spline.getPoint(0).x;
+ float py = spline.getPoint(0).y;
+ double delta = Math.sqrt((px - x) * (px - x) + (py - y) * (py - y));
+ for (int i = 1; i < spline.getNbPoints(); i++) {
+ px = spline.getPoint(i).x;
+ py = spline.getPoint(i).y;
+ double currentDelta = Math.sqrt((px - x) * (px - x) + (py - y)
+ * (py - y));
+ if (currentDelta < delta) {
+ delta = currentDelta;
+ pick = i;
+ }
+ }
+
+ if (!mDidAddPoint && (delta * getWidth() > 100)
+ && (spline.getNbPoints() < 10)) {
+ return -1;
+ }
+
+ return pick;
+ }
+
+ private String getFilterName() {
+ return "Curves";
+ }
+
+ @Override
+ public synchronized boolean onTouchEvent(MotionEvent e) {
+ if (e.getPointerCount() != 1) {
+ return true;
+ }
+
+ if (didFinishScalingOperation()) {
+ return true;
+ }
+
+ float margin = Spline.curveHandleSize() / 2;
+ float posX = e.getX();
+ if (posX < margin) {
+ posX = margin;
+ }
+ float posY = e.getY();
+ if (posY < margin) {
+ posY = margin;
+ }
+ if (posX > getWidth() - margin) {
+ posX = getWidth() - margin;
+ }
+ if (posY > getHeight() - margin) {
+ posY = getHeight() - margin;
+ }
+ posX = (posX - margin) / (getWidth() - 2 * margin);
+ posY = (posY - margin) / (getHeight() - 2 * margin);
+
+ if (e.getActionMasked() == MotionEvent.ACTION_UP) {
+ mCurrentControlPoint = null;
+ mCurrentPick = -1;
+ updateCachedImage();
+ mDidAddPoint = false;
+ if (mDidDelete) {
+ mDidDelete = false;
+ }
+ mDoingTouchMove = false;
+ return true;
+ }
+
+ if (mDidDelete) {
+ return true;
+ }
+
+ if (curves() == null) {
+ return true;
+ }
+
+ if (e.getActionMasked() == MotionEvent.ACTION_MOVE) {
+ mDoingTouchMove = true;
+ Spline spline = getSpline(mCurrentCurveIndex);
+ int pick = mCurrentPick;
+ if (mCurrentControlPoint == null) {
+ pick = pickControlPoint(posX, posY);
+ if (pick == -1) {
+ mCurrentControlPoint = new ControlPoint(posX, posY);
+ pick = spline.addPoint(mCurrentControlPoint);
+ mDidAddPoint = true;
+ } else {
+ mCurrentControlPoint = spline.getPoint(pick);
+ }
+ mCurrentPick = pick;
+ }
+
+ if (spline.isPointContained(posX, pick)) {
+ spline.movePoint(pick, posX, posY);
+ } else if (pick != -1 && spline.getNbPoints() > 2) {
+ spline.deletePoint(pick);
+ mDidDelete = true;
+ }
+ updateCachedImage();
+ invalidate();
+ }
+ return true;
+ }
+
+ public synchronized void updateCachedImage() {
+ if (getImagePreset() != null) {
+ resetImageCaches(this);
+ if (mEditorCurves != null) {
+ mEditorCurves.commitLocalRepresentation();
+ }
+ invalidate();
+ }
+ }
+
+ class ComputeHistogramTask extends AsyncTask<Bitmap, Void, int[]> {
+ @Override
+ protected int[] doInBackground(Bitmap... params) {
+ int[] histo = new int[256 * 3];
+ Bitmap bitmap = params[0];
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
+ int[] pixels = new int[w * h];
+ bitmap.getPixels(pixels, 0, w, 0, 0, w, h);
+ for (int i = 0; i < w; i++) {
+ for (int j = 0; j < h; j++) {
+ int index = j * w + i;
+ int r = Color.red(pixels[index]);
+ int g = Color.green(pixels[index]);
+ int b = Color.blue(pixels[index]);
+ histo[r]++;
+ histo[256 + g]++;
+ histo[512 + b]++;
+ }
+ }
+ return histo;
+ }
+
+ @Override
+ protected void onPostExecute(int[] result) {
+ System.arraycopy(result, 0, redHistogram, 0, 256);
+ System.arraycopy(result, 256, greenHistogram, 0, 256);
+ System.arraycopy(result, 512, blueHistogram, 0, 256);
+ invalidate();
+ }
+ }
+
+ private void drawHistogram(Canvas canvas, int[] histogram, int color, PorterDuff.Mode mode) {
+ int max = 0;
+ for (int i = 0; i < histogram.length; i++) {
+ if (histogram[i] > max) {
+ max = histogram[i];
+ }
+ }
+ float w = getWidth() - Spline.curveHandleSize();
+ float h = getHeight() - Spline.curveHandleSize() / 2.0f;
+ float dx = Spline.curveHandleSize() / 2.0f;
+ float wl = w / histogram.length;
+ float wh = (0.3f * h) / max;
+ Paint paint = new Paint();
+ paint.setARGB(100, 255, 255, 255);
+ paint.setStrokeWidth((int) Math.ceil(wl));
+
+ Paint paint2 = new Paint();
+ paint2.setColor(color);
+ paint2.setStrokeWidth(6);
+ paint2.setXfermode(new PorterDuffXfermode(mode));
+ gHistoPath.reset();
+ gHistoPath.moveTo(dx, h);
+ boolean firstPointEncountered = false;
+ float prev = 0;
+ float last = 0;
+ for (int i = 0; i < histogram.length; i++) {
+ float x = i * wl + dx;
+ float l = histogram[i] * wh;
+ if (l != 0) {
+ float v = h - (l + prev) / 2.0f;
+ if (!firstPointEncountered) {
+ gHistoPath.lineTo(x, h);
+ firstPointEncountered = true;
+ }
+ gHistoPath.lineTo(x, v);
+ prev = l;
+ last = x;
+ }
+ }
+ gHistoPath.lineTo(last, h);
+ gHistoPath.lineTo(w, h);
+ gHistoPath.close();
+ canvas.drawPath(gHistoPath, paint2);
+ paint2.setStrokeWidth(2);
+ paint2.setStyle(Paint.Style.STROKE);
+ paint2.setARGB(255, 200, 200, 200);
+ canvas.drawPath(gHistoPath, paint2);
+ }
+
+ public void setChannel(int itemId) {
+ switch (itemId) {
+ case R.id.curve_menu_rgb: {
+ mCurrentCurveIndex = Spline.RGB;
+ break;
+ }
+ case R.id.curve_menu_red: {
+ mCurrentCurveIndex = Spline.RED;
+ break;
+ }
+ case R.id.curve_menu_green: {
+ mCurrentCurveIndex = Spline.GREEN;
+ break;
+ }
+ case R.id.curve_menu_blue: {
+ mCurrentCurveIndex = Spline.BLUE;
+ break;
+ }
+ }
+ mEditorCurves.commitLocalRepresentation();
+ invalidate();
+ }
+
+ public void setEditor(EditorCurves editorCurves) {
+ mEditorCurves = editorCurves;
+ }
+
+ public void setFilterDrawRepresentation(FilterCurvesRepresentation drawRep) {
+ mFilterCurvesRepresentation = drawRep;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java b/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
index 8fcc028..795a247 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
@@ -2,13 +2,25 @@
package com.android.gallery3d.filtershow.imageshow;
import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
+import android.graphics.RectF;
+import android.graphics.Shader;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.NinePatchDrawable;
+import android.os.Handler;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.editors.EditorDraw;
import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilterDraw;
@@ -22,24 +34,72 @@
private byte mType = 0;
private FilterDrawRepresentation mFRep;
private EditorDraw mEditorDraw;
+ private long mTimeout;
+ private Paint mCheckerdPaint = makeCheckedPaint();
+ private Paint mShadowPaint = new Paint();
+ private Paint mIconPaint = new Paint();
+ private Paint mBorderPaint = new Paint();
+ private Handler mHandler;
+ private FilterDrawRepresentation.StrokeData mTmpStrokData =
+ new FilterDrawRepresentation.StrokeData();
+ private Bitmap mBitmap;
+ private float mDisplayRound;
+ private float mDisplayBorder;
+ private int DISPLAY_TIME = 500;
+ private Matrix mRotateToScreen = new Matrix();
+ private Matrix mToOrig;
+ private int mBorderColor;
+ private int mBorderShadowSize;
+ private NinePatchDrawable mShadow;
+
+ Runnable mUpdateRunnable = new Runnable() {
+ @Override
+ public void run() {
+ invalidate();
+ }
+ };
+
public ImageDraw(Context context, AttributeSet attrs) {
super(context, attrs);
resetParameter();
- super.setOriginalDisabled(true);
+ setupConstants(context);
+ setupTimer();
}
public ImageDraw(Context context) {
super(context);
resetParameter();
- super.setOriginalDisabled(true);
+ setupConstants(context);
+ setupTimer();
+ }
+
+ private void setupConstants(Context context){
+ Resources res = context.getResources();
+ mDisplayRound = res.getDimensionPixelSize(R.dimen.draw_rect_round);
+ mDisplayBorder = res.getDimensionPixelSize(R.dimen.draw_rect_border);
+ mBorderShadowSize = res.getDimensionPixelSize(R.dimen.draw_rect_shadow);
+ float edge = res.getDimensionPixelSize(R.dimen.draw_rect_border_edge);
+
+ mBorderColor = res.getColor(R.color.draw_rect_border);
+ mBorderPaint.setColor(mBorderColor);
+ mBorderPaint.setStyle(Paint.Style.STROKE);
+ mBorderPaint.setStrokeWidth(edge);
+ mShadowPaint.setStyle(Paint.Style.FILL);
+ mShadowPaint.setColor(Color.BLACK);
+ mShadowPaint.setShadowLayer(mBorderShadowSize,mBorderShadowSize,
+ mBorderShadowSize,Color.BLACK);
+ mShadow = (NinePatchDrawable) res.getDrawable(R.drawable.geometry_shadow);
}
public void setEditor(EditorDraw editorDraw) {
mEditorDraw = editorDraw;
}
+
public void setFilterDrawRepresentation(FilterDrawRepresentation fr) {
mFRep = fr;
+ mTmpStrokData =
+ new FilterDrawRepresentation.StrokeData();
}
public Drawable getIcon(Context context) {
@@ -74,12 +134,6 @@
return (int) mCurrentSize;
}
- @Override
- public void updateImage() {
- super.updateImage();
- invalidate();
- }
-
float[] mTmpPoint = new float[2]; // so we do not malloc
@Override
public boolean onTouchEvent(MotionEvent event) {
@@ -97,20 +151,17 @@
}
}
- ImageFilterDraw filter = (ImageFilterDraw) getCurrentFilter();
-
if (event.getAction() == MotionEvent.ACTION_DOWN) {
calcScreenMapping();
mTmpPoint[0] = event.getX();
mTmpPoint[1] = event.getY();
mToOrig.mapPoints(mTmpPoint);
- mFRep.startNewSection(mType, mCurrentColor, mCurrentSize, mTmpPoint[0], mTmpPoint[1]);
+ mFRep.startNewSection( mTmpPoint[0], mTmpPoint[1]);
}
if (event.getAction() == MotionEvent.ACTION_MOVE) {
int historySize = event.getHistorySize();
- final int pointerCount = event.getPointerCount();
for (int h = 0; h < historySize; h++) {
int p = 0;
{
@@ -133,18 +184,107 @@
return true;
}
- Matrix mRotateToScreen = new Matrix();
- Matrix mToOrig;
private void calcScreenMapping() {
mToOrig = getScreenToImageMatrix(true);
mToOrig.invert(mRotateToScreen);
}
+ private static Paint makeCheckedPaint(){
+ int[] colors = new int[16 * 16];
+ for (int i = 0; i < colors.length; i++) {
+ int y = i / (16 * 8);
+ int x = (i / 8) % 2;
+ colors[i] = (x == y) ? 0xFF777777 : 0xFF222222;
+ }
+ Bitmap bitmap = Bitmap.createBitmap(colors, 16, 16, Bitmap.Config.ARGB_8888);
+ BitmapShader bs = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+ Paint p = new Paint();
+ p.setShader(bs);
+ return p;
+ }
+
+ private void setupTimer() {
+ mHandler = new Handler(getActivity().getMainLooper());
+ }
+
+ private void scheduleWakeup(int delay) {
+ mHandler.removeCallbacks(mUpdateRunnable);
+ mHandler.postDelayed(mUpdateRunnable, delay);
+ }
+
+ public Bitmap getBrush(int brushid) {
+ Bitmap bitmap;
+ BitmapFactory.Options opt = new BitmapFactory.Options();
+ opt.inPreferredConfig = Bitmap.Config.ALPHA_8;
+ bitmap = BitmapFactory.decodeResource(getActivity().getResources(), brushid, opt);
+ bitmap = bitmap.extractAlpha();
+
+ return bitmap;
+ }
+
+ public Bitmap createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter) {
+ Matrix m = new Matrix();
+ m.setScale(dstWidth / (float) src.getWidth(), dstHeight / (float) src.getHeight());
+ Bitmap result = Bitmap.createBitmap(dstWidth, dstHeight, src.getConfig());
+ Canvas canvas = new Canvas(result);
+
+ Paint paint = new Paint();
+ paint.setFilterBitmap(filter);
+ canvas.drawBitmap(src, m, paint);
+
+ return result;
+
+ }
+
+ public void displayDrawLook() {
+ if (mFRep == null) {
+ return;
+ }
+ int color = mTmpStrokData.mColor;
+ byte type = mTmpStrokData.mType;
+ float radius = mTmpStrokData.mRadius;
+ mFRep.fillStrokeParameters(mTmpStrokData);
+
+ if (radius != mTmpStrokData.mRadius) {
+ mTimeout = DISPLAY_TIME + System.currentTimeMillis();
+ scheduleWakeup(DISPLAY_TIME);
+ }
+ }
+
+ public void drawLook(Canvas canvas) {
+ if (mFRep == null) {
+ return;
+ }
+ int cw = canvas.getWidth();
+ int ch = canvas.getHeight();
+ int centerx = cw / 2;
+ int centery = ch / 2;
+
+// mFRep.fillStrokeParameters(mTmpStrokData);
+ mIconPaint.setAntiAlias(true);
+ mIconPaint.setStyle(Paint.Style.STROKE);
+ float rad = mRotateToScreen.mapRadius(mTmpStrokData.mRadius);
+
+ RectF rec = new RectF();
+ rec.set(centerx - rad,
+ centery - rad,
+ centerx + rad,
+ centery + rad);
+ mIconPaint.setColor(Color.BLACK);
+ mIconPaint.setStrokeWidth(5);
+ canvas.drawArc(rec, 0, 360, true, mIconPaint);
+ mIconPaint.setColor(Color.WHITE);
+ mIconPaint.setStrokeWidth(3);
+ canvas.drawArc(rec, 0, 360, true, mIconPaint);
+ }
+
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
calcScreenMapping();
-
+ if (System.currentTimeMillis() < mTimeout) {
+ drawLook(canvas);
+ }
}
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageFlip.java b/src/com/android/gallery3d/filtershow/imageshow/ImageFlip.java
deleted file mode 100644
index 15197b0..0000000
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageFlip.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.imageshow;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.RectF;
-import android.util.AttributeSet;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.editors.EditorFlip;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata.FLIP;
-
-public class ImageFlip extends ImageGeometry {
-
- private static final Paint gPaint = new Paint();
- private static final float MIN_FLICK_DIST_FOR_FLIP = 0.1f;
- private static final String LOGTAG = "ImageFlip";
- private FLIP mNextFlip = FLIP.NONE;
- private EditorFlip mEditorFlip;
-
- public ImageFlip(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public ImageFlip(Context context) {
- super(context);
- }
-
- @Override
- public String getName() {
- return getContext().getString(R.string.mirror);
- }
-
- @Override
- protected void setActionDown(float x, float y) {
- super.setActionDown(x, y);
- }
-
- boolean hasRotated90(){
- int rot = constrainedRotation(getLocalRotation());
- return (rot / 90) % 2 != 0;
- }
-
- public void flip() {
- FLIP flip = getLocalFlip();
- boolean next = true;
- // Picks next flip in order from enum FLIP (wrapping)
- for (FLIP f : FLIP.values()) {
- if (next) {
- mNextFlip = f;
- next = false;
- }
- if (f.equals(flip)) {
- next = true;
- }
- }
- setLocalFlip(mNextFlip);
- }
-
- @Override
- protected void setActionMove(float x, float y) {
- super.setActionMove(x, y);
-
- float diffx = mTouchCenterX - x;
- float diffy = mTouchCenterY - y;
- float flick = getScaledMinFlick();
- if(hasRotated90()){
- float temp = diffx;
- diffx = diffy;
- diffy = temp;
- }
- if (Math.abs(diffx) >= flick) {
- // flick moving left/right
- FLIP flip = getLocalFlip();
- switch (flip) {
- case NONE:
- flip = FLIP.HORIZONTAL;
- break;
- case HORIZONTAL:
- flip = FLIP.NONE;
- break;
- case VERTICAL:
- flip = FLIP.BOTH;
- break;
- case BOTH:
- flip = FLIP.VERTICAL;
- break;
- default:
- flip = FLIP.NONE;
- break;
- }
- mNextFlip = flip;
- }
- if (Math.abs(diffy) >= flick) {
- // flick moving up/down
- FLIP flip = getLocalFlip();
- switch (flip) {
- case NONE:
- flip = FLIP.VERTICAL;
- break;
- case VERTICAL:
- flip = FLIP.NONE;
- break;
- case HORIZONTAL:
- flip = FLIP.BOTH;
- break;
- case BOTH:
- flip = FLIP.HORIZONTAL;
- break;
- default:
- flip = FLIP.NONE;
- break;
- }
- mNextFlip = flip;
- }
- }
-
- @Override
- protected void setActionUp() {
- super.setActionUp();
- setLocalFlip(mNextFlip);
- }
-
- @Override
- public void resetParameter() {
- super.resetParameter();
- mNextFlip = FLIP.NONE;
- }
-
- private float getScaledMinFlick() {
- RectF disp = getLocalDisplayBounds();
- float scaled = Math.min(disp.width(), disp.height()) * MIN_FLICK_DIST_FOR_FLIP
- / getLocalScale();
- return scaled;
- }
-
- @Override
- protected void drawShape(Canvas canvas, Bitmap image) {
- gPaint.setAntiAlias(true);
- gPaint.setARGB(255, 255, 255, 255);
- drawTransformedCropped(canvas, image, gPaint);
- }
-
- public void setEditor(EditorFlip editorFlip) {
- mEditorFlip = editorFlip;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java b/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java
deleted file mode 100644
index 0c51b16..0000000
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageGeometry.java
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.imageshow;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.Path;
-import android.graphics.RectF;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata.FLIP;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-
-public abstract class ImageGeometry extends ImageShow {
- protected boolean mVisibilityGained = false;
- private boolean mHasDrawn = false;
-
- protected static final float MAX_STRAIGHTEN_ANGLE = 45;
- protected static final float MIN_STRAIGHTEN_ANGLE = -45;
-
- protected float mCenterX;
- protected float mCenterY;
-
- protected float mCurrentX;
- protected float mCurrentY;
- protected float mTouchCenterX;
- protected float mTouchCenterY;
-
- // Local geometry data
- private GeometryMetadata mLocalGeometry = null;
- private RectF mLocalDisplayBounds = null;
- protected float mXOffset = 0;
- protected float mYOffset = 0;
-
- protected enum MODES {
- NONE, DOWN, UP, MOVE
- }
-
- protected MODES mMode = MODES.NONE;
-
- private static final String LOGTAG = "ImageGeometry";
-
- public ImageGeometry(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public ImageGeometry(Context context) {
- super(context);
- }
-
- private void setupLocalDisplayBounds(RectF b) {
- mLocalDisplayBounds = b;
- calculateLocalScalingFactorAndOffset();
- }
-
- protected static float angleFor(float dx, float dy) {
- return (float) (Math.atan2(dx, dy) * 180 / Math.PI);
- }
-
- protected static int snappedAngle(float angle) {
- float remainder = angle % 90;
- int current = (int) (angle / 90); // truncates
- if (remainder < -45) {
- --current;
- } else if (remainder > 45) {
- ++current;
- }
- return current * 90;
- }
-
- protected float getCurrentTouchAngle() {
- if (mCurrentX == mTouchCenterX && mCurrentY == mTouchCenterY) {
- return 0;
- }
- float dX1 = mTouchCenterX - mCenterX;
- float dY1 = mTouchCenterY - mCenterY;
- float dX2 = mCurrentX - mCenterX;
- float dY2 = mCurrentY - mCenterY;
-
- float angleA = angleFor(dX1, dY1);
- float angleB = angleFor(dX2, dY2);
- return (angleB - angleA) % 360;
- }
-
- protected float computeScale(float width, float height) {
- float imageWidth = mLocalGeometry.getPhotoBounds().width();
- float imageHeight = mLocalGeometry.getPhotoBounds().height();
- return GeometryMath.scale(imageWidth, imageHeight, width, height);
- }
-
- private void calculateLocalScalingFactorAndOffset() {
- if (mLocalGeometry == null || mLocalDisplayBounds == null)
- return;
- RectF imageBounds = mLocalGeometry.getPhotoBounds();
- float imageWidth = imageBounds.width();
- float imageHeight = imageBounds.height();
- float displayWidth = mLocalDisplayBounds.width();
- float displayHeight = mLocalDisplayBounds.height();
-
- mCenterX = displayWidth / 2;
- mCenterY = displayHeight / 2;
- mYOffset = (displayHeight - imageHeight) / 2.0f;
- mXOffset = (displayWidth - imageWidth) / 2.0f;
- updateScale();
- }
-
- @Override
- public void resetParameter() {
- super.resetParameter();
- setLocalRotation(0);
- setLocalStraighten(0);
- setLocalCropBounds(getLocalPhotoBounds());
- setLocalFlip(FLIP.NONE);
- saveAndSetPreset();
- invalidate();
- }
-
- // Overwrites local with master
- public void syncLocalToMasterGeometry() {
- mLocalGeometry = getGeometry();
- calculateLocalScalingFactorAndOffset();
- }
-
- protected RectF getLocalPhotoBounds() {
- return mLocalGeometry.getPhotoBounds();
- }
-
- protected RectF getLocalCropBounds() {
- return mLocalGeometry.getPreviewCropBounds();
- }
-
- protected RectF getLocalDisplayBounds() {
- return new RectF(mLocalDisplayBounds);
- }
-
- protected float getLocalScale() {
- return mLocalGeometry.getScaleFactor();
- }
-
- protected float getLocalRotation() {
- return mLocalGeometry.getRotation();
- }
-
- protected float getLocalStraighten() {
- return mLocalGeometry.getStraightenRotation();
- }
-
- protected void setLocalScale(float s) {
- mLocalGeometry.setScaleFactor(s);
- }
-
- protected void updateScale() {
- RectF bounds = getUntranslatedStraightenCropBounds(mLocalGeometry.getPhotoBounds(),
- getLocalStraighten());
- float zoom = computeScale(bounds.width(), bounds.height());
- setLocalScale(zoom);
- }
-
- protected void setLocalRotation(float r) {
- mLocalGeometry.setRotation(r);
- updateScale();
- }
-
- /**
- * Constrains rotation to be in [0, 90, 180, 270].
- */
- protected int constrainedRotation(float rotation) {
- int r = (int) ((rotation % 360) / 90);
- r = (r < 0) ? (r + 4) : r;
- return r * 90;
- }
-
- protected boolean isHeightWidthSwapped() {
- return ((int) (getLocalRotation() / 90)) % 2 != 0;
- }
-
- protected void setLocalStraighten(float r) {
- mLocalGeometry.setStraightenRotation(r);
- updateScale();
- }
-
- protected void setLocalCropBounds(RectF c) {
- mLocalGeometry.setCropBounds(c);
- updateScale();
- }
-
- protected FLIP getLocalFlip() {
- return mLocalGeometry.getFlipType();
- }
-
- protected void setLocalFlip(FLIP flip) {
- mLocalGeometry.setFlipType(flip);
- }
-
- protected float getTotalLocalRotation() {
- return getLocalRotation() + getLocalStraighten();
- }
-
- protected static Path drawClosedPath(Canvas canvas, Paint paint, float[] points) {
- Path crop = new Path();
- crop.moveTo(points[0], points[1]);
- crop.lineTo(points[2], points[3]);
- crop.lineTo(points[4], points[5]);
- crop.lineTo(points[6], points[7]);
- crop.close();
- canvas.drawPath(crop, paint);
- return crop;
- }
-
- protected static float getNewHeightForWidthAspect(float width, float w, float h) {
- return width * h / w;
- }
-
- protected static float getNewWidthForHeightAspect(float height, float w, float h) {
- return height * w / h;
- }
-
- @Override
- protected void onVisibilityChanged(View changedView, int visibility) {
- super.onVisibilityChanged(changedView, visibility);
- if (visibility == View.VISIBLE) {
- mVisibilityGained = true;
- MasterImage.getImage().invalidateFiltersOnly();
- syncLocalToMasterGeometry();
- updateScale();
- gainedVisibility();
- } else {
- if (mVisibilityGained == true && mHasDrawn == true) {
- lostVisibility();
- }
- mVisibilityGained = false;
- mHasDrawn = false;
- }
- }
-
- protected void gainedVisibility() {
- // Override this stub.
- }
-
- protected void lostVisibility() {
- // Override this stub.
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- setupLocalDisplayBounds(new RectF(0, 0, w, h));
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- switch (event.getActionMasked()) {
- case (MotionEvent.ACTION_DOWN):
- setActionDown(event.getX(), event.getY());
- break;
- case (MotionEvent.ACTION_UP):
- setActionUp();
- saveAndSetPreset();
- break;
- case (MotionEvent.ACTION_MOVE):
- setActionMove(event.getX(), event.getY());
- break;
- default:
- setNoAction();
- }
- invalidate();
- return true;
- }
-
- protected int getLocalValue() {
- return 0; // Override this
- }
-
- protected void setActionDown(float x, float y) {
- mTouchCenterX = x;
- mTouchCenterY = y;
- mCurrentX = x;
- mCurrentY = y;
- mMode = MODES.DOWN;
- }
-
- protected void setActionMove(float x, float y) {
- mCurrentX = x;
- mCurrentY = y;
- mMode = MODES.MOVE;
- }
-
- protected void setActionUp() {
- mMode = MODES.UP;
- }
-
- protected void setNoAction() {
- mMode = MODES.NONE;
- }
-
- @Override
- public boolean showTitle() {
- return false;
- }
-
- public String getName() {
- return "Geometry";
- }
-
- public void saveAndSetPreset() {
- ImagePreset lastHistoryItem = MasterImage.getImage().getHistory().getLast();
- if (lastHistoryItem != null && lastHistoryItem.historyName().equalsIgnoreCase(getName())) {
- getImagePreset().setGeometry(mLocalGeometry);
- resetImageCaches(this);
- } else {
- if (mLocalGeometry.hasModifications()) {
- ImagePreset copy = new ImagePreset(getImagePreset());
- copy.setGeometry(mLocalGeometry);
- copy.setHistoryName(getName());
- copy.setIsFx(false);
- MasterImage.getImage().setPreset(copy, true);
- }
- }
- invalidate();
- }
-
- public static RectF getUntranslatedStraightenCropBounds(RectF imageRect, float straightenAngle) {
- float deg = straightenAngle;
- if (deg < 0) {
- deg = -deg;
- }
- double a = Math.toRadians(deg);
- double sina = Math.sin(a);
- double cosa = Math.cos(a);
-
- double rw = imageRect.width();
- double rh = imageRect.height();
- double h1 = rh * rh / (rw * sina + rh * cosa);
- double h2 = rh * rw / (rw * cosa + rh * sina);
- double hh = Math.min(h1, h2);
- double ww = hh * rw / rh;
-
- float left = (float) ((rw - ww) * 0.5f);
- float top = (float) ((rh - hh) * 0.5f);
- float right = (float) (left + ww);
- float bottom = (float) (top + hh);
-
- return new RectF(left, top, right, bottom);
- }
-
- protected RectF straightenBounds() {
- RectF bounds = getUntranslatedStraightenCropBounds(getLocalPhotoBounds(),
- getLocalStraighten());
- float scale = computeScale(getWidth(), getHeight());
- bounds = GeometryMath.scaleRect(bounds, scale);
- float dx = (getWidth() / 2) - bounds.centerX();
- float dy = (getHeight() / 2) - bounds.centerY();
- bounds.offset(dx, dy);
- return bounds;
- }
-
- protected static void drawRotatedShadows(Canvas canvas, Paint p, RectF innerBounds,
- RectF outerBounds,
- float rotation, float centerX, float centerY) {
- canvas.save();
- canvas.rotate(rotation, centerX, centerY);
-
- float x = (outerBounds.left - outerBounds.right);
- float y = (outerBounds.top - outerBounds.bottom);
- float longest = (float) Math.sqrt(x * x + y * y) / 2;
- float minX = centerX - longest;
- float maxX = centerX + longest;
- float minY = centerY - longest;
- float maxY = centerY + longest;
- canvas.drawRect(minX, minY, innerBounds.right, innerBounds.top, p);
- canvas.drawRect(minX, innerBounds.top, innerBounds.left, maxY, p);
- canvas.drawRect(innerBounds.left, innerBounds.bottom, maxX, maxY,
- p);
- canvas.drawRect(innerBounds.right, minY, maxX,
- innerBounds.bottom, p);
- canvas.rotate(-rotation, centerX, centerY);
- canvas.restore();
- }
-
- protected void drawShadows(Canvas canvas, Paint p, RectF innerBounds) {
- float w = getWidth();
- float h = getHeight();
- canvas.drawRect(0f, 0f, w, innerBounds.top, p);
- canvas.drawRect(0f, innerBounds.top, innerBounds.left, innerBounds.bottom, p);
- canvas.drawRect(innerBounds.right, innerBounds.top, w, innerBounds.bottom, p);
- canvas.drawRect(0f, innerBounds.bottom, w, h, p);
- }
-
- @Override
- public void onDraw(Canvas canvas) {
- if (getDirtyGeometryFlag()) {
- syncLocalToMasterGeometry();
- clearDirtyGeometryFlag();
- }
- Bitmap image = getFiltersOnlyImage();
- if (image == null) {
- invalidate();
- return;
- }
- mHasDrawn = true;
-
- drawShape(canvas, image);
- }
-
- protected void drawShape(Canvas canvas, Bitmap image) {
- // TODO: Override this stub.
- }
-
- /**
- * Sets up inputs for buildCenteredPhotoMatrix and buildWanderingCropMatrix
- * and returns the scale factor.
- */
- protected float getTransformState(RectF photo, RectF crop, float[] displayCenter) {
- RectF photoBounds = getLocalPhotoBounds();
- RectF cropBounds = getLocalCropBounds();
- float scale = computeScale(getWidth(), getHeight());
- // checks if local rotation is an odd multiple of 90.
- if (isHeightWidthSwapped()) {
- scale = computeScale(getHeight(), getWidth());
- }
- // put in screen coordinates
- if (crop != null) {
- crop.set(GeometryMath.scaleRect(cropBounds, scale));
- }
- if (photo != null) {
- photo.set(GeometryMath.scaleRect(photoBounds, scale));
- }
- if (displayCenter != null && displayCenter.length >= 2) {
- displayCenter[0] = getWidth() / 2f;
- displayCenter[1] = getHeight() / 2f;
- }
- return scale;
- }
-
- protected RectF drawTransformed(Canvas canvas, Bitmap photo, Paint p, float[] offset) {
- p.setARGB(255, 0, 0, 0);
- float[] displayCenter = new float[2];
- RectF scaledCrop = new RectF();
- RectF scaledPhoto = new RectF();
- float scale = getTransformState(scaledPhoto, scaledCrop, displayCenter);
- Matrix m = GeometryMetadata.buildCenteredPhotoMatrix(scaledPhoto, scaledCrop,
- getLocalRotation(), getLocalStraighten(), getLocalFlip(), displayCenter);
-
- Matrix m1 = GeometryMetadata.buildWanderingCropMatrix(scaledPhoto, scaledCrop,
- getLocalRotation(), getLocalStraighten(), getLocalFlip(), displayCenter);
- m1.mapRect(scaledCrop);
- Path path = new Path();
- scaledCrop.offset(-offset[0], -offset[1]);
- path.addRect(scaledCrop, Path.Direction.CCW);
-
- m.preScale(scale, scale);
- m.postTranslate(-offset[0], -offset[1]);
- canvas.save();
- canvas.drawBitmap(photo, m, p);
- canvas.restore();
-
- p.setColor(Color.WHITE);
- p.setStyle(Style.STROKE);
- p.setStrokeWidth(2);
- canvas.drawPath(path, p);
-
- p.setColor(getDefaultBackgroundColor());
- p.setAlpha(128);
- p.setStyle(Paint.Style.FILL);
- drawShadows(canvas, p, scaledCrop);
- return scaledCrop;
- }
-
- protected void drawTransformedCropped(Canvas canvas, Bitmap photo, Paint p) {
- RectF photoBounds = getLocalPhotoBounds();
- RectF cropBounds = getLocalCropBounds();
- float imageWidth = cropBounds.width();
- float imageHeight = cropBounds.height();
- float scale = GeometryMath.scale(imageWidth, imageHeight, getWidth(), getHeight());
- // checks if local rotation is an odd multiple of 90.
- if (isHeightWidthSwapped()) {
- scale = GeometryMath.scale(imageWidth, imageHeight, getHeight(), getWidth());
- }
- // put in screen coordinates
- RectF scaledCrop = GeometryMath.scaleRect(cropBounds, scale);
- RectF scaledPhoto = GeometryMath.scaleRect(photoBounds, scale);
- float[] displayCenter = {
- getWidth() / 2f, getHeight() / 2f
- };
- Matrix m1 = GeometryMetadata.buildWanderingCropMatrix(scaledPhoto, scaledCrop,
- getLocalRotation(), getLocalStraighten(), getLocalFlip(), displayCenter);
- float[] cropCenter = {
- scaledCrop.centerX(), scaledCrop.centerY()
- };
- m1.mapPoints(cropCenter);
- GeometryMetadata.concatRecenterMatrix(m1, cropCenter, displayCenter);
- m1.preRotate(getLocalStraighten(), scaledPhoto.centerX(), scaledPhoto.centerY());
- m1.preScale(scale, scale);
-
- p.setARGB(255, 0, 0, 0);
- canvas.save();
- canvas.drawBitmap(photo, m1, p);
- canvas.restore();
-
- p.setColor(getDefaultBackgroundColor());
- p.setStyle(Paint.Style.FILL);
- scaledCrop.offset(displayCenter[0] - scaledCrop.centerX(), displayCenter[1]
- - scaledCrop.centerY());
- RectF display = new RectF(0, 0, getWidth(), getHeight());
- drawRotatedShadows(canvas, p, scaledCrop, display, getLocalRotation(), getWidth() / 2,
- getHeight() / 2);
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageGrad.java b/src/com/android/gallery3d/filtershow/imageshow/ImageGrad.java
new file mode 100644
index 0000000..b55cc2b
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageGrad.java
@@ -0,0 +1,215 @@
+package com.android.gallery3d.filtershow.imageshow;
+/*
+ * 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.
+ */
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.EditorGrad;
+import com.android.gallery3d.filtershow.filters.FilterGradRepresentation;
+
+public class ImageGrad extends ImageShow {
+ private static final String LOGTAG = "ImageGrad";
+ private FilterGradRepresentation mGradRep;
+ private EditorGrad mEditorGrad;
+ private float mMinTouchDist;
+ private int mActiveHandle = -1;
+ private GradControl mEllipse;
+
+ Matrix mToScr = new Matrix();
+ float[] mPointsX = new float[FilterGradRepresentation.MAX_POINTS];
+ float[] mPointsY = new float[FilterGradRepresentation.MAX_POINTS];
+
+ public ImageGrad(Context context) {
+ super(context);
+ Resources res = context.getResources();
+ mMinTouchDist = res.getDimensionPixelSize(R.dimen.gradcontrol_min_touch_dist);
+ mEllipse = new GradControl(context);
+ mEllipse.setShowReshapeHandles(false);
+ }
+
+ public ImageGrad(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ Resources res = context.getResources();
+ mMinTouchDist = res.getDimensionPixelSize(R.dimen.gradcontrol_min_touch_dist);
+ mEllipse = new GradControl(context);
+ mEllipse.setShowReshapeHandles(false);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ int mask = event.getActionMasked();
+
+ if (mActiveHandle == -1) {
+ if (MotionEvent.ACTION_DOWN != mask) {
+ return super.onTouchEvent(event);
+ }
+ if (event.getPointerCount() == 1) {
+ mActiveHandle = mEllipse.getCloseHandle(event.getX(), event.getY());
+ if (mActiveHandle == -1) {
+ float x = event.getX();
+ float y = event.getY();
+ float min_d = Float.MAX_VALUE;
+ int pos = -1;
+ for (int i = 0; i < mPointsX.length; i++) {
+ if (mPointsX[i] == -1) {
+ continue;
+ }
+ float d = (float) Math.hypot(x - mPointsX[i], y - mPointsY[i]);
+ if ( min_d > d) {
+ min_d = d;
+ pos = i;
+ }
+ }
+ if (min_d > mMinTouchDist){
+ pos = -1;
+ }
+
+ if (pos != -1) {
+ mGradRep.setSelectedPoint(pos);
+ resetImageCaches(this);
+ mEditorGrad.updateSeekBar(mGradRep);
+ mEditorGrad.commitLocalRepresentation();
+ invalidate();
+ }
+ }
+ }
+ if (mActiveHandle == -1) {
+ return super.onTouchEvent(event);
+ }
+ } else {
+ switch (mask) {
+ case MotionEvent.ACTION_UP: {
+
+ mActiveHandle = -1;
+ break;
+ }
+ case MotionEvent.ACTION_DOWN: {
+ break;
+ }
+ }
+ }
+ float x = event.getX();
+ float y = event.getY();
+
+ mEllipse.setScrImageInfo(getScreenToImageMatrix(true),
+ MasterImage.getImage().getOriginalBounds());
+
+ switch (mask) {
+ case (MotionEvent.ACTION_DOWN): {
+ mEllipse.actionDown(x, y, mGradRep);
+ break;
+ }
+ case (MotionEvent.ACTION_UP):
+ case (MotionEvent.ACTION_MOVE): {
+ mEllipse.actionMove(mActiveHandle, x, y, mGradRep);
+ setRepresentation(mGradRep);
+ break;
+ }
+ }
+ invalidate();
+ mEditorGrad.commitLocalRepresentation();
+ return true;
+ }
+
+ public void setRepresentation(FilterGradRepresentation pointRep) {
+ mGradRep = pointRep;
+ Matrix toImg = getScreenToImageMatrix(false);
+
+ toImg.invert(mToScr);
+
+ float[] c1 = new float[] { mGradRep.getPoint1X(), mGradRep.getPoint1Y() };
+ float[] c2 = new float[] { mGradRep.getPoint2X(), mGradRep.getPoint2Y() };
+
+ if (c1[0] == -1) {
+ float cx = MasterImage.getImage().getOriginalBounds().width() / 2;
+ float cy = MasterImage.getImage().getOriginalBounds().height() / 2;
+ float rx = Math.min(cx, cy) * .4f;
+
+ mGradRep.setPoint1(cx, cy-rx);
+ mGradRep.setPoint2(cx, cy+rx);
+ c1[0] = cx;
+ c1[1] = cy-rx;
+ mToScr.mapPoints(c1);
+ if (getWidth() != 0) {
+ mEllipse.setPoint1(c1[0], c1[1]);
+ c2[0] = cx;
+ c2[1] = cy+rx;
+ mToScr.mapPoints(c2);
+ mEllipse.setPoint2(c2[0], c2[1]);
+ }
+ mEditorGrad.commitLocalRepresentation();
+ } else {
+ mToScr.mapPoints(c1);
+ mToScr.mapPoints(c2);
+ mEllipse.setPoint1(c1[0], c1[1]);
+ mEllipse.setPoint2(c2[0], c2[1]);
+ }
+ }
+
+ public void drawOtherPoints(Canvas canvas) {
+ computCenterLocations();
+ for (int i = 0; i < mPointsX.length; i++) {
+ if (mPointsX[i] != -1) {
+ mEllipse.paintGrayPoint(canvas, mPointsX[i], mPointsY[i]);
+ }
+ }
+ }
+
+ public void computCenterLocations() {
+ int x1[] = mGradRep.getXPos1();
+ int y1[] = mGradRep.getYPos1();
+ int x2[] = mGradRep.getXPos2();
+ int y2[] = mGradRep.getYPos2();
+ int selected = mGradRep.getSelectedPoint();
+ boolean m[] = mGradRep.getMask();
+ float[] c = new float[2];
+ for (int i = 0; i < m.length; i++) {
+ if (selected == i || !m[i]) {
+ mPointsX[i] = -1;
+ continue;
+ }
+
+ c[0] = (x1[i]+x2[i])/2;
+ c[1] = (y1[i]+y2[i])/2;
+ mToScr.mapPoints(c);
+
+ mPointsX[i] = c[0];
+ mPointsY[i] = c[1];
+ }
+ }
+
+ public void setEditor(EditorGrad editorGrad) {
+ mEditorGrad = editorGrad;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ if (mGradRep == null) {
+ return;
+ }
+ setRepresentation(mGradRep);
+ mEllipse.draw(canvas);
+ drawOtherPoints(canvas);
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageMirror.java b/src/com/android/gallery3d/filtershow/imageshow/ImageMirror.java
new file mode 100644
index 0000000..26c49b1
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageMirror.java
@@ -0,0 +1,78 @@
+/*
+ * 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.imageshow;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+import com.android.gallery3d.filtershow.editors.EditorMirror;
+import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder;
+
+public class ImageMirror extends ImageShow {
+ private static final String TAG = ImageMirror.class.getSimpleName();
+ private EditorMirror mEditorMirror;
+ private FilterMirrorRepresentation mLocalRep = new FilterMirrorRepresentation();
+ private GeometryHolder mDrawHolder = new GeometryHolder();
+
+ public ImageMirror(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public ImageMirror(Context context) {
+ super(context);
+ }
+
+ public void setFilterMirrorRepresentation(FilterMirrorRepresentation rep) {
+ mLocalRep = (rep == null) ? new FilterMirrorRepresentation() : rep;
+ }
+
+ public void flip() {
+ mLocalRep.cycle();
+ invalidate();
+ }
+
+ public FilterMirrorRepresentation getFinalRepresentation() {
+ return mLocalRep;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ // Treat event as handled.
+ return true;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ MasterImage master = MasterImage.getImage();
+ Bitmap image = master.getFiltersOnlyImage();
+ if (image == null) {
+ return;
+ }
+ GeometryMathUtils.initializeHolder(mDrawHolder, mLocalRep);
+ GeometryMathUtils.drawTransformedCropped(mDrawHolder, canvas, image, getWidth(),
+ getHeight());
+ }
+
+ public void setEditor(EditorMirror editorFlip) {
+ mEditorMirror = editorFlip;
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImagePoint.java b/src/com/android/gallery3d/filtershow/imageshow/ImagePoint.java
index c58dd5f..fd57141 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImagePoint.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImagePoint.java
@@ -58,12 +58,6 @@
}
@Override
- public void updateImage() {
- super.updateImage();
- invalidate();
- }
-
- @Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java b/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
index ab8023e..5186c09 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
@@ -19,20 +19,18 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Paint;
import android.util.AttributeSet;
+import android.view.MotionEvent;
-import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.editors.EditorRotate;
+import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder;
-public class ImageRotate extends ImageGeometry {
-
- private float mBaseAngle = 0;
- private float mAngle = 0;
-
- private final boolean mSnapToNinety = true;
+public class ImageRotate extends ImageShow {
private EditorRotate mEditorRotate;
- private static final String LOGTAG = "ImageRotate";
+ private static final String TAG = ImageRotate.class.getSimpleName();
+ private FilterRotateRepresentation mLocalRep = new FilterRotateRepresentation();
+ private GeometryHolder mDrawHolder = new GeometryHolder();
public ImageRotate(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -42,56 +40,39 @@
super(context);
}
- @Override
- public String getName() {
- return getContext().getString(R.string.rotate);
- }
-
- private static final Paint gPaint = new Paint();
-
- private void computeValue() {
- float angle = getCurrentTouchAngle();
- mAngle = (mBaseAngle - angle) % 360;
+ public void setFilterRotateRepresentation(FilterRotateRepresentation rep) {
+ mLocalRep = (rep == null) ? new FilterRotateRepresentation() : rep;
}
public void rotate() {
- mAngle += 90;
- mAngle = snappedAngle(mAngle);
- mAngle %= 360;
- setLocalRotation(mAngle);
+ mLocalRep.rotateCW();
+ invalidate();
+ }
+
+ public FilterRotateRepresentation getFinalRepresentation() {
+ return mLocalRep;
}
@Override
- protected void setActionDown(float x, float y) {
- super.setActionDown(x, y);
- mBaseAngle = mAngle = getLocalRotation();
+ public boolean onTouchEvent(MotionEvent event) {
+ // Treat event as handled.
+ return true;
}
- @Override
- protected void setActionMove(float x, float y) {
- super.setActionMove(x, y);
- computeValue();
- setLocalRotation(mAngle % 360);
- }
-
- @Override
- protected void setActionUp() {
- super.setActionUp();
- if (mSnapToNinety) {
- setLocalRotation(snappedAngle(mAngle % 360));
- }
- }
-
- @Override
public int getLocalValue() {
- return constrainedRotation(snappedAngle(getLocalRotation()));
+ return mLocalRep.getRotation().value();
}
@Override
- protected void drawShape(Canvas canvas, Bitmap image) {
- gPaint.setAntiAlias(true);
- gPaint.setARGB(255, 255, 255, 255);
- drawTransformedCropped(canvas, image, gPaint);
+ public void onDraw(Canvas canvas) {
+ MasterImage master = MasterImage.getImage();
+ Bitmap image = master.getFiltersOnlyImage();
+ if (image == null) {
+ return;
+ }
+ GeometryMathUtils.initializeHolder(mDrawHolder, mLocalRep);
+ GeometryMathUtils.drawTransformedCropped(mDrawHolder, canvas, image, canvas.getWidth(),
+ canvas.getHeight());
}
public void setEditor(EditorRotate editorRotate) {
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index b833cf8..7089e60 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -16,8 +16,13 @@
package com.android.gallery3d.filtershow.imageshow;
+import android.animation.Animator;
+import android.animation.ValueAnimator;
import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
@@ -25,9 +30,11 @@
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
-import android.net.Uri;
-import android.os.Handler;
+import android.graphics.Shader;
+import android.graphics.drawable.NinePatchDrawable;
+import android.support.v4.widget.EdgeEffectCompat;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.GestureDetector.OnGestureListener;
@@ -36,12 +43,16 @@
import android.view.View;
import android.widget.LinearLayout;
+import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilter;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+import com.android.gallery3d.filtershow.tools.SaveImage;
import java.io.File;
+import java.util.ArrayList;
public class ImageShow extends View implements OnGestureListener,
ScaleGestureDetector.OnScaleGestureListener,
@@ -51,15 +62,10 @@
private static final boolean ENABLE_ZOOMED_COMPARISON = false;
protected Paint mPaint = new Paint();
- protected static int mTextSize = 24;
- protected static int mTextPadding = 20;
+ protected int mTextSize;
+ protected int mTextPadding;
- protected ImageLoader mImageLoader = null;
- private boolean mDirtyGeometry = false;
-
- private Bitmap mBackgroundImage = null;
- private final boolean USE_BACKGROUND_IMAGE = false;
- private static int mBackgroundColor = Color.RED;
+ protected int mBackgroundColor;
private GestureDetector mGestureDetector = null;
private ScaleGestureDetector mScaleGestureDetector = null;
@@ -69,83 +75,72 @@
private boolean mTouchShowOriginal = false;
private long mTouchShowOriginalDate = 0;
private final long mTouchShowOriginalDelayMin = 200; // 200ms
- private final long mTouchShowOriginalDelayMax = 300; // 300ms
private int mShowOriginalDirection = 0;
private static int UNVEIL_HORIZONTAL = 1;
private static int UNVEIL_VERTICAL = 2;
+ private NinePatchDrawable mShadow = null;
+ private Rect mShadowBounds = new Rect();
+ private int mShadowMargin = 15; // not scaled, fixed in the asset
+ private boolean mShadowDrawn = false;
+
private Point mTouchDown = new Point();
private Point mTouch = new Point();
private boolean mFinishedScalingOperation = false;
- private static int mOriginalTextMargin = 8;
- private static int mOriginalTextSize = 26;
- private static String mOriginalText = "Original";
+ private int mOriginalTextMargin;
+ private int mOriginalTextSize;
+ private String mOriginalText;
private boolean mZoomIn = false;
Point mOriginalTranslation = new Point();
float mOriginalScale;
float mStartFocusX, mStartFocusY;
+
+ private EdgeEffectCompat mEdgeEffect = null;
+ private static final int EDGE_LEFT = 1;
+ private static final int EDGE_TOP = 2;
+ private static final int EDGE_RIGHT = 3;
+ private static final int EDGE_BOTTOM = 4;
+ private int mCurrentEdgeEffect = 0;
+ private int mEdgeSize = 100;
+
+ private static final int mAnimationSnapDelay = 200;
+ private static final int mAnimationZoomDelay = 400;
+ private ValueAnimator mAnimatorScale = null;
+ private ValueAnimator mAnimatorTranslateX = null;
+ private ValueAnimator mAnimatorTranslateY = null;
+
private enum InteractionMode {
NONE,
SCALE,
MOVE
}
- private String mToast = null;
- private boolean mShowToast = false;
- private boolean mImportantToast = false;
InteractionMode mInteractionMode = InteractionMode.NONE;
- protected GeometryMetadata getGeometry() {
- return new GeometryMetadata(getImagePreset().mGeoData);
+ private static Bitmap sMask;
+ private Paint mMaskPaint = new Paint();
+ private Matrix mShaderMatrix = new Matrix();
+ private boolean mDidStartAnimation = false;
+
+ private static Bitmap convertToAlphaMask(Bitmap b) {
+ Bitmap a = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ALPHA_8);
+ Canvas c = new Canvas(a);
+ c.drawBitmap(b, 0.0f, 0.0f, null);
+ return a;
+ }
+
+ private static Shader createShader(Bitmap b) {
+ return new BitmapShader(b, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
}
private FilterShowActivity mActivity = null;
- public static void setDefaultBackgroundColor(int value) {
- mBackgroundColor = value;
- }
-
public FilterShowActivity getActivity() {
return mActivity;
}
- public int getDefaultBackgroundColor() {
- return mBackgroundColor;
- }
-
- public static void setTextSize(int value) {
- mTextSize = value;
- }
-
- public static void setTextPadding(int value) {
- mTextPadding = value;
- }
-
- public static void setOriginalTextMargin(int value) {
- mOriginalTextMargin = value;
- }
-
- public static void setOriginalTextSize(int value) {
- mOriginalTextSize = value;
- }
-
- public static void setOriginalText(String text) {
- mOriginalText = text;
- }
-
- private final Handler mHandler = new Handler();
-
- public void select() {
- }
-
- public void unselect() {
- }
-
public boolean hasModifications() {
- if (getImagePreset() == null) {
- return false;
- }
- return getImagePreset().hasModifications();
+ return MasterImage.getImage().hasModifications();
}
public void resetParameter() {
@@ -154,27 +149,52 @@
public void onNewValue(int parameter) {
invalidate();
- mActivity.enableSave(hasModifications());
}
- public Point getTouchPoint() {
- return mTouch;
+ public ImageShow(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ setupImageShow(context);
}
public ImageShow(Context context, AttributeSet attrs) {
super(context, attrs);
+ setupImageShow(context);
- setupGestureDetector(context);
- mActivity = (FilterShowActivity) context;
- MasterImage.getImage().addObserver(this);
}
public ImageShow(Context context) {
super(context);
+ setupImageShow(context);
+ }
+ private void setupImageShow(Context context) {
+ Resources res = context.getResources();
+ mTextSize = res.getDimensionPixelSize(R.dimen.photoeditor_text_size);
+ mTextPadding = res.getDimensionPixelSize(R.dimen.photoeditor_text_padding);
+ mOriginalTextMargin = res.getDimensionPixelSize(R.dimen.photoeditor_original_text_margin);
+ mOriginalTextSize = res.getDimensionPixelSize(R.dimen.photoeditor_original_text_size);
+ mBackgroundColor = res.getColor(R.color.background_screen);
+ mOriginalText = res.getString(R.string.original_picture_text);
+ mShadow = (NinePatchDrawable) res.getDrawable(R.drawable.geometry_shadow);
setupGestureDetector(context);
mActivity = (FilterShowActivity) context;
+ if (sMask == null) {
+ Bitmap mask = BitmapFactory.decodeResource(res, R.drawable.spot_mask);
+ sMask = convertToAlphaMask(mask);
+ }
+ mEdgeEffect = new EdgeEffectCompat(context);
+ mEdgeSize = res.getDimensionPixelSize(R.dimen.edge_glow_size);
+ }
+
+ public void attach() {
MasterImage.getImage().addObserver(this);
+ bindAsImageLoadListener();
+ MasterImage.getImage().resetGeometryImages(false);
+ }
+
+ public void detach() {
+ MasterImage.getImage().removeObserver(this);
+ mMaskPaint.reset();
}
public void setupGestureDetector(Context context) {
@@ -193,35 +213,6 @@
return MasterImage.getImage().getCurrentFilter();
}
- public void showToast(String text) {
- showToast(text, false);
- }
-
- public void showToast(String text, boolean important) {
- mToast = text;
- mShowToast = true;
- mImportantToast = important;
- invalidate();
-
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- mShowToast = false;
- invalidate();
- }
- }, 400);
- }
-
- public Rect getImageBounds() {
- Rect dst = new Rect();
- getImagePreset().mGeoData.getPhotoBounds().roundOut(dst);
- return dst;
- }
-
- public Rect getImageCropBounds() {
- return GeometryMath.roundNearest(getImagePreset().mGeoData.getPreviewCropBounds());
- }
-
/* consider moving the following 2 methods into a subclass */
/**
* This function calculates a Image to Screen Transformation matrix
@@ -230,16 +221,14 @@
* @return Image to Screen transformation matrix
*/
protected Matrix getImageToScreenMatrix(boolean reflectRotation) {
- GeometryMetadata geo = getImagePreset().mGeoData;
- if (geo == null || mImageLoader == null
- || mImageLoader.getOriginalBounds() == null) {
+ MasterImage master = MasterImage.getImage();
+ if (master.getOriginalBounds() == null) {
return new Matrix();
}
- Matrix m = geo.getOriginalToScreen(reflectRotation,
- mImageLoader.getOriginalBounds().width(),
- mImageLoader.getOriginalBounds().height(), getWidth(), getHeight());
- Point translate = MasterImage.getImage().getTranslation();
- float scaleFactor = MasterImage.getImage().getScaleFactor();
+ Matrix m = GeometryMathUtils.getImageToScreenMatrix(master.getPreset().getGeometryFilters(),
+ reflectRotation, master.getOriginalBounds(), getWidth(), getHeight());
+ Point translate = master.getTranslation();
+ float scaleFactor = master.getScaleFactor();
m.postTranslate(translate.x, translate.y);
m.postScale(scaleFactor, scaleFactor, getWidth() / 2.0f, getHeight() / 2.0f);
return m;
@@ -258,110 +247,94 @@
return invert;
}
- public Rect getDisplayedImageBounds() {
- return mImageBounds;
- }
-
public ImagePreset getImagePreset() {
return MasterImage.getImage().getPreset();
}
- public void drawToast(Canvas canvas) {
- if (mShowToast && mToast != null) {
- Paint paint = new Paint();
- paint.setTextSize(128);
- float textWidth = paint.measureText(mToast);
- int toastX = (int) ((getWidth() - textWidth) / 2.0f);
- int toastY = (int) (getHeight() / 3.0f);
+ @Override
+ public void onDraw(Canvas canvas) {
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setFilterBitmap(true);
+ MasterImage.getImage().setImageShowSize(
+ getWidth() - 2*mShadowMargin,
+ getHeight() - 2*mShadowMargin);
- paint.setARGB(255, 0, 0, 0);
- canvas.drawText(mToast, toastX - 2, toastY - 2, paint);
- canvas.drawText(mToast, toastX - 2, toastY, paint);
- canvas.drawText(mToast, toastX, toastY - 2, paint);
- canvas.drawText(mToast, toastX + 2, toastY + 2, paint);
- canvas.drawText(mToast, toastX + 2, toastY, paint);
- canvas.drawText(mToast, toastX, toastY + 2, paint);
- if (mImportantToast) {
- paint.setARGB(255, 200, 0, 0);
- } else {
- paint.setARGB(255, 255, 255, 255);
+ MasterImage img = MasterImage.getImage();
+ // Hide the loading indicator as needed
+ if (mActivity.isLoadingVisible() && getFilteredImage() != null) {
+ if ((img.getLoadedPreset() == null)
+ || (img.getLoadedPreset() != null
+ && img.getLoadedPreset().equals(img.getCurrentPreset()))) {
+ mActivity.stopLoadingIndicator();
+ } else if (img.getLoadedPreset() != null) {
+ return;
}
- canvas.drawText(mToast, toastX, toastY, paint);
+ mActivity.stopLoadingIndicator();
+ }
+
+ canvas.save();
+
+ mShadowDrawn = false;
+
+ Bitmap highresPreview = MasterImage.getImage().getHighresImage();
+ Bitmap fullHighres = MasterImage.getImage().getPartialImage();
+
+ boolean isDoingNewLookAnimation = MasterImage.getImage().onGoingNewLookAnimation();
+
+ if (highresPreview == null || isDoingNewLookAnimation) {
+ drawImageAndAnimate(canvas, getFilteredImage());
+ } else {
+ drawImageAndAnimate(canvas, highresPreview);
+ }
+
+ drawHighresImage(canvas, fullHighres);
+ drawCompareImage(canvas, getGeometryOnlyImage());
+
+ canvas.restore();
+
+ if (!mEdgeEffect.isFinished()) {
+ canvas.save();
+ float dx = (getHeight() - getWidth()) / 2f;
+ if (getWidth() > getHeight()) {
+ dx = - (getWidth() - getHeight()) / 2f;
+ }
+ if (mCurrentEdgeEffect == EDGE_BOTTOM) {
+ canvas.rotate(180, getWidth()/2, getHeight()/2);
+ } else if (mCurrentEdgeEffect == EDGE_RIGHT) {
+ canvas.rotate(90, getWidth()/2, getHeight()/2);
+ canvas.translate(0, dx);
+ } else if (mCurrentEdgeEffect == EDGE_LEFT) {
+ canvas.rotate(270, getWidth()/2, getHeight()/2);
+ canvas.translate(0, dx);
+ }
+ if (mCurrentEdgeEffect != 0) {
+ mEdgeEffect.draw(canvas);
+ }
+ canvas.restore();
+ invalidate();
+ } else {
+ mCurrentEdgeEffect = 0;
}
}
- @Override
- public void onDraw(Canvas canvas) {
- MasterImage.getImage().setImageShowSize(getWidth(), getHeight());
-
- float cx = canvas.getWidth()/2.0f;
- float cy = canvas.getHeight()/2.0f;
- float scaleFactor = MasterImage.getImage().getScaleFactor();
- Point translation = MasterImage.getImage().getTranslation();
-
- Matrix scalingMatrix = new Matrix();
- scalingMatrix.postScale(scaleFactor, scaleFactor, cx, cy);
- scalingMatrix.preTranslate(translation.x, translation.y);
-
- RectF unscaledClipRect = new RectF(mImageBounds);
- scalingMatrix.mapRect(unscaledClipRect, unscaledClipRect);
-
- canvas.save();
-
- boolean enablePartialRendering = false;
-
- // For now, partial rendering is disabled for all filters,
- // so no need to clip.
- if (enablePartialRendering && !unscaledClipRect.isEmpty()) {
- canvas.clipRect(unscaledClipRect);
+ private void drawHighresImage(Canvas canvas, Bitmap fullHighres) {
+ Matrix originalToScreen = MasterImage.getImage().originalImageToScreen();
+ if (fullHighres != null && originalToScreen != null) {
+ Matrix screenToOriginal = new Matrix();
+ originalToScreen.invert(screenToOriginal);
+ Rect rBounds = new Rect();
+ rBounds.set(MasterImage.getImage().getPartialBounds());
+ if (fullHighres != null) {
+ originalToScreen.preTranslate(rBounds.left, rBounds.top);
+ canvas.clipRect(mImageBounds);
+ canvas.drawBitmap(fullHighres, originalToScreen, mPaint);
+ }
}
-
- canvas.save();
- // TODO: center scale on gesture
- canvas.scale(scaleFactor, scaleFactor, cx, cy);
- canvas.translate(translation.x, translation.y);
- drawBackground(canvas);
- drawImage(canvas, getFilteredImage(), true);
- Bitmap highresPreview = MasterImage.getImage().getHighresImage();
- if (highresPreview != null) {
- drawImage(canvas, highresPreview, false);
- }
- canvas.restore();
-
- if (showTitle() && getImagePreset() != null) {
- mPaint.setARGB(200, 0, 0, 0);
- mPaint.setTextSize(mTextSize);
-
- Rect textRect = new Rect(0, 0, getWidth(), mTextSize + mTextPadding);
- canvas.drawRect(textRect, mPaint);
- mPaint.setARGB(255, 200, 200, 200);
- canvas.drawText(getImagePreset().name(), mTextPadding,
- 1.5f * mTextPadding, mPaint);
- }
-
- Bitmap partialPreview = MasterImage.getImage().getPartialImage();
- if (partialPreview != null) {
- Rect src = new Rect(0, 0, partialPreview.getWidth(), partialPreview.getHeight());
- Rect dest = new Rect(0, 0, getWidth(), getHeight());
- canvas.drawBitmap(partialPreview, src, dest, mPaint);
- }
-
- canvas.save();
- canvas.scale(scaleFactor, scaleFactor, cx, cy);
- canvas.translate(translation.x, translation.y);
- drawPartialImage(canvas, getGeometryOnlyImage());
- canvas.restore();
-
- canvas.restore();
-
- drawToast(canvas);
}
public void resetImageCaches(ImageShow caller) {
- if (mImageLoader == null) {
- return;
- }
- MasterImage.getImage().updatePresets(true);
+ MasterImage.getImage().invalidatePreview();
}
public Bitmap getFiltersOnlyImage() {
@@ -376,30 +349,172 @@
return MasterImage.getImage().getFilteredImage();
}
- public void drawImage(Canvas canvas, Bitmap image, boolean updateBounds) {
- if (image != null) {
- Rect s = new Rect(0, 0, image.getWidth(),
- image.getHeight());
+ public void drawImageAndAnimate(Canvas canvas,
+ Bitmap image) {
+ if (image == null) {
+ return;
+ }
+ MasterImage master = MasterImage.getImage();
+ Matrix m = master.computeImageToScreen(image, 0, false);
+ if (m == null) {
+ return;
+ }
- float scale = GeometryMath.scale(image.getWidth(), image.getHeight(), getWidth(),
- getHeight());
+ canvas.save();
- float w = image.getWidth() * scale;
- float h = image.getHeight() * scale;
- float ty = (getHeight() - h) / 2.0f;
- float tx = (getWidth() - w) / 2.0f;
+ RectF d = new RectF(0, 0, image.getWidth(), image.getHeight());
+ m.mapRect(d);
+ d.roundOut(mImageBounds);
- Rect d = new Rect((int) tx, (int) ty, (int) (w + tx),
- (int) (h + ty));
- if (updateBounds) {
- mImageBounds = d;
+ boolean showAnimatedImage = master.onGoingNewLookAnimation();
+ if (!showAnimatedImage && mDidStartAnimation) {
+ // animation ended, but do we have the correct image to show?
+ if (master.getPreset().equals(master.getCurrentPreset())) {
+ // we do, let's stop showing the animated image
+ mDidStartAnimation = false;
+ MasterImage.getImage().resetAnimBitmap();
+ } else {
+ showAnimatedImage = true;
}
- canvas.drawBitmap(image, s, d, mPaint);
+ } else if (showAnimatedImage) {
+ mDidStartAnimation = true;
+ }
+
+ if (showAnimatedImage) {
+ canvas.save();
+
+ // Animation uses the image before the change
+ Bitmap previousImage = master.getPreviousImage();
+ Matrix mp = master.computeImageToScreen(previousImage, 0, false);
+ RectF dp = new RectF(0, 0, previousImage.getWidth(), previousImage.getHeight());
+ mp.mapRect(dp);
+ Rect previousBounds = new Rect();
+ dp.roundOut(previousBounds);
+ float centerX = dp.centerX();
+ float centerY = dp.centerY();
+ boolean needsToDrawImage = true;
+
+ if (master.getCurrentLookAnimation()
+ == MasterImage.CIRCLE_ANIMATION) {
+ float maskScale = MasterImage.getImage().getMaskScale();
+ if (maskScale >= 0.0f) {
+ float maskW = sMask.getWidth() / 2.0f;
+ float maskH = sMask.getHeight() / 2.0f;
+ Point point = mActivity.hintTouchPoint(this);
+ float maxMaskScale = 2 * Math.max(getWidth(), getHeight())
+ / Math.min(maskW, maskH);
+ maskScale = maskScale * maxMaskScale;
+ float x = point.x - maskW * maskScale;
+ float y = point.y - maskH * maskScale;
+
+ // Prepare the shader
+ mShaderMatrix.reset();
+ mShaderMatrix.setScale(1.0f / maskScale, 1.0f / maskScale);
+ mShaderMatrix.preTranslate(-x + mImageBounds.left, -y + mImageBounds.top);
+ float scaleImageX = mImageBounds.width() / (float) image.getWidth();
+ float scaleImageY = mImageBounds.height() / (float) image.getHeight();
+ mShaderMatrix.preScale(scaleImageX, scaleImageY);
+ mMaskPaint.reset();
+ mMaskPaint.setShader(createShader(image));
+ mMaskPaint.getShader().setLocalMatrix(mShaderMatrix);
+
+ drawShadow(canvas, mImageBounds); // as needed
+ canvas.drawBitmap(previousImage, m, mPaint);
+ canvas.clipRect(mImageBounds);
+ canvas.translate(x, y);
+ canvas.scale(maskScale, maskScale);
+ canvas.drawBitmap(sMask, 0, 0, mMaskPaint);
+ needsToDrawImage = false;
+ }
+ } else if (master.getCurrentLookAnimation()
+ == MasterImage.ROTATE_ANIMATION) {
+ Rect d1 = computeImageBounds(master.getPreviousImage().getHeight(),
+ master.getPreviousImage().getWidth());
+ Rect d2 = computeImageBounds(master.getPreviousImage().getWidth(),
+ master.getPreviousImage().getHeight());
+ float finalScale = d1.width() / (float) d2.height();
+ finalScale = (1.0f * (1.0f - master.getAnimFraction()))
+ + (finalScale * master.getAnimFraction());
+ canvas.rotate(master.getAnimRotationValue(), centerX, centerY);
+ canvas.scale(finalScale, finalScale, centerX, centerY);
+ } else if (master.getCurrentLookAnimation()
+ == MasterImage.MIRROR_ANIMATION) {
+ if (master.getCurrentFilterRepresentation()
+ instanceof FilterMirrorRepresentation) {
+ FilterMirrorRepresentation rep =
+ (FilterMirrorRepresentation) master.getCurrentFilterRepresentation();
+
+ ImagePreset preset = master.getPreset();
+ ArrayList<FilterRepresentation> geometry =
+ (ArrayList<FilterRepresentation>) preset.getGeometryFilters();
+ GeometryMathUtils.GeometryHolder holder = null;
+ holder = GeometryMathUtils.unpackGeometry(geometry);
+
+ if (holder.rotation.value() == 90 || holder.rotation.value() == 270) {
+ if (rep.isHorizontal() && !rep.isVertical()) {
+ canvas.scale(1, master.getAnimRotationValue(), centerX, centerY);
+ } else if (rep.isVertical() && !rep.isHorizontal()) {
+ canvas.scale(1, master.getAnimRotationValue(), centerX, centerY);
+ } else if (rep.isHorizontal() && rep.isVertical()) {
+ canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY);
+ } else {
+ canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY);
+ }
+ } else {
+ if (rep.isHorizontal() && !rep.isVertical()) {
+ canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY);
+ } else if (rep.isVertical() && !rep.isHorizontal()) {
+ canvas.scale(master.getAnimRotationValue(), 1, centerX, centerY);
+ } else if (rep.isHorizontal() && rep.isVertical()) {
+ canvas.scale(1, master.getAnimRotationValue(), centerX, centerY);
+ } else {
+ canvas.scale(1, master.getAnimRotationValue(), centerX, centerY);
+ }
+ }
+ }
+ }
+
+ if (needsToDrawImage) {
+ drawShadow(canvas, previousBounds); // as needed
+ canvas.drawBitmap(previousImage, mp, mPaint);
+ }
+
+ canvas.restore();
+ } else {
+ drawShadow(canvas, mImageBounds); // as needed
+ canvas.drawBitmap(image, m, mPaint);
+ }
+
+ canvas.restore();
+ }
+
+ private Rect computeImageBounds(int imageWidth, int imageHeight) {
+ float scale = GeometryMathUtils.scale(imageWidth, imageHeight,
+ getWidth(), getHeight());
+
+ float w = imageWidth * scale;
+ float h = imageHeight * scale;
+ float ty = (getHeight() - h) / 2.0f;
+ float tx = (getWidth() - w) / 2.0f;
+ return new Rect((int) tx + mShadowMargin,
+ (int) ty + mShadowMargin,
+ (int) (w + tx) - mShadowMargin,
+ (int) (h + ty) - mShadowMargin);
+ }
+
+ private void drawShadow(Canvas canvas, Rect d) {
+ if (!mShadowDrawn) {
+ mShadowBounds.set(d.left - mShadowMargin, d.top - mShadowMargin,
+ d.right + mShadowMargin, d.bottom + mShadowMargin);
+ mShadow.setBounds(mShadowBounds);
+ mShadow.draw(canvas);
+ mShadowDrawn = true;
}
}
- public void drawPartialImage(Canvas canvas, Bitmap image) {
- boolean showsOriginal = MasterImage.getImage().showsOriginal();
+ public void drawCompareImage(Canvas canvas, Bitmap image) {
+ MasterImage master = MasterImage.getImage();
+ boolean showsOriginal = master.showsOriginal();
if (!showsOriginal && !mTouchShowOriginal)
return;
canvas.save();
@@ -416,9 +531,9 @@
int py = 0;
if (mShowOriginalDirection == UNVEIL_VERTICAL) {
px = mImageBounds.width();
- py = (int) (mTouch.y - mImageBounds.top);
+ py = mTouch.y - mImageBounds.top;
} else {
- px = (int) (mTouch.x - mImageBounds.left);
+ px = mTouch.x - mImageBounds.left;
py = mImageBounds.height();
if (showsOriginal) {
px = mImageBounds.width();
@@ -427,8 +542,20 @@
Rect d = new Rect(mImageBounds.left, mImageBounds.top,
mImageBounds.left + px, mImageBounds.top + py);
+ if (mShowOriginalDirection == UNVEIL_HORIZONTAL) {
+ if (mTouchDown.x - mTouch.x > 0) {
+ d.set(mImageBounds.left + px, mImageBounds.top,
+ mImageBounds.right, mImageBounds.top + py);
+ }
+ } else {
+ if (mTouchDown.y - mTouch.y > 0) {
+ d.set(mImageBounds.left, mImageBounds.top + py,
+ mImageBounds.left + px, mImageBounds.bottom);
+ }
+ }
canvas.clipRect(d);
- drawImage(canvas, image, false);
+ Matrix m = master.computeImageToScreen(image, 0, false);
+ canvas.drawBitmap(image, m, mPaint);
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setStrokeWidth(3);
@@ -459,106 +586,27 @@
canvas.restore();
}
- public void drawBackground(Canvas canvas) {
- if (USE_BACKGROUND_IMAGE) {
- if (mBackgroundImage == null) {
- mBackgroundImage = mImageLoader.getBackgroundBitmap(getResources());
- }
- if (mBackgroundImage != null) {
- Rect s = new Rect(0, 0, mBackgroundImage.getWidth(),
- mBackgroundImage.getHeight());
- Rect d = new Rect(0, 0, getWidth(), getHeight());
- canvas.drawBitmap(mBackgroundImage, s, d, mPaint);
- }
- } else {
- canvas.drawARGB(0, 0, 0, 0);
- }
- }
-
- public boolean showTitle() {
- return false;
- }
-
- public void setImageLoader(ImageLoader loader) {
- mImageLoader = loader;
- if (mImageLoader != null) {
- mImageLoader.addListener(this);
- MasterImage.getImage().setImageLoader(mImageLoader);
- }
- }
-
- private void setDirtyGeometryFlag() {
- mDirtyGeometry = true;
- }
-
- protected void clearDirtyGeometryFlag() {
- mDirtyGeometry = false;
- }
-
- protected boolean getDirtyGeometryFlag() {
- return mDirtyGeometry;
- }
-
- private void imageSizeChanged(Bitmap image) {
- if (image == null || getImagePreset() == null)
- return;
- float w = image.getWidth();
- float h = image.getHeight();
- GeometryMetadata geo = getImagePreset().mGeoData;
- RectF pb = geo.getPhotoBounds();
- if (w == pb.width() && h == pb.height()) {
- return;
- }
- RectF r = new RectF(0, 0, w, h);
- getImagePreset().mGeoData.setPhotoBounds(r);
- getImagePreset().mGeoData.setCropBounds(r);
-
- }
-
- public boolean updateGeometryFlags() {
- return true;
+ public void bindAsImageLoadListener() {
+ MasterImage.getImage().addListener(this);
}
public void updateImage() {
invalidate();
- if (!updateGeometryFlags()) {
- return;
- }
- Bitmap bitmap = mImageLoader.getOriginalBitmapLarge();
- if (bitmap != null) {
- imageSizeChanged(bitmap);
- }
}
public void imageLoaded() {
updateImage();
- invalidate();
}
public void saveImage(FilterShowActivity filterShowActivity, File file) {
- mImageLoader.saveImage(getImagePreset(), filterShowActivity, file);
+ SaveImage.saveImage(getImagePreset(), filterShowActivity, file);
}
- public void saveToUri(Bitmap f, Uri u, String m, FilterShowActivity filterShowActivity) {
- mImageLoader.saveToUri(f, u, m, filterShowActivity);
- }
-
- public void returnFilteredResult(FilterShowActivity filterShowActivity) {
- mImageLoader.returnFilteredResult(getImagePreset(), filterShowActivity);
- }
public boolean scaleInProgress() {
return mScaleGestureDetector.isInProgress();
}
- protected boolean isOriginalDisabled() {
- return mOriginalDisabled;
- }
-
- protected void setOriginalDisabled(boolean originalDisabled) {
- mOriginalDisabled = originalDisabled;
- }
-
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
@@ -610,7 +658,9 @@
}
}
- if (action == MotionEvent.ACTION_UP) {
+ if (action == MotionEvent.ACTION_UP
+ || action == MotionEvent.ACTION_CANCEL
+ || action == MotionEvent.ACTION_OUTSIDE) {
mInteractionMode = InteractionMode.NONE;
mTouchShowOriginal = false;
mTouchDown.x = 0;
@@ -622,48 +672,214 @@
MasterImage.getImage().resetTranslation();
}
}
+
+ float scaleFactor = MasterImage.getImage().getScaleFactor();
+ Point translation = MasterImage.getImage().getTranslation();
+ constrainTranslation(translation, scaleFactor);
+ MasterImage.getImage().setTranslation(translation);
+
invalidate();
return true;
}
+ private void startAnimTranslation(int fromX, int toX,
+ int fromY, int toY, int delay) {
+ if (fromX == toX && fromY == toY) {
+ return;
+ }
+ if (mAnimatorTranslateX != null) {
+ mAnimatorTranslateX.cancel();
+ }
+ if (mAnimatorTranslateY != null) {
+ mAnimatorTranslateY.cancel();
+ }
+ mAnimatorTranslateX = ValueAnimator.ofInt(fromX, toX);
+ mAnimatorTranslateY = ValueAnimator.ofInt(fromY, toY);
+ mAnimatorTranslateX.setDuration(delay);
+ mAnimatorTranslateY.setDuration(delay);
+ mAnimatorTranslateX.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ Point translation = MasterImage.getImage().getTranslation();
+ translation.x = (Integer) animation.getAnimatedValue();
+ MasterImage.getImage().setTranslation(translation);
+ invalidate();
+ }
+ });
+ mAnimatorTranslateY.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ Point translation = MasterImage.getImage().getTranslation();
+ translation.y = (Integer) animation.getAnimatedValue();
+ MasterImage.getImage().setTranslation(translation);
+ invalidate();
+ }
+ });
+ mAnimatorTranslateX.start();
+ mAnimatorTranslateY.start();
+ }
+
+ private void applyTranslationConstraints() {
+ float scaleFactor = MasterImage.getImage().getScaleFactor();
+ Point translation = MasterImage.getImage().getTranslation();
+ int x = translation.x;
+ int y = translation.y;
+ constrainTranslation(translation, scaleFactor);
+
+ if (x != translation.x || y != translation.y) {
+ startAnimTranslation(x, translation.x,
+ y, translation.y,
+ mAnimationSnapDelay);
+ }
+ }
+
protected boolean enableComparison() {
return true;
}
- // listview stuff
- public void showOriginal(boolean show) {
- invalidate();
- }
-
@Override
public boolean onDoubleTap(MotionEvent arg0) {
mZoomIn = !mZoomIn;
float scale = 1.0f;
+ final float x = arg0.getX();
+ final float y = arg0.getY();
if (mZoomIn) {
scale = MasterImage.getImage().getMaxScaleFactor();
}
if (scale != MasterImage.getImage().getScaleFactor()) {
- MasterImage.getImage().setScaleFactor(scale);
- invalidate();
+ if (mAnimatorScale != null) {
+ mAnimatorScale.cancel();
+ }
+ mAnimatorScale = ValueAnimator.ofFloat(
+ MasterImage.getImage().getScaleFactor(),
+ scale
+ );
+ float translateX = (getWidth() / 2 - x);
+ float translateY = (getHeight() / 2 - y);
+ Point translation = MasterImage.getImage().getTranslation();
+ int startTranslateX = translation.x;
+ int startTranslateY = translation.y;
+ if (scale != 1.0f) {
+ translation.x = (int) (mOriginalTranslation.x + translateX);
+ translation.y = (int) (mOriginalTranslation.y + translateY);
+ } else {
+ translation.x = 0;
+ translation.y = 0;
+ }
+ constrainTranslation(translation, scale);
+
+ startAnimTranslation(startTranslateX, translation.x,
+ startTranslateY, translation.y,
+ mAnimationZoomDelay);
+ mAnimatorScale.setDuration(mAnimationZoomDelay);
+ mAnimatorScale.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ MasterImage.getImage().setScaleFactor((Float) animation.getAnimatedValue());
+ invalidate();
+ }
+ });
+ mAnimatorScale.addListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ applyTranslationConstraints();
+ MasterImage.getImage().needsUpdatePartialPreview();
+ invalidate();
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
+ });
+ mAnimatorScale.start();
}
return true;
}
+ private void constrainTranslation(Point translation, float scale) {
+ int currentEdgeEffect = 0;
+ if (scale <= 1) {
+ mCurrentEdgeEffect = 0;
+ mEdgeEffect.finish();
+ return;
+ }
+
+ Matrix originalToScreen = MasterImage.getImage().originalImageToScreen();
+ Rect originalBounds = MasterImage.getImage().getOriginalBounds();
+ RectF screenPos = new RectF(originalBounds);
+ originalToScreen.mapRect(screenPos);
+
+ boolean rightConstraint = screenPos.right < getWidth() - mShadowMargin;
+ boolean leftConstraint = screenPos.left > mShadowMargin;
+ boolean topConstraint = screenPos.top > mShadowMargin;
+ boolean bottomConstraint = screenPos.bottom < getHeight() - mShadowMargin;
+
+ if (screenPos.width() > getWidth()) {
+ if (rightConstraint && !leftConstraint) {
+ float tx = screenPos.right - translation.x * scale;
+ translation.x = (int) ((getWidth() - mShadowMargin - tx) / scale);
+ currentEdgeEffect = EDGE_RIGHT;
+ } else if (leftConstraint && !rightConstraint) {
+ float tx = screenPos.left - translation.x * scale;
+ translation.x = (int) ((mShadowMargin - tx) / scale);
+ currentEdgeEffect = EDGE_LEFT;
+ }
+ } else {
+ float tx = screenPos.right - translation.x * scale;
+ float dx = (getWidth() - 2 * mShadowMargin - screenPos.width()) / 2f;
+ translation.x = (int) ((getWidth() - mShadowMargin - tx - dx) / scale);
+ }
+
+ if (screenPos.height() > getHeight()) {
+ if (bottomConstraint && !topConstraint) {
+ float ty = screenPos.bottom - translation.y * scale;
+ translation.y = (int) ((getHeight() - mShadowMargin - ty) / scale);
+ currentEdgeEffect = EDGE_BOTTOM;
+ } else if (topConstraint && !bottomConstraint) {
+ float ty = screenPos.top - translation.y * scale;
+ translation.y = (int) ((mShadowMargin - ty) / scale);
+ currentEdgeEffect = EDGE_TOP;
+ }
+ } else {
+ float ty = screenPos.bottom - translation.y * scale;
+ float dy = (getHeight()- 2 * mShadowMargin - screenPos.height()) / 2f;
+ translation.y = (int) ((getHeight() - mShadowMargin - ty - dy) / scale);
+ }
+
+ if (mCurrentEdgeEffect != currentEdgeEffect) {
+ if (mCurrentEdgeEffect == 0 || currentEdgeEffect != 0) {
+ mCurrentEdgeEffect = currentEdgeEffect;
+ mEdgeEffect.finish();
+ }
+ mEdgeEffect.setSize(getWidth(), mEdgeSize);
+ }
+ if (currentEdgeEffect != 0) {
+ mEdgeEffect.onPull(mEdgeSize);
+ }
+ }
+
@Override
public boolean onDoubleTapEvent(MotionEvent arg0) {
- // TODO Auto-generated method stub
return false;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent arg0) {
- // TODO Auto-generated method stub
return false;
}
@Override
public boolean onDown(MotionEvent arg0) {
- // TODO Auto-generated method stub
return false;
}
@@ -680,23 +896,19 @@
@Override
public void onLongPress(MotionEvent arg0) {
- // TODO Auto-generated method stub
}
@Override
public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3) {
- // TODO Auto-generated method stub
return false;
}
@Override
public void onShowPress(MotionEvent arg0) {
- // TODO Auto-generated method stub
}
@Override
public boolean onSingleTapUp(MotionEvent arg0) {
- // TODO Auto-generated method stub
return false;
}
@@ -705,25 +917,22 @@
}
public void openUtilityPanel(final LinearLayout accessoryViewList) {
- // TODO Auto-generated method stub
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
MasterImage img = MasterImage.getImage();
float scaleFactor = img.getScaleFactor();
- Point pos = img.getTranslation();
scaleFactor = scaleFactor * detector.getScaleFactor();
if (scaleFactor > MasterImage.getImage().getMaxScaleFactor()) {
scaleFactor = MasterImage.getImage().getMaxScaleFactor();
}
- if (scaleFactor < 0.5) {
- scaleFactor = 0.5f;
+ if (scaleFactor < 1.0f) {
+ scaleFactor = 1.0f;
}
MasterImage.getImage().setScaleFactor(scaleFactor);
scaleFactor = img.getScaleFactor();
- pos = img.getTranslation();
float focusx = detector.getFocusX();
float focusy = detector.getFocusY();
float translateX = (focusx - mStartFocusX) / scaleFactor;
@@ -732,7 +941,6 @@
translation.x = (int) (mOriginalTranslation.x + translateX);
translation.y = (int) (mOriginalTranslation.y + translateY);
MasterImage.getImage().setTranslation(translation);
-
invalidate();
return true;
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java b/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
index 5f906ea..4742f2e 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
@@ -16,24 +16,63 @@
package com.android.gallery3d.filtershow.imageshow;
+import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Matrix;
import android.graphics.Paint;
+import android.graphics.Paint.Style;
+import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
+import android.view.MotionEvent;
-import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.crop.CropDrawingUtils;
import com.android.gallery3d.filtershow.editors.EditorStraighten;
+import com.android.gallery3d.filtershow.filters.FilterCropRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder;
-public class ImageStraighten extends ImageGeometry {
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class ImageStraighten extends ImageShow {
+ private static final String TAG = ImageStraighten.class.getSimpleName();
private float mBaseAngle = 0;
private float mAngle = 0;
+ private float mInitialAngle = 0;
+ private static final int NBLINES = 16;
+ private boolean mFirstDrawSinceUp = false;
private EditorStraighten mEditorStraighten;
+ private FilterStraightenRepresentation mLocalRep = new FilterStraightenRepresentation();
+ private RectF mPriorCropAtUp = new RectF();
+ private RectF mDrawRect = new RectF();
+ private Path mDrawPath = new Path();
+ private GeometryHolder mDrawHolder = new GeometryHolder();
+ private enum MODES {
+ NONE, MOVE
+ }
+ private MODES mState = MODES.NONE;
+ private ValueAnimator mAnimator = null;
+ private int mDefaultGridAlpha = 60;
+ private float mGridAlpha = 1f;
+ private int mOnStartAnimDelay = 1000;
+ private int mAnimDelay = 500;
+ private static final float MAX_STRAIGHTEN_ANGLE
+ = FilterStraightenRepresentation.MAX_STRAIGHTEN_ANGLE;
+ private static final float MIN_STRAIGHTEN_ANGLE
+ = FilterStraightenRepresentation.MIN_STRAIGHTEN_ANGLE;
+ private float mCurrentX;
+ private float mCurrentY;
+ private float mTouchCenterX;
+ private float mTouchCenterY;
+ private RectF mCrop = new RectF();
+ private final Paint mPaint = new Paint();
- private static final String LOGTAG = "ImageStraighten";
- private static final Paint gPaint = new Paint();
public ImageStraighten(Context context) {
super(context);
}
@@ -43,27 +82,97 @@
}
@Override
- public String getName() {
- return getContext().getString(R.string.straighten);
+ public void attach() {
+ super.attach();
+ mGridAlpha = 1f;
+ hidesGrid(mOnStartAnimDelay);
+ }
+
+ private void hidesGrid(int delay) {
+ mAnimator = ValueAnimator.ofFloat(1, 0);
+ mAnimator.setStartDelay(delay);
+ mAnimator.setDuration(mAnimDelay);
+ mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ mGridAlpha = ((Float) animation.getAnimatedValue());
+ invalidate();
+ }
+ });
+ mAnimator.start();
+ }
+
+ public void setFilterStraightenRepresentation(FilterStraightenRepresentation rep) {
+ mLocalRep = (rep == null) ? new FilterStraightenRepresentation() : rep;
+ mInitialAngle = mBaseAngle = mAngle = mLocalRep.getStraighten();
+ }
+
+ public Collection<FilterRepresentation> getFinalRepresentation() {
+ ArrayList<FilterRepresentation> reps = new ArrayList<FilterRepresentation>(2);
+ reps.add(mLocalRep);
+ if (mInitialAngle != mLocalRep.getStraighten()) {
+ reps.add(new FilterCropRepresentation(mCrop));
+ }
+ return reps;
}
@Override
- protected void setActionDown(float x, float y) {
- super.setActionDown(x, y);
- mBaseAngle = mAngle = getLocalStraighten();
+ public boolean onTouchEvent(MotionEvent event) {
+ float x = event.getX();
+ float y = event.getY();
+
+ switch (event.getActionMasked()) {
+ case (MotionEvent.ACTION_DOWN):
+ if (mState == MODES.NONE) {
+ mTouchCenterX = x;
+ mTouchCenterY = y;
+ mCurrentX = x;
+ mCurrentY = y;
+ mState = MODES.MOVE;
+ mBaseAngle = mAngle;
+ }
+ break;
+ case (MotionEvent.ACTION_UP):
+ if (mState == MODES.MOVE) {
+ mState = MODES.NONE;
+ mCurrentX = x;
+ mCurrentY = y;
+ computeValue();
+ mFirstDrawSinceUp = true;
+ hidesGrid(0);
+ }
+ break;
+ case (MotionEvent.ACTION_MOVE):
+ if (mState == MODES.MOVE) {
+ mCurrentX = x;
+ mCurrentY = y;
+ computeValue();
+ }
+ break;
+ default:
+ break;
+ }
+ invalidate();
+ return true;
}
- private void setCropToStraighten(){
- setLocalCropBounds(getUntranslatedStraightenCropBounds(getLocalPhotoBounds(),
- getLocalStraighten()));
+ private static float angleFor(float dx, float dy) {
+ return (float) (Math.atan2(dx, dy) * 180 / Math.PI);
}
- @Override
- protected void setActionMove(float x, float y) {
- super.setActionMove(x, y);
- computeValue();
- setLocalStraighten(mAngle);
- setCropToStraighten();
+ private float getCurrentTouchAngle() {
+ float centerX = getWidth() / 2f;
+ float centerY = getHeight() / 2f;
+ if (mCurrentX == mTouchCenterX && mCurrentY == mTouchCenterY) {
+ return 0;
+ }
+ float dX1 = mTouchCenterX - centerX;
+ float dY1 = mTouchCenterY - centerY;
+ float dX2 = mCurrentX - centerX;
+ float dY2 = mCurrentY - centerY;
+ float angleA = angleFor(dX1, dY1);
+ float angleB = angleFor(dX2, dY2);
+ return (angleB - angleA) % 360;
}
private void computeValue() {
@@ -73,62 +182,125 @@
mAngle = Math.min(MAX_STRAIGHTEN_ANGLE, mAngle);
}
- @Override
- protected void lostVisibility() {
- saveAndSetPreset();
+ public static void getUntranslatedStraightenCropBounds(RectF outRect, float straightenAngle) {
+ float deg = straightenAngle;
+ if (deg < 0) {
+ deg = -deg;
+ }
+ double a = Math.toRadians(deg);
+ double sina = Math.sin(a);
+ double cosa = Math.cos(a);
+ double rw = outRect.width();
+ double rh = outRect.height();
+ double h1 = rh * rh / (rw * sina + rh * cosa);
+ double h2 = rh * rw / (rw * cosa + rh * sina);
+ double hh = Math.min(h1, h2);
+ double ww = hh * rw / rh;
+ float left = (float) ((rw - ww) * 0.5f);
+ float top = (float) ((rh - hh) * 0.5f);
+ float right = (float) (left + ww);
+ float bottom = (float) (top + hh);
+ outRect.set(left, top, right, bottom);
}
- @Override
- protected void gainedVisibility(){
- setCropToStraighten();
+ private void updateCurrentCrop(Matrix m, GeometryHolder h, RectF tmp, int imageWidth,
+ int imageHeight, int viewWidth, int viewHeight) {
+ tmp.set(0, 0, imageHeight, imageWidth);
+ m.mapRect(tmp);
+ float top = tmp.top;
+ float bottom = tmp.bottom;
+ float left = tmp.left;
+ float right = tmp.right;
+ m.mapRect(tmp);
+ int iw,ih;
+ if (GeometryMathUtils.needsDimensionSwap(h.rotation)) {
+ tmp.set(0, 0, imageHeight, imageWidth);
+ iw = imageHeight;
+ ih = imageWidth;
+ } else {
+ tmp.set(0, 0, imageWidth, imageHeight);
+ iw = imageWidth;
+ ih = imageHeight;
+ }
+ float scale = GeometryMathUtils.scale(iw, ih, viewWidth, viewHeight);
+ scale *= GeometryMathUtils.SHOW_SCALE;
+ GeometryMathUtils.scaleRect(tmp, scale);
+ getUntranslatedStraightenCropBounds(tmp, mAngle);
+ tmp.offset(viewWidth / 2f - tmp.centerX(), viewHeight / 2f - tmp.centerY());
+ h.straighten = 0;
+ Matrix m1 = GeometryMathUtils.getFullGeometryToScreenMatrix(h, imageWidth,
+ imageHeight, viewWidth, viewHeight);
+ m.reset();
+ m1.invert(m);
+ mCrop.set(tmp);
+ m.mapRect(mCrop);
+ FilterCropRepresentation.findNormalizedCrop(mCrop, imageWidth, imageHeight);
}
- @Override
- protected void setActionUp() {
- super.setActionUp();
- setCropToStraighten();
- }
@Override
- public void onNewValue(int value) {
- setLocalStraighten(GeometryMath.clamp(value, MIN_STRAIGHTEN_ANGLE, MAX_STRAIGHTEN_ANGLE));
- invalidate();
- }
+ public void onDraw(Canvas canvas) {
+ MasterImage master = MasterImage.getImage();
+ Bitmap image = master.getFiltersOnlyImage();
+ if (image == null) {
+ MasterImage.getImage().invalidateFiltersOnly();
+ return;
+ }
+ GeometryMathUtils.initializeHolder(mDrawHolder, mLocalRep);
+ mDrawHolder.straighten = mAngle;
+ int imageWidth = image.getWidth();
+ int imageHeight = image.getHeight();
+ int viewWidth = canvas.getWidth();
+ int viewHeight = canvas.getHeight();
- @Override
- protected int getLocalValue() {
- return (int) getLocalStraighten();
- }
+ // Get matrix for drawing bitmap
+ Matrix m = GeometryMathUtils.getFullGeometryToScreenMatrix(mDrawHolder, imageWidth,
+ imageHeight, viewWidth, viewHeight);
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setFilterBitmap(true);
+ canvas.drawBitmap(image, m, mPaint);
- @Override
- protected void drawShape(Canvas canvas, Bitmap image) {
- float [] o = {0, 0};
- RectF bounds = drawTransformed(canvas, image, gPaint, o);
-
+ mPaint.setFilterBitmap(false);
+ mPaint.setColor(Color.WHITE);
+ mPaint.setStrokeWidth(2);
+ mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
+ updateCurrentCrop(m, mDrawHolder, mDrawRect, imageWidth,
+ imageHeight, viewWidth, viewHeight);
+ if (mFirstDrawSinceUp) {
+ mPriorCropAtUp.set(mCrop);
+ mLocalRep.setStraighten(mAngle);
+ mFirstDrawSinceUp = false;
+ }
+ CropDrawingUtils.drawShade(canvas, mDrawRect);
// Draw the grid
- gPaint.setARGB(255, 255, 255, 255);
- gPaint.setStrokeWidth(3);
- gPaint.setStyle(Paint.Style.FILL_AND_STROKE);
-
- RectF display = getLocalDisplayBounds();
- float dWidth = display.width();
- float dHeight = display.height();
-
- if (mMode == MODES.MOVE) {
+ if (mState == MODES.MOVE || mGridAlpha > 0) {
canvas.save();
- canvas.clipRect(bounds);
+ canvas.clipRect(mDrawRect);
- int n = 16;
- float step = dWidth / n;
+ float step = Math.max(viewWidth, viewHeight) / NBLINES;
float p = 0;
- for (int i = 1; i < n; i++) {
+ for (int i = 1; i < NBLINES; i++) {
p = i * step;
- gPaint.setARGB(60, 255, 255, 255);
- canvas.drawLine(p, 0, p, dHeight, gPaint);
- canvas.drawLine(0, p, dWidth, p, gPaint);
+ int alpha = (int) (mDefaultGridAlpha * mGridAlpha);
+ if (alpha == 0 && mState == MODES.MOVE) {
+ alpha = mDefaultGridAlpha;
+ }
+ mPaint.setAlpha(alpha);
+ canvas.drawLine(p, 0, p, viewHeight, mPaint);
+ canvas.drawLine(0, p, viewWidth, p, mPaint);
}
canvas.restore();
}
+ mPaint.reset();
+ mPaint.setColor(Color.WHITE);
+ mPaint.setStyle(Style.STROKE);
+ mPaint.setStrokeWidth(3);
+ mDrawPath.reset();
+
+
+ mDrawPath.addRect(mDrawRect, Path.Direction.CW);
+ canvas.drawPath(mDrawPath, mPaint);
}
public void setEditor(EditorStraighten editorStraighten) {
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java b/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java
index 7ce9e51..9571287 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java
@@ -20,7 +20,6 @@
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.MotionEvent;
import com.android.gallery3d.filtershow.editors.EditorVignette;
@@ -31,7 +30,7 @@
private FilterVignetteRepresentation mVignetteRep;
private EditorVignette mEditorVignette;
-
+ private OvalSpaceAdapter mScreenOval = new OvalSpaceAdapter();
private int mActiveHandle = -1;
EclipseControl mElipse;
@@ -46,8 +45,101 @@
mElipse = new EclipseControl(context);
}
+ static class OvalSpaceAdapter implements Oval {
+ private Oval mOval;
+ Matrix mToScr;
+ Matrix mToImage;
+ int mImgWidth;
+ int mImgHeight;
+ float[] mTmp = new float[2];
+ float mTmpRadiusX;
+ float mTmpRadiusY;
+
+ public void setImageOval(Oval oval) {
+ mOval = oval;
+ }
+
+ public void setTransform(Matrix toScr, Matrix toImage, int imgWidth, int imgHeight) {
+ mToScr = toScr;
+ mToImage = toImage;
+ mImgWidth = imgWidth;
+ mImgHeight = imgHeight;
+ mTmpRadiusX = getRadiusX();
+ mTmpRadiusY = getRadiusY();
+ }
+
+ @Override
+ public void setCenter(float x, float y) {
+ mTmp[0] = x;
+ mTmp[1] = y;
+ mToImage.mapPoints(mTmp);
+ mOval.setCenter(mTmp[0] / mImgWidth, mTmp[1] / mImgHeight);
+ }
+
+ @Override
+ public void setRadius(float w, float h) {
+ mTmp[0] = mTmpRadiusX = w;
+ mTmp[1] = mTmpRadiusY = h;
+ mToImage.mapVectors(mTmp);
+ mOval.setRadius(mTmp[0] / mImgWidth, mTmp[1] / mImgHeight);
+ }
+
+ @Override
+ public float getCenterX() {
+ mTmp[0] = mOval.getCenterX() * mImgWidth;
+ mTmp[1] = mOval.getCenterY() * mImgHeight;
+ mToScr.mapPoints(mTmp);
+
+ return mTmp[0];
+ }
+
+ @Override
+ public float getCenterY() {
+ mTmp[0] = mOval.getCenterX() * mImgWidth;
+ mTmp[1] = mOval.getCenterY() * mImgHeight;
+ mToScr.mapPoints(mTmp);
+ return mTmp[1];
+ }
+
+ @Override
+ public float getRadiusX() {
+ mTmp[0] = mOval.getRadiusX() * mImgWidth;
+ mTmp[1] = mOval.getRadiusY() * mImgHeight;
+ mToScr.mapVectors(mTmp);
+ return Math.abs(mTmp[0]);
+ }
+
+ @Override
+ public float getRadiusY() {
+ mTmp[0] = mOval.getRadiusX() * mImgWidth;
+ mTmp[1] = mOval.getRadiusY() * mImgHeight;
+ mToScr.mapVectors(mTmp);
+ return Math.abs(mTmp[1]);
+ }
+
+ @Override
+ public void setRadiusY(float y) {
+ mTmp[0] = mTmpRadiusX;
+ mTmp[1] = mTmpRadiusY = y;
+ mToImage.mapVectors(mTmp);
+ mOval.setRadiusX(mTmp[0] / mImgWidth);
+ mOval.setRadiusY(mTmp[1] / mImgHeight);
+ }
+
+ @Override
+ public void setRadiusX(float x) {
+ mTmp[0] = mTmpRadiusX = x;
+ mTmp[1] = mTmpRadiusY;
+ mToImage.mapVectors(mTmp);
+ mOval.setRadiusX(mTmp[0] / mImgWidth);
+ mOval.setRadiusY(mTmp[1] / mImgHeight);
+ }
+ }
+
@Override
public boolean onTouchEvent(MotionEvent event) {
+ int w = MasterImage.getImage().getOriginalBounds().width();
+ int h = MasterImage.getImage().getOriginalBounds().height();
int mask = event.getActionMasked();
if (mActiveHandle == -1) {
if (MotionEvent.ACTION_DOWN != mask) {
@@ -71,16 +163,18 @@
float x = event.getX();
float y = event.getY();
- mElipse.setScrToImageMatrix(getScreenToImageMatrix(true));
+ mElipse.setScrImageInfo(new Matrix(),
+ MasterImage.getImage().getOriginalBounds());
boolean didComputeEllipses = false;
switch (mask) {
case (MotionEvent.ACTION_DOWN):
- mElipse.actionDown(x, y, mVignetteRep);
+ mElipse.actionDown(x, y, mScreenOval);
break;
case (MotionEvent.ACTION_UP):
case (MotionEvent.ACTION_MOVE):
- mElipse.actionMove(mActiveHandle, x, y, mVignetteRep);
+
+ mElipse.actionMove(mActiveHandle, x, y, mScreenOval);
setRepresentation(mVignetteRep);
didComputeEllipses = true;
break;
@@ -94,6 +188,7 @@
public void setRepresentation(FilterVignetteRepresentation vignetteRep) {
mVignetteRep = vignetteRep;
+ mScreenOval.setImageOval(mVignetteRep);
computeEllipses();
}
@@ -101,35 +196,16 @@
if (mVignetteRep == null) {
return;
}
+ float w = MasterImage.getImage().getOriginalBounds().width();
+ float h = MasterImage.getImage().getOriginalBounds().height();
Matrix toImg = getScreenToImageMatrix(false);
Matrix toScr = new Matrix();
toImg.invert(toScr);
+ mScreenOval.setTransform(toScr, toImg, (int) w, (int) h);
- float[] c = new float[] {
- mVignetteRep.getCenterX(), mVignetteRep.getCenterY() };
- if (Float.isNaN(c[0])) {
- float cx = mImageLoader.getOriginalBounds().width() / 2;
- float cy = mImageLoader.getOriginalBounds().height() / 2;
- float rx = Math.min(cx, cy) * .8f;
- float ry = rx;
- mVignetteRep.setCenter(cx, cy);
- mVignetteRep.setRadius(rx, ry);
+ mElipse.setCenter(mScreenOval.getCenterX(), mScreenOval.getCenterY());
+ mElipse.setRadius(mScreenOval.getRadiusX(), mScreenOval.getRadiusY());
- c[0] = cx;
- c[1] = cy;
- toScr.mapPoints(c);
- if (getWidth() != 0) {
- mElipse.setCenter(c[0], c[1]);
- mElipse.setRadius(c[0] * 0.8f, c[1] * 0.8f);
- }
- } else {
-
- toScr.mapPoints(c);
-
- mElipse.setCenter(c[0], c[1]);
- mElipse.setRadius(toScr.mapRadius(mVignetteRep.getRadiusX()),
- toScr.mapRadius(mVignetteRep.getRadiusY()));
- }
mEditorVignette.commitLocalRepresentation();
}
@@ -139,7 +215,7 @@
@Override
public void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
+ super.onSizeChanged(w, h, oldw, oldh);
computeEllipses();
}
@@ -149,15 +225,14 @@
if (mVignetteRep == null) {
return;
}
+ float w = MasterImage.getImage().getOriginalBounds().width();
+ float h = MasterImage.getImage().getOriginalBounds().height();
Matrix toImg = getScreenToImageMatrix(false);
Matrix toScr = new Matrix();
toImg.invert(toScr);
- float[] c = new float[] {
- mVignetteRep.getCenterX(), mVignetteRep.getCenterY() };
- toScr.mapPoints(c);
- mElipse.setCenter(c[0], c[1]);
- mElipse.setRadius(toScr.mapRadius(mVignetteRep.getRadiusX()),
- toScr.mapRadius(mVignetteRep.getRadiusY()));
+ mScreenOval.setTransform(toScr, toImg, (int) w, (int) h);
+ mElipse.setCenter(mScreenOval.getCenterX(), mScreenOval.getCenterY());
+ mElipse.setRadius(mScreenOval.getRadiusX(), mScreenOval.getRadiusY());
mElipse.draw(canvas);
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/Line.java b/src/com/android/gallery3d/filtershow/imageshow/Line.java
new file mode 100644
index 0000000..a767bd8
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/Line.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+public interface Line {
+ void setPoint1(float x, float y);
+ void setPoint2(float x, float y);
+ float getPoint1X();
+ float getPoint1Y();
+ float getPoint2X();
+ float getPoint2Y();
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index a0b59c0..3513ded 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -16,54 +16,94 @@
package com.android.gallery3d.filtershow.imageshow;
-import android.graphics.*;
-import android.os.Handler;
-import android.os.Message;
+import android.animation.Animator;
+import android.animation.ValueAnimator;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.net.Uri;
+import com.android.gallery3d.exif.ExifTag;
import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.HistoryAdapter;
-import com.android.gallery3d.filtershow.cache.*;
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilter;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
+import com.android.gallery3d.filtershow.history.HistoryItem;
+import com.android.gallery3d.filtershow.history.HistoryManager;
+import com.android.gallery3d.filtershow.pipeline.Buffer;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequest;
+import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
+import com.android.gallery3d.filtershow.pipeline.SharedBuffer;
+import com.android.gallery3d.filtershow.pipeline.SharedPreset;
import com.android.gallery3d.filtershow.state.StateAdapter;
+import java.util.List;
import java.util.Vector;
public class MasterImage implements RenderingRequestCaller {
private static final String LOGTAG = "MasterImage";
private boolean DEBUG = false;
- private static final boolean DISABLEZOOM = true;
+ private static final boolean DISABLEZOOM = false;
+ public static final int SMALL_BITMAP_DIM = 160;
+ public static final int MAX_BITMAP_DIM = 900;
private static MasterImage sMasterImage = null;
- private static int sIconSeedSize = 128;
- private static float sHistoryPreviewSize = 128.0f;
private boolean mSupportsHighRes = false;
private ImageFilter mCurrentFilter = null;
private ImagePreset mPreset = null;
+ private ImagePreset mLoadedPreset = null;
private ImagePreset mGeometryOnlyPreset = null;
private ImagePreset mFiltersOnlyPreset = null;
- private TripleBufferBitmap mFilteredPreview = new TripleBufferBitmap();
+ private SharedBuffer mPreviewBuffer = new SharedBuffer();
+ private SharedPreset mPreviewPreset = new SharedPreset();
+
+ private Bitmap mOriginalBitmapSmall = null;
+ private Bitmap mOriginalBitmapLarge = null;
+ private Bitmap mOriginalBitmapHighres = null;
+ private Bitmap mTemporaryThumbnail = null;
+ private int mOrientation;
+ private Rect mOriginalBounds;
+ private final Vector<ImageShow> mLoadListeners = new Vector<ImageShow>();
+ private Uri mUri = null;
+ private int mZoomOrientation = ImageLoader.ORI_NORMAL;
private Bitmap mGeometryOnlyBitmap = null;
private Bitmap mFiltersOnlyBitmap = null;
private Bitmap mPartialBitmap = null;
private Bitmap mHighresBitmap = null;
+ private Bitmap mPreviousImage = null;
+ private int mShadowMargin = 15; // not scaled, fixed in the asset
+ private Rect mPartialBounds = new Rect();
- private ImageLoader mLoader = null;
- private HistoryAdapter mHistory = null;
+ private ValueAnimator mAnimator = null;
+ private float mMaskScale = 1;
+ private boolean mOnGoingNewLookAnimation = false;
+ private float mAnimRotationValue = 0;
+ private float mCurrentAnimRotationStartValue = 0;
+ private float mAnimFraction = 0;
+ private int mCurrentLookAnimation = 0;
+ public static final int CIRCLE_ANIMATION = 1;
+ public static final int ROTATE_ANIMATION = 2;
+ public static final int MIRROR_ANIMATION = 3;
+
+ private HistoryManager mHistory = null;
private StateAdapter mState = null;
private FilterShowActivity mActivity = null;
private Vector<ImageShow> mObservers = new Vector<ImageShow>();
private FilterRepresentation mCurrentFilterRepresentation;
- private Vector<GeometryListener> mGeometryListeners = new Vector<GeometryListener>();
-
- private GeometryMetadata mPreviousGeometry = null;
private float mScaleFactor = 1.0f;
private float mMaxScaleFactor = 3.0f; // TODO: base this on the current view / image
@@ -73,20 +113,8 @@
private Point mImageShowSize = new Point();
private boolean mShowsOriginal;
-
- final private static int NEW_GEOMETRY = 1;
-
- private final Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case NEW_GEOMETRY: {
- hasNewGeometry();
- break;
- }
- }
- }
- };
+ private List<ExifTag> mEXIF;
+ private BitmapCache mBitmapCache = new BitmapCache();
private MasterImage() {
}
@@ -103,12 +131,93 @@
return sMasterImage;
}
- public void setSupportsHighRes(boolean value) {
- mSupportsHighRes = value;
+ public Bitmap getOriginalBitmapSmall() {
+ return mOriginalBitmapSmall;
}
- public static void setIconSeedSize(int iconSeedSize) {
- sIconSeedSize = iconSeedSize;
+ public Bitmap getOriginalBitmapLarge() {
+ return mOriginalBitmapLarge;
+ }
+
+ public Bitmap getOriginalBitmapHighres() {
+ if (mOriginalBitmapHighres == null) {
+ return mOriginalBitmapLarge;
+ }
+ return mOriginalBitmapHighres;
+ }
+
+ public void setOriginalBitmapHighres(Bitmap mOriginalBitmapHighres) {
+ this.mOriginalBitmapHighres = mOriginalBitmapHighres;
+ }
+
+ public int getOrientation() {
+ return mOrientation;
+ }
+
+ public Rect getOriginalBounds() {
+ return mOriginalBounds;
+ }
+
+ public void setOriginalBounds(Rect r) {
+ mOriginalBounds = r;
+ }
+
+ public Uri getUri() {
+ return mUri;
+ }
+
+ public void setUri(Uri uri) {
+ mUri = uri;
+ }
+
+ public int getZoomOrientation() {
+ return mZoomOrientation;
+ }
+
+ public void addListener(ImageShow imageShow) {
+ if (!mLoadListeners.contains(imageShow)) {
+ mLoadListeners.add(imageShow);
+ }
+ }
+
+ public void warnListeners() {
+ mActivity.runOnUiThread(mWarnListenersRunnable);
+ }
+
+ private Runnable mWarnListenersRunnable = new Runnable() {
+ @Override
+ public void run() {
+ for (int i = 0; i < mLoadListeners.size(); i++) {
+ ImageShow imageShow = mLoadListeners.elementAt(i);
+ imageShow.imageLoaded();
+ }
+ invalidatePreview();
+ }
+ };
+
+ public boolean loadBitmap(Uri uri, int size) {
+ setUri(uri);
+ mEXIF = ImageLoader.getExif(getActivity(), uri);
+ mOrientation = ImageLoader.getMetadataOrientation(mActivity, uri);
+ Rect originalBounds = new Rect();
+ mOriginalBitmapLarge = ImageLoader.loadOrientedConstrainedBitmap(uri, mActivity,
+ Math.min(MAX_BITMAP_DIM, size),
+ mOrientation, originalBounds);
+ setOriginalBounds(originalBounds);
+ if (mOriginalBitmapLarge == null) {
+ return false;
+ }
+ int sw = SMALL_BITMAP_DIM;
+ int sh = (int) (sw * (float) mOriginalBitmapLarge.getHeight() / mOriginalBitmapLarge
+ .getWidth());
+ mOriginalBitmapSmall = Bitmap.createScaledBitmap(mOriginalBitmapLarge, sw, sh, true);
+ mZoomOrientation = mOrientation;
+ warnListeners();
+ return true;
+ }
+
+ public void setSupportsHighRes(boolean value) {
+ mSupportsHighRes = value;
}
public void addObserver(ImageShow observer) {
@@ -118,12 +227,16 @@
mObservers.add(observer);
}
+ public void removeObserver(ImageShow observer) {
+ mObservers.remove(observer);
+ }
+
public void setActivity(FilterShowActivity activity) {
mActivity = activity;
}
- public ImageLoader getLoader() {
- return mLoader;
+ public FilterShowActivity getActivity() {
+ return mActivity;
}
public synchronized ImagePreset getPreset() {
@@ -138,63 +251,33 @@
return mFiltersOnlyPreset;
}
- public synchronized void setPreset(ImagePreset preset, boolean addToHistory) {
+ public synchronized void setPreset(ImagePreset preset,
+ FilterRepresentation change,
+ boolean addToHistory) {
+ if (DEBUG) {
+ preset.showFilters();
+ }
mPreset = preset;
- mPreset.setImageLoader(mLoader);
- setGeometry();
mPreset.fillImageStateAdapter(mState);
if (addToHistory) {
- mHistory.addHistoryItem(mPreset);
+ HistoryItem historyItem = new HistoryItem(mPreset, change);
+ mHistory.addHistoryItem(historyItem);
}
updatePresets(true);
- GeometryMetadata geo = mPreset.mGeoData;
- if (!geo.equals(mPreviousGeometry)) {
- notifyGeometryChange();
- }
- mPreviousGeometry = new GeometryMetadata(geo);
- }
-
- private void renderHistoryPreview() {
- ImagePreset historyPreset = mPreset;
- if (historyPreset != null) {
- Bitmap preview = mLoader.getOriginalBitmapSmall();
- if (preview != null) {
- float s = Math.min(preview.getWidth(), preview.getHeight());
- float f = sHistoryPreviewSize / s;
- int w = (int) (preview.getWidth() * f);
- int h = (int) (preview.getHeight() * f);
- Bitmap historyPreview = Bitmap.createScaledBitmap(preview, w, h, true);
- historyPreset.setPreviewImage(historyPreview);
- RenderingRequest.post(historyPreview,
- historyPreset, RenderingRequest.ICON_RENDERING, this);
- }
- }
- }
-
- private void setGeometry() {
- Bitmap image = mLoader.getOriginalBitmapLarge();
- if (image == null) {
- return;
- }
- float w = image.getWidth();
- float h = image.getHeight();
- GeometryMetadata geo = mPreset.mGeoData;
- RectF pb = geo.getPhotoBounds();
- if (w == pb.width() && h == pb.height()) {
- return;
- }
- RectF r = new RectF(0, 0, w, h);
- geo.setPhotoBounds(r);
- geo.setCropBounds(r);
+ resetGeometryImages(false);
+ mActivity.updateCategories();
}
public void onHistoryItemClick(int position) {
- setPreset(new ImagePreset(mHistory.getItem(position)), false);
+ HistoryItem historyItem = mHistory.getItem(position);
// We need a copy from the history
+ ImagePreset newPreset = new ImagePreset(historyItem.getImagePreset());
+ // don't need to add it to the history
+ setPreset(newPreset, historyItem.getFilterRepresentation(), false);
mHistory.setCurrentPreset(position);
}
- public HistoryAdapter getHistory() {
+ public HistoryManager getHistory() {
return mHistory;
}
@@ -202,7 +285,7 @@
return mState;
}
- public void setHistoryAdapter(HistoryAdapter adapter) {
+ public void setHistoryManager(HistoryManager adapter) {
mHistory = adapter;
}
@@ -210,14 +293,6 @@
mState = adapter;
}
- public void setImageLoader(ImageLoader loader) {
- mLoader = loader;
- }
-
- public ImageLoader getImageLoader() {
- return mLoader;
- }
-
public void setCurrentFilter(ImageFilter filter) {
mCurrentFilter = filter;
}
@@ -227,28 +302,40 @@
}
public synchronized boolean hasModifications() {
+ // TODO: We need to have a better same effects check to see if two
+ // presets are functionally the same. Right now, we are relying on a
+ // stricter check as equals().
+ ImagePreset loadedPreset = getLoadedPreset();
if (mPreset == null) {
- return false;
+ if (loadedPreset == null) {
+ return false;
+ } else {
+ return loadedPreset.hasModifications();
+ }
+ } else {
+ if (loadedPreset == null) {
+ return mPreset.hasModifications();
+ } else {
+ return !mPreset.equals(loadedPreset);
+ }
}
- return mPreset.hasModifications();
}
- public TripleBufferBitmap getDoubleBuffer() {
- return mFilteredPreview;
+ public SharedBuffer getPreviewBuffer() {
+ return mPreviewBuffer;
}
- public void setOriginalGeometry(Bitmap originalBitmapLarge) {
- GeometryMetadata geo = getPreset().mGeoData;
- float w = originalBitmapLarge.getWidth();
- float h = originalBitmapLarge.getHeight();
- RectF r = new RectF(0, 0, w, h);
- geo.setPhotoBounds(r);
- geo.setCropBounds(r);
- getPreset().setGeometry(geo);
+ public SharedPreset getPreviewPreset() {
+ return mPreviewPreset;
}
public Bitmap getFilteredImage() {
- return mFilteredPreview.getConsumer();
+ mPreviewBuffer.swapConsumerIfNeeded(); // get latest bitmap
+ Buffer consumer = mPreviewBuffer.getConsumer();
+ if (consumer != null) {
+ return consumer.getBitmap();
+ }
+ return null;
}
public Bitmap getFiltersOnlyImage() {
@@ -263,41 +350,164 @@
return mPartialBitmap;
}
+ public Rect getPartialBounds() {
+ return mPartialBounds;
+ }
+
public Bitmap getHighresImage() {
+ if (mHighresBitmap == null) {
+ return getFilteredImage();
+ }
return mHighresBitmap;
}
+ public Bitmap getPreviousImage() {
+ return mPreviousImage;
+ }
+
+ public ImagePreset getCurrentPreset() {
+ return getPreviewBuffer().getConsumer().getPreset();
+ }
+
+ public float getMaskScale() {
+ return mMaskScale;
+ }
+
+ public void setMaskScale(float scale) {
+ mMaskScale = scale;
+ notifyObservers();
+ }
+
+ public float getAnimRotationValue() {
+ return mAnimRotationValue;
+ }
+
+ public void setAnimRotation(float rotation) {
+ mAnimRotationValue = mCurrentAnimRotationStartValue + rotation;
+ notifyObservers();
+ }
+
+ public void setAnimFraction(float fraction) {
+ mAnimFraction = fraction;
+ }
+
+ public float getAnimFraction() {
+ return mAnimFraction;
+ }
+
+ public boolean onGoingNewLookAnimation() {
+ return mOnGoingNewLookAnimation;
+ }
+
+ public int getCurrentLookAnimation() {
+ return mCurrentLookAnimation;
+ }
+
+ public void resetAnimBitmap() {
+ mBitmapCache.cache(mPreviousImage);
+ mPreviousImage = null;
+ }
+
+ public void onNewLook(FilterRepresentation newRepresentation) {
+ if (getFilteredImage() == null) {
+ return;
+ }
+ if (mAnimator != null) {
+ mAnimator.cancel();
+ if (mCurrentLookAnimation == ROTATE_ANIMATION) {
+ mCurrentAnimRotationStartValue += 90;
+ }
+ } else {
+ resetAnimBitmap();
+ mPreviousImage = mBitmapCache.getBitmapCopy(getFilteredImage(), BitmapCache.NEW_LOOK);
+ }
+ if (newRepresentation instanceof FilterUserPresetRepresentation) {
+ mCurrentLookAnimation = CIRCLE_ANIMATION;
+ mAnimator = ValueAnimator.ofFloat(0, 1);
+ mAnimator.setDuration(650);
+ }
+ if (newRepresentation instanceof FilterRotateRepresentation) {
+ mCurrentLookAnimation = ROTATE_ANIMATION;
+ mAnimator = ValueAnimator.ofFloat(0, 90);
+ mAnimator.setDuration(500);
+ }
+ if (newRepresentation instanceof FilterMirrorRepresentation) {
+ mCurrentLookAnimation = MIRROR_ANIMATION;
+ mAnimator = ValueAnimator.ofFloat(1, 0, -1);
+ mAnimator.setDuration(500);
+ }
+ mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ if (mCurrentLookAnimation == CIRCLE_ANIMATION) {
+ setMaskScale((Float) animation.getAnimatedValue());
+ } else if (mCurrentLookAnimation == ROTATE_ANIMATION
+ || mCurrentLookAnimation == MIRROR_ANIMATION) {
+ setAnimRotation((Float) animation.getAnimatedValue());
+ setAnimFraction(animation.getAnimatedFraction());
+ }
+ }
+ });
+ mAnimator.addListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mOnGoingNewLookAnimation = true;
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mOnGoingNewLookAnimation = false;
+ mCurrentAnimRotationStartValue = 0;
+ mAnimator = null;
+ notifyObservers();
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
+ });
+ mAnimator.start();
+ notifyObservers();
+ }
+
public void notifyObservers() {
for (ImageShow observer : mObservers) {
observer.invalidate();
}
}
+ public void resetGeometryImages(boolean force) {
+ if (mPreset == null) {
+ return;
+ }
+ ImagePreset newPresetGeometryOnly = new ImagePreset(mPreset);
+ newPresetGeometryOnly.setDoApplyFilters(false);
+ newPresetGeometryOnly.setDoApplyGeometry(true);
+ if (force || mGeometryOnlyPreset == null
+ || !newPresetGeometryOnly.equals(mGeometryOnlyPreset)) {
+ mGeometryOnlyPreset = newPresetGeometryOnly;
+ RenderingRequest.post(mActivity, null,
+ mGeometryOnlyPreset, RenderingRequest.GEOMETRY_RENDERING, this);
+ }
+ ImagePreset newPresetFiltersOnly = new ImagePreset(mPreset);
+ newPresetFiltersOnly.setDoApplyFilters(true);
+ newPresetFiltersOnly.setDoApplyGeometry(false);
+ if (force || mFiltersOnlyPreset == null
+ || !newPresetFiltersOnly.same(mFiltersOnlyPreset)) {
+ mFiltersOnlyPreset = newPresetFiltersOnly;
+ RenderingRequest.post(mActivity, null,
+ mFiltersOnlyPreset, RenderingRequest.FILTERS_RENDERING, this);
+ }
+ }
+
public void updatePresets(boolean force) {
- if (force || mGeometryOnlyPreset == null) {
- ImagePreset newPreset = new ImagePreset(mPreset);
- newPreset.setDoApplyFilters(false);
- newPreset.setDoApplyGeometry(true);
- if (force || mGeometryOnlyPreset == null
- || !newPreset.same(mGeometryOnlyPreset)) {
- mGeometryOnlyPreset = newPreset;
- RenderingRequest.post(mLoader.getOriginalBitmapLarge(),
- mGeometryOnlyPreset, RenderingRequest.GEOMETRY_RENDERING, this);
- }
- }
- if (force || mFiltersOnlyPreset == null) {
- ImagePreset newPreset = new ImagePreset(mPreset);
- newPreset.setDoApplyFilters(true);
- newPreset.setDoApplyGeometry(false);
- if (force || mFiltersOnlyPreset == null
- || !newPreset.same(mFiltersOnlyPreset)) {
- mFiltersOnlyPreset = newPreset;
- RenderingRequest.post(mLoader.getOriginalBitmapLarge(),
- mFiltersOnlyPreset, RenderingRequest.FILTERS_RENDERING, this);
- }
- }
invalidatePreview();
- mActivity.enableSave(hasModifications());
}
public FilterRepresentation getCurrentFilterRepresentation() {
@@ -310,11 +520,12 @@
public void invalidateFiltersOnly() {
mFiltersOnlyPreset = null;
- updatePresets(false);
+ invalidatePreview();
}
public void invalidatePartialPreview() {
if (mPartialBitmap != null) {
+ mBitmapCache.cache(mPartialBitmap);
mPartialBitmap = null;
notifyObservers();
}
@@ -322,42 +533,104 @@
public void invalidateHighresPreview() {
if (mHighresBitmap != null) {
+ mBitmapCache.cache(mHighresBitmap);
mHighresBitmap = null;
notifyObservers();
}
}
public void invalidatePreview() {
- mFilteredPreview.invalidate();
+ if (mPreset == null) {
+ return;
+ }
+
+ mPreviewPreset.enqueuePreset(mPreset);
+ mPreviewBuffer.invalidate();
invalidatePartialPreview();
invalidateHighresPreview();
needsUpdatePartialPreview();
needsUpdateHighResPreview();
- FilteringPipeline.getPipeline().updatePreviewBuffer();
+ mActivity.getProcessingService().updatePreviewBuffer();
}
public void setImageShowSize(int w, int h) {
if (mImageShowSize.x != w || mImageShowSize.y != h) {
mImageShowSize.set(w, h);
+ float maxWidth = mOriginalBounds.width() / (float) w;
+ float maxHeight = mOriginalBounds.height() / (float) h;
+ mMaxScaleFactor = Math.max(3.f, Math.max(maxWidth, maxHeight));
needsUpdatePartialPreview();
needsUpdateHighResPreview();
}
}
+ public Matrix originalImageToScreen() {
+ return computeImageToScreen(null, 0, true);
+ }
+
+ public Matrix computeImageToScreen(Bitmap bitmapToDraw,
+ float rotate,
+ boolean applyGeometry) {
+ if (getOriginalBounds() == null
+ || mImageShowSize.x == 0
+ || mImageShowSize.y == 0) {
+ return null;
+ }
+
+ Matrix m = null;
+ float scale = 1f;
+ float translateX = 0;
+ float translateY = 0;
+
+ if (applyGeometry) {
+ GeometryMathUtils.GeometryHolder holder = GeometryMathUtils.unpackGeometry(
+ mPreset.getGeometryFilters());
+ m = GeometryMathUtils.getCropSelectionToScreenMatrix(null, holder,
+ getOriginalBounds().width(), getOriginalBounds().height(),
+ mImageShowSize.x, mImageShowSize.y);
+ } else if (bitmapToDraw != null) {
+ m = new Matrix();
+ RectF size = new RectF(0, 0,
+ bitmapToDraw.getWidth(),
+ bitmapToDraw.getHeight());
+ scale = mImageShowSize.x / size.width();
+ if (size.width() < size.height()) {
+ scale = mImageShowSize.y / size.height();
+ }
+ translateX = (mImageShowSize.x - (size.width() * scale)) / 2.0f;
+ translateY = (mImageShowSize.y - (size.height() * scale)) / 2.0f;
+ } else {
+ return null;
+ }
+
+ Point translation = getTranslation();
+ m.postScale(scale, scale);
+ m.postRotate(rotate, mImageShowSize.x / 2.0f, mImageShowSize.y / 2.0f);
+ m.postTranslate(translateX, translateY);
+ m.postTranslate(mShadowMargin, mShadowMargin);
+ m.postScale(getScaleFactor(), getScaleFactor(),
+ mImageShowSize.x / 2.0f,
+ mImageShowSize.y / 2.0f);
+ m.postTranslate(translation.x * getScaleFactor(),
+ translation.y * getScaleFactor());
+ return m;
+ }
+
private Matrix getImageToScreenMatrix(boolean reflectRotation) {
- GeometryMetadata geo = mPreset.mGeoData;
- if (geo == null || mLoader == null
- || mLoader.getOriginalBounds() == null
- || mImageShowSize.x == 0) {
+ if (getOriginalBounds() == null || mImageShowSize.x == 0 || mImageShowSize.y == 0) {
return new Matrix();
}
- Matrix m = geo.getOriginalToScreen(reflectRotation,
- mLoader.getOriginalBounds().width(),
- mLoader.getOriginalBounds().height(), mImageShowSize.x, mImageShowSize.y);
+ Matrix m = GeometryMathUtils.getImageToScreenMatrix(mPreset.getGeometryFilters(),
+ reflectRotation, getOriginalBounds(), mImageShowSize.x, mImageShowSize.y);
+ if (m == null) {
+ m = new Matrix();
+ m.reset();
+ return m;
+ }
Point translate = getTranslation();
float scaleFactor = getScaleFactor();
m.postTranslate(translate.x, translate.y);
- m.postScale(scaleFactor, scaleFactor, mImageShowSize.x/2.0f, mImageShowSize.y/2.0f);
+ m.postScale(scaleFactor, scaleFactor, mImageShowSize.x / 2.0f, mImageShowSize.y / 2.0f);
return m;
}
@@ -372,23 +645,41 @@
if (!mSupportsHighRes) {
return;
}
- RenderingRequest.post(null, mPreset, RenderingRequest.HIGHRES_RENDERING, this);
+ if (mActivity.getProcessingService() == null) {
+ return;
+ }
+ if (mPreset == null) {
+ return;
+ }
+ mActivity.getProcessingService().postHighresRenderingRequest(mPreset,
+ getScaleFactor(), this);
invalidateHighresPreview();
}
public void needsUpdatePartialPreview() {
+ if (mPreset == null) {
+ return;
+ }
if (!mPreset.canDoPartialRendering()) {
invalidatePartialPreview();
return;
}
- Matrix m = getScreenToImageMatrix(true);
- RectF r = new RectF(0, 0, mImageShowSize.x, mImageShowSize.y);
- RectF dest = new RectF();
- m.mapRect(dest, r);
- Rect bounds = new Rect();
- dest.roundOut(bounds);
- RenderingRequest.post(null, mPreset, RenderingRequest.PARTIAL_RENDERING,
- this, bounds, new Rect(0, 0, mImageShowSize.x, mImageShowSize.y));
+ Matrix originalToScreen = MasterImage.getImage().originalImageToScreen();
+ if (originalToScreen == null) {
+ return;
+ }
+ Matrix screenToOriginal = new Matrix();
+ originalToScreen.invert(screenToOriginal);
+ RectF bounds = new RectF(0, 0,
+ mImageShowSize.x + 2 * mShadowMargin,
+ mImageShowSize.y + 2 * mShadowMargin);
+ screenToOriginal.mapRect(bounds);
+ Rect rBounds = new Rect();
+ bounds.roundOut(rBounds);
+
+ mActivity.getProcessingService().postFullresRenderingRequest(mPreset,
+ getScaleFactor(), rBounds,
+ new Rect(0, 0, mImageShowSize.x, mImageShowSize.y), this);
invalidatePartialPreview();
}
@@ -397,27 +688,35 @@
if (request.getBitmap() == null) {
return;
}
+
+ boolean needsCheckModification = false;
if (request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
+ mBitmapCache.cache(mGeometryOnlyBitmap);
mGeometryOnlyBitmap = request.getBitmap();
+ needsCheckModification = true;
}
if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ mBitmapCache.cache(mFiltersOnlyBitmap);
mFiltersOnlyBitmap = request.getBitmap();
+ notifyObservers();
+ needsCheckModification = true;
}
if (request.getType() == RenderingRequest.PARTIAL_RENDERING
&& request.getScaleFactor() == getScaleFactor()) {
+ mBitmapCache.cache(mPartialBitmap);
mPartialBitmap = request.getBitmap();
+ mPartialBounds.set(request.getBounds());
notifyObservers();
+ needsCheckModification = true;
}
if (request.getType() == RenderingRequest.HIGHRES_RENDERING) {
+ mBitmapCache.cache(mHighresBitmap);
mHighresBitmap = request.getBitmap();
notifyObservers();
+ needsCheckModification = true;
}
-
- if (request.getType() == RenderingRequest.ICON_RENDERING) {
- // History preview images
- ImagePreset preset = request.getOriginalImagePreset();
- preset.setPreviewImage(request.getBitmap());
- mHistory.notifyDataSetChanged();
+ if (needsCheckModification) {
+ mActivity.enableSave(hasModifications());
}
}
@@ -425,25 +724,6 @@
sMasterImage = null;
}
- public void addGeometryListener(GeometryListener listener) {
- mGeometryListeners.add(listener);
- }
-
- public void notifyGeometryChange() {
- if (mHandler.hasMessages(NEW_GEOMETRY)) {
- return;
- }
- mHandler.sendEmptyMessage(NEW_GEOMETRY);
- }
-
- public void hasNewGeometry() {
- updatePresets(true);
- for (GeometryListener listener : mGeometryListeners) {
- listener.geometryChanged();
- }
- }
-
-
public float getScaleFactor() {
return mScaleFactor;
}
@@ -492,12 +772,22 @@
needsUpdatePartialPreview();
}
+ public Bitmap getTemporaryThumbnailBitmap() {
+ if (mTemporaryThumbnail == null
+ && getOriginalBitmapSmall() != null) {
+ mTemporaryThumbnail = getOriginalBitmapSmall().copy(Bitmap.Config.ARGB_8888, true);
+ Canvas canvas = new Canvas(mTemporaryThumbnail);
+ canvas.drawARGB(200, 80, 80, 80);
+ }
+ return mTemporaryThumbnail;
+ }
+
public Bitmap getThumbnailBitmap() {
- return mLoader.getOriginalBitmapSmall();
+ return getOriginalBitmapSmall();
}
public Bitmap getLargeThumbnailBitmap() {
- return mLoader.getOriginalBitmapLarge();
+ return getOriginalBitmapLarge();
}
public float getMaxScaleFactor() {
@@ -523,4 +813,20 @@
public boolean showsOriginal() {
return mShowsOriginal;
}
+
+ public void setLoadedPreset(ImagePreset preset) {
+ mLoadedPreset = preset;
+ }
+
+ public ImagePreset getLoadedPreset() {
+ return mLoadedPreset;
+ }
+
+ public List<ExifTag> getEXIF() {
+ return mEXIF;
+ }
+
+ public BitmapCache getBitmapCache() {
+ return mBitmapCache;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/Spline.java b/src/com/android/gallery3d/filtershow/imageshow/Spline.java
new file mode 100644
index 0000000..3c27a4d
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/Spline.java
@@ -0,0 +1,450 @@
+/*
+ * 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.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.drawable.Drawable;
+import android.util.Log;
+
+import java.util.Collections;
+import java.util.Vector;
+
+public class Spline {
+ private final Vector<ControlPoint> mPoints;
+ private static Drawable mCurveHandle;
+ private static int mCurveHandleSize;
+ private static int mCurveWidth;
+
+ public static final int RGB = 0;
+ public static final int RED = 1;
+ public static final int GREEN = 2;
+ public static final int BLUE = 3;
+ private static final String LOGTAG = "Spline";
+
+ private final Paint gPaint = new Paint();
+ private ControlPoint mCurrentControlPoint = null;
+
+ public Spline() {
+ mPoints = new Vector<ControlPoint>();
+ }
+
+ public Spline(Spline spline) {
+ mPoints = new Vector<ControlPoint>();
+ for (int i = 0; i < spline.mPoints.size(); i++) {
+ ControlPoint p = spline.mPoints.elementAt(i);
+ ControlPoint newPoint = new ControlPoint(p);
+ mPoints.add(newPoint);
+ if (spline.mCurrentControlPoint == p) {
+ mCurrentControlPoint = newPoint;
+ }
+ }
+ Collections.sort(mPoints);
+ }
+
+ public static void setCurveHandle(Drawable drawable, int size) {
+ mCurveHandle = drawable;
+ mCurveHandleSize = size;
+ }
+
+ public static void setCurveWidth(int width) {
+ mCurveWidth = width;
+ }
+
+ public static int curveHandleSize() {
+ return mCurveHandleSize;
+ }
+
+ public static int colorForCurve(int curveIndex) {
+ switch (curveIndex) {
+ case Spline.RED:
+ return Color.RED;
+ case GREEN:
+ return Color.GREEN;
+ case BLUE:
+ return Color.BLUE;
+ }
+ return Color.WHITE;
+ }
+
+ public boolean sameValues(Spline other) {
+ if (this == other) {
+ return true;
+ }
+ if (other == null) {
+ return false;
+ }
+
+ if (getNbPoints() != other.getNbPoints()) {
+ return false;
+ }
+
+ for (int i = 0; i < getNbPoints(); i++) {
+ ControlPoint p = mPoints.elementAt(i);
+ ControlPoint otherPoint = other.mPoints.elementAt(i);
+ if (!p.sameValues(otherPoint)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private void didMovePoint(ControlPoint point) {
+ mCurrentControlPoint = point;
+ }
+
+ public void movePoint(int pick, float x, float y) {
+ if (pick < 0 || pick > mPoints.size() - 1) {
+ return;
+ }
+ ControlPoint point = mPoints.elementAt(pick);
+ point.x = x;
+ point.y = y;
+ didMovePoint(point);
+ }
+
+ public boolean isOriginal() {
+ if (this.getNbPoints() != 2) {
+ return false;
+ }
+ if (mPoints.elementAt(0).x != 0 || mPoints.elementAt(0).y != 1) {
+ return false;
+ }
+ if (mPoints.elementAt(1).x != 1 || mPoints.elementAt(1).y != 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public void reset() {
+ mPoints.clear();
+ addPoint(0.0f, 1.0f);
+ addPoint(1.0f, 0.0f);
+ }
+
+ private void drawHandles(Canvas canvas, Drawable indicator, float centerX, float centerY) {
+ int left = (int) centerX - mCurveHandleSize / 2;
+ int top = (int) centerY - mCurveHandleSize / 2;
+ indicator.setBounds(left, top, left + mCurveHandleSize, top + mCurveHandleSize);
+ indicator.draw(canvas);
+ }
+
+ public float[] getAppliedCurve() {
+ float[] curve = new float[256];
+ ControlPoint[] points = new ControlPoint[mPoints.size()];
+ for (int i = 0; i < mPoints.size(); i++) {
+ ControlPoint p = mPoints.get(i);
+ points[i] = new ControlPoint(p.x, p.y);
+ }
+ double[] derivatives = solveSystem(points);
+ int start = 0;
+ int end = 256;
+ if (points[0].x != 0) {
+ start = (int) (points[0].x * 256);
+ }
+ if (points[points.length - 1].x != 1) {
+ end = (int) (points[points.length - 1].x * 256);
+ }
+ for (int i = 0; i < start; i++) {
+ curve[i] = 1.0f - points[0].y;
+ }
+ for (int i = end; i < 256; i++) {
+ curve[i] = 1.0f - points[points.length - 1].y;
+ }
+ for (int i = start; i < end; i++) {
+ ControlPoint cur = null;
+ ControlPoint next = null;
+ double x = i / 256.0;
+ int pivot = 0;
+ for (int j = 0; j < points.length - 1; j++) {
+ if (x >= points[j].x && x <= points[j + 1].x) {
+ pivot = j;
+ }
+ }
+ cur = points[pivot];
+ next = points[pivot + 1];
+ if (x <= next.x) {
+ double x1 = cur.x;
+ double x2 = next.x;
+ double y1 = cur.y;
+ double y2 = next.y;
+
+ // Use the second derivatives to apply the cubic spline
+ // equation:
+ double delta = (x2 - x1);
+ double delta2 = delta * delta;
+ double b = (x - x1) / delta;
+ double a = 1 - b;
+ double ta = a * y1;
+ double tb = b * y2;
+ double tc = (a * a * a - a) * derivatives[pivot];
+ double td = (b * b * b - b) * derivatives[pivot + 1];
+ double y = ta + tb + (delta2 / 6) * (tc + td);
+ if (y > 1.0f) {
+ y = 1.0f;
+ }
+ if (y < 0) {
+ y = 0;
+ }
+ curve[i] = (float) (1.0f - y);
+ } else {
+ curve[i] = 1.0f - next.y;
+ }
+ }
+ return curve;
+ }
+
+ private void drawGrid(Canvas canvas, float w, float h) {
+ // Grid
+ gPaint.setARGB(128, 150, 150, 150);
+ gPaint.setStrokeWidth(1);
+
+ float stepH = h / 9;
+ float stepW = w / 9;
+
+ // central diagonal
+ gPaint.setARGB(255, 100, 100, 100);
+ gPaint.setStrokeWidth(2);
+ canvas.drawLine(0, h, w, 0, gPaint);
+
+ gPaint.setARGB(128, 200, 200, 200);
+ gPaint.setStrokeWidth(4);
+ stepH = h / 3;
+ stepW = w / 3;
+ for (int j = 1; j < 3; j++) {
+ canvas.drawLine(0, j * stepH, w, j * stepH, gPaint);
+ canvas.drawLine(j * stepW, 0, j * stepW, h, gPaint);
+ }
+ canvas.drawLine(0, 0, 0, h, gPaint);
+ canvas.drawLine(w, 0, w, h, gPaint);
+ canvas.drawLine(0, 0, w, 0, gPaint);
+ canvas.drawLine(0, h, w, h, gPaint);
+ }
+
+ public void draw(Canvas canvas, int color, int canvasWidth, int canvasHeight,
+ boolean showHandles, boolean moving) {
+ float w = canvasWidth - mCurveHandleSize;
+ float h = canvasHeight - mCurveHandleSize;
+ float dx = mCurveHandleSize / 2;
+ float dy = mCurveHandleSize / 2;
+
+ // The cubic spline equation is (from numerical recipes in C):
+ // y = a(y_i) + b(y_i+1) + c(y"_i) + d(y"_i+1)
+ //
+ // with c(y"_i) and d(y"_i+1):
+ // c(y"_i) = 1/6 (a^3 - a) delta^2 (y"_i)
+ // d(y"_i_+1) = 1/6 (b^3 - b) delta^2 (y"_i+1)
+ //
+ // and delta:
+ // delta = x_i+1 - x_i
+ //
+ // To find the second derivatives y", we can rearrange the equation as:
+ // A(y"_i-1) + B(y"_i) + C(y"_i+1) = D
+ //
+ // With the coefficients A, B, C, D:
+ // A = 1/6 (x_i - x_i-1)
+ // B = 1/3 (x_i+1 - x_i-1)
+ // C = 1/6 (x_i+1 - x_i)
+ // D = (y_i+1 - y_i)/(x_i+1 - x_i) - (y_i - y_i-1)/(x_i - x_i-1)
+ //
+ // We can now easily solve the equation to find the second derivatives:
+ ControlPoint[] points = new ControlPoint[mPoints.size()];
+ for (int i = 0; i < mPoints.size(); i++) {
+ ControlPoint p = mPoints.get(i);
+ points[i] = new ControlPoint(p.x * w, p.y * h);
+ }
+ double[] derivatives = solveSystem(points);
+
+ Path path = new Path();
+ path.moveTo(0, points[0].y);
+ for (int i = 0; i < points.length - 1; i++) {
+ double x1 = points[i].x;
+ double x2 = points[i + 1].x;
+ double y1 = points[i].y;
+ double y2 = points[i + 1].y;
+
+ for (double x = x1; x < x2; x += 20) {
+ // Use the second derivatives to apply the cubic spline
+ // equation:
+ double delta = (x2 - x1);
+ double delta2 = delta * delta;
+ double b = (x - x1) / delta;
+ double a = 1 - b;
+ double ta = a * y1;
+ double tb = b * y2;
+ double tc = (a * a * a - a) * derivatives[i];
+ double td = (b * b * b - b) * derivatives[i + 1];
+ double y = ta + tb + (delta2 / 6) * (tc + td);
+ if (y > h) {
+ y = h;
+ }
+ if (y < 0) {
+ y = 0;
+ }
+ path.lineTo((float) x, (float) y);
+ }
+ }
+ canvas.save();
+ canvas.translate(dx, dy);
+ drawGrid(canvas, w, h);
+ ControlPoint lastPoint = points[points.length - 1];
+ path.lineTo(lastPoint.x, lastPoint.y);
+ path.lineTo(w, lastPoint.y);
+ Paint paint = new Paint();
+ paint.setAntiAlias(true);
+ paint.setFilterBitmap(true);
+ paint.setDither(true);
+ paint.setStyle(Paint.Style.STROKE);
+ int curveWidth = mCurveWidth;
+ if (showHandles) {
+ curveWidth *= 1.5;
+ }
+ paint.setStrokeWidth(curveWidth + 2);
+ paint.setColor(Color.BLACK);
+ canvas.drawPath(path, paint);
+
+ if (moving && mCurrentControlPoint != null) {
+ float px = mCurrentControlPoint.x * w;
+ float py = mCurrentControlPoint.y * h;
+ paint.setStrokeWidth(3);
+ paint.setColor(Color.BLACK);
+ canvas.drawLine(px, py, px, h, paint);
+ canvas.drawLine(0, py, px, py, paint);
+ paint.setStrokeWidth(1);
+ paint.setColor(color);
+ canvas.drawLine(px, py, px, h, paint);
+ canvas.drawLine(0, py, px, py, paint);
+ }
+
+ paint.setStrokeWidth(curveWidth);
+ paint.setColor(color);
+ canvas.drawPath(path, paint);
+ if (showHandles) {
+ for (int i = 0; i < points.length; i++) {
+ float x = points[i].x;
+ float y = points[i].y;
+ drawHandles(canvas, mCurveHandle, x, y);
+ }
+ }
+ canvas.restore();
+ }
+
+ double[] solveSystem(ControlPoint[] points) {
+ int n = points.length;
+ double[][] system = new double[n][3];
+ double[] result = new double[n]; // d
+ double[] solution = new double[n]; // returned coefficients
+ system[0][1] = 1;
+ system[n - 1][1] = 1;
+ double d6 = 1.0 / 6.0;
+ double d3 = 1.0 / 3.0;
+
+ // let's create a tridiagonal matrix representing the
+ // system, and apply the TDMA algorithm to solve it
+ // (see http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm)
+ for (int i = 1; i < n - 1; i++) {
+ double deltaPrevX = points[i].x - points[i - 1].x;
+ double deltaX = points[i + 1].x - points[i - 1].x;
+ double deltaNextX = points[i + 1].x - points[i].x;
+ double deltaNextY = points[i + 1].y - points[i].y;
+ double deltaPrevY = points[i].y - points[i - 1].y;
+ system[i][0] = d6 * deltaPrevX; // a_i
+ system[i][1] = d3 * deltaX; // b_i
+ system[i][2] = d6 * deltaNextX; // c_i
+ result[i] = (deltaNextY / deltaNextX) - (deltaPrevY / deltaPrevX); // d_i
+ }
+
+ // Forward sweep
+ for (int i = 1; i < n; i++) {
+ // m = a_i/b_i-1
+ double m = system[i][0] / system[i - 1][1];
+ // b_i = b_i - m(c_i-1)
+ system[i][1] = system[i][1] - m * system[i - 1][2];
+ // d_i = d_i - m(d_i-1)
+ result[i] = result[i] - m * result[i - 1];
+ }
+
+ // Back substitution
+ solution[n - 1] = result[n - 1] / system[n - 1][1];
+ for (int i = n - 2; i >= 0; --i) {
+ solution[i] = (result[i] - system[i][2] * solution[i + 1]) / system[i][1];
+ }
+ return solution;
+ }
+
+ public int addPoint(float x, float y) {
+ return addPoint(new ControlPoint(x, y));
+ }
+
+ public int addPoint(ControlPoint v) {
+ mPoints.add(v);
+ Collections.sort(mPoints);
+ return mPoints.indexOf(v);
+ }
+
+ public void deletePoint(int n) {
+ mPoints.remove(n);
+ if (mPoints.size() < 2) {
+ reset();
+ }
+ Collections.sort(mPoints);
+ }
+
+ public int getNbPoints() {
+ return mPoints.size();
+ }
+
+ public ControlPoint getPoint(int n) {
+ return mPoints.elementAt(n);
+ }
+
+ public boolean isPointContained(float x, int n) {
+ for (int i = 0; i < n; i++) {
+ ControlPoint point = mPoints.elementAt(i);
+ if (point.x > x) {
+ return false;
+ }
+ }
+ for (int i = n + 1; i < mPoints.size(); i++) {
+ ControlPoint point = mPoints.elementAt(i);
+ if (point.x < x) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public Spline copy() {
+ Spline spline = new Spline();
+ for (int i = 0; i < mPoints.size(); i++) {
+ ControlPoint point = mPoints.elementAt(i);
+ spline.addPoint(point.copy());
+ }
+ return spline;
+ }
+
+ public void show() {
+ Log.v(LOGTAG, "show curve " + this);
+ for (int i = 0; i < mPoints.size(); i++) {
+ ControlPoint point = mPoints.elementAt(i);
+ Log.v(LOGTAG, "point " + i + " is (" + point.x + ", " + point.y + ")");
+ }
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/info/HistogramView.java b/src/com/android/gallery3d/filtershow/info/HistogramView.java
new file mode 100644
index 0000000..99cf235
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/info/HistogramView.java
@@ -0,0 +1,144 @@
+/*
+ * 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.info;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
+import android.os.AsyncTask;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class HistogramView extends View {
+
+ private Bitmap mBitmap;
+ private Paint mPaint = new Paint();
+ private int[] redHistogram = new int[256];
+ private int[] greenHistogram = new int[256];
+ private int[] blueHistogram = new int[256];
+ private Path mHistoPath = new Path();
+
+ class ComputeHistogramTask extends AsyncTask<Bitmap, Void, int[]> {
+ @Override
+ protected int[] doInBackground(Bitmap... params) {
+ int[] histo = new int[256 * 3];
+ Bitmap bitmap = params[0];
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
+ int[] pixels = new int[w * h];
+ bitmap.getPixels(pixels, 0, w, 0, 0, w, h);
+ for (int i = 0; i < w; i++) {
+ for (int j = 0; j < h; j++) {
+ int index = j * w + i;
+ int r = Color.red(pixels[index]);
+ int g = Color.green(pixels[index]);
+ int b = Color.blue(pixels[index]);
+ histo[r]++;
+ histo[256 + g]++;
+ histo[512 + b]++;
+ }
+ }
+ return histo;
+ }
+
+ @Override
+ protected void onPostExecute(int[] result) {
+ System.arraycopy(result, 0, redHistogram, 0, 256);
+ System.arraycopy(result, 256, greenHistogram, 0, 256);
+ System.arraycopy(result, 512, blueHistogram, 0, 256);
+ invalidate();
+ }
+ }
+
+ public HistogramView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public void setBitmap(Bitmap bitmap) {
+ mBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
+ new ComputeHistogramTask().execute(mBitmap);
+ }
+
+ private void drawHistogram(Canvas canvas, int[] histogram, int color, PorterDuff.Mode mode) {
+ int max = 0;
+ for (int i = 0; i < histogram.length; i++) {
+ if (histogram[i] > max) {
+ max = histogram[i];
+ }
+ }
+ float w = getWidth(); // - Spline.curveHandleSize();
+ float h = getHeight(); // - Spline.curveHandleSize() / 2.0f;
+ float dx = 0; // Spline.curveHandleSize() / 2.0f;
+ float wl = w / histogram.length;
+ float wh = h / max;
+
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
+ mPaint.setARGB(100, 255, 255, 255);
+ mPaint.setStrokeWidth((int) Math.ceil(wl));
+
+ // Draw grid
+ mPaint.setStyle(Paint.Style.STROKE);
+ canvas.drawRect(dx, 0, dx + w, h, mPaint);
+ canvas.drawLine(dx + w / 3, 0, dx + w / 3, h, mPaint);
+ canvas.drawLine(dx + 2 * w / 3, 0, dx + 2 * w / 3, h, mPaint);
+
+ mPaint.setStyle(Paint.Style.FILL);
+ mPaint.setColor(color);
+ mPaint.setStrokeWidth(6);
+ mPaint.setXfermode(new PorterDuffXfermode(mode));
+ mHistoPath.reset();
+ mHistoPath.moveTo(dx, h);
+ boolean firstPointEncountered = false;
+ float prev = 0;
+ float last = 0;
+ for (int i = 0; i < histogram.length; i++) {
+ float x = i * wl + dx;
+ float l = histogram[i] * wh;
+ if (l != 0) {
+ float v = h - (l + prev) / 2.0f;
+ if (!firstPointEncountered) {
+ mHistoPath.lineTo(x, h);
+ firstPointEncountered = true;
+ }
+ mHistoPath.lineTo(x, v);
+ prev = l;
+ last = x;
+ }
+ }
+ mHistoPath.lineTo(last, h);
+ mHistoPath.lineTo(w, h);
+ mHistoPath.close();
+ canvas.drawPath(mHistoPath, mPaint);
+ mPaint.setStrokeWidth(2);
+ mPaint.setStyle(Paint.Style.STROKE);
+ mPaint.setARGB(255, 200, 200, 200);
+ canvas.drawPath(mHistoPath, mPaint);
+ }
+
+ public void onDraw(Canvas canvas) {
+ canvas.drawARGB(0, 0, 0, 0);
+ drawHistogram(canvas, redHistogram, Color.RED, PorterDuff.Mode.SCREEN);
+ drawHistogram(canvas, greenHistogram, Color.GREEN, PorterDuff.Mode.SCREEN);
+ drawHistogram(canvas, blueHistogram, Color.BLUE, PorterDuff.Mode.SCREEN);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/info/InfoPanel.java b/src/com/android/gallery3d/filtershow/info/InfoPanel.java
new file mode 100644
index 0000000..3a66578
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/info/InfoPanel.java
@@ -0,0 +1,140 @@
+/*
+ * 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.info;
+
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.text.Html;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import com.android.gallery3d.R;
+import com.android.gallery3d.exif.ExifInterface;
+import com.android.gallery3d.exif.ExifTag;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+import java.util.List;
+
+public class InfoPanel extends DialogFragment {
+ public static final String FRAGMENT_TAG = "InfoPanel";
+ private static final String LOGTAG = FRAGMENT_TAG;
+ private LinearLayout mMainView;
+ private ImageView mImageThumbnail;
+ private TextView mImageName;
+ private TextView mImageSize;
+ private TextView mExifData;
+
+ private String createStringFromIfFound(ExifTag exifTag, int tag, int str) {
+ String exifString = "";
+ short tagId = exifTag.getTagId();
+ if (tagId == ExifInterface.getTrueTagKey(tag)) {
+ String label = getActivity().getString(str);
+ exifString += "<b>" + label + ": </b>";
+ exifString += exifTag.forceGetValueAsString();
+ exifString += "<br>";
+ }
+ return exifString;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ if (getDialog() != null) {
+ getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
+ }
+
+ mMainView = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_info_panel, null, false);
+
+ mImageThumbnail = (ImageView) mMainView.findViewById(R.id.imageThumbnail);
+ Bitmap bitmap = MasterImage.getImage().getFilteredImage();
+ mImageThumbnail.setImageBitmap(bitmap);
+
+ mImageName = (TextView) mMainView.findViewById(R.id.imageName);
+ mImageSize = (TextView) mMainView.findViewById(R.id.imageSize);
+ mExifData = (TextView) mMainView.findViewById(R.id.exifData);
+ TextView exifLabel = (TextView) mMainView.findViewById(R.id.exifLabel);
+
+ HistogramView histogramView = (HistogramView) mMainView.findViewById(R.id.histogramView);
+ histogramView.setBitmap(bitmap);
+
+ Uri uri = MasterImage.getImage().getUri();
+ String path = ImageLoader.getLocalPathFromUri(getActivity(), uri);
+ Uri localUri = null;
+ if (path != null) {
+ localUri = Uri.parse(path);
+ }
+
+ if (localUri != null) {
+ mImageName.setText(localUri.getLastPathSegment());
+ }
+ Rect originalBounds = MasterImage.getImage().getOriginalBounds();
+ mImageSize.setText("" + originalBounds.width() + " x " + originalBounds.height());
+
+ List<ExifTag> exif = MasterImage.getImage().getEXIF();
+ String exifString = "";
+ boolean hasExifData = false;
+ if (exif != null) {
+ for (ExifTag tag : exif) {
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_MODEL,
+ R.string.filtershow_exif_model);
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_APERTURE_VALUE,
+ R.string.filtershow_exif_aperture);
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_FOCAL_LENGTH,
+ R.string.filtershow_exif_focal_length);
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_ISO_SPEED_RATINGS,
+ R.string.filtershow_exif_iso);
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_SUBJECT_DISTANCE,
+ R.string.filtershow_exif_subject_distance);
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_DATE_TIME_ORIGINAL,
+ R.string.filtershow_exif_date);
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_F_NUMBER,
+ R.string.filtershow_exif_f_stop);
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_EXPOSURE_TIME,
+ R.string.filtershow_exif_exposure_time);
+ exifString += createStringFromIfFound(tag,
+ ExifInterface.TAG_COPYRIGHT,
+ R.string.filtershow_exif_copyright);
+ hasExifData = true;
+ }
+ }
+ if (hasExifData) {
+ exifLabel.setVisibility(View.VISIBLE);
+ mExifData.setText(Html.fromHtml(exifString));
+ } else {
+ exifLabel.setVisibility(View.GONE);
+ }
+ return mMainView;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/Buffer.java b/src/com/android/gallery3d/filtershow/pipeline/Buffer.java
new file mode 100644
index 0000000..c378eb9
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/Buffer.java
@@ -0,0 +1,97 @@
+/*
+ * 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.pipeline;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.support.v8.renderscript.Allocation;
+import android.support.v8.renderscript.RenderScript;
+import android.util.Log;
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class Buffer {
+ private static final String LOGTAG = "Buffer";
+ private Bitmap mBitmap;
+ private Allocation mAllocation;
+ private boolean mUseAllocation = false;
+ private ImagePreset mPreset;
+
+ public Buffer(Bitmap bitmap) {
+ RenderScript rs = CachingPipeline.getRenderScriptContext();
+ if (bitmap != null) {
+ BitmapCache cache = MasterImage.getImage().getBitmapCache();
+ mBitmap = cache.getBitmapCopy(bitmap, BitmapCache.PREVIEW_CACHE);
+ }
+ if (mUseAllocation) {
+ // TODO: recreate the allocation when the RS context changes
+ mAllocation = Allocation.createFromBitmap(rs, mBitmap,
+ Allocation.MipmapControl.MIPMAP_NONE,
+ Allocation.USAGE_SHARED | Allocation.USAGE_SCRIPT);
+ }
+ }
+
+ public boolean isSameSize(Bitmap bitmap) {
+ if (mBitmap == null || bitmap == null) {
+ return false;
+ }
+ if (mBitmap.getWidth() == bitmap.getWidth()
+ && mBitmap.getHeight() == bitmap.getHeight()) {
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized void useBitmap(Bitmap bitmap) {
+ Canvas canvas = new Canvas(mBitmap);
+ canvas.drawBitmap(bitmap, 0, 0, null);
+ }
+
+ public synchronized Bitmap getBitmap() {
+ return mBitmap;
+ }
+
+ public Allocation getAllocation() {
+ return mAllocation;
+ }
+
+ public void sync() {
+ if (mUseAllocation) {
+ mAllocation.copyTo(mBitmap);
+ }
+ }
+
+ public ImagePreset getPreset() {
+ return mPreset;
+ }
+
+ public void setPreset(ImagePreset preset) {
+ if ((mPreset == null) || (!mPreset.same(preset))) {
+ mPreset = new ImagePreset(preset);
+ } else {
+ mPreset.updateWith(preset);
+ }
+ }
+
+ public void remove() {
+ BitmapCache cache = MasterImage.getImage().getBitmapCache();
+ if (cache.cache(mBitmap)) {
+ mBitmap = null;
+ }
+ }
+}
+
diff --git a/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java b/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java
new file mode 100644
index 0000000..c2912ed
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java
@@ -0,0 +1,306 @@
+/*
+ * 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.pipeline;
+
+import android.graphics.Bitmap;
+import android.util.Log;
+
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
+
+import java.util.ArrayList;
+import java.util.Vector;
+
+public class CacheProcessing {
+ private static final String LOGTAG = "CacheProcessing";
+ private static final boolean DEBUG = false;
+ private static final boolean NO_CACHING = false;
+ private Vector<CacheStep> mSteps = new Vector<CacheStep>();
+
+ static class CacheStep {
+ ArrayList<FilterRepresentation> representations;
+ Bitmap cache;
+
+ public CacheStep() {
+ representations = new ArrayList<FilterRepresentation>();
+ }
+
+ public void add(FilterRepresentation representation) {
+ representations.add(representation);
+ }
+
+ public boolean canMergeWith(FilterRepresentation representation) {
+ for (FilterRepresentation rep : representations) {
+ if (!rep.canMergeWith(representation)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean equals(CacheStep step) {
+ if (representations.size() != step.representations.size()) {
+ return false;
+ }
+ for (int i = 0; i < representations.size(); i++) {
+ FilterRepresentation r1 = representations.get(i);
+ FilterRepresentation r2 = step.representations.get(i);
+ if (!r1.equals(r2)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static Vector<CacheStep> buildSteps(Vector<FilterRepresentation> filters) {
+ Vector<CacheStep> steps = new Vector<CacheStep>();
+ CacheStep step = new CacheStep();
+ for (int i = 0; i < filters.size(); i++) {
+ FilterRepresentation representation = filters.elementAt(i);
+ if (step.canMergeWith(representation)) {
+ step.add(representation.copy());
+ } else {
+ steps.add(step);
+ step = new CacheStep();
+ step.add(representation.copy());
+ }
+ }
+ steps.add(step);
+ return steps;
+ }
+
+ public String getName() {
+ if (representations.size() > 0) {
+ return representations.get(0).getName();
+ }
+ return "EMPTY";
+ }
+
+ public Bitmap apply(FilterEnvironment environment, Bitmap cacheBitmap) {
+ boolean onlyGeometry = true;
+ Bitmap source = cacheBitmap;
+ for (FilterRepresentation representation : representations) {
+ if (representation.getFilterType() != FilterRepresentation.TYPE_GEOMETRY) {
+ onlyGeometry = false;
+ break;
+ }
+ }
+ if (onlyGeometry) {
+ ArrayList<FilterRepresentation> geometry = new ArrayList<FilterRepresentation>();
+ for (FilterRepresentation representation : representations) {
+ geometry.add(representation);
+ }
+ if (DEBUG) {
+ Log.v(LOGTAG, "Apply geometry to bitmap " + cacheBitmap);
+ }
+ cacheBitmap = GeometryMathUtils.applyGeometryRepresentations(geometry, cacheBitmap);
+ } else {
+ for (FilterRepresentation representation : representations) {
+ if (DEBUG) {
+ Log.v(LOGTAG, "Apply " + representation.getSerializationName()
+ + " to bitmap " + cacheBitmap);
+ }
+ cacheBitmap = environment.applyRepresentation(representation, cacheBitmap);
+ }
+ }
+ if (cacheBitmap != source) {
+ environment.cache(source);
+ }
+ if (DEBUG) {
+ Log.v(LOGTAG, "Apply returns bitmap " + cacheBitmap);
+ }
+ return cacheBitmap;
+ }
+ }
+
+ public Bitmap process(Bitmap originalBitmap,
+ Vector<FilterRepresentation> filters,
+ FilterEnvironment environment) {
+
+ if (filters.size() == 0) {
+ return environment.getBitmapCopy(originalBitmap, BitmapCache.PREVIEW_CACHE_NO_FILTERS);
+ }
+
+ environment.getBimapCache().setCacheProcessing(this);
+
+ if (DEBUG) {
+ displayFilters(filters);
+ }
+ Vector<CacheStep> steps = CacheStep.buildSteps(filters);
+ // New set of filters, let's clear the cache and rebuild it.
+ if (steps.size() != mSteps.size()) {
+ mSteps = steps;
+ }
+
+ if (DEBUG) {
+ displaySteps(mSteps);
+ }
+
+ // First, let's find how similar we are in our cache
+ // compared to the current list of filters
+ int similarUpToIndex = -1;
+ boolean similar = true;
+ for (int i = 0; i < steps.size(); i++) {
+ CacheStep newStep = steps.elementAt(i);
+ CacheStep cacheStep = mSteps.elementAt(i);
+ if (similar) {
+ similar = newStep.equals(cacheStep);
+ }
+ if (similar) {
+ similarUpToIndex = i;
+ } else {
+ mSteps.remove(i);
+ mSteps.insertElementAt(newStep, i);
+ environment.cache(cacheStep.cache);
+ }
+ }
+ if (DEBUG) {
+ Log.v(LOGTAG, "similar up to index " + similarUpToIndex);
+ }
+
+ // Now, let's get the earliest cached result in our pipeline
+ Bitmap cacheBitmap = null;
+ int findBaseImageIndex = similarUpToIndex;
+ if (findBaseImageIndex > -1) {
+ while (findBaseImageIndex > 0
+ && mSteps.elementAt(findBaseImageIndex).cache == null) {
+ findBaseImageIndex--;
+ }
+ cacheBitmap = mSteps.elementAt(findBaseImageIndex).cache;
+ }
+
+ if (DEBUG) {
+ Log.v(LOGTAG, "found baseImageIndex: " + findBaseImageIndex + " max is "
+ + mSteps.size() + " cacheBitmap: " + cacheBitmap);
+ }
+
+ if (NO_CACHING) {
+ cacheBitmap = environment.getBitmapCopy(originalBitmap,
+ BitmapCache.PREVIEW_CACHE_NO_ROOT);
+ for (int i = 0; i < mSteps.size(); i++) {
+ CacheStep step = mSteps.elementAt(i);
+ Bitmap prev = cacheBitmap;
+ cacheBitmap = step.apply(environment, cacheBitmap);
+ if (prev != cacheBitmap) {
+ environment.cache(prev);
+ }
+ }
+ return cacheBitmap;
+ }
+
+ Bitmap originalCopy = null;
+ int lastPositionCached = -1;
+ for (int i = findBaseImageIndex; i < mSteps.size(); i++) {
+ if (i == -1 || cacheBitmap == null) {
+ cacheBitmap = environment.getBitmapCopy(originalBitmap,
+ BitmapCache.PREVIEW_CACHE_NO_ROOT);
+ originalCopy = cacheBitmap;
+ if (DEBUG) {
+ Log.v(LOGTAG, "i: " + i + " cacheBitmap: " + cacheBitmap + " w: "
+ + cacheBitmap.getWidth() + " h: " + cacheBitmap.getHeight()
+ + " got from original Bitmap: " + originalBitmap + " w: "
+ + originalBitmap.getWidth() + " h: " + originalBitmap.getHeight());
+ }
+ if (i == -1) {
+ continue;
+ }
+ }
+ CacheStep step = mSteps.elementAt(i);
+ if (step.cache == null) {
+ if (DEBUG) {
+ Log.v(LOGTAG, "i: " + i + " get new copy for cacheBitmap "
+ + cacheBitmap + " apply...");
+ }
+ cacheBitmap = environment.getBitmapCopy(cacheBitmap, BitmapCache.PREVIEW_CACHE);
+ cacheBitmap = step.apply(environment, cacheBitmap);
+ step.cache = cacheBitmap;
+ lastPositionCached = i;
+ }
+ }
+ environment.cache(originalCopy);
+
+ if (DEBUG) {
+ Log.v(LOGTAG, "now let's cleanup the cache...");
+ displayNbBitmapsInCache();
+ }
+
+ // Let's see if we can cleanup the cache for unused bitmaps
+ for (int i = 0; i < similarUpToIndex; i++) {
+ CacheStep currentStep = mSteps.elementAt(i);
+ Bitmap bitmap = currentStep.cache;
+ currentStep.cache = null;
+ environment.cache(bitmap);
+ }
+
+ if (DEBUG) {
+ Log.v(LOGTAG, "cleanup done...");
+ displayNbBitmapsInCache();
+ }
+ if (lastPositionCached != -1) {
+ // The last element will never be reused, remove it from the cache.
+ mSteps.elementAt(lastPositionCached).cache = null;
+ }
+ if (contains(cacheBitmap)) {
+ return environment.getBitmapCopy(cacheBitmap, BitmapCache.PREVIEW_CACHE_NO_APPLY);
+ }
+ return cacheBitmap;
+ }
+
+ public boolean contains(Bitmap bitmap) {
+ for (int i = 0; i < mSteps.size(); i++) {
+ if (mSteps.elementAt(i).cache == bitmap) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void displayFilters(Vector<FilterRepresentation> filters) {
+ Log.v(LOGTAG, "------>>> Filters received");
+ for (int i = 0; i < filters.size(); i++) {
+ FilterRepresentation filter = filters.elementAt(i);
+ Log.v(LOGTAG, "[" + i + "] - " + filter.getName());
+ }
+ Log.v(LOGTAG, "<<<------");
+ }
+
+ private void displaySteps(Vector<CacheStep> filters) {
+ Log.v(LOGTAG, "------>>>");
+ for (int i = 0; i < filters.size(); i++) {
+ CacheStep newStep = filters.elementAt(i);
+ CacheStep step = mSteps.elementAt(i);
+ boolean similar = step.equals(newStep);
+ Log.v(LOGTAG, "[" + i + "] - " + step.getName()
+ + " similar rep ? " + (similar ? "YES" : "NO")
+ + " -- bitmap: " + step.cache);
+ }
+ Log.v(LOGTAG, "<<<------");
+ }
+
+ private void displayNbBitmapsInCache() {
+ int nbBitmapsCached = 0;
+ for (int i = 0; i < mSteps.size(); i++) {
+ CacheStep step = mSteps.elementAt(i);
+ if (step.cache != null) {
+ nbBitmapsCached++;
+ }
+ }
+ Log.v(LOGTAG, "nb bitmaps in cache: " + nbBitmapsCached + " / " + mSteps.size());
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/CachingPipeline.java b/src/com/android/gallery3d/filtershow/pipeline/CachingPipeline.java
new file mode 100644
index 0000000..8ae9a7c
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/CachingPipeline.java
@@ -0,0 +1,490 @@
+/*
+ * 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.pipeline;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.support.v8.renderscript.Allocation;
+import android.support.v8.renderscript.RenderScript;
+import android.util.Log;
+
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+import java.util.Vector;
+
+public class CachingPipeline implements PipelineInterface {
+ private static final String LOGTAG = "CachingPipeline";
+ private boolean DEBUG = false;
+
+ private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
+
+ private static volatile RenderScript sRS = null;
+
+ private FiltersManager mFiltersManager = null;
+ private volatile Bitmap mOriginalBitmap = null;
+ private volatile Bitmap mResizedOriginalBitmap = null;
+
+ private FilterEnvironment mEnvironment = new FilterEnvironment();
+ private CacheProcessing mCachedProcessing = new CacheProcessing();
+
+
+ private volatile Allocation mOriginalAllocation = null;
+ private volatile Allocation mFiltersOnlyOriginalAllocation = null;
+
+ protected volatile Allocation mInPixelsAllocation;
+ protected volatile Allocation mOutPixelsAllocation;
+ private volatile int mWidth = 0;
+ private volatile int mHeight = 0;
+
+ private volatile float mPreviewScaleFactor = 1.0f;
+ private volatile float mHighResPreviewScaleFactor = 1.0f;
+ private volatile String mName = "";
+
+ public CachingPipeline(FiltersManager filtersManager, String name) {
+ mFiltersManager = filtersManager;
+ mName = name;
+ }
+
+ public static synchronized RenderScript getRenderScriptContext() {
+ return sRS;
+ }
+
+ public static synchronized void createRenderscriptContext(Context context) {
+ if (sRS != null) {
+ Log.w(LOGTAG, "A prior RS context exists when calling setRenderScriptContext");
+ destroyRenderScriptContext();
+ }
+ sRS = RenderScript.create(context);
+ }
+
+ public static synchronized void destroyRenderScriptContext() {
+ if (sRS != null) {
+ sRS.destroy();
+ }
+ sRS = null;
+ }
+
+ public void stop() {
+ mEnvironment.setStop(true);
+ }
+
+ public synchronized void reset() {
+ synchronized (CachingPipeline.class) {
+ if (getRenderScriptContext() == null) {
+ return;
+ }
+ mOriginalBitmap = null; // just a reference to the bitmap in ImageLoader
+ if (mResizedOriginalBitmap != null) {
+ mResizedOriginalBitmap.recycle();
+ mResizedOriginalBitmap = null;
+ }
+ if (mOriginalAllocation != null) {
+ mOriginalAllocation.destroy();
+ mOriginalAllocation = null;
+ }
+ if (mFiltersOnlyOriginalAllocation != null) {
+ mFiltersOnlyOriginalAllocation.destroy();
+ mFiltersOnlyOriginalAllocation = null;
+ }
+ mPreviewScaleFactor = 1.0f;
+ mHighResPreviewScaleFactor = 1.0f;
+
+ destroyPixelAllocations();
+ }
+ }
+
+ public Resources getResources() {
+ return sRS.getApplicationContext().getResources();
+ }
+
+ private synchronized void destroyPixelAllocations() {
+ if (DEBUG) {
+ Log.v(LOGTAG, "destroyPixelAllocations in " + getName());
+ }
+ if (mInPixelsAllocation != null) {
+ mInPixelsAllocation.destroy();
+ mInPixelsAllocation = null;
+ }
+ if (mOutPixelsAllocation != null) {
+ mOutPixelsAllocation.destroy();
+ mOutPixelsAllocation = null;
+ }
+ mWidth = 0;
+ mHeight = 0;
+ }
+
+ private String getType(RenderingRequest request) {
+ if (request.getType() == RenderingRequest.ICON_RENDERING) {
+ return "ICON_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ return "FILTERS_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.FULL_RENDERING) {
+ return "FULL_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
+ return "GEOMETRY_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.PARTIAL_RENDERING) {
+ return "PARTIAL_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.HIGHRES_RENDERING) {
+ return "HIGHRES_RENDERING";
+ }
+ return "UNKNOWN TYPE!";
+ }
+
+ private void setupEnvironment(ImagePreset preset, boolean highResPreview) {
+ mEnvironment.setPipeline(this);
+ mEnvironment.setFiltersManager(mFiltersManager);
+ mEnvironment.setBitmapCache(MasterImage.getImage().getBitmapCache());
+ if (highResPreview) {
+ mEnvironment.setScaleFactor(mHighResPreviewScaleFactor);
+ } else {
+ mEnvironment.setScaleFactor(mPreviewScaleFactor);
+ }
+ mEnvironment.setQuality(FilterEnvironment.QUALITY_PREVIEW);
+ mEnvironment.setImagePreset(preset);
+ mEnvironment.setStop(false);
+ }
+
+ public void setOriginal(Bitmap bitmap) {
+ mOriginalBitmap = bitmap;
+ Log.v(LOGTAG,"setOriginal, size " + bitmap.getWidth() + " x " + bitmap.getHeight());
+ ImagePreset preset = MasterImage.getImage().getPreset();
+ setupEnvironment(preset, false);
+ updateOriginalAllocation(preset);
+ }
+
+ private synchronized boolean updateOriginalAllocation(ImagePreset preset) {
+ if (preset == null) {
+ return false;
+ }
+ Bitmap originalBitmap = mOriginalBitmap;
+
+ if (originalBitmap == null) {
+ return false;
+ }
+
+ RenderScript RS = getRenderScriptContext();
+
+ Allocation filtersOnlyOriginalAllocation = mFiltersOnlyOriginalAllocation;
+ mFiltersOnlyOriginalAllocation = Allocation.createFromBitmap(RS, originalBitmap,
+ Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+ if (filtersOnlyOriginalAllocation != null) {
+ filtersOnlyOriginalAllocation.destroy();
+ }
+
+ Allocation originalAllocation = mOriginalAllocation;
+ mResizedOriginalBitmap = preset.applyGeometry(originalBitmap, mEnvironment);
+ mOriginalAllocation = Allocation.createFromBitmap(RS, mResizedOriginalBitmap,
+ Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+ if (originalAllocation != null) {
+ originalAllocation.destroy();
+ }
+
+ return true;
+ }
+
+ public void renderHighres(RenderingRequest request) {
+ synchronized (CachingPipeline.class) {
+ if (getRenderScriptContext() == null) {
+ return;
+ }
+ ImagePreset preset = request.getImagePreset();
+ setupEnvironment(preset, false);
+ Bitmap bitmap = MasterImage.getImage().getOriginalBitmapHighres();
+ if (bitmap == null) {
+ return;
+ }
+ bitmap = mEnvironment.getBitmapCopy(bitmap, BitmapCache.HIGHRES);
+ bitmap = preset.applyGeometry(bitmap, mEnvironment);
+
+ mEnvironment.setQuality(FilterEnvironment.QUALITY_PREVIEW);
+ Bitmap bmp = preset.apply(bitmap, mEnvironment);
+ if (!mEnvironment.needsStop()) {
+ request.setBitmap(bmp);
+ } else {
+ mEnvironment.cache(bmp);
+ }
+ mFiltersManager.freeFilterResources(preset);
+ }
+ }
+
+ public void renderGeometry(RenderingRequest request) {
+ synchronized (CachingPipeline.class) {
+ if (getRenderScriptContext() == null) {
+ return;
+ }
+ ImagePreset preset = request.getImagePreset();
+ setupEnvironment(preset, false);
+ Bitmap bitmap = MasterImage.getImage().getOriginalBitmapHighres();
+ if (bitmap == null) {
+ return;
+ }
+ bitmap = mEnvironment.getBitmapCopy(bitmap, BitmapCache.GEOMETRY);
+ bitmap = preset.applyGeometry(bitmap, mEnvironment);
+ if (!mEnvironment.needsStop()) {
+ request.setBitmap(bitmap);
+ } else {
+ mEnvironment.cache(bitmap);
+ }
+ mFiltersManager.freeFilterResources(preset);
+ }
+ }
+
+ public void renderFilters(RenderingRequest request) {
+ synchronized (CachingPipeline.class) {
+ if (getRenderScriptContext() == null) {
+ return;
+ }
+ ImagePreset preset = request.getImagePreset();
+ setupEnvironment(preset, false);
+ Bitmap bitmap = MasterImage.getImage().getOriginalBitmapHighres();
+ if (bitmap == null) {
+ return;
+ }
+ bitmap = mEnvironment.getBitmapCopy(bitmap, BitmapCache.FILTERS);
+ bitmap = preset.apply(bitmap, mEnvironment);
+ if (!mEnvironment.needsStop()) {
+ request.setBitmap(bitmap);
+ } else {
+ mEnvironment.cache(bitmap);
+ }
+ mFiltersManager.freeFilterResources(preset);
+ }
+ }
+
+ public synchronized void render(RenderingRequest request) {
+ // TODO: cleanup/remove GEOMETRY / FILTERS paths
+ synchronized (CachingPipeline.class) {
+ if (getRenderScriptContext() == null) {
+ return;
+ }
+ if ((request.getType() != RenderingRequest.PARTIAL_RENDERING
+ && request.getType() != RenderingRequest.ICON_RENDERING
+ && request.getBitmap() == null)
+ || request.getImagePreset() == null) {
+ return;
+ }
+
+ if (DEBUG) {
+ Log.v(LOGTAG, "render image of type " + getType(request));
+ }
+
+ Bitmap bitmap = request.getBitmap();
+ ImagePreset preset = request.getImagePreset();
+ setupEnvironment(preset, true);
+ mFiltersManager.freeFilterResources(preset);
+
+ if (request.getType() == RenderingRequest.PARTIAL_RENDERING) {
+ MasterImage master = MasterImage.getImage();
+ bitmap = ImageLoader.getScaleOneImageForPreset(master.getActivity(),
+ mEnvironment.getBimapCache(),
+ master.getUri(), request.getBounds(),
+ request.getDestination());
+ if (bitmap == null) {
+ Log.w(LOGTAG, "could not get bitmap for: " + getType(request));
+ return;
+ }
+ }
+
+ if (request.getType() == RenderingRequest.FULL_RENDERING
+ || request.getType() == RenderingRequest.GEOMETRY_RENDERING
+ || request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ updateOriginalAllocation(preset);
+ }
+
+ if (DEBUG && bitmap != null) {
+ Log.v(LOGTAG, "after update, req bitmap (" + bitmap.getWidth() + "x" + bitmap.getHeight()
+ + " ? resizeOriginal (" + mResizedOriginalBitmap.getWidth() + "x"
+ + mResizedOriginalBitmap.getHeight());
+ }
+
+ if (request.getType() == RenderingRequest.FULL_RENDERING
+ || request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
+ mOriginalAllocation.copyTo(bitmap);
+ } else if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ mFiltersOnlyOriginalAllocation.copyTo(bitmap);
+ }
+
+ if (request.getType() == RenderingRequest.FULL_RENDERING
+ || request.getType() == RenderingRequest.FILTERS_RENDERING
+ || request.getType() == RenderingRequest.ICON_RENDERING
+ || request.getType() == RenderingRequest.PARTIAL_RENDERING
+ || request.getType() == RenderingRequest.STYLE_ICON_RENDERING) {
+
+ if (request.getType() == RenderingRequest.ICON_RENDERING) {
+ mEnvironment.setQuality(FilterEnvironment.QUALITY_ICON);
+ } else {
+ mEnvironment.setQuality(FilterEnvironment.QUALITY_PREVIEW);
+ }
+
+ if (request.getType() == RenderingRequest.ICON_RENDERING) {
+ Rect iconBounds = request.getIconBounds();
+ Bitmap source = MasterImage.getImage().getThumbnailBitmap();
+ if (iconBounds.width() > source.getWidth() * 2) {
+ source = MasterImage.getImage().getLargeThumbnailBitmap();
+ }
+ if (iconBounds != null) {
+ bitmap = mEnvironment.getBitmap(iconBounds.width(),
+ iconBounds.height(), BitmapCache.ICON);
+ Canvas canvas = new Canvas(bitmap);
+ Matrix m = new Matrix();
+ float minSize = Math.min(source.getWidth(), source.getHeight());
+ float maxSize = Math.max(iconBounds.width(), iconBounds.height());
+ float scale = maxSize / minSize;
+ m.setScale(scale, scale);
+ float dx = (iconBounds.width() - (source.getWidth() * scale))/2.0f;
+ float dy = (iconBounds.height() - (source.getHeight() * scale))/2.0f;
+ m.postTranslate(dx, dy);
+ canvas.drawBitmap(source, m, new Paint(Paint.FILTER_BITMAP_FLAG));
+ } else {
+ bitmap = mEnvironment.getBitmapCopy(source, BitmapCache.ICON);
+ }
+ }
+ Bitmap bmp = preset.apply(bitmap, mEnvironment);
+ if (!mEnvironment.needsStop()) {
+ request.setBitmap(bmp);
+ }
+ mFiltersManager.freeFilterResources(preset);
+ }
+ }
+ }
+
+ public synchronized void renderImage(ImagePreset preset, Allocation in, Allocation out) {
+ synchronized (CachingPipeline.class) {
+ if (getRenderScriptContext() == null) {
+ return;
+ }
+ setupEnvironment(preset, false);
+ mFiltersManager.freeFilterResources(preset);
+ preset.applyFilters(-1, -1, in, out, mEnvironment);
+ boolean copyOut = false;
+ if (preset.nbFilters() > 0) {
+ copyOut = true;
+ }
+ preset.applyBorder(in, out, copyOut, mEnvironment);
+ }
+ }
+
+ public synchronized Bitmap renderFinalImage(Bitmap bitmap, ImagePreset preset) {
+ synchronized (CachingPipeline.class) {
+ if (getRenderScriptContext() == null) {
+ return bitmap;
+ }
+ setupEnvironment(preset, false);
+ mEnvironment.setQuality(FilterEnvironment.QUALITY_FINAL);
+ mEnvironment.setScaleFactor(1.0f);
+ mFiltersManager.freeFilterResources(preset);
+ bitmap = preset.applyGeometry(bitmap, mEnvironment);
+ bitmap = preset.apply(bitmap, mEnvironment);
+ return bitmap;
+ }
+ }
+
+ public Bitmap renderGeometryIcon(Bitmap bitmap, ImagePreset preset) {
+ return GeometryMathUtils.applyGeometryRepresentations(preset.getGeometryFilters(), bitmap);
+ }
+
+ public void compute(SharedBuffer buffer, ImagePreset preset, int type) {
+ if (getRenderScriptContext() == null) {
+ return;
+ }
+ setupEnvironment(preset, false);
+ Vector<FilterRepresentation> filters = preset.getFilters();
+ Bitmap result = mCachedProcessing.process(mOriginalBitmap, filters, mEnvironment);
+ buffer.setProducer(result);
+ mEnvironment.cache(result);
+ }
+
+ public boolean needsRepaint() {
+ SharedBuffer buffer = MasterImage.getImage().getPreviewBuffer();
+ return buffer.checkRepaintNeeded();
+ }
+
+ public void setPreviewScaleFactor(float previewScaleFactor) {
+ mPreviewScaleFactor = previewScaleFactor;
+ }
+
+ public void setHighResPreviewScaleFactor(float highResPreviewScaleFactor) {
+ mHighResPreviewScaleFactor = highResPreviewScaleFactor;
+ }
+
+ public synchronized boolean isInitialized() {
+ return getRenderScriptContext() != null && mOriginalBitmap != null;
+ }
+
+ public boolean prepareRenderscriptAllocations(Bitmap bitmap) {
+ RenderScript RS = getRenderScriptContext();
+ boolean needsUpdate = false;
+ if (mOutPixelsAllocation == null || mInPixelsAllocation == null ||
+ bitmap.getWidth() != mWidth || bitmap.getHeight() != mHeight) {
+ destroyPixelAllocations();
+ Bitmap bitmapBuffer = bitmap;
+ if (bitmap.getConfig() == null || bitmap.getConfig() != BITMAP_CONFIG) {
+ bitmapBuffer = bitmap.copy(BITMAP_CONFIG, true);
+ }
+ mOutPixelsAllocation = Allocation.createFromBitmap(RS, bitmapBuffer,
+ Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+ mInPixelsAllocation = Allocation.createTyped(RS,
+ mOutPixelsAllocation.getType());
+ needsUpdate = true;
+ }
+ if (RS != null) {
+ mInPixelsAllocation.copyFrom(bitmap);
+ }
+ if (bitmap.getWidth() != mWidth
+ || bitmap.getHeight() != mHeight) {
+ mWidth = bitmap.getWidth();
+ mHeight = bitmap.getHeight();
+ needsUpdate = true;
+ }
+ if (DEBUG) {
+ Log.v(LOGTAG, "prepareRenderscriptAllocations: " + needsUpdate + " in " + getName());
+ }
+ return needsUpdate;
+ }
+
+ public synchronized Allocation getInPixelsAllocation() {
+ return mInPixelsAllocation;
+ }
+
+ public synchronized Allocation getOutPixelsAllocation() {
+ return mOutPixelsAllocation;
+ }
+
+ public String getName() {
+ return mName;
+ }
+
+ public RenderScript getRSContext() {
+ return CachingPipeline.getRenderScriptContext();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/FilterEnvironment.java b/src/com/android/gallery3d/filtershow/pipeline/FilterEnvironment.java
new file mode 100644
index 0000000..ebf83b7
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/FilterEnvironment.java
@@ -0,0 +1,174 @@
+/*
+ * 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.pipeline;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.support.v8.renderscript.Allocation;
+
+import com.android.gallery3d.app.Log;
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
+import com.android.gallery3d.filtershow.filters.FiltersManagerInterface;
+import com.android.gallery3d.filtershow.filters.ImageFilter;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+
+public class FilterEnvironment {
+ private static final String LOGTAG = "FilterEnvironment";
+ private ImagePreset mImagePreset;
+ private float mScaleFactor;
+ private int mQuality;
+ private FiltersManagerInterface mFiltersManager;
+ private PipelineInterface mPipeline;
+ private volatile boolean mStop = false;
+ private BitmapCache mBitmapCache;
+
+ public static final int QUALITY_ICON = 0;
+ public static final int QUALITY_PREVIEW = 1;
+ public static final int QUALITY_FINAL = 2;
+
+ public synchronized boolean needsStop() {
+ return mStop;
+ }
+
+ public synchronized void setStop(boolean stop) {
+ this.mStop = stop;
+ }
+
+ private HashMap<Integer, Integer>
+ generalParameters = new HashMap<Integer, Integer>();
+
+ public void setBitmapCache(BitmapCache cache) {
+ mBitmapCache = cache;
+ }
+
+ public void cache(Buffer buffer) {
+ mBitmapCache.cache(buffer);
+ }
+
+ public void cache(Bitmap bitmap) {
+ mBitmapCache.cache(bitmap);
+ }
+
+ public Bitmap getBitmap(int w, int h, int type) {
+ return mBitmapCache.getBitmap(w, h, type);
+ }
+
+ public Bitmap getBitmapCopy(Bitmap source, int type) {
+ return mBitmapCache.getBitmapCopy(source, type);
+ }
+
+ public void setImagePreset(ImagePreset imagePreset) {
+ mImagePreset = imagePreset;
+ }
+
+ public ImagePreset getImagePreset() {
+ return mImagePreset;
+ }
+
+ public void setScaleFactor(float scaleFactor) {
+ mScaleFactor = scaleFactor;
+ }
+
+ public float getScaleFactor() {
+ return mScaleFactor;
+ }
+
+ public void setQuality(int quality) {
+ mQuality = quality;
+ }
+
+ public int getQuality() {
+ return mQuality;
+ }
+
+ public void setFiltersManager(FiltersManagerInterface filtersManager) {
+ mFiltersManager = filtersManager;
+ }
+
+ public FiltersManagerInterface getFiltersManager() {
+ return mFiltersManager;
+ }
+
+ public void applyRepresentation(FilterRepresentation representation,
+ Allocation in, Allocation out) {
+ ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
+ filter.useRepresentation(representation);
+ filter.setEnvironment(this);
+ if (filter.supportsAllocationInput()) {
+ filter.apply(in, out);
+ }
+ filter.setGeneralParameters();
+ filter.setEnvironment(null);
+ }
+
+ public Bitmap applyRepresentation(FilterRepresentation representation, Bitmap bitmap) {
+ if (representation instanceof FilterUserPresetRepresentation) {
+ // we allow instances of FilterUserPresetRepresentation in a preset only to know if one
+ // has been applied (so we can show this in the UI). But as all the filters in them are
+ // applied directly they do not themselves need to do any kind of filtering.
+ return bitmap;
+ }
+ ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
+ if (filter == null){
+ Log.e(LOGTAG,"No ImageFilter for "+representation.getSerializationName());
+ }
+ filter.useRepresentation(representation);
+ filter.setEnvironment(this);
+ Bitmap ret = filter.apply(bitmap, mScaleFactor, mQuality);
+ if (bitmap != ret) {
+ cache(bitmap);
+ }
+ filter.setGeneralParameters();
+ filter.setEnvironment(null);
+ return ret;
+ }
+
+ public PipelineInterface getPipeline() {
+ return mPipeline;
+ }
+
+ public void setPipeline(PipelineInterface cachingPipeline) {
+ mPipeline = cachingPipeline;
+ }
+
+ public synchronized void clearGeneralParameters() {
+ generalParameters = null;
+ }
+
+ public synchronized Integer getGeneralParameter(int id) {
+ if (generalParameters == null || !generalParameters.containsKey(id)) {
+ return null;
+ }
+ return generalParameters.get(id);
+ }
+
+ public synchronized void setGeneralParameter(int id, int value) {
+ if (generalParameters == null) {
+ generalParameters = new HashMap<Integer, Integer>();
+ }
+
+ generalParameters.put(id, value);
+ }
+
+ public BitmapCache getBimapCache() {
+ return mBitmapCache;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/FullresRenderingRequestTask.java b/src/com/android/gallery3d/filtershow/pipeline/FullresRenderingRequestTask.java
new file mode 100644
index 0000000..ab72c8d
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/FullresRenderingRequestTask.java
@@ -0,0 +1,67 @@
+package com.android.gallery3d.filtershow.pipeline;
+
+import android.graphics.Bitmap;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+
+public class FullresRenderingRequestTask extends ProcessingTask {
+
+ private CachingPipeline mFullresPipeline = null;
+ private boolean mPipelineIsOn = false;
+
+ public void setPreviewScaleFactor(float previewScale) {
+ mFullresPipeline.setPreviewScaleFactor(previewScale);
+ }
+
+ static class Render implements Request {
+ RenderingRequest request;
+ }
+
+ static class RenderResult implements Result {
+ RenderingRequest request;
+ }
+
+ public FullresRenderingRequestTask() {
+ mFullresPipeline = new CachingPipeline(
+ FiltersManager.getHighresManager(), "Fullres");
+ }
+
+ public void setOriginal(Bitmap bitmap) {
+ mFullresPipeline.setOriginal(bitmap);
+ mPipelineIsOn = true;
+ }
+
+ public void stop() {
+ mFullresPipeline.stop();
+ }
+
+ public void postRenderingRequest(RenderingRequest request) {
+ if (!mPipelineIsOn) {
+ return;
+ }
+ Render render = new Render();
+ render.request = request;
+ postRequest(render);
+ }
+
+ @Override
+ public Result doInBackground(Request message) {
+ RenderingRequest request = ((Render) message).request;
+ RenderResult result = null;
+ mFullresPipeline.render(request);
+ result = new RenderResult();
+ result.request = request;
+ return result;
+ }
+
+ @Override
+ public void onResult(Result message) {
+ if (message == null) {
+ return;
+ }
+ RenderingRequest request = ((RenderResult) message).request;
+ request.markAvailable();
+ }
+
+ @Override
+ public boolean isDelayedTask() { return true; }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/HighresRenderingRequestTask.java b/src/com/android/gallery3d/filtershow/pipeline/HighresRenderingRequestTask.java
new file mode 100644
index 0000000..5a0eb4d
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/HighresRenderingRequestTask.java
@@ -0,0 +1,90 @@
+/*
+ * 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.pipeline;
+
+import android.graphics.Bitmap;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+
+public class HighresRenderingRequestTask extends ProcessingTask {
+
+ private CachingPipeline mHighresPreviewPipeline = null;
+ private boolean mPipelineIsOn = false;
+
+ public void setHighresPreviewScaleFactor(float highResPreviewScale) {
+ mHighresPreviewPipeline.setHighResPreviewScaleFactor(highResPreviewScale);
+ }
+
+ public void setPreviewScaleFactor(float previewScale) {
+ mHighresPreviewPipeline.setPreviewScaleFactor(previewScale);
+ }
+
+ static class Render implements Request {
+ RenderingRequest request;
+ }
+
+ static class RenderResult implements Result {
+ RenderingRequest request;
+ }
+
+ public HighresRenderingRequestTask() {
+ mHighresPreviewPipeline = new CachingPipeline(
+ FiltersManager.getHighresManager(), "Highres");
+ }
+
+ public void setOriginal(Bitmap bitmap) {
+ mHighresPreviewPipeline.setOriginal(bitmap);
+ }
+
+ public void setOriginalBitmapHighres(Bitmap originalHires) {
+ mPipelineIsOn = true;
+ }
+
+ public void stop() {
+ mHighresPreviewPipeline.stop();
+ }
+
+ public void postRenderingRequest(RenderingRequest request) {
+ if (!mPipelineIsOn) {
+ return;
+ }
+ Render render = new Render();
+ render.request = request;
+ postRequest(render);
+ }
+
+ @Override
+ public Result doInBackground(Request message) {
+ RenderingRequest request = ((Render) message).request;
+ RenderResult result = null;
+ mHighresPreviewPipeline.renderHighres(request);
+ result = new RenderResult();
+ result.request = request;
+ return result;
+ }
+
+ @Override
+ public void onResult(Result message) {
+ if (message == null) {
+ return;
+ }
+ RenderingRequest request = ((RenderResult) message).request;
+ request.markAvailable();
+ }
+
+ @Override
+ public boolean isDelayedTask() { return true; }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java
new file mode 100644
index 0000000..4322ed7
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java
@@ -0,0 +1,739 @@
+/*
+ * 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.
+ */
+
+package com.android.gallery3d.filtershow.pipeline;
+
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.support.v8.renderscript.Allocation;
+import android.util.JsonReader;
+import android.util.JsonWriter;
+import android.util.Log;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
+import com.android.gallery3d.filtershow.filters.FilterCropRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterFxRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterImageBorderRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation;
+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.imageshow.GeometryMathUtils;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.state.State;
+import com.android.gallery3d.filtershow.state.StateAdapter;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Vector;
+
+public class ImagePreset {
+
+ private static final String LOGTAG = "ImagePreset";
+ public static final String JASON_SAVED = "Saved";
+
+ private Vector<FilterRepresentation> mFilters = new Vector<FilterRepresentation>();
+
+ private boolean mDoApplyGeometry = true;
+ private boolean mDoApplyFilters = true;
+
+ private boolean mPartialRendering = false;
+ private Rect mPartialRenderingBounds;
+ private static final boolean DEBUG = false;
+
+ public ImagePreset() {
+ }
+
+ public ImagePreset(ImagePreset source) {
+ for (int i = 0; i < source.mFilters.size(); i++) {
+ FilterRepresentation sourceRepresentation = source.mFilters.elementAt(i);
+ mFilters.add(sourceRepresentation.copy());
+ }
+ }
+
+ public Vector<FilterRepresentation> getFilters() {
+ return mFilters;
+ }
+
+ public FilterRepresentation getFilterRepresentation(int position) {
+ FilterRepresentation representation = null;
+
+ representation = mFilters.elementAt(position).copy();
+
+ return representation;
+ }
+
+ private static boolean sameSerializationName(String a, String b) {
+ if (a != null && b != null) {
+ return a.equals(b);
+ } else {
+ return a == null && b == null;
+ }
+ }
+
+ public static boolean sameSerializationName(FilterRepresentation a, FilterRepresentation b) {
+ if (a == null || b == null) {
+ return false;
+ }
+ return sameSerializationName(a.getSerializationName(), b.getSerializationName());
+ }
+
+ public int getPositionForRepresentation(FilterRepresentation representation) {
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (sameSerializationName(mFilters.elementAt(i), representation)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private FilterRepresentation getFilterRepresentationForType(int type) {
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (mFilters.elementAt(i).getFilterType() == type) {
+ return mFilters.elementAt(i);
+ }
+ }
+ return null;
+ }
+
+ public int getPositionForType(int type) {
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (mFilters.elementAt(i).getFilterType() == type) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public FilterRepresentation getFilterRepresentationCopyFrom(
+ FilterRepresentation filterRepresentation) {
+ // TODO: add concept of position in the filters (to allow multiple instances)
+ if (filterRepresentation == null) {
+ return null;
+ }
+ int position = getPositionForRepresentation(filterRepresentation);
+ if (position == -1) {
+ return null;
+ }
+ FilterRepresentation representation = mFilters.elementAt(position);
+ if (representation != null) {
+ representation = representation.copy();
+ }
+ return representation;
+ }
+
+ public void updateFilterRepresentations(Collection<FilterRepresentation> reps) {
+ for (FilterRepresentation r : reps) {
+ updateOrAddFilterRepresentation(r);
+ }
+ }
+
+ public void updateOrAddFilterRepresentation(FilterRepresentation rep) {
+ int pos = getPositionForRepresentation(rep);
+ if (pos != -1) {
+ mFilters.elementAt(pos).useParametersFrom(rep);
+ } else {
+ addFilter(rep.copy());
+ }
+ }
+
+ public void setDoApplyGeometry(boolean value) {
+ mDoApplyGeometry = value;
+ }
+
+ public void setDoApplyFilters(boolean value) {
+ mDoApplyFilters = value;
+ }
+
+ public boolean getDoApplyFilters() {
+ return mDoApplyFilters;
+ }
+
+ public boolean hasModifications() {
+ for (int i = 0; i < mFilters.size(); i++) {
+ FilterRepresentation filter = mFilters.elementAt(i);
+ if (!filter.isNil()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean contains(byte type) {
+ for (FilterRepresentation representation : mFilters) {
+ if (representation.getFilterType() == type
+ && !representation.isNil()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isPanoramaSafe() {
+ for (FilterRepresentation representation : mFilters) {
+ if (representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY
+ && !representation.isNil()) {
+ return false;
+ }
+ if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER
+ && !representation.isNil()) {
+ return false;
+ }
+ if (representation.getFilterType() == FilterRepresentation.TYPE_VIGNETTE
+ && !representation.isNil()) {
+ return false;
+ }
+ if (representation.getFilterType() == FilterRepresentation.TYPE_TINYPLANET
+ && !representation.isNil()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean same(ImagePreset preset) {
+ if (preset == null) {
+ return false;
+ }
+
+ if (preset.mFilters.size() != mFilters.size()) {
+ return false;
+ }
+
+ if (mDoApplyGeometry != preset.mDoApplyGeometry) {
+ return false;
+ }
+
+ if (mDoApplyFilters != preset.mDoApplyFilters) {
+ if (mFilters.size() > 0 || preset.mFilters.size() > 0) {
+ return false;
+ }
+ }
+
+ if (mDoApplyFilters && preset.mDoApplyFilters) {
+ for (int i = 0; i < preset.mFilters.size(); i++) {
+ FilterRepresentation a = preset.mFilters.elementAt(i);
+ FilterRepresentation b = mFilters.elementAt(i);
+
+ if (!a.same(b)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public boolean equals(ImagePreset preset) {
+ if (preset == null) {
+ return false;
+ }
+
+ if (preset.mFilters.size() != mFilters.size()) {
+ return false;
+ }
+
+ if (mDoApplyGeometry != preset.mDoApplyGeometry) {
+ return false;
+ }
+
+ if (mDoApplyFilters != preset.mDoApplyFilters) {
+ if (mFilters.size() > 0 || preset.mFilters.size() > 0) {
+ return false;
+ }
+ }
+
+ for (int i = 0; i < preset.mFilters.size(); i++) {
+ FilterRepresentation a = preset.mFilters.elementAt(i);
+ FilterRepresentation b = mFilters.elementAt(i);
+ boolean isGeometry = false;
+ if (a instanceof FilterRotateRepresentation
+ || a instanceof FilterMirrorRepresentation
+ || a instanceof FilterCropRepresentation
+ || a instanceof FilterStraightenRepresentation) {
+ isGeometry = true;
+ }
+ boolean evaluate = true;
+ if (!isGeometry && mDoApplyGeometry && !mDoApplyFilters) {
+ evaluate = false;
+ } else if (isGeometry && !mDoApplyGeometry && mDoApplyFilters) {
+ evaluate = false;
+ }
+ if (evaluate && !a.equals(b)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public int similarUpTo(ImagePreset preset) {
+ for (int i = 0; i < preset.mFilters.size(); i++) {
+ FilterRepresentation a = preset.mFilters.elementAt(i);
+ if (i < mFilters.size()) {
+ FilterRepresentation b = mFilters.elementAt(i);
+ if (!a.same(b)) {
+ return i;
+ }
+ if (!a.equals(b)) {
+ return i;
+ }
+ } else {
+ return i;
+ }
+ }
+ return preset.mFilters.size();
+ }
+
+ public void showFilters() {
+ Log.v(LOGTAG, "\\\\\\ showFilters -- " + mFilters.size() + " filters");
+ int n = 0;
+ for (FilterRepresentation representation : mFilters) {
+ Log.v(LOGTAG, " filter " + n + " : " + representation.toString());
+ n++;
+ }
+ Log.v(LOGTAG, "/// showFilters -- " + mFilters.size() + " filters");
+ }
+
+ public FilterRepresentation getLastRepresentation() {
+ if (mFilters.size() > 0) {
+ return mFilters.lastElement();
+ }
+ return null;
+ }
+
+ public void removeFilter(FilterRepresentation filterRepresentation) {
+ if (filterRepresentation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (mFilters.elementAt(i).getFilterType()
+ == filterRepresentation.getFilterType()) {
+ mFilters.remove(i);
+ break;
+ }
+ }
+ } else {
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (sameSerializationName(mFilters.elementAt(i), filterRepresentation)) {
+ mFilters.remove(i);
+ break;
+ }
+ }
+ }
+ }
+
+ // If the filter is an "None" effect or border, then just don't add this filter.
+ public void addFilter(FilterRepresentation representation) {
+ if (representation instanceof FilterUserPresetRepresentation) {
+ ImagePreset preset = ((FilterUserPresetRepresentation) representation).getImagePreset();
+ if (preset.nbFilters() == 1
+ && preset.contains(FilterRepresentation.TYPE_FX)) {
+ FilterRepresentation rep = preset.getFilterRepresentationForType(
+ FilterRepresentation.TYPE_FX);
+ addFilter(rep);
+ } else {
+ // user preset replaces everything
+ mFilters.clear();
+ for (int i = 0; i < preset.nbFilters(); i++) {
+ addFilter(preset.getFilterRepresentation(i));
+ }
+ }
+ } else if (representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY) {
+ // Add geometry filter, removing duplicates and do-nothing operations.
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (sameSerializationName(representation, mFilters.elementAt(i))) {
+ mFilters.remove(i);
+ }
+ }
+ int index = 0;
+ for (; index < mFilters.size(); index++) {
+ FilterRepresentation rep = mFilters.elementAt(index);
+ if (rep.getFilterType() != FilterRepresentation.TYPE_GEOMETRY) {
+ break;
+ }
+ }
+ if (!representation.isNil()) {
+ mFilters.insertElementAt(representation, index);
+ }
+ } else if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
+ removeFilter(representation);
+ if (!isNoneBorderFilter(representation)) {
+ mFilters.add(representation);
+ }
+ } else if (representation.getFilterType() == FilterRepresentation.TYPE_FX) {
+ boolean replaced = false;
+ for (int i = 0; i < mFilters.size(); i++) {
+ FilterRepresentation current = mFilters.elementAt(i);
+ if (current.getFilterType() == FilterRepresentation.TYPE_FX) {
+ mFilters.remove(i);
+ replaced = true;
+ if (!isNoneFxFilter(representation)) {
+ mFilters.add(i, representation);
+ }
+ break;
+ }
+ }
+ if (!replaced) {
+ mFilters.add(0, representation);
+ }
+ } else {
+ mFilters.add(representation);
+ }
+ // Enforces Filter type ordering for borders
+ FilterRepresentation border = null;
+ for (int i = 0; i < mFilters.size();) {
+ FilterRepresentation rep = mFilters.elementAt(i);
+ if (rep.getFilterType() == FilterRepresentation.TYPE_BORDER) {
+ border = rep;
+ mFilters.remove(i);
+ continue;
+ }
+ i++;
+ }
+ if (border != null) {
+ mFilters.add(border);
+ }
+ }
+
+ private boolean isNoneBorderFilter(FilterRepresentation representation) {
+ return representation instanceof FilterImageBorderRepresentation &&
+ ((FilterImageBorderRepresentation) representation).getDrawableResource() == 0;
+ }
+
+ private boolean isNoneFxFilter(FilterRepresentation representation) {
+ return representation instanceof FilterFxRepresentation &&
+ ((FilterFxRepresentation) representation).getNameResource() == R.string.none;
+ }
+
+ public FilterRepresentation getRepresentation(FilterRepresentation filterRepresentation) {
+ for (int i = 0; i < mFilters.size(); i++) {
+ FilterRepresentation representation = mFilters.elementAt(i);
+ if (sameSerializationName(representation, filterRepresentation)) {
+ return representation;
+ }
+ }
+ return null;
+ }
+
+ public Bitmap apply(Bitmap original, FilterEnvironment environment) {
+ Bitmap bitmap = original;
+ bitmap = applyFilters(bitmap, -1, -1, environment);
+ return applyBorder(bitmap, environment);
+ }
+
+ public Collection<FilterRepresentation> getGeometryFilters() {
+ ArrayList<FilterRepresentation> geometry = new ArrayList<FilterRepresentation>();
+ for (FilterRepresentation r : mFilters) {
+ if (r.getFilterType() == FilterRepresentation.TYPE_GEOMETRY) {
+ geometry.add(r);
+ }
+ }
+ return geometry;
+ }
+
+ public FilterRepresentation getFilterWithSerializationName(String serializationName) {
+ for (FilterRepresentation r : mFilters) {
+ if (r != null) {
+ if (sameSerializationName(r.getSerializationName(), serializationName)) {
+ return r.copy();
+ }
+ }
+ }
+ return null;
+ }
+
+ public Rect finalGeometryRect(int width, int height) {
+ return GeometryMathUtils.finalGeometryRect(width, height, getGeometryFilters());
+ }
+
+ public Bitmap applyGeometry(Bitmap bitmap, FilterEnvironment environment) {
+ // Apply any transform -- 90 rotate, flip, straighten, crop
+ // Returns a new bitmap.
+ if (mDoApplyGeometry) {
+ Bitmap bmp = GeometryMathUtils.applyGeometryRepresentations(
+ getGeometryFilters(), bitmap);
+ if (bmp != bitmap) {
+ environment.cache(bitmap);
+ }
+ return bmp;
+ }
+ return bitmap;
+ }
+
+ public Bitmap applyBorder(Bitmap bitmap, FilterEnvironment environment) {
+ // get the border from the list of filters.
+ FilterRepresentation border = getFilterRepresentationForType(
+ FilterRepresentation.TYPE_BORDER);
+ if (border != null && mDoApplyGeometry) {
+ bitmap = environment.applyRepresentation(border, bitmap);
+ if (environment.getQuality() == FilterEnvironment.QUALITY_FINAL) {
+ }
+ }
+ return bitmap;
+ }
+
+ public int nbFilters() {
+ return mFilters.size();
+ }
+
+ public Bitmap applyFilters(Bitmap bitmap, int from, int to, FilterEnvironment environment) {
+ if (mDoApplyFilters) {
+ if (from < 0) {
+ from = 0;
+ }
+ if (to == -1) {
+ to = mFilters.size();
+ }
+ for (int i = from; i < to; i++) {
+ FilterRepresentation representation = mFilters.elementAt(i);
+ if (representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY) {
+ // skip the geometry as it's already applied.
+ continue;
+ }
+ if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
+ // for now, let's skip the border as it will be applied in
+ // applyBorder()
+ // TODO: might be worth getting rid of applyBorder.
+ continue;
+ }
+ Bitmap tmp = bitmap;
+ bitmap = environment.applyRepresentation(representation, bitmap);
+ if (tmp != bitmap) {
+ environment.cache(tmp);
+ }
+ if (environment.needsStop()) {
+ return bitmap;
+ }
+ }
+ }
+
+ return bitmap;
+ }
+
+ public void applyBorder(Allocation in, Allocation out,
+ boolean copyOut, FilterEnvironment environment) {
+ FilterRepresentation border = getFilterRepresentationForType(
+ FilterRepresentation.TYPE_BORDER);
+ if (border != null && mDoApplyGeometry) {
+ // TODO: should keep the bitmap around
+ Allocation bitmapIn = in;
+ if (copyOut) {
+ bitmapIn = Allocation.createTyped(
+ CachingPipeline.getRenderScriptContext(), in.getType());
+ bitmapIn.copyFrom(out);
+ }
+ environment.applyRepresentation(border, bitmapIn, out);
+ }
+ }
+
+ public void applyFilters(int from, int to, Allocation in, Allocation out,
+ FilterEnvironment environment) {
+ if (mDoApplyFilters) {
+ if (from < 0) {
+ from = 0;
+ }
+ if (to == -1) {
+ to = mFilters.size();
+ }
+ for (int i = from; i < to; i++) {
+ FilterRepresentation representation = mFilters.elementAt(i);
+ if (representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY
+ || representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
+ continue;
+ }
+ if (i > from) {
+ in.copyFrom(out);
+ }
+ environment.applyRepresentation(representation, in, out);
+ }
+ }
+ }
+
+ public boolean canDoPartialRendering() {
+ if (MasterImage.getImage().getZoomOrientation() != ImageLoader.ORI_NORMAL) {
+ return false;
+ }
+ for (int i = 0; i < mFilters.size(); i++) {
+ FilterRepresentation representation = mFilters.elementAt(i);
+ if (!representation.supportsPartialRendering()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void fillImageStateAdapter(StateAdapter imageStateAdapter) {
+ if (imageStateAdapter == null) {
+ return;
+ }
+ Vector<State> states = new Vector<State>();
+ for (FilterRepresentation filter : mFilters) {
+ if (filter instanceof FilterUserPresetRepresentation) {
+ // do not show the user preset itself in the state panel
+ continue;
+ }
+ State state = new State(filter.getName());
+ state.setFilterRepresentation(filter);
+ states.add(state);
+ }
+ imageStateAdapter.fill(states);
+ }
+
+ public void setPartialRendering(boolean partialRendering, Rect bounds) {
+ mPartialRendering = partialRendering;
+ mPartialRenderingBounds = bounds;
+ }
+
+ public boolean isPartialRendering() {
+ return mPartialRendering;
+ }
+
+ public Rect getPartialRenderingBounds() {
+ return mPartialRenderingBounds;
+ }
+
+ public Vector<ImageFilter> getUsedFilters(BaseFiltersManager filtersManager) {
+ Vector<ImageFilter> usedFilters = new Vector<ImageFilter>();
+ for (int i = 0; i < mFilters.size(); i++) {
+ FilterRepresentation representation = mFilters.elementAt(i);
+ ImageFilter filter = filtersManager.getFilterForRepresentation(representation);
+ usedFilters.add(filter);
+ }
+ return usedFilters;
+ }
+
+ public String getJsonString(String name) {
+ StringWriter swriter = new StringWriter();
+ try {
+ JsonWriter writer = new JsonWriter(swriter);
+ writeJson(writer, name);
+ writer.close();
+ } catch (IOException e) {
+ return null;
+ }
+ return swriter.toString();
+ }
+
+ public void writeJson(JsonWriter writer, String name) {
+ int numFilters = mFilters.size();
+ try {
+ writer.beginObject();
+ for (int i = 0; i < numFilters; i++) {
+ FilterRepresentation filter = mFilters.get(i);
+ if (filter instanceof FilterUserPresetRepresentation) {
+ continue;
+ }
+ String sname = filter.getSerializationName();
+ if (DEBUG) {
+ Log.v(LOGTAG, "Serialization: " + sname);
+ if (sname == null) {
+ Log.v(LOGTAG, "Serialization name null for filter: " + filter);
+ }
+ }
+ writer.name(sname);
+ filter.serializeRepresentation(writer);
+ }
+ writer.endObject();
+
+ } catch (IOException e) {
+ Log.e(LOGTAG,"Error encoding JASON",e);
+ }
+ }
+
+ /**
+ * populates preset from JSON string
+ *
+ * @param filterString a JSON string
+ * @return true on success if false ImagePreset is undefined
+ */
+ public boolean readJsonFromString(String filterString) {
+ if (DEBUG) {
+ Log.v(LOGTAG, "reading preset: \"" + filterString + "\"");
+ }
+ StringReader sreader = new StringReader(filterString);
+ try {
+ JsonReader reader = new JsonReader(sreader);
+ boolean ok = readJson(reader);
+ if (!ok) {
+ reader.close();
+ return false;
+ }
+ reader.close();
+ } catch (Exception e) {
+ Log.e(LOGTAG, "\""+filterString+"\"");
+ Log.e(LOGTAG, "parsing the filter parameters:", e);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * populates preset from JSON stream
+ *
+ * @param sreader a JSON string
+ * @return true on success if false ImagePreset is undefined
+ */
+ public boolean readJson(JsonReader sreader) throws IOException {
+ sreader.beginObject();
+
+ while (sreader.hasNext()) {
+ String name = sreader.nextName();
+ FilterRepresentation filter = creatFilterFromName(name);
+ if (filter == null) {
+ Log.w(LOGTAG, "UNKNOWN FILTER! " + name);
+ return false;
+ }
+ filter.deSerializeRepresentation(sreader);
+ addFilter(filter);
+ }
+ sreader.endObject();
+ return true;
+ }
+
+ FilterRepresentation creatFilterFromName(String name) {
+ if (FilterRotateRepresentation.SERIALIZATION_NAME.equals(name)) {
+ return new FilterRotateRepresentation();
+ } else if (FilterMirrorRepresentation.SERIALIZATION_NAME.equals(name)) {
+ return new FilterMirrorRepresentation();
+ } else if (FilterStraightenRepresentation.SERIALIZATION_NAME.equals(name)) {
+ return new FilterStraightenRepresentation();
+ } else if (FilterCropRepresentation.SERIALIZATION_NAME.equals(name)) {
+ return new FilterCropRepresentation();
+ }
+ FiltersManager filtersManager = FiltersManager.getManager();
+ return filtersManager.createFilterFromName(name);
+ }
+
+ public void updateWith(ImagePreset preset) {
+ if (preset.mFilters.size() != mFilters.size()) {
+ Log.e(LOGTAG, "Updating a preset with an incompatible one");
+ return;
+ }
+ for (int i = 0; i < mFilters.size(); i++) {
+ FilterRepresentation destRepresentation = mFilters.elementAt(i);
+ FilterRepresentation sourceRepresentation = preset.mFilters.elementAt(i);
+ destRepresentation.useParametersFrom(sourceRepresentation);
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java b/src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java
new file mode 100644
index 0000000..801aee4
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/ImageSavingTask.java
@@ -0,0 +1,161 @@
+/*
+ * 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.pipeline;
+
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.net.Uri;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.tools.SaveImage;
+
+import java.io.File;
+
+public class ImageSavingTask extends ProcessingTask {
+ private ProcessingService mProcessingService;
+
+ static class SaveRequest implements Request {
+ Uri sourceUri;
+ Uri selectedUri;
+ File destinationFile;
+ ImagePreset preset;
+ boolean flatten;
+ int quality;
+ float sizeFactor;
+ Bitmap previewImage;
+ boolean exit;
+ }
+
+ static class UpdateBitmap implements Update {
+ Bitmap bitmap;
+ }
+
+ static class UpdateProgress implements Update {
+ int max;
+ int current;
+ }
+
+ static class UpdatePreviewSaved implements Update {
+ Uri uri;
+ boolean exit;
+ }
+
+ static class URIResult implements Result {
+ Uri uri;
+ boolean exit;
+ }
+
+ public ImageSavingTask(ProcessingService service) {
+ mProcessingService = service;
+ }
+
+ public void saveImage(Uri sourceUri, Uri selectedUri,
+ File destinationFile, ImagePreset preset,
+ Bitmap previewImage, boolean flatten,
+ int quality, float sizeFactor, boolean exit) {
+ SaveRequest request = new SaveRequest();
+ request.sourceUri = sourceUri;
+ request.selectedUri = selectedUri;
+ request.destinationFile = destinationFile;
+ request.preset = preset;
+ request.flatten = flatten;
+ request.quality = quality;
+ request.sizeFactor = sizeFactor;
+ request.previewImage = previewImage;
+ request.exit = exit;
+ postRequest(request);
+ }
+
+ public Result doInBackground(Request message) {
+ SaveRequest request = (SaveRequest) message;
+ Uri sourceUri = request.sourceUri;
+ Uri selectedUri = request.selectedUri;
+ File destinationFile = request.destinationFile;
+ Bitmap previewImage = request.previewImage;
+ ImagePreset preset = request.preset;
+ boolean flatten = request.flatten;
+ final boolean exit = request.exit;
+ // We create a small bitmap showing the result that we can
+ // give to the notification
+ UpdateBitmap updateBitmap = new UpdateBitmap();
+ updateBitmap.bitmap = createNotificationBitmap(previewImage, sourceUri, preset);
+ postUpdate(updateBitmap);
+ SaveImage saveImage = new SaveImage(mProcessingService, sourceUri,
+ selectedUri, destinationFile, previewImage,
+ new SaveImage.Callback() {
+ @Override
+ public void onPreviewSaved(Uri uri){
+ UpdatePreviewSaved previewSaved = new UpdatePreviewSaved();
+ previewSaved.uri = uri;
+ previewSaved.exit = exit;
+ postUpdate(previewSaved);
+ }
+
+ @Override
+ public void onProgress(int max, int current) {
+ UpdateProgress updateProgress = new UpdateProgress();
+ updateProgress.max = max;
+ updateProgress.current = current;
+ postUpdate(updateProgress);
+ }
+ });
+ Uri uri = saveImage.processAndSaveImage(preset, flatten,
+ request.quality, request.sizeFactor, request.exit);
+ URIResult result = new URIResult();
+ result.uri = uri;
+ result.exit = request.exit;
+ return result;
+ }
+
+ @Override
+ public void onResult(Result message) {
+ URIResult result = (URIResult) message;
+ mProcessingService.completeSaveImage(result.uri, result.exit);
+ }
+
+ @Override
+ public void onUpdate(Update message) {
+ if (message instanceof UpdatePreviewSaved){
+ Uri uri = ((UpdatePreviewSaved) message).uri;
+ boolean exit = ((UpdatePreviewSaved) message).exit;
+ mProcessingService.completePreviewSaveImage(uri, exit);
+ }
+ if (message instanceof UpdateBitmap) {
+ Bitmap bitmap = ((UpdateBitmap) message).bitmap;
+ mProcessingService.updateNotificationWithBitmap(bitmap);
+ }
+ if (message instanceof UpdateProgress) {
+ UpdateProgress progress = (UpdateProgress) message;
+ mProcessingService.updateProgress(progress.max, progress.current);
+ }
+ }
+
+ private Bitmap createNotificationBitmap(Bitmap preview, Uri sourceUri, ImagePreset preset) {
+ int notificationBitmapSize = Resources.getSystem().getDimensionPixelSize(
+ android.R.dimen.notification_large_icon_width);
+ if (preview != null) {
+ return Bitmap.createScaledBitmap(preview,
+ notificationBitmapSize, notificationBitmapSize, true);
+ }
+ Bitmap bitmap = ImageLoader.loadConstrainedBitmap(sourceUri, getContext(),
+ notificationBitmapSize, null, true);
+ CachingPipeline pipeline = new CachingPipeline(FiltersManager.getManager(), "Thumb");
+ return pipeline.renderFinalImage(bitmap, preset);
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/PipelineInterface.java b/src/com/android/gallery3d/filtershow/pipeline/PipelineInterface.java
new file mode 100644
index 0000000..d53768c
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/PipelineInterface.java
@@ -0,0 +1,31 @@
+/*
+ * 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.pipeline;
+
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.support.v8.renderscript.Allocation;
+import android.support.v8.renderscript.RenderScript;
+
+public interface PipelineInterface {
+ public String getName();
+ public Resources getResources();
+ public Allocation getInPixelsAllocation();
+ public Allocation getOutPixelsAllocation();
+ public boolean prepareRenderscriptAllocations(Bitmap bitmap);
+ public RenderScript getRSContext();
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java
new file mode 100644
index 0000000..b5b636e
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java
@@ -0,0 +1,327 @@
+/*
+ * 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.pipeline;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.IBinder;
+import android.util.Log;
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.filters.ImageFilter;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.tools.SaveImage;
+
+import java.io.File;
+
+public class ProcessingService extends Service {
+ private static final String LOGTAG = "ProcessingService";
+ private static final boolean SHOW_IMAGE = false;
+ private int mNotificationId;
+ private NotificationManager mNotifyMgr = null;
+ private Notification.Builder mBuilder = null;
+
+ private static final String PRESET = "preset";
+ private static final String QUALITY = "quality";
+ private static final String SOURCE_URI = "sourceUri";
+ private static final String SELECTED_URI = "selectedUri";
+ private static final String DESTINATION_FILE = "destinationFile";
+ private static final String SAVING = "saving";
+ private static final String FLATTEN = "flatten";
+ private static final String SIZE_FACTOR = "sizeFactor";
+ private static final String EXIT = "exit";
+
+ private ProcessingTaskController mProcessingTaskController;
+ private ImageSavingTask mImageSavingTask;
+ private UpdatePreviewTask mUpdatePreviewTask;
+ private HighresRenderingRequestTask mHighresRenderingRequestTask;
+ private FullresRenderingRequestTask mFullresRenderingRequestTask;
+ private RenderingRequestTask mRenderingRequestTask;
+
+ private final IBinder mBinder = new LocalBinder();
+ private FilterShowActivity mFiltershowActivity;
+
+ private boolean mSaving = false;
+ private boolean mNeedsAlive = false;
+
+ public void setFiltershowActivity(FilterShowActivity filtershowActivity) {
+ mFiltershowActivity = filtershowActivity;
+ }
+
+ public void setOriginalBitmap(Bitmap originalBitmap) {
+ if (mUpdatePreviewTask == null) {
+ return;
+ }
+ mUpdatePreviewTask.setOriginal(originalBitmap);
+ mHighresRenderingRequestTask.setOriginal(originalBitmap);
+ mFullresRenderingRequestTask.setOriginal(originalBitmap);
+ mRenderingRequestTask.setOriginal(originalBitmap);
+ }
+
+ public void updatePreviewBuffer() {
+ mHighresRenderingRequestTask.stop();
+ mFullresRenderingRequestTask.stop();
+ mUpdatePreviewTask.updatePreview();
+ }
+
+ public void postRenderingRequest(RenderingRequest request) {
+ mRenderingRequestTask.postRenderingRequest(request);
+ }
+
+ public void postHighresRenderingRequest(ImagePreset preset, float scaleFactor,
+ RenderingRequestCaller caller) {
+ RenderingRequest request = new RenderingRequest();
+ // TODO: use the triple buffer preset as UpdatePreviewTask does instead of creating a copy
+ ImagePreset passedPreset = new ImagePreset(preset);
+ request.setOriginalImagePreset(preset);
+ request.setScaleFactor(scaleFactor);
+ request.setImagePreset(passedPreset);
+ request.setType(RenderingRequest.HIGHRES_RENDERING);
+ request.setCaller(caller);
+ mHighresRenderingRequestTask.postRenderingRequest(request);
+ }
+
+ public void postFullresRenderingRequest(ImagePreset preset, float scaleFactor,
+ Rect bounds, Rect destination,
+ RenderingRequestCaller caller) {
+ RenderingRequest request = new RenderingRequest();
+ ImagePreset passedPreset = new ImagePreset(preset);
+ request.setOriginalImagePreset(preset);
+ request.setScaleFactor(scaleFactor);
+ request.setImagePreset(passedPreset);
+ request.setType(RenderingRequest.PARTIAL_RENDERING);
+ request.setCaller(caller);
+ request.setBounds(bounds);
+ request.setDestination(destination);
+ passedPreset.setPartialRendering(true, bounds);
+ mFullresRenderingRequestTask.postRenderingRequest(request);
+ }
+
+ public void setHighresPreviewScaleFactor(float highResPreviewScale) {
+ mHighresRenderingRequestTask.setHighresPreviewScaleFactor(highResPreviewScale);
+ }
+
+ public void setPreviewScaleFactor(float previewScale) {
+ mHighresRenderingRequestTask.setPreviewScaleFactor(previewScale);
+ mFullresRenderingRequestTask.setPreviewScaleFactor(previewScale);
+ mRenderingRequestTask.setPreviewScaleFactor(previewScale);
+ }
+
+ public void setOriginalBitmapHighres(Bitmap originalHires) {
+ mHighresRenderingRequestTask.setOriginalBitmapHighres(originalHires);
+ }
+
+ public class LocalBinder extends Binder {
+ public ProcessingService getService() {
+ return ProcessingService.this;
+ }
+ }
+
+ public static Intent getSaveIntent(Context context, ImagePreset preset, File destination,
+ Uri selectedImageUri, Uri sourceImageUri, boolean doFlatten, int quality,
+ float sizeFactor, boolean needsExit) {
+ Intent processIntent = new Intent(context, ProcessingService.class);
+ processIntent.putExtra(ProcessingService.SOURCE_URI,
+ sourceImageUri.toString());
+ processIntent.putExtra(ProcessingService.SELECTED_URI,
+ selectedImageUri.toString());
+ processIntent.putExtra(ProcessingService.QUALITY, quality);
+ processIntent.putExtra(ProcessingService.SIZE_FACTOR, sizeFactor);
+ if (destination != null) {
+ processIntent.putExtra(ProcessingService.DESTINATION_FILE, destination.toString());
+ }
+ processIntent.putExtra(ProcessingService.PRESET,
+ preset.getJsonString(ImagePreset.JASON_SAVED));
+ processIntent.putExtra(ProcessingService.SAVING, true);
+ processIntent.putExtra(ProcessingService.EXIT, needsExit);
+ if (doFlatten) {
+ processIntent.putExtra(ProcessingService.FLATTEN, true);
+ }
+ return processIntent;
+ }
+
+
+ @Override
+ public void onCreate() {
+ mProcessingTaskController = new ProcessingTaskController(this);
+ mImageSavingTask = new ImageSavingTask(this);
+ mUpdatePreviewTask = new UpdatePreviewTask();
+ mHighresRenderingRequestTask = new HighresRenderingRequestTask();
+ mFullresRenderingRequestTask = new FullresRenderingRequestTask();
+ mRenderingRequestTask = new RenderingRequestTask();
+ mProcessingTaskController.add(mImageSavingTask);
+ mProcessingTaskController.add(mUpdatePreviewTask);
+ mProcessingTaskController.add(mHighresRenderingRequestTask);
+ mProcessingTaskController.add(mFullresRenderingRequestTask);
+ mProcessingTaskController.add(mRenderingRequestTask);
+ setupPipeline();
+ }
+
+ @Override
+ public void onDestroy() {
+ tearDownPipeline();
+ mProcessingTaskController.quit();
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ mNeedsAlive = true;
+ if (intent != null && intent.getBooleanExtra(SAVING, false)) {
+ // we save using an intent to keep the service around after the
+ // activity has been destroyed.
+ String presetJson = intent.getStringExtra(PRESET);
+ String source = intent.getStringExtra(SOURCE_URI);
+ String selected = intent.getStringExtra(SELECTED_URI);
+ String destination = intent.getStringExtra(DESTINATION_FILE);
+ int quality = intent.getIntExtra(QUALITY, 100);
+ float sizeFactor = intent.getFloatExtra(SIZE_FACTOR, 1);
+ boolean flatten = intent.getBooleanExtra(FLATTEN, false);
+ boolean exit = intent.getBooleanExtra(EXIT, false);
+ Uri sourceUri = Uri.parse(source);
+ Uri selectedUri = null;
+ if (selected != null) {
+ selectedUri = Uri.parse(selected);
+ }
+ File destinationFile = null;
+ if (destination != null) {
+ destinationFile = new File(destination);
+ }
+ ImagePreset preset = new ImagePreset();
+ preset.readJsonFromString(presetJson);
+ mNeedsAlive = false;
+ mSaving = true;
+ handleSaveRequest(sourceUri, selectedUri, destinationFile, preset,
+ MasterImage.getImage().getHighresImage(),
+ flatten, quality, sizeFactor, exit);
+ }
+ return START_REDELIVER_INTENT;
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mBinder;
+ }
+
+ public void onStart() {
+ mNeedsAlive = true;
+ if (!mSaving && mFiltershowActivity != null) {
+ mFiltershowActivity.updateUIAfterServiceStarted();
+ }
+ }
+
+ public void handleSaveRequest(Uri sourceUri, Uri selectedUri,
+ File destinationFile, ImagePreset preset, Bitmap previewImage,
+ boolean flatten, int quality, float sizeFactor, boolean exit) {
+ mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ mNotifyMgr.cancelAll();
+
+ mBuilder =
+ new Notification.Builder(this)
+ .setSmallIcon(R.drawable.filtershow_button_fx)
+ .setContentTitle(getString(R.string.filtershow_notification_label))
+ .setContentText(getString(R.string.filtershow_notification_message));
+
+ startForeground(mNotificationId, mBuilder.build());
+
+ updateProgress(SaveImage.MAX_PROCESSING_STEPS, 0);
+
+ // Process the image
+
+ mImageSavingTask.saveImage(sourceUri, selectedUri, destinationFile,
+ preset, previewImage, flatten, quality, sizeFactor, exit);
+ }
+
+ public void updateNotificationWithBitmap(Bitmap bitmap) {
+ mBuilder.setLargeIcon(bitmap);
+ mNotifyMgr.notify(mNotificationId, mBuilder.build());
+ }
+
+ public void updateProgress(int max, int current) {
+ mBuilder.setProgress(max, current, false);
+ mNotifyMgr.notify(mNotificationId, mBuilder.build());
+ }
+
+ public void completePreviewSaveImage(Uri result, boolean exit) {
+ if (exit && !mNeedsAlive && !mFiltershowActivity.isSimpleEditAction()) {
+ mFiltershowActivity.completeSaveImage(result);
+ }
+ }
+
+ public void completeSaveImage(Uri result, boolean exit) {
+ if (SHOW_IMAGE) {
+ // TODO: we should update the existing image in Gallery instead
+ Intent viewImage = new Intent(Intent.ACTION_VIEW, result);
+ viewImage.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(viewImage);
+ }
+ mNotifyMgr.cancel(mNotificationId);
+ if (!exit) {
+ stopForeground(true);
+ stopSelf();
+ return;
+ }
+ stopForeground(true);
+ stopSelf();
+ if (mNeedsAlive) {
+ // If the app has been restarted while we were saving...
+ mFiltershowActivity.updateUIAfterServiceStarted();
+ } else if (mFiltershowActivity.isSimpleEditAction()) {
+ // terminate now
+ mFiltershowActivity.completeSaveImage(result);
+ }
+ }
+
+ private void setupPipeline() {
+ Resources res = getResources();
+ FiltersManager.setResources(res);
+ CachingPipeline.createRenderscriptContext(this);
+
+ FiltersManager filtersManager = FiltersManager.getManager();
+ filtersManager.addLooks(this);
+ filtersManager.addBorders(this);
+ filtersManager.addTools(this);
+ filtersManager.addEffects();
+
+ FiltersManager highresFiltersManager = FiltersManager.getHighresManager();
+ highresFiltersManager.addLooks(this);
+ highresFiltersManager.addBorders(this);
+ highresFiltersManager.addTools(this);
+ highresFiltersManager.addEffects();
+ }
+
+ private void tearDownPipeline() {
+ ImageFilter.resetStatics();
+ FiltersManager.getPreviewManager().freeRSFilterScripts();
+ FiltersManager.getManager().freeRSFilterScripts();
+ FiltersManager.getHighresManager().freeRSFilterScripts();
+ FiltersManager.reset();
+ CachingPipeline.destroyRenderScriptContext();
+ }
+
+ static {
+ System.loadLibrary("jni_filtershow_filters");
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/ProcessingTask.java b/src/com/android/gallery3d/filtershow/pipeline/ProcessingTask.java
new file mode 100644
index 0000000..8d3e811
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/ProcessingTask.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.pipeline;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+
+public abstract class ProcessingTask {
+ private ProcessingTaskController mTaskController;
+ private Handler mProcessingHandler;
+ private Handler mResultHandler;
+ private int mType;
+ private static final int DELAY = 300;
+
+ static interface Request {}
+ static interface Update {}
+ static interface Result {}
+
+ public boolean postRequest(Request message) {
+ Message msg = mProcessingHandler.obtainMessage(mType);
+ msg.obj = message;
+ if (isPriorityTask()) {
+ if (mProcessingHandler.hasMessages(getType())) {
+ return false;
+ }
+ mProcessingHandler.sendMessageAtFrontOfQueue(msg);
+ } else if (isDelayedTask()) {
+ if (mProcessingHandler.hasMessages(getType())) {
+ mProcessingHandler.removeMessages(getType());
+ }
+ mProcessingHandler.sendMessageDelayed(msg, DELAY);
+ } else {
+ mProcessingHandler.sendMessage(msg);
+ }
+ return true;
+ }
+
+ public void postUpdate(Update message) {
+ Message msg = mResultHandler.obtainMessage(mType);
+ msg.obj = message;
+ msg.arg1 = ProcessingTaskController.UPDATE;
+ mResultHandler.sendMessage(msg);
+ }
+
+ public void processRequest(Request message) {
+ Object result = doInBackground(message);
+ Message msg = mResultHandler.obtainMessage(mType);
+ msg.obj = result;
+ msg.arg1 = ProcessingTaskController.RESULT;
+ mResultHandler.sendMessage(msg);
+ }
+
+ public void added(ProcessingTaskController taskController) {
+ mTaskController = taskController;
+ mResultHandler = taskController.getResultHandler();
+ mProcessingHandler = taskController.getProcessingHandler();
+ mType = taskController.getReservedType();
+ }
+
+ public int getType() {
+ return mType;
+ }
+
+ public Context getContext() {
+ return mTaskController.getContext();
+ }
+
+ public abstract Result doInBackground(Request message);
+ public abstract void onResult(Result message);
+ public void onUpdate(Update message) {}
+ public boolean isPriorityTask() { return false; }
+ public boolean isDelayedTask() { return false; }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/ProcessingTaskController.java b/src/com/android/gallery3d/filtershow/pipeline/ProcessingTaskController.java
new file mode 100644
index 0000000..b54bbb0
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/ProcessingTaskController.java
@@ -0,0 +1,97 @@
+/*
+ * 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.pipeline;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Message;
+import android.util.Log;
+
+import java.util.HashMap;
+
+public class ProcessingTaskController implements Handler.Callback {
+ private static final String LOGTAG = "ProcessingTaskController";
+
+ private Context mContext;
+ private HandlerThread mHandlerThread = null;
+ private Handler mProcessingHandler = null;
+ private int mCurrentType;
+ private HashMap<Integer, ProcessingTask> mTasks = new HashMap<Integer, ProcessingTask>();
+
+ public final static int RESULT = 1;
+ public final static int UPDATE = 2;
+
+ private final Handler mResultHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ ProcessingTask task = mTasks.get(msg.what);
+ if (task != null) {
+ if (msg.arg1 == RESULT) {
+ task.onResult((ProcessingTask.Result) msg.obj);
+ } else if (msg.arg1 == UPDATE) {
+ task.onUpdate((ProcessingTask.Update) msg.obj);
+ } else {
+ Log.w(LOGTAG, "received unknown message! " + msg.arg1);
+ }
+ }
+ }
+ };
+
+ @Override
+ public boolean handleMessage(Message msg) {
+ ProcessingTask task = mTasks.get(msg.what);
+ if (task != null) {
+ task.processRequest((ProcessingTask.Request) msg.obj);
+ return true;
+ }
+ return false;
+ }
+
+ public ProcessingTaskController(Context context) {
+ mContext = context;
+ mHandlerThread = new HandlerThread("ProcessingTaskController",
+ android.os.Process.THREAD_PRIORITY_FOREGROUND);
+ mHandlerThread.start();
+ mProcessingHandler = new Handler(mHandlerThread.getLooper(), this);
+ }
+
+ public Handler getProcessingHandler() {
+ return mProcessingHandler;
+ }
+
+ public Handler getResultHandler() {
+ return mResultHandler;
+ }
+
+ public int getReservedType() {
+ return mCurrentType++;
+ }
+
+ public Context getContext() {
+ return mContext;
+ }
+
+ public void add(ProcessingTask task) {
+ task.added(this);
+ mTasks.put(task.getType(), task);
+ }
+
+ public void quit() {
+ mHandlerThread.quit();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/RenderingRequest.java b/src/com/android/gallery3d/filtershow/pipeline/RenderingRequest.java
new file mode 100644
index 0000000..4cb9e5a
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/RenderingRequest.java
@@ -0,0 +1,205 @@
+/*
+ * 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.pipeline;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import com.android.gallery3d.app.Log;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.cache.BitmapCache;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class RenderingRequest {
+ private static final String LOGTAG = "RenderingRequest";
+ private boolean mIsDirect = false;
+ private Bitmap mBitmap = null;
+ private ImagePreset mImagePreset = null;
+ private ImagePreset mOriginalImagePreset = null;
+ private RenderingRequestCaller mCaller = null;
+ private float mScaleFactor = 1.0f;
+ private Rect mBounds = null;
+ private Rect mDestination = null;
+ private Rect mIconBounds = null;
+ private int mType = FULL_RENDERING;
+ public static final int FULL_RENDERING = 0;
+ public static final int FILTERS_RENDERING = 1;
+ public static final int GEOMETRY_RENDERING = 2;
+ public static final int ICON_RENDERING = 3;
+ public static final int PARTIAL_RENDERING = 4;
+ public static final int HIGHRES_RENDERING = 5;
+ public static final int STYLE_ICON_RENDERING = 6;
+
+ private static final Bitmap.Config mConfig = Bitmap.Config.ARGB_8888;
+
+ public static void post(Context context, Bitmap source, ImagePreset preset,
+ int type, RenderingRequestCaller caller) {
+ RenderingRequest.post(context, source, preset, type, caller, null, null);
+ }
+
+ public static void post(Context context, Bitmap source, ImagePreset preset, int type,
+ RenderingRequestCaller caller, Rect bounds, Rect destination) {
+ if (((type != PARTIAL_RENDERING && type != HIGHRES_RENDERING
+ && type != GEOMETRY_RENDERING && type != FILTERS_RENDERING) && source == null)
+ || preset == null || caller == null) {
+ Log.v(LOGTAG, "something null: source: " + source
+ + " or preset: " + preset + " or caller: " + caller);
+ return;
+ }
+ RenderingRequest request = new RenderingRequest();
+ Bitmap bitmap = null;
+ if (type == FULL_RENDERING
+ || type == ICON_RENDERING
+ || type == STYLE_ICON_RENDERING) {
+ CachingPipeline pipeline = new CachingPipeline(
+ FiltersManager.getManager(), "Icon");
+ bitmap = pipeline.renderGeometryIcon(source, preset);
+ } else if (type != PARTIAL_RENDERING && type != HIGHRES_RENDERING
+ && type != GEOMETRY_RENDERING && type != FILTERS_RENDERING) {
+ bitmap = MasterImage.getImage().getBitmapCache().getBitmap(
+ source.getWidth(), source.getHeight(), BitmapCache.RENDERING_REQUEST);
+ }
+
+ request.setBitmap(bitmap);
+ ImagePreset passedPreset = new ImagePreset(preset);
+ request.setOriginalImagePreset(preset);
+ request.setScaleFactor(MasterImage.getImage().getScaleFactor());
+
+ if (type == PARTIAL_RENDERING) {
+ request.setBounds(bounds);
+ request.setDestination(destination);
+ passedPreset.setPartialRendering(true, bounds);
+ }
+
+ request.setImagePreset(passedPreset);
+ request.setType(type);
+ request.setCaller(caller);
+ request.post(context);
+ }
+
+ public static void postIconRequest(Context context, int w, int h,
+ ImagePreset preset,
+ RenderingRequestCaller caller) {
+ if (preset == null || caller == null) {
+ Log.v(LOGTAG, "something null, preset: "
+ + preset + " or caller: " + caller);
+ return;
+ }
+ RenderingRequest request = new RenderingRequest();
+ ImagePreset passedPreset = new ImagePreset(preset);
+ request.setOriginalImagePreset(preset);
+ request.setScaleFactor(MasterImage.getImage().getScaleFactor());
+ request.setImagePreset(passedPreset);
+ request.setType(RenderingRequest.ICON_RENDERING);
+ request.setCaller(caller);
+ request.setIconBounds(new Rect(0, 0, w, h));
+ request.post(context);
+ }
+
+ public void post(Context context) {
+ if (context instanceof FilterShowActivity) {
+ FilterShowActivity activity = (FilterShowActivity) context;
+ ProcessingService service = activity.getProcessingService();
+ service.postRenderingRequest(this);
+ }
+ }
+
+ public void markAvailable() {
+ if (mBitmap == null || mImagePreset == null
+ || mCaller == null) {
+ return;
+ }
+ mCaller.available(this);
+ }
+
+ public boolean isDirect() {
+ return mIsDirect;
+ }
+
+ public void setDirect(boolean isDirect) {
+ mIsDirect = isDirect;
+ }
+
+ public Bitmap getBitmap() {
+ return mBitmap;
+ }
+
+ public void setBitmap(Bitmap bitmap) {
+ mBitmap = bitmap;
+ }
+
+ public ImagePreset getImagePreset() {
+ return mImagePreset;
+ }
+
+ public void setImagePreset(ImagePreset imagePreset) {
+ mImagePreset = imagePreset;
+ }
+
+ public int getType() {
+ return mType;
+ }
+
+ public void setType(int type) {
+ mType = type;
+ }
+
+ public void setCaller(RenderingRequestCaller caller) {
+ mCaller = caller;
+ }
+
+ public Rect getBounds() {
+ return mBounds;
+ }
+
+ public void setBounds(Rect bounds) {
+ mBounds = bounds;
+ }
+
+ public void setScaleFactor(float scaleFactor) {
+ mScaleFactor = scaleFactor;
+ }
+
+ public float getScaleFactor() {
+ return mScaleFactor;
+ }
+
+ public Rect getDestination() {
+ return mDestination;
+ }
+
+ public void setDestination(Rect destination) {
+ mDestination = destination;
+ }
+
+ public void setIconBounds(Rect bounds) {
+ mIconBounds = bounds;
+ }
+
+ public Rect getIconBounds() {
+ return mIconBounds;
+ }
+
+ public ImagePreset getOriginalImagePreset() {
+ return mOriginalImagePreset;
+ }
+
+ public void setOriginalImagePreset(ImagePreset originalImagePreset) {
+ mOriginalImagePreset = originalImagePreset;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/RenderingRequestCaller.java b/src/com/android/gallery3d/filtershow/pipeline/RenderingRequestCaller.java
new file mode 100644
index 0000000..b978e70
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/RenderingRequestCaller.java
@@ -0,0 +1,21 @@
+/*
+ * 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.pipeline;
+
+public interface RenderingRequestCaller {
+ public void available(RenderingRequest request);
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/RenderingRequestTask.java b/src/com/android/gallery3d/filtershow/pipeline/RenderingRequestTask.java
new file mode 100644
index 0000000..c8bc57d
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/RenderingRequestTask.java
@@ -0,0 +1,87 @@
+/*
+ * 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.pipeline;
+
+import android.graphics.Bitmap;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+
+public class RenderingRequestTask extends ProcessingTask {
+
+ private CachingPipeline mPreviewPipeline = null;
+ private boolean mPipelineIsOn = false;
+
+ public void setPreviewScaleFactor(float previewScale) {
+ mPreviewPipeline.setPreviewScaleFactor(previewScale);
+ }
+
+ static class Render implements Request {
+ RenderingRequest request;
+ }
+
+ static class RenderResult implements Result {
+ RenderingRequest request;
+ }
+
+ public RenderingRequestTask() {
+ mPreviewPipeline = new CachingPipeline(
+ FiltersManager.getManager(), "Normal");
+ }
+
+ public void setOriginal(Bitmap bitmap) {
+ mPreviewPipeline.setOriginal(bitmap);
+ mPipelineIsOn = true;
+ }
+
+ public void stop() {
+ mPreviewPipeline.stop();
+ }
+
+ public void postRenderingRequest(RenderingRequest request) {
+ if (!mPipelineIsOn) {
+ return;
+ }
+ Render render = new Render();
+ render.request = request;
+ postRequest(render);
+ }
+
+ @Override
+ public Result doInBackground(Request message) {
+ RenderingRequest request = ((Render) message).request;
+ RenderResult result = null;
+ if (request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
+ mPreviewPipeline.renderGeometry(request);
+ } else if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ mPreviewPipeline.renderFilters(request);
+ } else {
+ mPreviewPipeline.render(request);
+ }
+ result = new RenderResult();
+ result.request = request;
+ return result;
+ }
+
+ @Override
+ public void onResult(Result message) {
+ if (message == null) {
+ return;
+ }
+ RenderingRequest request = ((RenderResult) message).request;
+ request.markAvailable();
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/SharedBuffer.java b/src/com/android/gallery3d/filtershow/pipeline/SharedBuffer.java
new file mode 100644
index 0000000..f243aa6
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/SharedBuffer.java
@@ -0,0 +1,83 @@
+/*
+ * 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.pipeline;
+
+import android.graphics.Bitmap;
+
+public class SharedBuffer {
+
+ private static final String LOGTAG = "SharedBuffer";
+
+ private volatile Buffer mProducer = null;
+ private volatile Buffer mConsumer = null;
+ private volatile Buffer mIntermediate = null;
+
+ private volatile boolean mNeedsSwap = false;
+ private volatile boolean mNeedsRepaint = true;
+
+ public synchronized void setProducer(Bitmap producer) {
+ if (mProducer != null
+ && !mProducer.isSameSize(producer)) {
+ mProducer.remove();
+ mProducer = null;
+ }
+ if (mProducer == null) {
+ mProducer = new Buffer(producer);
+ } else {
+ mProducer.useBitmap(producer);
+ }
+ }
+
+ public synchronized Buffer getProducer() {
+ return mProducer;
+ }
+
+ public synchronized Buffer getConsumer() {
+ return mConsumer;
+ }
+
+ public synchronized void swapProducer() {
+ Buffer intermediate = mIntermediate;
+ mIntermediate = mProducer;
+ mProducer = intermediate;
+ mNeedsSwap = true;
+ }
+
+ public synchronized void swapConsumerIfNeeded() {
+ if (!mNeedsSwap) {
+ return;
+ }
+ Buffer intermediate = mIntermediate;
+ mIntermediate = mConsumer;
+ mConsumer = intermediate;
+ mNeedsSwap = false;
+ }
+
+ public synchronized void invalidate() {
+ mNeedsRepaint = true;
+ }
+
+ public synchronized boolean checkRepaintNeeded() {
+ if (mNeedsRepaint) {
+ mNeedsRepaint = false;
+ return true;
+ }
+ return false;
+ }
+
+}
+
diff --git a/src/com/android/gallery3d/filtershow/pipeline/SharedPreset.java b/src/com/android/gallery3d/filtershow/pipeline/SharedPreset.java
new file mode 100644
index 0000000..3343612
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/SharedPreset.java
@@ -0,0 +1,48 @@
+/*
+ * 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.pipeline;
+
+public class SharedPreset {
+
+ private volatile ImagePreset mProducerPreset = null;
+ private volatile ImagePreset mConsumerPreset = null;
+ private volatile ImagePreset mIntermediatePreset = null;
+ private volatile boolean mHasNewContent = false;
+
+ public synchronized void enqueuePreset(ImagePreset preset) {
+ if (mProducerPreset == null || (!mProducerPreset.same(preset))) {
+ mProducerPreset = new ImagePreset(preset);
+ } else {
+ mProducerPreset.updateWith(preset);
+ }
+ ImagePreset temp = mIntermediatePreset;
+ mIntermediatePreset = mProducerPreset;
+ mProducerPreset = temp;
+ mHasNewContent = true;
+ }
+
+ public synchronized ImagePreset dequeuePreset() {
+ if (!mHasNewContent) {
+ return mConsumerPreset;
+ }
+ ImagePreset temp = mConsumerPreset;
+ mConsumerPreset = mIntermediatePreset;
+ mIntermediatePreset = temp;
+ mHasNewContent = false;
+ return mConsumerPreset;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/pipeline/UpdatePreviewTask.java b/src/com/android/gallery3d/filtershow/pipeline/UpdatePreviewTask.java
new file mode 100644
index 0000000..61ee8eb
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/pipeline/UpdatePreviewTask.java
@@ -0,0 +1,81 @@
+/*
+ * 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.pipeline;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+
+public class UpdatePreviewTask extends ProcessingTask {
+ private static final String LOGTAG = "UpdatePreviewTask";
+ private CachingPipeline mPreviewPipeline = null;
+ private boolean mHasUnhandledPreviewRequest = false;
+ private boolean mPipelineIsOn = false;
+
+ public UpdatePreviewTask() {
+ mPreviewPipeline = new CachingPipeline(
+ FiltersManager.getPreviewManager(), "Preview");
+ }
+
+ public void setOriginal(Bitmap bitmap) {
+ mPreviewPipeline.setOriginal(bitmap);
+ mPipelineIsOn = true;
+ }
+
+ public void updatePreview() {
+ if (!mPipelineIsOn) {
+ return;
+ }
+ mHasUnhandledPreviewRequest = true;
+ if (postRequest(null)) {
+ mHasUnhandledPreviewRequest = false;
+ }
+ }
+
+ @Override
+ public boolean isPriorityTask() {
+ return true;
+ }
+
+ @Override
+ public Result doInBackground(Request message) {
+ SharedBuffer buffer = MasterImage.getImage().getPreviewBuffer();
+ SharedPreset preset = MasterImage.getImage().getPreviewPreset();
+ ImagePreset renderingPreset = preset.dequeuePreset();
+ if (renderingPreset != null) {
+ mPreviewPipeline.compute(buffer, renderingPreset, 0);
+ // set the preset we used in the buffer for later inspection UI-side
+ buffer.getProducer().setPreset(renderingPreset);
+ buffer.getProducer().sync();
+ buffer.swapProducer(); // push back the result
+ }
+ return null;
+ }
+
+ @Override
+ public void onResult(Result message) {
+ MasterImage.getImage().notifyObservers();
+ if (mHasUnhandledPreviewRequest) {
+ updatePreview();
+ }
+ }
+
+ public void setPipelineIsOn(boolean pipelineIsOn) {
+ mPipelineIsOn = pipelineIsOn;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java b/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java
deleted file mode 100644
index c454c1a..0000000
--- a/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.presets;
-
-import android.graphics.Bitmap;
-import android.support.v8.renderscript.Allocation;
-import android.util.Log;
-
-import com.android.gallery3d.filtershow.cache.CachingPipeline;
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.filters.ImageFilter;
-
-import java.lang.ref.WeakReference;
-import java.util.HashMap;
-
-public class FilterEnvironment {
- private static final String LOGTAG = "FilterEnvironment";
- private ImagePreset mImagePreset;
- private float mScaleFactor;
- private int mQuality;
- private FiltersManager mFiltersManager;
- private CachingPipeline mCachingPipeline;
- private volatile boolean mStop = false;
-
- public synchronized boolean needsStop() {
- return mStop;
- }
-
- public synchronized void setStop(boolean stop) {
- this.mStop = stop;
- }
-
- private HashMap<Long, WeakReference<Bitmap>>
- bitmapCach = new HashMap<Long, WeakReference<Bitmap>>();
-
- public void cache(Bitmap bitmap) {
- if (bitmap == null) {
- return;
- }
- Long key = calcKey(bitmap.getWidth(), bitmap.getHeight());
- bitmapCach.put(key, new WeakReference<Bitmap>(bitmap));
- }
-
- public Bitmap getBitmap(int w, int h) {
- Long key = calcKey(w, h);
- WeakReference<Bitmap> ref = bitmapCach.remove(key);
- Bitmap bitmap = null;
- if (ref != null) {
- bitmap = ref.get();
- }
- if (bitmap == null) {
- bitmap = Bitmap.createBitmap(
- w, h, Bitmap.Config.ARGB_8888);
- }
- return bitmap;
- }
-
- private Long calcKey(long w, long h) {
- return (w << 32) | (h << 32);
- }
-
- public void setImagePreset(ImagePreset imagePreset) {
- mImagePreset = imagePreset;
- }
-
- public ImagePreset getImagePreset() {
- return mImagePreset;
- }
-
- public void setScaleFactor(float scaleFactor) {
- mScaleFactor = scaleFactor;
- }
-
- public float getScaleFactor() {
- return mScaleFactor;
- }
-
- public void setQuality(int quality) {
- mQuality = quality;
- }
-
- public int getQuality() {
- return mQuality;
- }
-
- public void setFiltersManager(FiltersManager filtersManager) {
- mFiltersManager = filtersManager;
- }
-
- public FiltersManager getFiltersManager() {
- return mFiltersManager;
- }
-
- public void applyRepresentation(FilterRepresentation representation,
- Allocation in, Allocation out) {
- ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
- filter.useRepresentation(representation);
- filter.setEnvironment(this);
- if (filter.supportsAllocationInput()) {
- filter.apply(in, out);
- }
- filter.setEnvironment(null);
- }
-
- public Bitmap applyRepresentation(FilterRepresentation representation, Bitmap bitmap) {
- ImageFilter filter = mFiltersManager.getFilterForRepresentation(representation);
- filter.useRepresentation(representation);
- filter.setEnvironment(this);
- Bitmap ret = filter.apply(bitmap, mScaleFactor, mQuality);
- filter.setEnvironment(null);
- return ret;
- }
-
- public CachingPipeline getCachingPipeline() {
- return mCachingPipeline;
- }
-
- public void setCachingPipeline(CachingPipeline cachingPipeline) {
- mCachingPipeline = cachingPipeline;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
deleted file mode 100644
index 2a7e601..0000000
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.presets;
-
-import android.graphics.Bitmap;
-import android.graphics.Rect;
-import android.support.v8.renderscript.Allocation;
-import android.util.Log;
-
-import com.android.gallery3d.filtershow.cache.CachingPipeline;
-import com.android.gallery3d.filtershow.cache.ImageLoader;
-import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.filters.ImageFilter;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.state.State;
-import com.android.gallery3d.filtershow.state.StateAdapter;
-import com.android.gallery3d.util.UsageStatistics;
-
-import java.util.Vector;
-
-public class ImagePreset {
-
- private static final String LOGTAG = "ImagePreset";
-
- private FilterRepresentation mBorder = null;
- public static final int QUALITY_ICON = 0;
- public static final int QUALITY_PREVIEW = 1;
- public static final int QUALITY_FINAL = 2;
- public static final int STYLE_ICON = 3;
-
- private ImageLoader mImageLoader = null;
-
- private Vector<FilterRepresentation> mFilters = new Vector<FilterRepresentation>();
-
- protected String mName = "Original";
- private String mHistoryName = "Original";
- protected boolean mIsFxPreset = false;
-
- private boolean mDoApplyGeometry = true;
- private boolean mDoApplyFilters = true;
-
- public final GeometryMetadata mGeoData = new GeometryMetadata();
- private boolean mPartialRendering = false;
- private Rect mPartialRenderingBounds;
-
- private Bitmap mPreviewImage;
-
- public ImagePreset() {
- setup();
- }
-
- public ImagePreset(String historyName) {
- setHistoryName(historyName);
- setup();
- }
-
- public ImagePreset(ImagePreset source, String historyName) {
- this(source);
- if (historyName != null) {
- setHistoryName(historyName);
- }
- }
-
- public ImagePreset(ImagePreset source) {
- try {
- if (source.mBorder != null) {
- mBorder = source.mBorder.clone();
- }
- for (int i = 0; i < source.mFilters.size(); i++) {
- FilterRepresentation representation = source.mFilters.elementAt(i).clone();
- addFilter(representation);
- }
- } catch (java.lang.CloneNotSupportedException e) {
- Log.v(LOGTAG, "Exception trying to clone: " + e);
- }
- mName = source.name();
- mHistoryName = source.name();
- mIsFxPreset = source.isFx();
- mImageLoader = source.getImageLoader();
- mPreviewImage = source.getPreviewImage();
-
- mGeoData.set(source.mGeoData);
- }
-
- public FilterRepresentation getFilterRepresentation(int position) {
- FilterRepresentation representation = null;
- try {
- representation = mFilters.elementAt(position).clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
- return representation;
- }
-
- public int getPositionForRepresentation(FilterRepresentation representation) {
- for (int i = 0; i < mFilters.size(); i++) {
- if (mFilters.elementAt(i).getFilterClass() == representation.getFilterClass()) {
- return i;
- }
- }
- return -1;
- }
-
- public FilterRepresentation getFilterRepresentationCopyFrom(FilterRepresentation filterRepresentation) {
- // TODO: add concept of position in the filters (to allow multiple instances)
- if (filterRepresentation == null) {
- return null;
- }
- FilterRepresentation representation = null;
- if ((mBorder != null)
- && (mBorder.getFilterClass() == filterRepresentation.getFilterClass())) {
- // TODO: instead of special casing for border, we should correctly implements "filters priority set"
- representation = mBorder;
- } else {
- int position = getPositionForRepresentation(filterRepresentation);
- if (position == -1) {
- return null;
- }
- representation = mFilters.elementAt(position);
- }
- if (representation != null) {
- try {
- representation = representation.clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
- }
- return representation;
- }
-
- public void updateFilterRepresentation(FilterRepresentation representation) {
- if (representation == null) {
- return;
- }
- synchronized (mFilters) {
- if (representation instanceof GeometryMetadata) {
- setGeometry((GeometryMetadata) representation);
- } else {
- if ((mBorder != null)
- && (mBorder.getFilterClass() == representation.getFilterClass())) {
- mBorder.updateTempParametersFrom(representation);
- } else {
- int position = getPositionForRepresentation(representation);
- if (position == -1) {
- return;
- }
- FilterRepresentation old = mFilters.elementAt(position);
- old.updateTempParametersFrom(representation);
- }
- }
- }
- MasterImage.getImage().invalidatePreview();
- fillImageStateAdapter(MasterImage.getImage().getState());
- }
-
- public void setDoApplyGeometry(boolean value) {
- mDoApplyGeometry = value;
- }
-
- public void setDoApplyFilters(boolean value) {
- mDoApplyFilters = value;
- }
-
- public boolean getDoApplyFilters() {
- return mDoApplyFilters;
- }
-
- public synchronized GeometryMetadata getGeometry() {
- return mGeoData;
- }
-
- public boolean hasModifications() {
- if (mBorder != null && !mBorder.isNil()) {
- return true;
- }
- if (mGeoData.hasModifications()) {
- return true;
- }
- for (int i = 0; i < mFilters.size(); i++) {
- FilterRepresentation filter = mFilters.elementAt(i);
- if (!filter.isNil() && !filter.getName().equalsIgnoreCase("none")) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isPanoramaSafe() {
- if (mBorder != null && !mBorder.isNil()) {
- return false;
- }
- if (mGeoData.hasModifications()) {
- return false;
- }
- for (FilterRepresentation representation : mFilters) {
- if (representation.getPriority() == FilterRepresentation.TYPE_VIGNETTE
- && !representation.isNil()) {
- return false;
- }
- if (representation.getPriority() == FilterRepresentation.TYPE_TINYPLANET
- && !representation.isNil()) {
- return false;
- }
- }
- return true;
- }
-
- public synchronized void setGeometry(GeometryMetadata m) {
- mGeoData.set(m);
- MasterImage.getImage().notifyGeometryChange();
- }
-
- private void setBorder(FilterRepresentation filter) {
- mBorder = filter;
- }
-
- public void resetBorder() {
- mBorder = null;
- }
-
- 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 ImageLoader getImageLoader() {
- return mImageLoader;
- }
-
- public void setImageLoader(ImageLoader mImageLoader) {
- this.mImageLoader = mImageLoader;
- }
-
- public boolean equals(ImagePreset preset) {
- if (!same(preset)) {
- return false;
- }
- if (mDoApplyFilters && preset.mDoApplyFilters) {
- for (int i = 0; i < preset.mFilters.size(); i++) {
- FilterRepresentation a = preset.mFilters.elementAt(i);
- FilterRepresentation b = mFilters.elementAt(i);
- if (!a.equals(b)) {
- return false;
- }
- }
- }
- return true;
- }
-
- public boolean same(ImagePreset preset) {
- if (preset == null) {
- return false;
- }
-
- if (preset.mFilters.size() != mFilters.size()) {
- return false;
- }
-
- if (!mName.equalsIgnoreCase(preset.name())) {
- return false;
- }
-
- if (mDoApplyGeometry != preset.mDoApplyGeometry) {
- return false;
- }
-
- if (mDoApplyGeometry && !mGeoData.equals(preset.mGeoData)) {
- return false;
- }
-
- if (mDoApplyGeometry && mBorder != preset.mBorder) {
- return false;
- }
-
- if (mBorder != null && !mBorder.equals(preset.mBorder)) {
- return false;
- }
-
- if (mDoApplyFilters != preset.mDoApplyFilters) {
- if (mFilters.size() > 0 || preset.mFilters.size() > 0) {
- return false;
- }
- }
-
- if (mDoApplyFilters && preset.mDoApplyFilters) {
- for (int i = 0; i < preset.mFilters.size(); i++) {
- FilterRepresentation a = preset.mFilters.elementAt(i);
- FilterRepresentation b = mFilters.elementAt(i);
- if (!a.same(b)) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- public int similarUpTo(ImagePreset preset) {
- if (!mGeoData.equals(preset.mGeoData)) {
- return -1;
- }
-
- for (int i = 0; i < preset.mFilters.size(); i++) {
- FilterRepresentation a = preset.mFilters.elementAt(i);
- if (i < mFilters.size()) {
- FilterRepresentation b = mFilters.elementAt(i);
- if (!a.same(b)) {
- return i;
- }
- if (!a.equals(b)) {
- return i;
- }
- } else {
- return i;
- }
- }
- return preset.mFilters.size();
- }
-
- public String name() {
- return mName;
- }
-
- public String historyName() {
- return mHistoryName;
- }
-
- public void showFilters() {
- Log.v(LOGTAG, "\\\\\\ showFilters -- " + mFilters.size() + " filters");
- int n = 0;
- for (FilterRepresentation representation : mFilters) {
- Log.v(LOGTAG, " filter " + n + " : " + representation.toString());
- n++;
- }
- Log.v(LOGTAG, "/// showFilters -- " + mFilters.size() + " filters");
- }
-
- public FilterRepresentation getLastRepresentation() {
- if (mFilters.size() > 0) {
- return mFilters.lastElement();
- }
- return null;
- }
-
- public void removeFilter(FilterRepresentation filterRepresentation) {
- if (filterRepresentation.getPriority() == FilterRepresentation.TYPE_BORDER) {
- setBorder(null);
- setHistoryName("Remove");
- return;
- }
- for (int i = 0; i < mFilters.size(); i++) {
- if (mFilters.elementAt(i).getFilterClass() == filterRepresentation.getFilterClass()) {
- mFilters.remove(i);
- setHistoryName("Remove");
- return;
- }
- }
- }
-
- public void addFilter(FilterRepresentation representation) {
- if (representation instanceof GeometryMetadata) {
- setGeometry((GeometryMetadata) representation);
- return;
- }
- if (representation.getPriority() == FilterRepresentation.TYPE_BORDER) {
- setHistoryName(representation.getName());
- setBorder(representation);
- } else if (representation.getPriority() == FilterRepresentation.TYPE_FX) {
- boolean found = false;
- for (int i = 0; i < mFilters.size(); i++) {
- int type = mFilters.elementAt(i).getPriority();
- if (found) {
- if (type != FilterRepresentation.TYPE_VIGNETTE) {
- mFilters.remove(i);
- continue;
- }
- }
- if (type == FilterRepresentation.TYPE_FX) {
- mFilters.remove(i);
- mFilters.add(i, representation);
- setHistoryName(representation.getName());
- found = true;
- }
- }
- if (!found) {
- mFilters.add(representation);
- setHistoryName(representation.getName());
- }
- } else {
- mFilters.add(representation);
- setHistoryName(representation.getName());
- }
- }
-
- public FilterRepresentation getRepresentation(FilterRepresentation filterRepresentation) {
- if (filterRepresentation instanceof GeometryMetadata) {
- return mGeoData;
- }
- for (int i = 0; i < mFilters.size(); i++) {
- FilterRepresentation representation = mFilters.elementAt(i);
- if (representation.getFilterClass() == filterRepresentation.getFilterClass()) {
- return representation;
- }
- }
- if (mBorder != null && mBorder.getFilterClass() == filterRepresentation.getFilterClass()) {
- return mBorder;
- }
- return null;
- }
-
- public void setup() {
- // do nothing here
- }
-
- public Bitmap apply(Bitmap original, FilterEnvironment environment) {
- Bitmap bitmap = original;
- bitmap = applyFilters(bitmap, -1, -1, environment);
- return applyBorder(bitmap, environment);
- }
-
- public Bitmap applyGeometry(Bitmap bitmap, FilterEnvironment environment) {
- // Apply any transform -- 90 rotate, flip, straighten, crop
- // Returns a new bitmap.
- if (mDoApplyGeometry) {
- mGeoData.synchronizeRepresentation();
- bitmap = environment.applyRepresentation(mGeoData, bitmap);
- }
- return bitmap;
- }
-
- public Bitmap applyBorder(Bitmap bitmap, FilterEnvironment environment) {
- if (mBorder != null && mDoApplyGeometry) {
- mBorder.synchronizeRepresentation();
- bitmap = environment.applyRepresentation(mBorder, bitmap);
- if (environment.getQuality() == QUALITY_FINAL) {
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
- "SaveBorder", mBorder.getName(), 1);
- }
- }
- return bitmap;
- }
-
- public Bitmap applyFilters(Bitmap bitmap, int from, int to, FilterEnvironment environment) {
- if (mDoApplyFilters) {
- if (from < 0) {
- from = 0;
- }
- if (to == -1) {
- to = mFilters.size();
- }
- for (int i = from; i < to; i++) {
- FilterRepresentation representation = null;
- synchronized (mFilters) {
- representation = mFilters.elementAt(i);
- representation.synchronizeRepresentation();
- }
- bitmap = environment.applyRepresentation(representation, bitmap);
- if (environment.getQuality() == QUALITY_FINAL) {
- UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
- "SaveFilter", representation.getName(), 1);
- }
- if (environment.needsStop()) {
- return bitmap;
- }
- }
- }
-
- return bitmap;
- }
-
- public void applyBorder(Allocation in, Allocation out, FilterEnvironment environment) {
- if (mBorder != null && mDoApplyGeometry) {
- mBorder.synchronizeRepresentation();
- // TODO: should keep the bitmap around
- Allocation bitmapIn = Allocation.createTyped(CachingPipeline.getRenderScriptContext(), in.getType());
- bitmapIn.copyFrom(out);
- environment.applyRepresentation(mBorder, bitmapIn, out);
- }
- }
-
- public void applyFilters(int from, int to, Allocation in, Allocation out, FilterEnvironment environment) {
- if (mDoApplyFilters) {
- if (from < 0) {
- from = 0;
- }
- if (to == -1) {
- to = mFilters.size();
- }
- for (int i = from; i < to; i++) {
- FilterRepresentation representation = null;
- synchronized (mFilters) {
- representation = mFilters.elementAt(i);
- representation.synchronizeRepresentation();
- }
- if (i > from) {
- in.copyFrom(out);
- }
- environment.applyRepresentation(representation, in, out);
- }
- }
- }
-
- public boolean canDoPartialRendering() {
- if (mGeoData.hasModifications()) {
- return false;
- }
- if (mBorder != null && !mBorder.supportsPartialRendering()) {
- return false;
- }
- if (ImageLoader.getZoomOrientation() != ImageLoader.ORI_NORMAL) {
- return false;
- }
- for (int i = 0; i < mFilters.size(); i++) {
- FilterRepresentation representation = null;
- synchronized (mFilters) {
- representation = mFilters.elementAt(i);
- }
- if (!representation.supportsPartialRendering()) {
- return false;
- }
- }
- return true;
- }
-
- public void fillImageStateAdapter(StateAdapter imageStateAdapter) {
- if (imageStateAdapter == null) {
- return;
- }
- Vector<State> states = new Vector<State>();
- // TODO: supports Geometry representations in the state panel.
- if (false && mGeoData != null && mGeoData.hasModifications()) {
- State geo = new State("Geometry");
- geo.setFilterRepresentation(mGeoData);
- states.add(geo);
- }
- for (FilterRepresentation filter : mFilters) {
- State state = new State(filter.getName());
- state.setFilterRepresentation(filter);
- states.add(state);
- }
- if (mBorder != null) {
- State border = new State(mBorder.getName());
- border.setFilterRepresentation(mBorder);
- states.add(border);
- }
- imageStateAdapter.fill(states);
- }
-
- public void setPartialRendering(boolean partialRendering, Rect bounds) {
- mPartialRendering = partialRendering;
- mPartialRenderingBounds = bounds;
- }
-
- public boolean isPartialRendering() {
- return mPartialRendering;
- }
-
- public Rect getPartialRenderingBounds() {
- return mPartialRenderingBounds;
- }
-
- public Bitmap getPreviewImage() {
- return mPreviewImage;
- }
-
- public void setPreviewImage(Bitmap previewImage) {
- mPreviewImage = previewImage;
- }
-
- public Vector<ImageFilter> getUsedFilters(BaseFiltersManager filtersManager) {
- Vector<ImageFilter> usedFilters = new Vector<ImageFilter>();
- for (int i = 0; i < mFilters.size(); i++) {
- FilterRepresentation representation = mFilters.elementAt(i);
- ImageFilter filter = filtersManager.getFilterForRepresentation(representation);
- usedFilters.add(filter);
- }
- return usedFilters;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/presets/PresetManagementDialog.java b/src/com/android/gallery3d/filtershow/presets/PresetManagementDialog.java
new file mode 100644
index 0000000..63a6165
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/presets/PresetManagementDialog.java
@@ -0,0 +1,67 @@
+/*
+ * 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.presets;
+
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.ListView;
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+
+public class PresetManagementDialog extends DialogFragment implements View.OnClickListener {
+ private UserPresetsAdapter mAdapter;
+ private EditText mEditText;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.filtershow_presets_management_dialog, container);
+
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ mAdapter = activity.getUserPresetsAdapter();
+ mEditText = (EditText) view.findViewById(R.id.editView);
+ view.findViewById(R.id.cancel).setOnClickListener(this);
+ view.findViewById(R.id.ok).setOnClickListener(this);
+ getDialog().setTitle(getString(R.string.filtershow_save_preset));
+ return view;
+ }
+
+ @Override
+ public void onClick(View v) {
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ switch (v.getId()) {
+ case R.id.cancel:
+ mAdapter.clearChangedRepresentations();
+ mAdapter.clearDeletedRepresentations();
+ activity.updateUserPresetsFromAdapter(mAdapter);
+ dismiss();
+ break;
+ case R.id.ok:
+ String text = String.valueOf(mEditText.getText());
+ activity.saveCurrentImagePreset(text);
+ mAdapter.updateCurrent();
+ activity.updateUserPresetsFromAdapter(mAdapter);
+ dismiss();
+ break;
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/presets/UserPresetsAdapter.java b/src/com/android/gallery3d/filtershow/presets/UserPresetsAdapter.java
new file mode 100644
index 0000000..dab9ea4
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/presets/UserPresetsAdapter.java
@@ -0,0 +1,171 @@
+/*
+ * 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.presets;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.category.Action;
+import com.android.gallery3d.filtershow.category.CategoryView;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
+
+import java.util.ArrayList;
+
+public class UserPresetsAdapter extends ArrayAdapter<Action>
+ implements View.OnClickListener, View.OnFocusChangeListener {
+ private static final String LOGTAG = "UserPresetsAdapter";
+ private LayoutInflater mInflater;
+ private int mIconSize = 160;
+ private ArrayList<FilterUserPresetRepresentation> mDeletedRepresentations =
+ new ArrayList<FilterUserPresetRepresentation>();
+ private ArrayList<FilterUserPresetRepresentation> mChangedRepresentations =
+ new ArrayList<FilterUserPresetRepresentation>();
+ private EditText mCurrentEditText;
+
+ public UserPresetsAdapter(Context context, int textViewResourceId) {
+ super(context, textViewResourceId);
+ mInflater = LayoutInflater.from(context);
+ mIconSize = context.getResources().getDimensionPixelSize(R.dimen.category_panel_icon_size);
+ }
+
+ public UserPresetsAdapter(Context context) {
+ this(context, 0);
+ }
+
+ @Override
+ public void add(Action action) {
+ super.add(action);
+ action.setAdapter(this);
+ }
+
+ private void deletePreset(Action action) {
+ FilterRepresentation rep = action.getRepresentation();
+ if (rep instanceof FilterUserPresetRepresentation) {
+ mDeletedRepresentations.add((FilterUserPresetRepresentation) rep);
+ }
+ remove(action);
+ notifyDataSetChanged();
+ }
+
+ private void changePreset(Action action) {
+ FilterRepresentation rep = action.getRepresentation();
+ rep.setName(action.getName());
+ if (rep instanceof FilterUserPresetRepresentation) {
+ mChangedRepresentations.add((FilterUserPresetRepresentation) rep);
+ }
+ }
+
+ public void updateCurrent() {
+ if (mCurrentEditText != null) {
+ updateActionFromEditText(mCurrentEditText);
+ }
+ }
+
+ static class UserPresetViewHolder {
+ ImageView imageView;
+ EditText editText;
+ ImageButton deleteButton;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ UserPresetViewHolder viewHolder;
+ if (convertView == null) {
+ convertView = mInflater.inflate(R.layout.filtershow_presets_management_row, null);
+ viewHolder = new UserPresetViewHolder();
+ viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView);
+ viewHolder.editText = (EditText) convertView.findViewById(R.id.editView);
+ viewHolder.deleteButton = (ImageButton) convertView.findViewById(R.id.deleteUserPreset);
+ viewHolder.editText.setOnClickListener(this);
+ viewHolder.editText.setOnFocusChangeListener(this);
+ viewHolder.deleteButton.setOnClickListener(this);
+ convertView.setTag(viewHolder);
+ } else {
+ viewHolder = (UserPresetViewHolder) convertView.getTag();
+ }
+ Action action = getItem(position);
+ viewHolder.imageView.setImageBitmap(action.getImage());
+ if (action.getImage() == null) {
+ // queue image rendering for this action
+ action.setImageFrame(new Rect(0, 0, mIconSize, mIconSize), CategoryView.VERTICAL);
+ }
+ viewHolder.deleteButton.setTag(action);
+ viewHolder.editText.setTag(action);
+ viewHolder.editText.setHint(action.getName());
+
+ return convertView;
+ }
+
+ public ArrayList<FilterUserPresetRepresentation> getDeletedRepresentations() {
+ return mDeletedRepresentations;
+ }
+
+ public void clearDeletedRepresentations() {
+ mDeletedRepresentations.clear();
+ }
+
+ public ArrayList<FilterUserPresetRepresentation> getChangedRepresentations() {
+ return mChangedRepresentations;
+ }
+
+ public void clearChangedRepresentations() {
+ mChangedRepresentations.clear();
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.editView:
+ v.requestFocus();
+ break;
+ case R.id.deleteUserPreset:
+ Action action = (Action) v.getTag();
+ deletePreset(action);
+ break;
+ }
+ }
+
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (v.getId() != R.id.editView) {
+ return;
+ }
+ EditText editText = (EditText) v;
+ if (!hasFocus) {
+ updateActionFromEditText(editText);
+ } else {
+ mCurrentEditText = editText;
+ }
+ }
+
+ private void updateActionFromEditText(EditText editText) {
+ Action action = (Action) editText.getTag();
+ String newName = editText.getText().toString();
+ if (newName.length() > 0) {
+ action.setName(editText.getText().toString());
+ changePreset(action);
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/state/State.java b/src/com/android/gallery3d/filtershow/state/State.java
index 29bbf91..e7dedd6 100644
--- a/src/com/android/gallery3d/filtershow/state/State.java
+++ b/src/com/android/gallery3d/filtershow/state/State.java
@@ -16,6 +16,7 @@
package com.android.gallery3d.filtershow.state;
+import com.android.gallery3d.filtershow.filters.FilterFxRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
public class State {
@@ -41,6 +42,9 @@
!= state.mFilterRepresentation.getFilterClass()) {
return false;
}
+ if (mFilterRepresentation instanceof FilterFxRepresentation) {
+ return mFilterRepresentation.equals(state.getFilterRepresentation());
+ }
return true;
}
diff --git a/src/com/android/gallery3d/filtershow/state/StatePanel.java b/src/com/android/gallery3d/filtershow/state/StatePanel.java
index df470f2..95c2df9 100644
--- a/src/com/android/gallery3d/filtershow/state/StatePanel.java
+++ b/src/com/android/gallery3d/filtershow/state/StatePanel.java
@@ -22,23 +22,48 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.category.MainPanel;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.util.FilterShowHelper;
public class StatePanel extends Fragment {
private static final String LOGTAG = "StatePanel";
+ private MainPanel mMainPanel;
private StatePanelTrack track;
private LinearLayout mMainView;
+ private ImageButton mToggleVersionsPanel;
public static final String FRAGMENT_TAG = "StatePanel";
+ public void setMainPanel(MainPanel mainPanel) {
+ mMainPanel = mainPanel;
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mMainView = (LinearLayout) inflater.inflate(R.layout.filtershow_state_panel_new, null);
+
View panel = mMainView.findViewById(R.id.listStates);
track = (StatePanelTrack) panel;
track.setAdapter(MasterImage.getImage().getState());
+ mToggleVersionsPanel = (ImageButton) mMainView.findViewById(R.id.toggleVersionsPanel);
+ if (FilterShowHelper.shouldUseVersions()) {
+ if (mToggleVersionsPanel.getVisibility() == View.GONE
+ || mToggleVersionsPanel.getVisibility() == View.INVISIBLE) {
+ mToggleVersionsPanel.setVisibility(View.VISIBLE);
+ mToggleVersionsPanel.setImageBitmap(null);
+ }
+ if (mMainPanel != null) {
+ mMainPanel.setToggleVersionsPanelButton(mToggleVersionsPanel);
+ } else if (mToggleVersionsPanel != null) {
+ mToggleVersionsPanel.setVisibility(View.GONE);
+ }
+ } else {
+ mToggleVersionsPanel.setVisibility(View.GONE);
+ }
return mMainView;
}
}
diff --git a/src/com/android/gallery3d/filtershow/state/StatePanelTrack.java b/src/com/android/gallery3d/filtershow/state/StatePanelTrack.java
index fff7e7f..4ddb363 100644
--- a/src/com/android/gallery3d/filtershow/state/StatePanelTrack.java
+++ b/src/com/android/gallery3d/filtershow/state/StatePanelTrack.java
@@ -58,6 +58,7 @@
private long mTouchTime;
private int mMaxTouchDelay = 300; // 300ms delay for touch
private static final boolean ALLOWS_DRAG = false;
+ private static final boolean ALLOWS_DUPLICATES = false;
private DataSetObserver mObserver = new DataSetObserver() {
@Override
public void onChanged() {
@@ -104,6 +105,9 @@
}
private void addDuplicate(MotionEvent e) {
+ if (!ALLOWS_DUPLICATES) {
+ return;
+ }
if (mCurrentSelectedView == null) {
return;
}
@@ -115,6 +119,9 @@
}
private void longPress(MotionEvent e) {
+ if (!ALLOWS_DUPLICATES) {
+ return;
+ }
View view = findChildAt((int) e.getX(), (int) e.getY());
if (view == null) {
return;
diff --git a/src/com/android/gallery3d/filtershow/state/StateView.java b/src/com/android/gallery3d/filtershow/state/StateView.java
index 73d5784..a43cd47 100644
--- a/src/com/android/gallery3d/filtershow/state/StateView.java
+++ b/src/com/android/gallery3d/filtershow/state/StateView.java
@@ -19,17 +19,17 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.*;
-import android.util.AttributeSet;
-import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewParent;
import android.widget.LinearLayout;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.category.SwipableView;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
-public class StateView extends View {
+public class StateView extends View implements SwipableView {
private static final String LOGTAG = "StateView";
private Path mPath = new Path();
@@ -51,6 +51,10 @@
private static int sMargin = 16;
private static int sArrowHeight = 16;
private static int sArrowWidth = 8;
+ private float mStartTouchX = 0;
+ private float mStartTouchY = 0;
+ private float mDeleteSlope = 20;
+
private int mOrientation = LinearLayout.VERTICAL;
private int mDirection = DOWN;
private boolean mDuplicateButton;
@@ -104,24 +108,6 @@
invalidate();
}
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
- ViewParent parent = getParent();
- if (parent instanceof PanelTrack) {
- ((PanelTrack) getParent()).onTouch(event, this);
- }
- if (mType == BEGIN) {
- MasterImage.getImage().setShowsOriginal(true);
- }
- }
- if (event.getActionMasked() == MotionEvent.ACTION_UP
- || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
- MasterImage.getImage().setShowsOriginal(false);
- }
- return true;
- }
-
public void drawText(Canvas canvas) {
if (mText == null) {
return;
@@ -180,22 +166,42 @@
}
private void drawHorizontalPath(float w, float h, float r, float d) {
- mPath.moveTo(0, 0);
- if (mType == END) {
- mPath.lineTo(w, 0);
+ if (this.getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
+ mPath.moveTo(w, 0);
+ if (mType == END) {
+ mPath.lineTo(0, 0);
+ mPath.lineTo(0, h);
+ } else {
+ mPath.lineTo(d, 0);
+ mPath.lineTo(d, r);
+ mPath.lineTo(0, r + d);
+ mPath.lineTo(d, r + d + r);
+ mPath.lineTo(d, h);
+ }
mPath.lineTo(w, h);
+ if (mType != BEGIN) {
+ mPath.lineTo(w, r + d + r);
+ mPath.lineTo(w - d, r + d);
+ mPath.lineTo(w, r);
+ }
} else {
- mPath.lineTo(w - d, 0);
- mPath.lineTo(w - d, r);
- mPath.lineTo(w, r + d);
- mPath.lineTo(w - d, r + d + r);
- mPath.lineTo(w - d, h);
- }
- mPath.lineTo(0, h);
- if (mType != BEGIN) {
- mPath.lineTo(0, r + d + r);
- mPath.lineTo(d, r + d);
- mPath.lineTo(0, r);
+ mPath.moveTo(0, 0);
+ if (mType == END) {
+ mPath.lineTo(w, 0);
+ mPath.lineTo(w, h);
+ } else {
+ mPath.lineTo(w - d, 0);
+ mPath.lineTo(w - d, r);
+ mPath.lineTo(w, r + d);
+ mPath.lineTo(w - d, r + d + r);
+ mPath.lineTo(w - d, h);
+ }
+ mPath.lineTo(0, h);
+ if (mType != BEGIN) {
+ mPath.lineTo(0, r + d + r);
+ mPath.lineTo(d, r + d);
+ mPath.lineTo(0, r);
+ }
}
mPath.close();
}
@@ -288,4 +294,54 @@
public boolean isDraggable() {
return mState.isDraggable();
}
+
+ @Override
+ public void delete() {
+ FilterShowActivity activity = (FilterShowActivity) getContext();
+ FilterRepresentation representation = getState().getFilterRepresentation();
+ activity.removeFilterRepresentation(representation);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ boolean ret = super.onTouchEvent(event);
+ FilterShowActivity activity = (FilterShowActivity) getContext();
+
+ if (event.getActionMasked() == MotionEvent.ACTION_UP) {
+ activity.startTouchAnimation(this, event.getX(), event.getY());
+ }
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ mStartTouchY = event.getY();
+ mStartTouchX = event.getX();
+ if (mType == BEGIN) {
+ MasterImage.getImage().setShowsOriginal(true);
+ }
+ }
+ if (event.getActionMasked() == MotionEvent.ACTION_UP
+ || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
+ setTranslationX(0);
+ setTranslationY(0);
+ MasterImage.getImage().setShowsOriginal(false);
+ if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_UP) {
+ setSelected(true);
+ FilterRepresentation representation = getState().getFilterRepresentation();
+ MasterImage image = MasterImage.getImage();
+ ImagePreset preset = image != null ? image.getCurrentPreset() : null;
+ if (getTranslationY() == 0
+ && image != null && preset != null
+ && representation != image.getCurrentFilterRepresentation()
+ && preset.getRepresentation(representation) != null) {
+ activity.showRepresentation(representation);
+ setSelected(false);
+ }
+ }
+ }
+ if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_MOVE) {
+ float delta = event.getY() - mStartTouchY;
+ if (Math.abs(delta) > mDeleteSlope) {
+ activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
+ }
+ }
+ return true;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/tools/BitmapTask.java b/src/com/android/gallery3d/filtershow/tools/BitmapTask.java
deleted file mode 100644
index 62801c1..0000000
--- a/src/com/android/gallery3d/filtershow/tools/BitmapTask.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.tools;
-
-import android.graphics.Bitmap;
-import android.os.AsyncTask;
-
-/**
- * Asynchronous task filtering or doign I/O with bitmaps.
- */
-public class BitmapTask <T> extends AsyncTask<T, Void, Bitmap> {
-
- private Callbacks<T> mCallbacks;
- private static final String LOGTAG = "BitmapTask";
-
- public BitmapTask(Callbacks<T> callbacks) {
- mCallbacks = callbacks;
- }
-
- @Override
- protected Bitmap doInBackground(T... params) {
- if (params == null || mCallbacks == null) {
- return null;
- }
- return mCallbacks.onExecute(params[0]);
- }
-
- @Override
- protected void onPostExecute(Bitmap result) {
- if (mCallbacks == null) {
- return;
- }
- mCallbacks.onComplete(result);
- }
-
- @Override
- protected void onCancelled() {
- if (mCallbacks == null) {
- return;
- }
- mCallbacks.onCancel();
- }
-
- /**
- * Callbacks for the asynchronous task.
- */
- public interface Callbacks<P> {
- void onComplete(Bitmap result);
-
- void onCancel();
-
- Bitmap onExecute(P param);
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/tools/IconFactory.java b/src/com/android/gallery3d/filtershow/tools/IconFactory.java
index ccc49e1..9e39f27 100644
--- a/src/com/android/gallery3d/filtershow/tools/IconFactory.java
+++ b/src/com/android/gallery3d/filtershow/tools/IconFactory.java
@@ -103,6 +103,6 @@
rec.roundOut(srcRect);
}
- canvas.drawBitmap(sourceImage, srcRect, destRect, new Paint());
+ canvas.drawBitmap(sourceImage, srcRect, destRect, new Paint(Paint.FILTER_BITMAP_FLAG));
}
}
diff --git a/src/com/android/gallery3d/filtershow/tools/MatrixFit.java b/src/com/android/gallery3d/filtershow/tools/MatrixFit.java
new file mode 100644
index 0000000..3b81567
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/tools/MatrixFit.java
@@ -0,0 +1,200 @@
+/*
+ * 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.tools;
+
+import android.util.Log;
+
+public class MatrixFit {
+ // Simple implementation of a matrix fit in N dimensions.
+
+ private static final String LOGTAG = "MatrixFit";
+
+ private double[][] mMatrix;
+ private int mDimension;
+ private boolean mValid = false;
+ private static double sEPS = 1.0f/10000000000.0f;
+
+ public MatrixFit(double[][] from, double[][] to) {
+ mValid = fit(from, to);
+ }
+
+ public int getDimension() {
+ return mDimension;
+ }
+
+ public boolean isValid() {
+ return mValid;
+ }
+
+ public double[][] getMatrix() {
+ return mMatrix;
+ }
+
+ public boolean fit(double[][] from, double[][] to) {
+ if ((from.length != to.length) || (from.length < 1)) {
+ Log.e(LOGTAG, "from and to must be of same size");
+ return false;
+ }
+
+ mDimension = from[0].length;
+ mMatrix = new double[mDimension +1][mDimension + mDimension +1];
+
+ if (from.length < mDimension) {
+ Log.e(LOGTAG, "Too few points => under-determined system");
+ return false;
+ }
+
+ double[][] q = new double[from.length][mDimension];
+ for (int i = 0; i < from.length; i++) {
+ for (int j = 0; j < mDimension; j++) {
+ q[i][j] = from[i][j];
+ }
+ }
+
+ double[][] p = new double[to.length][mDimension];
+ for (int i = 0; i < to.length; i++) {
+ for (int j = 0; j < mDimension; j++) {
+ p[i][j] = to[i][j];
+ }
+ }
+
+ // Make an empty (dim) x (dim + 1) matrix and fill it
+ double[][] c = new double[mDimension+1][mDimension];
+ for (int j = 0; j < mDimension; j++) {
+ for (int k = 0; k < mDimension + 1; k++) {
+ for (int i = 0; i < q.length; i++) {
+ double qt = 1;
+ if (k < mDimension) {
+ qt = q[i][k];
+ }
+ c[k][j] += qt * p[i][j];
+ }
+ }
+ }
+
+ // Make an empty (dim+1) x (dim+1) matrix and fill it
+ double[][] Q = new double[mDimension+1][mDimension+1];
+ for (int qi = 0; qi < q.length; qi++) {
+ double[] qt = new double[mDimension + 1];
+ for (int i = 0; i < mDimension; i++) {
+ qt[i] = q[qi][i];
+ }
+ qt[mDimension] = 1;
+ for (int i = 0; i < mDimension + 1; i++) {
+ for (int j = 0; j < mDimension + 1; j++) {
+ Q[i][j] += qt[i] * qt[j];
+ }
+ }
+ }
+
+ // Use a gaussian elimination to solve the linear system
+ for (int i = 0; i < mDimension + 1; i++) {
+ for (int j = 0; j < mDimension + 1; j++) {
+ mMatrix[i][j] = Q[i][j];
+ }
+ for (int j = 0; j < mDimension; j++) {
+ mMatrix[i][mDimension + 1 + j] = c[i][j];
+ }
+ }
+ if (!gaussianElimination(mMatrix)) {
+ return false;
+ }
+ return true;
+ }
+
+ public double[] apply(double[] point) {
+ if (mDimension != point.length) {
+ return null;
+ }
+ double[] res = new double[mDimension];
+ for (int j = 0; j < mDimension; j++) {
+ for (int i = 0; i < mDimension; i++) {
+ res[j] += point[i] * mMatrix[i][j+ mDimension +1];
+ }
+ res[j] += mMatrix[mDimension][j+ mDimension +1];
+ }
+ return res;
+ }
+
+ public void printEquation() {
+ for (int j = 0; j < mDimension; j++) {
+ String str = "x" + j + "' = ";
+ for (int i = 0; i < mDimension; i++) {
+ str += "x" + i + " * " + mMatrix[i][j+mDimension+1] + " + ";
+ }
+ str += mMatrix[mDimension][j+mDimension+1];
+ Log.v(LOGTAG, str);
+ }
+ }
+
+ private void printMatrix(String name, double[][] matrix) {
+ Log.v(LOGTAG, "name: " + name);
+ for (int i = 0; i < matrix.length; i++) {
+ String str = "";
+ for (int j = 0; j < matrix[0].length; j++) {
+ str += "" + matrix[i][j] + " ";
+ }
+ Log.v(LOGTAG, str);
+ }
+ }
+
+ /*
+ * Transforms the given matrix into a row echelon matrix
+ */
+ private boolean gaussianElimination(double[][] m) {
+ int h = m.length;
+ int w = m[0].length;
+
+ for (int y = 0; y < h; y++) {
+ int maxrow = y;
+ for (int y2 = y + 1; y2 < h; y2++) { // Find max pivot
+ if (Math.abs(m[y2][y]) > Math.abs(m[maxrow][y])) {
+ maxrow = y2;
+ }
+ }
+ // swap
+ for (int i = 0; i < mDimension; i++) {
+ double t = m[y][i];
+ m[y][i] = m[maxrow][i];
+ m[maxrow][i] = t;
+ }
+
+ if (Math.abs(m[y][y]) <= sEPS) { // Singular Matrix
+ return false;
+ }
+ for (int y2 = y + 1; y2 < h; y2++) { // Eliminate column y
+ double c = m[y2][y] / m[y][y];
+ for (int x = y; x < w; x++) {
+ m[y2][x] -= m[y][x] * c;
+ }
+ }
+ }
+ for (int y = h -1; y > -1; y--) { // Back substitution
+ double c = m[y][y];
+ for (int y2 = 0; y2 < y; y2++) {
+ for (int x = w - 1; x > y - 1; x--) {
+ m[y2][x] -= m[y][x] * m[y2][y] / c;
+ }
+ }
+ m[y][y] /= c;
+ for (int x = h; x < w; x++) { // Normalize row y
+ m[y][x] /= c;
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/tools/SaveCopyTask.java b/src/com/android/gallery3d/filtershow/tools/SaveCopyTask.java
deleted file mode 100644
index 6255f31..0000000
--- a/src/com/android/gallery3d/filtershow/tools/SaveCopyTask.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright (C) 2010 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.tools;
-
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Environment;
-import android.provider.MediaStore.Images;
-import android.provider.MediaStore.Images.ImageColumns;
-import android.util.Log;
-
-import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.exif.ExifInterface;
-import com.android.gallery3d.filtershow.cache.CachingPipeline;
-import com.android.gallery3d.filtershow.cache.ImageLoader;
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-import com.android.gallery3d.util.XmpUtilHelper;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Asynchronous task for saving edited photo as a new copy.
- */
-public class SaveCopyTask extends AsyncTask<ImagePreset, Void, Uri> {
-
- private static final String LOGTAG = "SaveCopyTask";
-
- /**
- * Callback for the completed asynchronous task.
- */
- public interface Callback {
-
- void onComplete(Uri result);
- }
-
- private interface ContentResolverQueryCallback {
-
- void onCursorResult(Cursor cursor);
- }
-
- private static final String TIME_STAMP_NAME = "'IMG'_yyyyMMdd_HHmmss";
-
- private final Context context;
- private final Uri sourceUri;
- private final Callback callback;
- private final String saveFileName;
- private final File destinationFile;
-
- public SaveCopyTask(Context context, Uri sourceUri, File destination, Callback callback) {
- this.context = context;
- this.sourceUri = sourceUri;
- this.callback = callback;
-
- if (destination == null) {
- this.destinationFile = getNewFile(context, sourceUri);
- } else {
- this.destinationFile = destination;
- }
-
- saveFileName = new SimpleDateFormat(TIME_STAMP_NAME).format(new Date());
- }
-
- public static File getFinalSaveDirectory(Context context, Uri sourceUri) {
- File saveDirectory = getSaveDirectory(context, sourceUri);
- if ((saveDirectory == null) || !saveDirectory.canWrite()) {
- saveDirectory = new File(Environment.getExternalStorageDirectory(),
- ImageLoader.DEFAULT_SAVE_DIRECTORY);
- }
- // Create the directory if it doesn't exist
- if (!saveDirectory.exists())
- saveDirectory.mkdirs();
- return saveDirectory;
- }
-
- public static File getNewFile(Context context, Uri sourceUri) {
- File saveDirectory = getFinalSaveDirectory(context, sourceUri);
- String filename = new SimpleDateFormat(TIME_STAMP_NAME).format(new Date());
- return new File(saveDirectory, filename + ".JPG");
- }
-
- public Object getPanoramaXMPData(Uri source, ImagePreset preset) {
- Object xmp = null;
- if (preset.isPanoramaSafe()) {
- InputStream is = null;
- try {
- is = context.getContentResolver().openInputStream(source);
- xmp = XmpUtilHelper.extractXMPMeta(is);
- } catch (FileNotFoundException e) {
- Log.w(LOGTAG, "Failed to get XMP data from image: ", e);
- } finally {
- Utils.closeSilently(is);
- }
- }
- return xmp;
- }
-
- public boolean putPanoramaXMPData(File file, Object xmp) {
- if (xmp != null) {
- return XmpUtilHelper.writeXMPMeta(file.getAbsolutePath(), xmp);
- }
- return false;
- }
-
- public ExifInterface getExifData(Uri source) {
- ExifInterface exif = new ExifInterface();
- String mimeType = context.getContentResolver().getType(sourceUri);
- if (mimeType.equals(ImageLoader.JPEG_MIME_TYPE)) {
- InputStream inStream = null;
- try {
- inStream = context.getContentResolver().openInputStream(source);
- exif.readExif(inStream);
- } catch (FileNotFoundException e) {
- Log.w(LOGTAG, "Cannot find file: " + source, e);
- } catch (IOException e) {
- Log.w(LOGTAG, "Cannot read exif for: " + source, e);
- } finally {
- Utils.closeSilently(inStream);
- }
- }
- return exif;
- }
-
- public boolean putExifData(File file, ExifInterface exif, Bitmap image) {
- boolean ret = false;
- try {
- exif.writeExif(image, file.getAbsolutePath());
- ret = true;
- } catch (FileNotFoundException e) {
- Log.w(LOGTAG, "File not found: " + file.getAbsolutePath(), e);
- } catch (IOException e) {
- Log.w(LOGTAG, "Could not write exif: ", e);
- }
- return ret;
- }
-
- /**
- * The task should be executed with one given bitmap to be saved.
- */
- @Override
- protected Uri doInBackground(ImagePreset... params) {
- // TODO: Support larger dimensions for photo saving.
- if (params[0] == null || sourceUri == null) {
- return null;
- }
- ImagePreset preset = params[0];
- BitmapFactory.Options options = new BitmapFactory.Options();
- Uri uri = null;
- boolean noBitmap = true;
- int num_tries = 0;
- // Stopgap fix for low-memory devices.
- while (noBitmap) {
- try {
- // Try to do bitmap operations, downsample if low-memory
- Bitmap bitmap = ImageLoader.loadMutableBitmap(context, sourceUri, options);
- if (bitmap == null) {
- return null;
- }
- CachingPipeline pipeline = new CachingPipeline(FiltersManager.getManager(), "Saving");
- bitmap = pipeline.renderFinalImage(bitmap, preset);
-
- Object xmp = getPanoramaXMPData(sourceUri, preset);
- ExifInterface exif = getExifData(sourceUri);
-
- // Set tags
- long time = System.currentTimeMillis();
- exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, time,
- TimeZone.getDefault());
- exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION,
- ExifInterface.Orientation.TOP_LEFT));
-
- // Remove old thumbnail
- exif.removeCompressedThumbnail();
-
- // If we succeed in writing the bitmap as a jpeg, return a uri.
- if (putExifData(this.destinationFile, exif, bitmap)) {
- putPanoramaXMPData(this.destinationFile, xmp);
- uri = insertContent(context, sourceUri, this.destinationFile, saveFileName,
- time);
- }
- noBitmap = false;
- } catch (java.lang.OutOfMemoryError e) {
- // Try 5 times before failing for good.
- if (++num_tries >= 5) {
- throw e;
- }
- System.gc();
- options.inSampleSize *= 2;
- }
- }
- return uri;
- }
-
- @Override
- protected void onPostExecute(Uri result) {
- if (callback != null) {
- callback.onComplete(result);
- }
- }
-
- private static void querySource(Context context, Uri sourceUri, String[] projection,
- ContentResolverQueryCallback callback) {
- ContentResolver contentResolver = context.getContentResolver();
- Cursor cursor = null;
- try {
- cursor = contentResolver.query(sourceUri, projection, null, null,
- null);
- if ((cursor != null) && cursor.moveToNext()) {
- callback.onCursorResult(cursor);
- }
- } catch (Exception e) {
- // Ignore error for lacking the data column from the source.
- } finally {
- if (cursor != null) {
- cursor.close();
- }
- }
- }
-
- private static File getSaveDirectory(Context context, Uri sourceUri) {
- final File[] dir = new File[1];
- querySource(context, sourceUri, new String[] {
- ImageColumns.DATA
- },
- new ContentResolverQueryCallback() {
-
- @Override
- public void onCursorResult(Cursor cursor) {
- dir[0] = new File(cursor.getString(0)).getParentFile();
- }
- });
- return dir[0];
- }
-
- /**
- * Insert the content (saved file) with proper source photo properties.
- */
- public static Uri insertContent(Context context, Uri sourceUri, File file, String saveFileName,
- long time) {
- time /= 1000;
-
- final ContentValues values = new ContentValues();
- values.put(Images.Media.TITLE, saveFileName);
- values.put(Images.Media.DISPLAY_NAME, file.getName());
- values.put(Images.Media.MIME_TYPE, "image/jpeg");
- values.put(Images.Media.DATE_TAKEN, time);
- values.put(Images.Media.DATE_MODIFIED, time);
- values.put(Images.Media.DATE_ADDED, time);
- values.put(Images.Media.ORIENTATION, 0);
- values.put(Images.Media.DATA, file.getAbsolutePath());
- values.put(Images.Media.SIZE, file.length());
-
- final String[] projection = new String[] {
- ImageColumns.DATE_TAKEN,
- ImageColumns.LATITUDE, ImageColumns.LONGITUDE,
- };
- querySource(context, sourceUri, projection,
- new ContentResolverQueryCallback() {
-
- @Override
- public void onCursorResult(Cursor cursor) {
- values.put(Images.Media.DATE_TAKEN, cursor.getLong(0));
-
- double latitude = cursor.getDouble(1);
- double longitude = cursor.getDouble(2);
- // TODO: Change || to && after the default location
- // issue is fixed.
- if ((latitude != 0f) || (longitude != 0f)) {
- values.put(Images.Media.LATITUDE, latitude);
- values.put(Images.Media.LONGITUDE, longitude);
- }
- }
- });
-
- return context.getContentResolver().insert(
- Images.Media.EXTERNAL_CONTENT_URI, values);
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/tools/SaveImage.java b/src/com/android/gallery3d/filtershow/tools/SaveImage.java
new file mode 100644
index 0000000..354081e
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/tools/SaveImage.java
@@ -0,0 +1,743 @@
+/*
+ * Copyright (C) 2010 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.tools;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.Environment;
+import android.provider.MediaStore;
+import android.provider.MediaStore.Images;
+import android.provider.MediaStore.Images.ImageColumns;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.exif.ExifInterface;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.CachingPipeline;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.ProcessingService;
+import com.android.gallery3d.util.XmpUtilHelper;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.sql.Date;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+/**
+ * Handles saving edited photo
+ */
+public class SaveImage {
+ private static final String LOGTAG = "SaveImage";
+
+ /**
+ * Callback for updates
+ */
+ public interface Callback {
+ void onPreviewSaved(Uri uri);
+ void onProgress(int max, int current);
+ }
+
+ public interface ContentResolverQueryCallback {
+ void onCursorResult(Cursor cursor);
+ }
+
+ private static final String TIME_STAMP_NAME = "_yyyyMMdd_HHmmss";
+ private static final String PREFIX_PANO = "PANO";
+ private static final String PREFIX_IMG = "IMG";
+ private static final String POSTFIX_JPG = ".jpg";
+ private static final String AUX_DIR_NAME = ".aux";
+
+ private final Context mContext;
+ private final Uri mSourceUri;
+ private final Callback mCallback;
+ private final File mDestinationFile;
+ private final Uri mSelectedImageUri;
+ private final Bitmap mPreviewImage;
+
+ private int mCurrentProcessingStep = 1;
+
+ public static final int MAX_PROCESSING_STEPS = 6;
+ public static final String DEFAULT_SAVE_DIRECTORY = "EditedOnlinePhotos";
+
+ // In order to support the new edit-save behavior such that user won't see
+ // the edited image together with the original image, we are adding a new
+ // auxiliary directory for the edited image. Basically, the original image
+ // will be hidden in that directory after edit and user will see the edited
+ // image only.
+ // Note that deletion on the edited image will also cause the deletion of
+ // the original image under auxiliary directory.
+ //
+ // There are several situations we need to consider:
+ // 1. User edit local image local01.jpg. A local02.jpg will be created in the
+ // same directory, and original image will be moved to auxiliary directory as
+ // ./.aux/local02.jpg.
+ // If user edit the local02.jpg, local03.jpg will be created in the local
+ // directory and ./.aux/local02.jpg will be renamed to ./.aux/local03.jpg
+ //
+ // 2. User edit remote image remote01.jpg from picassa or other server.
+ // remoteSavedLocal01.jpg will be saved under proper local directory.
+ // In remoteSavedLocal01.jpg, there will be a reference pointing to the
+ // remote01.jpg. There will be no local copy of remote01.jpg.
+ // If user edit remoteSavedLocal01.jpg, then a new remoteSavedLocal02.jpg
+ // will be generated and still pointing to the remote01.jpg
+ //
+ // 3. User delete any local image local.jpg.
+ // Since the filenames are kept consistent in auxiliary directory, every
+ // time a local.jpg get deleted, the files in auxiliary directory whose
+ // names starting with "local." will be deleted.
+ // This pattern will facilitate the multiple images deletion in the auxiliary
+ // directory.
+
+ /**
+ * @param context
+ * @param sourceUri The Uri for the original image, which can be the hidden
+ * image under the auxiliary directory or the same as selectedImageUri.
+ * @param selectedImageUri The Uri for the image selected by the user.
+ * In most cases, it is a content Uri for local image or remote image.
+ * @param destination Destinaton File, if this is null, a new file will be
+ * created under the same directory as selectedImageUri.
+ * @param callback Let the caller know the saving has completed.
+ * @return the newSourceUri
+ */
+ public SaveImage(Context context, Uri sourceUri, Uri selectedImageUri,
+ File destination, Bitmap previewImage, Callback callback) {
+ mContext = context;
+ mSourceUri = sourceUri;
+ mCallback = callback;
+ mPreviewImage = previewImage;
+ if (destination == null) {
+ mDestinationFile = getNewFile(context, selectedImageUri);
+ } else {
+ mDestinationFile = destination;
+ }
+
+ mSelectedImageUri = selectedImageUri;
+ }
+
+ public static File getFinalSaveDirectory(Context context, Uri sourceUri) {
+ File saveDirectory = SaveImage.getSaveDirectory(context, sourceUri);
+ if ((saveDirectory == null) || !saveDirectory.canWrite()) {
+ saveDirectory = new File(Environment.getExternalStorageDirectory(),
+ SaveImage.DEFAULT_SAVE_DIRECTORY);
+ }
+ // Create the directory if it doesn't exist
+ if (!saveDirectory.exists())
+ saveDirectory.mkdirs();
+ return saveDirectory;
+ }
+
+ public static File getNewFile(Context context, Uri sourceUri) {
+ File saveDirectory = getFinalSaveDirectory(context, sourceUri);
+ String filename = new SimpleDateFormat(TIME_STAMP_NAME).format(new Date(
+ System.currentTimeMillis()));
+ if (hasPanoPrefix(context, sourceUri)) {
+ return new File(saveDirectory, PREFIX_PANO + filename + POSTFIX_JPG);
+ }
+ return new File(saveDirectory, PREFIX_IMG + filename + POSTFIX_JPG);
+ }
+
+ /**
+ * Remove the files in the auxiliary directory whose names are the same as
+ * the source image.
+ * @param contentResolver The application's contentResolver
+ * @param srcContentUri The content Uri for the source image.
+ */
+ public static void deleteAuxFiles(ContentResolver contentResolver,
+ Uri srcContentUri) {
+ final String[] fullPath = new String[1];
+ String[] queryProjection = new String[] { ImageColumns.DATA };
+ querySourceFromContentResolver(contentResolver,
+ srcContentUri, queryProjection,
+ new ContentResolverQueryCallback() {
+ @Override
+ public void onCursorResult(Cursor cursor) {
+ fullPath[0] = cursor.getString(0);
+ }
+ }
+ );
+ if (fullPath[0] != null) {
+ // Construct the auxiliary directory given the source file's path.
+ // Then select and delete all the files starting with the same name
+ // under the auxiliary directory.
+ File currentFile = new File(fullPath[0]);
+
+ String filename = currentFile.getName();
+ int firstDotPos = filename.indexOf(".");
+ final String filenameNoExt = (firstDotPos == -1) ? filename :
+ filename.substring(0, firstDotPos);
+ File auxDir = getLocalAuxDirectory(currentFile);
+ if (auxDir.exists()) {
+ FilenameFilter filter = new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ if (name.startsWith(filenameNoExt + ".")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ };
+
+ // Delete all auxiliary files whose name is matching the
+ // current local image.
+ File[] auxFiles = auxDir.listFiles(filter);
+ for (File file : auxFiles) {
+ file.delete();
+ }
+ }
+ }
+ }
+
+ public Object getPanoramaXMPData(Uri source, ImagePreset preset) {
+ Object xmp = null;
+ if (preset.isPanoramaSafe()) {
+ InputStream is = null;
+ try {
+ is = mContext.getContentResolver().openInputStream(source);
+ xmp = XmpUtilHelper.extractXMPMeta(is);
+ } catch (FileNotFoundException e) {
+ Log.w(LOGTAG, "Failed to get XMP data from image: ", e);
+ } finally {
+ Utils.closeSilently(is);
+ }
+ }
+ return xmp;
+ }
+
+ public boolean putPanoramaXMPData(File file, Object xmp) {
+ if (xmp != null) {
+ return XmpUtilHelper.writeXMPMeta(file.getAbsolutePath(), xmp);
+ }
+ return false;
+ }
+
+ public ExifInterface getExifData(Uri source) {
+ ExifInterface exif = new ExifInterface();
+ String mimeType = mContext.getContentResolver().getType(mSelectedImageUri);
+ if (mimeType == null) {
+ mimeType = ImageLoader.getMimeType(mSelectedImageUri);
+ }
+ if (mimeType.equals(ImageLoader.JPEG_MIME_TYPE)) {
+ InputStream inStream = null;
+ try {
+ inStream = mContext.getContentResolver().openInputStream(source);
+ exif.readExif(inStream);
+ } catch (FileNotFoundException e) {
+ Log.w(LOGTAG, "Cannot find file: " + source, e);
+ } catch (IOException e) {
+ Log.w(LOGTAG, "Cannot read exif for: " + source, e);
+ } finally {
+ Utils.closeSilently(inStream);
+ }
+ }
+ return exif;
+ }
+
+ public boolean putExifData(File file, ExifInterface exif, Bitmap image,
+ int jpegCompressQuality) {
+ boolean ret = false;
+ OutputStream s = null;
+ try {
+ s = exif.getExifWriterStream(file.getAbsolutePath());
+ image.compress(Bitmap.CompressFormat.JPEG,
+ (jpegCompressQuality > 0) ? jpegCompressQuality : 1, s);
+ s.flush();
+ s.close();
+ s = null;
+ ret = true;
+ } catch (FileNotFoundException e) {
+ Log.w(LOGTAG, "File not found: " + file.getAbsolutePath(), e);
+ } catch (IOException e) {
+ Log.w(LOGTAG, "Could not write exif: ", e);
+ } finally {
+ Utils.closeSilently(s);
+ }
+ return ret;
+ }
+
+ private Uri resetToOriginalImageIfNeeded(ImagePreset preset, boolean doAuxBackup) {
+ Uri uri = null;
+ if (!preset.hasModifications()) {
+ // This can happen only when preset has no modification but save
+ // button is enabled, it means the file is loaded with filters in
+ // the XMP, then all the filters are removed or restore to default.
+ // In this case, when mSourceUri exists, rename it to the
+ // destination file.
+ File srcFile = getLocalFileFromUri(mContext, mSourceUri);
+ // If the source is not a local file, then skip this renaming and
+ // create a local copy as usual.
+ if (srcFile != null) {
+ srcFile.renameTo(mDestinationFile);
+ uri = SaveImage.linkNewFileToUri(mContext, mSelectedImageUri,
+ mDestinationFile, System.currentTimeMillis(), doAuxBackup);
+ }
+ }
+ return uri;
+ }
+
+ private void resetProgress() {
+ mCurrentProcessingStep = 0;
+ }
+
+ private void updateProgress() {
+ if (mCallback != null) {
+ mCallback.onProgress(MAX_PROCESSING_STEPS, ++mCurrentProcessingStep);
+ }
+ }
+
+ private void updateExifData(ExifInterface exif, long time) {
+ // Set tags
+ exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, time,
+ TimeZone.getDefault());
+ exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION,
+ ExifInterface.Orientation.TOP_LEFT));
+ // Remove old thumbnail
+ exif.removeCompressedThumbnail();
+ }
+
+ public Uri processAndSaveImage(ImagePreset preset, boolean flatten,
+ int quality, float sizeFactor, boolean exit) {
+
+ Uri uri = null;
+ if (exit) {
+ uri = resetToOriginalImageIfNeeded(preset, !flatten);
+ }
+ if (uri != null) {
+ return null;
+ }
+
+ resetProgress();
+
+ boolean noBitmap = true;
+ int num_tries = 0;
+ int sampleSize = 1;
+
+ // If necessary, move the source file into the auxiliary directory,
+ // newSourceUri is then pointing to the new location.
+ // If no file is moved, newSourceUri will be the same as mSourceUri.
+ Uri newSourceUri = mSourceUri;
+ if (!flatten) {
+ newSourceUri = moveSrcToAuxIfNeeded(mSourceUri, mDestinationFile);
+ }
+
+ Uri savedUri = mSelectedImageUri;
+ if (mPreviewImage != null) {
+ if (flatten) {
+ Object xmp = getPanoramaXMPData(newSourceUri, preset);
+ ExifInterface exif = getExifData(newSourceUri);
+ long time = System.currentTimeMillis();
+ updateExifData(exif, time);
+ if (putExifData(mDestinationFile, exif, mPreviewImage, quality)) {
+ putPanoramaXMPData(mDestinationFile, xmp);
+ ContentValues values = getContentValues(mContext, mSelectedImageUri, mDestinationFile, time);
+ Object result = mContext.getContentResolver().insert(
+ Images.Media.EXTERNAL_CONTENT_URI, values);
+
+ }
+ } else {
+ Object xmp = getPanoramaXMPData(newSourceUri, preset);
+ ExifInterface exif = getExifData(newSourceUri);
+ long time = System.currentTimeMillis();
+ updateExifData(exif, time);
+ // If we succeed in writing the bitmap as a jpeg, return a uri.
+ if (putExifData(mDestinationFile, exif, mPreviewImage, quality)) {
+ putPanoramaXMPData(mDestinationFile, xmp);
+ // mDestinationFile will save the newSourceUri info in the XMP.
+ if (!flatten) {
+ XmpPresets.writeFilterXMP(mContext, newSourceUri,
+ mDestinationFile, preset);
+ }
+ // After this call, mSelectedImageUri will be actually
+ // pointing at the new file mDestinationFile.
+ savedUri = SaveImage.linkNewFileToUri(mContext, mSelectedImageUri,
+ mDestinationFile, time, !flatten);
+ }
+ }
+ if (mCallback != null) {
+ mCallback.onPreviewSaved(savedUri);
+ }
+ }
+
+ // Stopgap fix for low-memory devices.
+ while (noBitmap) {
+ try {
+ updateProgress();
+ // Try to do bitmap operations, downsample if low-memory
+ Bitmap bitmap = ImageLoader.loadOrientedBitmapWithBackouts(mContext, newSourceUri,
+ sampleSize);
+ if (bitmap == null) {
+ return null;
+ }
+ if (sizeFactor != 1f) {
+ // if we have a valid size
+ int w = (int) (bitmap.getWidth() * sizeFactor);
+ int h = (int) (bitmap.getHeight() * sizeFactor);
+ bitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
+ }
+ updateProgress();
+ CachingPipeline pipeline = new CachingPipeline(FiltersManager.getManager(),
+ "Saving");
+
+ bitmap = pipeline.renderFinalImage(bitmap, preset);
+ updateProgress();
+
+ Object xmp = getPanoramaXMPData(newSourceUri, preset);
+ ExifInterface exif = getExifData(newSourceUri);
+ long time = System.currentTimeMillis();
+ updateProgress();
+
+ updateExifData(exif, time);
+ updateProgress();
+
+ // If we succeed in writing the bitmap as a jpeg, return a uri.
+ if (putExifData(mDestinationFile, exif, bitmap, quality)) {
+ putPanoramaXMPData(mDestinationFile, xmp);
+ // mDestinationFile will save the newSourceUri info in the XMP.
+ if (!flatten) {
+ XmpPresets.writeFilterXMP(mContext, newSourceUri,
+ mDestinationFile, preset);
+ uri = updateFile(mContext, savedUri, mDestinationFile, time);
+
+ } else {
+
+ ContentValues values = getContentValues(mContext, mSelectedImageUri, mDestinationFile, time);
+ Object result = mContext.getContentResolver().insert(
+ Images.Media.EXTERNAL_CONTENT_URI, values);
+ }
+ }
+ updateProgress();
+
+ noBitmap = false;
+ } catch (OutOfMemoryError e) {
+ // Try 5 times before failing for good.
+ if (++num_tries >= 5) {
+ throw e;
+ }
+ System.gc();
+ sampleSize *= 2;
+ resetProgress();
+ }
+ }
+ return uri;
+ }
+
+ /**
+ * Move the source file to auxiliary directory if needed and return the Uri
+ * pointing to this new source file. If any file error happens, then just
+ * don't move into the auxiliary directory.
+ * @param srcUri Uri to the source image.
+ * @param dstFile Providing the destination file info to help to build the
+ * auxiliary directory and new source file's name.
+ * @return the newSourceUri pointing to the new source image.
+ */
+ private Uri moveSrcToAuxIfNeeded(Uri srcUri, File dstFile) {
+ File srcFile = getLocalFileFromUri(mContext, srcUri);
+ if (srcFile == null) {
+ Log.d(LOGTAG, "Source file is not a local file, no update.");
+ return srcUri;
+ }
+
+ // Get the destination directory and create the auxilliary directory
+ // if necessary.
+ File auxDiretory = getLocalAuxDirectory(dstFile);
+ if (!auxDiretory.exists()) {
+ boolean success = auxDiretory.mkdirs();
+ if (!success) {
+ return srcUri;
+ }
+ }
+
+ // Make sure there is a .nomedia file in the auxiliary directory, such
+ // that MediaScanner will not report those files under this directory.
+ File noMedia = new File(auxDiretory, ".nomedia");
+ if (!noMedia.exists()) {
+ try {
+ noMedia.createNewFile();
+ } catch (IOException e) {
+ Log.e(LOGTAG, "Can't create the nomedia");
+ return srcUri;
+ }
+ }
+ // We are using the destination file name such that photos sitting in
+ // the auxiliary directory are matching the parent directory.
+ File newSrcFile = new File(auxDiretory, dstFile.getName());
+ // Maintain the suffix during move
+ String to = newSrcFile.getName();
+ String from = srcFile.getName();
+ to = to.substring(to.lastIndexOf("."));
+ from = from.substring(from.lastIndexOf("."));
+
+ if (!to.equals(from)) {
+ String name = dstFile.getName();
+ name = name.substring(0, name.lastIndexOf(".")) + from;
+ newSrcFile = new File(auxDiretory, name);
+ }
+
+ if (!newSrcFile.exists()) {
+ boolean success = srcFile.renameTo(newSrcFile);
+ if (!success) {
+ return srcUri;
+ }
+ }
+
+ return Uri.fromFile(newSrcFile);
+
+ }
+
+ private static File getLocalAuxDirectory(File dstFile) {
+ File dstDirectory = dstFile.getParentFile();
+ File auxDiretory = new File(dstDirectory + "/" + AUX_DIR_NAME);
+ return auxDiretory;
+ }
+
+ public static Uri makeAndInsertUri(Context context, Uri sourceUri) {
+ long time = System.currentTimeMillis();
+ String filename = new SimpleDateFormat(TIME_STAMP_NAME).format(new Date(time));
+ File saveDirectory = getFinalSaveDirectory(context, sourceUri);
+ File file = new File(saveDirectory, filename + ".JPG");
+ return linkNewFileToUri(context, sourceUri, file, time, false);
+ }
+
+ public static void saveImage(ImagePreset preset, final FilterShowActivity filterShowActivity,
+ File destination) {
+ Uri selectedImageUri = filterShowActivity.getSelectedImageUri();
+ Uri sourceImageUri = MasterImage.getImage().getUri();
+ boolean flatten = false;
+ if (preset.contains(FilterRepresentation.TYPE_TINYPLANET)){
+ flatten = true;
+ }
+ Intent processIntent = ProcessingService.getSaveIntent(filterShowActivity, preset,
+ destination, selectedImageUri, sourceImageUri, flatten, 90, 1f, true);
+
+ filterShowActivity.startService(processIntent);
+
+ if (!filterShowActivity.isSimpleEditAction()) {
+ String toastMessage = filterShowActivity.getResources().getString(
+ R.string.save_and_processing);
+ Toast.makeText(filterShowActivity,
+ toastMessage,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ public static void querySource(Context context, Uri sourceUri, String[] projection,
+ ContentResolverQueryCallback callback) {
+ ContentResolver contentResolver = context.getContentResolver();
+ querySourceFromContentResolver(contentResolver, sourceUri, projection, callback);
+ }
+
+ private static void querySourceFromContentResolver(
+ ContentResolver contentResolver, Uri sourceUri, String[] projection,
+ ContentResolverQueryCallback callback) {
+ Cursor cursor = null;
+ try {
+ cursor = contentResolver.query(sourceUri, projection, null, null,
+ null);
+ if ((cursor != null) && cursor.moveToNext()) {
+ callback.onCursorResult(cursor);
+ }
+ } catch (Exception e) {
+ // Ignore error for lacking the data column from the source.
+ } finally {
+ if (cursor != null) {
+ cursor.close();
+ }
+ }
+ }
+
+ private static File getSaveDirectory(Context context, Uri sourceUri) {
+ File file = getLocalFileFromUri(context, sourceUri);
+ if (file != null) {
+ return file.getParentFile();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Construct a File object based on the srcUri.
+ * @return The file object. Return null if srcUri is invalid or not a local
+ * file.
+ */
+ private static File getLocalFileFromUri(Context context, Uri srcUri) {
+ if (srcUri == null) {
+ Log.e(LOGTAG, "srcUri is null.");
+ return null;
+ }
+
+ String scheme = srcUri.getScheme();
+ if (scheme == null) {
+ Log.e(LOGTAG, "scheme is null.");
+ return null;
+ }
+
+ final File[] file = new File[1];
+ // sourceUri can be a file path or a content Uri, it need to be handled
+ // differently.
+ if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
+ if (srcUri.getAuthority().equals(MediaStore.AUTHORITY)) {
+ querySource(context, srcUri, new String[] {
+ ImageColumns.DATA
+ },
+ new ContentResolverQueryCallback() {
+
+ @Override
+ public void onCursorResult(Cursor cursor) {
+ file[0] = new File(cursor.getString(0));
+ }
+ });
+ }
+ } else if (scheme.equals(ContentResolver.SCHEME_FILE)) {
+ file[0] = new File(srcUri.getPath());
+ }
+ return file[0];
+ }
+
+ /**
+ * Gets the actual filename for a Uri from Gallery's ContentProvider.
+ */
+ private static String getTrueFilename(Context context, Uri src) {
+ if (context == null || src == null) {
+ return null;
+ }
+ final String[] trueName = new String[1];
+ querySource(context, src, new String[] {
+ ImageColumns.DATA
+ }, new ContentResolverQueryCallback() {
+ @Override
+ public void onCursorResult(Cursor cursor) {
+ trueName[0] = new File(cursor.getString(0)).getName();
+ }
+ });
+ return trueName[0];
+ }
+
+ /**
+ * Checks whether the true filename has the panorama image prefix.
+ */
+ private static boolean hasPanoPrefix(Context context, Uri src) {
+ String name = getTrueFilename(context, src);
+ return name != null && name.startsWith(PREFIX_PANO);
+ }
+
+ /**
+ * If the <code>sourceUri</code> is a local content Uri, update the
+ * <code>sourceUri</code> to point to the <code>file</code>.
+ * At the same time, the old file <code>sourceUri</code> used to point to
+ * will be removed if it is local.
+ * If the <code>sourceUri</code> is not a local content Uri, then the
+ * <code>file</code> will be inserted as a new content Uri.
+ * @return the final Uri referring to the <code>file</code>.
+ */
+ public static Uri linkNewFileToUri(Context context, Uri sourceUri,
+ File file, long time, boolean deleteOriginal) {
+ File oldSelectedFile = getLocalFileFromUri(context, sourceUri);
+ final ContentValues values = getContentValues(context, sourceUri, file, time);
+
+ Uri result = sourceUri;
+
+ // In the case of incoming Uri is just a local file Uri (like a cached
+ // file), we can't just update the Uri. We have to create a new Uri.
+ boolean fileUri = isFileUri(sourceUri);
+
+ if (fileUri || oldSelectedFile == null || !deleteOriginal) {
+ result = context.getContentResolver().insert(
+ Images.Media.EXTERNAL_CONTENT_URI, values);
+ } else {
+ context.getContentResolver().update(sourceUri, values, null, null);
+ if (oldSelectedFile.exists()) {
+ oldSelectedFile.delete();
+ }
+ }
+ return result;
+ }
+
+ public static Uri updateFile(Context context, Uri sourceUri, File file, long time) {
+ final ContentValues values = getContentValues(context, sourceUri, file, time);
+ context.getContentResolver().update(sourceUri, values, null, null);
+ return sourceUri;
+ }
+
+ private static ContentValues getContentValues(Context context, Uri sourceUri,
+ File file, long time) {
+ final ContentValues values = new ContentValues();
+
+ time /= 1000;
+ values.put(Images.Media.TITLE, file.getName());
+ values.put(Images.Media.DISPLAY_NAME, file.getName());
+ values.put(Images.Media.MIME_TYPE, "image/jpeg");
+ values.put(Images.Media.DATE_TAKEN, time);
+ values.put(Images.Media.DATE_MODIFIED, time);
+ values.put(Images.Media.DATE_ADDED, time);
+ values.put(Images.Media.ORIENTATION, 0);
+ values.put(Images.Media.DATA, file.getAbsolutePath());
+ values.put(Images.Media.SIZE, file.length());
+
+ final String[] projection = new String[] {
+ ImageColumns.DATE_TAKEN,
+ ImageColumns.LATITUDE, ImageColumns.LONGITUDE,
+ };
+
+ SaveImage.querySource(context, sourceUri, projection,
+ new ContentResolverQueryCallback() {
+
+ @Override
+ public void onCursorResult(Cursor cursor) {
+ values.put(Images.Media.DATE_TAKEN, cursor.getLong(0));
+
+ double latitude = cursor.getDouble(1);
+ double longitude = cursor.getDouble(2);
+ // TODO: Change || to && after the default location
+ // issue is fixed.
+ if ((latitude != 0f) || (longitude != 0f)) {
+ values.put(Images.Media.LATITUDE, latitude);
+ values.put(Images.Media.LONGITUDE, longitude);
+ }
+ }
+ });
+ return values;
+ }
+
+ /**
+ * @param sourceUri
+ * @return true if the sourceUri is a local file Uri.
+ */
+ private static boolean isFileUri(Uri sourceUri) {
+ String scheme = sourceUri.getScheme();
+ if (scheme != null && scheme.equals(ContentResolver.SCHEME_FILE)) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/tools/XmpPresets.java b/src/com/android/gallery3d/filtershow/tools/XmpPresets.java
new file mode 100644
index 0000000..7095e74
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/tools/XmpPresets.java
@@ -0,0 +1,134 @@
+/*
+ * 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.tools;
+
+import android.content.Context;
+import android.net.Uri;
+import android.util.Log;
+
+import com.adobe.xmp.XMPException;
+import com.adobe.xmp.XMPMeta;
+import com.adobe.xmp.XMPMetaFactory;
+import com.android.gallery3d.R;
+import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+import com.android.gallery3d.util.XmpUtilHelper;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+public class XmpPresets {
+ public static final String
+ XMP_GOOGLE_FILTER_NAMESPACE = "http://ns.google.com/photos/1.0/filter/";
+ public static final String XMP_GOOGLE_FILTER_PREFIX = "AFltr";
+ public static final String XMP_SRC_FILE_URI = "SourceFileUri";
+ public static final String XMP_FILTERSTACK = "filterstack";
+
+ private static final String LOGTAG = "XmpPresets";
+
+ public static class XMresults {
+ public String presetString;
+ public ImagePreset preset;
+ public Uri originalimage;
+ }
+
+ static {
+ try {
+ XMPMetaFactory.getSchemaRegistry().registerNamespace(
+ XMP_GOOGLE_FILTER_NAMESPACE, XMP_GOOGLE_FILTER_PREFIX);
+ } catch (XMPException e) {
+ Log.e(LOGTAG, "Register XMP name space failed", e);
+ }
+ }
+
+ public static void writeFilterXMP(
+ Context context, Uri srcUri, File dstFile, ImagePreset preset) {
+ InputStream is = null;
+ XMPMeta xmpMeta = null;
+ try {
+ is = context.getContentResolver().openInputStream(srcUri);
+ xmpMeta = XmpUtilHelper.extractXMPMeta(is);
+ } catch (FileNotFoundException e) {
+
+ } finally {
+ Utils.closeSilently(is);
+ }
+
+ if (xmpMeta == null) {
+ xmpMeta = XMPMetaFactory.create();
+ }
+ try {
+ xmpMeta.setProperty(XMP_GOOGLE_FILTER_NAMESPACE,
+ XMP_SRC_FILE_URI, srcUri.toString());
+ xmpMeta.setProperty(XMP_GOOGLE_FILTER_NAMESPACE,
+ XMP_FILTERSTACK, preset.getJsonString(ImagePreset.JASON_SAVED));
+ } catch (XMPException e) {
+ Log.v(LOGTAG, "Write XMP meta to file failed:" + dstFile.getAbsolutePath());
+ return;
+ }
+
+ if (!XmpUtilHelper.writeXMPMeta(dstFile.getAbsolutePath(), xmpMeta)) {
+ Log.v(LOGTAG, "Write XMP meta to file failed:" + dstFile.getAbsolutePath());
+ }
+ }
+
+ public static XMresults extractXMPData(
+ Context context, MasterImage mMasterImage, Uri uriToEdit) {
+ XMresults ret = new XMresults();
+
+ InputStream is = null;
+ XMPMeta xmpMeta = null;
+ try {
+ is = context.getContentResolver().openInputStream(uriToEdit);
+ xmpMeta = XmpUtilHelper.extractXMPMeta(is);
+ } catch (FileNotFoundException e) {
+ } finally {
+ Utils.closeSilently(is);
+ }
+
+ if (xmpMeta == null) {
+ return null;
+ }
+
+ try {
+ String strSrcUri = xmpMeta.getPropertyString(XMP_GOOGLE_FILTER_NAMESPACE,
+ XMP_SRC_FILE_URI);
+
+ if (strSrcUri != null) {
+ String filterString = xmpMeta.getPropertyString(XMP_GOOGLE_FILTER_NAMESPACE,
+ XMP_FILTERSTACK);
+
+ Uri srcUri = Uri.parse(strSrcUri);
+ ret.originalimage = srcUri;
+
+ ret.preset = new ImagePreset();
+ ret.presetString = filterString;
+ boolean ok = ret.preset.readJsonFromString(filterString);
+ if (!ok) {
+ return null;
+ }
+ return ret;
+ }
+ } catch (XMPException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/ui/ControlPoint.java b/src/com/android/gallery3d/filtershow/ui/ControlPoint.java
deleted file mode 100644
index 73589d3..0000000
--- a/src/com/android/gallery3d/filtershow/ui/ControlPoint.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.ui;
-
-public class ControlPoint implements Comparable {
- public float x;
- public float y;
-
- public ControlPoint(float px, float py) {
- x = px;
- y = py;
- }
-
- public ControlPoint(ControlPoint point) {
- x = point.x;
- y = point.y;
- }
-
- public ControlPoint copy() {
- return new ControlPoint(x, y);
- }
-
- @Override
- public int compareTo(Object another) {
- ControlPoint p = (ControlPoint) another;
- if (p.x < x) {
- return 1;
- } else if (p.x > x) {
- return -1;
- }
- return 0;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/ui/ExportDialog.java b/src/com/android/gallery3d/filtershow/ui/ExportDialog.java
new file mode 100644
index 0000000..f6a84ce
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/ui/ExportDialog.java
@@ -0,0 +1,240 @@
+/*
+ * 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.ui;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.app.DialogFragment;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
+import com.android.gallery3d.filtershow.pipeline.ProcessingService;
+import com.android.gallery3d.filtershow.tools.SaveImage;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+
+public class ExportDialog extends DialogFragment implements View.OnClickListener,
+ SeekBar.OnSeekBarChangeListener {
+ SeekBar mSeekBar;
+ TextView mSeekVal;
+ EditText mWidthText;
+ EditText mHeightText;
+ TextView mEstimatedSize;
+ int mQuality = 95;
+ int mExportWidth = 0;
+ int mExportHeight = 0;
+ Rect mOriginalBounds;
+ int mCompressedSize;
+ Rect mCompressedBounds;
+ float mExportCompressionMargin = 1.1f;
+ float mRatio;
+ String mSliderLabel;
+ boolean mEditing = false;
+ Handler mHandler;
+ int mUpdateDelay = 1000;
+ Runnable mUpdateRunnable = new Runnable() {
+ @Override
+ public void run() {
+ updateCompressionFactor();
+ updateSize();
+ }
+ };
+
+ private class Watcher implements TextWatcher {
+ private EditText mEditText;
+ Watcher(EditText text) {
+ mEditText = text;
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ textChanged(mEditText);
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ mHandler = new Handler(getActivity().getMainLooper());
+
+ View view = inflater.inflate(R.layout.filtershow_export_dialog, container);
+ mSeekBar = (SeekBar) view.findViewById(R.id.qualitySeekBar);
+ mSeekVal = (TextView) view.findViewById(R.id.qualityTextView);
+ mSliderLabel = getString(R.string.quality) + ": ";
+ mSeekBar.setProgress(mQuality);
+ mSeekVal.setText(mSliderLabel + mSeekBar.getProgress());
+ mSeekBar.setOnSeekBarChangeListener(this);
+ mWidthText = (EditText) view.findViewById(R.id.editableWidth);
+ mHeightText = (EditText) view.findViewById(R.id.editableHeight);
+ mEstimatedSize = (TextView) view.findViewById(R.id.estimadedSize);
+
+ mOriginalBounds = MasterImage.getImage().getOriginalBounds();
+ ImagePreset preset = MasterImage.getImage().getPreset();
+ mOriginalBounds = preset.finalGeometryRect(mOriginalBounds.width(),
+ mOriginalBounds.height());
+ mRatio = mOriginalBounds.width() / (float) mOriginalBounds.height();
+ mWidthText.setText("" + mOriginalBounds.width());
+ mHeightText.setText("" + mOriginalBounds.height());
+ mExportWidth = mOriginalBounds.width();
+ mExportHeight = mOriginalBounds.height();
+ mWidthText.addTextChangedListener(new Watcher(mWidthText));
+ mHeightText.addTextChangedListener(new Watcher(mHeightText));
+
+ view.findViewById(R.id.cancel).setOnClickListener(this);
+ view.findViewById(R.id.done).setOnClickListener(this);
+ getDialog().setTitle(R.string.export_flattened);
+
+ updateCompressionFactor();
+ updateSize();
+ return view;
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar arg0) {
+ // Do nothing
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar arg0) {
+ // Do nothing
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
+ mSeekVal.setText(mSliderLabel + arg1);
+ mQuality = mSeekBar.getProgress();
+ scheduleUpdateCompressionFactor();
+ }
+
+ private void scheduleUpdateCompressionFactor() {
+ mHandler.removeCallbacks(mUpdateRunnable);
+ mHandler.postDelayed(mUpdateRunnable, mUpdateDelay);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.cancel:
+ dismiss();
+ break;
+ case R.id.done:
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ Uri sourceUri = MasterImage.getImage().getUri();
+ File dest = SaveImage.getNewFile(activity, activity.getSelectedImageUri());
+ float scaleFactor = mExportWidth / (float) mOriginalBounds.width();
+ Intent processIntent = ProcessingService.getSaveIntent(activity, MasterImage
+ .getImage().getPreset(), dest, activity.getSelectedImageUri(), sourceUri,
+ true, mSeekBar.getProgress(), scaleFactor, false);
+ activity.startService(processIntent);
+ dismiss();
+ break;
+ }
+ }
+
+ public void updateCompressionFactor() {
+ Bitmap bitmap = MasterImage.getImage().getFilteredImage();
+ if (bitmap == null) {
+ return;
+ }
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ bitmap.compress(Bitmap.CompressFormat.JPEG, mQuality, out);
+ mCompressedSize = out.size();
+ mCompressedBounds = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
+ }
+
+ public void updateSize() {
+ if (mCompressedBounds == null) {
+ return;
+ }
+ // This is a rough estimate of the final save size. There's some loose correlation
+ // between a compressed jpeg and a larger version of it in function of the image
+ // area. Not a perfect estimate by far.
+ float originalArea = mCompressedBounds.width() * mCompressedBounds.height();
+ float newArea = mExportWidth * mExportHeight;
+ float factor = originalArea / (float) mCompressedSize;
+ float compressedSize = newArea / factor;
+ compressedSize *= mExportCompressionMargin;
+ float size = compressedSize / 1024.f / 1024.f;
+ size = ((int) (size * 100)) / 100f;
+ String estimatedSize = "" + size + " Mb";
+ mEstimatedSize.setText(estimatedSize);
+ }
+
+ private void textChanged(EditText text) {
+ if (mEditing) {
+ return;
+ }
+ mEditing = true;
+ int width = 0;
+ int height = 0;
+ if (text.getId() == R.id.editableWidth) {
+ if (mWidthText.getText() != null) {
+ String value = String.valueOf(mWidthText.getText());
+ if (value.length() > 0) {
+ width = Integer.parseInt(value);
+ if (width > mOriginalBounds.width()) {
+ width = mOriginalBounds.width();
+ mWidthText.setText("" + width);
+ }
+ height = (int) (width / mRatio);
+ }
+ mHeightText.setText("" + height);
+ }
+ } else if (text.getId() == R.id.editableHeight) {
+ if (mHeightText.getText() != null) {
+ String value = String.valueOf(mHeightText.getText());
+ if (value.length() > 0) {
+ height = Integer.parseInt(value);
+ if (height > mOriginalBounds.height()) {
+ height = mOriginalBounds.height();
+ mHeightText.setText("" + height);
+ }
+ width = (int) (height * mRatio);
+ }
+ mWidthText.setText("" + width);
+ }
+ }
+ mExportWidth = width;
+ mExportHeight = height;
+ updateSize();
+ mEditing = false;
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
deleted file mode 100644
index 96126c5..0000000
--- a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.ui;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.cache.RenderingRequest;
-import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
-import com.android.gallery3d.filtershow.category.Action;
-import com.android.gallery3d.filtershow.category.CategoryAdapter;
-import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.imageshow.GeometryListener;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
-import com.android.gallery3d.filtershow.imageshow.MasterImage;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-import com.android.gallery3d.filtershow.tools.IconFactory;
-
-// TODO: merge back IconButton and FilterIconButton?
-public class FilterIconButton extends IconButton implements View.OnClickListener,
- RenderingRequestCaller, GeometryListener {
- private static final String LOGTAG = "FilterIconButton";
- private Bitmap mOverlayBitmap = null;
- private boolean mOverlayOnly = false;
- private FilterRepresentation mFilterRepresentation = null;
- private Bitmap mIconBitmap = null;
- private Action mAction;
- private Paint mSelectPaint;
- private int mSelectStroke;
- private CategoryAdapter mAdapter;
- public FilterIconButton(Context context) {
- super(context);
- }
-
- public FilterIconButton(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public FilterIconButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public void setup(String text, LinearLayout parent, CategoryAdapter adapter) {
- mAdapter = adapter;
- setText(text);
- setContentDescription(text);
- super.setOnClickListener(this);
- Resources res = getContext().getResources();
- MasterImage.getImage().addGeometryListener(this);
- mSelectStroke = res.getDimensionPixelSize(R.dimen.thumbnail_margin);
- mSelectPaint = new Paint();
- mSelectPaint.setStyle(Paint.Style.FILL);
- mSelectPaint.setColor(res.getColor(R.color.filtershow_category_selection));
- invalidate();
- }
-
- @Override
- public void onClick(View v) {
- FilterShowActivity activity = (FilterShowActivity) getContext();
- activity.showRepresentation(mFilterRepresentation);
- mAdapter.setSelected(v);
- }
-
- public FilterRepresentation getFilterRepresentation() {
- return mFilterRepresentation;
- }
-
- public void setAction(Action action) {
- mAction = action;
- if (action == null) {
- return;
- }
- if (mAction.getPortraitImage() != null) {
- mIconBitmap = mAction.getPortraitImage();
- setIcon(mIconBitmap);
- }
- setFilterRepresentation(mAction.getRepresentation());
- }
-
- private void setFilterRepresentation(FilterRepresentation filterRepresentation) {
- mFilterRepresentation = filterRepresentation;
- if (mFilterRepresentation != null && mFilterRepresentation.getOverlayId() != 0) {
- if (mAction.getOverlayBitmap() == null) {
- mOverlayBitmap = BitmapFactory.decodeResource(getResources(),
- mFilterRepresentation.getOverlayId());
- mAction.setOverlayBitmap(mOverlayBitmap);
- } else {
- mOverlayBitmap = mAction.getOverlayBitmap();
- }
- }
- mOverlayOnly = mFilterRepresentation.getOverlayOnly();
- if (mOverlayOnly) {
- assert(mOverlayBitmap != null);
- setIcon(mOverlayBitmap);
- }
- invalidate();
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- if (mIconBitmap == null && !mOverlayOnly) {
- postNewIconRenderRequest();
- } else {
- super.onDraw(canvas);
- }
- if (mAdapter.isSelected(this)) {
- Drawable iconDrawable = getCompoundDrawables()[1];
- if (iconDrawable != null) {
- canvas.save();
- int padding = getCompoundDrawablePadding();
- canvas.translate(getScrollX() + padding + getPaddingLeft() - mSelectStroke - 1,
- getScrollY() + padding + getPaddingTop() - mSelectStroke - 1);
- Rect r = iconDrawable.getBounds();
- SelectionRenderer.drawSelection(canvas, r.left, r.top,
- r.right + 2 * mSelectStroke + 2, r.bottom + 2 * mSelectStroke + 2,
- mSelectStroke, mSelectPaint);
- canvas.restore();
- }
- }
- }
-
- @Override
- public void available(RenderingRequest request) {
- Bitmap bmap = request.getBitmap();
- if (bmap == null) {
- return;
- }
- if (mOverlayOnly) {
- setIcon(mOverlayBitmap);
- } else {
- mIconBitmap = bmap;
- if (mOverlayBitmap != null) {
- // Draw overlay bitmap over icon
- IconFactory.drawIcon(mIconBitmap, mOverlayBitmap, false);
- }
- setIcon(mIconBitmap);
- if (mAction != null) {
- mAction.setPortraitImage(mIconBitmap);
- }
- }
- }
-
- @Override
- public void geometryChanged() {
- if (mOverlayOnly) {
- return;
- }
- mIconBitmap = null;
- invalidate();
- }
-
- private void postNewIconRenderRequest() {
- Bitmap dst = MasterImage.getImage().getThumbnailBitmap();
- if (dst != null && mAction != null) {
- ImagePreset mPreset = new ImagePreset();
- mPreset.addFilter(mFilterRepresentation);
-
- GeometryMetadata geometry = mPreset.mGeoData;
- RectF bound = new RectF(0, 0, dst.getWidth(), dst.getHeight());
- geometry.setCropBounds(bound);
- geometry.setPhotoBounds(bound);
-
- RenderingRequest.post(dst.copy(Bitmap.Config.ARGB_8888, true),
- mPreset, RenderingRequest.ICON_RENDERING, this);
- }
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/ui/IconButton.java b/src/com/android/gallery3d/filtershow/ui/IconButton.java
deleted file mode 100644
index e7087bd..0000000
--- a/src/com/android/gallery3d/filtershow/ui/IconButton.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.ui;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
-import android.util.AttributeSet;
-import android.widget.Button;
-
-import com.android.gallery3d.filtershow.tools.IconFactory;
-import com.android.photos.data.GalleryBitmapPool;
-
-/**
- * Class of buttons with both an image icon and text.
- */
-public class IconButton extends Button {
-
- private Bitmap mImageMirror = null;
- private Bitmap mIcon = null;
-
- private boolean stale_icon = true;
-
- public IconButton(Context context) {
- this(context, null);
- }
-
- public IconButton(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public IconButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- BitmapDrawable ic = (BitmapDrawable) getCompoundDrawables()[1];
-
- if (ic != null) {
- mImageMirror = ic.getBitmap();
- }
- }
-
- /**
- * Set the image that the button icon will use. The image bitmap will be scaled
- * and cropped into the largest bitmap with dimensions given by getGoodIconSideSize()
- * that will fit cleanly within the IconButton's layout.
- *
- * @param image image that icon will be set to before next draw.
- */
- public void setIcon(Bitmap image) {
- mImageMirror = image;
- stale_icon = true;
- invalidate();
- }
-
- /**
- * Finds a side lengths for the icon that fits within the button.
- * Only call after layout. The default implementation returns the best
- * side lengths for a square icon.
- * <p>
- * Override this to make non-square icons or icons with different padding
- * constraints.
- *
- * @return an array of ints representing the icon dimensions [ width, height ]
- */
- protected int[] getGoodIconSideSize() {
- Paint p = getPaint();
- Rect bounds = new Rect();
- // find text bounds
- String s = getText().toString();
- p.getTextBounds(s, 0, s.length(), bounds);
-
- int inner_padding = 2 * getCompoundDrawablePadding();
-
- // find total vertical space available for the icon
- int vert = getHeight() - getPaddingTop() - getPaddingBottom() - bounds.height()
- - inner_padding;
-
- // find total horizontal space available for the icon
- int horiz = getWidth() - getPaddingLeft() - getPaddingRight() - inner_padding;
-
- int defaultSize = Math.min(vert, horiz);
- return new int[] { defaultSize, defaultSize };
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- if (w != oldw || h != oldh) {
- stale_icon = true;
- }
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- if (stale_icon && mImageMirror != null && mImageMirror.getHeight() > 0
- && mImageMirror.getWidth() > 0) {
- stale_icon = !makeAndSetIcon(mImageMirror);
- }
- super.onDraw(canvas);
- }
-
- // Internal methods
-
- /**
- * Creates and sets button icon. Only call after layout.
- *
- * @param image bitmap to use as icon
- */
- private boolean makeAndSetIcon(Bitmap image) {
- int[] sizes = getGoodIconSideSize();
- if (sizes != null && sizes.length >= 2 && sizes[0] > 0 && sizes[1] > 0) {
- return setImageIcon(makeImageIcon(image, sizes[0], sizes[1]));
- }
- return false;
- }
-
- /**
- * Sets icon.
- *
- * @param image bitmap to set the icon to.
- */
- private boolean setImageIcon(Bitmap image) {
- if (image == null) {
- return false;
- }
- if(mIcon != null && mIcon.getConfig() == Bitmap.Config.ARGB_8888) {
- GalleryBitmapPool.getInstance().put(mIcon);
- mIcon = null;
- }
- mIcon = image;
- this.setCompoundDrawablesWithIntrinsicBounds(null,
- new BitmapDrawable(getResources(), mIcon), null, null);
- return true;
- }
-
- /**
- * Generate an icon bitmap from a given bitmap.
- *
- * @param image bitmap to use as button icon
- * @param width icon width
- * @param height icon height
- * @return the scaled/cropped icon bitmap
- */
- private Bitmap makeImageIcon(Bitmap image, int width, int height) {
- if (image == null || image.getHeight() < 1 || image.getWidth() < 1 ||
- width < 1 || height < 1) {
- throw new IllegalArgumentException("input is null, or has invalid dimensions");
- }
- Bitmap icon = null;
- icon = GalleryBitmapPool.getInstance().get(width, height);
- if (icon == null) {
- icon = IconFactory.createIcon(image, width, height, false);
- } else {
- assert(icon.getWidth() == width && icon.getHeight() == height);
- icon.eraseColor(Color.TRANSPARENT);
- IconFactory.drawIcon(icon, image, false);
- }
- return icon;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java
deleted file mode 100644
index f7dcad7..0000000
--- a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.ui;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffXfermode;
-import android.os.AsyncTask;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import android.widget.PopupMenu;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.editors.Editor;
-import com.android.gallery3d.filtershow.editors.EditorCurves;
-import com.android.gallery3d.filtershow.filters.FilterCurvesRepresentation;
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.filters.ImageFilterCurves;
-import com.android.gallery3d.filtershow.imageshow.ImageShow;
-import com.android.gallery3d.filtershow.presets.ImagePreset;
-
-import java.util.HashMap;
-
-public class ImageCurves extends ImageShow {
-
- private static final String LOGTAG = "ImageCurves";
- Paint gPaint = new Paint();
- Path gPathSpline = new Path();
- HashMap<Integer, String> mIdStrLut;
-
- private int mCurrentCurveIndex = Spline.RGB;
- private boolean mDidAddPoint = false;
- private boolean mDidDelete = false;
- private ControlPoint mCurrentControlPoint = null;
- private int mCurrentPick = -1;
- private ImagePreset mLastPreset = null;
- int[] redHistogram = new int[256];
- int[] greenHistogram = new int[256];
- int[] blueHistogram = new int[256];
- Path gHistoPath = new Path();
-
- boolean mDoingTouchMove = false;
- private EditorCurves mEditorCurves;
- private FilterCurvesRepresentation mFilterCurvesRepresentation;
-
- public ImageCurves(Context context) {
- super(context);
- setLayerType(LAYER_TYPE_SOFTWARE, gPaint);
- resetCurve();
- }
-
- public ImageCurves(Context context, AttributeSet attrs) {
- super(context, attrs);
- setLayerType(LAYER_TYPE_SOFTWARE, gPaint);
- resetCurve();
- }
-
- @Override
- protected boolean enableComparison() {
- return false;
- }
-
- @Override
- public boolean useUtilityPanel() {
- return true;
- }
-
- private void showPopupMenu(LinearLayout accessoryViewList) {
- final Button button = (Button) accessoryViewList.findViewById(
- R.id.applyEffect);
- if (button == null) {
- return;
- }
- if (mIdStrLut == null){
- mIdStrLut = new HashMap<Integer, String>();
- mIdStrLut.put(R.id.curve_menu_rgb,
- getContext().getString(R.string.curves_channel_rgb));
- mIdStrLut.put(R.id.curve_menu_red,
- getContext().getString(R.string.curves_channel_red));
- mIdStrLut.put(R.id.curve_menu_green,
- getContext().getString(R.string.curves_channel_green));
- mIdStrLut.put(R.id.curve_menu_blue,
- getContext().getString(R.string.curves_channel_blue));
- }
- PopupMenu popupMenu = new PopupMenu(getActivity(), button);
- popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_curves, popupMenu.getMenu());
- popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- setChannel(item.getItemId());
- button.setText(mIdStrLut.get(item.getItemId()));
- return true;
- }
- });
- Editor.hackFixStrings(popupMenu.getMenu());
- popupMenu.show();
- }
-
- @Override
- public void openUtilityPanel(final LinearLayout accessoryViewList) {
- Context context = accessoryViewList.getContext();
- Button view = (Button) accessoryViewList.findViewById(R.id.applyEffect);
- view.setText(context.getString(R.string.curves_channel_rgb));
- view.setVisibility(View.VISIBLE);
-
- view.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- showPopupMenu(accessoryViewList);
- }
- });
-
- if (view != null) {
- view.setVisibility(View.VISIBLE);
- }
- }
-
- public void nextChannel() {
- mCurrentCurveIndex = ((mCurrentCurveIndex + 1) % 4);
- invalidate();
- }
-
- @Override
- public boolean showTitle() {
- return false;
- }
-
- private ImageFilterCurves curves() {
- String filterName = getFilterName();
- ImagePreset p = getImagePreset();
- if (p != null) {
- return (ImageFilterCurves) FiltersManager.getManager().getFilter(ImageFilterCurves.class);
- }
- return null;
- }
-
- private Spline getSpline(int index) {
- return mFilterCurvesRepresentation.getSpline(index);
- }
-
- @Override
- public void resetParameter() {
- super.resetParameter();
- resetCurve();
- mLastPreset = null;
- invalidate();
- }
-
- public void resetCurve() {
- if (mFilterCurvesRepresentation != null) {
- mFilterCurvesRepresentation.reset();
- updateCachedImage();
- }
- }
-
- @Override
- public void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- if (mFilterCurvesRepresentation == null) {
- return;
- }
-
- gPaint.setAntiAlias(true);
-
- if (getImagePreset() != mLastPreset && getFilteredImage() != null) {
- new ComputeHistogramTask().execute(getFilteredImage());
- mLastPreset = getImagePreset();
- }
-
- if (curves() == null) {
- return;
- }
-
- if (mCurrentCurveIndex == Spline.RGB || mCurrentCurveIndex == Spline.RED) {
- drawHistogram(canvas, redHistogram, Color.RED, PorterDuff.Mode.SCREEN);
- }
- if (mCurrentCurveIndex == Spline.RGB || mCurrentCurveIndex == Spline.GREEN) {
- drawHistogram(canvas, greenHistogram, Color.GREEN, PorterDuff.Mode.SCREEN);
- }
- if (mCurrentCurveIndex == Spline.RGB || mCurrentCurveIndex == Spline.BLUE) {
- drawHistogram(canvas, blueHistogram, Color.BLUE, PorterDuff.Mode.SCREEN);
- }
- // We only display the other channels curves when showing the RGB curve
- if (mCurrentCurveIndex == Spline.RGB) {
- for (int i = 0; i < 4; i++) {
- Spline spline = getSpline(i);
- if (i != mCurrentCurveIndex && !spline.isOriginal()) {
- // And we only display a curve if it has more than two
- // points
- spline.draw(canvas, Spline.colorForCurve(i), getWidth(),
- getHeight(), false, mDoingTouchMove);
- }
- }
- }
- // ...but we always display the current curve.
- getSpline(mCurrentCurveIndex)
- .draw(canvas, Spline.colorForCurve(mCurrentCurveIndex), getWidth(), getHeight(),
- true, mDoingTouchMove);
- drawToast(canvas);
-
- }
-
- private int pickControlPoint(float x, float y) {
- int pick = 0;
- Spline spline = getSpline(mCurrentCurveIndex);
- float px = spline.getPoint(0).x;
- float py = spline.getPoint(0).y;
- double delta = Math.sqrt((px - x) * (px - x) + (py - y) * (py - y));
- for (int i = 1; i < spline.getNbPoints(); i++) {
- px = spline.getPoint(i).x;
- py = spline.getPoint(i).y;
- double currentDelta = Math.sqrt((px - x) * (px - x) + (py - y)
- * (py - y));
- if (currentDelta < delta) {
- delta = currentDelta;
- pick = i;
- }
- }
-
- if (!mDidAddPoint && (delta * getWidth() > 100)
- && (spline.getNbPoints() < 10)) {
- return -1;
- }
-
- return pick;
- }
-
- private String getFilterName() {
- return "Curves";
- }
-
- @Override
- public synchronized boolean onTouchEvent(MotionEvent e) {
- if (e.getPointerCount() != 1) {
- return true;
- }
-
- if (didFinishScalingOperation()) {
- return true;
- }
-
- float margin = Spline.curveHandleSize() / 2;
- float posX = e.getX();
- if (posX < margin) {
- posX = margin;
- }
- float posY = e.getY();
- if (posY < margin) {
- posY = margin;
- }
- if (posX > getWidth() - margin) {
- posX = getWidth() - margin;
- }
- if (posY > getHeight() - margin) {
- posY = getHeight() - margin;
- }
- posX = (posX - margin) / (getWidth() - 2 * margin);
- posY = (posY - margin) / (getHeight() - 2 * margin);
-
- if (e.getActionMasked() == MotionEvent.ACTION_UP) {
- mCurrentControlPoint = null;
- mCurrentPick = -1;
- updateCachedImage();
- mDidAddPoint = false;
- if (mDidDelete) {
- mDidDelete = false;
- }
- mDoingTouchMove = false;
- return true;
- }
-
- if (mDidDelete) {
- return true;
- }
-
- if (curves() == null) {
- return true;
- }
-
- if (e.getActionMasked() == MotionEvent.ACTION_MOVE) {
- mDoingTouchMove = true;
- Spline spline = getSpline(mCurrentCurveIndex);
- int pick = mCurrentPick;
- if (mCurrentControlPoint == null) {
- pick = pickControlPoint(posX, posY);
- if (pick == -1) {
- mCurrentControlPoint = new ControlPoint(posX, posY);
- pick = spline.addPoint(mCurrentControlPoint);
- mDidAddPoint = true;
- } else {
- mCurrentControlPoint = spline.getPoint(pick);
- }
- mCurrentPick = pick;
- }
-
- if (spline.isPointContained(posX, pick)) {
- spline.movePoint(pick, posX, posY);
- } else if (pick != -1 && spline.getNbPoints() > 2) {
- spline.deletePoint(pick);
- mDidDelete = true;
- }
- updateCachedImage();
- invalidate();
- }
- return true;
- }
-
- public synchronized void updateCachedImage() {
- if (getImagePreset() != null) {
- resetImageCaches(this);
- if (mEditorCurves != null) {
- mEditorCurves.commitLocalRepresentation();
- }
- invalidate();
- }
- }
-
- class ComputeHistogramTask extends AsyncTask<Bitmap, Void, int[]> {
- @Override
- protected int[] doInBackground(Bitmap... params) {
- int[] histo = new int[256 * 3];
- Bitmap bitmap = params[0];
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- int[] pixels = new int[w * h];
- bitmap.getPixels(pixels, 0, w, 0, 0, w, h);
- for (int i = 0; i < w; i++) {
- for (int j = 0; j < h; j++) {
- int index = j * w + i;
- int r = Color.red(pixels[index]);
- int g = Color.green(pixels[index]);
- int b = Color.blue(pixels[index]);
- histo[r]++;
- histo[256 + g]++;
- histo[512 + b]++;
- }
- }
- return histo;
- }
-
- @Override
- protected void onPostExecute(int[] result) {
- System.arraycopy(result, 0, redHistogram, 0, 256);
- System.arraycopy(result, 256, greenHistogram, 0, 256);
- System.arraycopy(result, 512, blueHistogram, 0, 256);
- invalidate();
- }
- }
-
- private void drawHistogram(Canvas canvas, int[] histogram, int color, PorterDuff.Mode mode) {
- int max = 0;
- for (int i = 0; i < histogram.length; i++) {
- if (histogram[i] > max) {
- max = histogram[i];
- }
- }
- float w = getWidth() - Spline.curveHandleSize();
- float h = getHeight() - Spline.curveHandleSize() / 2.0f;
- float dx = Spline.curveHandleSize() / 2.0f;
- float wl = w / histogram.length;
- float wh = (0.3f * h) / max;
- Paint paint = new Paint();
- paint.setARGB(100, 255, 255, 255);
- paint.setStrokeWidth((int) Math.ceil(wl));
-
- Paint paint2 = new Paint();
- paint2.setColor(color);
- paint2.setStrokeWidth(6);
- paint2.setXfermode(new PorterDuffXfermode(mode));
- gHistoPath.reset();
- gHistoPath.moveTo(dx, h);
- boolean firstPointEncountered = false;
- float prev = 0;
- float last = 0;
- for (int i = 0; i < histogram.length; i++) {
- float x = i * wl + dx;
- float l = histogram[i] * wh;
- if (l != 0) {
- float v = h - (l + prev) / 2.0f;
- if (!firstPointEncountered) {
- gHistoPath.lineTo(x, h);
- firstPointEncountered = true;
- }
- gHistoPath.lineTo(x, v);
- prev = l;
- last = x;
- }
- }
- gHistoPath.lineTo(last, h);
- gHistoPath.lineTo(w, h);
- gHistoPath.close();
- canvas.drawPath(gHistoPath, paint2);
- paint2.setStrokeWidth(2);
- paint2.setStyle(Paint.Style.STROKE);
- paint2.setARGB(255, 200, 200, 200);
- canvas.drawPath(gHistoPath, paint2);
- }
-
- public void setChannel(int itemId) {
- switch (itemId) {
- case R.id.curve_menu_rgb: {
- mCurrentCurveIndex = Spline.RGB;
- break;
- }
- case R.id.curve_menu_red: {
- mCurrentCurveIndex = Spline.RED;
- break;
- }
- case R.id.curve_menu_green: {
- mCurrentCurveIndex = Spline.GREEN;
- break;
- }
- case R.id.curve_menu_blue: {
- mCurrentCurveIndex = Spline.BLUE;
- break;
- }
- }
- mEditorCurves.commitLocalRepresentation();
- invalidate();
- }
-
- public void setEditor(EditorCurves editorCurves) {
- mEditorCurves = editorCurves;
- }
-
- public void setFilterDrawRepresentation(FilterCurvesRepresentation drawRep) {
- mFilterCurvesRepresentation = drawRep;
- }
-}
diff --git a/src/com/android/gallery3d/filtershow/ui/Spline.java b/src/com/android/gallery3d/filtershow/ui/Spline.java
deleted file mode 100644
index cadf2fd..0000000
--- a/src/com/android/gallery3d/filtershow/ui/Spline.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.filtershow.ui;
-
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.drawable.Drawable;
-import android.util.Log;
-
-import java.util.Collections;
-import java.util.Vector;
-
-public class Spline {
- private final Vector<ControlPoint> mPoints;
- private static Drawable mCurveHandle;
- private static int mCurveHandleSize;
- private static int mCurveWidth;
-
- public static final int RGB = 0;
- public static final int RED = 1;
- public static final int GREEN = 2;
- public static final int BLUE = 3;
- private static final String LOGTAG = "Spline";
-
- private final Paint gPaint = new Paint();
- private ControlPoint mCurrentControlPoint = null;
-
- public Spline() {
- mPoints = new Vector<ControlPoint>();
- }
-
- public Spline(Spline spline) {
- mPoints = new Vector<ControlPoint>();
- for (int i = 0; i < spline.mPoints.size(); i++) {
- ControlPoint p = spline.mPoints.elementAt(i);
- ControlPoint newPoint = new ControlPoint(p);
- mPoints.add(newPoint);
- if (spline.mCurrentControlPoint == p) {
- mCurrentControlPoint = newPoint;
- }
- }
- Collections.sort(mPoints);
- }
-
- public static void setCurveHandle(Drawable drawable, int size) {
- mCurveHandle = drawable;
- mCurveHandleSize = size;
- }
-
- public static void setCurveWidth(int width) {
- mCurveWidth = width;
- }
-
- public static int curveHandleSize() {
- return mCurveHandleSize;
- }
-
- public static int colorForCurve(int curveIndex) {
- switch (curveIndex) {
- case Spline.RED:
- return Color.RED;
- case GREEN:
- return Color.GREEN;
- case BLUE:
- return Color.BLUE;
- }
- return Color.WHITE;
- }
-
- private void didMovePoint(ControlPoint point) {
- mCurrentControlPoint = point;
- }
-
- public void movePoint(int pick, float x, float y) {
- if (pick < 0 || pick > mPoints.size() - 1) {
- return;
- }
- ControlPoint point = mPoints.elementAt(pick);
- point.x = x;
- point.y = y;
- didMovePoint(point);
- }
-
- public boolean isOriginal() {
- if (this.getNbPoints() != 2) {
- return false;
- }
- if (mPoints.elementAt(0).x != 0 || mPoints.elementAt(0).y != 1) {
- return false;
- }
- if (mPoints.elementAt(1).x != 1 || mPoints.elementAt(1).y != 0) {
- return false;
- }
- return true;
- }
-
- public void reset() {
- mPoints.clear();
- addPoint(0.0f, 1.0f);
- addPoint(1.0f, 0.0f);
- }
-
- private void drawHandles(Canvas canvas, Drawable indicator, float centerX, float centerY) {
- int left = (int) centerX - mCurveHandleSize / 2;
- int top = (int) centerY - mCurveHandleSize / 2;
- indicator.setBounds(left, top, left + mCurveHandleSize, top + mCurveHandleSize);
- indicator.draw(canvas);
- }
-
- public float[] getAppliedCurve() {
- float[] curve = new float[256];
- ControlPoint[] points = new ControlPoint[mPoints.size()];
- for (int i = 0; i < mPoints.size(); i++) {
- ControlPoint p = mPoints.get(i);
- points[i] = new ControlPoint(p.x, p.y);
- }
- double[] derivatives = solveSystem(points);
- int start = 0;
- int end = 256;
- if (points[0].x != 0) {
- start = (int) (points[0].x * 256);
- }
- if (points[points.length - 1].x != 1) {
- end = (int) (points[points.length - 1].x * 256);
- }
- for (int i = 0; i < start; i++) {
- curve[i] = 1.0f - points[0].y;
- }
- for (int i = end; i < 256; i++) {
- curve[i] = 1.0f - points[points.length - 1].y;
- }
- for (int i = start; i < end; i++) {
- ControlPoint cur = null;
- ControlPoint next = null;
- double x = i / 256.0;
- int pivot = 0;
- for (int j = 0; j < points.length - 1; j++) {
- if (x >= points[j].x && x <= points[j + 1].x) {
- pivot = j;
- }
- }
- cur = points[pivot];
- next = points[pivot + 1];
- if (x <= next.x) {
- double x1 = cur.x;
- double x2 = next.x;
- double y1 = cur.y;
- double y2 = next.y;
-
- // Use the second derivatives to apply the cubic spline
- // equation:
- double delta = (x2 - x1);
- double delta2 = delta * delta;
- double b = (x - x1) / delta;
- double a = 1 - b;
- double ta = a * y1;
- double tb = b * y2;
- double tc = (a * a * a - a) * derivatives[pivot];
- double td = (b * b * b - b) * derivatives[pivot + 1];
- double y = ta + tb + (delta2 / 6) * (tc + td);
- if (y > 1.0f) {
- y = 1.0f;
- }
- if (y < 0) {
- y = 0;
- }
- curve[i] = (float) (1.0f - y);
- } else {
- curve[i] = 1.0f - next.y;
- }
- }
- return curve;
- }
-
- private void drawGrid(Canvas canvas, float w, float h) {
- // Grid
- gPaint.setARGB(128, 150, 150, 150);
- gPaint.setStrokeWidth(1);
-
- float stepH = h / 9;
- float stepW = w / 9;
-
- // central diagonal
- gPaint.setARGB(255, 100, 100, 100);
- gPaint.setStrokeWidth(2);
- canvas.drawLine(0, h, w, 0, gPaint);
-
- gPaint.setARGB(128, 200, 200, 200);
- gPaint.setStrokeWidth(4);
- stepH = h / 3;
- stepW = w / 3;
- for (int j = 1; j < 3; j++) {
- canvas.drawLine(0, j * stepH, w, j * stepH, gPaint);
- canvas.drawLine(j * stepW, 0, j * stepW, h, gPaint);
- }
- canvas.drawLine(0, 0, 0, h, gPaint);
- canvas.drawLine(w, 0, w, h, gPaint);
- canvas.drawLine(0, 0, w, 0, gPaint);
- canvas.drawLine(0, h, w, h, gPaint);
- }
-
- public void draw(Canvas canvas, int color, int canvasWidth, int canvasHeight,
- boolean showHandles, boolean moving) {
- float w = canvasWidth - mCurveHandleSize;
- float h = canvasHeight - mCurveHandleSize;
- float dx = mCurveHandleSize / 2;
- float dy = mCurveHandleSize / 2;
-
- // The cubic spline equation is (from numerical recipes in C):
- // y = a(y_i) + b(y_i+1) + c(y"_i) + d(y"_i+1)
- //
- // with c(y"_i) and d(y"_i+1):
- // c(y"_i) = 1/6 (a^3 - a) delta^2 (y"_i)
- // d(y"_i_+1) = 1/6 (b^3 - b) delta^2 (y"_i+1)
- //
- // and delta:
- // delta = x_i+1 - x_i
- //
- // To find the second derivatives y", we can rearrange the equation as:
- // A(y"_i-1) + B(y"_i) + C(y"_i+1) = D
- //
- // With the coefficients A, B, C, D:
- // A = 1/6 (x_i - x_i-1)
- // B = 1/3 (x_i+1 - x_i-1)
- // C = 1/6 (x_i+1 - x_i)
- // D = (y_i+1 - y_i)/(x_i+1 - x_i) - (y_i - y_i-1)/(x_i - x_i-1)
- //
- // We can now easily solve the equation to find the second derivatives:
- ControlPoint[] points = new ControlPoint[mPoints.size()];
- for (int i = 0; i < mPoints.size(); i++) {
- ControlPoint p = mPoints.get(i);
- points[i] = new ControlPoint(p.x * w, p.y * h);
- }
- double[] derivatives = solveSystem(points);
-
- Path path = new Path();
- path.moveTo(0, points[0].y);
- for (int i = 0; i < points.length - 1; i++) {
- double x1 = points[i].x;
- double x2 = points[i + 1].x;
- double y1 = points[i].y;
- double y2 = points[i + 1].y;
-
- for (double x = x1; x < x2; x += 20) {
- // Use the second derivatives to apply the cubic spline
- // equation:
- double delta = (x2 - x1);
- double delta2 = delta * delta;
- double b = (x - x1) / delta;
- double a = 1 - b;
- double ta = a * y1;
- double tb = b * y2;
- double tc = (a * a * a - a) * derivatives[i];
- double td = (b * b * b - b) * derivatives[i + 1];
- double y = ta + tb + (delta2 / 6) * (tc + td);
- if (y > h) {
- y = h;
- }
- if (y < 0) {
- y = 0;
- }
- path.lineTo((float) x, (float) y);
- }
- }
- canvas.save();
- canvas.translate(dx, dy);
- drawGrid(canvas, w, h);
- ControlPoint lastPoint = points[points.length - 1];
- path.lineTo(lastPoint.x, lastPoint.y);
- path.lineTo(w, lastPoint.y);
- Paint paint = new Paint();
- paint.setAntiAlias(true);
- paint.setFilterBitmap(true);
- paint.setDither(true);
- paint.setStyle(Paint.Style.STROKE);
- int curveWidth = mCurveWidth;
- if (showHandles) {
- curveWidth *= 1.5;
- }
- paint.setStrokeWidth(curveWidth + 2);
- paint.setColor(Color.BLACK);
- canvas.drawPath(path, paint);
-
- if (moving && mCurrentControlPoint != null) {
- float px = mCurrentControlPoint.x * w;
- float py = mCurrentControlPoint.y * h;
- paint.setStrokeWidth(3);
- paint.setColor(Color.BLACK);
- canvas.drawLine(px, py, px, h, paint);
- canvas.drawLine(0, py, px, py, paint);
- paint.setStrokeWidth(1);
- paint.setColor(color);
- canvas.drawLine(px, py, px, h, paint);
- canvas.drawLine(0, py, px, py, paint);
- }
-
- paint.setStrokeWidth(curveWidth);
- paint.setColor(color);
- canvas.drawPath(path, paint);
- if (showHandles) {
- for (int i = 0; i < points.length; i++) {
- float x = points[i].x;
- float y = points[i].y;
- drawHandles(canvas, mCurveHandle, x, y);
- }
- }
- canvas.restore();
- }
-
- double[] solveSystem(ControlPoint[] points) {
- int n = points.length;
- double[][] system = new double[n][3];
- double[] result = new double[n]; // d
- double[] solution = new double[n]; // returned coefficients
- system[0][1] = 1;
- system[n - 1][1] = 1;
- double d6 = 1.0 / 6.0;
- double d3 = 1.0 / 3.0;
-
- // let's create a tridiagonal matrix representing the
- // system, and apply the TDMA algorithm to solve it
- // (see http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm)
- for (int i = 1; i < n - 1; i++) {
- double deltaPrevX = points[i].x - points[i - 1].x;
- double deltaX = points[i + 1].x - points[i - 1].x;
- double deltaNextX = points[i + 1].x - points[i].x;
- double deltaNextY = points[i + 1].y - points[i].y;
- double deltaPrevY = points[i].y - points[i - 1].y;
- system[i][0] = d6 * deltaPrevX; // a_i
- system[i][1] = d3 * deltaX; // b_i
- system[i][2] = d6 * deltaNextX; // c_i
- result[i] = (deltaNextY / deltaNextX) - (deltaPrevY / deltaPrevX); // d_i
- }
-
- // Forward sweep
- for (int i = 1; i < n; i++) {
- // m = a_i/b_i-1
- double m = system[i][0] / system[i - 1][1];
- // b_i = b_i - m(c_i-1)
- system[i][1] = system[i][1] - m * system[i - 1][2];
- // d_i = d_i - m(d_i-1)
- result[i] = result[i] - m * result[i - 1];
- }
-
- // Back substitution
- solution[n - 1] = result[n - 1] / system[n - 1][1];
- for (int i = n - 2; i >= 0; --i) {
- solution[i] = (result[i] - system[i][2] * solution[i + 1]) / system[i][1];
- }
- return solution;
- }
-
- public int addPoint(float x, float y) {
- return addPoint(new ControlPoint(x, y));
- }
-
- public int addPoint(ControlPoint v) {
- mPoints.add(v);
- Collections.sort(mPoints);
- return mPoints.indexOf(v);
- }
-
- public void deletePoint(int n) {
- mPoints.remove(n);
- if (mPoints.size() < 2) {
- reset();
- }
- Collections.sort(mPoints);
- }
-
- public int getNbPoints() {
- return mPoints.size();
- }
-
- public ControlPoint getPoint(int n) {
- return mPoints.elementAt(n);
- }
-
- public boolean isPointContained(float x, int n) {
- for (int i = 0; i < n; i++) {
- ControlPoint point = mPoints.elementAt(i);
- if (point.x > x) {
- return false;
- }
- }
- for (int i = n + 1; i < mPoints.size(); i++) {
- ControlPoint point = mPoints.elementAt(i);
- if (point.x < x) {
- return false;
- }
- }
- return true;
- }
-
- public Spline copy() {
- Spline spline = new Spline();
- for (int i = 0; i < mPoints.size(); i++) {
- ControlPoint point = mPoints.elementAt(i);
- spline.addPoint(point.copy());
- }
- return spline;
- }
-
- public void show() {
- Log.v(LOGTAG, "show curve " + this);
- for (int i = 0; i < mPoints.size(); i++) {
- ControlPoint point = mPoints.elementAt(i);
- Log.v(LOGTAG, "point " + i + " is (" + point.x + ", " + point.y + ")");
- }
- }
-
-}
diff --git a/src/com/android/gallery3d/gadget/WidgetClickHandler.java b/src/com/android/gallery3d/gadget/WidgetClickHandler.java
index 37ee1a6..e66a2a6 100644
--- a/src/com/android/gallery3d/gadget/WidgetClickHandler.java
+++ b/src/com/android/gallery3d/gadget/WidgetClickHandler.java
@@ -27,7 +27,7 @@
import android.widget.Toast;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.app.PhotoPage;
import com.android.gallery3d.common.ApiHelper;
@@ -63,7 +63,7 @@
} else {
Toast.makeText(this,
R.string.no_such_item, Toast.LENGTH_LONG).show();
- intent = new Intent(this, Gallery.class);
+ intent = new Intent(this, GalleryActivity.class);
}
if (tediousBack) {
intent.setFlags(
diff --git a/src/com/android/gallery3d/gadget/WidgetConfigure.java b/src/com/android/gallery3d/gadget/WidgetConfigure.java
index eb81b6e..2a4c6cf 100644
--- a/src/com/android/gallery3d/gadget/WidgetConfigure.java
+++ b/src/com/android/gallery3d/gadget/WidgetConfigure.java
@@ -35,7 +35,7 @@
import com.android.gallery3d.data.LocalAlbum;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
-import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.crop.CropActivity;
import com.android.gallery3d.filtershow.crop.CropExtras;
public class WidgetConfigure extends Activity {
@@ -149,7 +149,7 @@
int widgetHeight = Math.round(height * scale);
mPickedItem = data.getData();
- Intent request = new Intent(FilterShowActivity.CROP_ACTION, mPickedItem)
+ Intent request = new Intent(CropActivity.CROP_ACTION, mPickedItem)
.putExtra(CropExtras.KEY_OUTPUT_X, widgetWidth)
.putExtra(CropExtras.KEY_OUTPUT_Y, widgetHeight)
.putExtra(CropExtras.KEY_ASPECT_X, widgetWidth)
diff --git a/src/com/android/gallery3d/gadget/WidgetService.java b/src/com/android/gallery3d/gadget/WidgetService.java
index 94dd164..fc54fb6 100644
--- a/src/com/android/gallery3d/gadget/WidgetService.java
+++ b/src/com/android/gallery3d/gadget/WidgetService.java
@@ -97,7 +97,7 @@
@Override
public int getViewTypeCount() {
- return 1;
+ return 2;
}
@Override
diff --git a/src/com/android/gallery3d/glrenderer/TiledTexture.java b/src/com/android/gallery3d/glrenderer/TiledTexture.java
index 6ca1de0..78cb2f2 100644
--- a/src/com/android/gallery3d/glrenderer/TiledTexture.java
+++ b/src/com/android/gallery3d/glrenderer/TiledTexture.java
@@ -129,18 +129,25 @@
@Override
protected Bitmap onGetBitmap() {
- int x = BORDER_SIZE - offsetX;
- int y = BORDER_SIZE - offsetY;
- int r = bitmap.getWidth() + x;
- int b = bitmap.getHeight() + y;
- sCanvas.drawBitmap(bitmap, x, y, sBitmapPaint);
+ // make a local copy of the reference to the bitmap,
+ // since it might be null'd in a different thread. b/8694871
+ Bitmap localBitmapRef = bitmap;
bitmap = null;
- // draw borders if need
- if (x > 0) sCanvas.drawLine(x - 1, 0, x - 1, TILE_SIZE, sPaint);
- if (y > 0) sCanvas.drawLine(0, y - 1, TILE_SIZE, y - 1, sPaint);
- if (r < CONTENT_SIZE) sCanvas.drawLine(r, 0, r, TILE_SIZE, sPaint);
- if (b < CONTENT_SIZE) sCanvas.drawLine(0, b, TILE_SIZE, b, sPaint);
+ if (localBitmapRef != null) {
+ int x = BORDER_SIZE - offsetX;
+ int y = BORDER_SIZE - offsetY;
+ int r = localBitmapRef.getWidth() + x;
+ int b = localBitmapRef.getHeight() + y;
+ sCanvas.drawBitmap(localBitmapRef, x, y, sBitmapPaint);
+ localBitmapRef = null;
+
+ // draw borders if need
+ if (x > 0) sCanvas.drawLine(x - 1, 0, x - 1, TILE_SIZE, sPaint);
+ if (y > 0) sCanvas.drawLine(0, y - 1, TILE_SIZE, y - 1, sPaint);
+ if (r < CONTENT_SIZE) sCanvas.drawLine(r, 0, r, TILE_SIZE, sPaint);
+ if (b < CONTENT_SIZE) sCanvas.drawLine(0, b, TILE_SIZE, b, sPaint);
+ }
return sUploadBitmap;
}
diff --git a/src/com/android/gallery3d/ingest/ImportTask.java b/src/com/android/gallery3d/ingest/ImportTask.java
index d850bb8..7d2d641 100644
--- a/src/com/android/gallery3d/ingest/ImportTask.java
+++ b/src/com/android/gallery3d/ingest/ImportTask.java
@@ -65,6 +65,7 @@
List<MtpObjectInfo> objectsNotImported = new LinkedList<MtpObjectInfo>();
int visited = 0;
int total = mObjectsToImport.size();
+ mListener.onImportProgress(visited, total, null);
File dest = new File(Environment.getExternalStorageDirectory(), mDestAlbumName);
dest.mkdirs();
for (MtpObjectInfo object : mObjectsToImport) {
diff --git a/src/com/android/gallery3d/ingest/IngestActivity.java b/src/com/android/gallery3d/ingest/IngestActivity.java
index ffc4b50..687e9fd 100644
--- a/src/com/android/gallery3d/ingest/IngestActivity.java
+++ b/src/com/android/gallery3d/ingest/IngestActivity.java
@@ -75,6 +75,14 @@
private MenuItem mMenuSwitcherItem;
private MenuItem mActionMenuSwitcherItem;
+ // The MTP framework components don't give us fine-grained file copy
+ // progress updates, so for large photos and videos, we will be stuck
+ // with a dialog not updating for a long time. To give the user feedback,
+ // we switch to the animated indeterminate progress bar after the timeout
+ // specified by INDETERMINATE_SWITCH_TIMEOUT_MS. On the next update from
+ // the framework, we switch back to the normal progress bar.
+ private static final int INDETERMINATE_SWITCH_TIMEOUT_MS = 3000;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -437,6 +445,9 @@
mProgressState.current = visitedCount;
mProgressState.title = getResources().getString(R.string.ingest_importing);
mHandler.sendEmptyMessage(ItemListHandler.MSG_PROGRESS_UPDATE);
+ mHandler.removeMessages(ItemListHandler.MSG_PROGRESS_INDETERMINATE);
+ mHandler.sendEmptyMessageDelayed(ItemListHandler.MSG_PROGRESS_INDETERMINATE,
+ INDETERMINATE_SWITCH_TIMEOUT_MS);
}
@Override
@@ -444,6 +455,7 @@
int numVisited) {
// Not guaranteed to be called on the UI thread
mHandler.sendEmptyMessage(ItemListHandler.MSG_PROGRESS_HIDE);
+ mHandler.removeMessages(ItemListHandler.MSG_PROGRESS_INDETERMINATE);
// TODO: maybe show an extra dialog listing the ones that failed
// importing, if any?
}
@@ -477,6 +489,11 @@
}
}
+ private void makeProgressDialogIndeterminate() {
+ ProgressDialog dialog = getProgressDialog();
+ dialog.setIndeterminate(true);
+ }
+
private void cleanupProgressDialog() {
if (mProgressDialog != null) {
mProgressDialog.hide();
@@ -490,6 +507,7 @@
public static final int MSG_PROGRESS_HIDE = 1;
public static final int MSG_NOTIFY_CHANGED = 2;
public static final int MSG_BULK_CHECKED_CHANGE = 3;
+ public static final int MSG_PROGRESS_INDETERMINATE = 4;
WeakReference<IngestActivity> mParentReference;
@@ -515,6 +533,9 @@
case MSG_BULK_CHECKED_CHANGE:
parent.mPositionMappingCheckBroker.onBulkCheckedChange();
break;
+ case MSG_PROGRESS_INDETERMINATE:
+ parent.makeProgressDialogIndeterminate();
+ break;
default:
break;
}
diff --git a/src/com/android/gallery3d/ingest/IngestService.java b/src/com/android/gallery3d/ingest/IngestService.java
index 0ce3ab6..9d406b1 100644
--- a/src/com/android/gallery3d/ingest/IngestService.java
+++ b/src/com/android/gallery3d/ingest/IngestService.java
@@ -166,6 +166,9 @@
mClientActivity.onIndexFinish();
mRedeliverIndexFinish = false;
}
+ if (mDevice != null) {
+ mNeedRelaunchNotification = true;
+ }
}
protected void importSelectedItems(SparseBooleanArray selected, Adapter adapter) {
diff --git a/src/com/android/gallery3d/ingest/MtpDeviceIndex.java b/src/com/android/gallery3d/ingest/MtpDeviceIndex.java
index e873dd1..fed851e 100644
--- a/src/com/android/gallery3d/ingest/MtpDeviceIndex.java
+++ b/src/com/android/gallery3d/ingest/MtpDeviceIndex.java
@@ -26,8 +26,10 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Stack;
/**
@@ -62,6 +64,27 @@
*/
public class MtpDeviceIndex {
+ public static final int FORMAT_MOV = 0x300D; // For some reason this is not in MtpConstants
+
+ public static final Set<Integer> SUPPORTED_IMAGE_FORMATS;
+ public static final Set<Integer> SUPPORTED_VIDEO_FORMATS;
+
+ static {
+ SUPPORTED_IMAGE_FORMATS = new HashSet<Integer>();
+ SUPPORTED_IMAGE_FORMATS.add(MtpConstants.FORMAT_JFIF);
+ SUPPORTED_IMAGE_FORMATS.add(MtpConstants.FORMAT_EXIF_JPEG);
+ SUPPORTED_IMAGE_FORMATS.add(MtpConstants.FORMAT_PNG);
+ SUPPORTED_IMAGE_FORMATS.add(MtpConstants.FORMAT_GIF);
+ SUPPORTED_IMAGE_FORMATS.add(MtpConstants.FORMAT_BMP);
+
+ SUPPORTED_VIDEO_FORMATS = new HashSet<Integer>();
+ SUPPORTED_VIDEO_FORMATS.add(MtpConstants.FORMAT_3GP_CONTAINER);
+ SUPPORTED_VIDEO_FORMATS.add(MtpConstants.FORMAT_AVI);
+ SUPPORTED_VIDEO_FORMATS.add(MtpConstants.FORMAT_MP4_CONTAINER);
+ SUPPORTED_VIDEO_FORMATS.add(MtpConstants.FORMAT_MPEG);
+ // TODO: add FORMAT_MOV once Media Scanner supports .mov files
+ }
+
@Override
public int hashCode() {
final int prime = 31;
@@ -244,6 +267,9 @@
break;
}
}
+ if (mBuckets.length == 0 || mUnifiedLookupIndex.length == 0) {
+ return -1;
+ }
int mappedPos = mBuckets[bucketNumber].unifiedStartIndex
+ position - mBuckets[bucketNumber].itemsStartIndex;
if (order == SortOrder.Descending) {
@@ -260,6 +286,9 @@
return bucket.itemsStartIndex + position - 1 - bucket.unifiedStartIndex;
} else {
int zeroIndex = mUnifiedLookupIndex.length - 1 - position;
+ if (mBuckets.length == 0 || mUnifiedLookupIndex.length == 0) {
+ return -1;
+ }
DateBucket bucket = mBuckets[mUnifiedLookupIndex[zeroIndex]];
if (bucket.unifiedEndIndex == zeroIndex) zeroIndex--;
return mMtpObjects.length - 1 - bucket.itemsStartIndex
@@ -492,14 +521,12 @@
for (int objectHandle : mDevice.getObjectHandles(storageId, 0, dirHandle)) {
MtpObjectInfo objectInfo = mDevice.getObjectInfo(objectHandle);
if (objectInfo == null) throw new IndexingException();
- switch (objectInfo.getFormat()) {
- case MtpConstants.FORMAT_JFIF:
- case MtpConstants.FORMAT_EXIF_JPEG:
- addObject(objectInfo);
- break;
- case MtpConstants.FORMAT_ASSOCIATION:
- pendingDirectories.add(objectHandle);
- break;
+ int format = objectInfo.getFormat();
+ if (format == MtpConstants.FORMAT_ASSOCIATION) {
+ pendingDirectories.add(objectHandle);
+ } else if (SUPPORTED_IMAGE_FORMATS.contains(format)
+ || SUPPORTED_VIDEO_FORMATS.contains(format)) {
+ addObject(objectInfo);
}
}
}
diff --git a/src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java b/src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java
index 30868c2..c6504a5 100644
--- a/src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java
+++ b/src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java
@@ -24,7 +24,7 @@
import android.util.DisplayMetrics;
import android.view.WindowManager;
-import com.android.camera.Exif;
+import com.android.gallery3d.data.Exif;
import com.android.photos.data.GalleryBitmapPool;
public class MtpBitmapFetch {
diff --git a/src/com/android/gallery3d/ingest/ui/MtpImageView.java b/src/com/android/gallery3d/ingest/ui/MtpImageView.java
index 67414c6..80c1051 100644
--- a/src/com/android/gallery3d/ingest/ui/MtpImageView.java
+++ b/src/com/android/gallery3d/ingest/ui/MtpImageView.java
@@ -17,7 +17,9 @@
package com.android.gallery3d.ingest.ui;
import android.content.Context;
+import android.graphics.Canvas;
import android.graphics.Matrix;
+import android.graphics.drawable.Drawable;
import android.mtp.MtpDevice;
import android.mtp.MtpObjectInfo;
import android.os.Handler;
@@ -27,12 +29,17 @@
import android.util.AttributeSet;
import android.widget.ImageView;
+import com.android.gallery3d.R;
+import com.android.gallery3d.ingest.MtpDeviceIndex;
import com.android.gallery3d.ingest.data.BitmapWithMetadata;
import com.android.gallery3d.ingest.data.MtpBitmapFetch;
import java.lang.ref.WeakReference;
public class MtpImageView extends ImageView {
+ // We will use the thumbnail for images larger than this threshold
+ private static final int MAX_FULLSIZE_PREVIEW_SIZE = 8388608; // 8 megabytes
+
private int mObjectHandle;
private int mGeneration;
@@ -42,6 +49,8 @@
private MtpObjectInfo mFetchObjectInfo;
private MtpDevice mFetchDevice;
private Object mFetchResult;
+ private Drawable mOverlayIcon;
+ private boolean mShowOverlayIcon;
private static final FetchImageHandler sFetchHandler = FetchImageHandler.createOnNewThread();
private static final ShowImageHandler sFetchCompleteHandler = new ShowImageHandler();
@@ -78,6 +87,11 @@
showPlaceholder();
mGeneration = gen;
mObjectHandle = handle;
+ mShowOverlayIcon = MtpDeviceIndex.SUPPORTED_VIDEO_FORMATS.contains(object.getFormat());
+ if (mShowOverlayIcon && mOverlayIcon == null) {
+ mOverlayIcon = getResources().getDrawable(R.drawable.ic_control_play);
+ updateOverlayIconBounds();
+ }
synchronized (mFetchLock) {
mFetchObjectInfo = object;
mFetchDevice = device;
@@ -89,7 +103,12 @@
}
protected Object fetchMtpImageDataFromDevice(MtpDevice device, MtpObjectInfo info) {
- return MtpBitmapFetch.getFullsize(device, info);
+ if (info.getCompressedSize() <= MAX_FULLSIZE_PREVIEW_SIZE
+ && MtpDeviceIndex.SUPPORTED_IMAGE_FORMATS.contains(info.getFormat())) {
+ return MtpBitmapFetch.getFullsize(device, info);
+ } else {
+ return new BitmapWithMetadata(MtpBitmapFetch.getThumbnail(device, info), 0);
+ }
}
private float mLastBitmapWidth;
@@ -134,12 +153,46 @@
setImageMatrix(mDrawMatrix);
}
+ private static final int OVERLAY_ICON_SIZE_DENOMINATOR = 4;
+
+ private void updateOverlayIconBounds() {
+ int iheight = mOverlayIcon.getIntrinsicHeight();
+ int iwidth = mOverlayIcon.getIntrinsicWidth();
+ int vheight = getHeight();
+ int vwidth = getWidth();
+ float scale_height = ((float) vheight) / (iheight * OVERLAY_ICON_SIZE_DENOMINATOR);
+ float scale_width = ((float) vwidth) / (iwidth * OVERLAY_ICON_SIZE_DENOMINATOR);
+ if (scale_height >= 1f && scale_width >= 1f) {
+ mOverlayIcon.setBounds((vwidth - iwidth) / 2,
+ (vheight - iheight) / 2,
+ (vwidth + iwidth) / 2,
+ (vheight + iheight) / 2);
+ } else {
+ float scale = Math.min(scale_height, scale_width);
+ mOverlayIcon.setBounds((int) (vwidth - scale * iwidth) / 2,
+ (int) (vheight - scale * iheight) / 2,
+ (int) (vwidth + scale * iwidth) / 2,
+ (int) (vheight + scale * iheight) / 2);
+ }
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (changed && getScaleType() == ScaleType.MATRIX) {
updateDrawMatrix();
}
+ if (mShowOverlayIcon && changed && mOverlayIcon != null) {
+ updateOverlayIconBounds();
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ if (mShowOverlayIcon && mOverlayIcon != null) {
+ mOverlayIcon.draw(canvas);
+ }
}
protected void onMtpImageDataFetchedFromDevice(Object result) {
diff --git a/src/com/android/gallery3d/ui/DialogDetailsView.java b/src/com/android/gallery3d/ui/DialogDetailsView.java
index 058c036..30fd1e1 100644
--- a/src/com/android/gallery3d/ui/DialogDetailsView.java
+++ b/src/com/android/gallery3d/ui/DialogDetailsView.java
@@ -39,7 +39,9 @@
import com.android.gallery3d.ui.DetailsHelper.DetailsViewContainer;
import com.android.gallery3d.ui.DetailsHelper.ResolutionResolvingListener;
+import java.text.DecimalFormat;
import java.util.ArrayList;
+import java.util.Locale;
import java.util.Map.Entry;
public class DialogDetailsView implements DetailsViewContainer {
@@ -117,6 +119,8 @@
implements AddressResolvingListener, ResolutionResolvingListener {
private final ArrayList<String> mItems;
private int mLocationIndex;
+ private final Locale mDefaultLocale = Locale.getDefault();
+ private final DecimalFormat mDecimalFormat = new DecimalFormat(".####");
private int mWidthIndex = -1;
private int mHeightIndex = -1;
@@ -166,37 +170,57 @@
value = (String) detail.getValue();
double time = Double.valueOf(value);
if (time < 1.0f) {
- value = String.format("1/%d", (int) (0.5f + 1 / time));
+ value = String.format(mDefaultLocale, "%d/%d", 1,
+ (int) (0.5f + 1 / time));
} else {
int integer = (int) time;
time -= integer;
value = String.valueOf(integer) + "''";
if (time > 0.0001) {
- value += String.format(" 1/%d", (int) (0.5f + 1 / time));
+ value += String.format(mDefaultLocale, " %d/%d", 1,
+ (int) (0.5f + 1 / time));
}
}
break;
}
case MediaDetails.INDEX_WIDTH:
mWidthIndex = mItems.size();
- value = detail.getValue().toString();
- if (value.equalsIgnoreCase("0")) {
+ if (detail.getValue().toString().equalsIgnoreCase("0")) {
value = context.getString(R.string.unknown);
resolutionIsValid = false;
+ } else {
+ value = toLocalInteger(detail.getValue());
}
break;
case MediaDetails.INDEX_HEIGHT: {
mHeightIndex = mItems.size();
- value = detail.getValue().toString();
- if (value.equalsIgnoreCase("0")) {
+ if (detail.getValue().toString().equalsIgnoreCase("0")) {
value = context.getString(R.string.unknown);
resolutionIsValid = false;
+ } else {
+ value = toLocalInteger(detail.getValue());
}
break;
}
case MediaDetails.INDEX_PATH:
- // Get the path and then fall through to the default case
+ // Prepend the new-line as a) paths are usually long, so
+ // the formatting is better and b) an RTL UI will see it
+ // as a separate section and interpret it for what it
+ // is, rather than trying to make it RTL (which messes
+ // up the path).
+ value = "\n" + detail.getValue().toString();
path = detail.getValue().toString();
+ break;
+ case MediaDetails.INDEX_ISO:
+ value = toLocalNumber(Integer.parseInt((String) detail.getValue()));
+ break;
+ case MediaDetails.INDEX_FOCAL_LENGTH:
+ double focalLength = Double.parseDouble(detail.getValue().toString());
+ value = toLocalNumber(focalLength);
+ break;
+ case MediaDetails.INDEX_ORIENTATION:
+ value = toLocalInteger(detail.getValue());
+ break;
default: {
Object valueObj = detail.getValue();
// This shouldn't happen, log its key to help us diagnose the problem.
@@ -216,9 +240,9 @@
context, key), value);
}
mItems.add(value);
- if (!resolutionIsValid) {
- DetailsHelper.resolveResolution(path, this);
- }
+ }
+ if (!resolutionIsValid) {
+ DetailsHelper.resolveResolution(path, this);
}
}
@@ -271,14 +295,45 @@
if (width == 0 || height == 0) return;
// Update the resolution with the new width and height
Context context = mActivity.getAndroidContext();
- String widthString = String.format("%s: %d", DetailsHelper.getDetailsName(
- context, MediaDetails.INDEX_WIDTH), width);
- String heightString = String.format("%s: %d", DetailsHelper.getDetailsName(
- context, MediaDetails.INDEX_HEIGHT), height);
+ String widthString = String.format(mDefaultLocale, "%s: %d",
+ DetailsHelper.getDetailsName(
+ context, MediaDetails.INDEX_WIDTH), width);
+ String heightString = String.format(mDefaultLocale, "%s: %d",
+ DetailsHelper.getDetailsName(
+ context, MediaDetails.INDEX_HEIGHT), height);
mItems.set(mWidthIndex, String.valueOf(widthString));
mItems.set(mHeightIndex, String.valueOf(heightString));
notifyDataSetChanged();
}
+
+ /**
+ * Converts the given integer (given as String or Integer object) to a
+ * localized String version.
+ */
+ private String toLocalInteger(Object valueObj) {
+ if (valueObj instanceof Integer) {
+ return toLocalNumber((Integer) valueObj);
+ } else {
+ String value = valueObj.toString();
+ try {
+ value = toLocalNumber(Integer.parseInt(value));
+ } catch (NumberFormatException ex) {
+ // Just keep the current "value" if we cannot
+ // parse it as a fallback.
+ }
+ return value;
+ }
+ }
+
+ /** Converts the given integer to a localized String version. */
+ private String toLocalNumber(int n) {
+ return String.format(mDefaultLocale, "%d", n);
+ }
+
+ /** Converts the given double to a localized String version. */
+ private String toLocalNumber(double n) {
+ return mDecimalFormat.format(n);
+ }
}
@Override
diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java
index f00bd54..dc898d8 100644
--- a/src/com/android/gallery3d/ui/GLRootView.java
+++ b/src/com/android/gallery3d/ui/GLRootView.java
@@ -409,6 +409,9 @@
rotateCanvas(-mCompensation);
if (mContentView != null) {
mContentView.render(mCanvas);
+ } else {
+ // Make sure we always draw something to prevent displaying garbage
+ mCanvas.clearBuffer();
}
mCanvas.restore();
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 8f4854e..1ace718 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -26,6 +26,7 @@
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
+import android.support.v4.print.PrintHelper;
import android.view.Menu;
import android.view.MenuItem;
@@ -45,7 +46,6 @@
import java.util.ArrayList;
public class MenuExecutor {
- @SuppressWarnings("unused")
private static final String TAG = "MenuExecutor";
private static final int MSG_TASK_COMPLETE = 1;
@@ -177,6 +177,8 @@
boolean supportCache = (supported & MediaObject.SUPPORT_CACHE) != 0;
boolean supportEdit = (supported & MediaObject.SUPPORT_EDIT) != 0;
boolean supportInfo = (supported & MediaObject.SUPPORT_INFO) != 0;
+ boolean supportPrint = (supported & MediaObject.SUPPORT_PRINT) != 0;
+ supportPrint &= PrintHelper.systemSupportsPrint();
setMenuItemVisible(menu, R.id.action_delete, supportDelete);
setMenuItemVisible(menu, R.id.action_rotate_ccw, supportRotate);
@@ -192,6 +194,7 @@
setMenuItemVisible(menu, R.id.action_edit, supportEdit);
// setMenuItemVisible(menu, R.id.action_simple_edit, supportEdit);
setMenuItemVisible(menu, R.id.action_details, supportInfo);
+ setMenuItemVisible(menu, R.id.print, supportPrint);
}
public static void updateMenuForPanorama(Menu menu, boolean shareAsPanorama360,
diff --git a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
index f52aa5f..ce672f2 100644
--- a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
+++ b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
@@ -17,6 +17,10 @@
private GLView mRootPane;
public PreparePageFadeoutTexture(GLView rootPane) {
+ if (rootPane == null) {
+ mCancelled = true;
+ return;
+ }
int w = rootPane.getWidth();
int h = rootPane.getHeight();
if (w == 0 || h == 0) {
diff --git a/src/com/android/gallery3d/ui/SelectionManager.java b/src/com/android/gallery3d/ui/SelectionManager.java
index be6811b..0164a7a 100644
--- a/src/com/android/gallery3d/ui/SelectionManager.java
+++ b/src/com/android/gallery3d/ui/SelectionManager.java
@@ -69,6 +69,7 @@
public void selectAll() {
mInverseSelection = true;
mClickedSet.clear();
+ mTotal = -1;
enterSelectionMode();
if (mListener != null) mListener.onSelectionModeChange(SELECT_ALL_MODE);
}
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index 9245e2c..9a78fcd 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -37,7 +37,7 @@
import android.view.WindowManager;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.app.PackagesMonitor;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.DataManager;
@@ -239,8 +239,8 @@
int state = pm.getComponentEnabledSetting(name);
sCameraAvailableInitialized = true;
sCameraAvailable =
- (state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
- || (state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
+ (state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
+ || (state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
return sCameraAvailable;
}
@@ -252,7 +252,7 @@
}
public static void startGalleryActivity(Context context) {
- Intent intent = new Intent(context, Gallery.class)
+ Intent intent = new Intent(context, GalleryActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
diff --git a/src/com/android/gallery3d/util/HelpUtils.java b/src/com/android/gallery3d/util/HelpUtils.java
deleted file mode 100644
index 2a11283..0000000
--- a/src/com/android/gallery3d/util/HelpUtils.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.util;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.net.Uri;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.Locale;
-
-/**
- * Functions to easily prepare contextual help menu option items with an intent that opens up the
- * browser to a particular URL, while taking into account the preferred language and app version.
- */
-public class HelpUtils {
- private final static String TAG = HelpUtils.class.getName();
-
- /**
- * Help URL query parameter key for the preferred language.
- */
- private final static String PARAM_LANGUAGE_CODE = "hl";
-
- /**
- * Help URL query parameter key for the app version.
- */
- private final static String PARAM_VERSION = "version";
-
- /**
- * Cached version code to prevent repeated calls to the package manager.
- */
- private static String sCachedVersionCode = null;
-
- /** Static helper that is not instantiable*/
- private HelpUtils() {}
-
- public static Intent getHelpIntent(Context context, int helpUrlResId) {
- String helpUrlString = context.getString(helpUrlResId);
-
- if (TextUtils.isEmpty(helpUrlString)) {
- return null;
- } else {
- // The help url string exists, so first add in some extra query parameters.
- final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUrlString));
-
- // Then, create an intent that will be fired when the user
- // selects this help menu item.
- Intent intent = new Intent(Intent.ACTION_VIEW, fullUri);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
- return intent;
- }
- }
-
- /**
- * Adds two query parameters into the Uri, namely the language code and the version code
- * of the app's package as gotten via the context.
- * @return the uri with added query parameters
- */
- private static Uri uriWithAddedParameters(Context context, Uri baseUri) {
- Uri.Builder builder = baseUri.buildUpon();
-
- // Add in the preferred language
- builder.appendQueryParameter(PARAM_LANGUAGE_CODE, Locale.getDefault().toString());
-
- // Add in the package version code
- if (sCachedVersionCode == null) {
- // There is no cached version code, so try to get it from the package manager.
- try {
- // cache the version code
- PackageInfo info = context.getPackageManager().getPackageInfo(
- context.getPackageName(), 0);
- sCachedVersionCode = Integer.toString(info.versionCode);
-
- // append the version code to the uri
- builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode);
- } catch (NameNotFoundException e) {
- // Cannot find the package name, so don't add in the version parameter
- // This shouldn't happen.
- Log.wtf(TAG, "Invalid package name for context", e);
- }
- } else {
- builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode);
- }
-
- // Build the full uri and return it
- return builder.build();
- }
-}
diff --git a/src/com/android/gallery3d/util/SaveVideoFileUtils.java b/src/com/android/gallery3d/util/SaveVideoFileUtils.java
index 9e8f73a..10c41de 100644
--- a/src/com/android/gallery3d/util/SaveVideoFileUtils.java
+++ b/src/com/android/gallery3d/util/SaveVideoFileUtils.java
@@ -19,22 +19,19 @@
import android.content.ContentResolver;
import android.content.ContentValues;
import android.database.Cursor;
+import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore.Video;
import android.provider.MediaStore.Video.VideoColumns;
+import com.android.gallery3d.filtershow.tools.SaveImage.ContentResolverQueryCallback;
+
import java.io.File;
+import java.sql.Date;
import java.text.SimpleDateFormat;
-import java.util.Date;
public class SaveVideoFileUtils {
- // Copy from SaveCopyTask.java in terms of how to handle the destination
- // path and filename : querySource() and getSaveDirectory().
- public interface ContentResolverQueryCallback {
- void onCursorResult(Cursor cursor);
- }
-
// This function can decide which folder to save the video file, and generate
// the needed information for the video file including filename.
public static SaveVideoFileInfo getDstMp4FileInfo(String fileNameFormat,
@@ -50,7 +47,8 @@
} else {
dstFileInfo.mFolderName = dstFileInfo.mDirectory.getName();
}
- dstFileInfo.mFileName = new SimpleDateFormat(fileNameFormat).format(new Date());
+ dstFileInfo.mFileName = new SimpleDateFormat(fileNameFormat).format(
+ new Date(System.currentTimeMillis()));
dstFileInfo.mFile = new File(dstFileInfo.mDirectory, dstFileInfo.mFileName + ".mp4");
return dstFileInfo;
@@ -94,7 +92,7 @@
ContentResolver contentResolver, Uri uri ) {
long nowInMs = System.currentTimeMillis();
long nowInSec = nowInMs / 1000;
- final ContentValues values = new ContentValues(12);
+ final ContentValues values = new ContentValues(13);
values.put(Video.Media.TITLE, mDstFileInfo.mFileName);
values.put(Video.Media.DISPLAY_NAME, mDstFileInfo.mFile.getName());
values.put(Video.Media.MIME_TYPE, "video/mp4");
@@ -103,6 +101,8 @@
values.put(Video.Media.DATE_ADDED, nowInSec);
values.put(Video.Media.DATA, mDstFileInfo.mFile.getAbsolutePath());
values.put(Video.Media.SIZE, mDstFileInfo.mFile.length());
+ int durationMs = retriveVideoDurationMs(mDstFileInfo.mFile.getPath());
+ values.put(Video.Media.DURATION, durationMs);
// Copy the data taken and location info from src.
String[] projection = new String[] {
VideoColumns.DATE_TAKEN,
@@ -137,4 +137,18 @@
return contentResolver.insert(Video.Media.EXTERNAL_CONTENT_URI, values);
}
+ public static int retriveVideoDurationMs(String path) {
+ int durationMs = 0;
+ // Calculate the duration of the destination file.
+ MediaMetadataRetriever retriever = new MediaMetadataRetriever();
+ retriever.setDataSource(path);
+ String duration = retriever.extractMetadata(
+ MediaMetadataRetriever.METADATA_KEY_DURATION);
+ if (duration != null) {
+ durationMs = Integer.parseInt(duration);
+ }
+ retriever.release();
+ return durationMs;
+ }
+
}
diff --git a/src/com/android/photos/AlbumFragment.java b/src/com/android/photos/AlbumFragment.java
index 406fd2a..886ca68 100644
--- a/src/com/android/photos/AlbumFragment.java
+++ b/src/com/android/photos/AlbumFragment.java
@@ -31,7 +31,7 @@
import android.widget.TextView;
import com.android.gallery3d.R;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.photos.adapters.PhotoThumbnailAdapter;
import com.android.photos.data.PhotoSetLoader;
import com.android.photos.shims.LoaderCompatShim;
@@ -108,7 +108,7 @@
Cursor item = (Cursor) getItemAtPosition(position);
Uri uri = mLoaderCompatShim.uriForItem(item);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- intent.setClass(getActivity(), Gallery.class);
+ intent.setClass(getActivity(), GalleryActivity.class);
startActivity(intent);
}
diff --git a/src/com/android/photos/BitmapRegionTileSource.java b/src/com/android/photos/BitmapRegionTileSource.java
index 1c71151..d2d0570 100644
--- a/src/com/android/photos/BitmapRegionTileSource.java
+++ b/src/com/android/photos/BitmapRegionTileSource.java
@@ -16,66 +16,133 @@
package com.android.photos;
+import android.annotation.TargetApi;
+import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapRegionDecoder;
+import android.graphics.Canvas;
import android.graphics.Rect;
+import android.os.Build;
+import android.os.Build.VERSION_CODES;
import android.util.Log;
+
+import com.android.gallery3d.common.BitmapUtils;
+import com.android.gallery3d.glrenderer.BasicTexture;
+import com.android.gallery3d.glrenderer.BitmapTexture;
import com.android.photos.views.TiledImageRenderer;
import java.io.IOException;
+/**
+ * A {@link com.android.photos.views.TiledImageRenderer.TileSource} using
+ * {@link BitmapRegionDecoder} to wrap a local file
+ */
+@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
public class BitmapRegionTileSource implements TiledImageRenderer.TileSource {
+ private static final String TAG = "BitmapRegionTileSource";
+
+ private static final boolean REUSE_BITMAP =
+ Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
+ private static final int GL_SIZE_LIMIT = 2048;
+ // This must be no larger than half the size of the GL_SIZE_LIMIT
+ // due to decodePreview being allowed to be up to 2x the size of the target
+ private static final int MAX_PREVIEW_SIZE = 1024;
+
BitmapRegionDecoder mDecoder;
+ int mWidth;
+ int mHeight;
+ int mTileSize;
+ private BasicTexture mPreview;
+ private final int mRotation;
+ // For use only by getTile
+ private Rect mWantRegion = new Rect();
+ private Rect mOverlapRegion = new Rect();
+ private BitmapFactory.Options mOptions;
+ private Canvas mCanvas;
- public BitmapRegionTileSource(String path) {
+ public BitmapRegionTileSource(Context context, String path, int previewSize, int rotation) {
+ mTileSize = TiledImageRenderer.suggestedTileSize(context);
+ mRotation = rotation;
try {
mDecoder = BitmapRegionDecoder.newInstance(path, true);
+ mWidth = mDecoder.getWidth();
+ mHeight = mDecoder.getHeight();
} catch (IOException e) {
Log.w("BitmapRegionTileSource", "ctor failed", e);
}
+ mOptions = new BitmapFactory.Options();
+ mOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
+ mOptions.inPreferQualityOverSpeed = true;
+ mOptions.inTempStorage = new byte[16 * 1024];
+ if (previewSize != 0) {
+ previewSize = Math.min(previewSize, MAX_PREVIEW_SIZE);
+ // Although this is the same size as the Bitmap that is likely already
+ // loaded, the lifecycle is different and interactions are on a different
+ // thread. Thus to simplify, this source will decode its own bitmap.
+ Bitmap preview = decodePreview(path, previewSize);
+ if (preview.getWidth() <= GL_SIZE_LIMIT && preview.getHeight() <= GL_SIZE_LIMIT) {
+ mPreview = new BitmapTexture(preview);
+ } else {
+ Log.w(TAG, String.format(
+ "Failed to create preview of apropriate size! "
+ + " in: %dx%d, out: %dx%d",
+ mWidth, mHeight,
+ preview.getWidth(), preview.getHeight()));
+ }
+ }
}
@Override
public int getTileSize() {
- return 256;
+ return mTileSize;
}
@Override
public int getImageWidth() {
- return mDecoder.getWidth();
+ return mWidth;
}
@Override
public int getImageHeight() {
- return mDecoder.getHeight();
+ return mHeight;
+ }
+
+ @Override
+ public BasicTexture getPreview() {
+ return mPreview;
+ }
+
+ @Override
+ public int getRotation() {
+ return mRotation;
}
@Override
public Bitmap getTile(int level, int x, int y, Bitmap bitmap) {
int tileSize = getTileSize();
- int t = tileSize << level;
+ if (!REUSE_BITMAP) {
+ return getTileWithoutReusingBitmap(level, x, y, tileSize);
+ }
- Rect wantRegion = new Rect(x, y, x + t, y + t);
+ int t = tileSize << level;
+ mWantRegion.set(x, y, x + t, y + t);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(tileSize, tileSize, Bitmap.Config.ARGB_8888);
}
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- options.inPreferQualityOverSpeed = true;
- options.inSampleSize = (1 << level);
- options.inBitmap = bitmap;
+ mOptions.inSampleSize = (1 << level);
+ mOptions.inBitmap = bitmap;
try {
- // In CropImage, we may call the decodeRegion() concurrently.
- bitmap = mDecoder.decodeRegion(wantRegion, options);
+ bitmap = mDecoder.decodeRegion(mWantRegion, mOptions);
} finally {
- if (options.inBitmap != bitmap && options.inBitmap != null) {
- options.inBitmap = null;
+ if (mOptions.inBitmap != bitmap && mOptions.inBitmap != null) {
+ mOptions.inBitmap = null;
}
}
@@ -84,4 +151,68 @@
}
return bitmap;
}
+
+ private Bitmap getTileWithoutReusingBitmap(
+ int level, int x, int y, int tileSize) {
+
+ int t = tileSize << level;
+ mWantRegion.set(x, y, x + t, y + t);
+
+ mOverlapRegion.set(0, 0, mWidth, mHeight);
+
+ mOptions.inSampleSize = (1 << level);
+ Bitmap bitmap = mDecoder.decodeRegion(mOverlapRegion, mOptions);
+
+ if (bitmap == null) {
+ Log.w(TAG, "fail in decoding region");
+ }
+
+ if (mWantRegion.equals(mOverlapRegion)) {
+ return bitmap;
+ }
+
+ Bitmap result = Bitmap.createBitmap(tileSize, tileSize, Config.ARGB_8888);
+ if (mCanvas == null) {
+ mCanvas = new Canvas();
+ }
+ mCanvas.setBitmap(result);
+ mCanvas.drawBitmap(bitmap,
+ (mOverlapRegion.left - mWantRegion.left) >> level,
+ (mOverlapRegion.top - mWantRegion.top) >> level, null);
+ mCanvas.setBitmap(null);
+ return result;
+ }
+
+ /**
+ * Note that the returned bitmap may have a long edge that's longer
+ * than the targetSize, but it will always be less than 2x the targetSize
+ */
+ private Bitmap decodePreview(String file, int targetSize) {
+ float scale = (float) targetSize / Math.max(mWidth, mHeight);
+ mOptions.inSampleSize = BitmapUtils.computeSampleSizeLarger(scale);
+ mOptions.inJustDecodeBounds = false;
+
+ Bitmap result = BitmapFactory.decodeFile(file, mOptions);
+ if (result == null) {
+ return null;
+ }
+
+ // We need to resize down if the decoder does not support inSampleSize
+ // or didn't support the specified inSampleSize (some decoders only do powers of 2)
+ scale = (float) targetSize / (float) (Math.max(result.getWidth(), result.getHeight()));
+
+ if (scale <= 0.5) {
+ result = BitmapUtils.resizeBitmapByScale(result, scale, true);
+ }
+ return ensureGLCompatibleBitmap(result);
+ }
+
+ private static Bitmap ensureGLCompatibleBitmap(Bitmap bitmap) {
+ if (bitmap == null || bitmap.getConfig() != null) {
+ return bitmap;
+ }
+ Bitmap newBitmap = bitmap.copy(Config.ARGB_8888, false);
+ bitmap.recycle();
+ return newBitmap;
+ }
}
diff --git a/src/com/android/photos/FullscreenViewer.java b/src/com/android/photos/FullscreenViewer.java
index 50ea1ba..a376139 100644
--- a/src/com/android/photos/FullscreenViewer.java
+++ b/src/com/android/photos/FullscreenViewer.java
@@ -31,7 +31,7 @@
String path = getIntent().getData().toString();
mTextureView = new TiledImageView(this);
- mTextureView.setTileSource(new BitmapRegionTileSource(path));
+ mTextureView.setTileSource(new BitmapRegionTileSource(this, path, 0, 0), null);
setContentView(mTextureView);
}
diff --git a/src/com/android/photos/GalleryActivity.java b/src/com/android/photos/GalleryActivity.java
index 710767d..f3279fe 100644
--- a/src/com/android/photos/GalleryActivity.java
+++ b/src/com/android/photos/GalleryActivity.java
@@ -29,7 +29,6 @@
import android.view.MenuItem;
import android.view.ViewGroup;
-import com.android.camera.CameraActivity;
import com.android.gallery3d.R;
import java.util.ArrayList;
@@ -80,10 +79,12 @@
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_camera:
- Intent intent = new Intent(this, CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- return true;
+ // TODO: Call the correct Camera intent.
+ throw new RuntimeException("Not implemented yet.");
+// Intent intent = new Intent(this, CameraActivity.class);
+// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+// startActivity(intent);
+// return true;
default:
return super.onOptionsItemSelected(item);
}
diff --git a/src/com/android/photos/MultiChoiceManager.java b/src/com/android/photos/MultiChoiceManager.java
index f315cf9..49519ca 100644
--- a/src/com/android/photos/MultiChoiceManager.java
+++ b/src/com/android/photos/MultiChoiceManager.java
@@ -35,6 +35,7 @@
import com.android.gallery3d.app.TrimVideo;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.crop.CropActivity;
import com.android.gallery3d.util.GalleryUtils;
import java.util.ArrayList;
@@ -239,7 +240,7 @@
case R.id.menu_crop:
intent.setDataAndType(uri, mime)
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
- .setAction(FilterShowActivity.CROP_ACTION)
+ .setAction(CropActivity.CROP_ACTION)
.setClass(mContext, FilterShowActivity.class);
mContext.startActivity(intent);
return;
diff --git a/src/com/android/photos/PhotoSetFragment.java b/src/com/android/photos/PhotoSetFragment.java
index 961fd0b..7ce876f 100644
--- a/src/com/android/photos/PhotoSetFragment.java
+++ b/src/com/android/photos/PhotoSetFragment.java
@@ -28,7 +28,7 @@
import android.view.ViewGroup;
import android.widget.GridView;
-import com.android.gallery3d.app.Gallery;
+import com.android.gallery3d.app.GalleryActivity;
import com.android.photos.adapters.PhotoThumbnailAdapter;
import com.android.photos.data.PhotoSetLoader;
import com.android.photos.shims.LoaderCompatShim;
@@ -74,7 +74,7 @@
Cursor item = (Cursor) getItemAtPosition(position);
Uri uri = mLoaderCompatShim.uriForItem(item);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- intent.setClass(getActivity(), Gallery.class);
+ intent.setClass(getActivity(), GalleryActivity.class);
startActivity(intent);
}
diff --git a/src/com/android/photos/data/BitmapDecoder.java b/src/com/android/photos/data/BitmapDecoder.java
deleted file mode 100644
index a0ab410..0000000
--- a/src/com/android/photos/data/BitmapDecoder.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.BitmapFactory;
-import android.util.Log;
-import android.util.Pools.Pool;
-import android.util.Pools.SynchronizedPool;
-
-import com.android.gallery3d.common.Utils;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * BitmapDecoder keeps a pool of temporary storage to reuse for decoding
- * bitmaps. It also simplifies the multi-stage decoding required to efficiently
- * use GalleryBitmapPool. The static methods decode and decodeFile can be used
- * to decode a bitmap from GalleryBitmapPool. The bitmap may be returned
- * directly to GalleryBitmapPool or use the put method here when the bitmap is
- * ready to be recycled.
- */
-public class BitmapDecoder {
- private static final String TAG = BitmapDecoder.class.getSimpleName();
- private static final int POOL_SIZE = 4;
- private static final int TEMP_STORAGE_SIZE_BYTES = 16 * 1024;
- private static final int HEADER_MAX_SIZE = 16 * 1024;
-
- private static final Pool<BitmapFactory.Options> sOptions =
- new SynchronizedPool<BitmapFactory.Options>(POOL_SIZE);
-
- public static Bitmap decode(InputStream in) {
- BitmapFactory.Options opts = getOptions();
- try {
- if (!in.markSupported()) {
- in = new BufferedInputStream(in);
- }
- opts.inJustDecodeBounds = true;
- in.mark(HEADER_MAX_SIZE);
- BitmapFactory.decodeStream(in, null, opts);
- in.reset();
- opts.inJustDecodeBounds = false;
- GalleryBitmapPool pool = GalleryBitmapPool.getInstance();
- Bitmap reuseBitmap = pool.get(opts.outWidth, opts.outHeight);
- opts.inBitmap = reuseBitmap;
- Bitmap decodedBitmap = BitmapFactory.decodeStream(in, null, opts);
- if (reuseBitmap != null && decodedBitmap != reuseBitmap) {
- pool.put(reuseBitmap);
- }
- return decodedBitmap;
- } catch (IOException e) {
- Log.e(TAG, "Could not decode stream to bitmap", e);
- return null;
- } finally {
- Utils.closeSilently(in);
- release(opts);
- }
- }
-
- public static Bitmap decode(File in) {
- return decodeFile(in.toString());
- }
-
- public static Bitmap decodeFile(String in) {
- BitmapFactory.Options opts = getOptions();
- try {
- opts.inJustDecodeBounds = true;
- BitmapFactory.decodeFile(in, opts);
- opts.inJustDecodeBounds = false;
- GalleryBitmapPool pool = GalleryBitmapPool.getInstance();
- Bitmap reuseBitmap = pool.get(opts.outWidth, opts.outHeight);
- opts.inBitmap = reuseBitmap;
- Bitmap decodedBitmap = BitmapFactory.decodeFile(in, opts);
- if (reuseBitmap != null && decodedBitmap != reuseBitmap) {
- pool.put(reuseBitmap);
- }
- return decodedBitmap;
- } finally {
- release(opts);
- }
- }
-
- public static void put(Bitmap bitmap) {
- GalleryBitmapPool.getInstance().put(bitmap);
- }
-
- private static BitmapFactory.Options getOptions() {
- BitmapFactory.Options opts = sOptions.acquire();
- if (opts == null) {
- opts = new BitmapFactory.Options();
- opts.inMutable = true;
- opts.inPreferredConfig = Config.ARGB_8888;
- opts.inSampleSize = 1;
- opts.inTempStorage = new byte[TEMP_STORAGE_SIZE_BYTES];
- }
-
- return opts;
- }
-
- private static void release(BitmapFactory.Options opts) {
- opts.inBitmap = null;
- opts.inJustDecodeBounds = false;
- sOptions.release(opts);
- }
-}
diff --git a/src/com/android/photos/data/FileRetriever.java b/src/com/android/photos/data/FileRetriever.java
deleted file mode 100644
index eb7686e..0000000
--- a/src/com/android/photos/data/FileRetriever.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.graphics.Bitmap;
-import android.media.ExifInterface;
-import android.net.Uri;
-import android.util.Log;
-import android.webkit.MimeTypeMap;
-
-import com.android.gallery3d.common.BitmapUtils;
-
-import java.io.File;
-import java.io.IOException;
-
-public class FileRetriever implements MediaRetriever {
- private static final String TAG = FileRetriever.class.getSimpleName();
-
- @Override
- public File getLocalFile(Uri contentUri) {
- return new File(contentUri.getPath());
- }
-
- @Override
- public MediaSize getFastImageSize(Uri contentUri, MediaSize size) {
- if (isVideo(contentUri)) {
- return null;
- }
- return MediaSize.TemporaryThumbnail;
- }
-
- @Override
- public byte[] getTemporaryImage(Uri contentUri, MediaSize fastImageSize) {
-
- try {
- ExifInterface exif = new ExifInterface(contentUri.getPath());
- if (exif.hasThumbnail()) {
- return exif.getThumbnail();
- }
- } catch (IOException e) {
- Log.w(TAG, "Unable to load exif for " + contentUri);
- }
- return null;
- }
-
- @Override
- public boolean getMedia(Uri contentUri, MediaSize imageSize, File tempFile) {
- if (imageSize == MediaSize.Original) {
- return false; // getLocalFile should always return the original.
- }
- if (imageSize == MediaSize.Thumbnail) {
- File preview = MediaCache.getInstance().getCachedFile(contentUri, MediaSize.Preview);
- if (preview != null) {
- // Just downsample the preview, it is faster.
- return MediaCacheUtils.downsample(preview, imageSize, tempFile);
- }
- }
- File highRes = new File(contentUri.getPath());
- boolean success;
- if (!isVideo(contentUri)) {
- success = MediaCacheUtils.downsample(highRes, imageSize, tempFile);
- } else {
- // Video needs to extract the bitmap.
- Bitmap bitmap = BitmapUtils.createVideoThumbnail(highRes.getPath());
- if (bitmap == null) {
- return false;
- } else if (imageSize == MediaSize.Thumbnail
- && !MediaCacheUtils.needsDownsample(bitmap, MediaSize.Preview)
- && MediaCacheUtils.writeToFile(bitmap, tempFile)) {
- // Opportunistically save preview
- MediaCache mediaCache = MediaCache.getInstance();
- mediaCache.insertIntoCache(contentUri, MediaSize.Preview, tempFile);
- }
- // Now scale the image
- success = MediaCacheUtils.downsample(bitmap, imageSize, tempFile);
- }
- return success;
- }
-
- @Override
- public Uri normalizeUri(Uri contentUri, MediaSize size) {
- return contentUri;
- }
-
- @Override
- public MediaSize normalizeMediaSize(Uri contentUri, MediaSize size) {
- return size;
- }
-
- private static boolean isVideo(Uri uri) {
- MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
- String extension = MimeTypeMap.getFileExtensionFromUrl(uri.toString());
- String mimeType = mimeTypeMap.getMimeTypeFromExtension(extension);
- return (mimeType != null && mimeType.startsWith("video/"));
- }
-}
diff --git a/src/com/android/photos/data/GalleryBitmapPool.java b/src/com/android/photos/data/GalleryBitmapPool.java
index aca3e4b..390a0d4 100644
--- a/src/com/android/photos/data/GalleryBitmapPool.java
+++ b/src/com/android/photos/data/GalleryBitmapPool.java
@@ -23,9 +23,25 @@
import com.android.photos.data.SparseArrayBitmapPool.Node;
+/**
+ * Pool allowing the efficient reuse of bitmaps in order to avoid long
+ * garbage collection pauses.
+ */
public class GalleryBitmapPool {
private static final int CAPACITY_BYTES = 20971520;
+
+ // We found that Gallery uses bitmaps that are either square (for example,
+ // tiles of large images or square thumbnails), match one of the common
+ // photo aspect ratios (4x3, 3x2, or 16x9), or, less commonly, are of some
+ // other aspect ratio. Taking advantage of this information, we use 3
+ // SparseArrayBitmapPool instances to back the GalleryBitmapPool, which affords
+ // O(1) lookups for square bitmaps, and average-case - but *not* asymptotically -
+ // O(1) lookups for common photo aspect ratios and other miscellaneous aspect
+ // ratios. Beware of the pathological case where there are many bitmaps added
+ // to the pool with different non-square aspect ratios but the same width, as
+ // performance will degrade and the average case lookup will approach
+ // O(# of different aspect ratios).
private static final int POOL_INDEX_NONE = -1;
private static final int POOL_INDEX_SQUARE = 0;
private static final int POOL_INDEX_PHOTO = 1;
@@ -84,11 +100,20 @@
return POOL_INDEX_MISC;
}
+ /**
+ * @return Capacity of the pool in bytes.
+ */
public synchronized int getCapacity() {
return mCapacityBytes;
}
- public synchronized int getSize() {
+ /**
+ * @return Approximate total size in bytes of the bitmaps stored in the pool.
+ */
+ public int getSize() {
+ // Note that this only returns an approximate size, since multiple threads
+ // might be getting and putting Bitmaps from the pool and we lock at the
+ // sub-pool level to avoid unnecessary blocking.
int total = 0;
for (SparseArrayBitmapPool p : mPools) {
total += p.getSize();
@@ -96,6 +121,9 @@
return total;
}
+ /**
+ * @return Bitmap from the pool with the desired height/width or null if none available.
+ */
public Bitmap get(int width, int height) {
SparseArrayBitmapPool pool = getPoolForDimensions(width, height);
if (pool == null) {
@@ -105,6 +133,10 @@
}
}
+ /**
+ * Adds the given bitmap to the pool.
+ * @return Whether the bitmap was added to the pool.
+ */
public boolean put(Bitmap b) {
if (b == null || b.getConfig() != Bitmap.Config.ARGB_8888) {
return false;
@@ -118,6 +150,9 @@
}
}
+ /**
+ * Empty the pool, recycling all the bitmaps currently in it.
+ */
public void clear() {
for (SparseArrayBitmapPool p : mPools) {
p.clear();
diff --git a/src/com/android/photos/data/MediaCache.java b/src/com/android/photos/data/MediaCache.java
deleted file mode 100644
index 0952a40..0000000
--- a/src/com/android/photos/data/MediaCache.java
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
-import android.os.Environment;
-import android.util.Log;
-
-import com.android.photos.data.MediaCacheDatabase.Action;
-import com.android.photos.data.MediaRetriever.MediaSize;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-
-/**
- * MediaCache keeps a cache of images, videos, thumbnails and previews. Calls to
- * retrieve a specific media item are executed asynchronously. The caller has an
- * option to receive a notification for lower resolution images that happen to
- * be available prior to the one requested.
- * <p>
- * When an media item has been retrieved, the notification for it is called on a
- * separate notifier thread. This thread should not be held for a long time so
- * that other notifications may happen.
- * </p>
- * <p>
- * Media items are uniquely identified by their content URIs. Each
- * scheme/authority can offer its own MediaRetriever, running in its own thread.
- * </p>
- * <p>
- * The MediaCache is an LRU cache, but does not allow the thumbnail cache to
- * drop below a minimum size. This prevents browsing through original images to
- * wipe out the thumbnails.
- * </p>
- */
-public class MediaCache {
- static final String TAG = MediaCache.class.getSimpleName();
- /** Subdirectory containing the image cache. */
- static final String IMAGE_CACHE_SUBDIR = "image_cache";
- /** File name extension to use for cached images. */
- static final String IMAGE_EXTENSION = ".cache";
- /** File name extension to use for temporary cached images while retrieving. */
- static final String TEMP_IMAGE_EXTENSION = ".temp";
-
- public static interface ImageReady {
- void imageReady(InputStream bitmapInputStream);
- }
-
- public static interface OriginalReady {
- void originalReady(File originalFile);
- }
-
- /** A Thread for each MediaRetriever */
- private class ProcessQueue extends Thread {
- private Queue<ProcessingJob> mQueue;
-
- public ProcessQueue(Queue<ProcessingJob> queue) {
- mQueue = queue;
- }
-
- @Override
- public void run() {
- while (mRunning) {
- ProcessingJob status;
- synchronized (mQueue) {
- while (mQueue.isEmpty()) {
- try {
- mQueue.wait();
- } catch (InterruptedException e) {
- if (!mRunning) {
- return;
- }
- Log.w(TAG, "Unexpected interruption", e);
- }
- }
- status = mQueue.remove();
- }
- processTask(status);
- }
- }
- };
-
- private interface NotifyReady {
- void notifyReady();
-
- void setFile(File file) throws FileNotFoundException;
-
- boolean isPrefetch();
- }
-
- private static class NotifyOriginalReady implements NotifyReady {
- private final OriginalReady mCallback;
- private File mFile;
-
- public NotifyOriginalReady(OriginalReady callback) {
- mCallback = callback;
- }
-
- @Override
- public void notifyReady() {
- if (mCallback != null) {
- mCallback.originalReady(mFile);
- }
- }
-
- @Override
- public void setFile(File file) {
- mFile = file;
- }
-
- @Override
- public boolean isPrefetch() {
- return mCallback == null;
- }
- }
-
- private static class NotifyImageReady implements NotifyReady {
- private final ImageReady mCallback;
- private InputStream mInputStream;
-
- public NotifyImageReady(ImageReady callback) {
- mCallback = callback;
- }
-
- @Override
- public void notifyReady() {
- if (mCallback != null) {
- mCallback.imageReady(mInputStream);
- }
- }
-
- @Override
- public void setFile(File file) throws FileNotFoundException {
- mInputStream = new FileInputStream(file);
- }
-
- public void setBytes(byte[] bytes) {
- mInputStream = new ByteArrayInputStream(bytes);
- }
-
- @Override
- public boolean isPrefetch() {
- return mCallback == null;
- }
- }
-
- /** A media item to be retrieved and its notifications. */
- private static class ProcessingJob {
- public ProcessingJob(Uri uri, MediaSize size, NotifyReady complete,
- NotifyImageReady lowResolution) {
- this.contentUri = uri;
- this.size = size;
- this.complete = complete;
- this.lowResolution = lowResolution;
- }
- public Uri contentUri;
- public MediaSize size;
- public NotifyImageReady lowResolution;
- public NotifyReady complete;
- }
-
- private boolean mRunning = true;
- private static MediaCache sInstance;
- private File mCacheDir;
- private Context mContext;
- private Queue<NotifyReady> mCallbacks = new LinkedList<NotifyReady>();
- private Map<String, MediaRetriever> mRetrievers = new HashMap<String, MediaRetriever>();
- private Map<String, List<ProcessingJob>> mTasks = new HashMap<String, List<ProcessingJob>>();
- private List<ProcessQueue> mProcessingThreads = new ArrayList<ProcessQueue>();
- private MediaCacheDatabase mDatabaseHelper;
- private long mTempImageNumber = 1;
- private Object mTempImageNumberLock = new Object();
-
- private long mMaxCacheSize = 40 * 1024 * 1024; // 40 MB
- private long mMinThumbCacheSize = 4 * 1024 * 1024; // 4 MB
- private long mCacheSize = -1;
- private long mThumbCacheSize = -1;
- private Object mCacheSizeLock = new Object();
-
- private Action mNotifyCachedLowResolution = new Action() {
- @Override
- public void execute(Uri uri, long id, MediaSize size, Object parameter) {
- ProcessingJob job = (ProcessingJob) parameter;
- File file = createCacheImagePath(id);
- addNotification(job.lowResolution, file);
- }
- };
-
- private Action mMoveTempToCache = new Action() {
- @Override
- public void execute(Uri uri, long id, MediaSize size, Object parameter) {
- File tempFile = (File) parameter;
- File cacheFile = createCacheImagePath(id);
- tempFile.renameTo(cacheFile);
- }
- };
-
- private Action mDeleteFile = new Action() {
- @Override
- public void execute(Uri uri, long id, MediaSize size, Object parameter) {
- File file = createCacheImagePath(id);
- file.delete();
- synchronized (mCacheSizeLock) {
- if (mCacheSize != -1) {
- long length = (Long) parameter;
- mCacheSize -= length;
- if (size == MediaSize.Thumbnail) {
- mThumbCacheSize -= length;
- }
- }
- }
- }
- };
-
- /** The thread used to make ImageReady and OriginalReady callbacks. */
- private Thread mProcessNotifications = new Thread() {
- @Override
- public void run() {
- while (mRunning) {
- NotifyReady notifyImage;
- synchronized (mCallbacks) {
- while (mCallbacks.isEmpty()) {
- try {
- mCallbacks.wait();
- } catch (InterruptedException e) {
- if (!mRunning) {
- return;
- }
- Log.w(TAG, "Unexpected Interruption, continuing");
- }
- }
- notifyImage = mCallbacks.remove();
- }
-
- notifyImage.notifyReady();
- }
- }
- };
-
- public static synchronized void initialize(Context context) {
- if (sInstance == null) {
- sInstance = new MediaCache(context);
- MediaCacheUtils.initialize(context);
- }
- }
-
- public static MediaCache getInstance() {
- return sInstance;
- }
-
- public static synchronized void shutdown() {
- sInstance.mRunning = false;
- sInstance.mProcessNotifications.interrupt();
- for (ProcessQueue processingThread : sInstance.mProcessingThreads) {
- processingThread.interrupt();
- }
- sInstance = null;
- }
-
- private MediaCache(Context context) {
- mDatabaseHelper = new MediaCacheDatabase(context);
- mProcessNotifications.start();
- mContext = context;
- }
-
- // This is used for testing.
- public void setCacheDir(File cacheDir) {
- cacheDir.mkdirs();
- mCacheDir = cacheDir;
- }
-
- public File getCacheDir() {
- synchronized (mContext) {
- if (mCacheDir == null) {
- String state = Environment.getExternalStorageState();
- File baseDir;
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- baseDir = mContext.getExternalCacheDir();
- } else {
- // Stored in internal cache
- baseDir = mContext.getCacheDir();
- }
- mCacheDir = new File(baseDir, IMAGE_CACHE_SUBDIR);
- mCacheDir.mkdirs();
- }
- return mCacheDir;
- }
- }
-
- /**
- * Invalidates all cached images related to a given contentUri. This call
- * doesn't complete until the images have been removed from the cache.
- */
- public void invalidate(Uri contentUri) {
- mDatabaseHelper.delete(contentUri, mDeleteFile);
- }
-
- public void clearCacheDir() {
- File[] cachedFiles = getCacheDir().listFiles();
- if (cachedFiles != null) {
- for (File cachedFile : cachedFiles) {
- cachedFile.delete();
- }
- }
- }
-
- /**
- * Add a MediaRetriever for a Uri scheme and authority. This MediaRetriever
- * will be granted its own thread for retrieving images.
- */
- public void addRetriever(String scheme, String authority, MediaRetriever retriever) {
- String differentiator = getDifferentiator(scheme, authority);
- synchronized (mRetrievers) {
- mRetrievers.put(differentiator, retriever);
- }
- synchronized (mTasks) {
- LinkedList<ProcessingJob> queue = new LinkedList<ProcessingJob>();
- mTasks.put(differentiator, queue);
- new ProcessQueue(queue).start();
- }
- }
-
- /**
- * Retrieves a thumbnail. complete will be called when the thumbnail is
- * available. If lowResolution is not null and a lower resolution thumbnail
- * is available before the thumbnail, lowResolution will be called prior to
- * complete. All callbacks will be made on a thread other than the calling
- * thread.
- *
- * @param contentUri The URI for the full resolution image to search for.
- * @param complete Callback for when the image has been retrieved.
- * @param lowResolution If not null and a lower resolution image is
- * available prior to retrieving the thumbnail, this will be
- * called with the low resolution bitmap.
- */
- public void retrieveThumbnail(Uri contentUri, ImageReady complete, ImageReady lowResolution) {
- addTask(contentUri, complete, lowResolution, MediaSize.Thumbnail);
- }
-
- /**
- * Retrieves a preview. complete will be called when the preview is
- * available. If lowResolution is not null and a lower resolution preview is
- * available before the preview, lowResolution will be called prior to
- * complete. All callbacks will be made on a thread other than the calling
- * thread.
- *
- * @param contentUri The URI for the full resolution image to search for.
- * @param complete Callback for when the image has been retrieved.
- * @param lowResolution If not null and a lower resolution image is
- * available prior to retrieving the preview, this will be called
- * with the low resolution bitmap.
- */
- public void retrievePreview(Uri contentUri, ImageReady complete, ImageReady lowResolution) {
- addTask(contentUri, complete, lowResolution, MediaSize.Preview);
- }
-
- /**
- * Retrieves the original image or video. complete will be called when the
- * media is available on the local file system. If lowResolution is not null
- * and a lower resolution preview is available before the original,
- * lowResolution will be called prior to complete. All callbacks will be
- * made on a thread other than the calling thread.
- *
- * @param contentUri The URI for the full resolution image to search for.
- * @param complete Callback for when the image has been retrieved.
- * @param lowResolution If not null and a lower resolution image is
- * available prior to retrieving the preview, this will be called
- * with the low resolution bitmap.
- */
- public void retrieveOriginal(Uri contentUri, OriginalReady complete, ImageReady lowResolution) {
- File localFile = getLocalFile(contentUri);
- if (localFile != null) {
- addNotification(new NotifyOriginalReady(complete), localFile);
- } else {
- NotifyImageReady notifyLowResolution = (lowResolution == null) ? null
- : new NotifyImageReady(lowResolution);
- addTask(contentUri, new NotifyOriginalReady(complete), notifyLowResolution,
- MediaSize.Original);
- }
- }
-
- /**
- * Looks for an already cached media at a specific size.
- *
- * @param contentUri The original media item content URI
- * @param size The target size to search for in the cache
- * @return The cached file location or null if it is not cached.
- */
- public File getCachedFile(Uri contentUri, MediaSize size) {
- Long cachedId = mDatabaseHelper.getCached(contentUri, size);
- File file = null;
- if (cachedId != null) {
- file = createCacheImagePath(cachedId);
- if (!file.exists()) {
- mDatabaseHelper.delete(contentUri, size, mDeleteFile);
- file = null;
- }
- }
- return file;
- }
-
- /**
- * Inserts a media item into the cache.
- *
- * @param contentUri The original media item URI.
- * @param size The size of the media item to store in the cache.
- * @param tempFile The temporary file where the image is stored. This file
- * will no longer exist after executing this method.
- * @return The new location, in the cache, of the media item or null if it
- * wasn't possible to move into the cache.
- */
- public File insertIntoCache(Uri contentUri, MediaSize size, File tempFile) {
- long fileSize = tempFile.length();
- if (fileSize == 0) {
- return null;
- }
- File cacheFile = null;
- SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
- // Ensure that this step is atomic
- db.beginTransaction();
- try {
- Long id = mDatabaseHelper.getCached(contentUri, size);
- if (id != null) {
- cacheFile = createCacheImagePath(id);
- if (tempFile.renameTo(cacheFile)) {
- mDatabaseHelper.updateLength(id, fileSize);
- } else {
- Log.w(TAG, "Could not update cached file with " + tempFile);
- tempFile.delete();
- cacheFile = null;
- }
- } else {
- ensureFreeCacheSpace(tempFile.length(), size);
- id = mDatabaseHelper.insert(contentUri, size, mMoveTempToCache, tempFile);
- cacheFile = createCacheImagePath(id);
- }
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- return cacheFile;
- }
-
- /**
- * For testing purposes.
- */
- public void setMaxCacheSize(long maxCacheSize) {
- synchronized (mCacheSizeLock) {
- mMaxCacheSize = maxCacheSize;
- mMinThumbCacheSize = mMaxCacheSize / 10;
- mCacheSize = -1;
- mThumbCacheSize = -1;
- }
- }
-
- private File createCacheImagePath(long id) {
- return new File(getCacheDir(), String.valueOf(id) + IMAGE_EXTENSION);
- }
-
- private void addTask(Uri contentUri, ImageReady complete, ImageReady lowResolution,
- MediaSize size) {
- NotifyReady notifyComplete = new NotifyImageReady(complete);
- NotifyImageReady notifyLowResolution = null;
- if (lowResolution != null) {
- notifyLowResolution = new NotifyImageReady(lowResolution);
- }
- addTask(contentUri, notifyComplete, notifyLowResolution, size);
- }
-
- private void addTask(Uri contentUri, NotifyReady complete, NotifyImageReady lowResolution,
- MediaSize size) {
- MediaRetriever retriever = getMediaRetriever(contentUri);
- Uri uri = retriever.normalizeUri(contentUri, size);
- if (uri == null) {
- throw new IllegalArgumentException("No MediaRetriever for " + contentUri);
- }
- size = retriever.normalizeMediaSize(uri, size);
-
- File cachedFile = getCachedFile(uri, size);
- if (cachedFile != null) {
- addNotification(complete, cachedFile);
- return;
- }
- String differentiator = getDifferentiator(uri.getScheme(), uri.getAuthority());
- synchronized (mTasks) {
- List<ProcessingJob> tasks = mTasks.get(differentiator);
- if (tasks == null) {
- throw new IllegalArgumentException("Cannot find retriever for: " + uri);
- }
- synchronized (tasks) {
- ProcessingJob job = new ProcessingJob(uri, size, complete, lowResolution);
- if (complete.isPrefetch()) {
- tasks.add(job);
- } else {
- int index = tasks.size() - 1;
- while (index >= 0 && tasks.get(index).complete.isPrefetch()) {
- index--;
- }
- tasks.add(index + 1, job);
- }
- tasks.notifyAll();
- }
- }
- }
-
- private MediaRetriever getMediaRetriever(Uri uri) {
- String differentiator = getDifferentiator(uri.getScheme(), uri.getAuthority());
- MediaRetriever retriever;
- synchronized (mRetrievers) {
- retriever = mRetrievers.get(differentiator);
- }
- if (retriever == null) {
- throw new IllegalArgumentException("No MediaRetriever for " + uri);
- }
- return retriever;
- }
-
- private File getLocalFile(Uri uri) {
- MediaRetriever retriever = getMediaRetriever(uri);
- File localFile = null;
- if (retriever != null) {
- localFile = retriever.getLocalFile(uri);
- }
- return localFile;
- }
-
- private MediaSize getFastImageSize(Uri uri, MediaSize size) {
- MediaRetriever retriever = getMediaRetriever(uri);
- return retriever.getFastImageSize(uri, size);
- }
-
- private boolean isFastImageBetter(MediaSize fastImageType, MediaSize size) {
- if (fastImageType == null) {
- return false;
- }
- if (size == null) {
- return true;
- }
- return fastImageType.isBetterThan(size);
- }
-
- private byte[] getTemporaryImage(Uri uri, MediaSize fastImageType) {
- MediaRetriever retriever = getMediaRetriever(uri);
- return retriever.getTemporaryImage(uri, fastImageType);
- }
-
- private void processTask(ProcessingJob job) {
- File cachedFile = getCachedFile(job.contentUri, job.size);
- if (cachedFile != null) {
- addNotification(job.complete, cachedFile);
- return;
- }
-
- boolean hasLowResolution = job.lowResolution != null;
- if (hasLowResolution) {
- MediaSize cachedSize = mDatabaseHelper.executeOnBestCached(job.contentUri, job.size,
- mNotifyCachedLowResolution);
- MediaSize fastImageSize = getFastImageSize(job.contentUri, job.size);
- if (isFastImageBetter(fastImageSize, cachedSize)) {
- if (fastImageSize.isTemporary()) {
- byte[] bytes = getTemporaryImage(job.contentUri, fastImageSize);
- if (bytes != null) {
- addNotification(job.lowResolution, bytes);
- }
- } else {
- File lowFile = getMedia(job.contentUri, fastImageSize);
- if (lowFile != null) {
- addNotification(job.lowResolution, lowFile);
- }
- }
- }
- }
-
- // Now get the full size desired
- File fullSizeFile = getMedia(job.contentUri, job.size);
- if (fullSizeFile != null) {
- addNotification(job.complete, fullSizeFile);
- }
- }
-
- private void addNotification(NotifyReady callback, File file) {
- try {
- callback.setFile(file);
- synchronized (mCallbacks) {
- mCallbacks.add(callback);
- mCallbacks.notifyAll();
- }
- } catch (FileNotFoundException e) {
- Log.e(TAG, "Unable to read file " + file, e);
- }
- }
-
- private void addNotification(NotifyImageReady callback, byte[] bytes) {
- callback.setBytes(bytes);
- synchronized (mCallbacks) {
- mCallbacks.add(callback);
- mCallbacks.notifyAll();
- }
- }
-
- private File getMedia(Uri uri, MediaSize size) {
- long imageNumber;
- synchronized (mTempImageNumberLock) {
- imageNumber = mTempImageNumber++;
- }
- File tempFile = new File(getCacheDir(), String.valueOf(imageNumber) + TEMP_IMAGE_EXTENSION);
- MediaRetriever retriever = getMediaRetriever(uri);
- boolean retrieved = retriever.getMedia(uri, size, tempFile);
- File cachedFile = null;
- if (retrieved) {
- ensureFreeCacheSpace(tempFile.length(), size);
- long id = mDatabaseHelper.insert(uri, size, mMoveTempToCache, tempFile);
- cachedFile = createCacheImagePath(id);
- }
- return cachedFile;
- }
-
- private static String getDifferentiator(String scheme, String authority) {
- if (authority == null) {
- return scheme;
- }
- StringBuilder differentiator = new StringBuilder(scheme);
- differentiator.append(':');
- differentiator.append(authority);
- return differentiator.toString();
- }
-
- private void ensureFreeCacheSpace(long size, MediaSize mediaSize) {
- synchronized (mCacheSizeLock) {
- if (mCacheSize == -1 || mThumbCacheSize == -1) {
- mCacheSize = mDatabaseHelper.getCacheSize();
- mThumbCacheSize = mDatabaseHelper.getThumbnailCacheSize();
- if (mCacheSize == -1 || mThumbCacheSize == -1) {
- Log.e(TAG, "Can't determine size of the image cache");
- return;
- }
- }
- mCacheSize += size;
- if (mediaSize == MediaSize.Thumbnail) {
- mThumbCacheSize += size;
- }
- if (mCacheSize > mMaxCacheSize) {
- shrinkCacheLocked();
- }
- }
- }
-
- private void shrinkCacheLocked() {
- long deleteSize = mMinThumbCacheSize;
- boolean includeThumbnails = (mThumbCacheSize - deleteSize) > mMinThumbCacheSize;
- mDatabaseHelper.deleteOldCached(includeThumbnails, deleteSize, mDeleteFile);
- }
-}
diff --git a/src/com/android/photos/data/MediaCacheDatabase.java b/src/com/android/photos/data/MediaCacheDatabase.java
deleted file mode 100644
index c92ac0f..0000000
--- a/src/com/android/photos/data/MediaCacheDatabase.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.net.Uri;
-import android.provider.BaseColumns;
-
-import com.android.photos.data.MediaRetriever.MediaSize;
-
-import java.io.File;
-
-class MediaCacheDatabase extends SQLiteOpenHelper {
- public static final int DB_VERSION = 1;
- public static final String DB_NAME = "mediacache.db";
-
- /** Internal database table used for the media cache */
- public static final String TABLE = "media_cache";
-
- private static interface Columns extends BaseColumns {
- /** The Content URI of the original image. */
- public static final String URI = "uri";
- /** MediaSize.getValue() values. */
- public static final String MEDIA_SIZE = "media_size";
- /** The last time this image was queried. */
- public static final String LAST_ACCESS = "last_access";
- /** The image size in bytes. */
- public static final String SIZE_IN_BYTES = "size";
- }
-
- static interface Action {
- void execute(Uri uri, long id, MediaSize size, Object parameter);
- }
-
- private static final String[] PROJECTION_ID = {
- Columns._ID,
- };
-
- private static final String[] PROJECTION_CACHED = {
- Columns._ID, Columns.MEDIA_SIZE, Columns.SIZE_IN_BYTES,
- };
-
- private static final String[] PROJECTION_CACHE_SIZE = {
- "SUM(" + Columns.SIZE_IN_BYTES + ")"
- };
-
- private static final String[] PROJECTION_DELETE_OLD = {
- Columns._ID, Columns.URI, Columns.MEDIA_SIZE, Columns.SIZE_IN_BYTES, Columns.LAST_ACCESS,
- };
-
- public static final String CREATE_TABLE = "CREATE TABLE " + TABLE + "("
- + Columns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
- + Columns.URI + " TEXT NOT NULL,"
- + Columns.MEDIA_SIZE + " INTEGER NOT NULL,"
- + Columns.LAST_ACCESS + " INTEGER NOT NULL,"
- + Columns.SIZE_IN_BYTES + " INTEGER NOT NULL,"
- + "UNIQUE(" + Columns.URI + ", " + Columns.MEDIA_SIZE + "))";
-
- public static final String DROP_TABLE = "DROP TABLE IF EXISTS " + TABLE;
-
- public static final String WHERE_THUMBNAIL = Columns.MEDIA_SIZE + " = "
- + MediaSize.Thumbnail.getValue();
-
- public static final String WHERE_NOT_THUMBNAIL = Columns.MEDIA_SIZE + " <> "
- + MediaSize.Thumbnail.getValue();
-
- public static final String WHERE_CLEAR_CACHE = Columns.LAST_ACCESS + " <= ?";
-
- public static final String WHERE_CLEAR_CACHE_LARGE = WHERE_CLEAR_CACHE + " AND "
- + WHERE_NOT_THUMBNAIL;
-
- static class QueryCacheResults {
- public QueryCacheResults(long id, int sizeVal) {
- this.id = id;
- this.size = MediaSize.fromInteger(sizeVal);
- }
- public long id;
- public MediaSize size;
- }
-
- public MediaCacheDatabase(Context context) {
- super(context, DB_NAME, null, DB_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(CREATE_TABLE);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- db.execSQL(DROP_TABLE);
- onCreate(db);
- MediaCache.getInstance().clearCacheDir();
- }
-
- public Long getCached(Uri uri, MediaSize size) {
- String where = Columns.URI + " = ? AND " + Columns.MEDIA_SIZE + " = ?";
- SQLiteDatabase db = getWritableDatabase();
- String[] whereArgs = {
- uri.toString(), String.valueOf(size.getValue()),
- };
- Cursor cursor = db.query(TABLE, PROJECTION_ID, where, whereArgs, null, null, null);
- Long id = null;
- if (cursor.moveToNext()) {
- id = cursor.getLong(0);
- }
- cursor.close();
- if (id != null) {
- String[] updateArgs = {
- id.toString()
- };
- ContentValues values = new ContentValues();
- values.put(Columns.LAST_ACCESS, System.currentTimeMillis());
- db.beginTransaction();
- try {
- db.update(TABLE, values, Columns._ID + " = ?", updateArgs);
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- }
- return id;
- }
-
- public MediaSize executeOnBestCached(Uri uri, MediaSize size, Action action) {
- String where = Columns.URI + " = ? AND " + Columns.MEDIA_SIZE + " < ?";
- String orderBy = Columns.MEDIA_SIZE + " DESC";
- SQLiteDatabase db = getReadableDatabase();
- String[] whereArgs = {
- uri.toString(), String.valueOf(size.getValue()),
- };
- Cursor cursor = db.query(TABLE, PROJECTION_CACHED, where, whereArgs, null, null, orderBy);
- MediaSize bestSize = null;
- if (cursor.moveToNext()) {
- long id = cursor.getLong(0);
- bestSize = MediaSize.fromInteger(cursor.getInt(1));
- long fileSize = cursor.getLong(2);
- action.execute(uri, id, bestSize, fileSize);
- }
- cursor.close();
- return bestSize;
- }
-
- public long insert(Uri uri, MediaSize size, Action action, File tempFile) {
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
- try {
- ContentValues values = new ContentValues();
- values.put(Columns.LAST_ACCESS, System.currentTimeMillis());
- values.put(Columns.MEDIA_SIZE, size.getValue());
- values.put(Columns.URI, uri.toString());
- values.put(Columns.SIZE_IN_BYTES, tempFile.length());
- long id = db.insert(TABLE, null, values);
- if (id != -1) {
- action.execute(uri, id, size, tempFile);
- db.setTransactionSuccessful();
- }
- return id;
- } finally {
- db.endTransaction();
- }
- }
-
- public void updateLength(long id, long fileSize) {
- ContentValues values = new ContentValues();
- values.put(Columns.SIZE_IN_BYTES, fileSize);
- String[] whereArgs = {
- String.valueOf(id)
- };
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
- try {
- db.update(TABLE, values, Columns._ID + " = ?", whereArgs);
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- }
-
- public void delete(Uri uri, MediaSize size, Action action) {
- String where = Columns.URI + " = ? AND " + Columns.MEDIA_SIZE + " = ?";
- String[] whereArgs = {
- uri.toString(), String.valueOf(size.getValue()),
- };
- deleteRows(uri, where, whereArgs, action);
- }
-
- public void delete(Uri uri, Action action) {
- String where = Columns.URI + " = ?";
- String[] whereArgs = {
- uri.toString()
- };
- deleteRows(uri, where, whereArgs, action);
- }
-
- private void deleteRows(Uri uri, String where, String[] whereArgs, Action action) {
- SQLiteDatabase db = getWritableDatabase();
- // Make this an atomic operation
- db.beginTransaction();
- Cursor cursor = db.query(TABLE, PROJECTION_CACHED, where, whereArgs, null, null, null);
- while (cursor.moveToNext()) {
- long id = cursor.getLong(0);
- MediaSize size = MediaSize.fromInteger(cursor.getInt(1));
- long length = cursor.getLong(2);
- action.execute(uri, id, size, length);
- }
- cursor.close();
- try {
- db.delete(TABLE, where, whereArgs);
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- }
-
- public void deleteOldCached(boolean includeThumbnails, long deleteSize, Action action) {
- String where = includeThumbnails ? null : WHERE_NOT_THUMBNAIL;
- long lastAccess = 0;
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
- try {
- Cursor cursor = db.query(TABLE, PROJECTION_DELETE_OLD, where, null, null, null,
- Columns.LAST_ACCESS);
- while (cursor.moveToNext()) {
- long id = cursor.getLong(0);
- String uri = cursor.getString(1);
- MediaSize size = MediaSize.fromInteger(cursor.getInt(2));
- long length = cursor.getLong(3);
- long imageLastAccess = cursor.getLong(4);
-
- if (imageLastAccess != lastAccess && deleteSize < 0) {
- break; // We've deleted enough.
- }
- lastAccess = imageLastAccess;
- action.execute(Uri.parse(uri), id, size, length);
- deleteSize -= length;
- }
- cursor.close();
- String[] whereArgs = {
- String.valueOf(lastAccess),
- };
- String whereDelete = includeThumbnails ? WHERE_CLEAR_CACHE : WHERE_CLEAR_CACHE_LARGE;
- db.delete(TABLE, whereDelete, whereArgs);
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- }
-
- public long getCacheSize() {
- return getCacheSize(null);
- }
-
- public long getThumbnailCacheSize() {
- return getCacheSize(WHERE_THUMBNAIL);
- }
-
- private long getCacheSize(String where) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(TABLE, PROJECTION_CACHE_SIZE, where, null, null, null, null);
- long size = -1;
- if (cursor.moveToNext()) {
- size = cursor.getLong(0);
- }
- cursor.close();
- return size;
- }
-}
diff --git a/src/com/android/photos/data/MediaCacheUtils.java b/src/com/android/photos/data/MediaCacheUtils.java
deleted file mode 100644
index e3ccd14..0000000
--- a/src/com/android/photos/data/MediaCacheUtils.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.CompressFormat;
-import android.graphics.BitmapFactory;
-import android.util.Log;
-import android.util.Pools.SimplePool;
-import android.util.Pools.SynchronizedPool;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.common.BitmapUtils;
-import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.data.DecodeUtils;
-import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.util.ThreadPool.CancelListener;
-import com.android.gallery3d.util.ThreadPool.JobContext;
-import com.android.photos.data.MediaRetriever.MediaSize;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class MediaCacheUtils {
- private static final String TAG = MediaCacheUtils.class.getSimpleName();
- private static int QUALITY = 80;
- private static final int BUFFER_SIZE = 4096;
- private static final SimplePool<byte[]> mBufferPool = new SynchronizedPool<byte[]>(5);
-
- private static final JobContext sJobStub = new JobContext() {
-
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- @Override
- public void setCancelListener(CancelListener listener) {
- }
-
- @Override
- public boolean setMode(int mode) {
- return true;
- }
- };
-
- private static int mTargetThumbnailSize;
- private static int mTargetPreviewSize;
-
- public static void initialize(Context context) {
- Resources resources = context.getResources();
- mTargetThumbnailSize = resources.getDimensionPixelSize(R.dimen.size_thumbnail);
- mTargetPreviewSize = resources.getDimensionPixelSize(R.dimen.size_preview);
- }
-
- public static int getTargetSize(MediaSize size) {
- return (size == MediaSize.Thumbnail) ? mTargetThumbnailSize : mTargetPreviewSize;
- }
-
- public static boolean downsample(File inBitmap, MediaSize targetSize, File outBitmap) {
- if (MediaSize.Original == targetSize) {
- return false; // MediaCache should use the local path for this.
- }
- int size = getTargetSize(targetSize);
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- // TODO: remove unnecessary job context from DecodeUtils.
- Bitmap bitmap = DecodeUtils.decodeThumbnail(sJobStub, inBitmap.getPath(), options, size,
- MediaItem.TYPE_THUMBNAIL);
- boolean success = (bitmap != null);
- if (success) {
- success = writeAndRecycle(bitmap, outBitmap);
- }
- return success;
- }
-
- public static boolean downsample(Bitmap inBitmap, MediaSize size, File outBitmap) {
- if (MediaSize.Original == size) {
- return false; // MediaCache should use the local path for this.
- }
- int targetSize = getTargetSize(size);
- boolean success;
- if (!needsDownsample(inBitmap, size)) {
- success = writeAndRecycle(inBitmap, outBitmap);
- } else {
- float maxDimension = Math.max(inBitmap.getWidth(), inBitmap.getHeight());
- float scale = targetSize / maxDimension;
- int targetWidth = Math.round(scale * inBitmap.getWidth());
- int targetHeight = Math.round(scale * inBitmap.getHeight());
- Bitmap scaled = Bitmap.createScaledBitmap(inBitmap, targetWidth, targetHeight, false);
- success = writeAndRecycle(scaled, outBitmap);
- inBitmap.recycle();
- }
- return success;
- }
-
- public static boolean extractImageFromVideo(File inVideo, File outBitmap) {
- Bitmap bitmap = BitmapUtils.createVideoThumbnail(inVideo.getPath());
- return writeAndRecycle(bitmap, outBitmap);
- }
-
- public static boolean needsDownsample(Bitmap bitmap, MediaSize size) {
- if (size == MediaSize.Original) {
- return false;
- }
- int targetSize = getTargetSize(size);
- int maxDimension = Math.max(bitmap.getWidth(), bitmap.getHeight());
- return maxDimension > (targetSize * 4 / 3);
- }
-
- public static boolean writeAndRecycle(Bitmap bitmap, File outBitmap) {
- boolean success = writeToFile(bitmap, outBitmap);
- bitmap.recycle();
- return success;
- }
-
- public static boolean writeToFile(Bitmap bitmap, File outBitmap) {
- boolean success = false;
- try {
- FileOutputStream out = new FileOutputStream(outBitmap);
- success = bitmap.compress(CompressFormat.JPEG, QUALITY, out);
- out.close();
- } catch (IOException e) {
- Log.w(TAG, "Couldn't write bitmap to cache", e);
- // success is already false
- }
- return success;
- }
-
- public static int copyStream(InputStream in, OutputStream out) throws IOException {
- byte[] buffer = mBufferPool.acquire();
- if (buffer == null) {
- buffer = new byte[BUFFER_SIZE];
- }
- try {
- int totalWritten = 0;
- int bytesRead;
- while ((bytesRead = in.read(buffer)) >= 0) {
- out.write(buffer, 0, bytesRead);
- totalWritten += bytesRead;
- }
- return totalWritten;
- } finally {
- Utils.closeSilently(in);
- Utils.closeSilently(out);
- mBufferPool.release(buffer);
- }
- }
-}
diff --git a/src/com/android/photos/data/MediaRetriever.java b/src/com/android/photos/data/MediaRetriever.java
deleted file mode 100644
index f383e5f..0000000
--- a/src/com/android/photos/data/MediaRetriever.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.net.Uri;
-
-import java.io.File;
-
-public interface MediaRetriever {
- public enum MediaSize {
- TemporaryThumbnail(5), Thumbnail(10), TemporaryPreview(15), Preview(20), Original(30);
-
- private final int mValue;
-
- private MediaSize(int value) {
- mValue = value;
- }
-
- public int getValue() {
- return mValue;
- }
-
- static MediaSize fromInteger(int value) {
- switch (value) {
- case 10:
- return MediaSize.Thumbnail;
- case 20:
- return MediaSize.Preview;
- case 30:
- return MediaSize.Original;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- public boolean isBetterThan(MediaSize that) {
- return mValue > that.mValue;
- }
-
- public boolean isTemporary() {
- return this == TemporaryThumbnail || this == TemporaryPreview;
- }
- }
-
- /**
- * Returns the local File for the given Uri. If the image is not stored
- * locally, null should be returned. The image should not be retrieved if it
- * isn't already available.
- *
- * @param contentUri The media URI to search for.
- * @return The local File of the image if it is available or null if it
- * isn't.
- */
- File getLocalFile(Uri contentUri);
-
- /**
- * Returns the fast access image type for a given image size, if supported.
- * This image should be smaller than size and should be quick to retrieve.
- * It does not have to obey the expected aspect ratio.
- *
- * @param contentUri The original media Uri.
- * @param size The target size to search for a fast-access image.
- * @return The fast image type supported for the given image size or null of
- * no fast image is supported.
- */
- MediaSize getFastImageSize(Uri contentUri, MediaSize size);
-
- /**
- * Returns a byte array containing the contents of the fast temporary image
- * for a given image size. For example, a thumbnail may be smaller or of a
- * different aspect ratio than the generated thumbnail.
- *
- * @param contentUri The original media Uri.
- * @param temporarySize The target media size. Guaranteed to be a MediaSize
- * for which isTemporary() returns true.
- * @return A byte array of contents for for the given contentUri and
- * fastImageType. null can be retrieved if the quick retrieval
- * fails.
- */
- byte[] getTemporaryImage(Uri contentUri, MediaSize temporarySize);
-
- /**
- * Retrieves an image and saves it to a file.
- *
- * @param contentUri The original media Uri.
- * @param size The target media size.
- * @param tempFile The file to write the bitmap to.
- * @return <code>true</code> on success.
- */
- boolean getMedia(Uri contentUri, MediaSize imageSize, File tempFile);
-
- /**
- * Normalizes a URI that may have additional parameters. It is fine to
- * return contentUri. This is executed on the calling thread, so it must be
- * a fast access operation and cannot depend, for example, on I/O.
- *
- * @param contentUri The URI to normalize
- * @param size The size of the image being requested
- * @return The normalized URI representation of contentUri.
- */
- Uri normalizeUri(Uri contentUri, MediaSize size);
-
- /**
- * Normalize the MediaSize for a given URI. Typically the size returned
- * would be the passed-in size. Some URIs may only have one size used and
- * should be treaded as Thumbnails, for example. This is executed on the
- * calling thread, so it must be a fast access operation and cannot depend,
- * for example, on I/O.
- *
- * @param contentUri The URI for the size being normalized.
- * @param size The size to be normalized.
- * @return The normalized size of the given URI.
- */
- MediaSize normalizeMediaSize(Uri contentUri, MediaSize size);
-}
diff --git a/src/com/android/photos/data/PhotoDatabase.java b/src/com/android/photos/data/PhotoDatabase.java
index 1f15c5b..0c7b227 100644
--- a/src/com/android/photos/data/PhotoDatabase.java
+++ b/src/com/android/photos/data/PhotoDatabase.java
@@ -34,7 +34,7 @@
public class PhotoDatabase extends SQLiteOpenHelper {
@SuppressWarnings("unused")
private static final String TAG = PhotoDatabase.class.getSimpleName();
- static final int DB_VERSION = 2;
+ static final int DB_VERSION = 3;
private static final String SQL_CREATE_TABLE = "CREATE TABLE ";
@@ -80,7 +80,7 @@
private static final String[][] CREATE_ACCOUNT = {
{ Accounts._ID, "INTEGER PRIMARY KEY AUTOINCREMENT" },
- { Accounts.ACCOUNT_NAME, "TEXT NOT NULL" },
+ { Accounts.ACCOUNT_NAME, "TEXT UNIQUE NOT NULL" },
};
@Override
diff --git a/src/com/android/photos/data/SparseArrayBitmapPool.java b/src/com/android/photos/data/SparseArrayBitmapPool.java
index 1ef9e9f..95e1026 100644
--- a/src/com/android/photos/data/SparseArrayBitmapPool.java
+++ b/src/com/android/photos/data/SparseArrayBitmapPool.java
@@ -20,10 +20,15 @@
import android.util.SparseArray;
import android.util.Pools.Pool;
+import android.util.Pools.SimplePool;
+/**
+ * Bitmap pool backed by a sparse array indexing linked lists of bitmaps
+ * sharing the same width. Performance will degrade if using this to store
+ * many bitmaps with the same width but many different heights.
+ */
public class SparseArrayBitmapPool {
- private static final int BITMAPS_TO_KEEP_AFTER_UNNEEDED_HINT = 4;
private int mCapacityBytes;
private SparseArray<Node> mStore = new SparseArray<Node>();
private int mSizeBytes = 0;
@@ -34,53 +39,80 @@
protected static class Node {
Bitmap bitmap;
+
+ // Each node is part of two doubly linked lists:
+ // - A pool-level list (accessed by mPoolNodesHead and mPoolNodesTail)
+ // that is used for FIFO eviction of nodes when the pool gets full.
+ // - A bucket-level list for each index of the sparse array, so that
+ // each index can store more than one item.
Node prevInBucket;
Node nextInBucket;
Node nextInPool;
Node prevInPool;
}
+ /**
+ * @param capacityBytes Maximum capacity of the pool in bytes.
+ * @param nodePool Shared pool to use for recycling linked list nodes, or null.
+ */
public SparseArrayBitmapPool(int capacityBytes, Pool<Node> nodePool) {
mCapacityBytes = capacityBytes;
- mNodePool = nodePool;
+ if (nodePool == null) {
+ mNodePool = new SimplePool<Node>(32);
+ } else {
+ mNodePool = nodePool;
+ }
}
+ /**
+ * Set the maximum capacity of the pool, and if necessary trim it down to size.
+ */
public synchronized void setCapacity(int capacityBytes) {
mCapacityBytes = capacityBytes;
+
+ // No-op unless current size exceeds the new capacity.
freeUpCapacity(0);
}
private void freeUpCapacity(int bytesNeeded) {
int targetSize = mCapacityBytes - bytesNeeded;
+ // Repeatedly remove the oldest node until we have freed up at least bytesNeeded.
while (mPoolNodesTail != null && mSizeBytes > targetSize) {
unlinkAndRecycleNode(mPoolNodesTail, true);
}
}
private void unlinkAndRecycleNode(Node n, boolean recycleBitmap) {
- // Remove the node from its spot in its bucket
+ // Unlink the node from its sparse array bucket list.
if (n.prevInBucket != null) {
+ // This wasn't the head, update the previous node.
n.prevInBucket.nextInBucket = n.nextInBucket;
} else {
+ // This was the head of the bucket, replace it with the next node.
mStore.put(n.bitmap.getWidth(), n.nextInBucket);
}
if (n.nextInBucket != null) {
+ // This wasn't the tail, update the next node.
n.nextInBucket.prevInBucket = n.prevInBucket;
}
- // Remove the node from its spot in the list of pool nodes
+ // Unlink the node from the pool-wide list.
if (n.prevInPool != null) {
+ // This wasn't the head, update the previous node.
n.prevInPool.nextInPool = n.nextInPool;
} else {
+ // This was the head of the pool-wide list, update the head pointer.
mPoolNodesHead = n.nextInPool;
}
if (n.nextInPool != null) {
+ // This wasn't the tail, update the next node.
n.nextInPool.prevInPool = n.prevInPool;
} else {
+ // This was the tail, update the tail pointer.
mPoolNodesTail = n.prevInPool;
}
- // Recycle the node
+ // Recycle the node.
n.nextInBucket = null;
n.nextInPool = null;
n.prevInBucket = null;
@@ -91,16 +123,29 @@
mNodePool.release(n);
}
+ /**
+ * @return Capacity of the pool in bytes.
+ */
public synchronized int getCapacity() {
return mCapacityBytes;
}
+ /**
+ * @return Total size in bytes of the bitmaps stored in the pool.
+ */
public synchronized int getSize() {
return mSizeBytes;
}
+ /**
+ * @return Bitmap from the pool with the desired height/width or null if none available.
+ */
public synchronized Bitmap get(int width, int height) {
Node cur = mStore.get(width);
+
+ // Traverse the list corresponding to the width bucket in the
+ // sparse array, and unlink and return the first bitmap that
+ // also has the correct height.
while (cur != null) {
if (cur.bitmap.getHeight() == height) {
Bitmap b = cur.bitmap;
@@ -112,28 +157,43 @@
return null;
}
+ /**
+ * Adds the given bitmap to the pool.
+ * @return Whether the bitmap was added to the pool.
+ */
public synchronized boolean put(Bitmap b) {
if (b == null) {
return false;
}
+
+ // Ensure there is enough room to contain the new bitmap.
int bytes = b.getByteCount();
freeUpCapacity(bytes);
+
Node newNode = mNodePool.acquire();
if (newNode == null) {
newNode = new Node();
}
newNode.bitmap = b;
+
+ // We append to the head, and freeUpCapacity clears from the tail,
+ // resulting in FIFO eviction.
newNode.prevInBucket = null;
newNode.prevInPool = null;
newNode.nextInPool = mPoolNodesHead;
mPoolNodesHead = newNode;
+
+ // Insert the node into its appropriate bucket based on width.
int key = b.getWidth();
newNode.nextInBucket = mStore.get(key);
if (newNode.nextInBucket != null) {
+ // The bucket already had nodes, update the old head.
newNode.nextInBucket.prevInBucket = newNode;
}
mStore.put(key, newNode);
+
if (newNode.nextInPool == null) {
+ // This is the only node in the list, update the tail pointer.
mPoolNodesTail = newNode;
} else {
newNode.nextInPool.prevInPool = newNode;
@@ -142,7 +202,11 @@
return true;
}
+ /**
+ * Empty the pool, recycling all the bitmaps currently in it.
+ */
public synchronized void clear() {
+ // Clearing is equivalent to ensuring all the capacity is available.
freeUpCapacity(mCapacityBytes);
}
}
diff --git a/src/com/android/photos/drawables/MtpThumbnailDrawable.java b/src/com/android/photos/drawables/MtpThumbnailDrawable.java
deleted file mode 100644
index e35e069..0000000
--- a/src/com/android/photos/drawables/MtpThumbnailDrawable.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.photos.drawables;
-
-import android.mtp.MtpDevice;
-import android.mtp.MtpObjectInfo;
-
-import com.android.gallery3d.ingest.MtpDeviceIndex;
-
-import java.io.InputStream;
-
-public class MtpThumbnailDrawable extends AutoThumbnailDrawable<MtpObjectInfo> {
- public void setImage(MtpObjectInfo data) {
- if (data == null) {
- setImage(null, 0, 0);
- } else {
- setImage(data, data.getImagePixWidth(), data.getImagePixHeight());
- }
- }
-
- @Override
- protected byte[] getPreferredImageBytes(MtpObjectInfo data) {
- if (data == null) {
- return null;
- }
- MtpDevice device = MtpDeviceIndex.getInstance().getDevice();
- if (device != null) {
- return device.getThumbnail(data.getObjectHandle());
- } else {
- return null;
- }
- }
-
- @Override
- protected InputStream getFallbackImageStream(MtpObjectInfo data) {
- // No fallback
- return null;
- }
-
- @Override
- protected boolean dataChangedLocked(MtpObjectInfo data) {
- // We only fetch the MtpObjectInfo once when creating
- // the index so checking the reference is enough
- return mData == data;
- }
-
-}
diff --git a/src/com/android/photos/views/BlockingGLTextureView.java b/src/com/android/photos/views/BlockingGLTextureView.java
index c38f8f7..8a05051 100644
--- a/src/com/android/photos/views/BlockingGLTextureView.java
+++ b/src/com/android/photos/views/BlockingGLTextureView.java
@@ -16,7 +16,6 @@
package com.android.photos.views;
-import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.GLSurfaceView.Renderer;
@@ -32,7 +31,9 @@
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL10;
-
+/**
+ * A TextureView that supports blocking rendering for synchronous drawing
+ */
public class BlockingGLTextureView extends TextureView
implements SurfaceTextureListener {
@@ -90,7 +91,9 @@
protected void finalize() throws Throwable {
try {
destroy();
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ // Ignore
+ }
super.finalize();
}
@@ -135,8 +138,8 @@
}
EGLContext createContext(EGL10 egl, EGLDisplay eglDisplay, EGLConfig eglConfig) {
- int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
- return egl.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
+ int[] attribList = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
+ return egl.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, attribList);
}
/**
@@ -161,7 +164,7 @@
* We can now initialize EGL for that display
*/
int[] version = new int[2];
- if(!mEgl.eglInitialize(mEglDisplay, version)) {
+ if (!mEgl.eglInitialize(mEglDisplay, version)) {
throw new RuntimeException("eglInitialize failed");
}
mEglConfig = chooseEglConfig();
@@ -251,7 +254,7 @@
* @return the EGL error code from eglSwapBuffers.
*/
public int swap() {
- if (! mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
+ if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
return mEgl.eglGetError();
}
return EGL10.EGL_SUCCESS;
@@ -368,19 +371,24 @@
exec(FINISH);
try {
join();
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
private void exec(int msgid) {
synchronized (mLock) {
if (mExecMsgId != INVALID) {
- throw new IllegalArgumentException("Message already set - multithreaded access?");
+ throw new IllegalArgumentException(
+ "Message already set - multithreaded access?");
}
mExecMsgId = msgid;
mLock.notify();
try {
mLock.wait();
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
}
@@ -415,12 +423,15 @@
while (mExecMsgId == INVALID) {
try {
mLock.wait();
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
handleMessageLocked(mExecMsgId);
mExecMsgId = INVALID;
mLock.notify();
}
+ mExecMsgId = FINISH;
}
}
}
diff --git a/src/com/android/photos/views/TiledImageRenderer.java b/src/com/android/photos/views/TiledImageRenderer.java
index a1f7107..c4e493b 100644
--- a/src/com/android/photos/views/TiledImageRenderer.java
+++ b/src/com/android/photos/views/TiledImageRenderer.java
@@ -23,14 +23,19 @@
import android.support.v4.util.LongSparseArray;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.util.Pools.Pool;
+import android.util.Pools.SynchronizedPool;
import android.view.View;
import android.view.WindowManager;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.glrenderer.BasicTexture;
import com.android.gallery3d.glrenderer.GLCanvas;
import com.android.gallery3d.glrenderer.UploadedTexture;
-import com.android.photos.data.GalleryBitmapPool;
+/**
+ * Handles laying out, decoding, and drawing of tiles in GL
+ */
public class TiledImageRenderer {
public static final int SIZE_UNKNOWN = -1;
@@ -62,12 +67,13 @@
private static final int STATE_RECYCLING = 0x20;
private static final int STATE_RECYCLED = 0x40;
- private static GalleryBitmapPool sTilePool = GalleryBitmapPool.getInstance();
+ private static Pool<Bitmap> sTilePool = new SynchronizedPool<Bitmap>(64);
// TILE_SIZE must be 2^N
private int mTileSize;
private TileSource mModel;
+ private BasicTexture mPreview;
protected int mLevelCount; // cache the value of mScaledBitmaps.length
// The mLevel variable indicates which level of bitmap we should use.
@@ -116,22 +122,39 @@
private int mViewWidth, mViewHeight;
private View mParent;
+ /**
+ * Interface for providing tiles to a {@link TiledImageRenderer}
+ */
public static interface TileSource {
+
+ /**
+ * If the source does not care about the tile size, it should use
+ * {@link TiledImageRenderer#suggestedTileSize(Context)}
+ */
public int getTileSize();
public int getImageWidth();
public int getImageHeight();
+ public int getRotation();
- // The tile returned by this method can be specified this way: Assuming
- // the image size is (width, height), first take the intersection of (0,
- // 0) - (width, height) and (x, y) - (x + tileSize, y + tileSize). If
- // in extending the region, we found some part of the region is outside
- // the image, those pixels are filled with black.
- //
- // If level > 0, it does the same operation on a down-scaled version of
- // the original image (down-scaled by a factor of 2^level), but (x, y)
- // still refers to the coordinate on the original image.
- //
- // The method would be called by the decoder thread.
+ /**
+ * Return a Preview image if available. This will be used as the base layer
+ * if higher res tiles are not yet available
+ */
+ public BasicTexture getPreview();
+
+ /**
+ * The tile returned by this method can be specified this way: Assuming
+ * the image size is (width, height), first take the intersection of (0,
+ * 0) - (width, height) and (x, y) - (x + tileSize, y + tileSize). If
+ * in extending the region, we found some part of the region is outside
+ * the image, those pixels are filled with black.
+ *
+ * If level > 0, it does the same operation on a down-scaled version of
+ * the original image (down-scaled by a factor of 2^level), but (x, y)
+ * still refers to the coordinate on the original image.
+ *
+ * The method would be called by the decoder thread.
+ */
public Bitmap getTile(int level, int x, int y, Bitmap reuse);
}
@@ -173,19 +196,23 @@
if (mRotation != rotation) {
mRotation = rotation;
mLayoutTiles = true;
- invalidate();
}
}
- private static int calulateLevelCount(TileSource source) {
- int levels = 1;
- int maxDim = Math.max(source.getImageWidth(), source.getImageHeight());
- int t = source.getTileSize();
- while (t < maxDim) {
- t <<= 1;
- levels++;
+ private void calculateLevelCount() {
+ if (mPreview != null) {
+ mLevelCount = Math.max(0, Utils.ceilLog2(
+ mImageWidth / (float) mPreview.getWidth()));
+ } else {
+ int levels = 1;
+ int maxDim = Math.max(mImageWidth, mImageHeight);
+ int t = mTileSize;
+ while (t < maxDim) {
+ t <<= 1;
+ levels++;
+ }
+ mLevelCount = levels;
}
- return levels;
}
public void notifyModelInvalidated() {
@@ -194,14 +221,15 @@
mImageWidth = 0;
mImageHeight = 0;
mLevelCount = 0;
+ mPreview = null;
} else {
mImageWidth = mModel.getImageWidth();
mImageHeight = mModel.getImageHeight();
- mLevelCount = calulateLevelCount(mModel);
+ mPreview = mModel.getPreview();
mTileSize = mModel.getTileSize();
+ calculateLevelCount();
}
mLayoutTiles = true;
- invalidate();
}
public void setViewSize(int width, int height) {
@@ -211,12 +239,13 @@
public void setPosition(int centerX, int centerY, float scale) {
if (mCenterX == centerX && mCenterY == centerY
- && mScale == scale) return;
+ && mScale == scale) {
+ return;
+ }
mCenterX = centerX;
mCenterY = centerY;
mScale = scale;
mLayoutTiles = true;
- invalidate();
}
// Prepare the tiles we want to use for display.
@@ -265,7 +294,9 @@
}
// If rotation is transient, don't update the tile.
- if (mRotation % 90 != 0) return;
+ if (mRotation % 90 != 0) {
+ return;
+ }
synchronized (mQueueLock) {
mDecodeQueue.clean();
@@ -305,7 +336,7 @@
mDecodeQueue.clean();
mUploadQueue.clean();
- // TODO disable decoder
+ // TODO(xx): disable decoder
int n = mActiveTiles.size();
for (int i = 0; i < n; i++) {
Tile tile = mActiveTiles.valueAt(i);
@@ -357,6 +388,7 @@
public void freeTextures() {
mLayoutTiles = true;
+ mTileDecoder.finishAndWait();
synchronized (mQueueLock) {
mUploadQueue.clean();
mDecodeQueue.clean();
@@ -375,10 +407,10 @@
mActiveTiles.clear();
mTileRange.set(0, 0, 0, 0);
- if (sTilePool != null) sTilePool.clear();
+ while (sTilePool.acquire() != null) {}
}
- public void draw(GLCanvas canvas) {
+ public boolean draw(GLCanvas canvas) {
layoutTiles();
uploadTiles(canvas);
@@ -388,7 +420,9 @@
int level = mLevel;
int rotation = mRotation;
int flags = 0;
- if (rotation != 0) flags |= GLCanvas.SAVE_FLAG_MATRIX;
+ if (rotation != 0) {
+ flags |= GLCanvas.SAVE_FLAG_MATRIX;
+ }
if (flags != 0) {
canvas.save(flags);
@@ -412,9 +446,15 @@
drawTile(canvas, tx, ty, level, x, y, length);
}
}
+ } else if (mPreview != null) {
+ mPreview.draw(canvas, mOffsetX, mOffsetY,
+ Math.round(mImageWidth * mScale),
+ Math.round(mImageHeight * mScale));
}
} finally {
- if (flags != 0) canvas.restore();
+ if (flags != 0) {
+ canvas.restore();
+ }
}
if (mRenderComplete) {
@@ -424,6 +464,7 @@
} else {
invalidate();
}
+ return mRenderComplete || mPreview != null;
}
private void uploadBackgroundTiles(GLCanvas canvas) {
@@ -437,17 +478,6 @@
}
}
- private void queueForUpload(Tile tile) {
- synchronized (mQueueLock) {
- mUploadQueue.push(tile);
- }
- invalidate();
- // TODO
-// if (mTileUploader.mActive.compareAndSet(false, true)) {
-// getGLRoot().addOnGLIdleListener(mTileUploader);
-// }
- }
-
private void queueForDecode(Tile tile) {
synchronized (mQueueLock) {
if (tile.mTileState == STATE_ACTIVATED) {
@@ -459,9 +489,11 @@
}
}
- private boolean decodeTile(Tile tile) {
+ private void decodeTile(Tile tile) {
synchronized (mQueueLock) {
- if (tile.mTileState != STATE_IN_QUEUE) return false;
+ if (tile.mTileState != STATE_IN_QUEUE) {
+ return;
+ }
tile.mTileState = STATE_DECODING;
}
boolean decodeComplete = tile.decode();
@@ -469,15 +501,19 @@
if (tile.mTileState == STATE_RECYCLING) {
tile.mTileState = STATE_RECYCLED;
if (tile.mDecodedTile != null) {
- if (sTilePool != null) sTilePool.put(tile.mDecodedTile);
+ sTilePool.release(tile.mDecodedTile);
tile.mDecodedTile = null;
}
mRecycledQueue.push(tile);
- return false;
+ return;
}
tile.mTileState = decodeComplete ? STATE_DECODED : STATE_DECODE_FAIL;
- return decodeComplete;
+ if (!decodeComplete) {
+ return;
+ }
+ mUploadQueue.push(tile);
}
+ invalidate();
}
private Tile obtainTile(int x, int y, int level) {
@@ -500,7 +536,7 @@
}
tile.mTileState = STATE_RECYCLED;
if (tile.mDecodedTile != null) {
- if (sTilePool != null) sTilePool.put(tile.mDecodedTile);
+ sTilePool.release(tile.mDecodedTile);
tile.mDecodedTile = null;
}
mRecycledQueue.push(tile);
@@ -538,11 +574,16 @@
synchronized (mQueueLock) {
tile = mUploadQueue.pop();
}
- if (tile == null) break;
+ if (tile == null) {
+ break;
+ }
if (!tile.isContentValid()) {
- Utils.assertTrue(tile.mTileState == STATE_DECODED);
- tile.updateContent(canvas);
- --quota;
+ if (tile.mTileState == STATE_DECODED) {
+ tile.updateContent(canvas);
+ --quota;
+ } else {
+ Log.w(TAG, "Tile in upload queue has invalid state: " + tile.mTileState);
+ }
}
}
if (tile != null) {
@@ -574,7 +615,17 @@
queueForDecode(tile);
}
}
- drawTile(tile, canvas, source, target);
+ if (drawTile(tile, canvas, source, target)) {
+ return;
+ }
+ }
+ if (mPreview != null) {
+ int size = mTileSize << level;
+ float scaleX = (float) mPreview.getWidth() / mImageWidth;
+ float scaleY = (float) mPreview.getHeight() / mImageHeight;
+ source.set(tx * scaleX, ty * scaleY, (tx + size) * scaleX,
+ (ty + size) * scaleY);
+ canvas.drawTexture(mPreview, source, target);
}
}
@@ -588,7 +639,9 @@
// Parent can be divided to four quads and tile is one of the four.
Tile parent = tile.getParentTile();
- if (parent == null) return false;
+ if (parent == null) {
+ return false;
+ }
if (tile.mX == parent.mX) {
source.left /= 2f;
source.right /= 2f;
@@ -623,14 +676,17 @@
@Override
protected void onFreeBitmap(Bitmap bitmap) {
- if (sTilePool != null) sTilePool.put(bitmap);
+ sTilePool.release(bitmap);
}
boolean decode() {
// Get a tile from the original image. The tile is down-scaled
// by (1 << mTilelevel) from a region in the original image.
try {
- Bitmap reuse = sTilePool.get(mTileSize, mTileSize);
+ Bitmap reuse = sTilePool.acquire();
+ if (reuse != null && reuse.getWidth() != mTileSize) {
+ reuse = null;
+ }
mDecodedTile = mModel.getTile(mTileLevel, mX, mY, reuse);
} catch (Throwable t) {
Log.w(TAG, "fail to decode tile", t);
@@ -676,7 +732,9 @@
}
public Tile getParentTile() {
- if (mTileLevel + 1 == mLevelCount) return null;
+ if (mTileLevel + 1 == mLevelCount) {
+ return null;
+ }
int size = mTileSize << (mTileLevel + 1);
int x = size * (mX / size);
int y = size * (mY / size);
@@ -695,17 +753,34 @@
public Tile pop() {
Tile tile = mHead;
- if (tile != null) mHead = tile.mNext;
+ if (tile != null) {
+ mHead = tile.mNext;
+ }
return tile;
}
public boolean push(Tile tile) {
+ if (contains(tile)) {
+ Log.w(TAG, "Attempting to add a tile already in the queue!");
+ return false;
+ }
boolean wasEmpty = mHead == null;
tile.mNext = mHead;
mHead = tile;
return wasEmpty;
}
+ private boolean contains(Tile tile) {
+ Tile other = mHead;
+ while (other != null) {
+ if (other == tile) {
+ return true;
+ }
+ other = other.mNext;
+ }
+ return false;
+ }
+
public void clean() {
mHead = null;
}
@@ -723,7 +798,7 @@
}
private Tile waitForTile() throws InterruptedException {
- synchronized(mQueueLock) {
+ synchronized (mQueueLock) {
while (true) {
Tile tile = mDecodeQueue.pop();
if (tile != null) {
@@ -739,11 +814,10 @@
try {
while (!isInterrupted()) {
Tile tile = waitForTile();
- if (decodeTile(tile)) {
- queueForUpload(tile);
- }
+ decodeTile(tile);
}
} catch (InterruptedException ex) {
+ // We were finished
}
}
diff --git a/src/com/android/photos/views/TiledImageView.java b/src/com/android/photos/views/TiledImageView.java
index 6fe030d..8d1cb48 100644
--- a/src/com/android/photos/views/TiledImageView.java
+++ b/src/com/android/photos/views/TiledImageView.java
@@ -16,29 +16,48 @@
package com.android.photos.views;
+import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Align;
+import android.graphics.RectF;
+import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
+import android.os.Build;
import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.ScaleGestureDetector;
-import android.view.ScaleGestureDetector.OnScaleGestureListener;
+import android.view.Choreographer;
+import android.view.Choreographer.FrameCallback;
+import android.view.View;
import android.widget.FrameLayout;
+
+import com.android.gallery3d.glrenderer.BasicTexture;
import com.android.gallery3d.glrenderer.GLES20Canvas;
import com.android.photos.views.TiledImageRenderer.TileSource;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
+/**
+ * Shows an image using {@link TiledImageRenderer} using either {@link GLSurfaceView}
+ * or {@link BlockingGLTextureView}.
+ */
+public class TiledImageView extends FrameLayout {
-public class TiledImageView extends FrameLayout implements OnScaleGestureListener {
+ private static final boolean USE_TEXTURE_VIEW = false;
+ private static final boolean IS_SUPPORTED =
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
+ private static final boolean USE_CHOREOGRAPHER =
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
private BlockingGLTextureView mTextureView;
- private float mLastX, mLastY;
+ private GLSurfaceView mGLSurfaceView;
+ private boolean mInvalPending = false;
+ private FrameCallback mFrameCallback;
private static class ImageRendererWrapper {
// Guarded by locks
@@ -46,20 +65,23 @@
int centerX, centerY;
int rotation;
TileSource source;
+ Runnable isReadyCallback;
// GL thread only
TiledImageRenderer image;
}
- // TODO: left/right paging
- private ImageRendererWrapper mRenderers[] = new ImageRendererWrapper[1];
- private ImageRendererWrapper mFocusedRenderer;
+ private float[] mValues = new float[9];
// -------------------------
// Guarded by mLock
// -------------------------
private Object mLock = new Object();
- private ScaleGestureDetector mScaleGestureDetector;
+ private ImageRendererWrapper mRenderer;
+
+ public static boolean isTilingSupported() {
+ return IS_SUPPORTED;
+ }
public TiledImageView(Context context) {
this(context, null);
@@ -67,102 +89,99 @@
public TiledImageView(Context context, AttributeSet attrs) {
super(context, attrs);
- mTextureView = new BlockingGLTextureView(context);
- addView(mTextureView, new LayoutParams(
+ if (!IS_SUPPORTED) {
+ return;
+ }
+
+ mRenderer = new ImageRendererWrapper();
+ mRenderer.image = new TiledImageRenderer(this);
+ View view;
+ if (USE_TEXTURE_VIEW) {
+ mTextureView = new BlockingGLTextureView(context);
+ mTextureView.setRenderer(new TileRenderer());
+ view = mTextureView;
+ } else {
+ mGLSurfaceView = new GLSurfaceView(context);
+ mGLSurfaceView.setEGLContextClientVersion(2);
+ mGLSurfaceView.setRenderer(new TileRenderer());
+ mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
+ view = mGLSurfaceView;
+ }
+ addView(view, new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
- mTextureView.setRenderer(new TileRenderer());
- setTileSource(new ColoredTiles());
- mScaleGestureDetector = new ScaleGestureDetector(context, this);
+ //setTileSource(new ColoredTiles());
}
public void destroy() {
- mTextureView.destroy();
+ if (!IS_SUPPORTED) {
+ return;
+ }
+ if (USE_TEXTURE_VIEW) {
+ mTextureView.destroy();
+ } else {
+ mGLSurfaceView.queueEvent(mFreeTextures);
+ }
}
- public void setTileSource(TileSource source) {
+ private Runnable mFreeTextures = new Runnable() {
+
+ @Override
+ public void run() {
+ mRenderer.image.freeTextures();
+ }
+ };
+
+ public void onPause() {
+ if (!IS_SUPPORTED) {
+ return;
+ }
+ if (!USE_TEXTURE_VIEW) {
+ mGLSurfaceView.onPause();
+ }
+ }
+
+ public void onResume() {
+ if (!IS_SUPPORTED) {
+ return;
+ }
+ if (!USE_TEXTURE_VIEW) {
+ mGLSurfaceView.onResume();
+ }
+ }
+
+ public void setTileSource(TileSource source, Runnable isReadyCallback) {
+ if (!IS_SUPPORTED) {
+ return;
+ }
synchronized (mLock) {
- for (int i = 0; i < mRenderers.length; i++) {
- ImageRendererWrapper renderer = mRenderers[i];
- if (renderer == null) {
- renderer = mRenderers[i] = new ImageRendererWrapper();
- }
- renderer.source = source;
- renderer.centerX = renderer.source.getImageWidth() / 2;
- renderer.centerY = renderer.source.getImageHeight() / 2;
- renderer.rotation = 0;
- renderer.scale = 0;
- renderer.image = new TiledImageRenderer(this);
- updateScaleIfNecessaryLocked(renderer);
- }
+ mRenderer.source = source;
+ mRenderer.isReadyCallback = isReadyCallback;
+ mRenderer.centerX = source != null ? source.getImageWidth() / 2 : 0;
+ mRenderer.centerY = source != null ? source.getImageHeight() / 2 : 0;
+ mRenderer.rotation = source != null ? source.getRotation() : 0;
+ mRenderer.scale = 0;
+ updateScaleIfNecessaryLocked(mRenderer);
}
- mFocusedRenderer = mRenderers[0];
invalidate();
}
@Override
- public boolean onScaleBegin(ScaleGestureDetector detector) {
- return true;
- }
-
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- // Don't need the lock because this will only fire inside of onTouchEvent
- mFocusedRenderer.scale *= detector.getScaleFactor();
- invalidate();
- return true;
- }
-
- @Override
- public void onScaleEnd(ScaleGestureDetector detector) {
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- int action = event.getActionMasked();
- final boolean pointerUp = action == MotionEvent.ACTION_POINTER_UP;
- final int skipIndex = pointerUp ? event.getActionIndex() : -1;
-
- // Determine focal point
- float sumX = 0, sumY = 0;
- final int count = event.getPointerCount();
- for (int i = 0; i < count; i++) {
- if (skipIndex == i) continue;
- sumX += event.getX(i);
- sumY += event.getY(i);
- }
- final int div = pointerUp ? count - 1 : count;
- float x = sumX / div;
- float y = sumY / div;
-
- synchronized (mLock) {
- mScaleGestureDetector.onTouchEvent(event);
- switch (action) {
- case MotionEvent.ACTION_MOVE:
- mFocusedRenderer.centerX += (mLastX - x) / mFocusedRenderer.scale;
- mFocusedRenderer.centerY += (mLastY - y) / mFocusedRenderer.scale;
- invalidate();
- break;
- }
- }
-
- mLastX = x;
- mLastY = y;
- return true;
- }
-
- @Override
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
super.onLayout(changed, left, top, right, bottom);
+ if (!IS_SUPPORTED) {
+ return;
+ }
synchronized (mLock) {
- for (ImageRendererWrapper renderer : mRenderers) {
- updateScaleIfNecessaryLocked(renderer);
- }
+ updateScaleIfNecessaryLocked(mRenderer);
}
}
private void updateScaleIfNecessaryLocked(ImageRendererWrapper renderer) {
- if (renderer.scale > 0 || getWidth() == 0) return;
+ if (renderer == null || renderer.source == null
+ || renderer.scale > 0 || getWidth() == 0) {
+ return;
+ }
renderer.scale = Math.min(
(float) getWidth() / (float) renderer.source.getImageWidth(),
(float) getHeight() / (float) renderer.source.getImageHeight());
@@ -170,14 +189,93 @@
@Override
protected void dispatchDraw(Canvas canvas) {
- mTextureView.render();
+ if (!IS_SUPPORTED) {
+ return;
+ }
+ if (USE_TEXTURE_VIEW) {
+ mTextureView.render();
+ }
super.dispatchDraw(canvas);
}
+ @SuppressLint("NewApi")
+ @Override
+ public void setTranslationX(float translationX) {
+ if (!IS_SUPPORTED) {
+ return;
+ }
+ super.setTranslationX(translationX);
+ }
+
@Override
public void invalidate() {
- super.invalidate();
- mTextureView.invalidate();
+ if (!IS_SUPPORTED) {
+ return;
+ }
+ if (USE_TEXTURE_VIEW) {
+ super.invalidate();
+ mTextureView.invalidate();
+ } else {
+ if (USE_CHOREOGRAPHER) {
+ invalOnVsync();
+ } else {
+ mGLSurfaceView.requestRender();
+ }
+ }
+ }
+
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
+ private void invalOnVsync() {
+ if (!mInvalPending) {
+ mInvalPending = true;
+ if (mFrameCallback == null) {
+ mFrameCallback = new FrameCallback() {
+ @Override
+ public void doFrame(long frameTimeNanos) {
+ mInvalPending = false;
+ mGLSurfaceView.requestRender();
+ }
+ };
+ }
+ Choreographer.getInstance().postFrameCallback(mFrameCallback);
+ }
+ }
+
+ private RectF mTempRectF = new RectF();
+ public void positionFromMatrix(Matrix matrix) {
+ if (!IS_SUPPORTED) {
+ return;
+ }
+ if (mRenderer.source != null) {
+ final int rotation = mRenderer.source.getRotation();
+ final boolean swap = !(rotation % 180 == 0);
+ final int width = swap ? mRenderer.source.getImageHeight()
+ : mRenderer.source.getImageWidth();
+ final int height = swap ? mRenderer.source.getImageWidth()
+ : mRenderer.source.getImageHeight();
+ mTempRectF.set(0, 0, width, height);
+ matrix.mapRect(mTempRectF);
+ matrix.getValues(mValues);
+ int cx = width / 2;
+ int cy = height / 2;
+ float scale = mValues[Matrix.MSCALE_X];
+ int xoffset = Math.round((getWidth() - mTempRectF.width()) / 2 / scale);
+ int yoffset = Math.round((getHeight() - mTempRectF.height()) / 2 / scale);
+ if (rotation == 90 || rotation == 180) {
+ cx += (mTempRectF.left / scale) - xoffset;
+ } else {
+ cx -= (mTempRectF.left / scale) - xoffset;
+ }
+ if (rotation == 180 || rotation == 270) {
+ cy += (mTempRectF.top / scale) - yoffset;
+ } else {
+ cy -= (mTempRectF.top / scale) - yoffset;
+ }
+ mRenderer.scale = scale;
+ mRenderer.centerX = swap ? cy : cx;
+ mRenderer.centerY = swap ? cx : cy;
+ invalidate();
+ }
}
private class TileRenderer implements Renderer {
@@ -187,37 +285,46 @@
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
mCanvas = new GLES20Canvas();
- for (ImageRendererWrapper renderer : mRenderers) {
- renderer.image.setModel(renderer.source, renderer.rotation);
- }
+ BasicTexture.invalidateAllTextures();
+ mRenderer.image.setModel(mRenderer.source, mRenderer.rotation);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
mCanvas.setSize(width, height);
- for (ImageRendererWrapper renderer : mRenderers) {
- renderer.image.setViewSize(width, height);
- }
+ mRenderer.image.setViewSize(width, height);
}
@Override
public void onDrawFrame(GL10 gl) {
mCanvas.clearBuffer();
+ Runnable readyCallback;
synchronized (mLock) {
- for (ImageRendererWrapper renderer : mRenderers) {
- renderer.image.setModel(renderer.source, renderer.rotation);
- renderer.image.setPosition(renderer.centerX, renderer.centerY, renderer.scale);
- }
+ readyCallback = mRenderer.isReadyCallback;
+ mRenderer.image.setModel(mRenderer.source, mRenderer.rotation);
+ mRenderer.image.setPosition(mRenderer.centerX, mRenderer.centerY,
+ mRenderer.scale);
}
- for (ImageRendererWrapper renderer : mRenderers) {
- renderer.image.draw(mCanvas);
+ boolean complete = mRenderer.image.draw(mCanvas);
+ if (complete && readyCallback != null) {
+ synchronized (mLock) {
+ // Make sure we don't trample on a newly set callback/source
+ // if it changed while we were rendering
+ if (mRenderer.isReadyCallback == readyCallback) {
+ mRenderer.isReadyCallback = null;
+ }
+ }
+ if (readyCallback != null) {
+ post(readyCallback);
+ }
}
}
}
+ @SuppressWarnings("unused")
private static class ColoredTiles implements TileSource {
- private static int[] COLORS = new int[] {
+ private static final int[] COLORS = new int[] {
Color.RED,
Color.BLUE,
Color.YELLOW,
@@ -246,6 +353,11 @@
}
@Override
+ public int getRotation() {
+ return 0;
+ }
+
+ @Override
public Bitmap getTile(int level, int x, int y, Bitmap bitmap) {
int tileSize = getTileSize();
if (bitmap == null) {
@@ -265,5 +377,10 @@
mCanvas.setBitmap(null);
return bitmap;
}
+
+ @Override
+ public BasicTexture getPreview() {
+ return null;
+ }
}
}
diff --git a/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java b/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
index 2a39b68..e82d561 100644
--- a/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/editors/EditorManager.java
@@ -24,12 +24,15 @@
public class EditorManager {
public static void addEditors(EditorPlaceHolder editorPlaceHolder) {
+ editorPlaceHolder.addEditor(new EditorGrad());
+ editorPlaceHolder.addEditor(new EditorChanSat());
editorPlaceHolder.addEditor(new EditorZoom());
editorPlaceHolder.addEditor(new EditorCurves());
editorPlaceHolder.addEditor(new EditorTinyPlanet());
editorPlaceHolder.addEditor(new EditorDraw());
editorPlaceHolder.addEditor(new EditorVignette());
- editorPlaceHolder.addEditor(new EditorFlip());
+ editorPlaceHolder.addEditor(new EditorColorBorder());
+ editorPlaceHolder.addEditor(new EditorMirror());
editorPlaceHolder.addEditor(new EditorRotate());
editorPlaceHolder.addEditor(new EditorStraighten());
editorPlaceHolder.addEditor(new EditorCrop());
diff --git a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
index 97588db..cde615e 100644
--- a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
@@ -22,6 +22,7 @@
import com.android.gallery3d.R;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Vector;
@@ -29,7 +30,7 @@
private static FiltersManager sInstance = null;
private static FiltersManager sPreviewInstance = null;
private static FiltersManager sHighresInstance = null;
- private static int mImageBorderSize = 4; // in percent
+
public FiltersManager() {
init();
}
@@ -48,29 +49,6 @@
return sInstance;
}
- @Override
- public void addBorders(Context context, Vector<FilterRepresentation> representations) {
- // Regular borders
- representations.add(new FilterImageBorderRepresentation(R.drawable.filtershow_border_4x5));
- representations.add(
- new FilterImageBorderRepresentation(R.drawable.filtershow_border_brush));
- representations.add(
- new FilterImageBorderRepresentation(R.drawable.filtershow_border_grunge));
- representations.add(
- new FilterImageBorderRepresentation(R.drawable.filtershow_border_sumi_e));
- representations.add(new FilterImageBorderRepresentation(R.drawable.filtershow_border_tape));
- representations.add(new FilterColorBorderRepresentation(Color.BLACK, mImageBorderSize, 0));
- representations.add(new FilterColorBorderRepresentation(Color.BLACK, mImageBorderSize,
- mImageBorderSize));
- representations.add(new FilterColorBorderRepresentation(Color.WHITE, mImageBorderSize, 0));
- representations.add(new FilterColorBorderRepresentation(Color.WHITE, mImageBorderSize,
- mImageBorderSize));
- int creamColor = Color.argb(255, 237, 237, 227);
- representations.add(new FilterColorBorderRepresentation(creamColor, mImageBorderSize, 0));
- representations.add(new FilterColorBorderRepresentation(creamColor, mImageBorderSize,
- mImageBorderSize));
- }
-
public static FiltersManager getHighresManager() {
if (sHighresInstance == null) {
sHighresInstance = new FiltersManager();
diff --git a/src_pd/com/android/gallery3d/util/FilterShowHelper.java b/src_pd/com/android/gallery3d/util/FilterShowHelper.java
new file mode 100644
index 0000000..b30ebac
--- /dev/null
+++ b/src_pd/com/android/gallery3d/util/FilterShowHelper.java
@@ -0,0 +1,27 @@
+/*
+ * 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.util;
+
+public class FilterShowHelper {
+
+ /**
+ * Whether to utilize version info in editor.
+ */
+ public static final boolean shouldUseVersions() {
+ return true;
+ }
+}
diff --git a/src_pd/com/android/gallery3d/util/HelpUtils.java b/src_pd/com/android/gallery3d/util/HelpUtils.java
new file mode 100644
index 0000000..7da3fca
--- /dev/null
+++ b/src_pd/com/android/gallery3d/util/HelpUtils.java
@@ -0,0 +1,28 @@
+/*
+ * 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.util;
+
+import android.content.Context;
+import android.content.Intent;
+
+public class HelpUtils {
+
+ public static Intent getHelpIntent(Context context) {
+ return null;
+ }
+
+}
diff --git a/src_pd/com/android/gallery3d/util/IntentHelper.java b/src_pd/com/android/gallery3d/util/IntentHelper.java
new file mode 100644
index 0000000..13f69eb
--- /dev/null
+++ b/src_pd/com/android/gallery3d/util/IntentHelper.java
@@ -0,0 +1,32 @@
+/*
+ * 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.util;
+
+import android.content.Context;
+import android.content.Intent;
+
+public class IntentHelper {
+
+ public static Intent getCameraIntent(Context context) {
+ return new Intent(Intent.ACTION_MAIN)
+ .setClassName("com.android.camera2", "com.android.camera.CameraActivity");
+ }
+
+ public static Intent getGalleryIntent(Context context) {
+ return new Intent(Intent.ACTION_MAIN)
+ .setClassName("com.android.gallery3d", "com.android.gallery3d.app.GalleryActivity");
+ }
+}
diff --git a/src_pd/com/android/gallery3d/util/LightCycleHelper.java b/src_pd/com/android/gallery3d/util/LightCycleHelper.java
index bceeea6..3508824 100644
--- a/src_pd/com/android/gallery3d/util/LightCycleHelper.java
+++ b/src_pd/com/android/gallery3d/util/LightCycleHelper.java
@@ -16,15 +16,10 @@
package com.android.gallery3d.util;
-import android.app.Activity;
+import android.content.ContentResolver;
import android.content.Context;
-import android.content.Intent;
import android.net.Uri;
-import com.android.camera.CameraModule;
-import com.android.gallery3d.app.GalleryApp;
-import com.android.gallery3d.app.StitchingProgressManager;
-
public class LightCycleHelper {
public static class PanoramaMetadata {
// Whether a panorama viewer should be used
@@ -38,48 +33,23 @@
}
}
- public static class PanoramaViewHelper {
-
- public PanoramaViewHelper(Activity activity) {
- /* Do nothing */
- }
-
- public void onStart() {
- /* Do nothing */
- }
-
- public void onCreate() {
- /* Do nothing */
- }
-
- public void onStop() {
- /* Do nothing */
- }
-
- public void showPanorama(Uri uri) {
- /* Do nothing */
- }
- }
-
public static final PanoramaMetadata NOT_PANORAMA = new PanoramaMetadata(false, false);
- public static void setupCaptureIntent(Context context, Intent it, String outputDir) {
- /* Do nothing */
- }
-
- public static boolean hasLightCycleCapture(Context context) {
- return false;
- }
-
public static PanoramaMetadata getPanoramaMetadata(Context context, Uri uri) {
return NOT_PANORAMA;
}
- public static CameraModule createPanoramaModule() {
+ /**
+ * Get the file path from a Media storage URI.
+ */
+ public static String getPathFromURI(ContentResolver contentResolver, Uri contentUri) {
return null;
}
- public static StitchingProgressManager createStitchingManagerInstance(GalleryApp app) {
- return null;
+ /**
+ * Get the modified time from a Media storage URI.
+ */
+ public static long getModifiedTimeFromURI(ContentResolver contentResolver, Uri contentUri) {
+ return 0;
}
}
diff --git a/src_pd/com/android/gallery3d/util/PanoramaViewHelper.java b/src_pd/com/android/gallery3d/util/PanoramaViewHelper.java
new file mode 100644
index 0000000..2b1333a
--- /dev/null
+++ b/src_pd/com/android/gallery3d/util/PanoramaViewHelper.java
@@ -0,0 +1,42 @@
+/*
+ * 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.util;
+
+import android.app.Activity;
+import android.net.Uri;
+
+public class PanoramaViewHelper {
+
+ public PanoramaViewHelper(Activity activity) {
+ /* Do nothing */
+ }
+
+ public void onStart() {
+ /* Do nothing */
+ }
+
+ public void onCreate() {
+ /* Do nothing */
+ }
+
+ public void onStop() {
+ /* Do nothing */
+ }
+
+ public void showPanorama(Uri uri) {
+ /* Do nothing */
+ }
+}
diff --git a/src_pd/com/android/gallery3d/util/UsageStatistics.java b/src_pd/com/android/gallery3d/util/UsageStatistics.java
index 868bbb6..48fc6ae 100644
--- a/src_pd/com/android/gallery3d/util/UsageStatistics.java
+++ b/src_pd/com/android/gallery3d/util/UsageStatistics.java
@@ -40,6 +40,11 @@
public static final String ACTION_CAPTURE_DONE = "CaptureDone";
public static final String ACTION_SHARE = "Share";
+ public static final String CATEGORY_LIFECYCLE = "AppLifecycle";
+ public static final String CATEGORY_BUTTON_PRESS = "ButtonPress";
+
+ public static final String LIFECYCLE_START = "Start";
+
public static void initialize(Context context) {}
public static void setPendingTransitionCause(String cause) {}
public static void onContentViewChanged(String screenComponent, String screenName) {}
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 0cc5f87..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := 16
-
-LOCAL_STATIC_JAVA_LIBRARIES := littlemock dexmaker
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := Gallery2Tests
-
-LOCAL_INSTRUMENTATION_FOR := Gallery2
-
-include $(BUILD_PACKAGE)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
deleted file mode 100644
index b98b5e0..0000000
--- a/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.gallery3d.tests">
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.android.gallery3d"
- android:label="Tests for GalleryNew3D application."/>
-
- <instrumentation android:name="com.android.gallery3d.CameraTestRunner"
- android:targetPackage="com.android.gallery3d"
- android:label="Camera continuous test runner"/>
-
- <instrumentation android:name="com.android.gallery3d.exif.ExifTestRunner"
- android:targetPackage="com.android.gallery3d"
- android:label="Tests for ExifParser."/>
-
- <instrumentation android:name="com.android.gallery3d.stress.CameraStressTestRunner"
- android:targetPackage="com.android.gallery3d"
- android:label="Camera stress test runner"/>
-
- <instrumentation android:name="com.android.photos.data.DataTestRunner"
- android:targetPackage="com.android.gallery3d"
- android:label="Tests for android photo DataProviders."/>
-</manifest>
diff --git a/tests/exiftool_parser/parser.py b/tests/exiftool_parser/parser.py
deleted file mode 100755
index 7df23f1..0000000
--- a/tests/exiftool_parser/parser.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env python
-#
-# This parser parses the output from Phil Harvey's exiftool (version 9.02)
-# and convert it to xml format. It reads exiftool's output from stdin and
-# write the xml format to stdout.
-#
-# In order to get the raw infomation from exiftool, we need to enable the verbose
-# flag (-v2) of exiftool.
-#
-# Usage:
-# exiftool -v2 img.jpg | ./parser.py >> output.xml
-#
-#
-
-import os
-import sys
-import re
-
-text = sys.stdin.read()
-
-print """<?xml version="1.0" encoding="utf-8"?>"""
-print "<exif>"
-
-# find the following two groups of string:
-#
-# 1. tag:
-#
-# | | | x) name = value
-# | | | - Tag 0x1234
-#
-# 2. IFD indicator:
-#
-# | | | + [xxx directory with xx entries]
-#
-p = re.compile(
- "(((?:\| )+)[0-9]*\)(?:(?:.*? = .*?)|(?:.*? \(SubDirectory\) -->))\n.*?- Tag 0x[0-9a-f]{4})" + "|"
- + "(((?:\| )*)\+ \[.*? directory with [0-9]+ entries]$)"
- , re.M)
-tags = p.findall(text)
-
-layer = 0
-ifds = []
-
-for s in tags:
- # IFD indicator
- if s[2]:
- l = len(s[3])
- ifd = s[2][l + 3:].split()[0]
- new_layer = l / 2 + 1
- if new_layer > layer:
- ifds.append(ifd)
- else:
- for i in range(layer - new_layer):
- ifds.pop()
- ifds[-1] = ifd
- layer = new_layer
- else:
- l = len(s[1])
- s = s[0]
- new_layer = l / 2
- if new_layer < layer:
- for i in range(layer - new_layer):
- ifds.pop()
- layer = new_layer
-
- # find the ID
- _id = re.search("0x[0-9a-f]{4}", s)
- _id = _id.group(0)
-
- # find the name
- name = re.search("[0-9]*?\).*?(?:(?: = )|(?: \(SubDirectory\) -->))", s)
- name = name.group(0).split()[1]
-
- # find the raw value in the parenthesis
- value = re.search("\(SubDirectory\) -->", s)
- if value:
- value = "NO_VALUE"
- else:
- value = re.search("\(.*\)\n", s)
- if (name != 'Model' and value):
- value = value.group(0)[1:-2]
- else:
- value = re.search("=.*\n", s)
- value = value.group(0)[2:-1]
- if "[snip]" in value:
- value = "NO_VALUE"
-
- print (' <tag ifd="' + ifds[-1] + '" id="'
- + _id + '" name="' + name +'">' + value + "</tag>")
-print "</exif>"
diff --git a/tests/res/raw/android_lawn.mp4 b/tests/res/raw/android_lawn.mp4
deleted file mode 100644
index bdeffbe..0000000
--- a/tests/res/raw/android_lawn.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/res/raw/galaxy_nexus.jpg b/tests/res/raw/galaxy_nexus.jpg
deleted file mode 100755
index de91df6..0000000
--- a/tests/res/raw/galaxy_nexus.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/res/xml/galaxy_nexus.xml b/tests/res/xml/galaxy_nexus.xml
deleted file mode 100644
index 55dd524..0000000
--- a/tests/res/xml/galaxy_nexus.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<exif>
- <tag ifd="IFD0" id="0x0100" name="ImageWidth">2560</tag>
- <tag ifd="IFD0" id="0x0101" name="ImageHeight">1920</tag>
- <tag ifd="IFD0" id="0x010f" name="Make">google</tag>
- <tag ifd="IFD0" id="0x0110" name="Model">Nexus S</tag>
- <tag ifd="IFD0" id="0x0112" name="Orientation">1</tag>
- <tag ifd="IFD0" id="0x0131" name="Software">MASTER</tag>
- <tag ifd="IFD0" id="0x0132" name="ModifyDate">2012:07:30 16:28:42</tag>
- <tag ifd="IFD0" id="0x0213" name="YCbCrPositioning">1</tag>
- <tag ifd="IFD0" id="0x8769" name="ExifOffset">NO_VALUE</tag>
- <tag ifd="ExifIFD" id="0x829a" name="ExposureTime">1/40</tag>
- <tag ifd="ExifIFD" id="0x829d" name="FNumber">26/10</tag>
- <tag ifd="ExifIFD" id="0x8822" name="ExposureProgram">3</tag>
- <tag ifd="ExifIFD" id="0x8827" name="ISO">100</tag>
- <tag ifd="ExifIFD" id="0x9000" name="ExifVersion">0220</tag>
- <tag ifd="ExifIFD" id="0x9003" name="DateTimeOriginal">2012:07:30 16:28:42</tag>
- <tag ifd="ExifIFD" id="0x9004" name="CreateDate">2012:07:30 16:28:42</tag>
- <tag ifd="ExifIFD" id="0x9201" name="ShutterSpeedValue">50/10</tag>
- <tag ifd="ExifIFD" id="0x9202" name="ApertureValue">30/10</tag>
- <tag ifd="ExifIFD" id="0x9203" name="BrightnessValue">30/10</tag>
- <tag ifd="ExifIFD" id="0x9204" name="ExposureCompensation">0/0</tag>
- <tag ifd="ExifIFD" id="0x9205" name="MaxApertureValue">30/10</tag>
- <tag ifd="ExifIFD" id="0x9207" name="MeteringMode">2</tag>
- <tag ifd="ExifIFD" id="0x9209" name="Flash">0</tag>
- <tag ifd="ExifIFD" id="0x920a" name="FocalLength">343/100</tag>
- <tag ifd="ExifIFD" id="0x9286" name="UserComment">IICSAUser comments</tag>
- <tag ifd="ExifIFD" id="0xa001" name="ColorSpace">1</tag>
- <tag ifd="ExifIFD" id="0xa002" name="ExifImageWidth">2560</tag>
- <tag ifd="ExifIFD" id="0xa003" name="ExifImageHeight">1920</tag>
- <tag ifd="ExifIFD" id="0xa402" name="ExposureMode">0</tag>
- <tag ifd="ExifIFD" id="0xa403" name="WhiteBalance">0</tag>
- <tag ifd="ExifIFD" id="0xa406" name="SceneCaptureType">0</tag>
- <tag ifd="IFD1" id="0x0100" name="ImageWidth">320</tag>
- <tag ifd="IFD1" id="0x0101" name="ImageHeight">240</tag>
- <tag ifd="IFD1" id="0x0103" name="Compression">6</tag>
- <tag ifd="IFD1" id="0x0112" name="Orientation">1</tag>
- <tag ifd="IFD1" id="0x011a" name="XResolution">72/1</tag>
- <tag ifd="IFD1" id="0x011b" name="YResolution">72/1</tag>
- <tag ifd="IFD1" id="0x0128" name="ResolutionUnit">2</tag>
- <tag ifd="IFD1" id="0x0201" name="ThumbnailOffset">690</tag>
- <tag ifd="IFD1" id="0x0202" name="ThumbnailLength">10447</tag>
-</exif>
diff --git a/tests/src/com/android/gallery3d/CameraTestRunner.java b/tests/src/com/android/gallery3d/CameraTestRunner.java
deleted file mode 100755
index 5032336..0000000
--- a/tests/src/com/android/gallery3d/CameraTestRunner.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d;
-
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-
-import com.android.gallery3d.functional.CameraTest;
-import com.android.gallery3d.functional.ImageCaptureIntentTest;
-import com.android.gallery3d.functional.VideoCaptureIntentTest;
-import com.android.gallery3d.unittest.CameraUnitTest;
-
-import junit.framework.TestSuite;
-
-
-public class CameraTestRunner extends InstrumentationTestRunner {
-
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(CameraTest.class);
- suite.addTestSuite(ImageCaptureIntentTest.class);
- suite.addTestSuite(VideoCaptureIntentTest.class);
- suite.addTestSuite(CameraUnitTest.class);
- return suite;
- }
-
- @Override
- public ClassLoader getLoader() {
- return CameraTestRunner.class.getClassLoader();
- }
-}
diff --git a/tests/src/com/android/gallery3d/StressTests.java b/tests/src/com/android/gallery3d/StressTests.java
deleted file mode 100755
index b991e9e..0000000
--- a/tests/src/com/android/gallery3d/StressTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2009 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;
-
-import com.android.gallery3d.stress.CameraLatency;
-import com.android.gallery3d.stress.CameraStartUp;
-import com.android.gallery3d.stress.ImageCapture;
-import com.android.gallery3d.stress.SwitchPreview;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-/**
- * Instrumentation Test Runner for all Camera tests.
- *
- * Running all tests:
- *
- * adb shell am instrument \
- * -e class com.android.gallery3d.StressTests \
- * -w com.google.android.gallery3d.tests/com.android.gallery3d.stress.CameraStressTestRunner
- */
-
-public class StressTests extends TestSuite {
- public static Test suite() {
- TestSuite result = new TestSuite();
- result.addTestSuite(CameraLatency.class);
- result.addTestSuite(CameraStartUp.class);
- result.addTestSuite(ImageCapture.class);
-// result.addTestSuite(SwitchPreview.class);
- return result;
- }
-}
diff --git a/tests/src/com/android/gallery3d/anim/AnimationTest.java b/tests/src/com/android/gallery3d/anim/AnimationTest.java
deleted file mode 100644
index c7d5dae..0000000
--- a/tests/src/com/android/gallery3d/anim/AnimationTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2010 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.anim;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-import android.view.animation.Interpolator;
-
-import junit.framework.TestCase;
-
-@SmallTest
-public class AnimationTest extends TestCase {
- private static final String TAG = "AnimationTest";
-
- public void testFloatAnimation() {
- FloatAnimation a = new FloatAnimation(0f, 1f, 10); // value 0 to 1.0, duration 10
- a.start(); // start animation
- assertTrue(a.isActive()); // should be active now
- a.calculate(0); // set start time = 0
- assertTrue(a.get() == 0); // start value should be 0
- a.calculate(1); // calculate value for time 1
- assertFloatEq(a.get(), 0.1f);
- a.calculate(5); // calculate value for time 5
- assertTrue(a.get() == 0.5);//
- a.calculate(9); // calculate value for time 9
- assertFloatEq(a.get(), 0.9f);
- a.calculate(10); // calculate value for time 10
- assertTrue(!a.isActive()); // should be inactive now
- assertTrue(a.get() == 1.0);//
- a.start(); // restart
- assertTrue(a.isActive()); // should be active now
- a.calculate(5); // set start time = 5
- assertTrue(a.get() == 0); // start value should be 0
- a.calculate(5+9); // calculate for time 5+9
- assertFloatEq(a.get(), 0.9f);
- }
-
- private static class MyInterpolator implements Interpolator {
- public float getInterpolation(float input) {
- return 4f * (input - 0.5f); // maps [0,1] to [-2,2]
- }
- }
-
- public void testInterpolator() {
- FloatAnimation a = new FloatAnimation(0f, 1f, 10); // value 0 to 1.0, duration 10
- a.setInterpolator(new MyInterpolator());
- a.start(); // start animation
- a.calculate(0); // set start time = 0
- assertTrue(a.get() == -2); // start value should be -2
- a.calculate(1); // calculate value for time 1
- assertFloatEq(a.get(), -1.6f);
- a.calculate(5); // calculate value for time 5
- assertTrue(a.get() == 0); //
- a.calculate(9); // calculate value for time 9
- assertFloatEq(a.get(), 1.6f);
- a.calculate(10); // calculate value for time 10
- assertTrue(a.get() == 2); //
- }
-
- public static void assertFloatEq(float expected, float actual) {
- if (Math.abs(actual - expected) > 1e-6) {
- Log.v(TAG, "expected: " + expected + ", actual: " + actual);
- fail();
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/common/BlobCacheTest.java b/tests/src/com/android/gallery3d/common/BlobCacheTest.java
deleted file mode 100644
index 2a911c4..0000000
--- a/tests/src/com/android/gallery3d/common/BlobCacheTest.java
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- * Copyright (C) 2010 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.common;
-
-import com.android.gallery3d.common.BlobCache;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Random;
-
-public class BlobCacheTest extends AndroidTestCase {
- private static final String TAG = "BlobCacheTest";
-
- @SmallTest
- public void testReadIntLong() {
- byte[] buf = new byte[9];
- assertEquals(0, BlobCache.readInt(buf, 0));
- assertEquals(0, BlobCache.readLong(buf, 0));
- buf[0] = 1;
- assertEquals(1, BlobCache.readInt(buf, 0));
- assertEquals(1, BlobCache.readLong(buf, 0));
- buf[3] = 0x7f;
- assertEquals(0x7f000001, BlobCache.readInt(buf, 0));
- assertEquals(0x7f000001, BlobCache.readLong(buf, 0));
- assertEquals(0x007f0000, BlobCache.readInt(buf, 1));
- assertEquals(0x007f0000, BlobCache.readLong(buf, 1));
- buf[3] = (byte) 0x80;
- buf[7] = (byte) 0xA0;
- buf[0] = 0;
- assertEquals(0x80000000, BlobCache.readInt(buf, 0));
- assertEquals(0xA000000080000000L, BlobCache.readLong(buf, 0));
- for (int i = 0; i < 8; i++) {
- buf[i] = (byte) (0x11 * (i+8));
- }
- assertEquals(0xbbaa9988, BlobCache.readInt(buf, 0));
- assertEquals(0xffeeddccbbaa9988L, BlobCache.readLong(buf, 0));
- buf[8] = 0x33;
- assertEquals(0x33ffeeddccbbaa99L, BlobCache.readLong(buf, 1));
- }
-
- @SmallTest
- public void testWriteIntLong() {
- byte[] buf = new byte[8];
- BlobCache.writeInt(buf, 0, 0x12345678);
- assertEquals(0x78, buf[0]);
- assertEquals(0x56, buf[1]);
- assertEquals(0x34, buf[2]);
- assertEquals(0x12, buf[3]);
- assertEquals(0x00, buf[4]);
- BlobCache.writeLong(buf, 0, 0xffeeddccbbaa9988L);
- for (int i = 0; i < 8; i++) {
- assertEquals((byte) (0x11 * (i+8)), buf[i]);
- }
- }
-
- @MediumTest
- public void testChecksum() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
- byte[] buf = new byte[0];
- assertEquals(0x1, bc.checkSum(buf));
- buf = new byte[1];
- assertEquals(0x10001, bc.checkSum(buf));
- buf[0] = 0x47;
- assertEquals(0x480048, bc.checkSum(buf));
- buf = new byte[3];
- buf[0] = 0x10;
- buf[1] = 0x30;
- buf[2] = 0x01;
- assertEquals(0x940042, bc.checkSum(buf));
- assertEquals(0x310031, bc.checkSum(buf, 1, 1));
- assertEquals(0x1, bc.checkSum(buf, 1, 0));
- assertEquals(0x630032, bc.checkSum(buf, 1, 2));
- buf = new byte[1024];
- for (int i = 0; i < buf.length; i++) {
- buf[i] = (byte)(i*i);
- }
- assertEquals(0x3574a610, bc.checkSum(buf));
- bc.close();
- }
-
- private static final int HEADER_SIZE = 32;
- private static final int DATA_HEADER_SIZE = 4;
- private static final int BLOB_HEADER_SIZE = 20;
-
- private static final String TEST_FILE_NAME = "/sdcard/btest";
- private static final int MAX_ENTRIES = 100;
- private static final int MAX_BYTES = 1000;
- private static final int INDEX_SIZE = HEADER_SIZE + MAX_ENTRIES * 12 * 2;
- private static final long KEY_0 = 0x1122334455667788L;
- private static final long KEY_1 = 0x1122334455667789L;
- private static final long KEY_2 = 0x112233445566778AL;
- private static byte[] DATA_0 = new byte[10];
- private static byte[] DATA_1 = new byte[10];
-
- @MediumTest
- public void testBasic() throws IOException {
- String name = TEST_FILE_NAME;
- BlobCache bc;
- File idxFile = new File(name + ".idx");
- File data0File = new File(name + ".0");
- File data1File = new File(name + ".1");
-
- // Create a brand new cache.
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, true);
- bc.close();
-
- // Make sure the initial state is correct.
- assertTrue(idxFile.exists());
- assertTrue(data0File.exists());
- assertTrue(data1File.exists());
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE, data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
- assertEquals(0, bc.getActiveCount());
-
- // Re-open it.
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, false);
- assertNull(bc.lookup(KEY_0));
-
- // insert one blob
- genData(DATA_0, 1);
- bc.insert(KEY_0, DATA_0);
- assertSameData(DATA_0, bc.lookup(KEY_0));
- assertEquals(1, bc.getActiveCount());
- bc.close();
-
- // Make sure the file size is right.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + BLOB_HEADER_SIZE + DATA_0.length,
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Re-open it and make sure we can get the old data
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, false);
- assertSameData(DATA_0, bc.lookup(KEY_0));
-
- // insert with the same key (but using a different blob)
- genData(DATA_0, 2);
- bc.insert(KEY_0, DATA_0);
- assertSameData(DATA_0, bc.lookup(KEY_0));
- assertEquals(1, bc.getActiveCount());
- bc.close();
-
- // Make sure the file size is right.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + 2 * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Re-open it and make sure we can get the old data
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, false);
- assertSameData(DATA_0, bc.lookup(KEY_0));
-
- // insert another key and make sure we can get both key.
- assertNull(bc.lookup(KEY_1));
- genData(DATA_1, 3);
- bc.insert(KEY_1, DATA_1);
- assertSameData(DATA_0, bc.lookup(KEY_0));
- assertSameData(DATA_1, bc.lookup(KEY_1));
- assertEquals(2, bc.getActiveCount());
- bc.close();
-
- // Make sure the file size is right.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + 3 * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Re-open it and make sure we can get the old data
- bc = new BlobCache(name, 100, 1000, false);
- assertSameData(DATA_0, bc.lookup(KEY_0));
- assertSameData(DATA_1, bc.lookup(KEY_1));
- assertEquals(2, bc.getActiveCount());
- bc.close();
- }
-
- @MediumTest
- public void testNegativeKey() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- // insert one blob
- genData(DATA_0, 1);
- bc.insert(-123, DATA_0);
- assertSameData(DATA_0, bc.lookup(-123));
- bc.close();
- }
-
- @MediumTest
- public void testEmptyBlob() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- byte[] data = new byte[0];
- bc.insert(123, data);
- assertSameData(data, bc.lookup(123));
- bc.close();
- }
-
- @MediumTest
- public void testLookupRequest() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- // insert one blob
- genData(DATA_0, 1);
- bc.insert(1, DATA_0);
- assertSameData(DATA_0, bc.lookup(1));
-
- // the same size buffer
- byte[] buf = new byte[DATA_0.length];
- BlobCache.LookupRequest req = new BlobCache.LookupRequest();
- req.key = 1;
- req.buffer = buf;
- assertTrue(bc.lookup(req));
- assertEquals(1, req.key);
- assertSame(buf, req.buffer);
- assertEquals(DATA_0.length, req.length);
-
- // larger buffer
- buf = new byte[DATA_0.length + 22];
- req = new BlobCache.LookupRequest();
- req.key = 1;
- req.buffer = buf;
- assertTrue(bc.lookup(req));
- assertEquals(1, req.key);
- assertSame(buf, req.buffer);
- assertEquals(DATA_0.length, req.length);
-
- // smaller buffer
- buf = new byte[DATA_0.length - 1];
- req = new BlobCache.LookupRequest();
- req.key = 1;
- req.buffer = buf;
- assertTrue(bc.lookup(req));
- assertEquals(1, req.key);
- assertNotSame(buf, req.buffer);
- assertEquals(DATA_0.length, req.length);
- assertSameData(DATA_0, req.buffer, DATA_0.length);
-
- // null buffer
- req = new BlobCache.LookupRequest();
- req.key = 1;
- req.buffer = null;
- assertTrue(bc.lookup(req));
- assertEquals(1, req.key);
- assertNotNull(req.buffer);
- assertEquals(DATA_0.length, req.length);
- assertSameData(DATA_0, req.buffer, DATA_0.length);
-
- bc.close();
- }
-
- @MediumTest
- public void testKeyCollision() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- for (int i = 0; i < MAX_ENTRIES / 2; i++) {
- genData(DATA_0, i);
- long key = KEY_1 + i * MAX_ENTRIES;
- bc.insert(key, DATA_0);
- }
-
- for (int i = 0; i < MAX_ENTRIES / 2; i++) {
- genData(DATA_0, i);
- long key = KEY_1 + i * MAX_ENTRIES;
- assertSameData(DATA_0, bc.lookup(key));
- }
- bc.close();
- }
-
- @MediumTest
- public void testRegionFlip() throws IOException {
- String name = TEST_FILE_NAME;
- BlobCache bc;
- File idxFile = new File(name + ".idx");
- File data0File = new File(name + ".0");
- File data1File = new File(name + ".1");
-
- // Create a brand new cache.
- bc = new BlobCache(name, MAX_ENTRIES, MAX_BYTES, true);
-
- // This is the number of blobs fits into a region.
- int maxFit = (MAX_BYTES - DATA_HEADER_SIZE) /
- (BLOB_HEADER_SIZE + DATA_0.length);
-
- for (int k = 0; k < maxFit; k++) {
- genData(DATA_0, k);
- bc.insert(k, DATA_0);
- }
- assertEquals(maxFit, bc.getActiveCount());
-
- // Make sure the file size is right.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Now insert another one and let it flip.
- genData(DATA_0, 777);
- bc.insert(KEY_1, DATA_0);
- assertEquals(1, bc.getActiveCount());
-
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + 1 * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- // Make sure we can find the new data
- assertSameData(DATA_0, bc.lookup(KEY_1));
-
- // Now find an old blob
- int old = maxFit / 2;
- genData(DATA_0, old);
- assertSameData(DATA_0, bc.lookup(old));
- assertEquals(2, bc.getActiveCount());
-
- // Observed data is copied.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + 2 * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- // Now copy everything over (except we should have no space for the last one)
- assertTrue(old < maxFit - 1);
- for (int k = 0; k < maxFit; k++) {
- genData(DATA_0, k);
- assertSameData(DATA_0, bc.lookup(k));
- }
- assertEquals(maxFit, bc.getActiveCount());
-
- // Now both file should be full.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- // Now insert one to make it flip.
- genData(DATA_0, 888);
- bc.insert(KEY_2, DATA_0);
- assertEquals(1, bc.getActiveCount());
-
- // Check the size after the second flip.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + 1 * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- // Now the last key should be gone.
- assertNull(bc.lookup(maxFit - 1));
-
- // But others should remain
- for (int k = 0; k < maxFit - 1; k++) {
- genData(DATA_0, k);
- assertSameData(DATA_0, bc.lookup(k));
- }
-
- assertEquals(maxFit, bc.getActiveCount());
- genData(DATA_0, 777);
- assertSameData(DATA_0, bc.lookup(KEY_1));
- genData(DATA_0, 888);
- assertSameData(DATA_0, bc.lookup(KEY_2));
- assertEquals(maxFit, bc.getActiveCount());
-
- // Now two files should be full.
- assertEquals(INDEX_SIZE, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
-
- bc.close();
- }
-
- @MediumTest
- public void testEntryLimit() throws IOException {
- String name = TEST_FILE_NAME;
- BlobCache bc;
- File idxFile = new File(name + ".idx");
- File data0File = new File(name + ".0");
- File data1File = new File(name + ".1");
- int maxEntries = 10;
- int maxFit = maxEntries / 2;
- int indexSize = HEADER_SIZE + maxEntries * 12 * 2;
-
- // Create a brand new cache with a small entry limit.
- bc = new BlobCache(name, maxEntries, MAX_BYTES, true);
-
- // Fill to just before flipping
- for (int i = 0; i < maxFit; i++) {
- genData(DATA_0, i);
- bc.insert(i, DATA_0);
- }
- assertEquals(maxFit, bc.getActiveCount());
-
- // Check the file size.
- assertEquals(indexSize, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE, data1File.length());
-
- // Insert one and make it flip
- genData(DATA_0, 777);
- bc.insert(777, DATA_0);
- assertEquals(1, bc.getActiveCount());
-
- // Check the file size.
- assertEquals(indexSize, idxFile.length());
- assertEquals(DATA_HEADER_SIZE + maxFit * (BLOB_HEADER_SIZE + DATA_0.length),
- data0File.length());
- assertEquals(DATA_HEADER_SIZE + 1 * (BLOB_HEADER_SIZE + DATA_0.length),
- data1File.length());
- bc.close();
- }
-
- @LargeTest
- public void testDataIntegrity() throws IOException {
- String name = TEST_FILE_NAME;
- File idxFile = new File(name + ".idx");
- File data0File = new File(name + ".0");
- File data1File = new File(name + ".1");
- RandomAccessFile f;
-
- Log.v(TAG, "It should be readable if the content is not changed.");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(1);
- byte b = f.readByte();
- f.seek(1);
- f.write(b);
- f.close();
- assertReadable();
-
- Log.v(TAG, "Change the data file magic field");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(1);
- f.write(0xFF);
- f.close();
- assertUnreadable();
-
- prepareNewCache();
- f = new RandomAccessFile(data1File, "rw");
- f.write(0xFF);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob key");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4);
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob checksum");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 8);
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob offset");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 12);
- f.write(0x20);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob length: some other value");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 16);
- f.write(0x20);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob length: -1");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 16);
- f.writeInt(0xFFFFFFFF);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob length: big value");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 16);
- f.writeInt(0xFFFFFF00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the blob content");
- prepareNewCache();
- f = new RandomAccessFile(data0File, "rw");
- f.seek(4 + 20);
- f.write(0x01);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the index magic");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(1);
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the active region");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(12);
- f.write(0x01);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the reserved data");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(24);
- f.write(0x01);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the checksum");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(29);
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the key");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(32 + 12 * (KEY_1 % MAX_ENTRIES));
- f.write(0x00);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the offset");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(32 + 12 * (KEY_1 % MAX_ENTRIES) + 8);
- f.write(0x05);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Change the offset");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- f.seek(32 + 12 * (KEY_1 % MAX_ENTRIES) + 8 + 3);
- f.write(0xFF);
- f.close();
- assertUnreadable();
-
- Log.v(TAG, "Garbage index");
- prepareNewCache();
- f = new RandomAccessFile(idxFile, "rw");
- int n = (int) idxFile.length();
- f.seek(32);
- byte[] garbage = new byte[1024];
- for (int i = 0; i < garbage.length; i++) {
- garbage[i] = (byte) 0x80;
- }
- int i = 32;
- while (i < n) {
- int todo = Math.min(garbage.length, n - i);
- f.write(garbage, 0, todo);
- i += todo;
- }
- f.close();
- assertUnreadable();
- }
-
- // Create a brand new cache and put one entry into it.
- private void prepareNewCache() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
- genData(DATA_0, 777);
- bc.insert(KEY_1, DATA_0);
- bc.close();
- }
-
- private void assertReadable() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, false);
- genData(DATA_0, 777);
- assertSameData(DATA_0, bc.lookup(KEY_1));
- bc.close();
- }
-
- private void assertUnreadable() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, false);
- genData(DATA_0, 777);
- assertNull(bc.lookup(KEY_1));
- bc.close();
- }
-
- @LargeTest
- public void testRandomSize() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
-
- // Random size test
- Random rand = new Random(0);
- for (int i = 0; i < 100; i++) {
- byte[] data = new byte[rand.nextInt(MAX_BYTES*12/10)];
- try {
- bc.insert(rand.nextLong(), data);
- if (data.length > MAX_BYTES - 4 - 20) fail();
- } catch (RuntimeException ex) {
- if (data.length <= MAX_BYTES - 4 - 20) fail();
- }
- }
-
- bc.close();
- }
-
- @LargeTest
- public void testBandwidth() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, 1000, 10000000, true);
-
- // Write
- int count = 0;
- byte[] data = new byte[20000];
- long t0 = System.nanoTime();
- for (int i = 0; i < 1000; i++) {
- bc.insert(i, data);
- count += data.length;
- }
- bc.syncAll();
- float delta = (System.nanoTime() - t0) * 1e-3f;
- Log.v(TAG, "write bandwidth = " + (count / delta) + " M/s");
-
- // Copy over
- BlobCache.LookupRequest req = new BlobCache.LookupRequest();
- count = 0;
- t0 = System.nanoTime();
- for (int i = 0; i < 1000; i++) {
- req.key = i;
- req.buffer = data;
- if (bc.lookup(req)) {
- count += req.length;
- }
- }
- bc.syncAll();
- delta = (System.nanoTime() - t0) * 1e-3f;
- Log.v(TAG, "copy over bandwidth = " + (count / delta) + " M/s");
-
- // Read
- count = 0;
- t0 = System.nanoTime();
- for (int i = 0; i < 1000; i++) {
- req.key = i;
- req.buffer = data;
- if (bc.lookup(req)) {
- count += req.length;
- }
- }
- bc.syncAll();
- delta = (System.nanoTime() - t0) * 1e-3f;
- Log.v(TAG, "read bandwidth = " + (count / delta) + " M/s");
-
- bc.close();
- }
-
- @LargeTest
- public void testSmallSize() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, 40, true);
-
- // Small size test
- Random rand = new Random(0);
- for (int i = 0; i < 100; i++) {
- byte[] data = new byte[rand.nextInt(3)];
- bc.insert(rand.nextLong(), data);
- }
-
- bc.close();
- }
-
- @LargeTest
- public void testManyEntries() throws IOException {
- BlobCache bc = new BlobCache(TEST_FILE_NAME, 1, MAX_BYTES, true);
-
- // Many entries test
- Random rand = new Random(0);
- for (int i = 0; i < 100; i++) {
- byte[] data = new byte[rand.nextInt(10)];
- }
-
- bc.close();
- }
-
- private void genData(byte[] data, int seed) {
- for(int i = 0; i < data.length; i++) {
- data[i] = (byte) (seed * i);
- }
- }
-
- private void assertSameData(byte[] data1, byte[] data2) {
- if (data1 == null && data2 == null) return;
- if (data1 == null || data2 == null) fail();
- if (data1.length != data2.length) fail();
- for (int i = 0; i < data1.length; i++) {
- if (data1[i] != data2[i]) fail();
- }
- }
-
- private void assertSameData(byte[] data1, byte[] data2, int n) {
- if (data1 == null || data2 == null) fail();
- for (int i = 0; i < n; i++) {
- if (data1[i] != data2[i]) fail();
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/common/UtilsTest.java b/tests/src/com/android/gallery3d/common/UtilsTest.java
deleted file mode 100644
index a20ebeb..0000000
--- a/tests/src/com/android/gallery3d/common/UtilsTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2010 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.common;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-public class UtilsTest extends AndroidTestCase {
- private static final String TAG = "UtilsTest";
-
- private static final int [] testData = new int [] {
- /* outWidth, outHeight, minSideLength, maxNumOfPixels, sample size */
- 1, 1, BitmapUtils.UNCONSTRAINED, BitmapUtils.UNCONSTRAINED, 1,
- 1, 1, 1, 1, 1,
- 100, 100, 100, 10000, 1,
- 100, 100, 100, 2500, 2,
- 99, 66, 33, 10000, 2,
- 66, 99, 33, 10000, 2,
- 99, 66, 34, 10000, 1,
- 99, 66, 22, 10000, 4,
- 99, 66, 16, 10000, 4,
-
- 10000, 10000, 20000, 1000000, 16,
-
- 100, 100, 100, 10000, 1, // 1
- 100, 100, 50, 10000, 2, // 2
- 100, 100, 30, 10000, 4, // 3->4
- 100, 100, 22, 10000, 4, // 4
- 100, 100, 20, 10000, 8, // 5->8
- 100, 100, 11, 10000, 16, // 9->16
- 100, 100, 5, 10000, 24, // 20->24
- 100, 100, 2, 10000, 56, // 50->56
-
- 100, 100, 100, 10000 - 1, 2, // a bit less than 1
- 100, 100, 100, 10000 / (2 * 2) - 1, 4, // a bit less than 2
- 100, 100, 100, 10000 / (3 * 3) - 1, 4, // a bit less than 3
- 100, 100, 100, 10000 / (4 * 4) - 1, 8, // a bit less than 4
- 100, 100, 100, 10000 / (8 * 8) - 1, 16, // a bit less than 8
- 100, 100, 100, 10000 / (16 * 16) - 1, 24, // a bit less than 16
- 100, 100, 100, 10000 / (24 * 24) - 1, 32, // a bit less than 24
- 100, 100, 100, 10000 / (32 * 32) - 1, 40, // a bit less than 32
-
- 640, 480, 480, BitmapUtils.UNCONSTRAINED, 1, // 1
- 640, 480, 240, BitmapUtils.UNCONSTRAINED, 2, // 2
- 640, 480, 160, BitmapUtils.UNCONSTRAINED, 4, // 3->4
- 640, 480, 120, BitmapUtils.UNCONSTRAINED, 4, // 4
- 640, 480, 96, BitmapUtils.UNCONSTRAINED, 8, // 5->8
- 640, 480, 80, BitmapUtils.UNCONSTRAINED, 8, // 6->8
- 640, 480, 60, BitmapUtils.UNCONSTRAINED, 8, // 8
- 640, 480, 48, BitmapUtils.UNCONSTRAINED, 16, // 10->16
- 640, 480, 40, BitmapUtils.UNCONSTRAINED, 16, // 12->16
- 640, 480, 30, BitmapUtils.UNCONSTRAINED, 16, // 16
- 640, 480, 24, BitmapUtils.UNCONSTRAINED, 24, // 20->24
- 640, 480, 20, BitmapUtils.UNCONSTRAINED, 24, // 24
- 640, 480, 16, BitmapUtils.UNCONSTRAINED, 32, // 30->32
- 640, 480, 12, BitmapUtils.UNCONSTRAINED, 40, // 40
- 640, 480, 10, BitmapUtils.UNCONSTRAINED, 48, // 48
- 640, 480, 8, BitmapUtils.UNCONSTRAINED, 64, // 60->64
- 640, 480, 6, BitmapUtils.UNCONSTRAINED, 80, // 80
- 640, 480, 4, BitmapUtils.UNCONSTRAINED, 120, // 120
- 640, 480, 3, BitmapUtils.UNCONSTRAINED, 160, // 160
- 640, 480, 2, BitmapUtils.UNCONSTRAINED, 240, // 240
- 640, 480, 1, BitmapUtils.UNCONSTRAINED, 480, // 480
-
- 640, 480, BitmapUtils.UNCONSTRAINED, BitmapUtils.UNCONSTRAINED, 1,
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480, 1, // 1
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 - 1, 2, // a bit less than 1
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 4, 2, // 2
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 4 - 1, 4, // a bit less than 2
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 9, 4, // 3
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 9 - 1, 4, // a bit less than 3
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 16, 4, // 4
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 16 - 1, 8, // a bit less than 4
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 64, 8, // 8
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 64 - 1, 16, // a bit less than 8
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 256, 16, // 16
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / 256 - 1, 24, // a bit less than 16
- 640, 480, BitmapUtils.UNCONSTRAINED, 640 * 480 / (24 * 24) - 1, 32, // a bit less than 24
- };
-
- @SmallTest
- public void testComputeSampleSize() {
-
- for (int i = 0; i < testData.length; i += 5) {
- int w = testData[i];
- int h = testData[i + 1];
- int minSide = testData[i + 2];
- int maxPixels = testData[i + 3];
- int sampleSize = testData[i + 4];
- int result = BitmapUtils.computeSampleSize(w, h, minSide, maxPixels);
- if (result != sampleSize) {
- Log.v(TAG, w + "x" + h + ", minSide = " + minSide + ", maxPixels = "
- + maxPixels + ", sampleSize = " + sampleSize + ", result = "
- + result);
- }
- assertTrue(sampleSize == result);
- }
- }
-
- public void testAssert() {
- // This should not throw an exception.
- Utils.assertTrue(true);
-
- // This should throw an exception.
- try {
- Utils.assertTrue(false);
- fail();
- } catch (AssertionError ex) {
- // expected.
- }
- }
-
- public void testCheckNotNull() {
- // These should not throw an expection.
- Utils.checkNotNull(new Object());
- Utils.checkNotNull(0);
- Utils.checkNotNull("");
-
- // This should throw an expection.
- try {
- Utils.checkNotNull(null);
- fail();
- } catch (NullPointerException ex) {
- // expected.
- }
- }
-
- public void testEquals() {
- Object a = new Object();
- Object b = new Object();
-
- assertTrue(Utils.equals(null, null));
- assertTrue(Utils.equals(a, a));
- assertFalse(Utils.equals(null, a));
- assertFalse(Utils.equals(a, null));
- assertFalse(Utils.equals(a, b));
- }
-
- public void testNextPowerOf2() {
- int[] q = new int[] {1, 2, 3, 4, 5, 6, 10, 65535, (1 << 30) - 1, (1 << 30)};
- int[] a = new int[] {1, 2, 4, 4, 8, 8, 16, 65536, (1 << 30) , (1 << 30)};
-
- for (int i = 0; i < q.length; i++) {
- assertEquals(a[i], Utils.nextPowerOf2(q[i]));
- }
-
- int[] e = new int[] {0, -1, -2, -4, -65536, (1 << 30) + 1, Integer.MAX_VALUE};
-
- for (int v : e) {
- try {
- Utils.nextPowerOf2(v);
- fail();
- } catch (IllegalArgumentException ex) {
- // expected.
- }
- }
- }
-
- public void testClamp() {
- assertEquals(1000, Utils.clamp(300, 1000, 2000));
- assertEquals(1300, Utils.clamp(1300, 1000, 2000));
- assertEquals(2000, Utils.clamp(2300, 1000, 2000));
-
- assertEquals(0.125f, Utils.clamp(0.1f, 0.125f, 0.5f));
- assertEquals(0.25f, Utils.clamp(0.25f, 0.125f, 0.5f));
- assertEquals(0.5f, Utils.clamp(0.9f, 0.125f, 0.5f));
- }
-
- public void testIsOpaque() {
- assertTrue(Utils.isOpaque(0xFF000000));
- assertTrue(Utils.isOpaque(0xFFFFFFFF));
- assertTrue(Utils.isOpaque(0xFF123456));
-
- assertFalse(Utils.isOpaque(0xFEFFFFFF));
- assertFalse(Utils.isOpaque(0x8FFFFFFF));
- assertFalse(Utils.isOpaque(0x00FF0000));
- assertFalse(Utils.isOpaque(0x5500FF00));
- assertFalse(Utils.isOpaque(0xAA0000FF));
- }
-
- public static void assertFloatEq(float expected, float actual) {
- if (Math.abs(actual - expected) > 1e-6) {
- Log.v(TAG, "expected: " + expected + ", actual: " + actual);
- fail();
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/data/GalleryAppMock.java b/tests/src/com/android/gallery3d/data/GalleryAppMock.java
deleted file mode 100644
index bbc5692..0000000
--- a/tests/src/com/android/gallery3d/data/GalleryAppMock.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.os.Looper;
-
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.ui.GLRootStub;
-
-class GalleryAppMock extends GalleryAppStub {
- GLRoot mGLRoot = new GLRootStub();
- DataManager mDataManager = new DataManager(this);
- ContentResolver mResolver;
- Context mContext;
- Looper mMainLooper;
-
- GalleryAppMock(Context context,
- ContentResolver resolver, Looper mainLooper) {
- mContext = context;
- mResolver = resolver;
- mMainLooper = mainLooper;
- }
-
- @Override
- public GLRoot getGLRoot() { return mGLRoot; }
- @Override
- public DataManager getDataManager() { return mDataManager; }
- @Override
- public Context getAndroidContext() { return mContext; }
- @Override
- public ContentResolver getContentResolver() { return mResolver; }
- @Override
- public Looper getMainLooper() { return mMainLooper; }
-}
diff --git a/tests/src/com/android/gallery3d/data/GalleryAppStub.java b/tests/src/com/android/gallery3d/data/GalleryAppStub.java
deleted file mode 100644
index 5aff2a2..0000000
--- a/tests/src/com/android/gallery3d/data/GalleryAppStub.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import com.android.gallery3d.app.GalleryApp;
-import com.android.gallery3d.app.StateManager;
-import com.android.gallery3d.app.StitchingProgressManager;
-import com.android.gallery3d.ui.GLRoot;
-import com.android.gallery3d.util.ThreadPool;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Looper;
-
-class GalleryAppStub implements GalleryApp {
- public ImageCacheService getImageCacheService() { return null; }
- public StateManager getStateManager() { return null; }
- public DataManager getDataManager() { return null; }
- public DownloadUtils getDownloadService() { return null; }
- public DecodeUtils getDecodeService() { return null; }
-
- public GLRoot getGLRoot() { return null; }
-
- public Context getAndroidContext() { return null; }
-
- public Looper getMainLooper() { return null; }
- public Resources getResources() { return null; }
- public ContentResolver getContentResolver() { return null; }
- public ThreadPool getThreadPool() { return null; }
- public DownloadCache getDownloadCache() { return null; }
- public StitchingProgressManager getStitchingProgressManager() { return null; }
-}
diff --git a/tests/src/com/android/gallery3d/data/LocalDataTest.java b/tests/src/com/android/gallery3d/data/LocalDataTest.java
deleted file mode 100644
index 8f6a46b..0000000
--- a/tests/src/com/android/gallery3d/data/LocalDataTest.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import android.content.ContentProvider;
-import android.content.ContentResolver;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteQueryBuilder;
-import android.net.Uri;
-import android.os.Looper;
-import android.test.AndroidTestCase;
-import android.test.mock.MockContentProvider;
-import android.test.mock.MockContentResolver;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.util.Log;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class LocalDataTest extends AndroidTestCase {
- @SuppressWarnings("unused")
- private static final String TAG = "LocalDataTest";
- private static final long DEFAULT_TIMEOUT = 1000; // one second
-
- @MediumTest
- public void testLocalAlbum() throws Exception {
- new TestZeroImage().run();
- new TestOneImage().run();
- new TestMoreImages().run();
- new TestZeroVideo().run();
- new TestOneVideo().run();
- new TestMoreVideos().run();
- new TestDeleteOneImage().run();
- new TestDeleteOneAlbum().run();
- }
-
- abstract class TestLocalAlbumBase {
- private boolean mIsImage;
- protected GalleryAppStub mApp;
- protected LocalAlbumSet mAlbumSet;
-
- TestLocalAlbumBase(boolean isImage) {
- mIsImage = isImage;
- }
-
- public void run() throws Exception {
- SQLiteDatabase db = SQLiteDatabase.create(null);
- prepareData(db);
- mApp = newGalleryContext(db, Looper.getMainLooper());
- Path.clearAll();
- Path path = Path.fromString(
- mIsImage ? "/local/image" : "/local/video");
- mAlbumSet = new LocalAlbumSet(path, mApp);
- mAlbumSet.reload();
- verifyResult();
- }
-
- abstract void prepareData(SQLiteDatabase db);
- abstract void verifyResult() throws Exception;
- }
-
- abstract class TestLocalImageAlbum extends TestLocalAlbumBase {
- TestLocalImageAlbum() {
- super(true);
- }
- }
-
- abstract class TestLocalVideoAlbum extends TestLocalAlbumBase {
- TestLocalVideoAlbum() {
- super(false);
- }
- }
-
- class TestZeroImage extends TestLocalImageAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- createImageTable(db);
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(0, mAlbumSet.getSubMediaSetCount());
- assertEquals(0, mAlbumSet.getTotalMediaItemCount());
- }
- }
-
- class TestOneImage extends TestLocalImageAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- createImageTable(db);
- insertImageData(db);
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(1, mAlbumSet.getSubMediaSetCount());
- assertEquals(1, mAlbumSet.getTotalMediaItemCount());
- MediaSet sub = mAlbumSet.getSubMediaSet(0);
- assertEquals(1, sub.getMediaItemCount());
- assertEquals(0, sub.getSubMediaSetCount());
- LocalMediaItem item = (LocalMediaItem) sub.getMediaItem(0, 1).get(0);
- assertEquals(1, item.id);
- assertEquals("IMG_0072", item.caption);
- assertEquals("image/jpeg", item.mimeType);
- assertEquals(12.0, item.latitude);
- assertEquals(34.0, item.longitude);
- assertEquals(0xD000, item.dateTakenInMs);
- assertEquals(1280395646L, item.dateAddedInSec);
- assertEquals(1275934796L, item.dateModifiedInSec);
- assertEquals("/mnt/sdcard/DCIM/100CANON/IMG_0072.JPG", item.filePath);
- }
- }
-
- class TestMoreImages extends TestLocalImageAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- // Albums are sorted by names, and items are sorted by
- // dateTimeTaken (descending)
- createImageTable(db);
- // bucket 0xB000
- insertImageData(db, 1000, 0xB000, "second"); // id 1
- insertImageData(db, 2000, 0xB000, "second"); // id 2
- // bucket 0xB001
- insertImageData(db, 3000, 0xB001, "first"); // id 3
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(2, mAlbumSet.getSubMediaSetCount());
- assertEquals(3, mAlbumSet.getTotalMediaItemCount());
-
- MediaSet first = mAlbumSet.getSubMediaSet(0);
- assertEquals(1, first.getMediaItemCount());
- LocalMediaItem item = (LocalMediaItem) first.getMediaItem(0, 1).get(0);
- assertEquals(3, item.id);
- assertEquals(3000L, item.dateTakenInMs);
-
- MediaSet second = mAlbumSet.getSubMediaSet(1);
- assertEquals(2, second.getMediaItemCount());
- item = (LocalMediaItem) second.getMediaItem(0, 1).get(0);
- assertEquals(2, item.id);
- assertEquals(2000L, item.dateTakenInMs);
- item = (LocalMediaItem) second.getMediaItem(1, 1).get(0);
- assertEquals(1, item.id);
- assertEquals(1000L, item.dateTakenInMs);
- }
- }
-
- class OnContentDirtyLatch implements ContentListener {
- private CountDownLatch mLatch = new CountDownLatch(1);
-
- public void onContentDirty() {
- mLatch.countDown();
- }
-
- public boolean isOnContentDirtyBeCalled(long timeout)
- throws InterruptedException {
- return mLatch.await(timeout, TimeUnit.MILLISECONDS);
- }
- }
-
- class TestDeleteOneAlbum extends TestLocalImageAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- // Albums are sorted by names, and items are sorted by
- // dateTimeTaken (descending)
- createImageTable(db);
- // bucket 0xB000
- insertImageData(db, 1000, 0xB000, "second"); // id 1
- insertImageData(db, 2000, 0xB000, "second"); // id 2
- // bucket 0xB001
- insertImageData(db, 3000, 0xB001, "first"); // id 3
- }
-
- @Override
- public void verifyResult() throws Exception {
- MediaSet sub = mAlbumSet.getSubMediaSet(1); // "second"
- assertEquals(2, mAlbumSet.getSubMediaSetCount());
- OnContentDirtyLatch latch = new OnContentDirtyLatch();
- sub.addContentListener(latch);
- assertTrue((sub.getSupportedOperations() & MediaSet.SUPPORT_DELETE) != 0);
- sub.delete();
- mAlbumSet.fakeChange();
- latch.isOnContentDirtyBeCalled(DEFAULT_TIMEOUT);
- mAlbumSet.reload();
- assertEquals(1, mAlbumSet.getSubMediaSetCount());
- }
- }
-
- class TestDeleteOneImage extends TestLocalImageAlbum {
-
- @Override
- public void prepareData(SQLiteDatabase db) {
- createImageTable(db);
- insertImageData(db);
- }
-
- @Override
- public void verifyResult() {
- MediaSet sub = mAlbumSet.getSubMediaSet(0);
- LocalMediaItem item = (LocalMediaItem) sub.getMediaItem(0, 1).get(0);
- assertEquals(1, sub.getMediaItemCount());
- assertTrue((sub.getSupportedOperations() & MediaSet.SUPPORT_DELETE) != 0);
- sub.delete();
- sub.reload();
- assertEquals(0, sub.getMediaItemCount());
- }
- }
-
- static void createImageTable(SQLiteDatabase db) {
- // This is copied from MediaProvider
- db.execSQL("CREATE TABLE IF NOT EXISTS images (" +
- "_id INTEGER PRIMARY KEY," +
- "_data TEXT," +
- "_size INTEGER," +
- "_display_name TEXT," +
- "mime_type TEXT," +
- "title TEXT," +
- "date_added INTEGER," +
- "date_modified INTEGER," +
- "description TEXT," +
- "picasa_id TEXT," +
- "isprivate INTEGER," +
- "latitude DOUBLE," +
- "longitude DOUBLE," +
- "datetaken INTEGER," +
- "orientation INTEGER," +
- "mini_thumb_magic INTEGER," +
- "bucket_id TEXT," +
- "bucket_display_name TEXT" +
- ");");
- }
-
- static void insertImageData(SQLiteDatabase db) {
- insertImageData(db, 0xD000, 0xB000, "name");
- }
-
- static void insertImageData(SQLiteDatabase db, long dateTaken,
- int bucketId, String bucketName) {
- db.execSQL("INSERT INTO images (title, mime_type, latitude, longitude, "
- + "datetaken, date_added, date_modified, bucket_id, "
- + "bucket_display_name, _data, orientation) "
- + "VALUES ('IMG_0072', 'image/jpeg', 12, 34, "
- + dateTaken + ", 1280395646, 1275934796, '" + bucketId + "', "
- + "'" + bucketName + "', "
- + "'/mnt/sdcard/DCIM/100CANON/IMG_0072.JPG', 0)");
- }
-
- class TestZeroVideo extends TestLocalVideoAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- createVideoTable(db);
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(0, mAlbumSet.getSubMediaSetCount());
- assertEquals(0, mAlbumSet.getTotalMediaItemCount());
- }
- }
-
- class TestOneVideo extends TestLocalVideoAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- createVideoTable(db);
- insertVideoData(db);
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(1, mAlbumSet.getSubMediaSetCount());
- assertEquals(1, mAlbumSet.getTotalMediaItemCount());
- MediaSet sub = mAlbumSet.getSubMediaSet(0);
- assertEquals(1, sub.getMediaItemCount());
- assertEquals(0, sub.getSubMediaSetCount());
- LocalMediaItem item = (LocalMediaItem) sub.getMediaItem(0, 1).get(0);
- assertEquals(1, item.id);
- assertEquals("VID_20100811_051413", item.caption);
- assertEquals("video/mp4", item.mimeType);
- assertEquals(11.0, item.latitude);
- assertEquals(22.0, item.longitude);
- assertEquals(0xD000, item.dateTakenInMs);
- assertEquals(1281503663L, item.dateAddedInSec);
- assertEquals(1281503662L, item.dateModifiedInSec);
- assertEquals("/mnt/sdcard/DCIM/Camera/VID_20100811_051413.3gp",
- item.filePath);
- }
- }
-
- class TestMoreVideos extends TestLocalVideoAlbum {
- @Override
- public void prepareData(SQLiteDatabase db) {
- // Albums are sorted by names, and items are sorted by
- // dateTimeTaken (descending)
- createVideoTable(db);
- // bucket 0xB002
- insertVideoData(db, 1000, 0xB000, "second"); // id 1
- insertVideoData(db, 2000, 0xB000, "second"); // id 2
- // bucket 0xB001
- insertVideoData(db, 3000, 0xB001, "first"); // id 3
- }
-
- @Override
- public void verifyResult() {
- assertEquals(0, mAlbumSet.getMediaItemCount());
- assertEquals(2, mAlbumSet.getSubMediaSetCount());
- assertEquals(3, mAlbumSet.getTotalMediaItemCount());
-
- MediaSet first = mAlbumSet.getSubMediaSet(0);
- assertEquals(1, first.getMediaItemCount());
- LocalMediaItem item = (LocalMediaItem) first.getMediaItem(0, 1).get(0);
- assertEquals(3, item.id);
- assertEquals(3000L, item.dateTakenInMs);
-
- MediaSet second = mAlbumSet.getSubMediaSet(1);
- assertEquals(2, second.getMediaItemCount());
- item = (LocalMediaItem) second.getMediaItem(0, 1).get(0);
- assertEquals(2, item.id);
- assertEquals(2000L, item.dateTakenInMs);
- item = (LocalMediaItem) second.getMediaItem(1, 1).get(0);
- assertEquals(1, item.id);
- assertEquals(1000L, item.dateTakenInMs);
- }
- }
-
- static void createVideoTable(SQLiteDatabase db) {
- db.execSQL("CREATE TABLE IF NOT EXISTS video (" +
- "_id INTEGER PRIMARY KEY," +
- "_data TEXT NOT NULL," +
- "_display_name TEXT," +
- "_size INTEGER," +
- "mime_type TEXT," +
- "date_added INTEGER," +
- "date_modified INTEGER," +
- "title TEXT," +
- "duration INTEGER," +
- "artist TEXT," +
- "album TEXT," +
- "resolution TEXT," +
- "description TEXT," +
- "isprivate INTEGER," + // for YouTube videos
- "tags TEXT," + // for YouTube videos
- "category TEXT," + // for YouTube videos
- "language TEXT," + // for YouTube videos
- "mini_thumb_data TEXT," +
- "latitude DOUBLE," +
- "longitude DOUBLE," +
- "datetaken INTEGER," +
- "mini_thumb_magic INTEGER" +
- ");");
- db.execSQL("ALTER TABLE video ADD COLUMN bucket_id TEXT;");
- db.execSQL("ALTER TABLE video ADD COLUMN bucket_display_name TEXT");
- }
-
- static void insertVideoData(SQLiteDatabase db) {
- insertVideoData(db, 0xD000, 0xB000, "name");
- }
-
- static void insertVideoData(SQLiteDatabase db, long dateTaken,
- int bucketId, String bucketName) {
- db.execSQL("INSERT INTO video (title, mime_type, latitude, longitude, "
- + "datetaken, date_added, date_modified, bucket_id, "
- + "bucket_display_name, _data, duration) "
- + "VALUES ('VID_20100811_051413', 'video/mp4', 11, 22, "
- + dateTaken + ", 1281503663, 1281503662, '" + bucketId + "', "
- + "'" + bucketName + "', "
- + "'/mnt/sdcard/DCIM/Camera/VID_20100811_051413.3gp', 2964)");
- }
-
- static GalleryAppStub newGalleryContext(SQLiteDatabase db, Looper mainLooper) {
- MockContentResolver cr = new MockContentResolver();
- ContentProvider cp = new DbContentProvider(db, cr);
- cr.addProvider("media", cp);
- return new GalleryAppMock(null, cr, mainLooper);
- }
-}
-
-class DbContentProvider extends MockContentProvider {
- private static final String TAG = "DbContentProvider";
- private SQLiteDatabase mDatabase;
- private ContentResolver mContentResolver;
-
- DbContentProvider(SQLiteDatabase db, ContentResolver cr) {
- mDatabase = db;
- mContentResolver = cr;
- }
-
- @Override
- public Cursor query(Uri uri, String[] projection,
- String selection, String[] selectionArgs, String sortOrder) {
- // This is a simplified version extracted from MediaProvider.
-
- String tableName = getTableName(uri);
- if (tableName == null) return null;
-
- SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
- qb.setTables(tableName);
-
- String groupBy = null;
- String limit = uri.getQueryParameter("limit");
-
- if (uri.getQueryParameter("distinct") != null) {
- qb.setDistinct(true);
- }
-
- Log.v(TAG, "query = " + qb.buildQuery(projection, selection,
- selectionArgs, groupBy, null, sortOrder, limit));
-
- if (selectionArgs != null) {
- for (String s : selectionArgs) {
- Log.v(TAG, " selectionArgs = " + s);
- }
- }
-
- Cursor c = qb.query(mDatabase, projection, selection,
- selectionArgs, groupBy, null, sortOrder, limit);
-
- return c;
- }
-
- @Override
- public int delete(Uri uri, String whereClause, String[] whereArgs) {
- Log.v(TAG, "delete " + uri + "," + whereClause + "," + whereArgs[0]);
- String tableName = getTableName(uri);
- if (tableName == null) return 0;
- int count = mDatabase.delete(tableName, whereClause, whereArgs);
- mContentResolver.notifyChange(uri, null);
- return count;
- }
-
- private String getTableName(Uri uri) {
- String uriString = uri.toString();
- if (uriString.startsWith("content://media/external/images/media")) {
- return "images";
- } else if (uriString.startsWith("content://media/external/video/media")) {
- return "video";
- } else {
- return null;
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/data/MediaSetTest.java b/tests/src/com/android/gallery3d/data/MediaSetTest.java
deleted file mode 100644
index 33dfe96..0000000
--- a/tests/src/com/android/gallery3d/data/MediaSetTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import com.android.gallery3d.app.GalleryApp;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class MediaSetTest extends AndroidTestCase {
- @SuppressWarnings("unused")
- private static final String TAG = "MediaSetTest";
-
- @SmallTest
- public void testComboAlbumSet() {
- GalleryApp app = new GalleryAppMock(null, null, null);
- Path.clearAll();
- DataManager dataManager = app.getDataManager();
-
- dataManager.addSource(new ComboSource(app));
- dataManager.addSource(new MockSource(app));
-
- MockSet set00 = new MockSet(Path.fromString("/mock/00"), dataManager, 0, 2000);
- MockSet set01 = new MockSet(Path.fromString("/mock/01"), dataManager, 1, 3000);
- MockSet set10 = new MockSet(Path.fromString("/mock/10"), dataManager, 2, 4000);
- MockSet set11 = new MockSet(Path.fromString("/mock/11"), dataManager, 3, 5000);
- MockSet set12 = new MockSet(Path.fromString("/mock/12"), dataManager, 4, 6000);
-
- MockSet set0 = new MockSet(Path.fromString("/mock/0"), dataManager, 7, 7000);
- set0.addMediaSet(set00);
- set0.addMediaSet(set01);
-
- MockSet set1 = new MockSet(Path.fromString("/mock/1"), dataManager, 8, 8000);
- set1.addMediaSet(set10);
- set1.addMediaSet(set11);
- set1.addMediaSet(set12);
-
- MediaSet combo = dataManager.getMediaSet("/combo/{/mock/0,/mock/1}");
- assertEquals(5, combo.getSubMediaSetCount());
- assertEquals(0, combo.getMediaItemCount());
- assertEquals("/mock/00", combo.getSubMediaSet(0).getPath().toString());
- assertEquals("/mock/01", combo.getSubMediaSet(1).getPath().toString());
- assertEquals("/mock/10", combo.getSubMediaSet(2).getPath().toString());
- assertEquals("/mock/11", combo.getSubMediaSet(3).getPath().toString());
- assertEquals("/mock/12", combo.getSubMediaSet(4).getPath().toString());
-
- assertEquals(10, combo.getTotalMediaItemCount());
- }
-}
diff --git a/tests/src/com/android/gallery3d/data/MockItem.java b/tests/src/com/android/gallery3d/data/MockItem.java
deleted file mode 100644
index 2901979..0000000
--- a/tests/src/com/android/gallery3d/data/MockItem.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import com.android.gallery3d.util.ThreadPool.Job;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapRegionDecoder;
-
-public class MockItem extends MediaItem {
- public MockItem(Path path) {
- super(path, nextVersionNumber());
- }
-
- @Override
- public Job<Bitmap> requestImage(int type) {
- return null;
- }
-
- @Override
- public Job<BitmapRegionDecoder> requestLargeImage() {
- return null;
- }
-
- @Override
- public String getMimeType() {
- return null;
- }
-
- @Override
- public int getWidth() {
- return 0;
- }
-
- @Override
- public int getHeight() {
- return 0;
- }
-}
diff --git a/tests/src/com/android/gallery3d/data/MockSet.java b/tests/src/com/android/gallery3d/data/MockSet.java
deleted file mode 100644
index fa83c79..0000000
--- a/tests/src/com/android/gallery3d/data/MockSet.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import java.util.ArrayList;
-
-public class MockSet extends MediaSet {
- ArrayList<MediaItem> mItems = new ArrayList<MediaItem>();
- ArrayList<MediaSet> mSets = new ArrayList<MediaSet>();
- Path mItemPath;
-
- public MockSet(Path path, DataManager dataManager) {
- super(path, nextVersionNumber());
- mItemPath = Path.fromString("/mock/item");
- }
-
- public MockSet(Path path, DataManager dataManager,
- int items, int item_id_start) {
- this(path, dataManager);
- for (int i = 0; i < items; i++) {
- Path childPath = mItemPath.getChild(item_id_start + i);
- mItems.add(new MockItem(childPath));
- }
- }
-
- public void addMediaSet(MediaSet sub) {
- mSets.add(sub);
- }
-
- @Override
- public int getMediaItemCount() {
- return mItems.size();
- }
-
- @Override
- public ArrayList<MediaItem> getMediaItem(int start, int count) {
- ArrayList<MediaItem> result = new ArrayList<MediaItem>();
- int end = Math.min(start + count, mItems.size());
-
- for (int i = start; i < end; i++) {
- result.add(mItems.get(i));
- }
- return result;
- }
-
- @Override
- public int getSubMediaSetCount() {
- return mSets.size();
- }
-
- @Override
- public MediaSet getSubMediaSet(int index) {
- return mSets.get(index);
- }
-
- @Override
- public int getTotalMediaItemCount() {
- int result = mItems.size();
- for (MediaSet s : mSets) {
- result += s.getTotalMediaItemCount();
- }
- return result;
- }
-
- @Override
- public String getName() {
- return "Set " + mPath;
- }
-
- @Override
- public long reload() {
- return 0;
- }
-}
diff --git a/tests/src/com/android/gallery3d/data/MockSource.java b/tests/src/com/android/gallery3d/data/MockSource.java
deleted file mode 100644
index 27ed4d0..0000000
--- a/tests/src/com/android/gallery3d/data/MockSource.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import com.android.gallery3d.app.GalleryApp;
-
-class MockSource extends MediaSource {
- GalleryApp mApplication;
- PathMatcher mMatcher;
-
- private static final int MOCK_SET = 0;
- private static final int MOCK_ITEM = 1;
-
- public MockSource(GalleryApp context) {
- super("mock");
- mApplication = context;
- mMatcher = new PathMatcher();
- mMatcher.add("/mock/*", MOCK_SET);
- mMatcher.add("/mock/item/*", MOCK_ITEM);
- }
-
- @Override
- public MediaObject createMediaObject(Path path) {
- MediaObject obj;
- switch (mMatcher.match(path)) {
- case MOCK_SET:
- return new MockSet(path, mApplication.getDataManager());
- case MOCK_ITEM:
- return new MockItem(path);
- default:
- throw new RuntimeException("bad path: " + path);
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/data/PathTest.java b/tests/src/com/android/gallery3d/data/PathTest.java
deleted file mode 100644
index b43d109..0000000
--- a/tests/src/com/android/gallery3d/data/PathTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class PathTest extends AndroidTestCase {
- @SuppressWarnings("unused")
- private static final String TAG = "PathTest";
-
- @SmallTest
- public void testToString() {
- Path p = Path.fromString("/hello/world");
- assertEquals("/hello/world", p.toString());
-
- p = Path.fromString("/a");
- assertEquals("/a", p.toString());
-
- p = Path.fromString("");
- assertEquals("", p.toString());
- }
-
- @SmallTest
- public void testSplit() {
- Path p = Path.fromString("/hello/world");
- String[] s = p.split();
- assertEquals(2, s.length);
- assertEquals("hello", s[0]);
- assertEquals("world", s[1]);
-
- p = Path.fromString("");
- assertEquals(0, p.split().length);
- }
-
- @SmallTest
- public void testPrefix() {
- Path p = Path.fromString("/hello/world");
- assertEquals("hello", p.getPrefix());
-
- p = Path.fromString("");
- assertEquals("", p.getPrefix());
- }
-
- @SmallTest
- public void testGetChild() {
- Path p = Path.fromString("/hello");
- Path q = Path.fromString("/hello/world");
- assertSame(q, p.getChild("world"));
- Path r = q.getChild(17);
- assertEquals("/hello/world/17", r.toString());
- }
-
- @SmallTest
- public void testSplitSequence() {
- String[] s = Path.splitSequence("{a,bb,ccc}");
- assertEquals(3, s.length);
- assertEquals("a", s[0]);
- assertEquals("bb", s[1]);
- assertEquals("ccc", s[2]);
-
- s = Path.splitSequence("{a,{bb,ccc},d}");
- assertEquals(3, s.length);
- assertEquals("a", s[0]);
- assertEquals("{bb,ccc}", s[1]);
- assertEquals("d", s[2]);
- }
-}
diff --git a/tests/src/com/android/gallery3d/data/RealDataTest.java b/tests/src/com/android/gallery3d/data/RealDataTest.java
deleted file mode 100644
index 526cfe3..0000000
--- a/tests/src/com/android/gallery3d/data/RealDataTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2010 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.data;
-
-import com.android.gallery3d.app.GalleryApp;
-import com.android.gallery3d.picasasource.PicasaSource;
-
-import android.os.Looper;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-// This test reads real data directly and dump information out in the log.
-public class RealDataTest extends AndroidTestCase {
- private static final String TAG = "RealDataTest";
-
- private HashSet<Path> mUsedId = new HashSet<Path>();
- private GalleryApp mApplication;
- private DataManager mDataManager;
-
- @LargeTest
- public void testRealData() {
- mUsedId.clear();
- mApplication = new GalleryAppMock(
- mContext,
- mContext.getContentResolver(),
- Looper.myLooper());
- mDataManager = mApplication.getDataManager();
- mDataManager.addSource(new LocalSource(mApplication));
- mDataManager.addSource(new PicasaSource(mApplication));
- new TestLocalImage().run();
- new TestLocalVideo().run();
- new TestPicasa().run();
- }
-
- class TestLocalImage {
- public void run() {
- MediaSet set = mDataManager.getMediaSet("/local/image");
- set.reload();
- Log.v(TAG, "LocalAlbumSet (Image)");
- dumpMediaSet(set, "");
- }
- }
-
- class TestLocalVideo {
- public void run() {
- MediaSet set = mDataManager.getMediaSet("/local/video");
- set.reload();
- Log.v(TAG, "LocalAlbumSet (Video)");
- dumpMediaSet(set, "");
- }
- }
-
- class TestPicasa implements Runnable {
- public void run() {
- MediaSet set = mDataManager.getMediaSet("/picasa");
- set.reload();
- Log.v(TAG, "PicasaAlbumSet");
- dumpMediaSet(set, "");
- }
- }
-
- void dumpMediaSet(MediaSet set, String prefix) {
- Log.v(TAG, "getName() = " + set.getName());
- Log.v(TAG, "getPath() = " + set.getPath());
- Log.v(TAG, "getMediaItemCount() = " + set.getMediaItemCount());
- Log.v(TAG, "getSubMediaSetCount() = " + set.getSubMediaSetCount());
- Log.v(TAG, "getTotalMediaItemCount() = " + set.getTotalMediaItemCount());
- assertNewId(set.getPath());
- for (int i = 0, n = set.getSubMediaSetCount(); i < n; i++) {
- MediaSet sub = set.getSubMediaSet(i);
- Log.v(TAG, prefix + "got set " + i);
- dumpMediaSet(sub, prefix + " ");
- }
- for (int i = 0, n = set.getMediaItemCount(); i < n; i += 10) {
- ArrayList<MediaItem> list = set.getMediaItem(i, 10);
- Log.v(TAG, prefix + "got item " + i + " (+" + list.size() + ")");
- for (MediaItem item : list) {
- dumpMediaItem(item, prefix + "..");
- }
- }
- }
-
- void dumpMediaItem(MediaItem item, String prefix) {
- assertNewId(item.getPath());
- Log.v(TAG, prefix + "getPath() = " + item.getPath());
- }
-
- void assertNewId(Path key) {
- assertFalse(key + " has already appeared.", mUsedId.contains(key));
- mUsedId.add(key);
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifDataTest.java b/tests/src/com/android/gallery3d/exif/ExifDataTest.java
deleted file mode 100644
index 949f22c..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifDataTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import junit.framework.TestCase;
-
-import java.nio.ByteOrder;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ExifDataTest extends TestCase {
- Map<Integer, ExifTag> mTestTags;
- ExifInterface mInterface;
- private ExifTag mVersionTag;
- private ExifTag mGpsVersionTag;
- private ExifTag mModelTag;
- private ExifTag mDateTimeTag;
- private ExifTag mCompressionTag;
- private ExifTag mThumbnailFormatTag;
- private ExifTag mLongitudeTag;
- private ExifTag mShutterTag;
- private ExifTag mInteropIndex;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
-
- mInterface = new ExifInterface();
-
- // TYPE_UNDEFINED with 4 components
- mVersionTag = mInterface.buildTag(ExifInterface.TAG_EXIF_VERSION, new byte[] {
- 5, 4, 3, 2
- });
- // TYPE_UNSIGNED_BYTE with 4 components
- mGpsVersionTag = mInterface.buildTag(ExifInterface.TAG_GPS_VERSION_ID, new byte[] {
- 6, 7, 8, 9
- });
- // TYPE ASCII with arbitrary length
- mModelTag = mInterface.buildTag(ExifInterface.TAG_MODEL, "helloworld");
- // TYPE_ASCII with 20 components
- mDateTimeTag = mInterface.buildTag(ExifInterface.TAG_DATE_TIME, "2013:02:11 20:20:20");
- // TYPE_UNSIGNED_SHORT with 1 components
- mCompressionTag = mInterface.buildTag(ExifInterface.TAG_COMPRESSION, 100);
- // TYPE_UNSIGNED_LONG with 1 components
- mThumbnailFormatTag =
- mInterface.buildTag(ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, 100);
- // TYPE_UNSIGNED_RATIONAL with 3 components
- mLongitudeTag = mInterface.buildTag(ExifInterface.TAG_GPS_LONGITUDE, new Rational[] {
- new Rational(2, 2), new Rational(11, 11),
- new Rational(102, 102)
- });
- // TYPE_RATIONAL with 1 components
- mShutterTag = mInterface
- .buildTag(ExifInterface.TAG_SHUTTER_SPEED_VALUE, new Rational(4, 6));
- // TYPE_ASCII with arbitrary length
- mInteropIndex = mInterface.buildTag(ExifInterface.TAG_INTEROPERABILITY_INDEX, "foo");
-
- mTestTags = new HashMap<Integer, ExifTag>();
-
- mTestTags.put(ExifInterface.TAG_EXIF_VERSION, mVersionTag);
- mTestTags.put(ExifInterface.TAG_GPS_VERSION_ID, mGpsVersionTag);
- mTestTags.put(ExifInterface.TAG_MODEL, mModelTag);
- mTestTags.put(ExifInterface.TAG_DATE_TIME, mDateTimeTag);
- mTestTags.put(ExifInterface.TAG_COMPRESSION, mCompressionTag);
- mTestTags.put(ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, mThumbnailFormatTag);
- mTestTags.put(ExifInterface.TAG_GPS_LONGITUDE, mLongitudeTag);
- mTestTags.put(ExifInterface.TAG_SHUTTER_SPEED_VALUE, mShutterTag);
- mTestTags.put(ExifInterface.TAG_INTEROPERABILITY_INDEX, mInteropIndex);
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- mInterface = null;
- mTestTags = null;
- }
-
- public void testAddTag() {
- ExifData exifData = new ExifData(ByteOrder.BIG_ENDIAN);
-
- // Add all test tags
- for (ExifTag t : mTestTags.values()) {
- assertTrue(exifData.addTag(t) == null);
- }
-
- // Make sure no initial thumbnails
- assertFalse(exifData.hasCompressedThumbnail());
- assertFalse(exifData.hasUncompressedStrip());
-
- // Check that we can set thumbnails
- exifData.setStripBytes(3, new byte[] {
- 1, 2, 3, 4, 5
- });
- assertTrue(exifData.hasUncompressedStrip());
- exifData.setCompressedThumbnail(new byte[] {
- 1
- });
- assertTrue(exifData.hasCompressedThumbnail());
-
- // Check that we can clear thumbnails
- exifData.clearThumbnailAndStrips();
- assertFalse(exifData.hasCompressedThumbnail());
- assertFalse(exifData.hasUncompressedStrip());
-
- // Make sure ifds exist
- for (int i : IfdData.getIfds()) {
- assertTrue(exifData.getIfdData(i) != null);
- }
-
- // Get all test tags
- List<ExifTag> allTags = exifData.getAllTags();
- assertTrue(allTags != null);
-
- // Make sure all test tags are in data
- for (ExifTag t : mTestTags.values()) {
- boolean check = false;
- for (ExifTag i : allTags) {
- if (t.equals(i)) {
- check = true;
- break;
- }
- }
- assertTrue(check);
- }
-
- // Check if getting tags for a tid works
- List<ExifTag> tidTags = exifData.getAllTagsForTagId(ExifInterface
- .getTrueTagKey(ExifInterface.TAG_SHUTTER_SPEED_VALUE));
- assertTrue(tidTags.size() == 1);
- assertTrue(tidTags.get(0).equals(mShutterTag));
-
- // Check if getting tags for an ifd works
- List<ExifTag> ifdTags = exifData.getAllTagsForIfd(IfdId.TYPE_IFD_INTEROPERABILITY);
- assertTrue(ifdTags.size() == 1);
- assertTrue(ifdTags.get(0).equals(mInteropIndex));
-
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifInterfaceTest.java b/tests/src/com/android/gallery3d/exif/ExifInterfaceTest.java
deleted file mode 100644
index af1ccfb..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifInterfaceTest.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * 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.exif;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-
-import java.io.ByteArrayInputStream;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ExifInterfaceTest extends ExifXmlDataTestCase {
-
- private File mTmpFile;
- private List<Map<Short, List<String>>> mGroundTruth;
- private ExifInterface mInterface;
- private ExifTag mVersionTag;
- private ExifTag mGpsVersionTag;
- private ExifTag mModelTag;
- private ExifTag mDateTimeTag;
- private ExifTag mCompressionTag;
- private ExifTag mThumbnailFormatTag;
- private ExifTag mLongitudeTag;
- private ExifTag mShutterTag;
- Map<Integer, ExifTag> mTestTags;
- Map<Integer, Integer> mTagDefinitions;
-
- public ExifInterfaceTest(int imageRes, int xmlRes) {
- super(imageRes, xmlRes);
- }
-
- public ExifInterfaceTest(String imagePath, String xmlPath) {
- super(imagePath, xmlPath);
- }
-
- public void testInterface() throws Exception {
-
- InputStream imageInputStream = null;
- try {
- // Basic checks
-
- // Check if bitmap is valid
- byte[] imgData = Util.readToByteArray(getImageInputStream());
- imageInputStream = new ByteArrayInputStream(imgData);
- checkBitmap(imageInputStream);
-
- // Check defines
- int tag = ExifInterface.defineTag(1, (short) 0x0100);
- assertTrue(getImageTitle(), tag == 0x00010100);
- int tagDef = mInterface.getTagDefinition((short) 0x0100, IfdId.TYPE_IFD_0);
- assertTrue(getImageTitle(), tagDef == 0x03040001);
- int[] allowed = ExifInterface.getAllowedIfdsFromInfo(mInterface.getTagInfo().get(
- ExifInterface.TAG_IMAGE_WIDTH));
- assertTrue(getImageTitle(), allowed.length == 2 && allowed[0] == IfdId.TYPE_IFD_0
- && allowed[1] == IfdId.TYPE_IFD_1);
-
- // Check if there are any initial tags
- assertTrue(getImageTitle(), mInterface.getAllTags() == null);
-
- // ///////// Basic read/write testing
-
- // Make sure we can read
- imageInputStream = new ByteArrayInputStream(imgData);
- mInterface.readExif(imageInputStream);
-
- // Check tags against ground truth
- checkTagsAgainstXml(mInterface.getAllTags());
-
- // Make sure clearing Exif works
- mInterface.clearExif();
- assertTrue(getImageTitle(), mInterface.getAllTags() == null);
-
- // Make sure setting tags works
- mInterface.setTags(mTestTags.values());
- checkTagsAgainstHash(mInterface.getAllTags(), mTestTags);
-
- // Try writing over bitmap exif
- ByteArrayOutputStream imgModified = new ByteArrayOutputStream();
- mInterface.writeExif(imgData, imgModified);
-
- // Check if bitmap is valid
- byte[] imgData2 = imgModified.toByteArray();
- imageInputStream = new ByteArrayInputStream(imgData2);
- checkBitmap(imageInputStream);
-
- // Make sure we get the same tags out
- imageInputStream = new ByteArrayInputStream(imgData2);
- mInterface.readExif(imageInputStream);
- checkTagsAgainstHash(mInterface.getAllTags(), mTestTags);
-
- // Reread original image
- imageInputStream = new ByteArrayInputStream(imgData);
- mInterface.readExif(imageInputStream);
-
- // Write out with original exif
- imgModified = new ByteArrayOutputStream();
- mInterface.writeExif(imgData2, imgModified);
-
- // Read back in exif and check tags
- imgData2 = imgModified.toByteArray();
- imageInputStream = new ByteArrayInputStream(imgData2);
- mInterface.readExif(imageInputStream);
- checkTagsAgainstXml(mInterface.getAllTags());
-
- // Check if bitmap is valid
- imageInputStream = new ByteArrayInputStream(imgData2);
- checkBitmap(imageInputStream);
-
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- } finally {
- Util.closeSilently(imageInputStream);
- }
- }
-
- public void testInterfaceModify() throws Exception {
-
- // TODO: This test is dependent on galaxy_nexus jpeg/xml file.
- InputStream imageInputStream = null;
- try {
- // Check if bitmap is valid
- byte[] imgData = Util.readToByteArray(getImageInputStream());
- imageInputStream = new ByteArrayInputStream(imgData);
- checkBitmap(imageInputStream);
-
- // ///////// Exif modifier testing.
-
- // Read exif and write to temp file
- imageInputStream = new ByteArrayInputStream(imgData);
- mInterface.readExif(imageInputStream);
- mInterface.writeExif(imgData, mTmpFile.getPath());
-
- // Check if bitmap is valid
- imageInputStream = new FileInputStream(mTmpFile);
- checkBitmap(imageInputStream);
-
- // Create some tags to overwrite with
- ArrayList<ExifTag> tags = new ArrayList<ExifTag>();
- tags.add(mInterface.buildTag(ExifInterface.TAG_ORIENTATION,
- ExifInterface.Orientation.RIGHT_TOP));
- tags.add(mInterface.buildTag(ExifInterface.TAG_USER_COMMENT, "goooooooooooooooooogle"));
-
- // Attempt to rewrite tags
- assertTrue(getImageTitle(), mInterface.rewriteExif(mTmpFile.getPath(), tags));
-
- imageInputStream.close();
- // Check if bitmap is valid
- imageInputStream = new FileInputStream(mTmpFile);
- checkBitmap(imageInputStream);
-
- // Read tags and check against xml
- mInterface.readExif(mTmpFile.getPath());
- for (ExifTag t : mInterface.getAllTags()) {
- short tid = t.getTagId();
- if (tid != ExifInterface.getTrueTagKey(ExifInterface.TAG_ORIENTATION)
- && tid != ExifInterface.getTrueTagKey(ExifInterface.TAG_USER_COMMENT)) {
- checkTagAgainstXml(t);
- }
- }
- assertTrue(getImageTitle(), mInterface.getTagIntValue(ExifInterface.TAG_ORIENTATION)
- .shortValue() == ExifInterface.Orientation.RIGHT_TOP);
- String valString = mInterface.getTagStringValue(ExifInterface.TAG_USER_COMMENT);
- assertTrue(getImageTitle(), valString.equals("goooooooooooooooooogle"));
-
- // Test forced modify
-
- // Create some tags to overwrite with
- tags = new ArrayList<ExifTag>();
- tags.add(mInterface.buildTag(ExifInterface.TAG_SOFTWARE, "magic super photomaker pro"));
- tags.add(mInterface.buildTag(ExifInterface.TAG_USER_COMMENT, "noodles"));
- tags.add(mInterface.buildTag(ExifInterface.TAG_ORIENTATION,
- ExifInterface.Orientation.TOP_LEFT));
-
- // Force rewrite tags
- mInterface.forceRewriteExif(mTmpFile.getPath(), tags);
-
- imageInputStream.close();
- // Check if bitmap is valid
- imageInputStream = new FileInputStream(mTmpFile);
- checkBitmap(imageInputStream);
-
- // Read tags and check against xml
- mInterface.readExif(mTmpFile.getPath());
- for (ExifTag t : mInterface.getAllTags()) {
- short tid = t.getTagId();
- if (!ExifInterface.isOffsetTag(tid)
- && tid != ExifInterface.getTrueTagKey(ExifInterface.TAG_SOFTWARE)
- && tid != ExifInterface.getTrueTagKey(ExifInterface.TAG_USER_COMMENT)) {
- checkTagAgainstXml(t);
- }
- }
- valString = mInterface.getTagStringValue(ExifInterface.TAG_SOFTWARE);
- String compareString = "magic super photomaker pro\0";
- assertTrue(getImageTitle(), valString.equals(compareString));
- valString = mInterface.getTagStringValue(ExifInterface.TAG_USER_COMMENT);
- assertTrue(getImageTitle(), valString.equals("noodles"));
-
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- } finally {
- Util.closeSilently(imageInputStream);
- }
- }
-
- public void testInterfaceDefines() throws Exception {
-
- InputStream imageInputStream = null;
- try {
- // Check if bitmap is valid
- byte[] imgData = Util.readToByteArray(getImageInputStream());
- imageInputStream = new ByteArrayInputStream(imgData);
- checkBitmap(imageInputStream);
-
- // Set some tags.
- mInterface.setTags(mTestTags.values());
-
- // Check tag definitions against default
- for (Integer i : mTestTags.keySet()) {
- int check = mTagDefinitions.get(i).intValue();
- int actual = mInterface.getTagInfo().get(i);
- assertTrue(check == actual);
- }
-
- // Check defines
- int tag1 = ExifInterface.defineTag(IfdId.TYPE_IFD_1, (short) 42);
- int tag2 = ExifInterface.defineTag(IfdId.TYPE_IFD_INTEROPERABILITY, (short) 43);
- assertTrue(tag1 == 0x0001002a);
- assertTrue(tag2 == 0x0003002b);
-
- // Define some non-standard tags
- assertTrue(mInterface.setTagDefinition((short) 42, IfdId.TYPE_IFD_1,
- ExifTag.TYPE_UNSIGNED_BYTE, (short) 16, new int[] {
- IfdId.TYPE_IFD_1
- }) == tag1);
- assertTrue(mInterface.getTagInfo().get(tag1) == 0x02010010);
- assertTrue(mInterface.setTagDefinition((short) 43, IfdId.TYPE_IFD_INTEROPERABILITY,
- ExifTag.TYPE_ASCII, (short) 5, new int[] {
- IfdId.TYPE_IFD_GPS, IfdId.TYPE_IFD_INTEROPERABILITY
- }) == tag2);
- assertTrue(mInterface.getTagInfo().get(tag2) == 0x18020005);
-
- // Make sure these don't work
- assertTrue(mInterface.setTagDefinition((short) 42, IfdId.TYPE_IFD_1,
- ExifTag.TYPE_UNSIGNED_BYTE, (short) 16, new int[] {
- IfdId.TYPE_IFD_0
- }) == ExifInterface.TAG_NULL);
- assertTrue(mInterface.setTagDefinition((short) 42, IfdId.TYPE_IFD_1, (short) 0,
- (short) 16, new int[] {
- IfdId.TYPE_IFD_1
- }) == ExifInterface.TAG_NULL);
- assertTrue(mInterface.setTagDefinition((short) 42, 5, ExifTag.TYPE_UNSIGNED_BYTE,
- (short) 16, new int[] {
- 5
- }) == ExifInterface.TAG_NULL);
- assertTrue(mInterface.setTagDefinition((short) 42, IfdId.TYPE_IFD_1,
- ExifTag.TYPE_UNSIGNED_BYTE, (short) 16, new int[] {
- -1
- }) == ExifInterface.TAG_NULL);
- assertTrue(mInterface.setTagDefinition((short) 43, IfdId.TYPE_IFD_GPS,
- ExifTag.TYPE_ASCII, (short) 5, new int[] {
- IfdId.TYPE_IFD_GPS
- }) == ExifInterface.TAG_NULL);
- assertTrue(mInterface.setTagDefinition((short) 43, IfdId.TYPE_IFD_0,
- ExifTag.TYPE_ASCII, (short) 5, new int[] {
- IfdId.TYPE_IFD_0, IfdId.TYPE_IFD_GPS
- }) == ExifInterface.TAG_NULL);
-
- // Set some tags
- mInterface.setTags(mTestTags.values());
- checkTagsAgainstHash(mInterface.getAllTags(), mTestTags);
-
- // Make some tags using new defines
- ExifTag defTag0 = mInterface.buildTag(tag1, new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
- });
- assertTrue(defTag0 != null);
- ExifTag defTag1 = mInterface.buildTag(tag2, "hihi");
- assertTrue(defTag1 != null);
- ExifTag defTag2 = mInterface.buildTag(tag2, IfdId.TYPE_IFD_GPS, "byte");
- assertTrue(defTag2 != null);
-
- // Make sure these don't work
- ExifTag badTag = mInterface.buildTag(tag1, new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
- });
- assertTrue(badTag == null);
- badTag = mInterface.buildTag(tag1, IfdId.TYPE_IFD_0, new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
- });
- assertTrue(badTag == null);
- badTag = mInterface.buildTag(0x0002002a, new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
- });
- assertTrue(badTag == null);
- badTag = mInterface.buildTag(tag2, new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
- });
- assertTrue(badTag == null);
-
- // Set the tags
- assertTrue(mInterface.setTag(defTag0) == null);
- assertTrue(mInterface.setTag(defTag1) == null);
- assertTrue(mInterface.setTag(defTag2) == null);
- assertTrue(mInterface.setTag(defTag0).equals(defTag0));
- assertTrue(mInterface.setTag(null) == null);
- assertTrue(mInterface.setTagValue(tag2, "yoyo") == true);
- assertTrue(mInterface.setTagValue(tag2, "yaaarggg") == false);
- assertTrue(mInterface.getTagStringValue(tag2).equals("yoyo\0"));
-
- // Try writing over bitmap exif
- ByteArrayOutputStream imgModified = new ByteArrayOutputStream();
- mInterface.writeExif(imgData, imgModified);
-
- // Check if bitmap is valid
- byte[] imgData2 = imgModified.toByteArray();
- imageInputStream = new ByteArrayInputStream(imgData2);
- checkBitmap(imageInputStream);
-
- // Read back in the tags
- mInterface.readExif(imgData2);
-
- // Check tags
- for (ExifTag t : mInterface.getAllTags()) {
- int tid = t.getTagId();
- if (tid != ExifInterface.getTrueTagKey(tag1)
- && tid != ExifInterface.getTrueTagKey(tag2)) {
- checkTagAgainstHash(t, mTestTags);
- }
- }
- assertTrue(Arrays.equals(mInterface.getTagByteValues(tag1), new byte[] {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
- }));
- assertTrue(mInterface.getTagStringValue(tag2).equals("yoyo\0"));
- assertTrue(mInterface.getTagStringValue(tag2, IfdId.TYPE_IFD_GPS).equals("byte\0"));
-
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- } finally {
- Util.closeSilently(imageInputStream);
- }
- }
-
- public void testInterfaceThumbnails() throws Exception {
-
- InputStream imageInputStream = null;
- try {
- // Check if bitmap is valid
- byte[] imgData = Util.readToByteArray(getImageInputStream());
- imageInputStream = new ByteArrayInputStream(imgData);
- checkBitmap(imageInputStream);
-
- // Check thumbnails
- mInterface.readExif(imgData);
- Bitmap bmap = mInterface.getThumbnailBitmap();
- assertTrue(getImageTitle(), bmap != null);
-
- // Make a new thumbnail and set it
- BitmapFactory.Options opts = new BitmapFactory.Options();
- opts.inSampleSize = 16;
- Bitmap thumb = BitmapFactory.decodeByteArray(imgData, 0, imgData.length, opts);
- assertTrue(getImageTitle(), thumb != null);
- assertTrue(getImageTitle(), mInterface.setCompressedThumbnail(thumb) == true);
-
- // Write out image
- ByteArrayOutputStream outData = new ByteArrayOutputStream();
- mInterface.writeExif(imgData, outData);
-
- // Make sure bitmap is still valid
- byte[] imgData2 = outData.toByteArray();
- imageInputStream = new ByteArrayInputStream(imgData2);
- checkBitmap(imageInputStream);
-
- // Read in bitmap and make sure thumbnail is still valid
- mInterface.readExif(imgData2);
- bmap = mInterface.getThumbnailBitmap();
- assertTrue(getImageTitle(), bmap != null);
-
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- } finally {
- Util.closeSilently(imageInputStream);
- }
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mTmpFile = File.createTempFile("exif_test", ".jpg");
- mGroundTruth = ExifXmlReader.readXml(getXmlParser());
-
- mInterface = new ExifInterface();
-
- // TYPE_UNDEFINED with 4 components
- mVersionTag = mInterface.buildTag(ExifInterface.TAG_EXIF_VERSION, new byte[] {
- 5, 4, 3, 2
- });
- // TYPE_UNSIGNED_BYTE with 4 components
- mGpsVersionTag = mInterface.buildTag(ExifInterface.TAG_GPS_VERSION_ID, new byte[] {
- 6, 7, 8, 9
- });
- // TYPE ASCII with arbitary length
- mModelTag = mInterface.buildTag(ExifInterface.TAG_MODEL, "helloworld");
- // TYPE_ASCII with 20 components
- mDateTimeTag = mInterface.buildTag(ExifInterface.TAG_DATE_TIME, "2013:02:11 20:20:20");
- // TYPE_UNSIGNED_SHORT with 1 components
- mCompressionTag = mInterface.buildTag(ExifInterface.TAG_COMPRESSION, 100);
- // TYPE_UNSIGNED_LONG with 1 components
- mThumbnailFormatTag =
- mInterface.buildTag(ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, 100);
- // TYPE_UNSIGNED_RATIONAL with 3 components
- mLongitudeTag = mInterface.buildTag(ExifInterface.TAG_GPS_LONGITUDE, new Rational[] {
- new Rational(2, 2), new Rational(11, 11),
- new Rational(102, 102)
- });
- // TYPE_RATIONAL with 1 components
- mShutterTag = mInterface
- .buildTag(ExifInterface.TAG_SHUTTER_SPEED_VALUE, new Rational(4, 6));
-
- mTestTags = new HashMap<Integer, ExifTag>();
-
- mTestTags.put(ExifInterface.TAG_EXIF_VERSION, mVersionTag);
- mTestTags.put(ExifInterface.TAG_GPS_VERSION_ID, mGpsVersionTag);
- mTestTags.put(ExifInterface.TAG_MODEL, mModelTag);
- mTestTags.put(ExifInterface.TAG_DATE_TIME, mDateTimeTag);
- mTestTags.put(ExifInterface.TAG_COMPRESSION, mCompressionTag);
- mTestTags.put(ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, mThumbnailFormatTag);
- mTestTags.put(ExifInterface.TAG_GPS_LONGITUDE, mLongitudeTag);
- mTestTags.put(ExifInterface.TAG_SHUTTER_SPEED_VALUE, mShutterTag);
-
- mTagDefinitions = new HashMap<Integer, Integer>();
- mTagDefinitions.put(ExifInterface.TAG_EXIF_VERSION, 0x04070004);
- mTagDefinitions.put(ExifInterface.TAG_GPS_VERSION_ID, 0x10010004);
- mTagDefinitions.put(ExifInterface.TAG_MODEL, 0x03020000);
- mTagDefinitions.put(ExifInterface.TAG_DATE_TIME, 0x03020014);
- mTagDefinitions.put(ExifInterface.TAG_COMPRESSION, 0x03030001);
- mTagDefinitions.put(ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, 0x02040001);
- mTagDefinitions.put(ExifInterface.TAG_GPS_LONGITUDE, 0x100a0003);
- mTagDefinitions.put(ExifInterface.TAG_SHUTTER_SPEED_VALUE, 0x040a0001);
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- mTmpFile.delete();
- }
-
- // Helper functions
-
- private void checkTagAgainstXml(ExifTag tag) {
- List<String> truth = mGroundTruth.get(tag.getIfd()).get(tag.getTagId());
-
- if (truth == null) {
- fail(String.format("Unknown Tag %02x", tag.getTagId()) + ", " + getImageTitle());
- }
-
- // No value from exiftool.
- if (truth.contains(null))
- return;
-
- String dataString = Util.tagValueToString(tag).trim();
- assertTrue(String.format("Tag %02x", tag.getTagId()) + ", " + getImageTitle()
- + ": " + dataString,
- truth.contains(dataString));
- }
-
- private void checkTagsAgainstXml(List<ExifTag> tags) {
- for (ExifTag t : tags) {
- checkTagAgainstXml(t);
- }
- }
-
- private void checkTagAgainstHash(ExifTag tag, Map<Integer, ExifTag> testTags) {
- int tagdef = mInterface.getTagDefinitionForTag(tag);
- assertTrue(getImageTitle(), tagdef != ExifInterface.TAG_NULL);
- ExifTag t = testTags.get(tagdef);
- // Ignore offset tags & other special tags
- if (!ExifInterface.sBannedDefines.contains(tag.getTagId())) {
- assertTrue(getImageTitle(), t != null);
- } else {
- return;
- }
- if (t == tag)
- return;
- assertTrue(getImageTitle(), tag.equals(t));
- assertTrue(getImageTitle(), tag.getDataType() == t.getDataType());
- assertTrue(getImageTitle(), tag.getTagId() == t.getTagId());
- assertTrue(getImageTitle(), tag.getIfd() == t.getIfd());
- assertTrue(getImageTitle(), tag.getComponentCount() == t.getComponentCount());
- }
-
- private void checkTagsAgainstHash(List<ExifTag> tags, Map<Integer, ExifTag> testTags) {
- for (ExifTag t : tags) {
- checkTagAgainstHash(t, testTags);
- }
- }
-
- private void checkBitmap(InputStream inputStream) throws IOException {
- Bitmap bmp = BitmapFactory.decodeStream(inputStream);
- assertTrue(getImageTitle(), bmp != null);
- }
-
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifModifierTest.java b/tests/src/com/android/gallery3d/exif/ExifModifierTest.java
deleted file mode 100644
index 713a9d9..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifModifierTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel.MapMode;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ExifModifierTest extends ExifXmlDataTestCase {
-
- private File mTmpFile;
- private List<Map<Short, List<String>>> mGroundTruth;
- private ExifInterface mInterface;
- private Map<Short, ExifTag> mTestTags;
- ExifTag mVersionTag;
- ExifTag mGpsVersionTag;
- ExifTag mModelTag;
- ExifTag mDateTimeTag;
- ExifTag mCompressionTag;
- ExifTag mThumbnailFormatTag;
- ExifTag mLongitudeTag;
- ExifTag mShutterTag;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mGroundTruth = ExifXmlReader.readXml(getXmlParser());
- mTmpFile = File.createTempFile("exif_test", ".jpg");
- FileOutputStream os = null;
- InputStream is = getImageInputStream();
- try {
- os = new FileOutputStream(mTmpFile);
- byte[] buf = new byte[1024];
- int n;
- while ((n = is.read(buf)) > 0) {
- os.write(buf, 0, n);
- }
- } finally {
- Util.closeSilently(os);
- }
-
- // TYPE_UNDEFINED with 4 components
- mVersionTag = mInterface.buildTag(ExifInterface.TAG_EXIF_VERSION, new byte[] {
- 1, 2, 3, 4
- });
- // TYPE_UNSIGNED_BYTE with 4 components
- mGpsVersionTag = mInterface.buildTag(ExifInterface.TAG_GPS_VERSION_ID, new byte[] {
- 4, 3, 2, 1
- });
- // TYPE ASCII with arbitary length
- mModelTag = mInterface.buildTag(ExifInterface.TAG_MODEL, "end-of-the-world");
- // TYPE_ASCII with 20 components
- mDateTimeTag = mInterface.buildTag(ExifInterface.TAG_DATE_TIME, "2012:12:31 23:59:59");
- // TYPE_UNSIGNED_SHORT with 1 components
- mCompressionTag = mInterface.buildTag(ExifInterface.TAG_COMPRESSION, 100);
- // TYPE_UNSIGNED_LONG with 1 components
- mThumbnailFormatTag =
- mInterface.buildTag(ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, 100);
- // TYPE_UNSIGNED_RATIONAL with 3 components
- mLongitudeTag = mInterface.buildTag(ExifInterface.TAG_GPS_LONGITUDE, new Rational[] {
- new Rational(1, 1), new Rational(10, 10),
- new Rational(100, 100)
- });
- // TYPE_RATIONAL with 1 components
- mShutterTag = mInterface
- .buildTag(ExifInterface.TAG_SHUTTER_SPEED_VALUE, new Rational(1, 1));
-
- mTestTags = new HashMap<Short, ExifTag>();
-
- mTestTags.put(mVersionTag.getTagId(), mVersionTag);
- mTestTags.put(mGpsVersionTag.getTagId(), mGpsVersionTag);
- mTestTags.put(mModelTag.getTagId(), mModelTag);
- mTestTags.put(mDateTimeTag.getTagId(), mDateTimeTag);
- mTestTags.put(mCompressionTag.getTagId(), mCompressionTag);
- mTestTags.put(mThumbnailFormatTag.getTagId(), mThumbnailFormatTag);
- mTestTags.put(mLongitudeTag.getTagId(), mLongitudeTag);
- mTestTags.put(mShutterTag.getTagId(), mShutterTag);
- }
-
- public ExifModifierTest(int imageRes, int xmlRes) {
- super(imageRes, xmlRes);
- mInterface = new ExifInterface();
- }
-
- public ExifModifierTest(String imagePath, String xmlPath) {
- super(imagePath, xmlPath);
- mInterface = new ExifInterface();
- }
-
- public void testModify() throws Exception {
- Map<Short, Boolean> results = new HashMap<Short, Boolean>();
-
- RandomAccessFile file = null;
- try {
- file = new RandomAccessFile(mTmpFile, "rw");
- MappedByteBuffer buf = file.getChannel().map(MapMode.READ_WRITE, 0, file.length());
- for (ExifTag tag : mTestTags.values()) {
- ExifModifier modifier = new ExifModifier(buf, mInterface);
- modifier.modifyTag(tag);
- boolean result = modifier.commit();
- results.put(tag.getTagId(), result);
- buf.force();
- buf.position(0);
-
- if (!result) {
- List<String> value = mGroundTruth.get(tag.getIfd()).get(tag.getTagId());
- assertTrue(String.format("Tag %x, ", tag.getTagId()) + getImageTitle(),
- value == null || tag.getTagId() == ExifInterface.TAG_MODEL);
- }
- }
- } finally {
- Util.closeSilently(file);
- }
-
- // Parse the new file and check the result
- InputStream is = null;
- try {
- is = new FileInputStream(mTmpFile);
- ExifData data = new ExifReader(mInterface).read(is);
- for (int i = 0; i < IfdId.TYPE_IFD_COUNT; i++) {
- checkIfd(data.getIfdData(i), mGroundTruth.get(i), results);
- }
- } finally {
- Util.closeSilently(is);
- }
-
- }
-
- private void checkIfd(IfdData ifd, Map<Short, List<String>> ifdValue,
- Map<Short, Boolean> results) {
- if (ifd == null) {
- assertEquals(getImageTitle(), 0, ifdValue.size());
- return;
- }
- ExifTag[] tags = ifd.getAllTags();
- for (ExifTag tag : tags) {
- List<String> truth = ifdValue.get(tag.getTagId());
- assertNotNull(String.format("Tag %x, ", tag.getTagId()) + getImageTitle(), truth);
- if (truth.contains(null)) {
- continue;
- }
-
- ExifTag newTag = mTestTags.get(tag.getTagId());
- if (newTag != null
- && results.get(tag.getTagId())) {
- assertEquals(String.format("Tag %x, ", tag.getTagId()) + getImageTitle(),
- Util.tagValueToString(newTag), Util.tagValueToString(tag));
- } else {
- assertTrue(String.format("Tag %x, ", tag.getTagId()) + getImageTitle(),
- truth.contains(Util.tagValueToString(tag).trim()));
- }
- }
- assertEquals(getImageTitle(), ifdValue.size(), tags.length);
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- mTmpFile.delete();
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifOutputStreamTest.java b/tests/src/com/android/gallery3d/exif/ExifOutputStreamTest.java
deleted file mode 100644
index 1286c58..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifOutputStreamTest.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.util.Log;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class ExifOutputStreamTest extends ExifXmlDataTestCase {
-
- private File mTmpFile;
-
- private ExifInterface mInterface;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mTmpFile = File.createTempFile("exif_test", ".jpg");
- }
-
- public ExifOutputStreamTest(int imgRes, int xmlRes) {
- super(imgRes, xmlRes);
- mInterface = new ExifInterface();
- }
-
- public ExifOutputStreamTest(String imgPath, String xmlPath) {
- super(imgPath, xmlPath);
- mInterface = new ExifInterface();
- }
-
- public void testExifOutputStream() throws Exception {
- InputStream imageInputStream = null;
- InputStream exifInputStream = null;
- FileInputStream reDecodeInputStream = null;
- FileInputStream reParseInputStream = null;
-
- InputStream dangerInputStream = null;
- OutputStream dangerOutputStream = null;
- try {
- try {
- byte[] imgData = Util.readToByteArray(getImageInputStream());
- imageInputStream = new ByteArrayInputStream(imgData);
- exifInputStream = new ByteArrayInputStream(imgData);
-
- // Read the image data
- Bitmap bmp = BitmapFactory.decodeStream(imageInputStream);
- // The image is invalid
- if (bmp == null) {
- return;
- }
-
- // Read exif data
- ExifData exifData = new ExifReader(mInterface).read(exifInputStream);
-
- // Encode the image with the exif data
- FileOutputStream outputStream = new FileOutputStream(mTmpFile);
- ExifOutputStream exifOutputStream = new ExifOutputStream(outputStream, mInterface);
- exifOutputStream.setExifData(exifData);
- bmp.compress(Bitmap.CompressFormat.JPEG, 90, exifOutputStream);
- exifOutputStream.close();
- exifOutputStream = null;
-
- // Re-decode the temp file and check the data.
- reDecodeInputStream = new FileInputStream(mTmpFile);
- Bitmap decodedBmp = BitmapFactory.decodeStream(reDecodeInputStream);
- assertNotNull(getImageTitle(), decodedBmp);
- reDecodeInputStream.close();
-
- // Re-parse the temp file the check EXIF tag
- reParseInputStream = new FileInputStream(mTmpFile);
- ExifData reExifData = new ExifReader(mInterface).read(reParseInputStream);
- assertEquals(getImageTitle(), exifData, reExifData);
- reParseInputStream.close();
-
- // Try writing exif to file with existing exif.
- dangerOutputStream = (OutputStream) new FileOutputStream(mTmpFile);
- exifOutputStream = new ExifOutputStream(dangerOutputStream, mInterface);
- exifOutputStream.setExifData(exifData);
- exifOutputStream.write(imgData);
- // exifOutputStream.write(strippedImgData);
- exifOutputStream.close();
- exifOutputStream = null;
-
- // Make sure it still can be parsed into a bitmap.
- dangerInputStream = (InputStream) new FileInputStream(mTmpFile);
- decodedBmp = null;
- decodedBmp = BitmapFactory.decodeStream(dangerInputStream);
- assertNotNull(getImageTitle(), decodedBmp);
- dangerInputStream.close();
- dangerInputStream = null;
-
- // Make sure exif is still well-formatted.
- dangerInputStream = (InputStream) new FileInputStream(mTmpFile);
- reExifData = null;
- reExifData = new ExifReader(mInterface).read(dangerInputStream);
- assertEquals(getImageTitle(), exifData, reExifData);
- dangerInputStream.close();
- dangerInputStream = null;
-
- } finally {
- Util.closeSilently(imageInputStream);
- Util.closeSilently(exifInputStream);
- Util.closeSilently(reDecodeInputStream);
- Util.closeSilently(reParseInputStream);
-
- Util.closeSilently(dangerInputStream);
- Util.closeSilently(dangerOutputStream);
- }
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-
- public void testOutputSpeed() throws Exception {
- final String LOGTAG = "testOutputSpeed";
- InputStream imageInputStream = null;
- OutputStream imageOutputStream = null;
- try {
- try {
- imageInputStream = getImageInputStream();
- // Read the image data
- Bitmap bmp = BitmapFactory.decodeStream(imageInputStream);
- // The image is invalid
- if (bmp == null) {
- return;
- }
- imageInputStream.close();
- int nLoops = 20;
- long totalReadDuration = 0;
- long totalWriteDuration = 0;
- for (int i = 0; i < nLoops; i++) {
- imageInputStream = reopenFileStream();
- // Read exif data
- long startTime = System.nanoTime();
- ExifData exifData = new ExifReader(mInterface).read(imageInputStream);
- long endTime = System.nanoTime();
- long duration = endTime - startTime;
- totalReadDuration += duration;
- Log.v(LOGTAG, " read time: " + duration);
- imageInputStream.close();
-
- // Encode the image with the exif data
- imageOutputStream = (OutputStream) new FileOutputStream(mTmpFile);
- ExifOutputStream exifOutputStream = new ExifOutputStream(imageOutputStream,
- mInterface);
- exifOutputStream.setExifData(exifData);
- startTime = System.nanoTime();
- bmp.compress(Bitmap.CompressFormat.JPEG, 90, exifOutputStream);
- endTime = System.nanoTime();
- duration = endTime - startTime;
- totalWriteDuration += duration;
- Log.v(LOGTAG, " write time: " + duration);
- exifOutputStream.close();
- }
- Log.v(LOGTAG, "======================= normal");
- Log.v(LOGTAG, "avg read time: " + totalReadDuration / nLoops);
- Log.v(LOGTAG, "avg write time: " + totalWriteDuration / nLoops);
- Log.v(LOGTAG, "=======================");
- } finally {
- Util.closeSilently(imageInputStream);
- Util.closeSilently(imageOutputStream);
- }
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- mTmpFile.delete();
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifParserTest.java b/tests/src/com/android/gallery3d/exif/ExifParserTest.java
deleted file mode 100644
index 5c3fd24..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifParserTest.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-
-import java.util.List;
-import java.util.Map;
-
-public class ExifParserTest extends ExifXmlDataTestCase {
- private static final String TAG = "ExifParserTest";
-
- private ExifInterface mInterface;
-
- public ExifParserTest(int imgRes, int xmlRes) {
- super(imgRes, xmlRes);
- mInterface = new ExifInterface();
- }
-
- public ExifParserTest(String imgPath, String xmlPath) {
- super(imgPath, xmlPath);
- mInterface = new ExifInterface();
- }
-
- private List<Map<Short, List<String>>> mGroundTruth;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mGroundTruth = ExifXmlReader.readXml(getXmlParser());
- }
-
- public void testParse() throws Exception {
- try {
- ExifParser parser = ExifParser.parse(getImageInputStream(), mInterface);
- int event = parser.next();
- while (event != ExifParser.EVENT_END) {
- switch (event) {
- case ExifParser.EVENT_START_OF_IFD:
- break;
- case ExifParser.EVENT_NEW_TAG:
- ExifTag tag = parser.getTag();
- if (!tag.hasValue()) {
- parser.registerForTagValue(tag);
- } else {
- checkTag(tag);
- }
- break;
- case ExifParser.EVENT_VALUE_OF_REGISTERED_TAG:
- tag = parser.getTag();
- if (tag.getDataType() == ExifTag.TYPE_UNDEFINED) {
- byte[] buf = new byte[tag.getComponentCount()];
- parser.read(buf);
- assertTrue(TAG, tag.setValue(buf));
- }
- checkTag(tag);
- break;
- }
- event = parser.next();
- }
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-
- private void checkTag(ExifTag tag) {
- List<String> truth = mGroundTruth.get(tag.getIfd()).get(tag.getTagId());
-
- if (truth == null) {
- fail(String.format("Unknown Tag %02x", tag.getTagId()) + ", " + getImageTitle());
- }
-
- // No value from exiftool.
- if (truth.contains(null)) {
- return;
- }
-
- String dataString = Util.tagValueToString(tag).trim();
- assertTrue(String.format("Tag %02x", tag.getTagId()) + ", " + getImageTitle()
- + ": " + dataString,
- truth.contains(dataString));
- }
-
- private void parseOneIfd(int ifd, int options) throws Exception {
- try {
- Map<Short, List<String>> expectedResult = mGroundTruth.get(ifd);
- int numOfTag = 0;
- ExifParser parser = ExifParser.parse(getImageInputStream(), options, mInterface);
- int event = parser.next();
- while (event != ExifParser.EVENT_END) {
- switch (event) {
- case ExifParser.EVENT_START_OF_IFD:
- assertEquals(getImageTitle(), ifd, parser.getCurrentIfd());
- break;
- case ExifParser.EVENT_NEW_TAG:
- ExifTag tag = parser.getTag();
- numOfTag++;
- if (tag.hasValue()) {
- checkTag(tag);
- } else {
- parser.registerForTagValue(tag);
- }
- break;
- case ExifParser.EVENT_VALUE_OF_REGISTERED_TAG:
- tag = parser.getTag();
- if (tag.getDataType() == ExifTag.TYPE_UNDEFINED) {
- byte[] buf = new byte[tag.getComponentCount()];
- parser.read(buf);
- tag.setValue(buf);
- }
- checkTag(tag);
- break;
- case ExifParser.EVENT_COMPRESSED_IMAGE:
- case ExifParser.EVENT_UNCOMPRESSED_STRIP:
- fail("Invalid Event type: " + event + ", " + getImageTitle());
- break;
- }
- event = parser.next();
- }
- assertEquals(getImageTitle(), ExifXmlReader.getTrueTagNumber(expectedResult), numOfTag);
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-
- public void testOnlyExifIfd() throws Exception {
- parseOneIfd(IfdId.TYPE_IFD_EXIF, ExifParser.OPTION_IFD_EXIF);
- }
-
- public void testOnlyIfd0() throws Exception {
- parseOneIfd(IfdId.TYPE_IFD_0, ExifParser.OPTION_IFD_0);
- }
-
- public void testOnlyIfd1() throws Exception {
- parseOneIfd(IfdId.TYPE_IFD_1, ExifParser.OPTION_IFD_1);
- }
-
- public void testOnlyInteroperabilityIfd() throws Exception {
- parseOneIfd(IfdId.TYPE_IFD_INTEROPERABILITY, ExifParser.OPTION_IFD_INTEROPERABILITY);
- }
-
- public void testOnlyReadSomeTag() throws Exception {
- // Do not do this test if there is no model tag.
- if (mGroundTruth.get(IfdId.TYPE_IFD_0).get(ExifInterface.TAG_MODEL) == null) {
- return;
- }
-
- try {
- ExifParser parser = ExifParser.parse(getImageInputStream(), ExifParser.OPTION_IFD_0,
- mInterface);
- int event = parser.next();
- boolean isTagFound = false;
- while (event != ExifParser.EVENT_END) {
- switch (event) {
- case ExifParser.EVENT_START_OF_IFD:
- assertEquals(getImageTitle(), IfdId.TYPE_IFD_0, parser.getCurrentIfd());
- break;
- case ExifParser.EVENT_NEW_TAG:
- ExifTag tag = parser.getTag();
- if (tag.getTagId() == ExifInterface.TAG_MODEL) {
- if (tag.hasValue()) {
- isTagFound = true;
- checkTag(tag);
- } else {
- parser.registerForTagValue(tag);
- }
- parser.skipRemainingTagsInCurrentIfd();
- }
- break;
- case ExifParser.EVENT_VALUE_OF_REGISTERED_TAG:
- tag = parser.getTag();
- assertEquals(getImageTitle(), ExifInterface.TAG_MODEL, tag.getTagId());
- checkTag(tag);
- isTagFound = true;
- break;
- }
- event = parser.next();
- }
- assertTrue(getImageTitle(), isTagFound);
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-
- public void testReadThumbnail() throws Exception {
- try {
- ExifParser parser = ExifParser.parse(getImageInputStream(),
- ExifParser.OPTION_IFD_1 | ExifParser.OPTION_THUMBNAIL, mInterface);
-
- int event = parser.next();
- Bitmap bmp = null;
- boolean mIsContainCompressedImage = false;
- while (event != ExifParser.EVENT_END) {
- switch (event) {
- case ExifParser.EVENT_NEW_TAG:
- ExifTag tag = parser.getTag();
- if (tag.getTagId() == ExifInterface.TAG_COMPRESSION) {
- if (tag.getValueAt(0) == ExifInterface.Compression.JPEG) {
- mIsContainCompressedImage = true;
- }
- }
- break;
- case ExifParser.EVENT_COMPRESSED_IMAGE:
- int imageSize = parser.getCompressedImageSize();
- byte buf[] = new byte[imageSize];
- parser.read(buf);
- bmp = BitmapFactory.decodeByteArray(buf, 0, imageSize);
- break;
- }
- event = parser.next();
- }
- if (mIsContainCompressedImage) {
- assertNotNull(getImageTitle(), bmp);
- }
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java b/tests/src/com/android/gallery3d/exif/ExifReaderTest.java
deleted file mode 100644
index a057186..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifReaderTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import android.graphics.BitmapFactory;
-
-import java.util.List;
-import java.util.Map;
-
-public class ExifReaderTest extends ExifXmlDataTestCase {
- private static final String TAG = "ExifReaderTest";
-
- private ExifInterface mInterface;
- private List<Map<Short, List<String>>> mGroundTruth;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mGroundTruth = ExifXmlReader.readXml(getXmlParser());
- }
-
- public ExifReaderTest(int imgRes, int xmlRes) {
- super(imgRes, xmlRes);
- mInterface = new ExifInterface();
- }
-
- public ExifReaderTest(String imgPath, String xmlPath) {
- super(imgPath, xmlPath);
- mInterface = new ExifInterface();
- }
-
- public void testRead() throws Exception {
- try {
- ExifReader reader = new ExifReader(mInterface);
- ExifData exifData = reader.read(getImageInputStream());
- for (int i = 0; i < IfdId.TYPE_IFD_COUNT; i++) {
- checkIfd(exifData.getIfdData(i), mGroundTruth.get(i));
- }
- checkThumbnail(exifData);
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-
- private void checkThumbnail(ExifData exifData) {
- Map<Short, List<String>> ifd1Truth = mGroundTruth.get(IfdId.TYPE_IFD_1);
-
- List<String> typeTagValue = ifd1Truth.get(ExifInterface.TAG_COMPRESSION);
- if (typeTagValue == null)
- return;
-
- IfdData ifd1 = exifData.getIfdData(IfdId.TYPE_IFD_1);
- if (ifd1 == null)
- fail(getImageTitle() + ": failed to find IFD1");
-
- String typeTagTruth = typeTagValue.get(0);
-
- int type = (int) ifd1.getTag(ExifInterface.getTrueTagKey(ExifInterface.TAG_COMPRESSION))
- .getValueAt(0);
-
- if (String.valueOf(ExifInterface.Compression.JPEG).equals(typeTagTruth)) {
- assertTrue(getImageTitle(), type == ExifInterface.Compression.JPEG);
- assertTrue(getImageTitle(), exifData.hasCompressedThumbnail());
- byte[] thumbnail = exifData.getCompressedThumbnail();
- assertTrue(getImageTitle(),
- BitmapFactory.decodeByteArray(thumbnail, 0, thumbnail.length) != null);
- } else if (String.valueOf(ExifInterface.Compression.UNCOMPRESSION).equals(typeTagTruth)) {
- assertTrue(getImageTitle(), type == ExifInterface.Compression.UNCOMPRESSION);
- // Try to check the strip count with the formula provided by EXIF spec.
- int planarType = ExifInterface.PlanarConfiguration.CHUNKY;
- ExifTag planarTag = ifd1.getTag(ExifInterface
- .getTrueTagKey(ExifInterface.TAG_PLANAR_CONFIGURATION));
- if (planarTag != null) {
- planarType = (int) planarTag.getValueAt(0);
- }
-
- if (!ifd1Truth.containsKey(ExifInterface.TAG_IMAGE_LENGTH) ||
- !ifd1Truth.containsKey(ExifInterface.TAG_ROWS_PER_STRIP)) {
- return;
- }
-
- ExifTag heightTag = ifd1.getTag(ExifInterface
- .getTrueTagKey(ExifInterface.TAG_IMAGE_LENGTH));
- ExifTag rowPerStripTag = ifd1.getTag(ExifInterface
- .getTrueTagKey(ExifInterface.TAG_ROWS_PER_STRIP));
-
- // Fail the test if required tags are missing
- if (heightTag == null || rowPerStripTag == null) {
- fail(getImageTitle());
- }
-
- int imageLength = (int) heightTag.getValueAt(0);
- int rowsPerStrip = (int) rowPerStripTag.getValueAt(0);
- int stripCount = ifd1.getTag(
- ExifInterface.getTrueTagKey(ExifInterface.TAG_STRIP_OFFSETS))
- .getComponentCount();
-
- if (planarType == ExifInterface.PlanarConfiguration.CHUNKY) {
- assertTrue(getImageTitle(),
- stripCount == (imageLength + rowsPerStrip - 1) / rowsPerStrip);
- } else {
- if (!ifd1Truth.containsKey(ExifInterface.TAG_SAMPLES_PER_PIXEL)) {
- return;
- }
- ExifTag samplePerPixelTag = ifd1.getTag(ExifInterface
- .getTrueTagKey(ExifInterface.TAG_SAMPLES_PER_PIXEL));
- int samplePerPixel = (int) samplePerPixelTag.getValueAt(0);
- assertTrue(getImageTitle(),
- stripCount ==
- (imageLength + rowsPerStrip - 1) / rowsPerStrip * samplePerPixel);
- }
-
- if (!ifd1Truth.containsKey(ExifInterface.TAG_STRIP_BYTE_COUNTS)) {
- return;
- }
- ExifTag byteCountTag = ifd1.getTag(ExifInterface
- .getTrueTagKey(ExifInterface.TAG_STRIP_BYTE_COUNTS));
- short byteCountDataType = byteCountTag.getDataType();
- for (int i = 0; i < stripCount; i++) {
- if (byteCountDataType == ExifTag.TYPE_UNSIGNED_SHORT) {
- assertEquals(getImageTitle(),
- byteCountTag.getValueAt(i), exifData.getStrip(i).length);
- } else {
- assertEquals(getImageTitle(),
- byteCountTag.getValueAt(i), exifData.getStrip(i).length);
- }
- }
- }
- }
-
- private void checkIfd(IfdData ifd, Map<Short, List<String>> ifdValue) {
- if (ifd == null) {
- assertEquals(getImageTitle(), 0, ifdValue.size());
- return;
- }
- ExifTag[] tags = ifd.getAllTags();
- for (ExifTag tag : tags) {
- List<String> truth = ifdValue.get(tag.getTagId());
- assertNotNull(String.format("Tag %x, ", tag.getTagId()) + getImageTitle(), truth);
- if (truth.contains(null)) {
- continue;
- }
- assertTrue(String.format("Tag %x, ", tag.getTagId()) + getImageTitle(),
- truth.contains(Util.tagValueToString(tag).trim()));
- }
- assertEquals(getImageTitle(), ifdValue.size(), tags.length);
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifTagTest.java b/tests/src/com/android/gallery3d/exif/ExifTagTest.java
deleted file mode 100644
index 59067c3..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifTagTest.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import junit.framework.TestCase;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class ExifTagTest extends TestCase {
-
- private static long MAX_UNSIGNED_LONG = (1L << 32) - 1;
- private static int MAX_LONG = Integer.MAX_VALUE;
- private static int MIN_LONG = Integer.MIN_VALUE;
-
- Map<Integer, ExifTag> mTestTags;
- ExifInterface mInterface;
- private ExifTag mVersionTag;
- private ExifTag mGpsVersionTag;
- private ExifTag mModelTag;
- private ExifTag mDateTimeTag;
- private ExifTag mCompressionTag;
- private ExifTag mThumbnailFormatTag;
- private ExifTag mLongitudeTag;
- private ExifTag mShutterTag;
- private ExifTag mInteropIndex;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mInterface = new ExifInterface();
-
- // TYPE_UNDEFINED with 4 components
- mVersionTag = mInterface.buildTag(ExifInterface.TAG_EXIF_VERSION, new byte[] {
- 5, 4, 3, 2
- });
- // TYPE_UNSIGNED_BYTE with 4 components
- mGpsVersionTag = mInterface.buildTag(ExifInterface.TAG_GPS_VERSION_ID, new byte[] {
- 6, 7, 8, 9
- });
- // TYPE ASCII with arbitrary length
- mModelTag = mInterface.buildTag(ExifInterface.TAG_MODEL, "helloworld");
- // TYPE_ASCII with 20 components
- mDateTimeTag = mInterface.buildTag(ExifInterface.TAG_DATE_TIME, "2013:02:11 20:20:20");
- // TYPE_UNSIGNED_SHORT with 1 components
- mCompressionTag = mInterface.buildTag(ExifInterface.TAG_COMPRESSION, 100);
- // TYPE_UNSIGNED_LONG with 1 components
- mThumbnailFormatTag =
- mInterface.buildTag(ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, 100);
- // TYPE_UNSIGNED_RATIONAL with 3 components
- mLongitudeTag = mInterface.buildTag(ExifInterface.TAG_GPS_LONGITUDE, new Rational[] {
- new Rational(2, 2), new Rational(11, 11),
- new Rational(102, 102)
- });
- // TYPE_RATIONAL with 1 components
- mShutterTag = mInterface
- .buildTag(ExifInterface.TAG_SHUTTER_SPEED_VALUE, new Rational(4, 6));
- // TYPE_ASCII with arbitrary length
- mInteropIndex = mInterface.buildTag(ExifInterface.TAG_INTEROPERABILITY_INDEX, "foo");
-
- mTestTags = new HashMap<Integer, ExifTag>();
-
- mTestTags.put(ExifInterface.TAG_EXIF_VERSION, mVersionTag);
- mTestTags.put(ExifInterface.TAG_GPS_VERSION_ID, mGpsVersionTag);
- mTestTags.put(ExifInterface.TAG_MODEL, mModelTag);
- mTestTags.put(ExifInterface.TAG_DATE_TIME, mDateTimeTag);
- mTestTags.put(ExifInterface.TAG_COMPRESSION, mCompressionTag);
- mTestTags.put(ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, mThumbnailFormatTag);
- mTestTags.put(ExifInterface.TAG_GPS_LONGITUDE, mLongitudeTag);
- mTestTags.put(ExifInterface.TAG_SHUTTER_SPEED_VALUE, mShutterTag);
- mTestTags.put(ExifInterface.TAG_INTEROPERABILITY_INDEX, mInteropIndex);
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- mInterface = null;
- mTestTags = null;
- }
-
- public void testValueType() {
- for (ExifTag tag : mTestTags.values()) {
- assertTrue(tag != null);
- int count = tag.getComponentCount();
- int intBuf[] = new int[count];
- long longBuf[] = new long[count];
- byte byteBuf[] = new byte[count];
- Rational rationalBuf[] = new Rational[count];
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < count; i++) {
- intBuf[i] = 0;
- longBuf[i] = 0;
- byteBuf[i] = 0;
- rationalBuf[i] = new Rational(0, 0);
- // The string size should equal to component count - 1
- if (i != count - 1) {
- sb.append("*");
- } else {
- sb.append("\0");
- }
- }
- String strBuf = sb.toString();
-
- checkTypeByte(tag, byteBuf);
- checkTypeAscii(tag, strBuf);
- checkTypeUnsignedShort(tag, intBuf);
- checkTypeUnsignedLong(tag, intBuf, longBuf);
- checkTypeLong(tag, intBuf);
- checkTypeRational(tag, rationalBuf);
- checkTypeUnsignedRational(tag, rationalBuf);
- }
- }
-
- private void checkTypeByte(ExifTag tag, byte[] buf) {
- short type = tag.getDataType();
- assertFalse("\nTag: " + tag.toString(), tag.setValue(buf)
- ^ (type == ExifTag.TYPE_UNDEFINED || type == ExifTag.TYPE_UNSIGNED_BYTE));
- }
-
- private void checkTypeAscii(ExifTag tag, String str) {
- short type = tag.getDataType();
- assertFalse("\nTag: " + tag.toString(), tag.setValue(str)
- ^ (type == ExifTag.TYPE_ASCII || type == ExifTag.TYPE_UNDEFINED));
- }
-
- private void checkTypeUnsignedShort(ExifTag tag, int[] intBuf) {
- short type = tag.getDataType();
- assertFalse("\nTag: " + tag.toString(),
- tag.setValue(intBuf)
- ^ (type == ExifTag.TYPE_UNSIGNED_SHORT
- || type == ExifTag.TYPE_UNSIGNED_LONG
- || type == ExifTag.TYPE_LONG));
- }
-
- private void checkTypeUnsignedLong(ExifTag tag, int[] intBuf, long[] longBuf) {
-
- // Test value only for unsigned long.
- int count = intBuf.length;
- intBuf[count - 1] = MAX_LONG;
- tag.setValue(intBuf);
- longBuf[count - 1] = MAX_UNSIGNED_LONG;
-
- assertFalse("\nTag: " + tag.toString(), tag.setValue(longBuf)
- ^ (tag.getDataType() == ExifTag.TYPE_UNSIGNED_LONG));
-
- intBuf[count - 1] = 0;
- // Test invalid value for all type.
- longBuf[count - 1] = MAX_UNSIGNED_LONG + 1;
- assertFalse(tag.setValue(longBuf));
- longBuf[count - 1] = 0;
- }
-
- private void checkTypeLong(ExifTag tag, int[] intBuf) {
- int count = intBuf.length;
- intBuf[count - 1] = MAX_LONG;
- tag.setValue(intBuf);
- intBuf[count - 1] = MIN_LONG;
-
- assertFalse("\nTag: " + tag.toString(), tag.setValue(intBuf)
- ^ (tag.getDataType() == ExifTag.TYPE_LONG));
- intBuf[count - 1] = 0;
- }
-
- private void checkTypeRational(ExifTag tag, Rational rationalBuf[]) {
- int count = rationalBuf.length;
- Rational r = rationalBuf[count - 1];
- rationalBuf[count - 1] = new Rational(MAX_LONG, MIN_LONG);
-
- assertFalse("\nTag: " + tag.toString(), tag.setValue(rationalBuf)
- ^ (tag.getDataType() == ExifTag.TYPE_RATIONAL));
-
- if (tag.getDataType() == ExifTag.TYPE_RATIONAL) {
- // check overflow
-
- rationalBuf[count - 1] = new Rational(MAX_LONG + 1L, MIN_LONG);
- assertFalse(tag.setValue(rationalBuf));
-
- rationalBuf[count - 1] = new Rational(MAX_LONG, MIN_LONG - 1L);
- assertFalse(tag.setValue(rationalBuf));
- }
- rationalBuf[count - 1] = r;
- }
-
- private void checkTypeUnsignedRational(ExifTag tag, Rational rationalBuf[]) {
- int count = rationalBuf.length;
- Rational r = rationalBuf[count - 1];
- rationalBuf[count - 1] = new Rational(MAX_UNSIGNED_LONG, MAX_UNSIGNED_LONG);
-
- assertFalse("\nTag: " + tag.toString(), tag.setValue(rationalBuf)
- ^ (tag.getDataType() == ExifTag.TYPE_UNSIGNED_RATIONAL));
-
- if (tag.getDataType() == ExifTag.TYPE_UNSIGNED_RATIONAL) {
- // check overflow
- rationalBuf[count - 1] = new Rational(MAX_UNSIGNED_LONG + 1, 0);
- assertFalse(tag.setValue(rationalBuf));
-
- rationalBuf[count - 1] = new Rational(MAX_UNSIGNED_LONG, -1);
- assertFalse(tag.setValue(rationalBuf));
- }
- rationalBuf[count - 1] = r;
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifTestRunner.java b/tests/src/com/android/gallery3d/exif/ExifTestRunner.java
deleted file mode 100644
index 162baea..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifTestRunner.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import android.content.Context;
-import android.os.Environment;
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-import android.util.Log;
-
-import com.android.gallery3d.tests.R;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ExifTestRunner extends InstrumentationTestRunner {
- private static final String TAG = "ExifTestRunner";
-
- private static final int[] IMG_RESOURCE = {
- R.raw.galaxy_nexus
- };
-
- private static final int[] EXIF_DATA_RESOURCE = {
- R.xml.galaxy_nexus
- };
-
- private static List<String> mTestImgPath = new ArrayList<String>();
- private static List<String> mTestXmlPath = new ArrayList<String>();
-
- @Override
- public TestSuite getAllTests() {
- getTestImagePath();
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(ExifDataTest.class);
- suite.addTestSuite(ExifTagTest.class);
- addAllTestsFromExifTestCase(ExifParserTest.class, suite);
- addAllTestsFromExifTestCase(ExifReaderTest.class, suite);
- addAllTestsFromExifTestCase(ExifOutputStreamTest.class, suite);
- addAllTestsFromExifTestCase(ExifModifierTest.class, suite);
- addAllTestsFromExifTestCase(ExifInterfaceTest.class, suite);
- return suite;
- }
-
- private void getTestImagePath() {
- Context context = getContext();
- File imgDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
- File xmlDir = new File(context.getExternalFilesDir(null).getPath(), "Xml");
-
- if (imgDir != null && xmlDir != null) {
- String[] imgs = imgDir.list();
- if (imgs == null) {
- return;
- }
- for (String imgName : imgs) {
- String xmlName = imgName.substring(0, imgName.lastIndexOf('.')) + ".xml";
- File xmlFile = new File(xmlDir, xmlName);
- if (xmlFile.exists()) {
- mTestImgPath.add(new File(imgDir, imgName).getAbsolutePath());
- mTestXmlPath.add(xmlFile.getAbsolutePath());
- }
- }
- }
- }
-
- private void addAllTestsFromExifTestCase(Class<? extends ExifXmlDataTestCase> testClass,
- TestSuite suite) {
- for (Method method : testClass.getDeclaredMethods()) {
- if (method.getName().startsWith("test") && method.getParameterTypes().length == 0) {
- for (int i = 0; i < IMG_RESOURCE.length; i++) {
- TestCase test;
- try {
- test = testClass.getDeclaredConstructor(int.class, int.class).
- newInstance(IMG_RESOURCE[i], EXIF_DATA_RESOURCE[i]);
- test.setName(method.getName());
- suite.addTest(test);
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (InstantiationException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (IllegalAccessException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (InvocationTargetException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (NoSuchMethodException e) {
- Log.e(TAG, "Failed to create test case", e);
- }
- }
- for (int i = 0, n = mTestImgPath.size(); i < n; i++) {
- TestCase test;
- try {
- test = testClass.getDeclaredConstructor(String.class, String.class).
- newInstance(mTestImgPath.get(i), mTestXmlPath.get(i));
- test.setName(method.getName());
- suite.addTest(test);
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (InstantiationException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (IllegalAccessException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (InvocationTargetException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (NoSuchMethodException e) {
- Log.e(TAG, "Failed to create test case", e);
- }
- }
- }
- }
- }
-
- @Override
- public ClassLoader getLoader() {
- return ExifTestRunner.class.getClassLoader();
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifXmlDataTestCase.java b/tests/src/com/android/gallery3d/exif/ExifXmlDataTestCase.java
deleted file mode 100644
index da86020..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifXmlDataTestCase.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import android.content.res.Resources;
-import android.test.InstrumentationTestCase;
-import android.util.Xml;
-
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-public class ExifXmlDataTestCase extends InstrumentationTestCase {
-
- private static final String RES_ID_TITLE = "Resource ID: %x";
-
- private InputStream mImageInputStream;
- private InputStream mXmlInputStream;
- private XmlPullParser mXmlParser;
- private final String mImagePath;
- private final String mXmlPath;
- private final int mImageResourceId;
- private final int mXmlResourceId;
-
- public ExifXmlDataTestCase(int imageRes, int xmlRes) {
- mImagePath = null;
- mXmlPath = null;
- mImageResourceId = imageRes;
- mXmlResourceId = xmlRes;
- }
-
- public ExifXmlDataTestCase(String imagePath, String xmlPath) {
- mImagePath = imagePath;
- mXmlPath = xmlPath;
- mImageResourceId = 0;
- mXmlResourceId = 0;
- }
-
- protected InputStream getImageInputStream() {
- return mImageInputStream;
- }
-
- protected XmlPullParser getXmlParser() {
- return mXmlParser;
- }
-
- @Override
- public void setUp() throws Exception {
- try {
- if (mImagePath != null) {
- mImageInputStream = new FileInputStream(mImagePath);
- mXmlInputStream = new FileInputStream(mXmlPath);
- mXmlParser = Xml.newPullParser();
- mXmlParser.setInput(new InputStreamReader(mXmlInputStream));
- } else {
- Resources res = getInstrumentation().getContext().getResources();
- mImageInputStream = res.openRawResource(mImageResourceId);
- mXmlParser = res.getXml(mXmlResourceId);
- }
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-
- @Override
- public void tearDown() throws Exception {
- Util.closeSilently(mImageInputStream);
- Util.closeSilently(mXmlInputStream);
- mXmlParser = null;
- }
-
- protected String getImageTitle() {
- if (mImagePath != null) {
- return mImagePath;
- } else {
- return String.format(RES_ID_TITLE, mImageResourceId);
- }
- }
-
- protected InputStream reopenFileStream() throws Exception {
- try {
- if (mImagePath != null) {
- return new FileInputStream(mImagePath);
- } else {
- Resources res = getInstrumentation().getContext().getResources();
- return res.openRawResource(mImageResourceId);
- }
- } catch (Exception e) {
- throw new Exception(getImageTitle(), e);
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/ExifXmlReader.java b/tests/src/com/android/gallery3d/exif/ExifXmlReader.java
deleted file mode 100644
index 12e9cf7..0000000
--- a/tests/src/com/android/gallery3d/exif/ExifXmlReader.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ExifXmlReader {
- private static final String TAG_EXIF = "exif";
- private static final String TAG_TAG = "tag";
-
- private static final String IFD0 = "IFD0";
- private static final String EXIF_IFD = "ExifIFD";
- private static final String GPS_IFD = "GPS";
- private static final String IFD1 = "IFD1";
- private static final String INTEROP_IFD = "InteropIFD";
-
- private static final String ATTR_ID = "id";
- private static final String ATTR_IFD = "ifd";
-
- private static final String NO_VALUE = "NO_VALUE";
-
- /**
- * This function read the ground truth XML.
- *
- * @throws XmlPullParserException
- * @throws IOException
- */
- static public List<Map<Short, List<String>>> readXml(XmlPullParser parser)
- throws XmlPullParserException, IOException {
-
- List<Map<Short, List<String>>> exifData =
- new ArrayList<Map<Short, List<String>>>(IfdId.TYPE_IFD_COUNT);
- for (int i = 0; i < IfdId.TYPE_IFD_COUNT; i++) {
- exifData.add(new HashMap<Short, List<String>>());
- }
-
- while (parser.next() != XmlPullParser.END_DOCUMENT) {
- if (parser.getEventType() == XmlPullParser.START_TAG) {
- break;
- }
- }
- parser.require(XmlPullParser.START_TAG, null, TAG_EXIF);
-
- while (parser.next() != XmlPullParser.END_TAG) {
- if (parser.getEventType() != XmlPullParser.START_TAG) {
- continue;
- }
-
- parser.require(XmlPullParser.START_TAG, null, TAG_TAG);
-
- int ifdId = getIfdIdFromString(parser.getAttributeValue(null, ATTR_IFD));
- short id = Integer.decode(parser.getAttributeValue(null, ATTR_ID)).shortValue();
-
- String value = "";
- if (parser.next() == XmlPullParser.TEXT) {
- value = parser.getText();
- parser.next();
- }
-
- if (ifdId < 0) {
- // TODO: the MarkerNote segment.
- } else {
- List<String> tagData = exifData.get(ifdId).get(id);
- if (tagData == null) {
- tagData = new ArrayList<String>();
- exifData.get(ifdId).put(id, tagData);
- }
- if (NO_VALUE.equals(value)) {
- tagData.add(null);
- } else {
- tagData.add(value.trim());
- }
- }
-
- parser.require(XmlPullParser.END_TAG, null, null);
- }
- return exifData;
- }
-
- static private int getIfdIdFromString(String prefix) {
- if (IFD0.equals(prefix)) {
- return IfdId.TYPE_IFD_0;
- } else if (EXIF_IFD.equals(prefix)) {
- return IfdId.TYPE_IFD_EXIF;
- } else if (GPS_IFD.equals(prefix)) {
- return IfdId.TYPE_IFD_GPS;
- } else if (IFD1.equals(prefix)) {
- return IfdId.TYPE_IFD_1;
- } else if (INTEROP_IFD.equals(prefix)) {
- return IfdId.TYPE_IFD_INTEROPERABILITY;
- } else {
- assert (false);
- return -1;
- }
- }
-
- static public int getTrueTagNumber(Map<Short, List<String>> ifdData) {
- int size = 0;
- for (List<String> tag : ifdData.values()) {
- size += tag.size();
- }
- return size;
- }
-}
diff --git a/tests/src/com/android/gallery3d/exif/Util.java b/tests/src/com/android/gallery3d/exif/Util.java
deleted file mode 100644
index 15de007..0000000
--- a/tests/src/com/android/gallery3d/exif/Util.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.exif;
-
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-
-class Util {
- public static boolean equals(Object a, Object b) {
- return (a == b) || (a == null ? false : a.equals(b));
- }
-
- public static void closeSilently(Closeable c) {
- if (c == null)
- return;
- try {
- c.close();
- } catch (Throwable t) {
- // do nothing
- }
- }
-
- public static byte[] readToByteArray(InputStream is) throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- int len;
- byte[] buf = new byte[1024];
- while ((len = is.read(buf)) > -1) {
- bos.write(buf, 0, len);
- }
- bos.flush();
- return bos.toByteArray();
- }
-
- /**
- * Tags that are not defined in the spec.
- */
- static final short TAG_XP_TITLE = (short) 0x9c9b;
- static final short TAG_XP_COMMENT = (short) 0x9c9c;
- static final short TAG_XP_AUTHOR = (short) 0x9c9d;
- static final short TAG_XP_KEYWORDS = (short) 0x9c9e;
- static final short TAG_XP_SUBJECT = (short) 0x9c9f;
-
- private static String tagUndefinedTypeValueToString(ExifTag tag) {
- StringBuilder sbuilder = new StringBuilder();
- byte[] buf = new byte[tag.getComponentCount()];
- tag.getBytes(buf);
- short tagId = tag.getTagId();
- if (tagId == ExifInterface.getTrueTagKey(ExifInterface.TAG_COMPONENTS_CONFIGURATION)) {
- for (int i = 0, n = tag.getComponentCount(); i < n; i++) {
- if (i != 0) {
- sbuilder.append(" ");
- }
- sbuilder.append(buf[i]);
- }
- } else {
- if (buf.length == 1) {
- sbuilder.append(buf[0]);
- } else {
- for (int i = 0, n = buf.length; i < n; i++) {
- byte code = buf[i];
- if (code == 0) {
- continue;
- }
- if (code > 31 && code < 127) {
- sbuilder.append((char) code);
- } else {
- sbuilder.append('.');
- }
- }
- }
- }
- return sbuilder.toString();
- }
-
- /**
- * Returns a string representation of the value of this tag.
- */
- public static String tagValueToString(ExifTag tag) {
- StringBuilder sbuilder = new StringBuilder();
- short id = tag.getTagId();
- switch (tag.getDataType()) {
- case ExifTag.TYPE_UNDEFINED:
- sbuilder.append(tagUndefinedTypeValueToString(tag));
- break;
- case ExifTag.TYPE_UNSIGNED_BYTE:
- if (id == ExifInterface.TAG_MAKER_NOTE || id == TAG_XP_TITLE ||
- id == TAG_XP_COMMENT || id == TAG_XP_AUTHOR ||
- id == TAG_XP_KEYWORDS || id == TAG_XP_SUBJECT) {
- sbuilder.append(tagUndefinedTypeValueToString(tag));
- } else {
- byte[] buf = new byte[tag.getComponentCount()];
- tag.getBytes(buf);
- for (int i = 0, n = tag.getComponentCount(); i < n; i++) {
- if (i != 0)
- sbuilder.append(" ");
- sbuilder.append(buf[i]);
- }
- }
- break;
- case ExifTag.TYPE_ASCII:
- byte[] buf = tag.getStringByte();
- for (int i = 0, n = buf.length; i < n; i++) {
- byte code = buf[i];
- if (code == 0) {
- // Treat some tag as undefined type data.
- if (id == ExifInterface.TAG_COPYRIGHT
- || id == ExifInterface.TAG_GPS_DATE_STAMP) {
- continue;
- } else {
- break;
- }
- }
- if (code > 31 && code < 127) {
- sbuilder.append((char) code);
- } else {
- sbuilder.append('.');
- }
- }
- break;
- case ExifTag.TYPE_UNSIGNED_LONG:
- for (int i = 0, n = tag.getComponentCount(); i < n; i++) {
- if (i != 0) {
- sbuilder.append(" ");
- }
- sbuilder.append(tag.getValueAt(i));
- }
- break;
- case ExifTag.TYPE_RATIONAL:
- case ExifTag.TYPE_UNSIGNED_RATIONAL:
- for (int i = 0, n = tag.getComponentCount(); i < n; i++) {
- Rational r = tag.getRational(i);
- if (i != 0) {
- sbuilder.append(" ");
- }
- sbuilder.append(r.getNumerator()).append("/").append(r.getDenominator());
- }
- break;
- case ExifTag.TYPE_UNSIGNED_SHORT:
- for (int i = 0, n = tag.getComponentCount(); i < n; i++) {
- if (i != 0) {
- sbuilder.append(" ");
- }
- sbuilder.append((int) tag.getValueAt(i));
- }
- break;
- case ExifTag.TYPE_LONG:
- for (int i = 0, n = tag.getComponentCount(); i < n; i++) {
- if (i != 0) {
- sbuilder.append(" ");
- }
- sbuilder.append((int) tag.getValueAt(i));
- }
- break;
- }
- return sbuilder.toString();
- }
-
- public static String valueToString(Object obj) {
- if (obj instanceof int[]) {
- return Arrays.toString((int[]) obj);
- } else if (obj instanceof Integer[]) {
- return Arrays.toString((Integer[]) obj);
- } else if (obj instanceof long[]) {
- return Arrays.toString((long[]) obj);
- } else if (obj instanceof Long[]) {
- return Arrays.toString((Long[]) obj);
- } else if (obj instanceof Rational) {
- return ((Rational) obj).toString();
- } else if (obj instanceof Rational[]) {
- return Arrays.toString((Rational[]) obj);
- } else if (obj instanceof byte[]) {
- return Arrays.toString((byte[]) obj);
- } else if (obj != null) {
- return obj.toString();
- }
- return "";
- }
-}
diff --git a/tests/src/com/android/gallery3d/functional/CameraTest.java b/tests/src/com/android/gallery3d/functional/CameraTest.java
deleted file mode 100644
index c293c0d..0000000
--- a/tests/src/com/android/gallery3d/functional/CameraTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2010 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.functional;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Environment;
-import android.os.Process;
-import android.provider.MediaStore;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-
-public class CameraTest extends InstrumentationTestCase {
- @LargeTest
- public void testVideoCaptureIntentFdLeak() throws Exception {
- Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse("file://"
- + Environment.getExternalStorageDirectory().toString()
- + "test_fd_leak.3gp"));
- getInstrumentation().startActivitySync(intent).finish();
- // Test if the fd is closed.
- for (File f: new File("/proc/" + Process.myPid() + "/fd").listFiles()) {
- assertEquals(-1, f.getCanonicalPath().indexOf("test_fd_leak.3gp"));
- }
- }
-
- @LargeTest
- public void testActivityLeak() throws Exception {
- checkActivityLeak(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
- checkActivityLeak(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
- }
-
- private void checkActivityLeak(String action) throws Exception {
- final int TEST_COUNT = 5;
- Intent intent = new Intent(action);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClass(getInstrumentation().getTargetContext(),
- CameraActivity.class);
- ArrayList<WeakReference<Activity>> refs =
- new ArrayList<WeakReference<Activity>>();
- for (int i = 0; i < TEST_COUNT; i++) {
- Activity activity = getInstrumentation().startActivitySync(intent);
- refs.add(new WeakReference<Activity>(activity));
- activity.finish();
- getInstrumentation().waitForIdleSync();
- activity = null;
- }
- Runtime.getRuntime().gc();
- Runtime.getRuntime().runFinalization();
- Runtime.getRuntime().gc();
- int refCount = 0;
- for (WeakReference<Activity> c: refs) {
- if (c.get() != null) refCount++;
- }
- // If applications are leaking activity, every reference is reachable.
- assertTrue(refCount != TEST_COUNT);
- }
-}
diff --git a/tests/src/com/android/gallery3d/functional/ImageCaptureIntentTest.java b/tests/src/com/android/gallery3d/functional/ImageCaptureIntentTest.java
deleted file mode 100644
index 8d394b5..0000000
--- a/tests/src/com/android/gallery3d/functional/ImageCaptureIntentTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2011 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.functional;
-
-import com.android.camera.CameraActivity;
-import com.android.gallery3d.R;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.KeyEvent;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-public class ImageCaptureIntentTest extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private Intent mIntent;
-
- public ImageCaptureIntentTest() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- }
-
- @LargeTest
- public void testNoExtraOutput() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- takePicture();
- pressDone();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_OK, getActivity().getResultCode());
- Intent resultData = getActivity().getResultData();
- Bitmap bitmap = (Bitmap) resultData.getParcelableExtra("data");
- assertNotNull(bitmap);
- assertTrue(bitmap.getWidth() > 0);
- assertTrue(bitmap.getHeight() > 0);
- }
-
- @LargeTest
- public void testExtraOutput() throws Exception {
- File file = new File(Environment.getExternalStorageDirectory(),
- "test.jpg");
- BufferedInputStream stream = null;
- byte[] jpegData;
-
- try {
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
- setActivityIntent(mIntent);
- getActivity();
-
- takePicture();
- pressDone();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_OK, getActivity().getResultCode());
-
- // Verify the jpeg file
- int fileLength = (int) file.length();
- assertTrue(fileLength > 0);
- jpegData = new byte[fileLength];
- stream = new BufferedInputStream(new FileInputStream(file));
- stream.read(jpegData);
- } finally {
- if (stream != null) stream.close();
- file.delete();
- }
-
- Bitmap b = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
- assertTrue(b.getWidth() > 0);
- assertTrue(b.getHeight() > 0);
- }
-
- @LargeTest
- public void testCancel() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- pressCancel();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode());
- }
-
- @LargeTest
- public void testSnapshotCancel() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- takePicture();
- pressCancel();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode());
- }
-
- private void takePicture() throws Exception {
- getInstrumentation().sendKeySync(
- new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_FOCUS));
- getInstrumentation().sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(4000);
- }
-
- private void pressDone() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getActivity().findViewById(R.id.btn_done).performClick();
- }
- });
- }
-
- private void pressCancel() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getActivity().findViewById(R.id.btn_cancel).performClick();
- }
- });
- }
-}
diff --git a/tests/src/com/android/gallery3d/functional/VideoCaptureIntentTest.java b/tests/src/com/android/gallery3d/functional/VideoCaptureIntentTest.java
deleted file mode 100644
index c8d7bbb..0000000
--- a/tests/src/com/android/gallery3d/functional/VideoCaptureIntentTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2011 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.functional;
-
-import com.android.camera.CameraActivity;
-import com.android.gallery3d.R;
-
-import android.app.Activity;
-import android.content.ContentResolver;
-import android.content.Intent;
-import android.database.Cursor;
-import android.media.MediaMetadataRetriever;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-
-import java.io.File;
-
-public class VideoCaptureIntentTest extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private static final String TAG = "VideoCaptureIntentTest";
- private Intent mIntent;
- private Uri mVideoUri;
- private File mFile, mFile2;
-
- public VideoCaptureIntentTest() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (mVideoUri != null) {
- ContentResolver resolver = getActivity().getContentResolver();
- Uri query = mVideoUri.buildUpon().build();
- String[] projection = new String[] {VideoColumns.DATA};
-
- Cursor cursor = null;
- try {
- cursor = resolver.query(query, projection, null, null, null);
- if (cursor != null && cursor.moveToFirst()) {
- new File(cursor.getString(0)).delete();
- }
- } finally {
- if (cursor != null) cursor.close();
- }
-
- resolver.delete(mVideoUri, null, null);
- }
- if (mFile != null) mFile.delete();
- if (mFile2 != null) mFile2.delete();
- super.tearDown();
- }
-
- @LargeTest
- public void testNoExtraOutput() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressDone();
-
- Intent resultData = getActivity().getResultData();
- mVideoUri = resultData.getData();
- assertNotNull(mVideoUri);
- verify(getActivity(), mVideoUri);
- }
-
- @LargeTest
- public void testExtraOutput() throws Exception {
- mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp");
-
- Uri uri = Uri.fromFile(mFile);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressDone();
-
- verify(getActivity(), uri);
- }
-
- @LargeTest
- public void testCancel() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- pressCancel();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode());
- }
-
- @LargeTest
- public void testRecordCancel() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressCancel();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode());
- }
-
- @LargeTest
- public void testExtraSizeLimit() throws Exception {
- mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp");
- final long sizeLimit = 500000; // bytes
-
- Uri uri = Uri.fromFile(mFile);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit);
- mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // use low quality to speed up
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo(5000);
- pressDone();
-
- verify(getActivity(), uri);
- long length = mFile.length();
- Log.v(TAG, "Video size is " + length + " bytes.");
- assertTrue(length > 0);
- assertTrue("Actual size=" + length, length <= sizeLimit);
- }
-
- @LargeTest
- public void testExtraDurationLimit() throws Exception {
- mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp");
- final int durationLimit = 2; // seconds
-
- Uri uri = Uri.fromFile(mFile);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit);
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo(5000);
- pressDone();
-
- int duration = verify(getActivity(), uri);
- // The duraion should be close to to the limit. The last video duration
- // also has duration, so the total duration may exceeds the limit a
- // little bit.
- Log.v(TAG, "Video length is " + duration + " ms.");
- assertTrue(duration < (durationLimit + 1) * 1000);
- }
-
- @LargeTest
- public void testExtraVideoQuality() throws Exception {
- mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp");
- mFile2 = new File(Environment.getExternalStorageDirectory(), "video2.tmp");
-
- Uri uri = Uri.fromFile(mFile);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // low quality
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressDone();
-
- verify(getActivity(), uri);
- setActivity(null);
-
- uri = Uri.fromFile(mFile2);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // high quality
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressDone();
-
- verify(getActivity(), uri);
- assertTrue(mFile.length() <= mFile2.length());
- }
-
- // Verify result code, result data, and the duration.
- private int verify(CameraActivity activity, Uri uri) throws Exception {
- assertTrue(activity.isFinishing());
- assertEquals(Activity.RESULT_OK, activity.getResultCode());
-
- // Verify the video file
- MediaMetadataRetriever retriever = new MediaMetadataRetriever();
- retriever.setDataSource(activity, uri);
- String duration = retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_DURATION);
- assertNotNull(duration);
- int durationValue = Integer.parseInt(duration);
- Log.v(TAG, "Video duration is " + durationValue);
- assertTrue(durationValue > 0);
- return durationValue;
- }
-
- private void recordVideo(int ms) throws Exception {
- getInstrumentation().sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(ms);
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- // If recording is in progress, stop it. Run these atomically in
- // UI thread.
- CameraActivity activity = getActivity();
- if (activity.isRecording()) {
- activity.findViewById(R.id.shutter_button).performClick();
- }
- }
- });
- }
-
- private void recordVideo() throws Exception {
- recordVideo(2000);
- }
-
- private void pressDone() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getActivity().findViewById(R.id.btn_done).performClick();
- }
- });
- }
-
- private void pressCancel() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getActivity().findViewById(R.id.btn_cancel).performClick();
- }
- });
- }
-}
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLCanvasMock.java b/tests/src/com/android/gallery3d/glrenderer/GLCanvasMock.java
deleted file mode 100644
index a57c188..0000000
--- a/tests/src/com/android/gallery3d/glrenderer/GLCanvasMock.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2010 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.glrenderer;
-
-import com.android.gallery3d.glrenderer.BasicTexture;
-import com.android.gallery3d.ui.GLCanvasStub;
-
-import javax.microedition.khronos.opengles.GL11;
-
-public class GLCanvasMock extends GLCanvasStub {
- // fillRect
- int mFillRectCalled;
- float mFillRectWidth;
- float mFillRectHeight;
- int mFillRectColor;
- // drawMixed
- int mDrawMixedCalled;
- float mDrawMixedRatio;
- // drawTexture;
- int mDrawTextureCalled;
-
- private GL11 mGL;
-
- public GLCanvasMock(GL11 gl) {
- mGL = gl;
- }
-
- public GLCanvasMock() {
- mGL = new GLStub();
- }
-
- @Override
- public GL11 getGLInstance() {
- return mGL;
- }
-
- @Override
- public void fillRect(float x, float y, float width, float height, int color) {
- mFillRectCalled++;
- mFillRectWidth = width;
- mFillRectHeight = height;
- mFillRectColor = color;
- }
-
- @Override
- public void drawTexture(
- BasicTexture texture, int x, int y, int width, int height) {
- mDrawTextureCalled++;
- }
-
- @Override
- public void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int w, int h) {
- mDrawMixedCalled++;
- mDrawMixedRatio = ratio;
- }
-}
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java b/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java
deleted file mode 100644
index b1e6d5b..0000000
--- a/tests/src/com/android/gallery3d/glrenderer/GLCanvasTest.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (C) 2010 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.glrenderer;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-import junit.framework.TestCase;
-
-import java.util.Arrays;
-
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-
-@SmallTest
-public class GLCanvasTest extends TestCase {
- private static final String TAG = "GLCanvasTest";
-
- private static GLPaint newColorPaint(int color) {
- GLPaint paint = new GLPaint();
- paint.setColor(color);
- return paint;
- }
-
- @SmallTest
- public void testSetSize() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLES11Canvas(glStub);
- canvas.setSize(100, 200);
- canvas.setSize(1000, 100);
- try {
- canvas.setSize(-1, 100);
- fail();
- } catch (Throwable ex) {
- // expected.
- }
- }
-
- @SmallTest
- public void testClearBuffer() {
- new ClearBufferTest().run();
- }
-
- private static class ClearBufferTest extends GLMock {
- void run() {
- GLCanvas canvas = new GLES11Canvas(this);
- assertEquals(0, mGLClearCalled);
- canvas.clearBuffer();
- assertEquals(GL10.GL_COLOR_BUFFER_BIT, mGLClearMask);
- assertEquals(1, mGLClearCalled);
- }
- }
-
- @SmallTest
- public void testSetColor() {
- new SetColorTest().run();
- }
-
- // This test assumes we use pre-multipled alpha blending and should
- // set the blending function and color correctly.
- private static class SetColorTest extends GLMock {
- void run() {
- int[] testColors = new int[] {
- 0, 0xFFFFFFFF, 0xFF000000, 0x00FFFFFF, 0x80FF8001,
- 0x7F010101, 0xFEFEFDFC, 0x017F8081, 0x027F8081, 0x2ADE4C4D
- };
-
- GLCanvas canvas = new GLES11Canvas(this);
- canvas.setSize(400, 300);
- // Test one color to make sure blend function is set.
- assertEquals(0, mGLColorCalled);
- canvas.drawLine(0, 0, 1, 1, newColorPaint(0x7F804020));
- assertEquals(1, mGLColorCalled);
- assertEquals(0x7F402010, mGLColor);
- assertPremultipliedBlending(this);
-
- // Test other colors to make sure premultiplication is right
- for (int c : testColors) {
- float a = (c >>> 24) / 255f;
- float r = ((c >> 16) & 0xff) / 255f;
- float g = ((c >> 8) & 0xff) / 255f;
- float b = (c & 0xff) / 255f;
- int pre = makeColor4f(a * r, a * g, a * b, a);
-
- mGLColorCalled = 0;
- canvas.drawLine(0, 0, 1, 1, newColorPaint(c));
- assertEquals(1, mGLColorCalled);
- assertEquals(pre, mGLColor);
- }
- }
- }
-
- @SmallTest
- public void testSetGetMultiplyAlpha() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLES11Canvas(glStub);
-
- canvas.setAlpha(1f);
- assertEquals(1f, canvas.getAlpha());
-
- canvas.setAlpha(0f);
- assertEquals(0f, canvas.getAlpha());
-
- canvas.setAlpha(0.5f);
- assertEquals(0.5f, canvas.getAlpha());
-
- canvas.multiplyAlpha(0.5f);
- assertEquals(0.25f, canvas.getAlpha());
-
- canvas.multiplyAlpha(0f);
- assertEquals(0f, canvas.getAlpha());
-
- try {
- canvas.setAlpha(-0.01f);
- fail();
- } catch (Throwable ex) {
- // expected.
- }
-
- try {
- canvas.setAlpha(1.01f);
- fail();
- } catch (Throwable ex) {
- // expected.
- }
- }
-
- @SmallTest
- public void testAlpha() {
- new AlphaTest().run();
- }
-
- private static class AlphaTest extends GLMock {
- void run() {
- GLCanvas canvas = new GLES11Canvas(this);
- canvas.setSize(400, 300);
-
- assertEquals(0, mGLColorCalled);
- canvas.setAlpha(0.48f);
- canvas.drawLine(0, 0, 1, 1, newColorPaint(0xFF804020));
- assertPremultipliedBlending(this);
- assertEquals(1, mGLColorCalled);
- assertEquals(0x7A3D1F0F, mGLColor);
- }
- }
-
- @SmallTest
- public void testDrawLine() {
- new DrawLineTest().run();
- }
-
- // This test assumes the drawLine() function use glDrawArrays() with
- // GL_LINE_STRIP mode to draw the line and the input coordinates are used
- // directly.
- private static class DrawLineTest extends GLMock {
- private int mDrawArrayCalled = 0;
- private final int[] mResult = new int[4];
-
- @Override
- public void glDrawArrays(int mode, int first, int count) {
- assertNotNull(mGLVertexPointer);
- assertEquals(GL10.GL_LINE_STRIP, mode);
- assertEquals(2, count);
- mGLVertexPointer.bindByteBuffer();
-
- double[] coord = new double[4];
- mGLVertexPointer.getArrayElement(first, coord);
- mResult[0] = (int) coord[0];
- mResult[1] = (int) coord[1];
- mGLVertexPointer.getArrayElement(first + 1, coord);
- mResult[2] = (int) coord[0];
- mResult[3] = (int) coord[1];
- mDrawArrayCalled++;
- }
-
- void run() {
- GLCanvas canvas = new GLES11Canvas(this);
- canvas.setSize(400, 300);
- canvas.drawLine(2, 7, 1, 8, newColorPaint(0) /* color */);
- assertTrue(mGLVertexArrayEnabled);
- assertEquals(1, mDrawArrayCalled);
-
- Log.v(TAG, "result = " + Arrays.toString(mResult));
- int[] answer = new int[] {2, 7, 1, 8};
- for (int i = 0; i < answer.length; i++) {
- assertEquals(answer[i], mResult[i]);
- }
- }
- }
-
- @SmallTest
- public void testFillRect() {
- new FillRectTest().run();
- }
-
- // This test assumes the drawLine() function use glDrawArrays() with
- // GL_TRIANGLE_STRIP mode to draw the line and the input coordinates
- // are used directly.
- private static class FillRectTest extends GLMock {
- private int mDrawArrayCalled = 0;
- private final int[] mResult = new int[8];
-
- @Override
- public void glDrawArrays(int mode, int first, int count) {
- assertNotNull(mGLVertexPointer);
- assertEquals(GL10.GL_TRIANGLE_STRIP, mode);
- assertEquals(4, count);
- mGLVertexPointer.bindByteBuffer();
-
- double[] coord = new double[4];
- for (int i = 0; i < 4; i++) {
- mGLVertexPointer.getArrayElement(first + i, coord);
- mResult[i * 2 + 0] = (int) coord[0];
- mResult[i * 2 + 1] = (int) coord[1];
- }
-
- mDrawArrayCalled++;
- }
-
- void run() {
- GLCanvas canvas = new GLES11Canvas(this);
- canvas.setSize(400, 300);
- canvas.fillRect(2, 7, 1, 8, 0 /* color */);
- assertTrue(mGLVertexArrayEnabled);
- assertEquals(1, mDrawArrayCalled);
- Log.v(TAG, "result = " + Arrays.toString(mResult));
-
- // These are the four vertics that should be used.
- int[] answer = new int[] {
- 2, 7,
- 3, 7,
- 3, 15,
- 2, 15};
- int count[] = new int[4];
-
- // Count the number of appearances for each vertex.
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 4; j++) {
- if (answer[i * 2] == mResult[j * 2] &&
- answer[i * 2 + 1] == mResult[j * 2 + 1]) {
- count[i]++;
- }
- }
- }
-
- // Each vertex should appear exactly once.
- for (int i = 0; i < 4; i++) {
- assertEquals(1, count[i]);
- }
- }
- }
-
- @SmallTest
- public void testTransform() {
- new TransformTest().run();
- }
-
- // This test assumes glLoadMatrixf is used to load the model view matrix,
- // and glOrthof is used to load the projection matrix.
- //
- // The projection matrix is set to an orthogonal projection which is the
- // inverse of viewport transform. So the model view matrix maps input
- // directly to screen coordinates (default no scaling, and the y-axis is
- // reversed).
- //
- // The matrix here are all listed in column major order.
- //
- private static class TransformTest extends GLMock {
- private final float[] mModelViewMatrixUsed = new float[16];
- private final float[] mProjectionMatrixUsed = new float[16];
-
- @Override
- public void glDrawArrays(int mode, int first, int count) {
- copy(mModelViewMatrixUsed, mGLModelViewMatrix);
- copy(mProjectionMatrixUsed, mGLProjectionMatrix);
- }
-
- private void copy(float[] dest, float[] src) {
- System.arraycopy(src, 0, dest, 0, 16);
- }
-
- void run() {
- GLCanvas canvas = new GLES11Canvas(this);
- canvas.setSize(40, 50);
- int color = 0;
-
- // Initial matrix
- canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
- assertMatrixEq(new float[] {
- 1, 0, 0, 0,
- 0, -1, 0, 0,
- 0, 0, 1, 0,
- 0, 50, 0, 1
- }, mModelViewMatrixUsed);
-
- assertMatrixEq(new float[] {
- 2f / 40, 0, 0, 0,
- 0, 2f / 50, 0, 0,
- 0, 0, -1, 0,
- -1, -1, 0, 1
- }, mProjectionMatrixUsed);
-
- // Translation
- canvas.translate(3, 4, 5);
- canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
- assertMatrixEq(new float[] {
- 1, 0, 0, 0,
- 0, -1, 0, 0,
- 0, 0, 1, 0,
- 3, 46, 5, 1
- }, mModelViewMatrixUsed);
- canvas.save();
-
- // Scaling
- canvas.scale(0.7f, 0.6f, 0.5f);
- canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
- assertMatrixEq(new float[] {
- 0.7f, 0, 0, 0,
- 0, -0.6f, 0, 0,
- 0, 0, 0.5f, 0,
- 3, 46, 5, 1
- }, mModelViewMatrixUsed);
-
- // Rotation
- canvas.rotate(90, 0, 0, 1);
- canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
- assertMatrixEq(new float[] {
- 0, -0.6f, 0, 0,
- -0.7f, 0, 0, 0,
- 0, 0, 0.5f, 0,
- 3, 46, 5, 1
- }, mModelViewMatrixUsed);
- canvas.restore();
-
- // After restoring to the point just after translation,
- // do rotation again.
- canvas.rotate(180, 1, 0, 0);
- canvas.drawLine(0, 0, 1, 1, newColorPaint(color));
- assertMatrixEq(new float[] {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, -1, 0,
- 3, 46, 5, 1
- }, mModelViewMatrixUsed);
- }
- }
-
- private static void assertPremultipliedBlending(GLMock mock) {
- assertTrue(mock.mGLBlendFuncCalled > 0);
- assertTrue(mock.mGLBlendEnabled);
- assertEquals(GL11.GL_ONE, mock.mGLBlendFuncSFactor);
- assertEquals(GL11.GL_ONE_MINUS_SRC_ALPHA, mock.mGLBlendFuncDFactor);
- }
-
- private static void assertMatrixEq(float[] expected, float[] actual) {
- try {
- for (int i = 0; i < 16; i++) {
- assertFloatEq(expected[i], actual[i]);
- }
- } catch (Throwable t) {
- Log.v(TAG, "expected = " + Arrays.toString(expected) +
- ", actual = " + Arrays.toString(actual));
- fail();
- }
- }
-
- public static void assertFloatEq(float expected, float actual) {
- if (Math.abs(actual - expected) > 1e-6) {
- Log.v(TAG, "expected: " + expected + ", actual: " + actual);
- fail();
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLMock.java b/tests/src/com/android/gallery3d/glrenderer/GLMock.java
deleted file mode 100644
index b242217..0000000
--- a/tests/src/com/android/gallery3d/glrenderer/GLMock.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2010 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.glrenderer;
-
-import com.android.gallery3d.ui.PointerInfo;
-
-import java.nio.Buffer;
-import java.util.HashMap;
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-
-public class GLMock extends GLStub {
- @SuppressWarnings("unused")
- private static final String TAG = "GLMock";
-
- // glClear
- int mGLClearCalled;
- int mGLClearMask;
- // glBlendFunc
- int mGLBlendFuncCalled;
- int mGLBlendFuncSFactor;
- int mGLBlendFuncDFactor;
- // glColor4[fx]
- int mGLColorCalled;
- int mGLColor;
- // glEnable, glDisable
- boolean mGLBlendEnabled;
- boolean mGLStencilEnabled;
- // glEnableClientState
- boolean mGLVertexArrayEnabled;
- // glVertexPointer
- PointerInfo mGLVertexPointer;
- // glMatrixMode
- int mGLMatrixMode = GL10.GL_MODELVIEW;
- // glLoadMatrixf
- float[] mGLModelViewMatrix = new float[16];
- float[] mGLProjectionMatrix = new float[16];
- // glBindTexture
- int mGLBindTextureId;
- // glTexEnvf
- HashMap<Integer, Float> mGLTexEnv0 = new HashMap<Integer, Float>();
- HashMap<Integer, Float> mGLTexEnv1 = new HashMap<Integer, Float>();
- // glActiveTexture
- int mGLActiveTexture = GL11.GL_TEXTURE0;
-
- @Override
- public void glClear(int mask) {
- mGLClearCalled++;
- mGLClearMask = mask;
- }
-
- @Override
- public void glBlendFunc(int sfactor, int dfactor) {
- mGLBlendFuncSFactor = sfactor;
- mGLBlendFuncDFactor = dfactor;
- mGLBlendFuncCalled++;
- }
-
- @Override
- public void glColor4f(float red, float green, float blue,
- float alpha) {
- mGLColorCalled++;
- mGLColor = makeColor4f(red, green, blue, alpha);
- }
-
- @Override
- public void glColor4x(int red, int green, int blue, int alpha) {
- mGLColorCalled++;
- mGLColor = makeColor4x(red, green, blue, alpha);
- }
-
- @Override
- public void glEnable(int cap) {
- if (cap == GL11.GL_BLEND) {
- mGLBlendEnabled = true;
- } else if (cap == GL11.GL_STENCIL_TEST) {
- mGLStencilEnabled = true;
- }
- }
-
- @Override
- public void glDisable(int cap) {
- if (cap == GL11.GL_BLEND) {
- mGLBlendEnabled = false;
- } else if (cap == GL11.GL_STENCIL_TEST) {
- mGLStencilEnabled = false;
- }
- }
-
- @Override
- public void glEnableClientState(int array) {
- if (array == GL10.GL_VERTEX_ARRAY) {
- mGLVertexArrayEnabled = true;
- }
- }
-
- @Override
- public void glVertexPointer(int size, int type, int stride, Buffer pointer) {
- mGLVertexPointer = new PointerInfo(size, type, stride, pointer);
- }
-
- @Override
- public void glMatrixMode(int mode) {
- mGLMatrixMode = mode;
- }
-
- @Override
- public void glLoadMatrixf(float[] m, int offset) {
- if (mGLMatrixMode == GL10.GL_MODELVIEW) {
- System.arraycopy(m, offset, mGLModelViewMatrix, 0, 16);
- } else if (mGLMatrixMode == GL10.GL_PROJECTION) {
- System.arraycopy(m, offset, mGLProjectionMatrix, 0, 16);
- }
- }
-
- @Override
- public void glOrthof(
- float left, float right, float bottom, float top,
- float zNear, float zFar) {
- float tx = -(right + left) / (right - left);
- float ty = -(top + bottom) / (top - bottom);
- float tz = - (zFar + zNear) / (zFar - zNear);
- float[] m = new float[] {
- 2 / (right - left), 0, 0, 0,
- 0, 2 / (top - bottom), 0, 0,
- 0, 0, -2 / (zFar - zNear), 0,
- tx, ty, tz, 1
- };
- glLoadMatrixf(m, 0);
- }
-
- @Override
- public void glBindTexture(int target, int texture) {
- if (target == GL11.GL_TEXTURE_2D) {
- mGLBindTextureId = texture;
- }
- }
-
- @Override
- public void glTexEnvf(int target, int pname, float param) {
- if (target == GL11.GL_TEXTURE_ENV) {
- if (mGLActiveTexture == GL11.GL_TEXTURE0) {
- mGLTexEnv0.put(pname, param);
- } else if (mGLActiveTexture == GL11.GL_TEXTURE1) {
- mGLTexEnv1.put(pname, param);
- } else {
- throw new AssertionError();
- }
- }
- }
-
- public int getTexEnvi(int pname) {
- return getTexEnvi(mGLActiveTexture, pname);
- }
-
- public int getTexEnvi(int activeTexture, int pname) {
- if (activeTexture == GL11.GL_TEXTURE0) {
- return (int) mGLTexEnv0.get(pname).floatValue();
- } else if (activeTexture == GL11.GL_TEXTURE1) {
- return (int) mGLTexEnv1.get(pname).floatValue();
- } else {
- throw new AssertionError();
- }
- }
-
- @Override
- public void glActiveTexture(int texture) {
- mGLActiveTexture = texture;
- }
-
- public static int makeColor4f(float red, float green, float blue,
- float alpha) {
- return (Math.round(alpha * 255) << 24) |
- (Math.round(red * 255) << 16) |
- (Math.round(green * 255) << 8) |
- Math.round(blue * 255);
- }
-
- public static int makeColor4x(int red, int green, int blue, int alpha) {
- final float X = 65536f;
- return makeColor4f(red / X, green / X, blue / X, alpha / X);
- }
-}
diff --git a/tests/src/com/android/gallery3d/glrenderer/GLStub.java b/tests/src/com/android/gallery3d/glrenderer/GLStub.java
deleted file mode 100644
index 4b66040..0000000
--- a/tests/src/com/android/gallery3d/glrenderer/GLStub.java
+++ /dev/null
@@ -1,1490 +0,0 @@
-/*
- * Copyright (C) 2010 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.glrenderer;
-
-import javax.microedition.khronos.opengles.GL;
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL10Ext;
-import javax.microedition.khronos.opengles.GL11;
-import javax.microedition.khronos.opengles.GL11Ext;
-
-public class GLStub implements GL, GL10, GL10Ext, GL11, GL11Ext {
- @SuppressWarnings("unused")
- private static final String TAG = "GLStub";
-
- public void glActiveTexture(
- int texture
- ){}
-
- public void glAlphaFunc(
- int func,
- float ref
- ){}
-
- public void glAlphaFuncx(
- int func,
- int ref
- ){}
-
- public void glBindTexture(
- int target,
- int texture
- ){}
-
- public void glBlendFunc(
- int sfactor,
- int dfactor
- ){}
-
- public void glClear(
- int mask
- ){}
-
- public void glClearColor(
- float red,
- float green,
- float blue,
- float alpha
- ){}
-
- public void glClearColorx(
- int red,
- int green,
- int blue,
- int alpha
- ){}
-
- public void glClearDepthf(
- float depth
- ){}
-
- public void glClearDepthx(
- int depth
- ){}
-
- public void glClearStencil(
- int s
- ){}
-
- public void glClientActiveTexture(
- int texture
- ){}
-
- public void glColor4f(
- float red,
- float green,
- float blue,
- float alpha
- ){}
-
- public void glColor4x(
- int red,
- int green,
- int blue,
- int alpha
- ){}
-
- public void glColorMask(
- boolean red,
- boolean green,
- boolean blue,
- boolean alpha
- ){}
-
- public void glColorPointer(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glCompressedTexImage2D(
- int target,
- int level,
- int internalformat,
- int width,
- int height,
- int border,
- int imageSize,
- java.nio.Buffer data
- ){}
-
- public void glCompressedTexSubImage2D(
- int target,
- int level,
- int xoffset,
- int yoffset,
- int width,
- int height,
- int format,
- int imageSize,
- java.nio.Buffer data
- ){}
-
- public void glCopyTexImage2D(
- int target,
- int level,
- int internalformat,
- int x,
- int y,
- int width,
- int height,
- int border
- ){}
-
- public void glCopyTexSubImage2D(
- int target,
- int level,
- int xoffset,
- int yoffset,
- int x,
- int y,
- int width,
- int height
- ){}
-
- public void glCullFace(
- int mode
- ){}
-
- public void glDeleteTextures(
- int n,
- int[] textures,
- int offset
- ){}
-
- public void glDeleteTextures(
- int n,
- java.nio.IntBuffer textures
- ){}
-
- public void glDepthFunc(
- int func
- ){}
-
- public void glDepthMask(
- boolean flag
- ){}
-
- public void glDepthRangef(
- float zNear,
- float zFar
- ){}
-
- public void glDepthRangex(
- int zNear,
- int zFar
- ){}
-
- public void glDisable(
- int cap
- ){}
-
- public void glDisableClientState(
- int array
- ){}
-
- public void glDrawArrays(
- int mode,
- int first,
- int count
- ){}
-
- public void glDrawElements(
- int mode,
- int count,
- int type,
- java.nio.Buffer indices
- ){}
-
- public void glEnable(
- int cap
- ){}
-
- public void glEnableClientState(
- int array
- ){}
-
- public void glFinish(
- ){}
-
- public void glFlush(
- ){}
-
- public void glFogf(
- int pname,
- float param
- ){}
-
- public void glFogfv(
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glFogfv(
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glFogx(
- int pname,
- int param
- ){}
-
- public void glFogxv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glFogxv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glFrontFace(
- int mode
- ){}
-
- public void glFrustumf(
- float left,
- float right,
- float bottom,
- float top,
- float zNear,
- float zFar
- ){}
-
- public void glFrustumx(
- int left,
- int right,
- int bottom,
- int top,
- int zNear,
- int zFar
- ){}
-
- public void glGenTextures(
- int n,
- int[] textures,
- int offset
- ){}
-
- public void glGenTextures(
- int n,
- java.nio.IntBuffer textures
- ){}
-
- public int glGetError(
- ){ throw new UnsupportedOperationException(); }
-
- public void glGetIntegerv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetIntegerv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public String glGetString(
- int name
- ){ throw new UnsupportedOperationException(); }
-
- public void glHint(
- int target,
- int mode
- ){}
-
- public void glLightModelf(
- int pname,
- float param
- ){}
-
- public void glLightModelfv(
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glLightModelfv(
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glLightModelx(
- int pname,
- int param
- ){}
-
- public void glLightModelxv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glLightModelxv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glLightf(
- int light,
- int pname,
- float param
- ){}
-
- public void glLightfv(
- int light,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glLightfv(
- int light,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glLightx(
- int light,
- int pname,
- int param
- ){}
-
- public void glLightxv(
- int light,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glLightxv(
- int light,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glLineWidth(
- float width
- ){}
-
- public void glLineWidthx(
- int width
- ){}
-
- public void glLoadIdentity(
- ){}
-
- public void glLoadMatrixf(
- float[] m,
- int offset
- ){}
-
- public void glLoadMatrixf(
- java.nio.FloatBuffer m
- ){}
-
- public void glLoadMatrixx(
- int[] m,
- int offset
- ){}
-
- public void glLoadMatrixx(
- java.nio.IntBuffer m
- ){}
-
- public void glLogicOp(
- int opcode
- ){}
-
- public void glMaterialf(
- int face,
- int pname,
- float param
- ){}
-
- public void glMaterialfv(
- int face,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glMaterialfv(
- int face,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glMaterialx(
- int face,
- int pname,
- int param
- ){}
-
- public void glMaterialxv(
- int face,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glMaterialxv(
- int face,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glMatrixMode(
- int mode
- ){}
-
- public void glMultMatrixf(
- float[] m,
- int offset
- ){}
-
- public void glMultMatrixf(
- java.nio.FloatBuffer m
- ){}
-
- public void glMultMatrixx(
- int[] m,
- int offset
- ){}
-
- public void glMultMatrixx(
- java.nio.IntBuffer m
- ){}
-
- public void glMultiTexCoord4f(
- int target,
- float s,
- float t,
- float r,
- float q
- ){}
-
- public void glMultiTexCoord4x(
- int target,
- int s,
- int t,
- int r,
- int q
- ){}
-
- public void glNormal3f(
- float nx,
- float ny,
- float nz
- ){}
-
- public void glNormal3x(
- int nx,
- int ny,
- int nz
- ){}
-
- public void glNormalPointer(
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glOrthof(
- float left,
- float right,
- float bottom,
- float top,
- float zNear,
- float zFar
- ){}
-
- public void glOrthox(
- int left,
- int right,
- int bottom,
- int top,
- int zNear,
- int zFar
- ){}
-
- public void glPixelStorei(
- int pname,
- int param
- ){}
-
- public void glPointSize(
- float size
- ){}
-
- public void glPointSizex(
- int size
- ){}
-
- public void glPolygonOffset(
- float factor,
- float units
- ){}
-
- public void glPolygonOffsetx(
- int factor,
- int units
- ){}
-
- public void glPopMatrix(
- ){}
-
- public void glPushMatrix(
- ){}
-
- public void glReadPixels(
- int x,
- int y,
- int width,
- int height,
- int format,
- int type,
- java.nio.Buffer pixels
- ){}
-
- public void glRotatef(
- float angle,
- float x,
- float y,
- float z
- ){}
-
- public void glRotatex(
- int angle,
- int x,
- int y,
- int z
- ){}
-
- public void glSampleCoverage(
- float value,
- boolean invert
- ){}
-
- public void glSampleCoveragex(
- int value,
- boolean invert
- ){}
-
- public void glScalef(
- float x,
- float y,
- float z
- ){}
-
- public void glScalex(
- int x,
- int y,
- int z
- ){}
-
- public void glScissor(
- int x,
- int y,
- int width,
- int height
- ){}
-
- public void glShadeModel(
- int mode
- ){}
-
- public void glStencilFunc(
- int func,
- int ref,
- int mask
- ){}
-
- public void glStencilMask(
- int mask
- ){}
-
- public void glStencilOp(
- int fail,
- int zfail,
- int zpass
- ){}
-
- public void glTexCoordPointer(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glTexEnvf(
- int target,
- int pname,
- float param
- ){}
-
- public void glTexEnvfv(
- int target,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glTexEnvfv(
- int target,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glTexEnvx(
- int target,
- int pname,
- int param
- ){}
-
- public void glTexEnvxv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexEnvxv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glTexImage2D(
- int target,
- int level,
- int internalformat,
- int width,
- int height,
- int border,
- int format,
- int type,
- java.nio.Buffer pixels
- ){}
-
- public void glTexParameterf(
- int target,
- int pname,
- float param
- ){}
-
- public void glTexParameterx(
- int target,
- int pname,
- int param
- ){}
-
- public void glTexSubImage2D(
- int target,
- int level,
- int xoffset,
- int yoffset,
- int width,
- int height,
- int format,
- int type,
- java.nio.Buffer pixels
- ){}
-
- public void glTranslatef(
- float x,
- float y,
- float z
- ){}
-
- public void glTranslatex(
- int x,
- int y,
- int z
- ){}
-
- public void glVertexPointer(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glViewport(
- int x,
- int y,
- int width,
- int height
- ){}
-
- public int glQueryMatrixxOES(
- int[] mantissa,
- int mantissaOffset,
- int[] exponent,
- int exponentOffset
- ){ throw new UnsupportedOperationException(); }
-
- public int glQueryMatrixxOES(
- java.nio.IntBuffer mantissa,
- java.nio.IntBuffer exponent
- ){ throw new UnsupportedOperationException(); }
-
- public void glGetPointerv(int pname, java.nio.Buffer[] params){}
- public void glBindBuffer(
- int target,
- int buffer
- ){}
-
- public void glBufferData(
- int target,
- int size,
- java.nio.Buffer data,
- int usage
- ){}
-
- public void glBufferSubData(
- int target,
- int offset,
- int size,
- java.nio.Buffer data
- ){}
-
- public void glClipPlanef(
- int plane,
- float[] equation,
- int offset
- ){}
-
- public void glClipPlanef(
- int plane,
- java.nio.FloatBuffer equation
- ){}
-
- public void glClipPlanex(
- int plane,
- int[] equation,
- int offset
- ){}
-
- public void glClipPlanex(
- int plane,
- java.nio.IntBuffer equation
- ){}
-
- public void glColor4ub(
- byte red,
- byte green,
- byte blue,
- byte alpha
- ){}
-
- public void glColorPointer(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glDeleteBuffers(
- int n,
- int[] buffers,
- int offset
- ){}
-
- public void glDeleteBuffers(
- int n,
- java.nio.IntBuffer buffers
- ){}
-
- public void glDrawElements(
- int mode,
- int count,
- int type,
- int offset
- ){}
-
- public void glGenBuffers(
- int n,
- int[] buffers,
- int offset
- ){}
-
- public void glGenBuffers(
- int n,
- java.nio.IntBuffer buffers
- ){}
-
- public void glGetBooleanv(
- int pname,
- boolean[] params,
- int offset
- ){}
-
- public void glGetBooleanv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetBufferParameteriv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetBufferParameteriv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetClipPlanef(
- int pname,
- float[] eqn,
- int offset
- ){}
-
- public void glGetClipPlanef(
- int pname,
- java.nio.FloatBuffer eqn
- ){}
-
- public void glGetClipPlanex(
- int pname,
- int[] eqn,
- int offset
- ){}
-
- public void glGetClipPlanex(
- int pname,
- java.nio.IntBuffer eqn
- ){}
-
- public void glGetFixedv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetFixedv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetFloatv(
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetFloatv(
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetLightfv(
- int light,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetLightfv(
- int light,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetLightxv(
- int light,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetLightxv(
- int light,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetMaterialfv(
- int face,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetMaterialfv(
- int face,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetMaterialxv(
- int face,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetMaterialxv(
- int face,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexEnviv(
- int env,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexEnviv(
- int env,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexEnvxv(
- int env,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexEnvxv(
- int env,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexParameterfv(
- int target,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetTexParameterfv(
- int target,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetTexParameteriv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexParameteriv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexParameterxv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexParameterxv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public boolean glIsBuffer(
- int buffer
- ){ throw new UnsupportedOperationException(); }
-
- public boolean glIsEnabled(
- int cap
- ){ throw new UnsupportedOperationException(); }
-
- public boolean glIsTexture(
- int texture
- ){ throw new UnsupportedOperationException(); }
-
- public void glNormalPointer(
- int type,
- int stride,
- int offset
- ){}
-
- public void glPointParameterf(
- int pname,
- float param
- ){}
-
- public void glPointParameterfv(
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glPointParameterfv(
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glPointParameterx(
- int pname,
- int param
- ){}
-
- public void glPointParameterxv(
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glPointParameterxv(
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glPointSizePointerOES(
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glTexCoordPointer(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glTexEnvi(
- int target,
- int pname,
- int param
- ){}
-
- public void glTexEnviv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexEnviv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glTexParameterfv(
- int target,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glTexParameterfv(
- int target,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glTexParameteri(
- int target,
- int pname,
- int param
- ){}
-
- public void glTexParameteriv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexParameteriv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glTexParameterxv(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexParameterxv(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glVertexPointer(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glCurrentPaletteMatrixOES(
- int matrixpaletteindex
- ){}
-
- public void glDrawTexfOES(
- float x,
- float y,
- float z,
- float width,
- float height
- ){}
-
- public void glDrawTexfvOES(
- float[] coords,
- int offset
- ){}
-
- public void glDrawTexfvOES(
- java.nio.FloatBuffer coords
- ){}
-
- public void glDrawTexiOES(
- int x,
- int y,
- int z,
- int width,
- int height
- ){}
-
- public void glDrawTexivOES(
- int[] coords,
- int offset
- ){}
-
- public void glDrawTexivOES(
- java.nio.IntBuffer coords
- ){}
-
- public void glDrawTexsOES(
- short x,
- short y,
- short z,
- short width,
- short height
- ){}
-
- public void glDrawTexsvOES(
- short[] coords,
- int offset
- ){}
-
- public void glDrawTexsvOES(
- java.nio.ShortBuffer coords
- ){}
-
- public void glDrawTexxOES(
- int x,
- int y,
- int z,
- int width,
- int height
- ){}
-
- public void glDrawTexxvOES(
- int[] coords,
- int offset
- ){}
-
- public void glDrawTexxvOES(
- java.nio.IntBuffer coords
- ){}
-
- public void glLoadPaletteFromModelViewMatrixOES(
- ){}
-
- public void glMatrixIndexPointerOES(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glMatrixIndexPointerOES(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glWeightPointerOES(
- int size,
- int type,
- int stride,
- java.nio.Buffer pointer
- ){}
-
- public void glWeightPointerOES(
- int size,
- int type,
- int stride,
- int offset
- ){}
-
- public void glBindFramebufferOES(
- int target,
- int framebuffer
- ){}
-
- public void glBindRenderbufferOES(
- int target,
- int renderbuffer
- ){}
-
- public void glBlendEquation(
- int mode
- ){}
-
- public void glBlendEquationSeparate(
- int modeRGB,
- int modeAlpha
- ){}
-
- public void glBlendFuncSeparate(
- int srcRGB,
- int dstRGB,
- int srcAlpha,
- int dstAlpha
- ){}
-
- public int glCheckFramebufferStatusOES(
- int target
- ){ throw new UnsupportedOperationException(); }
-
- public void glDeleteFramebuffersOES(
- int n,
- int[] framebuffers,
- int offset
- ){}
-
- public void glDeleteFramebuffersOES(
- int n,
- java.nio.IntBuffer framebuffers
- ){}
-
- public void glDeleteRenderbuffersOES(
- int n,
- int[] renderbuffers,
- int offset
- ){}
-
- public void glDeleteRenderbuffersOES(
- int n,
- java.nio.IntBuffer renderbuffers
- ){}
-
- public void glFramebufferRenderbufferOES(
- int target,
- int attachment,
- int renderbuffertarget,
- int renderbuffer
- ){}
-
- public void glFramebufferTexture2DOES(
- int target,
- int attachment,
- int textarget,
- int texture,
- int level
- ){}
-
- public void glGenerateMipmapOES(
- int target
- ){}
-
- public void glGenFramebuffersOES(
- int n,
- int[] framebuffers,
- int offset
- ){}
-
- public void glGenFramebuffersOES(
- int n,
- java.nio.IntBuffer framebuffers
- ){}
-
- public void glGenRenderbuffersOES(
- int n,
- int[] renderbuffers,
- int offset
- ){}
-
- public void glGenRenderbuffersOES(
- int n,
- java.nio.IntBuffer renderbuffers
- ){}
-
- public void glGetFramebufferAttachmentParameterivOES(
- int target,
- int attachment,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetFramebufferAttachmentParameterivOES(
- int target,
- int attachment,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetRenderbufferParameterivOES(
- int target,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetRenderbufferParameterivOES(
- int target,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexGenfv(
- int coord,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glGetTexGenfv(
- int coord,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glGetTexGeniv(
- int coord,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexGeniv(
- int coord,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glGetTexGenxv(
- int coord,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glGetTexGenxv(
- int coord,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public boolean glIsFramebufferOES(
- int framebuffer
- ){ throw new UnsupportedOperationException(); }
-
- public boolean glIsRenderbufferOES(
- int renderbuffer
- ){ throw new UnsupportedOperationException(); }
-
- public void glRenderbufferStorageOES(
- int target,
- int internalformat,
- int width,
- int height
- ){}
-
- public void glTexGenf(
- int coord,
- int pname,
- float param
- ){}
-
- public void glTexGenfv(
- int coord,
- int pname,
- float[] params,
- int offset
- ){}
-
- public void glTexGenfv(
- int coord,
- int pname,
- java.nio.FloatBuffer params
- ){}
-
- public void glTexGeni(
- int coord,
- int pname,
- int param
- ){}
-
- public void glTexGeniv(
- int coord,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexGeniv(
- int coord,
- int pname,
- java.nio.IntBuffer params
- ){}
-
- public void glTexGenx(
- int coord,
- int pname,
- int param
- ){}
-
- public void glTexGenxv(
- int coord,
- int pname,
- int[] params,
- int offset
- ){}
-
- public void glTexGenxv(
- int coord,
- int pname,
- java.nio.IntBuffer params
- ){}
-}
diff --git a/tests/src/com/android/gallery3d/glrenderer/TextureTest.java b/tests/src/com/android/gallery3d/glrenderer/TextureTest.java
deleted file mode 100644
index 956d894..0000000
--- a/tests/src/com/android/gallery3d/glrenderer/TextureTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2010 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.glrenderer;
-
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import com.android.gallery3d.glrenderer.BasicTexture;
-import com.android.gallery3d.glrenderer.BitmapTexture;
-import com.android.gallery3d.glrenderer.ColorTexture;
-import com.android.gallery3d.glrenderer.GLCanvas;
-import com.android.gallery3d.glrenderer.GLES11Canvas;
-import com.android.gallery3d.glrenderer.UploadedTexture;
-
-import junit.framework.TestCase;
-
-import javax.microedition.khronos.opengles.GL11;
-
-@SmallTest
-public class TextureTest extends TestCase {
- @SuppressWarnings("unused")
- private static final String TAG = "TextureTest";
-
- class MyBasicTexture extends BasicTexture {
- int mOnBindCalled;
- int mOpaqueCalled;
-
- MyBasicTexture(GLCanvas canvas, int id) {
- super(canvas, id, 0);
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- mOnBindCalled++;
- return true;
- }
-
- @Override
- protected int getTarget() {
- return GL11.GL_TEXTURE_2D;
- }
-
- @Override
- public boolean isOpaque() {
- mOpaqueCalled++;
- return true;
- }
-
- void upload() {
- mState = STATE_LOADED;
- }
- }
-
- @SmallTest
- public void testBasicTexture() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLES11Canvas(glStub);
- MyBasicTexture texture = new MyBasicTexture(canvas, 47);
-
- assertEquals(47, texture.getId());
- texture.setSize(1, 1);
- assertEquals(1, texture.getWidth());
- assertEquals(1, texture.getHeight());
- assertEquals(1, texture.getTextureWidth());
- assertEquals(1, texture.getTextureHeight());
- texture.setSize(3, 5);
- assertEquals(3, texture.getWidth());
- assertEquals(5, texture.getHeight());
- assertEquals(4, texture.getTextureWidth());
- assertEquals(8, texture.getTextureHeight());
-
- assertFalse(texture.isLoaded());
- texture.upload();
- assertTrue(texture.isLoaded());
-
- // For a different GL, it's not loaded.
- GLCanvas canvas2 = new GLES11Canvas(glStub);
- assertFalse(texture.isLoaded());
-
- assertEquals(0, texture.mOnBindCalled);
- assertEquals(0, texture.mOpaqueCalled);
- texture.draw(canvas, 100, 200, 1, 1);
- assertEquals(1, texture.mOnBindCalled);
- assertEquals(1, texture.mOpaqueCalled);
- texture.draw(canvas, 0, 0);
- assertEquals(2, texture.mOnBindCalled);
- assertEquals(2, texture.mOpaqueCalled);
- }
-
- @SmallTest
- public void testColorTexture() {
- GLCanvasMock canvas = new GLCanvasMock();
- ColorTexture texture = new ColorTexture(0x12345678);
-
- texture.setSize(42, 47);
- assertEquals(texture.getWidth(), 42);
- assertEquals(texture.getHeight(), 47);
- assertEquals(0, canvas.mFillRectCalled);
- texture.draw(canvas, 0, 0);
- assertEquals(1, canvas.mFillRectCalled);
- assertEquals(0x12345678, canvas.mFillRectColor);
- assertEquals(42f, canvas.mFillRectWidth);
- assertEquals(47f, canvas.mFillRectHeight);
- assertFalse(texture.isOpaque());
- assertTrue(new ColorTexture(0xFF000000).isOpaque());
- }
-
- private class MyUploadedTexture extends UploadedTexture {
- int mGetCalled;
- int mFreeCalled;
- Bitmap mBitmap;
- @Override
- protected Bitmap onGetBitmap() {
- mGetCalled++;
- Config config = Config.ARGB_8888;
- mBitmap = Bitmap.createBitmap(47, 42, config);
- return mBitmap;
- }
- @Override
- protected void onFreeBitmap(Bitmap bitmap) {
- mFreeCalled++;
- assertSame(mBitmap, bitmap);
- mBitmap.recycle();
- mBitmap = null;
- }
- }
-
- @SmallTest
- public void testUploadedTexture() {
- GL11 glStub = new GLStub();
- GLCanvas canvas = new GLES11Canvas(glStub);
- MyUploadedTexture texture = new MyUploadedTexture();
-
- // draw it and the bitmap should be fetched.
- assertEquals(0, texture.mFreeCalled);
- assertEquals(0, texture.mGetCalled);
- texture.draw(canvas, 0, 0);
- assertEquals(1, texture.mGetCalled);
- assertTrue(texture.isLoaded());
- assertTrue(texture.isContentValid());
-
- // invalidate content and it should be freed.
- texture.invalidateContent();
- assertFalse(texture.isContentValid());
- assertEquals(1, texture.mFreeCalled);
- assertTrue(texture.isLoaded()); // But it's still loaded
-
- // draw it again and the bitmap should be fetched again.
- texture.draw(canvas, 0, 0);
- assertEquals(2, texture.mGetCalled);
- assertTrue(texture.isLoaded());
- assertTrue(texture.isContentValid());
-
- // recycle the texture and it should be freed again.
- texture.recycle();
- assertEquals(2, texture.mFreeCalled);
- // TODO: these two are broken and waiting for fix.
- //assertFalse(texture.isLoaded(canvas));
- //assertFalse(texture.isContentValid(canvas));
- }
-
- class MyTextureForMixed extends BasicTexture {
- MyTextureForMixed(GLCanvas canvas, int id) {
- super(canvas, id, 0);
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- return true;
- }
-
- @Override
- protected int getTarget() {
- return GL11.GL_TEXTURE_2D;
- }
-
- @Override
- public boolean isOpaque() {
- return true;
- }
- }
-
- @SmallTest
- public void testBitmapTexture() {
- Config config = Config.ARGB_8888;
- Bitmap bitmap = Bitmap.createBitmap(47, 42, config);
- assertFalse(bitmap.isRecycled());
- BitmapTexture texture = new BitmapTexture(bitmap);
- texture.recycle();
- assertFalse(bitmap.isRecycled());
- bitmap.recycle();
- assertTrue(bitmap.isRecycled());
- }
-}
diff --git a/tests/src/com/android/gallery3d/stress/CameraLatency.java b/tests/src/com/android/gallery3d/stress/CameraLatency.java
deleted file mode 100755
index 7177abe..0000000
--- a/tests/src/com/android/gallery3d/stress/CameraLatency.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2009 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.stress;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Instrumentation;
-import android.os.Environment;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-
-/**
- * Junit / Instrumentation test case for camera test
- *
- */
-
-public class CameraLatency extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private String TAG = "CameraLatency";
- private static final int TOTAL_NUMBER_OF_IMAGECAPTURE = 20;
- private static final long WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN = 4000;
- private static final String CAMERA_TEST_OUTPUT_FILE =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
-
- private long mTotalAutoFocusTime;
- private long mTotalShutterLag;
- private long mTotalShutterToPictureDisplayedTime;
- private long mTotalPictureDisplayedToJpegCallbackTime;
- private long mTotalJpegCallbackFinishTime;
- private long mAvgAutoFocusTime;
- private long mAvgShutterLag = mTotalShutterLag;
- private long mAvgShutterToPictureDisplayedTime;
- private long mAvgPictureDisplayedToJpegCallbackTime;
- private long mAvgJpegCallbackFinishTime;
-
- public CameraLatency() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- getActivity();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- @LargeTest
- public void testImageCapture() {
- Log.v(TAG, "start testImageCapture test");
- Instrumentation inst = getInstrumentation();
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
- try {
- for (int i = 0; i < TOTAL_NUMBER_OF_IMAGECAPTURE; i++) {
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- //skip the first measurement
- if (i != 0) {
- CameraActivity c = getActivity();
-
- // if any of the latency var accessor methods return -1 then the
- // camera is set to a different module other than PhotoModule so
- // skip the shot and try again
- if (c.getAutoFocusTime() != -1) {
- mTotalAutoFocusTime += c.getAutoFocusTime();
- mTotalShutterLag += c.getShutterLag();
- mTotalShutterToPictureDisplayedTime +=
- c.getShutterToPictureDisplayedTime();
- mTotalPictureDisplayedToJpegCallbackTime +=
- c.getPictureDisplayedToJpegCallbackTime();
- mTotalJpegCallbackFinishTime += c.getJpegCallbackFinishTime();
- }
- else {
- i--;
- continue;
- }
- }
- }
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- }
- //ToDO: yslau
- //1) Need to get the baseline from the cupcake so that we can add the
- //failure condition of the camera latency.
- //2) Only count those number with succesful capture. Set the timer to invalid
- //before capture and ignore them if the value is invalid
- int numberofRun = TOTAL_NUMBER_OF_IMAGECAPTURE - 1;
- mAvgAutoFocusTime = mTotalAutoFocusTime / numberofRun;
- mAvgShutterLag = mTotalShutterLag / numberofRun;
- mAvgShutterToPictureDisplayedTime =
- mTotalShutterToPictureDisplayedTime / numberofRun;
- mAvgPictureDisplayedToJpegCallbackTime =
- mTotalPictureDisplayedToJpegCallbackTime / numberofRun;
- mAvgJpegCallbackFinishTime =
- mTotalJpegCallbackFinishTime / numberofRun;
-
- try {
- FileWriter fstream = null;
- fstream = new FileWriter(CAMERA_TEST_OUTPUT_FILE, true);
- BufferedWriter out = new BufferedWriter(fstream);
- out.write("Camera Latency : \n");
- out.write("Number of loop: " + TOTAL_NUMBER_OF_IMAGECAPTURE + "\n");
- out.write("Avg AutoFocus = " + mAvgAutoFocusTime + "\n");
- out.write("Avg mShutterLag = " + mAvgShutterLag + "\n");
- out.write("Avg mShutterToPictureDisplayedTime = "
- + mAvgShutterToPictureDisplayedTime + "\n");
- out.write("Avg mPictureDisplayedToJpegCallbackTime = "
- + mAvgPictureDisplayedToJpegCallbackTime + "\n");
- out.write("Avg mJpegCallbackFinishTime = " +
- mAvgJpegCallbackFinishTime + "\n");
- out.close();
- fstream.close();
- } catch (Exception e) {
- fail("Camera Latency write output to file");
- }
- Log.v(TAG, "The Image capture wait time = " +
- WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- Log.v(TAG, "Avg AutoFocus = " + mAvgAutoFocusTime);
- Log.v(TAG, "Avg mShutterLag = " + mAvgShutterLag);
- Log.v(TAG, "Avg mShutterToPictureDisplayedTime = "
- + mAvgShutterToPictureDisplayedTime);
- Log.v(TAG, "Avg mPictureDisplayedToJpegCallbackTime = "
- + mAvgPictureDisplayedToJpegCallbackTime);
- Log.v(TAG, "Avg mJpegCallbackFinishTime = " + mAvgJpegCallbackFinishTime);
- }
-}
-
diff --git a/tests/src/com/android/gallery3d/stress/CameraStartUp.java b/tests/src/com/android/gallery3d/stress/CameraStartUp.java
deleted file mode 100644
index 8524465..0000000
--- a/tests/src/com/android/gallery3d/stress/CameraStartUp.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2009 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.stress;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-import java.io.FileWriter;
-import java.io.BufferedWriter;
-
-/**
- * Test cases to measure the camera and video recorder startup time.
- */
-public class CameraStartUp extends InstrumentationTestCase {
-
- private static final int TOTAL_NUMBER_OF_STARTUP = 20;
-
- private String TAG = "CameraStartUp";
- private static final String CAMERA_TEST_OUTPUT_FILE =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- private static int WAIT_TIME_FOR_PREVIEW = 1500; //1.5 second
-
- private long launchCamera() {
- long startupTime = 0;
- try {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- long beforeStart = System.currentTimeMillis();
- Instrumentation inst = getInstrumentation();
- Activity cameraActivity = inst.startActivitySync(intent);
- long cameraStarted = System.currentTimeMillis();
- Thread.sleep(WAIT_TIME_FOR_PREVIEW);
- cameraActivity.finish();
- startupTime = cameraStarted - beforeStart;
- Thread.sleep(1000);
- Log.v(TAG, "camera startup time: " + startupTime);
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- fail("Fails to get the output file");
- }
- return startupTime;
- }
-
- private long launchVideo() {
- long startupTime = 0;
-
- try {
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- long beforeStart = System.currentTimeMillis();
- Instrumentation inst = getInstrumentation();
- Activity recorderActivity = inst.startActivitySync(intent);
- long cameraStarted = System.currentTimeMillis();
- recorderActivity.finish();
- startupTime = cameraStarted - beforeStart;
- Log.v(TAG, "Video Startup Time = " + startupTime);
- // wait for 1s to make sure it reach a clean stage
- Thread.sleep(WAIT_TIME_FOR_PREVIEW);
- Log.v(TAG, "video startup time: " + startupTime);
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- fail("Fails to launch video output file");
- }
- return startupTime;
- }
-
- private void writeToOutputFile(long totalStartupTime,
- String individualStartupTime, boolean firstStartUp, String Type) throws Exception {
- // TODO (yslau) : Need to integrate the output data with central
- // dashboard
- try {
- FileWriter fstream = null;
- fstream = new FileWriter(CAMERA_TEST_OUTPUT_FILE, true);
- BufferedWriter out = new BufferedWriter(fstream);
- if (firstStartUp) {
- out.write("First " + Type + " Startup: " + totalStartupTime + "\n");
- } else {
- long averageStartupTime = totalStartupTime / (TOTAL_NUMBER_OF_STARTUP -1);
- out.write(Type + "startup time: " + "\n");
- out.write("Number of loop: " + (TOTAL_NUMBER_OF_STARTUP -1) + "\n");
- out.write(individualStartupTime + "\n\n");
- out.write(Type + " average startup time: " + averageStartupTime + " ms\n\n");
- }
- out.close();
- fstream.close();
- } catch (Exception e) {
- fail("Camera write output to file");
- }
- }
-
- @LargeTest
- public void testLaunchVideo() throws Exception {
- String individualStartupTime;
- individualStartupTime = "Individual Video Startup Time = ";
- long totalStartupTime = 0;
- long startupTime = 0;
- for (int i = 0; i < TOTAL_NUMBER_OF_STARTUP; i++) {
- if (i == 0) {
- // Capture the first startup time individually
- long firstStartUpTime = launchVideo();
- writeToOutputFile(firstStartUpTime, "na", true, "Video");
- } else {
- startupTime = launchVideo();
- totalStartupTime += startupTime;
- individualStartupTime += startupTime + " ,";
- }
- }
- Log.v(TAG, "totalStartupTime =" + totalStartupTime);
- writeToOutputFile(totalStartupTime, individualStartupTime, false, "Video");
- }
-
- @LargeTest
- public void testLaunchCamera() throws Exception {
- String individualStartupTime;
- individualStartupTime = "Individual Camera Startup Time = ";
- long totalStartupTime = 0;
- long startupTime = 0;
- for (int i = 0; i < TOTAL_NUMBER_OF_STARTUP; i++) {
- if (i == 0) {
- // Capture the first startup time individually
- long firstStartUpTime = launchCamera();
- writeToOutputFile(firstStartUpTime, "na", true, "Camera");
- } else {
- startupTime = launchCamera();
- totalStartupTime += startupTime;
- individualStartupTime += startupTime + " ,";
- }
- }
- Log.v(TAG, "totalStartupTime =" + totalStartupTime);
- writeToOutputFile(totalStartupTime,
- individualStartupTime, false, "Camera");
- }
-}
diff --git a/tests/src/com/android/gallery3d/stress/CameraStressTestRunner.java b/tests/src/com/android/gallery3d/stress/CameraStressTestRunner.java
deleted file mode 100755
index d3fb10d..0000000
--- a/tests/src/com/android/gallery3d/stress/CameraStressTestRunner.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2010 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.stress;
-
-import android.os.Bundle;
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-import junit.framework.TestSuite;
-
-public class CameraStressTestRunner extends InstrumentationTestRunner {
-
- // Default recorder settings
- public static int mVideoDuration = 20000; // set default to 20 seconds
- public static int mVideoIterations = 1; // set default to 1 video
- public static int mImageIterations = 10; // set default to 10 images
-
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(ImageCapture.class);
- suite.addTestSuite(VideoCapture.class);
- return suite;
- }
-
- @Override
- public ClassLoader getLoader() {
- return CameraStressTestRunner.class.getClassLoader();
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- String video_iterations = (String) icicle.get("video_iterations");
- String image_iterations = (String) icicle.get("image_iterations");
- String video_duration = (String) icicle.get("video_duration");
-
- if ( video_iterations != null ) {
- mVideoIterations = Integer.parseInt(video_iterations);
- }
- if ( image_iterations != null) {
- mImageIterations = Integer.parseInt(image_iterations);
- }
- if ( video_duration != null) {
- mVideoDuration = Integer.parseInt(video_duration);
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/stress/ImageCapture.java b/tests/src/com/android/gallery3d/stress/ImageCapture.java
deleted file mode 100755
index e322eb5..0000000
--- a/tests/src/com/android/gallery3d/stress/ImageCapture.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2009 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.stress;
-
-import com.android.camera.CameraActivity;
-import com.android.gallery3d.stress.CameraStressTestRunner;
-
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.app.Activity;
-
-/**
- * Junit / Instrumentation test case for camera test
- *
- * Running the test suite:
- *
- * adb shell am instrument \
- * -e class com.android.camera.stress.ImageCapture \
- * -w com.google.android.camera.tests/android.test.InstrumentationTestRunner
- *
- */
-
-public class ImageCapture extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private String TAG = "ImageCapture";
- private static final long WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN = 1500; //1.5 sedconds
- private static final long WAIT_FOR_SWITCH_CAMERA = 3000; //3 seconds
-
- private TestUtil testUtil = new TestUtil();
-
- // Private intent extras.
- private final static String EXTRAS_CAMERA_FACING =
- "android.intent.extras.CAMERA_FACING";
-
- public ImageCapture() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- testUtil.prepareOutputFile();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- testUtil.closeOutputFile();
- super.tearDown();
- }
-
- public void captureImages(String reportTag, Instrumentation inst) {
- int total_num_of_images = CameraStressTestRunner.mImageIterations;
- Log.v(TAG, "no of images = " + total_num_of_images);
-
- //TODO(yslau): Need to integrate the outoput with the central dashboard,
- //write to a txt file as a temp solution
- boolean memoryResult = false;
- KeyEvent focusEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_FOCUS);
-
- try {
- testUtil.writeReportHeader(reportTag, total_num_of_images);
- for (int i = 0; i < total_num_of_images; i++) {
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- inst.sendKeySync(focusEvent);
- inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- testUtil.writeResult(i);
- }
- } catch (Exception e) {
- Log.v(TAG, "Got exception: " + e.toString());
- assertTrue("testImageCapture", false);
- }
- }
-
- @LargeTest
- public void testBackImageCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
- Intent intent = new Intent();
-
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(EXTRAS_CAMERA_FACING,
- android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
- Activity act = inst.startActivitySync(intent);
- Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
- captureImages("Back Camera Image Capture\n", inst);
- act.finish();
- }
-
- @LargeTest
- public void testFrontImageCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
- Intent intent = new Intent();
-
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(EXTRAS_CAMERA_FACING,
- android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
- Activity act = inst.startActivitySync(intent);
- Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
- captureImages("Front Camera Image Capture\n", inst);
- act.finish();
- }
-}
diff --git a/tests/src/com/android/gallery3d/stress/ShotToShotLatency.java b/tests/src/com/android/gallery3d/stress/ShotToShotLatency.java
deleted file mode 100644
index a27bd90..0000000
--- a/tests/src/com/android/gallery3d/stress/ShotToShotLatency.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.stress;
-
-import android.app.Instrumentation;
-import android.os.Environment;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-import com.android.camera.CameraActivity;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-
-/**
- * Junit / Instrumentation test case for measuring camera shot to shot latency
- */
-public class ShotToShotLatency extends ActivityInstrumentationTestCase2<CameraActivity> {
- private String TAG = "ShotToShotLatency";
- private static final int TOTAL_NUMBER_OF_SNAPSHOTS = 250;
- private static final long SNAPSHOT_WAIT = 1000;
- private static final String CAMERA_TEST_OUTPUT_FILE =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- private static final String CAMERA_IMAGE_DIRECTORY =
- Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera/";
-
- public ShotToShotLatency() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- getActivity();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- private void cleanupLatencyImages() {
- try {
- File sdcard = new File(CAMERA_IMAGE_DIRECTORY);
- File[] pics = null;
- FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jpg");
- }
- };
- pics = sdcard.listFiles(filter);
- for (File f : pics) {
- f.delete();
- }
- } catch (SecurityException e) {
- Log.e(TAG, "Security manager access violation: " + e.toString());
- }
- }
-
- private void sleep(long time) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
- Log.e(TAG, "Sleep InterruptedException " + e.toString());
- }
- }
-
- @LargeTest
- public void testShotToShotLatency() {
- long sigmaOfDiffFromMeanSquared = 0;
- double mean = 0;
- double standardDeviation = 0;
- ArrayList<Long> captureTimes = new ArrayList<Long>();
- ArrayList<Long> latencyTimes = new ArrayList<Long>();
-
- Log.v(TAG, "start testShotToShotLatency test");
- Instrumentation inst = getInstrumentation();
-
- // Generate data points
- for (int i = 0; i < TOTAL_NUMBER_OF_SNAPSHOTS; i++) {
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
- sleep(SNAPSHOT_WAIT);
- CameraActivity c = getActivity();
- if (c.getCaptureStartTime() > 0) {
- captureTimes.add(c.getCaptureStartTime());
- }
- }
-
- // Calculate latencies
- for (int j = 1; j < captureTimes.size(); j++) {
- latencyTimes.add(captureTimes.get(j) - captureTimes.get(j - 1));
- }
-
- // Crunch numbers
- for (long dataPoint : latencyTimes) {
- mean += (double) dataPoint;
- }
- mean /= latencyTimes.size();
-
- for (long dataPoint : latencyTimes) {
- sigmaOfDiffFromMeanSquared += (dataPoint - mean) * (dataPoint - mean);
- }
- standardDeviation = Math.sqrt(sigmaOfDiffFromMeanSquared / latencyTimes.size());
-
- // Report statistics
- File outFile = new File(CAMERA_TEST_OUTPUT_FILE);
- BufferedWriter output = null;
- try {
- output = new BufferedWriter(new FileWriter(outFile, true));
- output.write("Shot to shot latency - mean: " + mean + "\n");
- output.write("Shot to shot latency - standard deviation: " + standardDeviation + "\n");
- cleanupLatencyImages();
- } catch (IOException e) {
- Log.e(TAG, "testShotToShotLatency IOException writing to log " + e.toString());
- } finally {
- try {
- if (output != null) {
- output.close();
- }
- } catch (IOException e) {
- Log.e(TAG, "Error closing file: " + e.toString());
- }
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/stress/SwitchPreview.java b/tests/src/com/android/gallery3d/stress/SwitchPreview.java
deleted file mode 100755
index 955d092..0000000
--- a/tests/src/com/android/gallery3d/stress/SwitchPreview.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2009 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.stress;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.provider.MediaStore;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.os.Environment;
-import android.util.Log;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-
-/**
- * Junit / Instrumentation test case for camera test
- *
- * Running the test suite:
- *
- * adb shell am instrument \
- * -e class com.android.camera.stress.SwitchPreview \
- * -w com.android.camera.tests/com.android.camera.stress.CameraStressTestRunner
- *
- */
-public class SwitchPreview extends ActivityInstrumentationTestCase2 <CameraActivity>{
- private String TAG = "SwitchPreview";
- private static final int TOTAL_NUMBER_OF_SWITCHING = 200;
- private static final long WAIT_FOR_PREVIEW = 4000;
-
- private static final String CAMERA_TEST_OUTPUT_FILE =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- private BufferedWriter mOut;
- private FileWriter mfstream;
-
- public SwitchPreview() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- getActivity();
- prepareOutputFile();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- getActivity().finish();
- closeOutputFile();
- super.tearDown();
- }
-
- private void prepareOutputFile(){
- try{
- mfstream = new FileWriter(CAMERA_TEST_OUTPUT_FILE, true);
- mOut = new BufferedWriter(mfstream);
- } catch (Exception e){
- assertTrue("Camera Switch Mode", false);
- }
- }
-
- private void closeOutputFile() {
- try {
- mOut.write("\n");
- mOut.close();
- mfstream.close();
- } catch (Exception e) {
- assertTrue("CameraSwitchMode close output", false);
- }
- }
-
- @LargeTest
- public void testSwitchMode() {
- //Switching the video and the video recorder mode
- Instrumentation inst = getInstrumentation();
- try{
- mOut.write("Camera Switch Mode:\n");
- mOut.write("No of loops :" + TOTAL_NUMBER_OF_SWITCHING + "\n");
- mOut.write("loop: ");
- for (int i=0; i< TOTAL_NUMBER_OF_SWITCHING; i++) {
- Thread.sleep(WAIT_FOR_PREVIEW);
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.setClass(getInstrumentation().getTargetContext(),
- CameraActivity.class);
- getActivity().startActivity(intent);
- Thread.sleep(WAIT_FOR_PREVIEW);
- intent = new Intent();
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.setClass(getInstrumentation().getTargetContext(),
- CameraActivity.class);
- getActivity().startActivity(intent);
- mOut.write(" ," + i);
- mOut.flush();
- }
- } catch (Exception e){
- Log.v(TAG, "Got exception", e);
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/stress/TestUtil.java b/tests/src/com/android/gallery3d/stress/TestUtil.java
deleted file mode 100644
index 56ab715..0000000
--- a/tests/src/com/android/gallery3d/stress/TestUtil.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 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.stress;
-
-import android.os.Environment;
-import java.io.FileWriter;
-import java.io.BufferedWriter;
-
-
-/**
- * Collection of utility functions used for the test.
- */
-public class TestUtil {
- public BufferedWriter mOut;
- public FileWriter mfstream;
-
- public TestUtil() {
- }
-
- public void prepareOutputFile() throws Exception {
- String camera_test_output_file =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- mfstream = new FileWriter(camera_test_output_file, true);
- mOut = new BufferedWriter(mfstream);
- }
-
- public void closeOutputFile() throws Exception {
- mOut.write("\n");
- mOut.close();
- mfstream.close();
- }
-
- public void writeReportHeader(String reportTag, int iteration) throws Exception {
- mOut.write(reportTag);
- mOut.write("No of loops :" + iteration + "\n");
- mOut.write("loop: ");
- }
-
- public void writeResult(int iteration) throws Exception {
- mOut.write(" ," + iteration);
- mOut.flush();
- }
-}
diff --git a/tests/src/com/android/gallery3d/stress/VideoCapture.java b/tests/src/com/android/gallery3d/stress/VideoCapture.java
deleted file mode 100755
index dbbd124..0000000
--- a/tests/src/com/android/gallery3d/stress/VideoCapture.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2010 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.stress;
-
-import com.android.camera.CameraActivity;
-import com.android.gallery3d.stress.TestUtil;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.provider.MediaStore;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.KeyEvent;
-
-import com.android.gallery3d.stress.CameraStressTestRunner;
-
-/**
- * Junit / Instrumentation test case for camera test
- *
- * Running the test suite:
- *
- * adb shell am instrument \
- * -e class com.android.camera.stress.VideoCapture \
- * -w com.google.android.camera.tests/android.test.InstrumentationTestRunner
- *
- */
-
-public class VideoCapture extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private static final long WAIT_FOR_PREVIEW = 1500; //1.5 seconds
- private static final long WAIT_FOR_SWITCH_CAMERA = 3000; //2 seconds
-
- // Private intent extras which control the camera facing.
- private final static String EXTRAS_CAMERA_FACING =
- "android.intent.extras.CAMERA_FACING";
-
- private TestUtil testUtil = new TestUtil();
-
- public VideoCapture() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- testUtil.prepareOutputFile();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- testUtil.closeOutputFile();
- super.tearDown();
- }
-
- @LargeTest
- public void captureVideos(String reportTag, Instrumentation inst) throws Exception{
- boolean memoryResult = false;
- int total_num_of_videos = CameraStressTestRunner.mVideoIterations;
- int video_duration = CameraStressTestRunner.mVideoDuration;
- testUtil.writeReportHeader(reportTag, total_num_of_videos);
-
- for (int i = 0; i < total_num_of_videos; i++) {
- Thread.sleep(WAIT_FOR_PREVIEW);
- // record a video
- inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(video_duration);
- inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- testUtil.writeResult(i);
- }
- }
-
- @LargeTest
- public void testBackVideoCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
-
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(EXTRAS_CAMERA_FACING,
- android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
- Activity act = inst.startActivitySync(intent);
- Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
- captureVideos("Back Camera Video Capture\n", inst);
- act.finish();
- }
-
- @LargeTest
- public void testFrontVideoCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
-
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(EXTRAS_CAMERA_FACING,
- android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
- Activity act = inst.startActivitySync(intent);
- Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
- captureVideos("Front Camera Video Capture\n", inst);
- act.finish();
- }
-}
diff --git a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java b/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
deleted file mode 100644
index 01f0350..0000000
--- a/tests/src/com/android/gallery3d/ui/GLCanvasStub.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2010 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.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.Rect;
-import android.graphics.RectF;
-
-import com.android.gallery3d.glrenderer.BasicTexture;
-import com.android.gallery3d.glrenderer.GLCanvas;
-import com.android.gallery3d.glrenderer.GLId;
-import com.android.gallery3d.glrenderer.GLPaint;
-import com.android.gallery3d.glrenderer.RawTexture;
-
-import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-
-import javax.microedition.khronos.opengles.GL11;
-
-public class GLCanvasStub implements GLCanvas {
- @Override
- public void setSize(int width, int height) {}
- @Override
- public void clearBuffer() {}
- @Override
- public void clearBuffer(float[] argb) {}
- public void setCurrentAnimationTimeMillis(long time) {}
- public long currentAnimationTimeMillis() {
- throw new UnsupportedOperationException();
- }
- @Override
- public void setAlpha(float alpha) {}
- @Override
- public float getAlpha() {
- throw new UnsupportedOperationException();
- }
- @Override
- public void multiplyAlpha(float alpha) {}
- @Override
- public void translate(float x, float y, float z) {}
- @Override
- public void translate(float x, float y) {}
- @Override
- public void scale(float sx, float sy, float sz) {}
- @Override
- public void rotate(float angle, float x, float y, float z) {}
- public boolean clipRect(int left, int top, int right, int bottom) {
- throw new UnsupportedOperationException();
- }
- @Override
- public void save() {
- throw new UnsupportedOperationException();
- }
- @Override
- public void save(int saveFlags) {
- throw new UnsupportedOperationException();
- }
- public void setBlendEnabled(boolean enabled) {}
- @Override
- public void restore() {}
- @Override
- public void drawLine(float x1, float y1, float x2, float y2, GLPaint paint) {}
- @Override
- public void drawRect(float x1, float y1, float x2, float y2, GLPaint paint) {}
- @Override
- public void fillRect(float x, float y, float width, float height, int color) {}
- @Override
- public void drawTexture(
- BasicTexture texture, int x, int y, int width, int height) {}
- @Override
- public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
- int uvBuffer, int indexBuffer, int indexCount) {}
- public void drawTexture(BasicTexture texture,
- int x, int y, int width, int height, float alpha) {}
- @Override
- public void drawTexture(BasicTexture texture, RectF source, RectF target) {}
- @Override
- public void drawTexture(BasicTexture texture, float[] mTextureTransform,
- int x, int y, int w, int h) {}
- public void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int w, int h) {}
- @Override
- public void drawMixed(BasicTexture from, int to,
- float ratio, int x, int y, int w, int h) {}
- public void drawMixed(BasicTexture from, BasicTexture to,
- float ratio, int x, int y, int width, int height, float alpha) {}
- public BasicTexture copyTexture(int x, int y, int width, int height) {
- throw new UnsupportedOperationException();
- }
- public GL11 getGLInstance() {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean unloadTexture(BasicTexture texture) {
- throw new UnsupportedOperationException();
- }
- @Override
- public void deleteBuffer(int bufferId) {
- throw new UnsupportedOperationException();
- }
- @Override
- public void deleteRecycledResources() {}
- @Override
- public void multiplyMatrix(float[] mMatrix, int offset) {}
- @Override
- public void dumpStatisticsAndClear() {}
- @Override
- public void beginRenderTarget(RawTexture texture) {}
- @Override
- public void endRenderTarget() {}
- @Override
- public void drawMixed(BasicTexture from, int toColor,
- float ratio, RectF src, RectF target) {}
-
- @Override
- public void setTextureParameters(BasicTexture texture) {
- }
- @Override
- public void initializeTextureSize(BasicTexture texture, int format, int type) {
- }
- @Override
- public void initializeTexture(BasicTexture texture, Bitmap bitmap) {
- }
- @Override
- public void texSubImage2D(BasicTexture texture, int xOffset, int yOffset, Bitmap bitmap,
- int format, int type) {
- }
- @Override
- public int uploadBuffer(ByteBuffer buffer) {
- return 0;
- }
- @Override
- public int uploadBuffer(FloatBuffer buffer) {
- return 0;
- }
- @Override
- public void recoverFromLightCycle() {
- }
- @Override
- public void getBounds(Rect bounds, int x, int y, int width, int height) {
- }
- @Override
- public GLId getGLId() {
- return null;
- }
-}
diff --git a/tests/src/com/android/gallery3d/ui/GLRootMock.java b/tests/src/com/android/gallery3d/ui/GLRootMock.java
deleted file mode 100644
index da78e14..0000000
--- a/tests/src/com/android/gallery3d/ui/GLRootMock.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2010 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.ui;
-
-import android.content.Context;
-import android.graphics.Matrix;
-import com.android.gallery3d.anim.CanvasAnimation;
-
-public class GLRootMock implements GLRoot {
- int mRequestRenderCalled;
- int mRequestLayoutContentPaneCalled;
-
- public void addOnGLIdleListener(OnGLIdleListener listener) {}
- public void registerLaunchedAnimation(CanvasAnimation animation) {}
- public void requestRenderForced() {
- mRequestRenderCalled++;
- }
- public void requestRender() {
- mRequestRenderCalled++;
- }
- public void requestLayoutContentPane() {
- mRequestLayoutContentPaneCalled++;
- }
- public boolean hasStencil() { return true; }
- public void lockRenderThread() {}
- public void unlockRenderThread() {}
- public void setContentPane(GLView content) {}
- public void setOrientationSource(OrientationSource source) {}
- public int getDisplayRotation() { return 0; }
- public int getCompensation() { return 0; }
- public Matrix getCompensationMatrix() { return null; }
- public void freeze() {}
- public void unfreeze() {}
- public void setLightsOutMode(boolean enabled) {}
- public Context getContext() { return null; }
-}
diff --git a/tests/src/com/android/gallery3d/ui/GLRootStub.java b/tests/src/com/android/gallery3d/ui/GLRootStub.java
deleted file mode 100644
index 25e7bca..0000000
--- a/tests/src/com/android/gallery3d/ui/GLRootStub.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010 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.ui;
-
-import android.content.Context;
-import android.graphics.Matrix;
-import com.android.gallery3d.anim.CanvasAnimation;
-
-public class GLRootStub implements GLRoot {
- public void addOnGLIdleListener(OnGLIdleListener listener) {}
- public void registerLaunchedAnimation(CanvasAnimation animation) {}
- public void requestRenderForced() {}
- public void requestRender() {}
- public void requestLayoutContentPane() {}
- public boolean hasStencil() { return true; }
- public void lockRenderThread() {}
- public void unlockRenderThread() {}
- public void setContentPane(GLView content) {}
- public void setOrientationSource(OrientationSource source) {}
- public int getDisplayRotation() { return 0; }
- public int getCompensation() { return 0; }
- public Matrix getCompensationMatrix() { return null; }
- public void freeze() {}
- public void unfreeze() {}
- public void setLightsOutMode(boolean enabled) {}
- public Context getContext() { return null; }
-}
diff --git a/tests/src/com/android/gallery3d/ui/GLViewMock.java b/tests/src/com/android/gallery3d/ui/GLViewMock.java
deleted file mode 100644
index 9b7488f..0000000
--- a/tests/src/com/android/gallery3d/ui/GLViewMock.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2010 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.ui;
-
-import com.android.gallery3d.glrenderer.GLCanvas;
-
-class GLViewMock extends GLView {
- // onAttachToRoot
- int mOnAttachCalled;
- GLRoot mRoot;
- // onDetachFromRoot
- int mOnDetachCalled;
- // onVisibilityChanged
- int mOnVisibilityChangedCalled;
- // onLayout
- int mOnLayoutCalled;
- boolean mOnLayoutChangeSize;
- // renderBackground
- int mRenderBackgroundCalled;
- // onMeasure
- int mOnMeasureCalled;
- int mOnMeasureWidthSpec;
- int mOnMeasureHeightSpec;
-
- @Override
- public void onAttachToRoot(GLRoot root) {
- mRoot = root;
- mOnAttachCalled++;
- super.onAttachToRoot(root);
- }
-
- @Override
- public void onDetachFromRoot() {
- mRoot = null;
- mOnDetachCalled++;
- super.onDetachFromRoot();
- }
-
- @Override
- protected void onVisibilityChanged(int visibility) {
- mOnVisibilityChangedCalled++;
- }
-
- @Override
- protected void onLayout(boolean changeSize, int left, int top,
- int right, int bottom) {
- mOnLayoutCalled++;
- mOnLayoutChangeSize = changeSize;
- // call children's layout.
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView item = getComponent(i);
- item.layout(left, top, right, bottom);
- }
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- mOnMeasureCalled++;
- mOnMeasureWidthSpec = widthSpec;
- mOnMeasureHeightSpec = heightSpec;
- // call children's measure.
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView item = getComponent(i);
- item.measure(widthSpec, heightSpec);
- }
- setMeasuredSize(widthSpec, heightSpec);
- }
-
- @Override
- protected void renderBackground(GLCanvas view) {
- mRenderBackgroundCalled++;
- }
-}
diff --git a/tests/src/com/android/gallery3d/ui/GLViewTest.java b/tests/src/com/android/gallery3d/ui/GLViewTest.java
deleted file mode 100644
index b17b254..0000000
--- a/tests/src/com/android/gallery3d/ui/GLViewTest.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright (C) 2010 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.ui;
-
-import android.graphics.Rect;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.view.MotionEvent;
-
-import junit.framework.TestCase;
-
-@SmallTest
-public class GLViewTest extends TestCase {
- @SuppressWarnings("unused")
- private static final String TAG = "GLViewTest";
-
- @SmallTest
- public void testVisibility() {
- GLViewMock a = new GLViewMock();
- assertEquals(GLView.VISIBLE, a.getVisibility());
- assertEquals(0, a.mOnVisibilityChangedCalled);
- a.setVisibility(GLView.INVISIBLE);
- assertEquals(GLView.INVISIBLE, a.getVisibility());
- assertEquals(1, a.mOnVisibilityChangedCalled);
- a.setVisibility(GLView.VISIBLE);
- assertEquals(GLView.VISIBLE, a.getVisibility());
- assertEquals(2, a.mOnVisibilityChangedCalled);
- }
-
- @SmallTest
- public void testComponents() {
- GLView view = new GLView();
- assertEquals(0, view.getComponentCount());
- try {
- view.getComponent(0);
- fail();
- } catch (IndexOutOfBoundsException ex) {
- // expected
- }
-
- GLView x = new GLView();
- GLView y = new GLView();
- view.addComponent(x);
- view.addComponent(y);
- assertEquals(2, view.getComponentCount());
- assertSame(x, view.getComponent(0));
- assertSame(y, view.getComponent(1));
- view.removeComponent(x);
- assertSame(y, view.getComponent(0));
- try {
- view.getComponent(1);
- fail();
- } catch (IndexOutOfBoundsException ex) {
- // expected
- }
- try {
- view.addComponent(y);
- fail();
- } catch (IllegalStateException ex) {
- // expected
- }
- view.addComponent(x);
- view.removeAllComponents();
- assertEquals(0, view.getComponentCount());
- }
-
- @SmallTest
- public void testBounds() {
- GLView view = new GLView();
-
- assertEquals(0, view.getWidth());
- assertEquals(0, view.getHeight());
-
- Rect b = view.bounds();
- assertEquals(0, b.left);
- assertEquals(0, b.top);
- assertEquals(0, b.right);
- assertEquals(0, b.bottom);
-
- view.layout(10, 20, 30, 100);
- assertEquals(20, view.getWidth());
- assertEquals(80, view.getHeight());
-
- b = view.bounds();
- assertEquals(10, b.left);
- assertEquals(20, b.top);
- assertEquals(30, b.right);
- assertEquals(100, b.bottom);
- }
-
- @SmallTest
- public void testParent() {
- GLView a = new GLView();
- GLView b = new GLView();
- assertNull(b.mParent);
- a.addComponent(b);
- assertSame(a, b.mParent);
- a.removeComponent(b);
- assertNull(b.mParent);
- }
-
- @SmallTest
- public void testRoot() {
- GLViewMock a = new GLViewMock();
- GLViewMock b = new GLViewMock();
- GLRoot r = new GLRootStub();
- GLRoot r2 = new GLRootStub();
- a.addComponent(b);
-
- // Attach to root r
- assertEquals(0, a.mOnAttachCalled);
- assertEquals(0, b.mOnAttachCalled);
- a.attachToRoot(r);
- assertEquals(1, a.mOnAttachCalled);
- assertEquals(1, b.mOnAttachCalled);
- assertSame(r, a.getGLRoot());
- assertSame(r, b.getGLRoot());
-
- // Detach from r
- assertEquals(0, a.mOnDetachCalled);
- assertEquals(0, b.mOnDetachCalled);
- a.detachFromRoot();
- assertEquals(1, a.mOnDetachCalled);
- assertEquals(1, b.mOnDetachCalled);
-
- // Attach to another root r2
- assertEquals(1, a.mOnAttachCalled);
- assertEquals(1, b.mOnAttachCalled);
- a.attachToRoot(r2);
- assertEquals(2, a.mOnAttachCalled);
- assertEquals(2, b.mOnAttachCalled);
- assertSame(r2, a.getGLRoot());
- assertSame(r2, b.getGLRoot());
-
- // Detach from r2
- assertEquals(1, a.mOnDetachCalled);
- assertEquals(1, b.mOnDetachCalled);
- a.detachFromRoot();
- assertEquals(2, a.mOnDetachCalled);
- assertEquals(2, b.mOnDetachCalled);
- }
-
- @SmallTest
- public void testRoot2() {
- GLView a = new GLViewMock();
- GLViewMock b = new GLViewMock();
- GLRoot r = new GLRootStub();
-
- a.attachToRoot(r);
-
- assertEquals(0, b.mOnAttachCalled);
- a.addComponent(b);
- assertEquals(1, b.mOnAttachCalled);
-
- assertEquals(0, b.mOnDetachCalled);
- a.removeComponent(b);
- assertEquals(1, b.mOnDetachCalled);
- }
-
- @SmallTest
- public void testInvalidate() {
- GLView a = new GLView();
- GLRootMock r = new GLRootMock();
- a.attachToRoot(r);
- assertEquals(0, r.mRequestRenderCalled);
- a.invalidate();
- assertEquals(1, r.mRequestRenderCalled);
- }
-
- @SmallTest
- public void testRequestLayout() {
- GLView a = new GLView();
- GLView b = new GLView();
- GLRootMock r = new GLRootMock();
- a.attachToRoot(r);
- a.addComponent(b);
- assertEquals(0, r.mRequestLayoutContentPaneCalled);
- b.requestLayout();
- assertEquals(1, r.mRequestLayoutContentPaneCalled);
- }
-
- @SmallTest
- public void testLayout() {
- GLViewMock a = new GLViewMock();
- GLViewMock b = new GLViewMock();
- GLViewMock c = new GLViewMock();
- GLRootMock r = new GLRootMock();
-
- a.attachToRoot(r);
- a.addComponent(b);
- a.addComponent(c);
-
- assertEquals(0, a.mOnLayoutCalled);
- a.layout(10, 20, 60, 100);
- assertEquals(1, a.mOnLayoutCalled);
- assertEquals(1, b.mOnLayoutCalled);
- assertEquals(1, c.mOnLayoutCalled);
- assertTrue(a.mOnLayoutChangeSize);
- assertTrue(b.mOnLayoutChangeSize);
- assertTrue(c.mOnLayoutChangeSize);
-
- // same size should not trigger onLayout
- a.layout(10, 20, 60, 100);
- assertEquals(1, a.mOnLayoutCalled);
-
- // unless someone requested it, but only those on the path
- // to the requester.
- assertEquals(0, r.mRequestLayoutContentPaneCalled);
- b.requestLayout();
- a.layout(10, 20, 60, 100);
- assertEquals(1, r.mRequestLayoutContentPaneCalled);
- assertEquals(2, a.mOnLayoutCalled);
- assertEquals(2, b.mOnLayoutCalled);
- assertEquals(1, c.mOnLayoutCalled);
- }
-
- @SmallTest
- public void testRender() {
- GLViewMock a = new GLViewMock();
- GLViewMock b = new GLViewMock();
-
- a.addComponent(b);
- GLCanvasStub canvas = new GLCanvasStub();
- assertEquals(0, a.mRenderBackgroundCalled);
- assertEquals(0, b.mRenderBackgroundCalled);
- a.render(canvas);
- assertEquals(1, a.mRenderBackgroundCalled);
- assertEquals(1, b.mRenderBackgroundCalled);
- }
-
- @SmallTest
- public void testMeasure() {
- GLViewMock a = new GLViewMock();
- GLViewMock b = new GLViewMock();
- GLViewMock c = new GLViewMock();
- GLRootMock r = new GLRootMock();
-
- a.addComponent(b);
- a.addComponent(c);
- a.attachToRoot(r);
-
- assertEquals(0, a.mOnMeasureCalled);
- a.measure(100, 200);
- assertEquals(1, a.mOnMeasureCalled);
- assertEquals(1, b.mOnMeasureCalled);
- assertEquals(100, a.mOnMeasureWidthSpec);
- assertEquals(200, a.mOnMeasureHeightSpec);
- assertEquals(100, b.mOnMeasureWidthSpec);
- assertEquals(200, b.mOnMeasureHeightSpec);
- assertEquals(100, a.getMeasuredWidth());
- assertEquals(200, b.getMeasuredHeight());
-
- // same spec should not trigger onMeasure
- a.measure(100, 200);
- assertEquals(1, a.mOnMeasureCalled);
-
- // unless someone requested it, but only those on the path
- // to the requester.
- b.requestLayout();
- a.measure(100, 200);
- assertEquals(2, a.mOnMeasureCalled);
- assertEquals(2, b.mOnMeasureCalled);
- assertEquals(1, c.mOnMeasureCalled);
- }
-
- class MyGLView extends GLView {
- private int mWidth;
- int mOnTouchCalled;
- int mOnTouchX;
- int mOnTouchY;
- int mOnTouchAction;
-
- public MyGLView(int width) {
- mWidth = width;
- }
-
- @Override
- protected void onLayout(boolean changeSize, int left, int top,
- int right, int bottom) {
- // layout children from left to right
- // call children's layout.
- int x = 0;
- for (int i = 0, n = getComponentCount(); i < n; ++i) {
- GLView item = getComponent(i);
- item.measure(0, 0);
- int w = item.getMeasuredWidth();
- int h = item.getMeasuredHeight();
- item.layout(x, 0, x + w, h);
- x += w;
- }
- }
-
- @Override
- protected void onMeasure(int widthSpec, int heightSpec) {
- setMeasuredSize(mWidth, 100);
- }
-
- @Override
- protected boolean onTouch(MotionEvent event) {
- mOnTouchCalled++;
- mOnTouchX = (int) event.getX();
- mOnTouchY = (int) event.getY();
- mOnTouchAction = event.getAction();
- return true;
- }
- }
-
- private MotionEvent NewMotionEvent(int action, int x, int y) {
- return MotionEvent.obtain(0, 0, action, x, y, 0);
- }
-
- @SmallTest
- public void testTouchEvent() {
- // We construct a tree with four nodes. Only the x coordinate is used:
- // A = [0..............................300)
- // B = [0......100)
- // C = [100......200)
- // D = [100..150)
-
- MyGLView a = new MyGLView(300);
- MyGLView b = new MyGLView(100);
- MyGLView c = new MyGLView(100);
- MyGLView d = new MyGLView(50);
- GLRoot r = new GLRootStub();
-
- a.addComponent(b);
- a.addComponent(c);
- c.addComponent(d);
- a.attachToRoot(r);
- a.layout(0, 0, 300, 100);
-
- int DOWN = MotionEvent.ACTION_DOWN;
- int UP = MotionEvent.ACTION_UP;
- int MOVE = MotionEvent.ACTION_MOVE;
- int CANCEL = MotionEvent.ACTION_CANCEL;
-
- // simple case
- assertEquals(0, a.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 250, 0));
- assertEquals(DOWN, a.mOnTouchAction);
- a.dispatchTouchEvent(NewMotionEvent(UP, 250, 0));
- assertEquals(UP, a.mOnTouchAction);
- assertEquals(2, a.mOnTouchCalled);
-
- // pass to a child, check the location is offseted.
- assertEquals(0, c.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 175, 0));
- a.dispatchTouchEvent(NewMotionEvent(UP, 175, 0));
- assertEquals(75, c.mOnTouchX);
- assertEquals(0, c.mOnTouchY);
- assertEquals(2, c.mOnTouchCalled);
- assertEquals(2, a.mOnTouchCalled);
-
- // motion target cancel event
- assertEquals(0, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 125, 0));
- assertEquals(1, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(MOVE, 250, 0));
- assertEquals(2, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(MOVE, 50, 0));
- assertEquals(3, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 175, 0));
- assertEquals(4, d.mOnTouchCalled);
- assertEquals(CANCEL, d.mOnTouchAction);
- assertEquals(3, c.mOnTouchCalled);
- assertEquals(DOWN, c.mOnTouchAction);
- a.dispatchTouchEvent(NewMotionEvent(UP, 175, 0));
-
- // motion target is removed
- assertEquals(4, d.mOnTouchCalled);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 125, 0));
- assertEquals(5, d.mOnTouchCalled);
- a.removeComponent(c);
- assertEquals(6, d.mOnTouchCalled);
- assertEquals(CANCEL, d.mOnTouchAction);
-
- // invisible component should not get events
- assertEquals(2, a.mOnTouchCalled);
- assertEquals(0, b.mOnTouchCalled);
- b.setVisibility(GLView.INVISIBLE);
- a.dispatchTouchEvent(NewMotionEvent(DOWN, 50, 0));
- assertEquals(3, a.mOnTouchCalled);
- assertEquals(0, b.mOnTouchCalled);
- }
-}
diff --git a/tests/src/com/android/gallery3d/ui/PointerInfo.java b/tests/src/com/android/gallery3d/ui/PointerInfo.java
deleted file mode 100644
index 6c78556..0000000
--- a/tests/src/com/android/gallery3d/ui/PointerInfo.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2010 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.ui;
-
-import java.nio.Buffer;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.CharBuffer;
-import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.LongBuffer;
-import java.nio.ShortBuffer;
-
-import javax.microedition.khronos.opengles.GL10;
-
-public class PointerInfo {
-
- /**
- * The number of coordinates per vertex. 1..4
- */
- public int mSize;
-
- /**
- * The type of each coordinate.
- */
- public int mType;
-
- /**
- * The byte offset between consecutive vertices. 0 means mSize *
- * sizeof(mType)
- */
- public int mStride;
- public Buffer mPointer;
- public ByteBuffer mTempByteBuffer;
-
- public PointerInfo(int size, int type, int stride, Buffer pointer) {
- mSize = size;
- mType = type;
- mStride = stride;
- mPointer = pointer;
- }
-
- private int getStride() {
- return mStride > 0 ? mStride : sizeof(mType) * mSize;
- }
-
- public void bindByteBuffer() {
- mTempByteBuffer = mPointer == null ? null : toByteBuffer(-1, mPointer);
- }
-
- public void unbindByteBuffer() {
- mTempByteBuffer = null;
- }
-
- private static int sizeof(int type) {
- switch (type) {
- case GL10.GL_UNSIGNED_BYTE:
- return 1;
- case GL10.GL_BYTE:
- return 1;
- case GL10.GL_SHORT:
- return 2;
- case GL10.GL_FIXED:
- return 4;
- case GL10.GL_FLOAT:
- return 4;
- default:
- return 0;
- }
- }
-
- private static ByteBuffer toByteBuffer(int byteCount, Buffer input) {
- ByteBuffer result = null;
- boolean convertWholeBuffer = (byteCount < 0);
- if (input instanceof ByteBuffer) {
- ByteBuffer input2 = (ByteBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = input2.limit() - position;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- for (int i = 0; i < byteCount; i++) {
- result.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof CharBuffer) {
- CharBuffer input2 = (CharBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 2;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- CharBuffer result2 = result.asCharBuffer();
- for (int i = 0; i < byteCount / 2; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof ShortBuffer) {
- ShortBuffer input2 = (ShortBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position)* 2;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- ShortBuffer result2 = result.asShortBuffer();
- for (int i = 0; i < byteCount / 2; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof IntBuffer) {
- IntBuffer input2 = (IntBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 4;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- IntBuffer result2 = result.asIntBuffer();
- for (int i = 0; i < byteCount / 4; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof FloatBuffer) {
- FloatBuffer input2 = (FloatBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 4;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- FloatBuffer result2 = result.asFloatBuffer();
- for (int i = 0; i < byteCount / 4; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof DoubleBuffer) {
- DoubleBuffer input2 = (DoubleBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 8;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- DoubleBuffer result2 = result.asDoubleBuffer();
- for (int i = 0; i < byteCount / 8; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else if (input instanceof LongBuffer) {
- LongBuffer input2 = (LongBuffer) input;
- int position = input2.position();
- if (convertWholeBuffer) {
- byteCount = (input2.limit() - position) * 8;
- }
- result = ByteBuffer.allocate(byteCount).order(input2.order());
- LongBuffer result2 = result.asLongBuffer();
- for (int i = 0; i < byteCount / 8; i++) {
- result2.put(input2.get());
- }
- input2.position(position);
- } else {
- throw new RuntimeException("Unimplemented Buffer subclass.");
- }
- result.rewind();
- // The OpenGL API will interpret the result in hardware byte order,
- // so we better do that as well:
- result.order(ByteOrder.nativeOrder());
- return result;
- }
-
- public void getArrayElement(int index, double[] result) {
- if (mTempByteBuffer == null) {
- throw new IllegalArgumentException("undefined pointer");
- }
- if (mStride < 0) {
- throw new IllegalArgumentException("invalid stride");
- }
-
- int stride = getStride();
- ByteBuffer byteBuffer = mTempByteBuffer;
- int size = mSize;
- int type = mType;
- int sizeofType = sizeof(type);
- int byteOffset = stride * index;
-
- for (int i = 0; i < size; i++) {
- switch (type) {
- case GL10.GL_BYTE:
- case GL10.GL_UNSIGNED_BYTE:
- result[i] = byteBuffer.get(byteOffset);
- break;
- case GL10.GL_SHORT:
- ShortBuffer shortBuffer = byteBuffer.asShortBuffer();
- result[i] = shortBuffer.get(byteOffset / 2);
- break;
- case GL10.GL_FIXED:
- IntBuffer intBuffer = byteBuffer.asIntBuffer();
- result[i] = intBuffer.get(byteOffset / 4);
- break;
- case GL10.GL_FLOAT:
- FloatBuffer floatBuffer = byteBuffer.asFloatBuffer();
- result[i] = floatBuffer.get(byteOffset / 4);
- break;
- default:
- throw new UnsupportedOperationException("unknown type");
- }
- byteOffset += sizeofType;
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/unittest/CameraUnitTest.java b/tests/src/com/android/gallery3d/unittest/CameraUnitTest.java
deleted file mode 100644
index b8fb05f..0000000
--- a/tests/src/com/android/gallery3d/unittest/CameraUnitTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2010 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.unittest;
-
-import com.android.camera.Util;
-
-import android.graphics.Matrix;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import junit.framework.TestCase;
-
-@SmallTest
-public class CameraUnitTest extends TestCase {
- public void testRoundOrientation() {
- int h = Util.ORIENTATION_HYSTERESIS;
- assertEquals(0, Util.roundOrientation(0, 0));
- assertEquals(0, Util.roundOrientation(359, 0));
- assertEquals(0, Util.roundOrientation(0 + 44 + h, 0));
- assertEquals(90, Util.roundOrientation(0 + 45 + h, 0));
- assertEquals(0, Util.roundOrientation(360 - 44 - h, 0));
- assertEquals(270, Util.roundOrientation(360 - 45 - h, 0));
-
- assertEquals(90, Util.roundOrientation(90, 90));
- assertEquals(90, Util.roundOrientation(90 + 44 + h, 90));
- assertEquals(180, Util.roundOrientation(90 + 45 + h, 90));
- assertEquals(90, Util.roundOrientation(90 - 44 - h, 90));
- assertEquals(0, Util.roundOrientation(90 - 45 - h, 90));
-
- assertEquals(180, Util.roundOrientation(180, 180));
- assertEquals(180, Util.roundOrientation(180 + 44 + h, 180));
- assertEquals(270, Util.roundOrientation(180 + 45 + h, 180));
- assertEquals(180, Util.roundOrientation(180 - 44 - h, 180));
- assertEquals(90, Util.roundOrientation(180 - 45 - h, 180));
-
- assertEquals(270, Util.roundOrientation(270, 270));
- assertEquals(270, Util.roundOrientation(270 + 44 + h, 270));
- assertEquals(0, Util.roundOrientation(270 + 45 + h, 270));
- assertEquals(270, Util.roundOrientation(270 - 44 - h, 270));
- assertEquals(180, Util.roundOrientation(270 - 45 - h, 270));
-
- assertEquals(90, Util.roundOrientation(90, 0));
- assertEquals(180, Util.roundOrientation(180, 0));
- assertEquals(270, Util.roundOrientation(270, 0));
-
- assertEquals(0, Util.roundOrientation(0, 90));
- assertEquals(180, Util.roundOrientation(180, 90));
- assertEquals(270, Util.roundOrientation(270, 90));
-
- assertEquals(0, Util.roundOrientation(0, 180));
- assertEquals(90, Util.roundOrientation(90, 180));
- assertEquals(270, Util.roundOrientation(270, 180));
-
- assertEquals(0, Util.roundOrientation(0, 270));
- assertEquals(90, Util.roundOrientation(90, 270));
- assertEquals(180, Util.roundOrientation(180, 270));
- }
-
- public void testPrepareMatrix() {
- Matrix matrix = new Matrix();
- float[] points;
- int[] expected;
-
- Util.prepareMatrix(matrix, false, 0, 800, 480);
- points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250};
- expected = new int[] {0, 0, 400, 240, 800, 480, 400, 480, 100, 300};
- matrix.mapPoints(points);
- assertEquals(expected, points);
-
- Util.prepareMatrix(matrix, false, 90, 800, 480);
- points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250};
- expected = new int[] {800, 0, 400, 240, 0, 480, 0, 240, 300, 60};
- matrix.mapPoints(points);
- assertEquals(expected, points);
-
- Util.prepareMatrix(matrix, false, 180, 800, 480);
- points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250};
- expected = new int[] {800, 480, 400, 240, 0, 0, 400, 0, 700, 180};
- matrix.mapPoints(points);
- assertEquals(expected, points);
-
- Util.prepareMatrix(matrix, true, 180, 800, 480);
- points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250};
- expected = new int[] {0, 480, 400, 240, 800, 0, 400, 0, 100, 180};
- matrix.mapPoints(points);
- assertEquals(expected, points);
- }
-
- private void assertEquals(int expected[], float[] actual) {
- for (int i = 0; i < expected.length; i++) {
- assertEquals("Array index " + i + " mismatch", expected[i], Math.round(actual[i]));
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/util/IntArrayTest.java b/tests/src/com/android/gallery3d/util/IntArrayTest.java
deleted file mode 100644
index 83e6050..0000000
--- a/tests/src/com/android/gallery3d/util/IntArrayTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 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.util;
-
-import com.android.gallery3d.util.IntArray;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-import java.util.Arrays;
-import junit.framework.TestCase;
-
-@SmallTest
-public class IntArrayTest extends TestCase {
- private static final String TAG = "IntArrayTest";
-
- public void testIntArray() {
- IntArray a = new IntArray();
- assertEquals(0, a.size());
- assertTrue(Arrays.equals(new int[] {}, a.toArray(null)));
-
- a.add(0);
- assertEquals(1, a.size());
- assertTrue(Arrays.equals(new int[] {0}, a.toArray(null)));
-
- a.add(1);
- assertEquals(2, a.size());
- assertTrue(Arrays.equals(new int[] {0, 1}, a.toArray(null)));
-
- int[] buf = new int[2];
- int[] result = a.toArray(buf);
- assertSame(buf, result);
-
- IntArray b = new IntArray();
- for (int i = 0; i < 100; i++) {
- b.add(i * i);
- }
-
- assertEquals(100, b.size());
- result = b.toArray(buf);
- assertEquals(100, result.length);
- for (int i = 0; i < 100; i++) {
- assertEquals(i * i, result[i]);
- }
- }
-}
diff --git a/tests/src/com/android/gallery3d/util/ProfileTest.java b/tests/src/com/android/gallery3d/util/ProfileTest.java
deleted file mode 100644
index 798b905..0000000
--- a/tests/src/com/android/gallery3d/util/ProfileTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.gallery3d.util;
-
-import com.android.gallery3d.util.Profile;
-
-import android.os.Environment;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-@SmallTest
-public class ProfileTest extends TestCase {
- private static final String TAG = "ProfileTest";
- private static final String TEST_FILE =
- Environment.getExternalStorageDirectory().getPath() + "/test.dat";
-
-
- public void testProfile() throws IOException {
- ProfileData p = new ProfileData();
- ParsedProfile q;
- String[] A = {"A"};
- String[] B = {"B"};
- String[] AC = {"A", "C"};
- String[] AD = {"A", "D"};
-
- // Empty profile
- p.dumpToFile(TEST_FILE);
- q = new ParsedProfile(TEST_FILE);
- assertTrue(q.mEntries.isEmpty());
- assertTrue(q.mSymbols.isEmpty());
-
- // Only one sample
- p.addSample(A);
- p.dumpToFile(TEST_FILE);
- q = new ParsedProfile(TEST_FILE);
- assertEquals(1, q.mEntries.size());
- assertEquals(1, q.mSymbols.size());
- assertEquals(1, q.mEntries.get(0).sampleCount);
-
- // Two samples at the same place
- p.addSample(A);
- p.dumpToFile(TEST_FILE);
- q = new ParsedProfile(TEST_FILE);
- assertEquals(1, q.mEntries.size());
- assertEquals(1, q.mSymbols.size());
- assertEquals(2, q.mEntries.get(0).sampleCount);
-
- // Two samples at the different places
- p.reset();
- p.addSample(A);
- p.addSample(B);
- p.dumpToFile(TEST_FILE);
- q = new ParsedProfile(TEST_FILE);
- assertEquals(2, q.mEntries.size());
- assertEquals(2, q.mSymbols.size());
- assertEquals(1, q.mEntries.get(0).sampleCount);
- assertEquals(1, q.mEntries.get(1).sampleCount);
-
- // depth > 1
- p.reset();
- p.addSample(AC);
- p.dumpToFile(TEST_FILE);
- q = new ParsedProfile(TEST_FILE);
- assertEquals(1, q.mEntries.size());
- assertEquals(2, q.mSymbols.size());
- assertEquals(1, q.mEntries.get(0).sampleCount);
-
- // two samples (AC and AD)
- p.addSample(AD);
- p.dumpToFile(TEST_FILE);
- q = new ParsedProfile(TEST_FILE);
- assertEquals(2, q.mEntries.size());
- assertEquals(3, q.mSymbols.size()); // three symbols: A, C, D
- assertEquals(1, q.mEntries.get(0).sampleCount);
- assertEquals(1, q.mEntries.get(0).sampleCount);
-
- // Remove the test file
- new File(TEST_FILE).delete();
- }
-}
-
-class ParsedProfile {
- public class Entry {
- int sampleCount;
- int stackId[];
- }
-
- ArrayList<Entry> mEntries = new ArrayList<Entry>();
- HashMap<Integer, String> mSymbols = new HashMap<Integer, String>();
- private DataInputStream mIn;
- private byte[] mScratch = new byte[4]; // scratch buffer for readInt
-
- public ParsedProfile(String filename) throws IOException {
- mIn = new DataInputStream(new FileInputStream(filename));
-
- Entry entry = parseOneEntry();
- checkIsFirstEntry(entry);
-
- while (true) {
- entry = parseOneEntry();
- if (entry.sampleCount == 0) {
- checkIsLastEntry(entry);
- break;
- }
- mEntries.add(entry);
- }
-
- // Read symbol table
- while (true) {
- String line = mIn.readLine();
- if (line == null) break;
- String[] fields = line.split(" +");
- checkIsValidSymbolLine(fields);
- mSymbols.put(Integer.decode(fields[0]), fields[1]);
- }
- }
-
- private void checkIsFirstEntry(Entry entry) {
- Assert.assertEquals(0, entry.sampleCount);
- Assert.assertEquals(3, entry.stackId.length);
- Assert.assertEquals(1, entry.stackId[0]);
- Assert.assertTrue(entry.stackId[1] > 0); // sampling period
- Assert.assertEquals(0, entry.stackId[2]); // padding
- }
-
- private void checkIsLastEntry(Entry entry) {
- Assert.assertEquals(0, entry.sampleCount);
- Assert.assertEquals(1, entry.stackId.length);
- Assert.assertEquals(0, entry.stackId[0]);
- }
-
- private void checkIsValidSymbolLine(String[] fields) {
- Assert.assertEquals(2, fields.length);
- Assert.assertTrue(fields[0].startsWith("0x"));
- }
-
- private Entry parseOneEntry() throws IOException {
- int sampleCount = readInt();
- int depth = readInt();
- Entry e = new Entry();
- e.sampleCount = sampleCount;
- e.stackId = new int[depth];
- for (int i = 0; i < depth; i++) {
- e.stackId[i] = readInt();
- }
- return e;
- }
-
- private int readInt() throws IOException {
- mIn.read(mScratch, 0, 4);
- return (mScratch[0] & 0xff) |
- ((mScratch[1] & 0xff) << 8) |
- ((mScratch[2] & 0xff) << 16) |
- ((mScratch[3] & 0xff) << 24);
- }
-}
diff --git a/tests/src/com/android/photos/data/DataTestRunner.java b/tests/src/com/android/photos/data/DataTestRunner.java
deleted file mode 100644
index 10618d6..0000000
--- a/tests/src/com/android/photos/data/DataTestRunner.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-
-import com.android.photos.data.TestHelper.TestInitialization;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class DataTestRunner extends InstrumentationTestRunner {
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(PhotoDatabaseTest.class);
- suite.addTestSuite(PhotoProviderTest.class);
- TestHelper.addTests(MediaCacheTest.class, suite, new TestInitialization() {
- @Override
- public void initialize(TestCase testCase) {
- MediaCacheTest test = (MediaCacheTest) testCase;
- test.setLocalContext(getContext());
- }
- });
- return suite;
- }
-
- @Override
- public ClassLoader getLoader() {
- return DataTestRunner.class.getClassLoader();
- }
-}
diff --git a/tests/src/com/android/photos/data/MediaCacheTest.java b/tests/src/com/android/photos/data/MediaCacheTest.java
deleted file mode 100644
index 9e71128..0000000
--- a/tests/src/com/android/photos/data/MediaCacheTest.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.Environment;
-import android.os.SystemClock;
-import android.test.ProviderTestCase2;
-
-import com.android.gallery3d.tests.R;
-import com.android.photos.data.MediaCache.ImageReady;
-import com.android.photos.data.MediaCache.OriginalReady;
-import com.android.photos.data.MediaRetriever.MediaSize;
-import com.android.photos.data.PhotoProvider.Photos;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class MediaCacheTest extends ProviderTestCase2<PhotoProvider> {
- @SuppressWarnings("unused")
- private static final String TAG = MediaCacheTest.class.getSimpleName();
-
- private File mDir;
- private File mImage;
- private File mCacheDir;
- private Resources mResources;
- private MediaCache mMediaCache;
- private ReadyCollector mReady;
-
- public static final long MAX_WAIT = 2000;
-
- private static class ReadyCollector implements ImageReady, OriginalReady {
- public File mOriginalFile;
- public InputStream mInputStream;
-
- @Override
- public synchronized void originalReady(File originalFile) {
- mOriginalFile = originalFile;
- notifyAll();
- }
-
- @Override
- public synchronized void imageReady(InputStream bitmapInputStream) {
- mInputStream = bitmapInputStream;
- notifyAll();
- }
-
- public synchronized boolean waitForNotification() {
- long endWait = SystemClock.uptimeMillis() + MAX_WAIT;
-
- try {
- while (mInputStream == null && mOriginalFile == null
- && SystemClock.uptimeMillis() < endWait) {
- wait(endWait - SystemClock.uptimeMillis());
- }
- } catch (InterruptedException e) {
- }
- return mInputStream != null || mOriginalFile != null;
- }
- }
-
- private static class DummyMediaRetriever implements MediaRetriever {
- private boolean mNullUri = false;
- @Override
- public File getLocalFile(Uri contentUri) {
- return null;
- }
-
- @Override
- public MediaSize getFastImageSize(Uri contentUri, MediaSize size) {
- return null;
- }
-
- @Override
- public byte[] getTemporaryImage(Uri contentUri, MediaSize temporarySize) {
- return null;
- }
-
- @Override
- public boolean getMedia(Uri contentUri, MediaSize imageSize, File tempFile) {
- return false;
- }
-
- @Override
- public Uri normalizeUri(Uri contentUri, MediaSize size) {
- if (mNullUri) {
- return null;
- } else {
- return contentUri;
- }
- }
-
- @Override
- public MediaSize normalizeMediaSize(Uri contentUri, MediaSize size) {
- return size;
- }
-
- public void setNullUri() {
- mNullUri = true;
- }
- };
-
- public MediaCacheTest() {
- super(PhotoProvider.class, PhotoProvider.AUTHORITY);
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
-
- mReady = new ReadyCollector();
- File externalDir = Environment.getExternalStorageDirectory();
- mDir = new File(externalDir, "test");
- mDir.mkdirs();
- mCacheDir = new File(externalDir, "test_cache");
- mImage = new File(mDir, "original.jpg");
- MediaCache.initialize(getMockContext());
- MediaCache.getInstance().setCacheDir(mCacheDir);
- mMediaCache = MediaCache.getInstance();
- mMediaCache.addRetriever("file", "", new FileRetriever());
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- mMediaCache.clearCacheDir();
- MediaCache.shutdown();
- mMediaCache = null;
- mImage.delete();
- mDir.delete();
- mCacheDir.delete();
- }
-
- public void setLocalContext(Context context) {
- mResources = context.getResources();
- }
-
- public void testRetrieveOriginal() throws IOException {
- copyResourceToFile(R.raw.galaxy_nexus, mImage.getPath());
- Uri uri = Uri.fromFile(mImage);
- mMediaCache.retrieveOriginal(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- assertNull(mReady.mInputStream);
- assertEquals(mImage, mReady.mOriginalFile);
- }
-
- public void testRetrievePreview() throws IOException {
- copyResourceToFile(R.raw.galaxy_nexus, mImage.getPath());
- Uri uri = Uri.fromFile(mImage);
- mMediaCache.retrievePreview(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- assertNotNull(mReady.mInputStream);
- assertNull(mReady.mOriginalFile);
- Bitmap bitmap = BitmapFactory.decodeStream(mReady.mInputStream);
- mReady.mInputStream.close();
- assertNotNull(bitmap);
- Bitmap original = BitmapFactory.decodeFile(mImage.getPath());
- assertTrue(bitmap.getWidth() < original.getWidth());
- assertTrue(bitmap.getHeight() < original.getHeight());
- int maxDimension = Math.max(bitmap.getWidth(), bitmap.getHeight());
- int targetSize = MediaCacheUtils.getTargetSize(MediaSize.Preview);
- assertTrue(maxDimension >= targetSize);
- assertTrue(maxDimension < (targetSize * 2));
- }
-
- public void testRetrieveExifThumb() throws IOException {
- copyResourceToFile(R.raw.galaxy_nexus, mImage.getPath());
- Uri uri = Uri.fromFile(mImage);
- ReadyCollector done = new ReadyCollector();
- mMediaCache.retrieveThumbnail(uri, done, mReady);
- assertTrue(mReady.waitForNotification());
- assertNotNull(mReady.mInputStream);
- assertNull(mReady.mOriginalFile);
- Bitmap bitmap = BitmapFactory.decodeStream(mReady.mInputStream);
- mReady.mInputStream.close();
- assertTrue(done.waitForNotification());
- assertNotNull(done.mInputStream);
- done.mInputStream.close();
- assertNotNull(bitmap);
- assertEquals(320, bitmap.getWidth());
- assertEquals(240, bitmap.getHeight());
- }
-
- public void testRetrieveThumb() throws IOException {
- copyResourceToFile(R.raw.galaxy_nexus, mImage.getPath());
- Uri uri = Uri.fromFile(mImage);
- long downsampleStart = SystemClock.uptimeMillis();
- mMediaCache.retrieveThumbnail(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- long downsampleEnd = SystemClock.uptimeMillis();
- assertNotNull(mReady.mInputStream);
- assertNull(mReady.mOriginalFile);
- Bitmap bitmap = BitmapFactory.decodeStream(mReady.mInputStream);
- mReady.mInputStream.close();
- assertNotNull(bitmap);
- Bitmap original = BitmapFactory.decodeFile(mImage.getPath());
- assertTrue(bitmap.getWidth() < original.getWidth());
- assertTrue(bitmap.getHeight() < original.getHeight());
- int maxDimension = Math.max(bitmap.getWidth(), bitmap.getHeight());
- int targetSize = MediaCacheUtils.getTargetSize(MediaSize.Thumbnail);
- assertTrue(maxDimension >= targetSize);
- assertTrue(maxDimension < (targetSize * 2));
-
- // Retrieve cached thumb.
- mReady = new ReadyCollector();
- long start = SystemClock.uptimeMillis();
- mMediaCache.retrieveThumbnail(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- mReady.mInputStream.close();
- long end = SystemClock.uptimeMillis();
- // Already cached. Wait shorter time.
- assertTrue((end - start) < (downsampleEnd - downsampleStart) / 2);
- }
-
- public void testGetVideo() throws IOException {
- mImage = new File(mDir, "original.mp4");
- copyResourceToFile(R.raw.android_lawn, mImage.getPath());
- Uri uri = Uri.fromFile(mImage);
-
- mMediaCache.retrieveOriginal(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- assertNull(mReady.mInputStream);
- assertNotNull(mReady.mOriginalFile);
-
- mReady = new ReadyCollector();
- mMediaCache.retrievePreview(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- assertNotNull(mReady.mInputStream);
- assertNull(mReady.mOriginalFile);
- Bitmap bitmap = BitmapFactory.decodeStream(mReady.mInputStream);
- mReady.mInputStream.close();
- int maxDimension = Math.max(bitmap.getWidth(), bitmap.getHeight());
- int targetSize = MediaCacheUtils.getTargetSize(MediaSize.Preview);
- assertTrue(maxDimension >= targetSize);
- assertTrue(maxDimension < (targetSize * 2));
-
- mReady = new ReadyCollector();
- mMediaCache.retrieveThumbnail(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- assertNotNull(mReady.mInputStream);
- assertNull(mReady.mOriginalFile);
- bitmap = BitmapFactory.decodeStream(mReady.mInputStream);
- mReady.mInputStream.close();
- maxDimension = Math.max(bitmap.getWidth(), bitmap.getHeight());
- targetSize = MediaCacheUtils.getTargetSize(MediaSize.Thumbnail);
- assertTrue(maxDimension >= targetSize);
- assertTrue(maxDimension < (targetSize * 2));
- }
-
- public void testFastImage() throws IOException {
- copyResourceToFile(R.raw.galaxy_nexus, mImage.getPath());
- Uri uri = Uri.fromFile(mImage);
- mMediaCache.retrieveThumbnail(uri, mReady, null);
- mReady.waitForNotification();
- mReady.mInputStream.close();
-
- mMediaCache.retrieveOriginal(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- assertNotNull(mReady.mInputStream);
- mReady.mInputStream.close();
- }
-
- public void testBadRetriever() {
- Uri uri = Photos.CONTENT_URI;
- try {
- mMediaCache.retrieveOriginal(uri, mReady, null);
- fail("Expected exception");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testInsertIntoCache() throws IOException {
- // FileRetriever inserts into the cache opportunistically with Videos
- mImage = new File(mDir, "original.mp4");
- copyResourceToFile(R.raw.android_lawn, mImage.getPath());
- Uri uri = Uri.fromFile(mImage);
-
- mMediaCache.retrieveThumbnail(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- mReady.mInputStream.close();
- assertNotNull(mMediaCache.getCachedFile(uri, MediaSize.Preview));
- }
-
- public void testBadNormalizedUri() {
- DummyMediaRetriever retriever = new DummyMediaRetriever();
- Uri uri = Uri.fromParts("http", "world", "morestuff");
- mMediaCache.addRetriever(uri.getScheme(), uri.getAuthority(), retriever);
- retriever.setNullUri();
- try {
- mMediaCache.retrieveOriginal(uri, mReady, null);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testClearOldCache() throws IOException {
- copyResourceToFile(R.raw.galaxy_nexus, mImage.getPath());
- Uri uri = Uri.fromFile(mImage);
- mMediaCache.retrievePreview(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- mReady.mInputStream.close();
- mMediaCache.setMaxCacheSize(mMediaCache.getCachedFile(uri, MediaSize.Preview).length());
- assertNotNull(mMediaCache.getCachedFile(uri, MediaSize.Preview));
-
- mReady = new ReadyCollector();
- // This should kick the preview image out of the cache.
- mMediaCache.retrieveThumbnail(uri, mReady, null);
- assertTrue(mReady.waitForNotification());
- mReady.mInputStream.close();
- assertNull(mMediaCache.getCachedFile(uri, MediaSize.Preview));
- assertNotNull(mMediaCache.getCachedFile(uri, MediaSize.Thumbnail));
- }
-
- public void testClearLargeInCache() throws IOException {
- copyResourceToFile(R.raw.galaxy_nexus, mImage.getPath());
- Uri imageUri = Uri.fromFile(mImage);
- mMediaCache.retrieveThumbnail(imageUri, mReady, null);
- assertTrue(mReady.waitForNotification());
- mReady.mInputStream.close();
- assertNotNull(mMediaCache.getCachedFile(imageUri, MediaSize.Thumbnail));
- long thumbSize = mMediaCache.getCachedFile(imageUri, MediaSize.Thumbnail).length();
- mMediaCache.setMaxCacheSize(thumbSize * 10);
-
- for (int i = 0; i < 9; i++) {
- File tempImage = new File(mDir, "image" + i + ".jpg");
- mImage.renameTo(tempImage);
- Uri tempImageUri = Uri.fromFile(tempImage);
- mReady = new ReadyCollector();
- mMediaCache.retrieveThumbnail(tempImageUri, mReady, null);
- assertTrue(mReady.waitForNotification());
- mReady.mInputStream.close();
- tempImage.renameTo(mImage);
- }
- assertNotNull(mMediaCache.getCachedFile(imageUri, MediaSize.Thumbnail));
-
- for (int i = 0; i < 9; i++) {
- File tempImage = new File(mDir, "image" + i + ".jpg");
- mImage.renameTo(tempImage);
- Uri tempImageUri = Uri.fromFile(tempImage);
- mReady = new ReadyCollector();
- mMediaCache.retrievePreview(tempImageUri, mReady, null);
- assertTrue(mReady.waitForNotification());
- mReady.mInputStream.close();
- tempImage.renameTo(mImage);
- }
- assertNotNull(mMediaCache.getCachedFile(imageUri, MediaSize.Thumbnail));
- Uri oldestUri = Uri.fromFile(new File(mDir, "image0.jpg"));
- assertNull(mMediaCache.getCachedFile(oldestUri, MediaSize.Thumbnail));
- }
-
- private void copyResourceToFile(int resourceId, String path) throws IOException {
- File outputDir = new File(path).getParentFile();
- outputDir.mkdirs();
-
- InputStream in = mResources.openRawResource(resourceId);
- FileOutputStream out = new FileOutputStream(path);
- byte[] buffer = new byte[1000];
- int bytesRead;
-
- while ((bytesRead = in.read(buffer)) >= 0) {
- out.write(buffer, 0, bytesRead);
- }
-
- in.close();
- out.close();
- }
-}
diff --git a/tests/src/com/android/photos/data/PhotoDatabaseTest.java b/tests/src/com/android/photos/data/PhotoDatabaseTest.java
deleted file mode 100644
index e7c1689..0000000
--- a/tests/src/com/android/photos/data/PhotoDatabaseTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.database.DatabaseUtils;
-import android.database.sqlite.SQLiteDatabase;
-import android.test.InstrumentationTestCase;
-
-import com.android.photos.data.PhotoProvider.Accounts;
-import com.android.photos.data.PhotoProvider.Albums;
-import com.android.photos.data.PhotoProvider.Metadata;
-import com.android.photos.data.PhotoProvider.Photos;
-
-import java.io.File;
-import java.io.IOException;
-
-public class PhotoDatabaseTest extends InstrumentationTestCase {
-
- private PhotoDatabase mDBHelper;
- private static final String DB_NAME = "dummy.db";
- private static final long PARENT_ID1 = 100;
- private static final long PARENT_ID2 = 101;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Context context = getInstrumentation().getTargetContext();
- context.deleteDatabase(DB_NAME);
- mDBHelper = new PhotoDatabase(context, DB_NAME);
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDBHelper.close();
- mDBHelper = null;
- Context context = getInstrumentation().getTargetContext();
- context.deleteDatabase(DB_NAME);
- super.tearDown();
- }
-
- public void testCreateDatabase() throws IOException {
- Context context = getInstrumentation().getTargetContext();
- File dbFile = context.getDatabasePath(DB_NAME);
- SQLiteDatabase db = getReadableDB();
- db.beginTransaction();
- db.endTransaction();
- assertTrue(dbFile.exists());
- }
-
- public void testTables() {
- validateTable(Metadata.TABLE, PhotoDatabaseUtils.PROJECTION_METADATA);
- validateTable(Albums.TABLE, PhotoDatabaseUtils.PROJECTION_ALBUMS);
- validateTable(Photos.TABLE, PhotoDatabaseUtils.PROJECTION_PHOTOS);
- }
-
- public void testAlbumsConstraints() {
- SQLiteDatabase db = getWritableDB();
- db.beginTransaction();
- try {
- long accountId = 100;
- // Test NOT NULL constraint on name
- assertFalse(PhotoDatabaseUtils.insertAlbum(db, null, null, Albums.VISIBILITY_PRIVATE,
- accountId));
-
- // test NOT NULL constraint on privacy
- assertFalse(PhotoDatabaseUtils.insertAlbum(db, null, "hello", null, accountId));
-
- // test NOT NULL constraint on account_id
- assertFalse(PhotoDatabaseUtils.insertAlbum(db, null, "hello",
- Albums.VISIBILITY_PRIVATE, null));
-
- // Normal insert
- assertTrue(PhotoDatabaseUtils.insertAlbum(db, PARENT_ID1, "hello",
- Albums.VISIBILITY_PRIVATE, accountId));
-
- long albumId = PhotoDatabaseUtils.queryAlbumIdFromParentId(db, PARENT_ID1);
-
- // Assign a valid child
- assertTrue(PhotoDatabaseUtils.insertAlbum(db, PARENT_ID2, "hello",
- Albums.VISIBILITY_PRIVATE, accountId));
-
- long otherAlbumId = PhotoDatabaseUtils.queryAlbumIdFromParentId(db, PARENT_ID2);
- assertNotSame(albumId, otherAlbumId);
-
- // This is a valid child of another album.
- assertTrue(PhotoDatabaseUtils.insertAlbum(db, otherAlbumId, "hello",
- Albums.VISIBILITY_PRIVATE, accountId));
-
- // This isn't allowed due to uniqueness constraint (parent_id/name)
- assertFalse(PhotoDatabaseUtils.insertAlbum(db, otherAlbumId, "hello",
- Albums.VISIBILITY_PRIVATE, accountId));
- } finally {
- db.endTransaction();
- }
- }
-
- public void testPhotosConstraints() {
- SQLiteDatabase db = getWritableDB();
- db.beginTransaction();
- try {
- int width = 100;
- int height = 100;
- long dateTaken = System.currentTimeMillis();
- String mimeType = "test/test";
- long accountId = 100;
-
- // Test NOT NULL mime-type
- assertFalse(PhotoDatabaseUtils.insertPhoto(db, width, height, dateTaken, null, null,
- accountId));
-
- // Test NOT NULL width
- assertFalse(PhotoDatabaseUtils.insertPhoto(db, null, height, dateTaken, null, mimeType,
- accountId));
-
- // Test NOT NULL height
- assertFalse(PhotoDatabaseUtils.insertPhoto(db, width, null, dateTaken, null, mimeType,
- accountId));
-
- // Test NOT NULL dateTaken
- assertFalse(PhotoDatabaseUtils.insertPhoto(db, width, height, null, null, mimeType,
- accountId));
-
- // Test NOT NULL accountId
- assertFalse(PhotoDatabaseUtils.insertPhoto(db, width, height, dateTaken, null,
- mimeType, null));
-
- // Test normal insert
- assertTrue(PhotoDatabaseUtils.insertPhoto(db, width, height, dateTaken, null, mimeType,
- accountId));
- } finally {
- db.endTransaction();
- }
- }
-
- public void testMetadataConstraints() {
- SQLiteDatabase db = getWritableDB();
- db.beginTransaction();
- try {
- final String mimeType = "test/test";
- PhotoDatabaseUtils.insertPhoto(db, 100, 100, 100L, PARENT_ID1, mimeType, 100L);
- long photoId = PhotoDatabaseUtils.queryPhotoIdFromAlbumId(db, PARENT_ID1);
-
- // Test NOT NULL PHOTO_ID constraint.
- assertFalse(PhotoDatabaseUtils.insertMetadata(db, null, "foo", "bar"));
-
- // Normal insert.
- assertTrue(PhotoDatabaseUtils.insertMetadata(db, photoId, "foo", "bar"));
-
- // Test uniqueness constraint.
- assertFalse(PhotoDatabaseUtils.insertMetadata(db, photoId, "foo", "baz"));
- } finally {
- db.endTransaction();
- }
- }
-
- public void testAccountsConstraints() {
- SQLiteDatabase db = getWritableDB();
- db.beginTransaction();
- try {
- assertFalse(PhotoDatabaseUtils.insertAccount(db, null));
- assertTrue(PhotoDatabaseUtils.insertAccount(db, "hello"));
- assertTrue(PhotoDatabaseUtils.insertAccount(db, "hello"));
- } finally {
- db.endTransaction();
- }
- }
-
- public void testUpgrade() {
- SQLiteDatabase db = getWritableDB();
- db.beginTransaction();
- try {
- assertTrue(PhotoDatabaseUtils.insertAccount(db, "Hello"));
- assertTrue(PhotoDatabaseUtils.insertAlbum(db, PARENT_ID1, "hello",
- Albums.VISIBILITY_PRIVATE, 100L));
- final String mimeType = "test/test";
- assertTrue(PhotoDatabaseUtils.insertPhoto(db, 100, 100, 100L, PARENT_ID1, mimeType,
- 100L));
- // Normal insert.
- assertTrue(PhotoDatabaseUtils.insertMetadata(db, 100L, "foo", "bar"));
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- mDBHelper.close();
- Context context = getInstrumentation().getTargetContext();
- mDBHelper = new PhotoDatabase(context, DB_NAME, PhotoDatabase.DB_VERSION + 1);
- db = getReadableDB();
- assertEquals(0, DatabaseUtils.queryNumEntries(db, Accounts.TABLE));
- assertEquals(0, DatabaseUtils.queryNumEntries(db, Photos.TABLE));
- assertEquals(0, DatabaseUtils.queryNumEntries(db, Albums.TABLE));
- assertEquals(0, DatabaseUtils.queryNumEntries(db, Metadata.TABLE));
- }
-
- private SQLiteDatabase getReadableDB() {
- return mDBHelper.getReadableDatabase();
- }
-
- private SQLiteDatabase getWritableDB() {
- return mDBHelper.getWritableDatabase();
- }
-
- private void validateTable(String table, String[] projection) {
- SQLiteDatabase db = getReadableDB();
- Cursor cursor = db.query(table, projection, null, null, null, null, null);
- assertNotNull(cursor);
- assertEquals(cursor.getCount(), 0);
- assertEquals(cursor.getColumnCount(), projection.length);
- for (int i = 0; i < projection.length; i++) {
- assertEquals(cursor.getColumnName(i), projection[i]);
- }
- }
-
-
-}
diff --git a/tests/src/com/android/photos/data/PhotoDatabaseUtils.java b/tests/src/com/android/photos/data/PhotoDatabaseUtils.java
deleted file mode 100644
index f7a46d4..0000000
--- a/tests/src/com/android/photos/data/PhotoDatabaseUtils.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-
-import com.android.photos.data.PhotoProvider.Accounts;
-import com.android.photos.data.PhotoProvider.Albums;
-import com.android.photos.data.PhotoProvider.Metadata;
-import com.android.photos.data.PhotoProvider.Photos;
-
-import junit.framework.AssertionFailedError;
-
-public class PhotoDatabaseUtils {
- public static String[] PROJECTION_ALBUMS = {
- Albums._ID,
- Albums.ACCOUNT_ID,
- Albums.PARENT_ID,
- Albums.VISIBILITY,
- Albums.LOCATION_STRING,
- Albums.TITLE,
- Albums.SUMMARY,
- Albums.DATE_PUBLISHED,
- Albums.DATE_MODIFIED,
- };
-
- public static String[] PROJECTION_METADATA = {
- Metadata.PHOTO_ID,
- Metadata.KEY,
- Metadata.VALUE,
- };
-
- public static String[] PROJECTION_PHOTOS = {
- Photos._ID,
- Photos.ACCOUNT_ID,
- Photos.WIDTH,
- Photos.HEIGHT,
- Photos.DATE_TAKEN,
- Photos.ALBUM_ID,
- Photos.MIME_TYPE,
- Photos.TITLE,
- Photos.DATE_MODIFIED,
- Photos.ROTATION,
- };
-
- public static String[] PROJECTION_ACCOUNTS = {
- Accounts._ID,
- Accounts.ACCOUNT_NAME,
- };
-
- private static String SELECTION_ALBUM_PARENT_ID = Albums.PARENT_ID + " = ?";
- private static String SELECTION_PHOTO_ALBUM_ID = Photos.ALBUM_ID + " = ?";
- private static String SELECTION_ACCOUNT_ID = Accounts.ACCOUNT_NAME + " = ?";
-
- public static long queryAlbumIdFromParentId(SQLiteDatabase db, long parentId) {
- return queryId(db, Albums.TABLE, PROJECTION_ALBUMS, SELECTION_ALBUM_PARENT_ID, parentId);
- }
-
- public static long queryPhotoIdFromAlbumId(SQLiteDatabase db, long albumId) {
- return queryId(db, Photos.TABLE, PROJECTION_PHOTOS, SELECTION_PHOTO_ALBUM_ID, albumId);
- }
-
- public static long queryAccountIdFromName(SQLiteDatabase db, String accountName) {
- return queryId(db, Accounts.TABLE, PROJECTION_ACCOUNTS, SELECTION_ACCOUNT_ID, accountName);
- }
-
- public static long queryId(SQLiteDatabase db, String table, String[] projection,
- String selection, Object parameter) {
- String paramString = parameter == null ? null : parameter.toString();
- String[] selectionArgs = {
- paramString,
- };
- Cursor cursor = db.query(table, projection, selection, selectionArgs, null, null, null);
- try {
- if (cursor.getCount() != 1 || !cursor.moveToNext()) {
- throw new AssertionFailedError("Couldn't find item in table");
- }
- long id = cursor.getLong(0);
- return id;
- } finally {
- cursor.close();
- }
- }
-
- public static boolean insertPhoto(SQLiteDatabase db, Integer width, Integer height,
- Long dateTaken, Long albumId, String mimeType, Long accountId) {
- ContentValues values = new ContentValues();
- values.put(Photos.WIDTH, width);
- values.put(Photos.HEIGHT, height);
- values.put(Photos.DATE_TAKEN, dateTaken);
- values.put(Photos.ALBUM_ID, albumId);
- values.put(Photos.MIME_TYPE, mimeType);
- values.put(Photos.ACCOUNT_ID, accountId);
- return db.insert(Photos.TABLE, null, values) != -1;
- }
-
- public static boolean insertAlbum(SQLiteDatabase db, Long parentId, String title,
- Integer privacy, Long accountId) {
- ContentValues values = new ContentValues();
- values.put(Albums.PARENT_ID, parentId);
- values.put(Albums.TITLE, title);
- values.put(Albums.VISIBILITY, privacy);
- values.put(Albums.ACCOUNT_ID, accountId);
- return db.insert(Albums.TABLE, null, values) != -1;
- }
-
- public static boolean insertMetadata(SQLiteDatabase db, Long photosId, String key, String value) {
- ContentValues values = new ContentValues();
- values.put(Metadata.PHOTO_ID, photosId);
- values.put(Metadata.KEY, key);
- values.put(Metadata.VALUE, value);
- return db.insert(Metadata.TABLE, null, values) != -1;
- }
-
- public static boolean insertAccount(SQLiteDatabase db, String name) {
- ContentValues values = new ContentValues();
- values.put(Accounts.ACCOUNT_NAME, name);
- return db.insert(Accounts.TABLE, null, values) != -1;
- }
-}
diff --git a/tests/src/com/android/photos/data/PhotoProviderTest.java b/tests/src/com/android/photos/data/PhotoProviderTest.java
deleted file mode 100644
index 685946e..0000000
--- a/tests/src/com/android/photos/data/PhotoProviderTest.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.content.ContentProviderOperation;
-import android.content.ContentResolver;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.OperationApplicationException;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.net.Uri;
-import android.os.RemoteException;
-import android.provider.BaseColumns;
-import android.test.ProviderTestCase2;
-
-import com.android.photos.data.PhotoProvider.Accounts;
-import com.android.photos.data.PhotoProvider.Albums;
-import com.android.photos.data.PhotoProvider.Metadata;
-import com.android.photos.data.PhotoProvider.Photos;
-
-import java.util.ArrayList;
-
-public class PhotoProviderTest extends ProviderTestCase2<PhotoProvider> {
- @SuppressWarnings("unused")
- private static final String TAG = PhotoProviderTest.class.getSimpleName();
-
- private static final String MIME_TYPE = "test/test";
- private static final String ALBUM_TITLE = "My Album";
- private static final long ALBUM_PARENT_ID = 100;
- private static final String META_KEY = "mykey";
- private static final String META_VALUE = "myvalue";
- private static final String ACCOUNT_NAME = "foo@bar.com";
-
- private static final Uri NO_TABLE_URI = PhotoProvider.BASE_CONTENT_URI;
- private static final Uri BAD_TABLE_URI = Uri.withAppendedPath(PhotoProvider.BASE_CONTENT_URI,
- "bad_table");
-
- private static final String WHERE_METADATA_PHOTOS_ID = Metadata.PHOTO_ID + " = ?";
- private static final String WHERE_METADATA = Metadata.PHOTO_ID + " = ? AND " + Metadata.KEY
- + " = ?";
-
- private long mAlbumId;
- private long mPhotoId;
- private long mMetadataId;
- private long mAccountId;
-
- private SQLiteOpenHelper mDBHelper;
- private ContentResolver mResolver;
- private NotificationWatcher mNotifications = new NotificationWatcher();
-
- public PhotoProviderTest() {
- super(PhotoProvider.class, PhotoProvider.AUTHORITY);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mResolver = getMockContentResolver();
- PhotoProvider provider = (PhotoProvider) getProvider();
- provider.setMockNotification(mNotifications);
- mDBHelper = provider.getDatabaseHelper();
- SQLiteDatabase db = mDBHelper.getWritableDatabase();
- db.beginTransaction();
- try {
- PhotoDatabaseUtils.insertAccount(db, ACCOUNT_NAME);
- mAccountId = PhotoDatabaseUtils.queryAccountIdFromName(db, ACCOUNT_NAME);
- PhotoDatabaseUtils.insertAlbum(db, ALBUM_PARENT_ID, ALBUM_TITLE,
- Albums.VISIBILITY_PRIVATE, mAccountId);
- mAlbumId = PhotoDatabaseUtils.queryAlbumIdFromParentId(db, ALBUM_PARENT_ID);
- PhotoDatabaseUtils.insertPhoto(db, 100, 100, System.currentTimeMillis(), mAlbumId,
- MIME_TYPE, mAccountId);
- mPhotoId = PhotoDatabaseUtils.queryPhotoIdFromAlbumId(db, mAlbumId);
- PhotoDatabaseUtils.insertMetadata(db, mPhotoId, META_KEY, META_VALUE);
- String[] projection = {
- BaseColumns._ID,
- };
- Cursor cursor = db.query(Metadata.TABLE, projection, null, null, null, null, null);
- cursor.moveToNext();
- mMetadataId = cursor.getLong(0);
- cursor.close();
- db.setTransactionSuccessful();
- mNotifications.reset();
- } finally {
- db.endTransaction();
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mDBHelper.close();
- mDBHelper = null;
- super.tearDown();
- getMockContext().deleteDatabase(PhotoProvider.DB_NAME);
- }
-
- public void testDelete() {
- try {
- mResolver.delete(NO_TABLE_URI, null, null);
- fail("Exeption should be thrown when no table given");
- } catch (Exception e) {
- // expected exception
- }
- try {
- mResolver.delete(BAD_TABLE_URI, null, null);
- fail("Exeption should be thrown when deleting from a table that doesn't exist");
- } catch (Exception e) {
- // expected exception
- }
-
- String[] selectionArgs = {
- String.valueOf(mPhotoId)
- };
- // Delete some metadata
- assertEquals(1,
- mResolver.delete(Metadata.CONTENT_URI, WHERE_METADATA_PHOTOS_ID, selectionArgs));
- Uri photoUri = ContentUris.withAppendedId(Photos.CONTENT_URI, mPhotoId);
- assertEquals(1, mResolver.delete(photoUri, null, null));
- Uri albumUri = ContentUris.withAppendedId(Albums.CONTENT_URI, mAlbumId);
- assertEquals(1, mResolver.delete(albumUri, null, null));
- // now delete something that isn't there
- assertEquals(0, mResolver.delete(photoUri, null, null));
- }
-
- public void testDeleteMetadataId() {
- Uri metadataUri = ContentUris.withAppendedId(Metadata.CONTENT_URI, mMetadataId);
- assertEquals(1, mResolver.delete(metadataUri, null, null));
- Cursor cursor = mResolver.query(Metadata.CONTENT_URI, null, null, null, null);
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
-
- // Delete the album and ensure that the photos referring to the album are
- // deleted.
- public void testDeleteAlbumCascade() {
- Uri albumUri = ContentUris.withAppendedId(Albums.CONTENT_URI, mAlbumId);
- mResolver.delete(albumUri, null, null);
- assertTrue(mNotifications.isNotified(Photos.CONTENT_URI));
- assertTrue(mNotifications.isNotified(Metadata.CONTENT_URI));
- assertTrue(mNotifications.isNotified(albumUri));
- assertEquals(3, mNotifications.notificationCount());
- Cursor cursor = mResolver.query(Photos.CONTENT_URI, PhotoDatabaseUtils.PROJECTION_PHOTOS,
- null, null, null);
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
-
- // Delete all albums and ensure that photos in any album are deleted.
- public void testDeleteAlbumCascade2() {
- mResolver.delete(Albums.CONTENT_URI, null, null);
- assertTrue(mNotifications.isNotified(Photos.CONTENT_URI));
- assertTrue(mNotifications.isNotified(Metadata.CONTENT_URI));
- assertTrue(mNotifications.isNotified(Albums.CONTENT_URI));
- assertEquals(3, mNotifications.notificationCount());
- Cursor cursor = mResolver.query(Photos.CONTENT_URI, PhotoDatabaseUtils.PROJECTION_PHOTOS,
- null, null, null);
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
-
- // Delete a photo and ensure that the metadata for that photo are deleted.
- public void testDeletePhotoCascade() {
- Uri photoUri = ContentUris.withAppendedId(Photos.CONTENT_URI, mPhotoId);
- mResolver.delete(photoUri, null, null);
- assertTrue(mNotifications.isNotified(photoUri));
- assertTrue(mNotifications.isNotified(Metadata.CONTENT_URI));
- assertEquals(2, mNotifications.notificationCount());
- Cursor cursor = mResolver.query(Metadata.CONTENT_URI,
- PhotoDatabaseUtils.PROJECTION_METADATA, null, null, null);
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
-
- public void testDeleteAccountCascade() {
- Uri accountUri = ContentUris.withAppendedId(Accounts.CONTENT_URI, mAccountId);
- SQLiteDatabase db = mDBHelper.getWritableDatabase();
- db.beginTransaction();
- PhotoDatabaseUtils.insertPhoto(db, 100, 100, System.currentTimeMillis(), null,
- "image/jpeg", mAccountId);
- PhotoDatabaseUtils.insertPhoto(db, 100, 100, System.currentTimeMillis(), null,
- "image/jpeg", 0L);
- PhotoDatabaseUtils.insertAlbum(db, null, "title", Albums.VISIBILITY_PRIVATE, 10630L);
- db.setTransactionSuccessful();
- db.endTransaction();
- // ensure all pictures are there:
- Cursor cursor = mResolver.query(Photos.CONTENT_URI, null, null, null, null);
- assertEquals(3, cursor.getCount());
- cursor.close();
- // delete the account
- assertEquals(1, mResolver.delete(accountUri, null, null));
- // now ensure that all associated photos were deleted
- cursor = mResolver.query(Photos.CONTENT_URI, null, null, null, null);
- assertEquals(1, cursor.getCount());
- cursor.close();
- // now ensure all associated albums were deleted.
- cursor = mResolver.query(Albums.CONTENT_URI, null, null, null, null);
- assertEquals(1, cursor.getCount());
- cursor.close();
- }
-
- public void testGetType() {
- // We don't return types for albums
- assertNull(mResolver.getType(Albums.CONTENT_URI));
-
- Uri noImage = ContentUris.withAppendedId(Photos.CONTENT_URI, mPhotoId + 1);
- assertNull(mResolver.getType(noImage));
-
- Uri image = ContentUris.withAppendedId(Photos.CONTENT_URI, mPhotoId);
- assertEquals(MIME_TYPE, mResolver.getType(image));
- }
-
- public void testInsert() {
- ContentValues values = new ContentValues();
- values.put(Albums.TITLE, "add me");
- values.put(Albums.VISIBILITY, Albums.VISIBILITY_PRIVATE);
- values.put(Albums.ACCOUNT_ID, 100L);
- values.put(Albums.DATE_MODIFIED, 100L);
- values.put(Albums.DATE_PUBLISHED, 100L);
- values.put(Albums.LOCATION_STRING, "Home");
- values.put(Albums.TITLE, "hello world");
- values.putNull(Albums.PARENT_ID);
- values.put(Albums.SUMMARY, "Nothing much to say about this");
- Uri insertedUri = mResolver.insert(Albums.CONTENT_URI, values);
- assertNotNull(insertedUri);
- Cursor cursor = mResolver.query(insertedUri, PhotoDatabaseUtils.PROJECTION_ALBUMS, null,
- null, null);
- assertNotNull(cursor);
- assertEquals(1, cursor.getCount());
- cursor.close();
- }
-
- public void testUpdate() {
- ContentValues values = new ContentValues();
- // Normal update -- use an album.
- values.put(Albums.TITLE, "foo");
- Uri albumUri = ContentUris.withAppendedId(Albums.CONTENT_URI, mAlbumId);
- assertEquals(1, mResolver.update(albumUri, values, null, null));
- String[] projection = {
- Albums.TITLE,
- };
- Cursor cursor = mResolver.query(albumUri, projection, null, null, null);
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals("foo", cursor.getString(0));
- cursor.close();
-
- // Update a row that doesn't exist.
- Uri noAlbumUri = ContentUris.withAppendedId(Albums.CONTENT_URI, mAlbumId + 1);
- values.put(Albums.TITLE, "bar");
- assertEquals(0, mResolver.update(noAlbumUri, values, null, null));
-
- // Update a metadata value that exists.
- ContentValues metadata = new ContentValues();
- metadata.put(Metadata.PHOTO_ID, mPhotoId);
- metadata.put(Metadata.KEY, META_KEY);
- metadata.put(Metadata.VALUE, "new value");
- assertEquals(1, mResolver.update(Metadata.CONTENT_URI, metadata, null, null));
-
- projection = new String[] {
- Metadata.VALUE,
- };
-
- String[] selectionArgs = {
- String.valueOf(mPhotoId), META_KEY,
- };
-
- cursor = mResolver.query(Metadata.CONTENT_URI, projection, WHERE_METADATA, selectionArgs,
- null);
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals("new value", cursor.getString(0));
- cursor.close();
-
- // Update a metadata value that doesn't exist.
- metadata.put(Metadata.KEY, "other stuff");
- assertEquals(1, mResolver.update(Metadata.CONTENT_URI, metadata, null, null));
-
- selectionArgs[1] = "other stuff";
- cursor = mResolver.query(Metadata.CONTENT_URI, projection, WHERE_METADATA, selectionArgs,
- null);
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals("new value", cursor.getString(0));
- cursor.close();
-
- // Remove a metadata value using update.
- metadata.putNull(Metadata.VALUE);
- assertEquals(1, mResolver.update(Metadata.CONTENT_URI, metadata, null, null));
- cursor = mResolver.query(Metadata.CONTENT_URI, projection, WHERE_METADATA, selectionArgs,
- null);
- assertEquals(0, cursor.getCount());
- cursor.close();
- }
-
- public void testQuery() {
- // Query a photo that exists.
- Cursor cursor = mResolver.query(Photos.CONTENT_URI, PhotoDatabaseUtils.PROJECTION_PHOTOS,
- null, null, null);
- assertNotNull(cursor);
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals(mPhotoId, cursor.getLong(0));
- cursor.close();
-
- // Query a photo that doesn't exist.
- Uri noPhotoUri = ContentUris.withAppendedId(Photos.CONTENT_URI, mPhotoId + 1);
- cursor = mResolver.query(noPhotoUri, PhotoDatabaseUtils.PROJECTION_PHOTOS, null, null,
- null);
- assertNotNull(cursor);
- assertEquals(0, cursor.getCount());
- cursor.close();
-
- // Query a photo that exists using selection arguments.
- String[] selectionArgs = {
- String.valueOf(mPhotoId),
- };
-
- cursor = mResolver.query(Photos.CONTENT_URI, PhotoDatabaseUtils.PROJECTION_PHOTOS,
- Photos._ID + " = ?", selectionArgs, null);
- assertNotNull(cursor);
- assertEquals(1, cursor.getCount());
- assertTrue(cursor.moveToNext());
- assertEquals(mPhotoId, cursor.getLong(0));
- cursor.close();
- }
-
- public void testUpdatePhotoNotification() {
- Uri photoUri = ContentUris.withAppendedId(Photos.CONTENT_URI, mPhotoId);
- ContentValues values = new ContentValues();
- values.put(Photos.MIME_TYPE, "not-a/mime-type");
- mResolver.update(photoUri, values, null, null);
- assertTrue(mNotifications.isNotified(photoUri));
- }
-
- public void testUpdateMetadataNotification() {
- ContentValues values = new ContentValues();
- values.put(Metadata.PHOTO_ID, mPhotoId);
- values.put(Metadata.KEY, META_KEY);
- values.put(Metadata.VALUE, "hello world");
- mResolver.update(Metadata.CONTENT_URI, values, null, null);
- assertTrue(mNotifications.isNotified(Metadata.CONTENT_URI));
- }
-
- public void testBatchTransaction() throws RemoteException, OperationApplicationException {
- ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
- ContentProviderOperation.Builder insert = ContentProviderOperation
- .newInsert(Photos.CONTENT_URI);
- insert.withValue(Photos.WIDTH, 200L);
- insert.withValue(Photos.HEIGHT, 100L);
- insert.withValue(Photos.DATE_TAKEN, System.currentTimeMillis());
- insert.withValue(Photos.ALBUM_ID, 1000L);
- insert.withValue(Photos.MIME_TYPE, "image/jpg");
- insert.withValue(Photos.ACCOUNT_ID, 1L);
- operations.add(insert.build());
- ContentProviderOperation.Builder update = ContentProviderOperation.newUpdate(Photos.CONTENT_URI);
- update.withValue(Photos.DATE_MODIFIED, System.currentTimeMillis());
- String[] whereArgs = {
- "100",
- };
- String where = Photos.WIDTH + " = ?";
- update.withSelection(where, whereArgs);
- operations.add(update.build());
- ContentProviderOperation.Builder delete = ContentProviderOperation
- .newDelete(Photos.CONTENT_URI);
- delete.withSelection(where, whereArgs);
- operations.add(delete.build());
- mResolver.applyBatch(PhotoProvider.AUTHORITY, operations);
- assertEquals(3, mNotifications.notificationCount());
- SQLiteDatabase db = mDBHelper.getReadableDatabase();
- long id = PhotoDatabaseUtils.queryPhotoIdFromAlbumId(db, 1000L);
- Uri uri = ContentUris.withAppendedId(Photos.CONTENT_URI, id);
- assertTrue(mNotifications.isNotified(uri));
- assertTrue(mNotifications.isNotified(Metadata.CONTENT_URI));
- assertTrue(mNotifications.isNotified(Photos.CONTENT_URI));
- }
-
-}
diff --git a/tests/src/com/android/photos/data/TestHelper.java b/tests/src/com/android/photos/data/TestHelper.java
deleted file mode 100644
index 338e160..0000000
--- a/tests/src/com/android/photos/data/TestHelper.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.photos.data;
-
-import android.util.Log;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.lang.reflect.Method;
-
-public class TestHelper {
- private static String TAG = TestHelper.class.getSimpleName();
-
- public interface TestInitialization {
- void initialize(TestCase testCase);
- }
-
- public static void addTests(Class<? extends TestCase> testClass, TestSuite suite,
- TestInitialization initialization) {
- for (Method method : testClass.getDeclaredMethods()) {
- if (method.getName().startsWith("test") && method.getParameterTypes().length == 0) {
- TestCase test;
- try {
- test = testClass.newInstance();
- test.setName(method.getName());
- initialization.initialize(test);
- suite.addTest(test);
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (InstantiationException e) {
- Log.e(TAG, "Failed to create test case", e);
- } catch (IllegalAccessException e) {
- Log.e(TAG, "Failed to create test case", e);
- }
- }
- }
- }
-
-}
diff --git a/tests_camera/Android.mk b/tests_camera/Android.mk
deleted file mode 100644
index 81ea50d..0000000
--- a/tests_camera/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-ifeq (0,1)
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SDK_VERSION := 16
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CameraTests
-
-LOCAL_INSTRUMENTATION_FOR := Gallery2
-
-include $(BUILD_PACKAGE)
-endif
diff --git a/tests_camera/AndroidManifest.xml b/tests_camera/AndroidManifest.xml
deleted file mode 100644
index 164bbd5..0000000
--- a/tests_camera/AndroidManifest.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.camera.tests">
-
- <uses-permission android:name="android.permission.INJECT_EVENTS" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="com.android.camera.CameraLaunchPerformance"
- android:targetPackage="com.android.camera"
- android:label="Camera Launch Performance">
- </instrumentation>
-
- <instrumentation android:name="com.android.camera.stress.CameraStressTestRunner"
- android:targetPackage="com.android.camera"
- android:label="Camera stress test runner">
- </instrumentation>
-
- <instrumentation android:name="com.android.camera.CameraTestRunner"
- android:targetPackage="com.android.camera"
- android:label="Camera continuous test runner">
- </instrumentation>
-
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.android.camera"
- android:label="Tests for Camera application."/>
-</manifest>
diff --git a/tests_camera/src/com/android/camera/CameraLaunchPerformance.java b/tests_camera/src/com/android/camera/CameraLaunchPerformance.java
deleted file mode 100644
index fe2b776..0000000
--- a/tests_camera/src/com/android/camera/CameraLaunchPerformance.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 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.camera;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.test.LaunchPerformanceBase;
-
-/**
- * Instrumentation class for Camera launch performance testing.
- */
-public class CameraLaunchPerformance extends LaunchPerformanceBase {
- @SuppressWarnings("unused")
- private static final String TAG = "CameraLaunchPerformance";
-
- @Override
- public void onCreate(Bundle arguments) {
- super.onCreate(arguments);
- mIntent.setClassName(getTargetContext(),
- "com.android.camera.CameraActivity");
- start();
- }
-
- /**
- * Calls LaunchApp and finish.
- */
- @Override
- public void onStart() {
- super.onStart();
- LaunchApp();
- finish(Activity.RESULT_OK, mResults);
- }
-}
diff --git a/tests_camera/src/com/android/camera/CameraTestRunner.java b/tests_camera/src/com/android/camera/CameraTestRunner.java
deleted file mode 100755
index 96c48a4..0000000
--- a/tests_camera/src/com/android/camera/CameraTestRunner.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera;
-
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-
-import com.android.camera.activity.CameraActivityTest;
-import com.android.camera.functional.CameraTest;
-import com.android.camera.functional.ImageCaptureIntentTest;
-import com.android.camera.functional.VideoCaptureIntentTest;
-import com.android.camera.unittest.CameraUnitTest;
-
-import junit.framework.TestSuite;
-
-
-public class CameraTestRunner extends InstrumentationTestRunner {
-
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(CameraActivityTest.class);
- suite.addTestSuite(CameraTest.class);
- suite.addTestSuite(ImageCaptureIntentTest.class);
- suite.addTestSuite(VideoCaptureIntentTest.class);
- suite.addTestSuite(CameraUnitTest.class);
- return suite;
- }
-
- @Override
- public ClassLoader getLoader() {
- return CameraTestRunner.class.getClassLoader();
- }
-}
diff --git a/tests_camera/src/com/android/camera/StressTests.java b/tests_camera/src/com/android/camera/StressTests.java
deleted file mode 100755
index 7ed8317..0000000
--- a/tests_camera/src/com/android/camera/StressTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera;
-
-import com.android.camera.stress.ImageCapture;
-import com.android.camera.stress.SwitchPreview;
-import com.android.camera.stress.CameraLatency;
-import com.android.camera.stress.CameraStartUp;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-/**
- * Instrumentation Test Runner for all Camera tests.
- *
- * Running all tests:
- *
- * adb shell am instrument \
- * -e class com.android.camera.StressTests \
- * -w com.android.camera.tests/com.android.camera.stress.CameraStressTestRunner
- */
-
-public class StressTests extends TestSuite {
- public static Test suite() {
- TestSuite result = new TestSuite();
- result.addTestSuite(SwitchPreview.class);
- result.addTestSuite(ImageCapture.class);
- result.addTestSuite(CameraLatency.class);
- result.addTestSuite(CameraStartUp.class);
- return result;
- }
-}
diff --git a/tests_camera/src/com/android/camera/UnitTests.java b/tests_camera/src/com/android/camera/UnitTests.java
deleted file mode 100644
index e56a907..0000000
--- a/tests_camera/src/com/android/camera/UnitTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 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.camera;
-
-import android.test.suitebuilder.UnitTestSuiteBuilder;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * TestSuite for all Camera unit tests.
- */
-public class UnitTests extends TestSuite {
-
- public static Test suite() {
- return new UnitTestSuiteBuilder(UnitTests.class)
- .includePackages("com.android.camera.unittest")
- .named("Camera Unit Tests")
- .build();
- }
-}
diff --git a/tests_camera/src/com/android/camera/activity/CameraActivityTest.java b/tests_camera/src/com/android/camera/activity/CameraActivityTest.java
deleted file mode 100644
index eb027e9..0000000
--- a/tests_camera/src/com/android/camera/activity/CameraActivityTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.activity;
-
-import android.hardware.Camera.Parameters;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.android.camera.CameraActivity;
-import com.android.camera.CameraHolder;
-import com.android.gallery3d.R;
-
-import static com.google.testing.littlemock.LittleMock.doReturn;
-
-public class CameraActivityTest extends CameraTestCase <CameraActivity> {
- public CameraActivityTest() {
- super(CameraActivity.class);
- }
-
- @LargeTest
- public void testFailToConnect() throws Exception {
- super.internalTestFailToConnect();
- }
-
- @LargeTest
- public void testTakePicture() throws Exception {
- CameraHolder.injectMockCamera(mCameraInfo, mOneMockCamera);
-
- getActivity();
- getInstrumentation().waitForIdleSync();
-
- // Press shutter button to take a picture.
- performClick(R.id.shutter_button);
- getInstrumentation().waitForIdleSync();
-
- // Force the activity to finish.
- getActivity().finish();
- getInstrumentation().waitForIdleSync();
- }
-}
diff --git a/tests_camera/src/com/android/camera/activity/CameraTestCase.java b/tests_camera/src/com/android/camera/activity/CameraTestCase.java
deleted file mode 100644
index 27be3c7..0000000
--- a/tests_camera/src/com/android/camera/activity/CameraTestCase.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.activity;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.hardware.Camera;
-import android.hardware.Camera.AutoFocusCallback;
-import android.hardware.Camera.CameraInfo;
-import android.hardware.Camera.Parameters;
-import android.hardware.Camera.PictureCallback;
-import android.hardware.Camera.ShutterCallback;
-import android.test.ActivityInstrumentationTestCase2;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.View;
-
-import com.android.camera.CameraHolder;
-import com.android.camera.CameraManager.CameraProxy;
-import com.android.camera.Util;
-import com.android.gallery3d.R;
-
-import static com.google.testing.littlemock.LittleMock.mock;
-import static com.google.testing.littlemock.LittleMock.doAnswer;
-import static com.google.testing.littlemock.LittleMock.doReturn;
-import static com.google.testing.littlemock.LittleMock.anyObject;
-import com.google.testing.littlemock.AppDataDirGuesser;
-import com.google.testing.littlemock.ArgumentCaptor;
-import com.google.testing.littlemock.Captor;
-import com.google.testing.littlemock.LittleMock;
-import com.google.testing.littlemock.Mock;
-
-import java.io.File;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.util.concurrent.Callable;
-
-
-public class CameraTestCase<T extends Activity> extends ActivityInstrumentationTestCase2<T> {
- protected CameraInfo mCameraInfo[];
- protected CameraProxy mMockCamera[];
- protected CameraInfo mOneCameraInfo[];
- protected CameraProxy mOneMockCamera[];
- private static Parameters mParameters;
- private byte[] mBlankJpeg;
- @Mock private CameraProxy mMockBackCamera;
- @Mock private CameraProxy mMockFrontCamera;
- @Captor private ArgumentCaptor<ShutterCallback> mShutterCallback;
- @Captor private ArgumentCaptor<PictureCallback> mRawPictureCallback;
- @Captor private ArgumentCaptor<PictureCallback> mJpegPictureCallback;
- @Captor private ArgumentCaptor<AutoFocusCallback> mAutoFocusCallback;
- Callable<Object> mAutoFocusCallable = new AutoFocusCallable();
- Callable<Object> mTakePictureCallable = new TakePictureCallable();
-
- private class TakePictureCallable implements Callable<Object> {
- @Override
- public Object call() throws Exception {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- readBlankJpeg();
- Camera camera = mOneMockCamera[0].getCamera();
- mShutterCallback.getValue().onShutter();
- mRawPictureCallback.getValue().onPictureTaken(null, camera);
- mJpegPictureCallback.getValue().onPictureTaken(mBlankJpeg, camera);
- }
- };
- // Probably need some delay. Make sure shutter callback is called
- // after onShutterButtonFocus(false).
- getActivity().findViewById(R.id.gl_root_view).postDelayed(runnable, 50);
- return null;
- }
- }
-
- private class AutoFocusCallable implements Callable<Object> {
- @Override
- public Object call() throws Exception {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- Camera camera = mOneMockCamera[0].getCamera();
- mAutoFocusCallback.getValue().onAutoFocus(true, camera);
- }
- };
- // Need some delay. Otherwise, focus callback will be run before
- // onShutterButtonClick
- getActivity().findViewById(R.id.gl_root_view).postDelayed(runnable, 50);
- return null;
- }
- }
-
- public CameraTestCase(Class<T> activityClass) {
- super(activityClass);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- AppDataDirGuesser.setInstance(new AppDataDirGuesser() {
- @Override
- public File guessSuitableDirectoryForGeneratedClasses() {
- return getInstrumentation().getTargetContext().getCacheDir();
- }
- });
- AppDataDirGuesser.getsInstance().guessSuitableDirectoryForGeneratedClasses();
- LittleMock.initMocks(this);
- mCameraInfo = new CameraInfo[2];
- mCameraInfo[0] = new CameraInfo();
- mCameraInfo[0].facing = CameraInfo.CAMERA_FACING_BACK;
- mCameraInfo[1] = new CameraInfo();
- mCameraInfo[1].facing = CameraInfo.CAMERA_FACING_FRONT;
- mMockCamera = new CameraProxy[2];
- mMockCamera[0] = mMockBackCamera;
- mMockCamera[1] = mMockFrontCamera;
- doReturn(getParameters()).when(mMockCamera[0]).getParameters();
- doReturn(getParameters()).when(mMockCamera[1]).getParameters();
-
- mOneCameraInfo = new CameraInfo[1];
- mOneCameraInfo[0] = new CameraInfo();
- mOneCameraInfo[0].facing = CameraInfo.CAMERA_FACING_BACK;
- mOneMockCamera = new CameraProxy[1];
- mOneMockCamera[0] = mMockBackCamera;
- doReturn(getParameters()).when(mOneMockCamera[0]).getParameters();
-
- // Mock takePicture call.
- doAnswer(mTakePictureCallable).when(mMockBackCamera).takePicture(
- mShutterCallback.capture(), mRawPictureCallback.capture(),
- (PictureCallback) anyObject(), mJpegPictureCallback.capture());
-
- // Mock autoFocus call.
- doAnswer(mAutoFocusCallable).when(mMockBackCamera).autoFocus(
- mAutoFocusCallback.capture());
- }
-
- private void readBlankJpeg() {
- InputStream ins = getActivity().getResources().openRawResource(R.raw.blank);
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- int size = 0;
-
- // Read the entire resource into a local byte buffer.
- byte[] buffer = new byte[1024];
- try {
- while((size = ins.read(buffer, 0, 1024)) >= 0){
- outputStream.write(buffer, 0, size);
- }
- } catch (IOException e) {
- // ignore
- } finally {
- Util.closeSilently(ins);
- }
- mBlankJpeg = outputStream.toByteArray();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- CameraHolder.injectMockCamera(null, null);
- }
-
- protected void internalTestFailToConnect() throws Exception {
- CameraHolder.injectMockCamera(mCameraInfo, null);
-
- getActivity();
- Instrumentation inst = getInstrumentation();
- inst.waitForIdleSync();
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER); // close dialog
- }
-
- protected void performClick(final int id) {
- Activity activity = getActivity();
- getInstrumentation().waitForIdleSync();
- assertNotNull(activity.findViewById(id));
- Instrumentation inst = getInstrumentation();
- inst.runOnMainSync(new Runnable() {
- @Override
- public void run() {
- View v = getActivity().findViewById(id);
- float x = (v.getLeft() + v.getRight()) / 2;
- float y = (v.getTop() + v.getBottom()) / 2;
- MotionEvent down = MotionEvent.obtain(0, 0,
- MotionEvent.ACTION_DOWN, x, y, 0, 0, 0, 0, 0, 0, 0);
- MotionEvent up = MotionEvent.obtain(0, 0,
- MotionEvent.ACTION_UP, x, y, 0, 0, 0, 0, 0, 0, 0);
- View parent = (View) v.getParent();
- parent.dispatchTouchEvent(down);
- parent.dispatchTouchEvent(up);
- }
- });
- inst.waitForIdleSync();
- }
-
- protected void assertViewNotExist(int id) {
- Activity activity = getActivity();
- getInstrumentation().waitForIdleSync();
- assertNull(activity.findViewById(id));
- }
-
- protected void assertViewNotVisible(int id) {
- Activity activity = getActivity();
- getInstrumentation().waitForIdleSync();
- View view = activity.findViewById(id);
- assertTrue(view.getVisibility() != View.VISIBLE);
- }
-
- protected static Parameters getParameters() {
- synchronized (CameraTestCase.class) {
- if (mParameters == null) {
- mParameters = android.hardware.Camera.getEmptyParameters();
- mParameters.unflatten("preview-format-values=yuv420sp,yuv420p,yuv422i-yuyv,yuv420p;" +
- "preview-format=yuv420sp;" +
- "preview-size-values=800x480;preview-size=800x480;" +
- "picture-size-values=320x240;picture-size=320x240;" +
- "jpeg-thumbnail-size-values=320x240,0x0;jpeg-thumbnail-width=320;jpeg-thumbnail-height=240;" +
- "jpeg-thumbnail-quality=60;jpeg-quality=95;" +
- "preview-frame-rate-values=30,15;preview-frame-rate=30;" +
- "focus-mode-values=continuous-video,auto,macro,infinity,continuous-picture;focus-mode=auto;" +
- "preview-fps-range-values=(15000,30000);preview-fps-range=15000,30000;" +
- "scene-mode-values=auto,action,night;scene-mode=auto;" +
- "flash-mode-values=off,on,auto,torch;flash-mode=off;" +
- "whitebalance-values=auto,daylight,fluorescent,incandescent;whitebalance=auto;" +
- "effect-values=none,mono,sepia;effect=none;" +
- "zoom-supported=true;zoom-ratios=100,200,400;max-zoom=2;" +
- "picture-format-values=jpeg;picture-format=jpeg;" +
- "min-exposure-compensation=-30;max-exposure-compensation=30;" +
- "exposure-compensation=0;exposure-compensation-step=0.1;" +
- "horizontal-view-angle=40;vertical-view-angle=40;");
- }
- }
- return mParameters;
- }
-}
diff --git a/tests_camera/src/com/android/camera/functional/CameraTest.java b/tests_camera/src/com/android/camera/functional/CameraTest.java
deleted file mode 100644
index 3fdebc0..0000000
--- a/tests_camera/src/com/android/camera/functional/CameraTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.functional;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Environment;
-import android.os.Process;
-import android.provider.MediaStore;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-
-public class CameraTest extends InstrumentationTestCase {
- @LargeTest
- public void testVideoCaptureIntentFdLeak() throws Exception {
- Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse("file://"
- + Environment.getExternalStorageDirectory().toString()
- + "test_fd_leak.3gp"));
- getInstrumentation().startActivitySync(intent).finish();
- // Test if the fd is closed.
- for (File f: new File("/proc/" + Process.myPid() + "/fd").listFiles()) {
- assertEquals(-1, f.getCanonicalPath().indexOf("test_fd_leak.3gp"));
- }
- }
-
- @LargeTest
- public void testActivityLeak() throws Exception {
- checkActivityLeak(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
- checkActivityLeak(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
- }
-
- private void checkActivityLeak(String action) throws Exception {
- final int TEST_COUNT = 5;
- Intent intent = new Intent(action);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClass(getInstrumentation().getTargetContext(),
- CameraActivity.class);
- ArrayList<WeakReference<Activity>> refs =
- new ArrayList<WeakReference<Activity>>();
- for (int i = 0; i < TEST_COUNT; i++) {
- Activity activity = getInstrumentation().startActivitySync(intent);
- refs.add(new WeakReference<Activity>(activity));
- activity.finish();
- getInstrumentation().waitForIdleSync();
- activity = null;
- }
- Runtime.getRuntime().gc();
- Runtime.getRuntime().runFinalization();
- Runtime.getRuntime().gc();
- int refCount = 0;
- for (WeakReference<Activity> c: refs) {
- if (c.get() != null) refCount++;
- }
- // If applications are leaking activity, every reference is reachable.
- assertTrue(refCount != TEST_COUNT);
- }
-}
diff --git a/tests_camera/src/com/android/camera/functional/ImageCaptureIntentTest.java b/tests_camera/src/com/android/camera/functional/ImageCaptureIntentTest.java
deleted file mode 100644
index 54ac1b4..0000000
--- a/tests_camera/src/com/android/camera/functional/ImageCaptureIntentTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.functional;
-
-import com.android.camera.CameraActivity;
-import com.android.gallery3d.R;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.KeyEvent;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-public class ImageCaptureIntentTest extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private Intent mIntent;
-
- public ImageCaptureIntentTest() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- }
-
- @LargeTest
- public void testNoExtraOutput() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- takePicture();
- pressDone();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_OK, getActivity().getResultCode());
- Intent resultData = getActivity().getResultData();
- Bitmap bitmap = (Bitmap) resultData.getParcelableExtra("data");
- assertNotNull(bitmap);
- assertTrue(bitmap.getWidth() > 0);
- assertTrue(bitmap.getHeight() > 0);
- }
-
- @LargeTest
- public void testExtraOutput() throws Exception {
- File file = new File(Environment.getExternalStorageDirectory(),
- "test.jpg");
- BufferedInputStream stream = null;
- byte[] jpegData;
-
- try {
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
- setActivityIntent(mIntent);
- getActivity();
-
- takePicture();
- pressDone();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_OK, getActivity().getResultCode());
-
- // Verify the jpeg file
- int fileLength = (int) file.length();
- assertTrue(fileLength > 0);
- jpegData = new byte[fileLength];
- stream = new BufferedInputStream(new FileInputStream(file));
- stream.read(jpegData);
- } finally {
- if (stream != null) stream.close();
- file.delete();
- }
-
- Bitmap b = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
- assertTrue(b.getWidth() > 0);
- assertTrue(b.getHeight() > 0);
- }
-
- @LargeTest
- public void testCancel() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- pressCancel();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode());
- }
-
- @LargeTest
- public void testSnapshotCancel() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- takePicture();
- pressCancel();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode());
- }
-
- private void takePicture() throws Exception {
- getInstrumentation().sendKeySync(
- new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_FOCUS));
- getInstrumentation().sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(4000);
- }
-
- private void pressDone() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getActivity().findViewById(R.id.btn_done).performClick();
- }
- });
- }
-
- private void pressCancel() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getActivity().findViewById(R.id.btn_cancel).performClick();
- }
- });
- }
-}
diff --git a/tests_camera/src/com/android/camera/functional/VideoCaptureIntentTest.java b/tests_camera/src/com/android/camera/functional/VideoCaptureIntentTest.java
deleted file mode 100644
index 43e91ca..0000000
--- a/tests_camera/src/com/android/camera/functional/VideoCaptureIntentTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.functional;
-
-import com.android.camera.CameraActivity;
-import com.android.gallery3d.R;
-
-import android.app.Activity;
-import android.content.ContentResolver;
-import android.content.Intent;
-import android.database.Cursor;
-import android.media.MediaMetadataRetriever;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-
-import java.io.File;
-
-public class VideoCaptureIntentTest extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private static final String TAG = "VideoCaptureIntentTest";
- private Intent mIntent;
- private Uri mVideoUri;
- private File mFile, mFile2;
-
- public VideoCaptureIntentTest() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (mVideoUri != null) {
- ContentResolver resolver = getActivity().getContentResolver();
- Uri query = mVideoUri.buildUpon().build();
- String[] projection = new String[] {VideoColumns.DATA};
-
- Cursor cursor = null;
- try {
- cursor = resolver.query(query, projection, null, null, null);
- if (cursor != null && cursor.moveToFirst()) {
- new File(cursor.getString(0)).delete();
- }
- } finally {
- if (cursor != null) cursor.close();
- }
-
- resolver.delete(mVideoUri, null, null);
- }
- if (mFile != null) mFile.delete();
- if (mFile2 != null) mFile2.delete();
- super.tearDown();
- }
-
- @LargeTest
- public void testNoExtraOutput() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressDone();
-
- Intent resultData = getActivity().getResultData();
- mVideoUri = resultData.getData();
- assertNotNull(mVideoUri);
- verify(getActivity(), mVideoUri);
- }
-
- @LargeTest
- public void testExtraOutput() throws Exception {
- mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp");
-
- Uri uri = Uri.fromFile(mFile);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressDone();
-
- verify(getActivity(), uri);
- }
-
- @LargeTest
- public void testCancel() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- pressCancel();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode());
- }
-
- @LargeTest
- public void testRecordCancel() throws Exception {
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressCancel();
-
- assertTrue(getActivity().isFinishing());
- assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode());
- }
-
- @LargeTest
- public void testExtraSizeLimit() throws Exception {
- mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp");
- final long sizeLimit = 500000; // bytes
-
- Uri uri = Uri.fromFile(mFile);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit);
- mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // use low quality to speed up
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo(5000);
- pressDone();
-
- verify(getActivity(), uri);
- long length = mFile.length();
- Log.v(TAG, "Video size is " + length + " bytes.");
- assertTrue(length > 0);
- assertTrue("Actual size=" + length, length <= sizeLimit);
- }
-
- @LargeTest
- public void testExtraDurationLimit() throws Exception {
- mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp");
- final int durationLimit = 2; // seconds
-
- Uri uri = Uri.fromFile(mFile);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit);
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo(5000);
- pressDone();
-
- int duration = verify(getActivity(), uri);
- // The duraion should be close to to the limit. The last video duration
- // also has duration, so the total duration may exceeds the limit a
- // little bit.
- Log.v(TAG, "Video length is " + duration + " ms.");
- assertTrue(duration < (durationLimit + 1) * 1000);
- }
-
- @LargeTest
- public void testExtraVideoQuality() throws Exception {
- mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp");
- mFile2 = new File(Environment.getExternalStorageDirectory(), "video2.tmp");
-
- Uri uri = Uri.fromFile(mFile);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // low quality
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressDone();
-
- verify(getActivity(), uri);
- setActivity(null);
-
- uri = Uri.fromFile(mFile2);
- mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
- mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // high quality
- setActivityIntent(mIntent);
- getActivity();
-
- recordVideo();
- pressDone();
-
- verify(getActivity(), uri);
- assertTrue(mFile.length() <= mFile2.length());
- }
-
- // Verify result code, result data, and the duration.
- private int verify(CameraActivity activity, Uri uri) throws Exception {
- assertTrue(activity.isFinishing());
- assertEquals(Activity.RESULT_OK, activity.getResultCode());
-
- // Verify the video file
- MediaMetadataRetriever retriever = new MediaMetadataRetriever();
- retriever.setDataSource(activity, uri);
- String duration = retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_DURATION);
- assertNotNull(duration);
- int durationValue = Integer.parseInt(duration);
- Log.v(TAG, "Video duration is " + durationValue);
- assertTrue(durationValue > 0);
- return durationValue;
- }
-
- private void recordVideo(int ms) throws Exception {
- getInstrumentation().sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(ms);
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- // If recording is in progress, stop it. Run these atomically in
- // UI thread.
- CameraActivity activity = getActivity();
- if (activity.isRecording()) {
- activity.findViewById(R.id.shutter_button).performClick();
- }
- }
- });
- }
-
- private void recordVideo() throws Exception {
- recordVideo(2000);
- }
-
- private void pressDone() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getActivity().findViewById(R.id.btn_done).performClick();
- }
- });
- }
-
- private void pressCancel() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getActivity().findViewById(R.id.btn_cancel).performClick();
- }
- });
- }
-}
diff --git a/tests_camera/src/com/android/camera/power/ImageAndVideoCapture.java b/tests_camera/src/com/android/camera/power/ImageAndVideoCapture.java
deleted file mode 100755
index b89b764..0000000
--- a/tests_camera/src/com/android/camera/power/ImageAndVideoCapture.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera.power;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Instrumentation;
-import android.provider.MediaStore;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.content.Intent;
-/**
- * Junit / Instrumentation test case for camera power measurement
- *
- * Running the test suite:
- *
- * adb shell am instrument \
- * -e com.android.camera.power.ImageAndVideoCapture \
- * -w com.android.camera.tests/android.test.InstrumentationTestRunner
- *
- */
-
-public class ImageAndVideoCapture extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private String TAG = "ImageAndVideoCapture";
- private static final int TOTAL_NUMBER_OF_IMAGECAPTURE = 5;
- private static final int TOTAL_NUMBER_OF_VIDEOCAPTURE = 5;
- private static final long WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN = 1500; //1.5 sedconds
- private static final long WAIT_FOR_VIDEO_CAPTURE_TO_BE_TAKEN = 10000; //10 seconds
- private static final long WAIT_FOR_PREVIEW = 1500; //1.5 seconds
- private static final long WAIT_FOR_STABLE_STATE = 2000; //2 seconds
-
- public ImageAndVideoCapture() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- getActivity();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- @LargeTest
- public void testLaunchCamera() {
- // This test case capture the baseline for the image preview.
- try {
- Thread.sleep(WAIT_FOR_STABLE_STATE);
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- assertTrue("testImageCaptureDoNothing", false);
- }
- }
-
- @LargeTest
- public void testCapture5Image() {
- // This test case will use the default camera setting
- Instrumentation inst = getInstrumentation();
- try {
- for (int i = 0; i < TOTAL_NUMBER_OF_IMAGECAPTURE; i++) {
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP);
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- }
- Thread.sleep(WAIT_FOR_STABLE_STATE);
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- assertTrue("testImageCapture", false);
- }
- }
-
- @LargeTest
- public void testCapture5Videos() {
- // This test case will use the default camera setting
- Instrumentation inst = getInstrumentation();
- try {
- // Switch to the video mode
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
- intent.setClass(getInstrumentation().getTargetContext(),
- CameraActivity.class);
- getActivity().startActivity(intent);
- for (int i = 0; i < TOTAL_NUMBER_OF_VIDEOCAPTURE; i++) {
- Thread.sleep(WAIT_FOR_PREVIEW);
- // record a video
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
- Thread.sleep(WAIT_FOR_VIDEO_CAPTURE_TO_BE_TAKEN);
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
- Thread.sleep(WAIT_FOR_PREVIEW);
- }
- Thread.sleep(WAIT_FOR_STABLE_STATE);
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- assertTrue("testVideoCapture", false);
- }
- }
-}
diff --git a/tests_camera/src/com/android/camera/stress/CameraLatency.java b/tests_camera/src/com/android/camera/stress/CameraLatency.java
deleted file mode 100755
index 35ff717..0000000
--- a/tests_camera/src/com/android/camera/stress/CameraLatency.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera.stress;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Instrumentation;
-import android.os.Environment;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-
-/**
- * Junit / Instrumentation test case for camera test
- *
- */
-
-public class CameraLatency extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private String TAG = "CameraLatency";
- private static final int TOTAL_NUMBER_OF_IMAGECAPTURE = 20;
- private static final long WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN = 4000;
- private static final String CAMERA_TEST_OUTPUT_FILE =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
-
- private long mTotalAutoFocusTime;
- private long mTotalShutterLag;
- private long mTotalShutterToPictureDisplayedTime;
- private long mTotalPictureDisplayedToJpegCallbackTime;
- private long mTotalJpegCallbackFinishTime;
- private long mAvgAutoFocusTime;
- private long mAvgShutterLag = mTotalShutterLag;
- private long mAvgShutterToPictureDisplayedTime;
- private long mAvgPictureDisplayedToJpegCallbackTime;
- private long mAvgJpegCallbackFinishTime;
-
- public CameraLatency() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- getActivity();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- @LargeTest
- public void testImageCapture() {
- Log.v(TAG, "start testImageCapture test");
- Instrumentation inst = getInstrumentation();
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
- try {
- for (int i = 0; i < TOTAL_NUMBER_OF_IMAGECAPTURE; i++) {
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- //skip the first measurement
- if (i != 0) {
- CameraActivity c = getActivity();
-
- // if any of the latency var accessor methods return -1 then the
- // camera is set to a different module other than PhotoModule so
- // skip the shot and try again
- if (c.getAutoFocusTime() != -1) {
- mTotalAutoFocusTime += c.getAutoFocusTime();
- mTotalShutterLag += c.getShutterLag();
- mTotalShutterToPictureDisplayedTime +=
- c.getShutterToPictureDisplayedTime();
- mTotalPictureDisplayedToJpegCallbackTime +=
- c.getPictureDisplayedToJpegCallbackTime();
- mTotalJpegCallbackFinishTime += c.getJpegCallbackFinishTime();
- }
- else {
- i--;
- continue;
- }
- }
- }
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- }
- //ToDO: yslau
- //1) Need to get the baseline from the cupcake so that we can add the
- //failure condition of the camera latency.
- //2) Only count those number with succesful capture. Set the timer to invalid
- //before capture and ignore them if the value is invalid
- int numberofRun = TOTAL_NUMBER_OF_IMAGECAPTURE - 1;
- mAvgAutoFocusTime = mTotalAutoFocusTime / numberofRun;
- mAvgShutterLag = mTotalShutterLag / numberofRun;
- mAvgShutterToPictureDisplayedTime =
- mTotalShutterToPictureDisplayedTime / numberofRun;
- mAvgPictureDisplayedToJpegCallbackTime =
- mTotalPictureDisplayedToJpegCallbackTime / numberofRun;
- mAvgJpegCallbackFinishTime =
- mTotalJpegCallbackFinishTime / numberofRun;
-
- try {
- FileWriter fstream = null;
- fstream = new FileWriter(CAMERA_TEST_OUTPUT_FILE, true);
- BufferedWriter out = new BufferedWriter(fstream);
- out.write("Camera Latency : \n");
- out.write("Number of loop: " + TOTAL_NUMBER_OF_IMAGECAPTURE + "\n");
- out.write("Avg AutoFocus = " + mAvgAutoFocusTime + "\n");
- out.write("Avg mShutterLag = " + mAvgShutterLag + "\n");
- out.write("Avg mShutterToPictureDisplayedTime = "
- + mAvgShutterToPictureDisplayedTime + "\n");
- out.write("Avg mPictureDisplayedToJpegCallbackTime = "
- + mAvgPictureDisplayedToJpegCallbackTime + "\n");
- out.write("Avg mJpegCallbackFinishTime = " +
- mAvgJpegCallbackFinishTime + "\n");
- out.close();
- fstream.close();
- } catch (Exception e) {
- fail("Camera Latency write output to file");
- }
- Log.v(TAG, "The Image capture wait time = " +
- WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- Log.v(TAG, "Avg AutoFocus = " + mAvgAutoFocusTime);
- Log.v(TAG, "Avg mShutterLag = " + mAvgShutterLag);
- Log.v(TAG, "Avg mShutterToPictureDisplayedTime = "
- + mAvgShutterToPictureDisplayedTime);
- Log.v(TAG, "Avg mPictureDisplayedToJpegCallbackTime = "
- + mAvgPictureDisplayedToJpegCallbackTime);
- Log.v(TAG, "Avg mJpegCallbackFinishTime = " + mAvgJpegCallbackFinishTime);
- }
-}
-
diff --git a/tests_camera/src/com/android/camera/stress/CameraStartUp.java b/tests_camera/src/com/android/camera/stress/CameraStartUp.java
deleted file mode 100644
index 94e9a94..0000000
--- a/tests_camera/src/com/android/camera/stress/CameraStartUp.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera.stress;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-import java.io.FileWriter;
-import java.io.BufferedWriter;
-
-/**
- * Test cases to measure the camera and video recorder startup time.
- */
-public class CameraStartUp extends InstrumentationTestCase {
-
- private static final int TOTAL_NUMBER_OF_STARTUP = 20;
-
- private String TAG = "CameraStartUp";
- private static final String CAMERA_TEST_OUTPUT_FILE =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- private static int WAIT_TIME_FOR_PREVIEW = 1500; //1.5 second
-
- private long launchCamera() {
- long startupTime = 0;
- try {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- long beforeStart = System.currentTimeMillis();
- Instrumentation inst = getInstrumentation();
- Activity cameraActivity = inst.startActivitySync(intent);
- long cameraStarted = System.currentTimeMillis();
- Thread.sleep(WAIT_TIME_FOR_PREVIEW);
- cameraActivity.finish();
- startupTime = cameraStarted - beforeStart;
- Thread.sleep(1000);
- Log.v(TAG, "camera startup time: " + startupTime);
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- fail("Fails to get the output file");
- }
- return startupTime;
- }
-
- private long launchVideo() {
- long startupTime = 0;
-
- try {
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- long beforeStart = System.currentTimeMillis();
- Instrumentation inst = getInstrumentation();
- Activity recorderActivity = inst.startActivitySync(intent);
- long cameraStarted = System.currentTimeMillis();
- recorderActivity.finish();
- startupTime = cameraStarted - beforeStart;
- Log.v(TAG, "Video Startup Time = " + startupTime);
- // wait for 1s to make sure it reach a clean stage
- Thread.sleep(WAIT_TIME_FOR_PREVIEW);
- Log.v(TAG, "video startup time: " + startupTime);
- } catch (Exception e) {
- Log.v(TAG, "Got exception", e);
- fail("Fails to launch video output file");
- }
- return startupTime;
- }
-
- private void writeToOutputFile(long totalStartupTime,
- String individualStartupTime, boolean firstStartUp, String Type) throws Exception {
- // TODO (yslau) : Need to integrate the output data with central
- // dashboard
- try {
- FileWriter fstream = null;
- fstream = new FileWriter(CAMERA_TEST_OUTPUT_FILE, true);
- BufferedWriter out = new BufferedWriter(fstream);
- if (firstStartUp) {
- out.write("First " + Type + " Startup: " + totalStartupTime + "\n");
- } else {
- long averageStartupTime = totalStartupTime / (TOTAL_NUMBER_OF_STARTUP -1);
- out.write(Type + "startup time: " + "\n");
- out.write("Number of loop: " + (TOTAL_NUMBER_OF_STARTUP -1) + "\n");
- out.write(individualStartupTime + "\n\n");
- out.write(Type + " average startup time: " + averageStartupTime + " ms\n\n");
- }
- out.close();
- fstream.close();
- } catch (Exception e) {
- fail("Camera write output to file");
- }
- }
-
- @LargeTest
- public void testLaunchVideo() throws Exception {
- String individualStartupTime;
- individualStartupTime = "Individual Video Startup Time = ";
- long totalStartupTime = 0;
- long startupTime = 0;
- for (int i = 0; i < TOTAL_NUMBER_OF_STARTUP; i++) {
- if (i == 0) {
- // Capture the first startup time individually
- long firstStartUpTime = launchVideo();
- writeToOutputFile(firstStartUpTime, "na", true, "Video");
- } else {
- startupTime = launchVideo();
- totalStartupTime += startupTime;
- individualStartupTime += startupTime + " ,";
- }
- }
- Log.v(TAG, "totalStartupTime =" + totalStartupTime);
- writeToOutputFile(totalStartupTime, individualStartupTime, false, "Video");
- }
-
- @LargeTest
- public void testLaunchCamera() throws Exception {
- String individualStartupTime;
- individualStartupTime = "Individual Camera Startup Time = ";
- long totalStartupTime = 0;
- long startupTime = 0;
- for (int i = 0; i < TOTAL_NUMBER_OF_STARTUP; i++) {
- if (i == 0) {
- // Capture the first startup time individually
- long firstStartUpTime = launchCamera();
- writeToOutputFile(firstStartUpTime, "na", true, "Camera");
- } else {
- startupTime = launchCamera();
- totalStartupTime += startupTime;
- individualStartupTime += startupTime + " ,";
- }
- }
- Log.v(TAG, "totalStartupTime =" + totalStartupTime);
- writeToOutputFile(totalStartupTime,
- individualStartupTime, false, "Camera");
- }
-}
diff --git a/tests_camera/src/com/android/camera/stress/CameraStressTestRunner.java b/tests_camera/src/com/android/camera/stress/CameraStressTestRunner.java
deleted file mode 100755
index 4047da0..0000000
--- a/tests_camera/src/com/android/camera/stress/CameraStressTestRunner.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.stress;
-
-import android.os.Bundle;
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-import junit.framework.TestSuite;
-
-public class CameraStressTestRunner extends InstrumentationTestRunner {
-
- // Default recorder settings
- public static int mVideoDuration = 20000; // set default to 20 seconds
- public static int mVideoIterations = 100; // set default to 100 videos
- public static int mImageIterations = 100; // set default to 100 images
-
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(ImageCapture.class);
- suite.addTestSuite(VideoCapture.class);
- return suite;
- }
-
- @Override
- public ClassLoader getLoader() {
- return CameraStressTestRunner.class.getClassLoader();
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- String video_iterations = (String) icicle.get("video_iterations");
- String image_iterations = (String) icicle.get("image_iterations");
- String video_duration = (String) icicle.get("video_duration");
-
- if ( video_iterations != null ) {
- mVideoIterations = Integer.parseInt(video_iterations);
- }
- if ( image_iterations != null) {
- mImageIterations = Integer.parseInt(image_iterations);
- }
- if ( video_duration != null) {
- mVideoDuration = Integer.parseInt(video_duration);
- }
- }
-}
diff --git a/tests_camera/src/com/android/camera/stress/ImageCapture.java b/tests_camera/src/com/android/camera/stress/ImageCapture.java
deleted file mode 100755
index ad06db1..0000000
--- a/tests_camera/src/com/android/camera/stress/ImageCapture.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera.stress;
-
-import com.android.camera.CameraActivity;
-import com.android.camera.stress.CameraStressTestRunner;
-
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.app.Activity;
-
-/**
- * Junit / Instrumentation test case for camera test
- *
- * Running the test suite:
- *
- * adb shell am instrument \
- * -e class com.android.camera.stress.ImageCapture \
- * -w com.google.android.camera.tests/android.test.InstrumentationTestRunner
- *
- */
-
-public class ImageCapture extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private String TAG = "ImageCapture";
- private static final long WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN = 1500; //1.5 sedconds
- private static final long WAIT_FOR_SWITCH_CAMERA = 3000; //3 seconds
-
- private TestUtil testUtil = new TestUtil();
-
- // Private intent extras.
- private final static String EXTRAS_CAMERA_FACING =
- "android.intent.extras.CAMERA_FACING";
-
- public ImageCapture() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- testUtil.prepareOutputFile();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- testUtil.closeOutputFile();
- super.tearDown();
- }
-
- public void captureImages(String reportTag, Instrumentation inst) {
- int total_num_of_images = CameraStressTestRunner.mImageIterations;
- Log.v(TAG, "no of images = " + total_num_of_images);
-
- //TODO(yslau): Need to integrate the outoput with the central dashboard,
- //write to a txt file as a temp solution
- boolean memoryResult = false;
- KeyEvent focusEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_FOCUS);
-
- try {
- testUtil.writeReportHeader(reportTag, total_num_of_images);
- for (int i = 0; i < total_num_of_images; i++) {
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- inst.sendKeySync(focusEvent);
- inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN);
- testUtil.writeResult(i);
- }
- } catch (Exception e) {
- Log.v(TAG, "Got exception: " + e.toString());
- assertTrue("testImageCapture", false);
- }
- }
-
- @LargeTest
- public void testBackImageCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
- Intent intent = new Intent();
-
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(EXTRAS_CAMERA_FACING,
- android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
- Activity act = inst.startActivitySync(intent);
- Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
- captureImages("Back Camera Image Capture\n", inst);
- act.finish();
- }
-
- @LargeTest
- public void testFrontImageCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
- Intent intent = new Intent();
-
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(EXTRAS_CAMERA_FACING,
- android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
- Activity act = inst.startActivitySync(intent);
- Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
- captureImages("Front Camera Image Capture\n", inst);
- act.finish();
- }
-}
diff --git a/tests_camera/src/com/android/camera/stress/ShotToShotLatency.java b/tests_camera/src/com/android/camera/stress/ShotToShotLatency.java
deleted file mode 100644
index 0c1ef45..0000000
--- a/tests_camera/src/com/android/camera/stress/ShotToShotLatency.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.camera.stress;
-
-import android.app.Instrumentation;
-import android.os.Environment;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-import com.android.camera.CameraActivity;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-
-/**
- * Junit / Instrumentation test case for measuring camera shot to shot latency
- */
-public class ShotToShotLatency extends ActivityInstrumentationTestCase2<CameraActivity> {
- private String TAG = "ShotToShotLatency";
- private static final int TOTAL_NUMBER_OF_SNAPSHOTS = 250;
- private static final long SNAPSHOT_WAIT = 1000;
- private static final String CAMERA_TEST_OUTPUT_FILE =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- private static final String CAMERA_IMAGE_DIRECTORY =
- Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera/";
-
- public ShotToShotLatency() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- getActivity();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- private void cleanupLatencyImages() {
- try {
- File sdcard = new File(CAMERA_IMAGE_DIRECTORY);
- File[] pics = null;
- FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".jpg");
- }
- };
- pics = sdcard.listFiles(filter);
- for (File f : pics) {
- f.delete();
- }
- } catch (SecurityException e) {
- Log.e(TAG, "Security manager access violation: " + e.toString());
- }
- }
-
- private void sleep(long time) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
- Log.e(TAG, "Sleep InterruptedException " + e.toString());
- }
- }
-
- @LargeTest
- public void testShotToShotLatency() {
- long sigmaOfDiffFromMeanSquared = 0;
- double mean = 0;
- double standardDeviation = 0;
- ArrayList<Long> captureTimes = new ArrayList<Long>();
- ArrayList<Long> latencyTimes = new ArrayList<Long>();
-
- Log.v(TAG, "start testShotToShotLatency test");
- Instrumentation inst = getInstrumentation();
-
- // Generate data points
- for (int i = 0; i < TOTAL_NUMBER_OF_SNAPSHOTS; i++) {
- inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
- sleep(SNAPSHOT_WAIT);
- CameraActivity c = getActivity();
- if (c.getCaptureStartTime() > 0) {
- captureTimes.add(c.getCaptureStartTime());
- }
- }
-
- // Calculate latencies
- for (int j = 1; j < captureTimes.size(); j++) {
- latencyTimes.add(captureTimes.get(j) - captureTimes.get(j - 1));
- }
-
- // Crunch numbers
- for (long dataPoint : latencyTimes) {
- mean += (double) dataPoint;
- }
- mean /= latencyTimes.size();
-
- for (long dataPoint : latencyTimes) {
- sigmaOfDiffFromMeanSquared += (dataPoint - mean) * (dataPoint - mean);
- }
- standardDeviation = Math.sqrt(sigmaOfDiffFromMeanSquared / latencyTimes.size());
-
- // Report statistics
- File outFile = new File(CAMERA_TEST_OUTPUT_FILE);
- BufferedWriter output = null;
- try {
- output = new BufferedWriter(new FileWriter(outFile, true));
- output.write("Shot to shot latency - mean: " + mean + "\n");
- output.write("Shot to shot latency - standard deviation: " + standardDeviation + "\n");
- cleanupLatencyImages();
- } catch (IOException e) {
- Log.e(TAG, "testShotToShotLatency IOException writing to log " + e.toString());
- } finally {
- try {
- if (output != null) {
- output.close();
- }
- } catch (IOException e) {
- Log.e(TAG, "Error closing file: " + e.toString());
- }
- }
- }
-}
diff --git a/tests_camera/src/com/android/camera/stress/SwitchPreview.java b/tests_camera/src/com/android/camera/stress/SwitchPreview.java
deleted file mode 100755
index 86b1b5d..0000000
--- a/tests_camera/src/com/android/camera/stress/SwitchPreview.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2009 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.camera.stress;
-
-import com.android.camera.CameraActivity;
-
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.provider.MediaStore;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.os.Environment;
-import android.util.Log;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-
-/**
- * Junit / Instrumentation test case for camera test
- *
- * Running the test suite:
- *
- * adb shell am instrument \
- * -e class com.android.camera.stress.SwitchPreview \
- * -w com.android.camera.tests/com.android.camera.stress.CameraStressTestRunner
- *
- */
-public class SwitchPreview extends ActivityInstrumentationTestCase2 <CameraActivity>{
- private String TAG = "SwitchPreview";
- private static final int TOTAL_NUMBER_OF_SWITCHING = 200;
- private static final long WAIT_FOR_PREVIEW = 4000;
-
- private static final String CAMERA_TEST_OUTPUT_FILE =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- private BufferedWriter mOut;
- private FileWriter mfstream;
-
- public SwitchPreview() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- getActivity();
- prepareOutputFile();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- getActivity().finish();
- closeOutputFile();
- super.tearDown();
- }
-
- private void prepareOutputFile(){
- try{
- mfstream = new FileWriter(CAMERA_TEST_OUTPUT_FILE, true);
- mOut = new BufferedWriter(mfstream);
- } catch (Exception e){
- assertTrue("Camera Switch Mode", false);
- }
- }
-
- private void closeOutputFile() {
- try {
- mOut.write("\n");
- mOut.close();
- mfstream.close();
- } catch (Exception e) {
- assertTrue("CameraSwitchMode close output", false);
- }
- }
-
- @LargeTest
- public void testSwitchMode() {
- //Switching the video and the video recorder mode
- Instrumentation inst = getInstrumentation();
- try{
- mOut.write("Camera Switch Mode:\n");
- mOut.write("No of loops :" + TOTAL_NUMBER_OF_SWITCHING + "\n");
- mOut.write("loop: ");
- for (int i=0; i< TOTAL_NUMBER_OF_SWITCHING; i++) {
- Thread.sleep(WAIT_FOR_PREVIEW);
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.setClass(getInstrumentation().getTargetContext(),
- CameraActivity.class);
- getActivity().startActivity(intent);
- Thread.sleep(WAIT_FOR_PREVIEW);
- intent = new Intent();
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.setClass(getInstrumentation().getTargetContext(),
- CameraActivity.class);
- getActivity().startActivity(intent);
- mOut.write(" ," + i);
- mOut.flush();
- }
- } catch (Exception e){
- Log.v(TAG, "Got exception", e);
- }
- }
-}
diff --git a/tests_camera/src/com/android/camera/stress/TestUtil.java b/tests_camera/src/com/android/camera/stress/TestUtil.java
deleted file mode 100644
index 64e2039..0000000
--- a/tests_camera/src/com/android/camera/stress/TestUtil.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 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.camera.stress;
-
-import android.os.Environment;
-import java.io.FileWriter;
-import java.io.BufferedWriter;
-
-
-/**
- * Collection of utility functions used for the test.
- */
-public class TestUtil {
- public BufferedWriter mOut;
- public FileWriter mfstream;
-
- public TestUtil() {
- }
-
- public void prepareOutputFile() throws Exception {
- String camera_test_output_file =
- Environment.getExternalStorageDirectory().toString() + "/mediaStressOut.txt";
- mfstream = new FileWriter(camera_test_output_file, true);
- mOut = new BufferedWriter(mfstream);
- }
-
- public void closeOutputFile() throws Exception {
- mOut.write("\n");
- mOut.close();
- mfstream.close();
- }
-
- public void writeReportHeader(String reportTag, int iteration) throws Exception {
- mOut.write(reportTag);
- mOut.write("No of loops :" + iteration + "\n");
- mOut.write("loop: ");
- }
-
- public void writeResult(int iteration) throws Exception {
- mOut.write(" ," + iteration);
- mOut.flush();
- }
-}
diff --git a/tests_camera/src/com/android/camera/stress/VideoCapture.java b/tests_camera/src/com/android/camera/stress/VideoCapture.java
deleted file mode 100755
index ec55ccc..0000000
--- a/tests_camera/src/com/android/camera/stress/VideoCapture.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.stress;
-
-import com.android.camera.CameraActivity;
-import com.android.camera.stress.TestUtil;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.provider.MediaStore;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.KeyEvent;
-
-import com.android.camera.stress.CameraStressTestRunner;
-
-/**
- * Junit / Instrumentation test case for camera test
- *
- * Running the test suite:
- *
- * adb shell am instrument \
- * -e class com.android.camera.stress.VideoCapture \
- * -w com.google.android.camera.tests/android.test.InstrumentationTestRunner
- *
- */
-
-public class VideoCapture extends ActivityInstrumentationTestCase2 <CameraActivity> {
- private static final long WAIT_FOR_PREVIEW = 1500; //1.5 seconds
- private static final long WAIT_FOR_SWITCH_CAMERA = 3000; //2 seconds
-
- // Private intent extras which control the camera facing.
- private final static String EXTRAS_CAMERA_FACING =
- "android.intent.extras.CAMERA_FACING";
-
- private TestUtil testUtil = new TestUtil();
-
- public VideoCapture() {
- super(CameraActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- testUtil.prepareOutputFile();
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- testUtil.closeOutputFile();
- super.tearDown();
- }
-
- @LargeTest
- public void captureVideos(String reportTag, Instrumentation inst) throws Exception{
- boolean memoryResult = false;
- int total_num_of_videos = CameraStressTestRunner.mVideoIterations;
- int video_duration = CameraStressTestRunner.mVideoDuration;
- testUtil.writeReportHeader(reportTag, total_num_of_videos);
-
- for (int i = 0; i < total_num_of_videos; i++) {
- Thread.sleep(WAIT_FOR_PREVIEW);
- // record a video
- inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(video_duration);
- inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- testUtil.writeResult(i);
- }
- }
-
- @LargeTest
- public void testBackVideoCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
-
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(EXTRAS_CAMERA_FACING,
- android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
- Activity act = inst.startActivitySync(intent);
- Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
- captureVideos("Back Camera Video Capture\n", inst);
- act.finish();
- }
-
- @LargeTest
- public void testFrontVideoCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
- Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
-
- intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(EXTRAS_CAMERA_FACING,
- android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT);
- Activity act = inst.startActivitySync(intent);
- Thread.sleep(WAIT_FOR_SWITCH_CAMERA);
- captureVideos("Front Camera Video Capture\n", inst);
- act.finish();
- }
-}
diff --git a/tests_camera/src/com/android/camera/unittest/CameraUnitTest.java b/tests_camera/src/com/android/camera/unittest/CameraUnitTest.java
deleted file mode 100644
index 0b4fc80..0000000
--- a/tests_camera/src/com/android/camera/unittest/CameraUnitTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2010 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.camera.unittest;
-
-import com.android.camera.Util;
-
-import android.graphics.Matrix;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import junit.framework.TestCase;
-
-@SmallTest
-public class CameraUnitTest extends TestCase {
- public void testRoundOrientation() {
- int h = Util.ORIENTATION_HYSTERESIS;
- assertEquals(0, Util.roundOrientation(0, 0));
- assertEquals(0, Util.roundOrientation(359, 0));
- assertEquals(0, Util.roundOrientation(0 + 44 + h, 0));
- assertEquals(90, Util.roundOrientation(0 + 45 + h, 0));
- assertEquals(0, Util.roundOrientation(360 - 44 - h, 0));
- assertEquals(270, Util.roundOrientation(360 - 45 - h, 0));
-
- assertEquals(90, Util.roundOrientation(90, 90));
- assertEquals(90, Util.roundOrientation(90 + 44 + h, 90));
- assertEquals(180, Util.roundOrientation(90 + 45 + h, 90));
- assertEquals(90, Util.roundOrientation(90 - 44 - h, 90));
- assertEquals(0, Util.roundOrientation(90 - 45 - h, 90));
-
- assertEquals(180, Util.roundOrientation(180, 180));
- assertEquals(180, Util.roundOrientation(180 + 44 + h, 180));
- assertEquals(270, Util.roundOrientation(180 + 45 + h, 180));
- assertEquals(180, Util.roundOrientation(180 - 44 - h, 180));
- assertEquals(90, Util.roundOrientation(180 - 45 - h, 180));
-
- assertEquals(270, Util.roundOrientation(270, 270));
- assertEquals(270, Util.roundOrientation(270 + 44 + h, 270));
- assertEquals(0, Util.roundOrientation(270 + 45 + h, 270));
- assertEquals(270, Util.roundOrientation(270 - 44 - h, 270));
- assertEquals(180, Util.roundOrientation(270 - 45 - h, 270));
-
- assertEquals(90, Util.roundOrientation(90, 0));
- assertEquals(180, Util.roundOrientation(180, 0));
- assertEquals(270, Util.roundOrientation(270, 0));
-
- assertEquals(0, Util.roundOrientation(0, 90));
- assertEquals(180, Util.roundOrientation(180, 90));
- assertEquals(270, Util.roundOrientation(270, 90));
-
- assertEquals(0, Util.roundOrientation(0, 180));
- assertEquals(90, Util.roundOrientation(90, 180));
- assertEquals(270, Util.roundOrientation(270, 180));
-
- assertEquals(0, Util.roundOrientation(0, 270));
- assertEquals(90, Util.roundOrientation(90, 270));
- assertEquals(180, Util.roundOrientation(180, 270));
- }
-
- public void testPrepareMatrix() {
- Matrix matrix = new Matrix();
- float[] points;
- int[] expected;
-
- Util.prepareMatrix(matrix, false, 0, 800, 480);
- points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250};
- expected = new int[] {0, 0, 400, 240, 800, 480, 400, 480, 100, 300};
- matrix.mapPoints(points);
- assertEquals(expected, points);
-
- Util.prepareMatrix(matrix, false, 90, 800, 480);
- points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250};
- expected = new int[] {800, 0, 400, 240, 0, 480, 0, 240, 300, 60};
- matrix.mapPoints(points);
- assertEquals(expected, points);
-
- Util.prepareMatrix(matrix, false, 180, 800, 480);
- points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250};
- expected = new int[] {800, 480, 400, 240, 0, 0, 400, 0, 700, 180};
- matrix.mapPoints(points);
- assertEquals(expected, points);
-
- Util.prepareMatrix(matrix, true, 180, 800, 480);
- points = new float[] {-1000, -1000, 0, 0, 1000, 1000, 0, 1000, -750, 250};
- expected = new int[] {0, 480, 400, 240, 800, 0, 400, 0, 100, 180};
- matrix.mapPoints(points);
- assertEquals(expected, points);
- }
-
- private void assertEquals(int expected[], float[] actual) {
- for (int i = 0; i < expected.length; i++) {
- assertEquals("Array index " + i + " mismatch", expected[i], Math.round(actual[i]));
- }
- }
-}