You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/23 20:56:15 UTC
[01/16] git commit: Add NOTICE file
Repository: cordova-plugin-camera
Updated Branches:
refs/heads/master 552b80634 -> b76b5ae67
Add NOTICE file
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/61a963d6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/61a963d6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/61a963d6
Branch: refs/heads/master
Commit: 61a963d6fb6e4540253af1f2219db6556824af3c
Parents: 3be1802
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Feb 27 15:36:31 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Feb 27 15:36:55 2014 -0500
----------------------------------------------------------------------
NOTICE | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/61a963d6/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..8ec56a5
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,5 @@
+Apache Cordova
+Copyright 2012 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
[16/16] git commit: CB-6452 Updated version and RELEASENOTES.md for
release 0.2.9
Posted by ia...@apache.org.
CB-6452 Updated version and RELEASENOTES.md for release 0.2.9
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/b76b5ae6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/b76b5ae6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/b76b5ae6
Branch: refs/heads/master
Commit: b76b5ae670bdff4dd4c716e889ab12e049f9c733
Parents: f2a41e4
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Apr 17 10:53:20 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Apr 17 10:53:20 2014 -0400
----------------------------------------------------------------------
RELEASENOTES.md | 9 +++++++++
plugin.xml | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/b76b5ae6/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 531019e..836bc27 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -71,3 +71,12 @@
### 0.2.8 (Feb 26, 2014)
* CB-1826 Catch OOM on gallery image resize
+
+### 0.2.9 (Apr 17, 2014)
+* CB-6460: Update license headers
+* CB-6422: [windows8] use cordova/exec/proxy
+* [WP8] When only targetWidth or targetHeight is provided, use it as the only bound
+* CB-4027, CB-5102, CB-2737, CB-2387: [WP] Fix camera issues, cropping, memory leaks
+* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
+* [BlackBerry10] Add rim xml namespaces declaration
+* Add NOTICE file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/b76b5ae6/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index b9f1b02..252fc3e 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -22,7 +22,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:rim="http://www.blackberry.com/ns/widgets"
id="org.apache.cordova.camera"
- version="0.2.9-dev">
+ version="0.2.9">
<name>Camera</name>
<description>Cordova Camera Plugin</description>
<license>Apache 2.0</license>
[11/16] git commit: cleanup, finalize implementations/consolidations
Posted by ia...@apache.org.
cleanup, finalize implementations/consolidations
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/ae2acd9a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/ae2acd9a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/ae2acd9a
Branch: refs/heads/master
Commit: ae2acd9ab237df976bd90c3da2fcf0498b027935
Parents: f6e8548
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Apr 7 18:13:57 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Apr 7 18:13:57 2014 -0700
----------------------------------------------------------------------
src/wp/Camera.cs | 252 ++++++++++++--------------------------------------
1 file changed, 58 insertions(+), 194 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/ae2acd9a/src/wp/Camera.cs
----------------------------------------------------------------------
diff --git a/src/wp/Camera.cs b/src/wp/Camera.cs
index c9f6f78..977634b 100644
--- a/src/wp/Camera.cs
+++ b/src/wp/Camera.cs
@@ -204,27 +204,32 @@ namespace WPCordovaClassLib.Cordova.Commands
return;
}
- //TODO Check if all the options are acceptable
-
+ if(cameraOptions.DestinationType != Camera.FILE_URI && cameraOptions.DestinationType != Camera.DATA_URL )
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
+ return;
+ }
+ ChooserBase<PhotoResult> chooserTask = null;
if (cameraOptions.PictureSourceType == CAMERA)
{
- CameraCaptureTask cameraTask = new CameraCaptureTask();
- cameraTask.Completed += onCameraTaskCompleted;
- cameraTask.Show();
+ chooserTask = new CameraCaptureTask();
}
else if ((cameraOptions.PictureSourceType == PHOTOLIBRARY) || (cameraOptions.PictureSourceType == SAVEDPHOTOALBUM))
{
- PhotoChooserTask photoChooserTask = new PhotoChooserTask();
- photoChooserTask.Completed += onPickerTaskCompleted;
- photoChooserTask.Show();
+ chooserTask = new PhotoChooserTask();
+ }
+ // if chooserTask is still null, then PictureSourceType was invalid
+ if (chooserTask != null)
+ {
+ chooserTask.Completed += onTaskCompleted;
+ chooserTask.Show();
}
else
{
+ Debug.WriteLine("Unrecognized PictureSourceType :: " + cameraOptions.PictureSourceType.ToString());
DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
}
-
-
}
public void onTaskCompleted(object sender, PhotoResult e)
@@ -232,7 +237,7 @@ namespace WPCordovaClassLib.Cordova.Commands
var task = sender as ChooserBase<PhotoResult>;
if (task != null)
{
- task.Completed -= onCameraTaskCompleted;
+ task.Completed -= onTaskCompleted;
}
if (e.Error != null)
@@ -247,217 +252,76 @@ namespace WPCordovaClassLib.Cordova.Commands
try
{
string imagePathOrContent = string.Empty;
- if (cameraOptions.DestinationType == FILE_URI)
- {
- // Save image in media library
- if (cameraOptions.SaveToPhotoAlbum)
- {
- MediaLibrary library = new MediaLibrary();
- Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ...
- }
-
- /*
- int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
- int newAngle = 0;
- switch (orient)
- {
- case ImageExifOrientation.LandscapeLeft:
- newAngle = 90;
- break;
- case ImageExifOrientation.PortraitUpsideDown:
- newAngle = 180;
- break;
- case ImageExifOrientation.LandscapeRight:
- newAngle = 270;
- break;
- case ImageExifOrientation.Portrait:
- default: break; // 0 default already set
- }
-
- Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle);
-
- // we should reset stream position after saving stream to media library
- rotImageStream.Seek(0, SeekOrigin.Begin);
- imagePathOrContent = SaveImageToLocalStorage(rotImageStream, Path.GetFileName(e.OriginalFileName));
- */
-
-
- imagePathOrContent = SaveImageToLocalStorage(e.ChosenPhoto, Path.GetFileName(e.OriginalFileName));
- }
- else if (cameraOptions.DestinationType == DATA_URL)
+ // Save image back to media library
+ // only save to photoalbum if it didn't come from there ...
+ if (cameraOptions.PictureSourceType == CAMERA && cameraOptions.SaveToPhotoAlbum)
{
- imagePathOrContent = GetImageContent(e.ChosenPhoto);
+ MediaLibrary library = new MediaLibrary();
+ Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ...
}
- else
+
+ int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
+ int newAngle = 270;
+ switch (orient)
{
- // TODO: shouldn't this happen before we launch the camera-picker?
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
- return;
+ case ImageExifOrientation.LandscapeLeft:
+ newAngle = 90;
+ break;
+ case ImageExifOrientation.PortraitUpsideDown:
+ newAngle = 180;
+ break;
+ case ImageExifOrientation.LandscapeRight:
+ newAngle = 270;
+ break;
+ case ImageExifOrientation.Portrait:
+ default: break; // 0 default already set
}
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent));
-
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image."));
- }
- break;
-
- case TaskResult.Cancel:
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled."));
- break;
- default:
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!"));
- break;
- }
-
-
- }
-
- public void onCameraTaskCompleted(object sender, PhotoResult e)
- {
- var task = sender as ChooserBase<PhotoResult>;
- if (task != null)
- {
- task.Completed -= onCameraTaskCompleted;
- }
-
- if (e.Error != null)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
- return;
- }
-
- switch (e.TaskResult)
- {
- case TaskResult.OK:
- try
- {
- string imagePathOrContent = string.Empty;
-
- if (cameraOptions.DestinationType == FILE_URI)
+ if (newAngle != 0)
{
- // Save image in media library
- if (cameraOptions.SaveToPhotoAlbum)
+ using (Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle))
{
- MediaLibrary library = new MediaLibrary();
- Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ...
+ // we should reset stream position after saving stream to media library
+ rotImageStream.Seek(0, SeekOrigin.Begin);
+ if (cameraOptions.DestinationType == DATA_URL)
+ {
+ imagePathOrContent = GetImageContent(rotImageStream);
+ }
+ else // FILE_URL
+ {
+ imagePathOrContent = SaveImageToLocalStorage(rotImageStream, Path.GetFileName(e.OriginalFileName));
+ }
}
-
- int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
- int newAngle = 0;
- switch (orient)
- {
- case ImageExifOrientation.LandscapeLeft:
- newAngle = 90;
- break;
- case ImageExifOrientation.PortraitUpsideDown:
- newAngle = 180;
- break;
- case ImageExifOrientation.LandscapeRight:
- newAngle = 270;
- break;
- case ImageExifOrientation.Portrait:
- default: break; // 0 default already set
- }
-
- Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle);
-
- // we should return stream position back after saving stream to media library
- rotImageStream.Seek(0, SeekOrigin.Begin);
- imagePathOrContent = SaveImageToLocalStorage(rotImageStream, Path.GetFileName(e.OriginalFileName));
-
-
- }
- else if (cameraOptions.DestinationType == DATA_URL)
- {
- imagePathOrContent = GetImageContent(e.ChosenPhoto);
- }
- else
- {
- // TODO: shouldn't this happen before we launch the camera-picker?
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
- return;
- }
-
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent));
-
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image."));
- }
- break;
-
- case TaskResult.Cancel:
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled."));
- break;
-
- default:
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!"));
- break;
- }
-
- }
-
- public void onPickerTaskCompleted(object sender, PhotoResult e)
- {
- var task = sender as ChooserBase<PhotoResult>;
- if (task != null)
- {
- task.Completed -= onCameraTaskCompleted;
- }
-
- if (e.Error != null)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
- return;
- }
-
- switch (e.TaskResult)
- {
- case TaskResult.OK:
- try
- {
- string imagePathOrContent = string.Empty;
-
- if (cameraOptions.DestinationType == FILE_URI)
- {
- imagePathOrContent = SaveImageToLocalStorage(e.ChosenPhoto, Path.GetFileName(e.OriginalFileName));
- }
- else if (cameraOptions.DestinationType == DATA_URL)
- {
- imagePathOrContent = GetImageContent(e.ChosenPhoto);
-
}
- else
+ else // no need to reorient
{
- // TODO: shouldn't this happen before we launch the camera-picker?
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
- return;
+ if (cameraOptions.DestinationType == DATA_URL)
+ {
+ imagePathOrContent = GetImageContent(e.ChosenPhoto);
+ }
+ else // FILE_URL
+ {
+ imagePathOrContent = SaveImageToLocalStorage(e.ChosenPhoto, Path.GetFileName(e.OriginalFileName));
+ }
}
DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent));
-
}
catch (Exception)
{
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image."));
}
break;
-
case TaskResult.Cancel:
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled."));
break;
-
default:
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!"));
break;
}
}
-
+
/// <summary>
/// Returns image content in a form of base64 string
/// </summary>
[08/16] git commit: CB-6212 iOS: fix warnings compiled under arm64
64-bit
Posted by ia...@apache.org.
CB-6212 iOS: fix warnings compiled under arm64 64-bit
-one update to CDVCamera.m
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/91d6e10b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/91d6e10b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/91d6e10b
Branch: refs/heads/master
Commit: 91d6e10b29e492d8d72a2d5c759ebf7b876ecc3b
Parents: 6fb63fe
Author: James Jong <wj...@gmail.com>
Authored: Thu Mar 13 10:16:30 2014 -0400
Committer: James Jong <wj...@gmail.com>
Committed: Thu Mar 13 10:16:30 2014 -0400
----------------------------------------------------------------------
src/ios/CDVCamera.m | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/91d6e10b/src/ios/CDVCamera.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVCamera.m b/src/ios/CDVCamera.m
index 8413ac5..9981747 100644
--- a/src/ios/CDVCamera.m
+++ b/src/ios/CDVCamera.m
@@ -84,7 +84,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
bool hasCamera = [UIImagePickerController isSourceTypeAvailable:sourceType];
if (!hasCamera) {
- NSLog(@"Camera.getPicture: source type %ld not available.", sourceType);
+ NSLog(@"Camera.getPicture: source type %lu not available.", (unsigned long)sourceType);
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no camera available"];
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
return;
[03/16] git commit: CB-6114 Updated version and RELEASENOTES.md for
release 0.2.8
Posted by ia...@apache.org.
CB-6114 Updated version and RELEASENOTES.md for release 0.2.8
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/19a44608
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/19a44608
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/19a44608
Branch: refs/heads/master
Commit: 19a44608b84966df1cf1a32df46a157e44bfffc0
Parents: f3a704b
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Feb 27 11:56:29 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Feb 27 15:36:55 2014 -0500
----------------------------------------------------------------------
RELEASENOTES.md | 3 +++
plugin.xml | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/19a44608/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 91cabf2..531019e 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -68,3 +68,6 @@
* Documented quirk for CB-5335 + CB-5206 for WP7+8
* reference the correct firefoxos implementation
* [BlackBerry10] Add permission to access_shared
+
+### 0.2.8 (Feb 26, 2014)
+* CB-1826 Catch OOM on gallery image resize
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/19a44608/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 7233291..b2db93e 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -3,7 +3,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="org.apache.cordova.camera"
- version="0.2.8-dev">
+ version="0.2.8">
<name>Camera</name>
<description>Cordova Camera Plugin</description>
<license>Apache 2.0</license>
[15/16] git commit: CB-6460: Update license headers
Posted by ia...@apache.org.
CB-6460: Update license headers
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/f2a41e4b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/f2a41e4b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/f2a41e4b
Branch: refs/heads/master
Commit: f2a41e4b5e5de71ac62803bf371ad2bcd7e901f3
Parents: 85a986f
Author: Ian Clelland <ic...@chromium.org>
Authored: Wed Apr 16 16:15:25 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Apr 16 16:15:25 2014 -0400
----------------------------------------------------------------------
plugin.xml | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/f2a41e4b/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index de07a06..b9f1b02 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
[05/16] git commit: Add rim xml namespaces declaration
Posted by ia...@apache.org.
Add rim xml namespaces declaration
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/5393a281
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/5393a281
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/5393a281
Branch: refs/heads/master
Commit: 5393a28191e8f53fb073f05c40a6133f68685274
Parents: 2a75201
Author: Ryan Willoughby <ry...@nitobi.com>
Authored: Thu Mar 6 13:50:49 2014 -0800
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Wed Mar 12 12:47:24 2014 -0400
----------------------------------------------------------------------
plugin.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/5393a281/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 4b89899..de07a06 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -2,6 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
id="org.apache.cordova.camera"
version="0.2.9-dev">
<name>Camera</name>
[07/16] git commit: Fix typo error in docs
Posted by ia...@apache.org.
Fix typo error in docs
from libarary to library
github: close #18
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/6fb63fed
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/6fb63fed
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/6fb63fed
Branch: refs/heads/master
Commit: 6fb63fede54e4f5defe45d3bf8a6945fbd8ff352
Parents: c9bab1f
Author: Long Nguyen <ol...@gmail.com>
Authored: Thu Mar 13 15:29:38 2014 +0700
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Thu Mar 13 09:59:53 2014 -0400
----------------------------------------------------------------------
doc/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/6fb63fed/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index c36d6cb..edd881f 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -20,7 +20,7 @@
# org.apache.cordova.camera
This plugin provides an API for taking pictures and for choosing images from
-the system's image libarary.
+the system's image library.
cordova plugin add org.apache.cordova.camera
[02/16] git commit: CB-6114 Incremented plugin version on dev branch.
Posted by ia...@apache.org.
CB-6114 Incremented plugin version on dev branch.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/3be1802c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/3be1802c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/3be1802c
Branch: refs/heads/master
Commit: 3be1802c9e5474b9e36d4dbc66ccb42648ff2a43
Parents: 19a4460
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Feb 27 12:29:15 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Feb 27 15:36:55 2014 -0500
----------------------------------------------------------------------
plugin.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/3be1802c/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index b2db93e..4b89899 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -3,7 +3,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="org.apache.cordova.camera"
- version="0.2.8">
+ version="0.2.9-dev">
<name>Camera</name>
<description>Cordova Camera Plugin</description>
<license>Apache 2.0</license>
[04/16] git commit: Merge branch 'master' into dev
Posted by ia...@apache.org.
Merge branch 'master' into dev
Conflicts:
plugin.xml
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/2a752011
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/2a752011
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/2a752011
Branch: refs/heads/master
Commit: 2a7520112e6dec287b864861f695f3f3d9c47bfb
Parents: 61a963d 552b806
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Feb 27 16:03:32 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Feb 27 16:03:32 2014 -0500
----------------------------------------------------------------------
----------------------------------------------------------------------
[10/16] git commit: combining callbacks, removing lots of dupe code
Posted by ia...@apache.org.
combining callbacks, removing lots of dupe code
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/f6e85483
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/f6e85483
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/f6e85483
Branch: refs/heads/master
Commit: f6e8548381db0e7e4b7d6e095c6718313a001edf
Parents: e7a3d70
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Apr 7 16:32:21 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Apr 7 16:32:21 2014 -0700
----------------------------------------------------------------------
src/wp/Camera.cs | 99 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 94 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/f6e85483/src/wp/Camera.cs
----------------------------------------------------------------------
diff --git a/src/wp/Camera.cs b/src/wp/Camera.cs
index 53ae61a..c9f6f78 100644
--- a/src/wp/Camera.cs
+++ b/src/wp/Camera.cs
@@ -200,7 +200,7 @@ namespace WPCordovaClassLib.Cordova.Commands
}
catch (Exception ex)
{
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
return;
}
@@ -227,6 +227,95 @@ namespace WPCordovaClassLib.Cordova.Commands
}
+ public void onTaskCompleted(object sender, PhotoResult e)
+ {
+ var task = sender as ChooserBase<PhotoResult>;
+ if (task != null)
+ {
+ task.Completed -= onCameraTaskCompleted;
+ }
+
+ if (e.Error != null)
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
+ return;
+ }
+
+ switch (e.TaskResult)
+ {
+ case TaskResult.OK:
+ try
+ {
+ string imagePathOrContent = string.Empty;
+ if (cameraOptions.DestinationType == FILE_URI)
+ {
+ // Save image in media library
+ if (cameraOptions.SaveToPhotoAlbum)
+ {
+ MediaLibrary library = new MediaLibrary();
+ Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ...
+ }
+
+ /*
+ int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
+ int newAngle = 0;
+ switch (orient)
+ {
+ case ImageExifOrientation.LandscapeLeft:
+ newAngle = 90;
+ break;
+ case ImageExifOrientation.PortraitUpsideDown:
+ newAngle = 180;
+ break;
+ case ImageExifOrientation.LandscapeRight:
+ newAngle = 270;
+ break;
+ case ImageExifOrientation.Portrait:
+ default: break; // 0 default already set
+ }
+
+ Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle);
+
+ // we should reset stream position after saving stream to media library
+ rotImageStream.Seek(0, SeekOrigin.Begin);
+ imagePathOrContent = SaveImageToLocalStorage(rotImageStream, Path.GetFileName(e.OriginalFileName));
+
+ */
+
+
+ imagePathOrContent = SaveImageToLocalStorage(e.ChosenPhoto, Path.GetFileName(e.OriginalFileName));
+ }
+ else if (cameraOptions.DestinationType == DATA_URL)
+ {
+ imagePathOrContent = GetImageContent(e.ChosenPhoto);
+ }
+ else
+ {
+ // TODO: shouldn't this happen before we launch the camera-picker?
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Incorrect option: destinationType"));
+ return;
+ }
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, imagePathOrContent));
+
+ }
+ catch (Exception)
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error retrieving image."));
+ }
+ break;
+
+ case TaskResult.Cancel:
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection cancelled."));
+ break;
+
+ default:
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Selection did not complete!"));
+ break;
+ }
+
+
+ }
+
public void onCameraTaskCompleted(object sender, PhotoResult e)
{
var task = sender as ChooserBase<PhotoResult>;
@@ -278,13 +367,13 @@ namespace WPCordovaClassLib.Cordova.Commands
// we should return stream position back after saving stream to media library
rotImageStream.Seek(0, SeekOrigin.Begin);
- imagePathOrContent = this.SaveImageToLocalStorage(rotImageStream, Path.GetFileName(e.OriginalFileName));
+ imagePathOrContent = SaveImageToLocalStorage(rotImageStream, Path.GetFileName(e.OriginalFileName));
}
else if (cameraOptions.DestinationType == DATA_URL)
{
- imagePathOrContent = this.GetImageContent(e.ChosenPhoto);
+ imagePathOrContent = GetImageContent(e.ChosenPhoto);
}
else
{
@@ -336,11 +425,11 @@ namespace WPCordovaClassLib.Cordova.Commands
if (cameraOptions.DestinationType == FILE_URI)
{
- imagePathOrContent = this.SaveImageToLocalStorage(e.ChosenPhoto, Path.GetFileName(e.OriginalFileName));
+ imagePathOrContent = SaveImageToLocalStorage(e.ChosenPhoto, Path.GetFileName(e.OriginalFileName));
}
else if (cameraOptions.DestinationType == DATA_URL)
{
- imagePathOrContent = this.GetImageContent(e.ChosenPhoto);
+ imagePathOrContent = GetImageContent(e.ChosenPhoto);
}
else
[06/16] git commit: CB-6212 iOS: fix warnings compiled under arm64
64-bit
Posted by ia...@apache.org.
CB-6212 iOS: fix warnings compiled under arm64 64-bit
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/c9bab1f9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/c9bab1f9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/c9bab1f9
Branch: refs/heads/master
Commit: c9bab1f94c89e53c0ad8dbc77e1027eaa89527f1
Parents: 5393a28
Author: James Jong <wj...@gmail.com>
Authored: Thu Mar 13 09:51:47 2014 -0400
Committer: James Jong <wj...@gmail.com>
Committed: Thu Mar 13 09:51:47 2014 -0400
----------------------------------------------------------------------
src/ios/CDVCamera.m | 12 ++++++------
src/ios/CDVJpegHeaderWriter.m | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/c9bab1f9/src/ios/CDVCamera.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVCamera.m b/src/ios/CDVCamera.m
index 42c5237..8413ac5 100644
--- a/src/ios/CDVCamera.m
+++ b/src/ios/CDVCamera.m
@@ -84,7 +84,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
bool hasCamera = [UIImagePickerController isSourceTypeAvailable:sourceType];
if (!hasCamera) {
- NSLog(@"Camera.getPicture: source type %d not available.", sourceType);
+ NSLog(@"Camera.getPicture: source type %ld not available.", sourceType);
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no camera available"];
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
return;
@@ -170,10 +170,10 @@ static NSSet* org_apache_cordova_validArrowDirections;
- (void)displayPopover:(NSDictionary*)options
{
- int x = 0;
- int y = 32;
- int width = 320;
- int height = 480;
+ NSInteger x = 0;
+ NSInteger y = 32;
+ NSInteger width = 320;
+ NSInteger height = 480;
UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirectionAny;
if (options) {
@@ -182,7 +182,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
width = [options integerValueForKey:@"width" defaultValue:320];
height = [options integerValueForKey:@"height" defaultValue:480];
arrowDirection = [options integerValueForKey:@"arrowDir" defaultValue:UIPopoverArrowDirectionAny];
- if (![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithInt:arrowDirection]]) {
+ if (![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithUnsignedInteger:arrowDirection]]) {
arrowDirection = UIPopoverArrowDirectionAny;
}
}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/c9bab1f9/src/ios/CDVJpegHeaderWriter.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVJpegHeaderWriter.m b/src/ios/CDVJpegHeaderWriter.m
index 93cafb8..4d3ea24 100644
--- a/src/ios/CDVJpegHeaderWriter.m
+++ b/src/ios/CDVJpegHeaderWriter.m
@@ -190,7 +190,7 @@ const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a
// construct the complete app1 data block
app1 = [[NSMutableString alloc] initWithFormat: @"%@%04x%@%@%@%@%@",
app1marker,
- 16 + ([exifIFD length]/2) + ([subExifIFD length]/2) /*16+[exifIFD length]/2*/,
+ (unsigned int)(16 + ([exifIFD length]/2) + ([subExifIFD length]/2)) /*16+[exifIFD length]/2*/,
exifmarker,
tiffheader,
ifd0offset,
@@ -268,10 +268,10 @@ const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a
}
// calculate IFD0 terminal offset tags, currently ExifSubIFD
- int entrycount = [ifdblock count];
+ unsigned int entrycount = (unsigned int)[ifdblock count];
if (ifd0flag) {
// 18 accounts for 8769's width + offset to next ifd, 8 accounts for start of header
- NSNumber * offset = [NSNumber numberWithInt:[exifstr length] / 2 + [dbstr length] / 2 + 18+8];
+ NSNumber * offset = [NSNumber numberWithUnsignedInteger:[exifstr length] / 2 + [dbstr length] / 2 + 18+8];
[self appendExifOffsetTagTo: exifstr
withOffset : offset];
@@ -293,7 +293,7 @@ const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a
NSNumber * dataformat = [formtemplate objectAtIndex:1];
NSNumber * components = [formtemplate objectAtIndex:2];
if([components intValue] == 0) {
- components = [NSNumber numberWithInt: [data length] * DataTypeToWidth[[dataformat intValue]-1]];
+ components = [NSNumber numberWithUnsignedInteger:[data length] * DataTypeToWidth[[dataformat intValue]-1]];
}
return [[NSString alloc] initWithFormat: @"%@%@%08x",
@@ -344,7 +344,7 @@ const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a
[datastr appendString:[dataformat objectAtIndex:3]];
}
if ([datastr length] < 8) {
- NSString * format = [NSString stringWithFormat:@"%%0%dd", 8 - [datastr length]];
+ NSString * format = [NSString stringWithFormat:@"%%0%dd", (int)(8 - [datastr length])];
[datastr appendFormat:format,0];
}
return datastr;
@@ -464,7 +464,7 @@ const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a
-(void) expandContinuedFraction: (NSArray*) fractionlist
withResultNumerator: (NSNumber**) numerator
withResultDenominator: (NSNumber**) denominator {
- int i = 0;
+ NSUInteger i = 0;
int den = 0;
int num = 0;
if ([fractionlist count] == 1) {
[09/16] git commit: Fix camera issues, cropping, memory leaks CB-4027,
CB-5102, CB-2737, CB-2387
Posted by ia...@apache.org.
Fix camera issues, cropping, memory leaks CB-4027, CB-5102, CB-2737, CB-2387
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/e7a3d70f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/e7a3d70f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/e7a3d70f
Branch: refs/heads/master
Commit: e7a3d70fe969f75b795ca216dd9173f8df1635ee
Parents: 91d6e10
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Apr 7 15:00:12 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Apr 7 15:00:12 2014 -0700
----------------------------------------------------------------------
src/wp/Camera.cs | 228 ++++++++++++++++++++++++++++++++------------------
1 file changed, 145 insertions(+), 83 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/e7a3d70f/src/wp/Camera.cs
----------------------------------------------------------------------
diff --git a/src/wp/Camera.cs b/src/wp/Camera.cs
index 5ff8045..53ae61a 100644
--- a/src/wp/Camera.cs
+++ b/src/wp/Camera.cs
@@ -113,8 +113,6 @@ namespace WPCordovaClassLib.Cordova.Commands
[DataMember(IsRequired = false, Name = "correctOrientation")]
public bool CorrectOrientation { get; set; }
-
-
/// <summary>
/// Ignored
/// </summary>
@@ -177,16 +175,6 @@ namespace WPCordovaClassLib.Cordova.Commands
}
/// <summary>
- /// Used to open photo library
- /// </summary>
- PhotoChooserTask photoChooserTask;
-
- /// <summary>
- /// Used to open camera application
- /// </summary>
- CameraCaptureTask cameraTask;
-
- /// <summary>
/// Camera options
/// </summary>
CameraOptions cameraOptions;
@@ -198,20 +186,17 @@ namespace WPCordovaClassLib.Cordova.Commands
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
// ["quality", "destinationType", "sourceType", "targetWidth", "targetHeight", "encodingType",
// "mediaType", "allowEdit", "correctOrientation", "saveToPhotoAlbum" ]
- this.cameraOptions = new CameraOptions();
- this.cameraOptions.Quality = int.Parse(args[0]);
- this.cameraOptions.DestinationType = int.Parse(args[1]);
- this.cameraOptions.PictureSourceType = int.Parse(args[2]);
- this.cameraOptions.TargetWidth = int.Parse(args[3]);
- this.cameraOptions.TargetHeight = int.Parse(args[4]);
- this.cameraOptions.EncodingType = int.Parse(args[5]);
- this.cameraOptions.MediaType = int.Parse(args[6]);
- this.cameraOptions.AllowEdit = bool.Parse(args[7]);
- this.cameraOptions.CorrectOrientation = bool.Parse(args[8]);
- this.cameraOptions.SaveToPhotoAlbum = bool.Parse(args[9]);
-
- //this.cameraOptions = String.IsNullOrEmpty(options) ?
- // new CameraOptions() : JSON.JsonHelper.Deserialize<CameraOptions>(options);
+ cameraOptions = new CameraOptions();
+ cameraOptions.Quality = int.Parse(args[0]);
+ cameraOptions.DestinationType = int.Parse(args[1]);
+ cameraOptions.PictureSourceType = int.Parse(args[2]);
+ cameraOptions.TargetWidth = int.Parse(args[3]);
+ cameraOptions.TargetHeight = int.Parse(args[4]);
+ cameraOptions.EncodingType = int.Parse(args[5]);
+ cameraOptions.MediaType = int.Parse(args[6]);
+ cameraOptions.AllowEdit = bool.Parse(args[7]);
+ cameraOptions.CorrectOrientation = bool.Parse(args[8]);
+ cameraOptions.SaveToPhotoAlbum = bool.Parse(args[9]);
}
catch (Exception ex)
{
@@ -224,28 +209,32 @@ namespace WPCordovaClassLib.Cordova.Commands
if (cameraOptions.PictureSourceType == CAMERA)
{
- cameraTask = new CameraCaptureTask();
+ CameraCaptureTask cameraTask = new CameraCaptureTask();
cameraTask.Completed += onCameraTaskCompleted;
cameraTask.Show();
}
+ else if ((cameraOptions.PictureSourceType == PHOTOLIBRARY) || (cameraOptions.PictureSourceType == SAVEDPHOTOALBUM))
+ {
+ PhotoChooserTask photoChooserTask = new PhotoChooserTask();
+ photoChooserTask.Completed += onPickerTaskCompleted;
+ photoChooserTask.Show();
+ }
else
{
- if ((cameraOptions.PictureSourceType == PHOTOLIBRARY) || (cameraOptions.PictureSourceType == SAVEDPHOTOALBUM))
- {
- photoChooserTask = new PhotoChooserTask();
- photoChooserTask.Completed += onPickerTaskCompleted;
- photoChooserTask.Show();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
- }
+ DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT));
}
+
}
public void onCameraTaskCompleted(object sender, PhotoResult e)
{
+ var task = sender as ChooserBase<PhotoResult>;
+ if (task != null)
+ {
+ task.Completed -= onCameraTaskCompleted;
+ }
+
if (e.Error != null)
{
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
@@ -289,10 +278,7 @@ namespace WPCordovaClassLib.Cordova.Commands
// we should return stream position back after saving stream to media library
rotImageStream.Seek(0, SeekOrigin.Begin);
-
- WriteableBitmap image = PictureDecoder.DecodeJpeg(rotImageStream);
-
- imagePathOrContent = this.SaveImageToLocalStorage(image, Path.GetFileName(e.OriginalFileName));
+ imagePathOrContent = this.SaveImageToLocalStorage(rotImageStream, Path.GetFileName(e.OriginalFileName));
}
@@ -329,6 +315,12 @@ namespace WPCordovaClassLib.Cordova.Commands
public void onPickerTaskCompleted(object sender, PhotoResult e)
{
+ var task = sender as ChooserBase<PhotoResult>;
+ if (task != null)
+ {
+ task.Completed -= onCameraTaskCompleted;
+ }
+
if (e.Error != null)
{
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
@@ -344,8 +336,7 @@ namespace WPCordovaClassLib.Cordova.Commands
if (cameraOptions.DestinationType == FILE_URI)
{
- WriteableBitmap image = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
- imagePathOrContent = this.SaveImageToLocalStorage(image, Path.GetFileName(e.OriginalFileName));
+ imagePathOrContent = this.SaveImageToLocalStorage(e.ChosenPhoto, Path.GetFileName(e.OriginalFileName));
}
else if (cameraOptions.DestinationType == DATA_URL)
{
@@ -385,23 +376,29 @@ namespace WPCordovaClassLib.Cordova.Commands
/// <returns>Base64 representation of the image</returns>
private string GetImageContent(Stream stream)
{
- int streamLength = (int)stream.Length;
- byte[] fileData = new byte[streamLength + 1];
- stream.Read(fileData, 0, streamLength);
+ byte[] imageContent = null;
- //use photo's actual width & height if user doesn't provide width & height
- if (cameraOptions.TargetWidth < 0 && cameraOptions.TargetHeight < 0)
+ try
{
- stream.Close();
- return Convert.ToBase64String(fileData);
+ //use photo's actual width & height if user doesn't provide width & height
+ if (cameraOptions.TargetWidth < 0 && cameraOptions.TargetHeight < 0)
+ {
+ int streamLength = (int)stream.Length;
+ imageContent = new byte[streamLength + 1];
+ stream.Read(imageContent, 0, streamLength);
+ }
+ else
+ {
+ // resize photo
+ imageContent = ResizePhoto(stream);
+ }
}
- else
+ finally
{
- // resize photo
- byte[] resizedFile = ResizePhoto(stream, fileData);
- stream.Close();
- return Convert.ToBase64String(resizedFile);
+ stream.Dispose();
}
+
+ return Convert.ToBase64String(imageContent);
}
/// <summary>
@@ -410,51 +407,87 @@ namespace WPCordovaClassLib.Cordova.Commands
/// <param name="stream">Image stream</param>
/// <param name="fileData">File data</param>
/// <returns>resized image</returns>
- private byte[] ResizePhoto(Stream stream, byte[] fileData)
+ private byte[] ResizePhoto(Stream stream)
{
- int streamLength = (int)stream.Length;
- int intResult = 0;
-
+ //output
byte[] resizedFile;
- stream.Read(fileData, 0, streamLength);
-
BitmapImage objBitmap = new BitmapImage();
- MemoryStream objBitmapStream = new MemoryStream(fileData);
- MemoryStream objBitmapStreamResized = new MemoryStream();
- WriteableBitmap objWB;
objBitmap.SetSource(stream);
- objWB = new WriteableBitmap(objBitmap);
+ objBitmap.CreateOptions = BitmapCreateOptions.None;
- // resize the photo with user defined TargetWidth & TargetHeight
- Extensions.SaveJpeg(objWB, objBitmapStreamResized, cameraOptions.TargetWidth, cameraOptions.TargetHeight, 0, cameraOptions.Quality);
+ WriteableBitmap objWB = new WriteableBitmap(objBitmap);
+ objBitmap.UriSource = null;
- //Convert the resized stream to a byte array.
- streamLength = (int)objBitmapStreamResized.Length;
- resizedFile = new Byte[streamLength]; //-1
- objBitmapStreamResized.Position = 0;
- //for some reason we have to set Position to zero, but we don't have to earlier when we get the bytes from the chosen photo...
- intResult = objBitmapStreamResized.Read(resizedFile, 0, streamLength);
+ //Keep proportionally
+ double ratio = Math.Min((double)cameraOptions.TargetWidth / objWB.PixelWidth, (double)cameraOptions.TargetHeight / objWB.PixelHeight);
+ int width = Convert.ToInt32(ratio * objWB.PixelWidth);
+ int height = Convert.ToInt32(ratio * objWB.PixelHeight);
+
+ //Hold the result stream
+ using (MemoryStream objBitmapStreamResized = new MemoryStream())
+ {
+
+ try
+ {
+ // resize the photo with user defined TargetWidth & TargetHeight
+ Extensions.SaveJpeg(objWB, objBitmapStreamResized, width, height, 0, cameraOptions.Quality);
+ }
+ finally
+ {
+ //Dispose bitmaps immediately, they are memory expensive
+ DisposeImage(objBitmap);
+ DisposeImage(objWB);
+ GC.Collect();
+ }
+
+ //Convert the resized stream to a byte array.
+ int streamLength = (int)objBitmapStreamResized.Length;
+ resizedFile = new Byte[streamLength]; //-1
+ objBitmapStreamResized.Position = 0;
+
+ //for some reason we have to set Position to zero, but we don't have to earlier when we get the bytes from the chosen photo...
+ objBitmapStreamResized.Read(resizedFile, 0, streamLength);
+ }
return resizedFile;
}
/// <summary>
+ /// Util: Dispose a bitmap resource
+ /// </summary>
+ /// <param name="image">BitmapSource subclass to dispose</param>
+ private void DisposeImage(BitmapSource image)
+ {
+ if (image != null)
+ {
+ try
+ {
+ using (var ms = new MemoryStream(new byte[] { 0x0 }))
+ {
+ image.SetSource(ms);
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+ }
+
+ /// <summary>
/// Saves captured image in isolated storage
/// </summary>
/// <param name="imageFileName">image file name</param>
/// <returns>Image path</returns>
- private string SaveImageToLocalStorage(WriteableBitmap image, string imageFileName)
+ private string SaveImageToLocalStorage(Stream stream, string imageFileName)
{
- if (image == null)
+ if (stream == null)
{
throw new ArgumentNullException("imageBytes");
}
try
{
-
-
var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
if (!isoFile.DirectoryExists(isoFolder))
@@ -464,16 +497,41 @@ namespace WPCordovaClassLib.Cordova.Commands
string filePath = System.IO.Path.Combine("///" + isoFolder + "/", imageFileName);
- using (var stream = isoFile.CreateFile(filePath))
+ using (IsolatedStorageFileStream outputStream = isoFile.CreateFile(filePath))
{
- // resize image if Height and Width defined via options
- if (cameraOptions.TargetHeight > 0 && cameraOptions.TargetWidth > 0)
+ BitmapImage objBitmap = new BitmapImage();
+ objBitmap.SetSource(stream);
+ objBitmap.CreateOptions = BitmapCreateOptions.None;
+
+ WriteableBitmap objWB = new WriteableBitmap(objBitmap);
+ objBitmap.UriSource = null;
+
+ try
{
- image.SaveJpeg(stream, cameraOptions.TargetWidth, cameraOptions.TargetHeight, 0, cameraOptions.Quality);
+
+ //use photo's actual width & height if user doesn't provide width & height
+ if (cameraOptions.TargetWidth < 0 && cameraOptions.TargetHeight < 0)
+ {
+ objWB.SaveJpeg(outputStream, objWB.PixelWidth, objWB.PixelHeight, 0, cameraOptions.Quality);
+ }
+ else
+ {
+ //Resize
+ //Keep proportionally
+ double ratio = Math.Min((double)cameraOptions.TargetWidth / objWB.PixelWidth, (double)cameraOptions.TargetHeight / objWB.PixelHeight);
+ int width = Convert.ToInt32(ratio * objWB.PixelWidth);
+ int height = Convert.ToInt32(ratio * objWB.PixelHeight);
+
+ // resize the photo with user defined TargetWidth & TargetHeight
+ objWB.SaveJpeg(outputStream, width, height, 0, cameraOptions.Quality);
+ }
}
- else
+ finally
{
- image.SaveJpeg(stream, image.PixelWidth, image.PixelHeight, 0, cameraOptions.Quality);
+ //Dispose bitmaps immediately, they are memory expensive
+ DisposeImage(objBitmap);
+ DisposeImage(objWB);
+ GC.Collect();
}
}
@@ -484,6 +542,10 @@ namespace WPCordovaClassLib.Cordova.Commands
//TODO: log or do something else
throw;
}
+ finally
+ {
+ stream.Dispose();
+ }
}
}
[14/16] git commit: CB-6422 [windows8] use cordova/exec/proxy
Posted by ia...@apache.org.
CB-6422 [windows8] use cordova/exec/proxy
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/85a986f5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/85a986f5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/85a986f5
Branch: refs/heads/master
Commit: 85a986f589e8dfaf3bb5ed4b24f4ea2e7c457826
Parents: 4c2c567
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 8 15:53:51 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 8 15:53:51 2014 -0700
----------------------------------------------------------------------
src/windows8/CameraProxy.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/85a986f5/src/windows8/CameraProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/CameraProxy.js b/src/windows8/CameraProxy.js
index 65ebdf5..d46553b 100644
--- a/src/windows8/CameraProxy.js
+++ b/src/windows8/CameraProxy.js
@@ -351,4 +351,4 @@ module.exports = {
}
};
-require("cordova/windows8/commandProxy").add("Camera",module.exports);
+require("cordova/exec/proxy").add("Camera",module.exports);
[13/16] git commit: WP8 When only targetWidth or targetHeight is
provided, use it as the only bound
Posted by ia...@apache.org.
WP8 When only targetWidth or targetHeight is provided, use it as the only bound
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/4c2c567f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/4c2c567f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/4c2c567f
Branch: refs/heads/master
Commit: 4c2c567fd874a861d4707b1a5c2e268fb56f4d76
Parents: fe6dc72
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 8 12:19:44 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 8 12:19:44 2014 -0700
----------------------------------------------------------------------
src/wp/Camera.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/4c2c567f/src/wp/Camera.cs
----------------------------------------------------------------------
diff --git a/src/wp/Camera.cs b/src/wp/Camera.cs
index 87617e4..b76929b 100644
--- a/src/wp/Camera.cs
+++ b/src/wp/Camera.cs
@@ -197,6 +197,16 @@ namespace WPCordovaClassLib.Cordova.Commands
cameraOptions.AllowEdit = bool.Parse(args[7]);
cameraOptions.CorrectOrientation = bool.Parse(args[8]);
cameraOptions.SaveToPhotoAlbum = bool.Parse(args[9]);
+
+ // a very large number will force the other value to be the bound
+ if (cameraOptions.TargetWidth > -1 && cameraOptions.TargetHeight == -1)
+ {
+ cameraOptions.TargetHeight = 100000;
+ }
+ else if (cameraOptions.TargetHeight > -1 && cameraOptions.TargetWidth == -1)
+ {
+ cameraOptions.TargetWidth = 100000;
+ }
}
catch (Exception ex)
{
[12/16] git commit: Remove rotation test value
Posted by ia...@apache.org.
Remove rotation test value
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/fe6dc72a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/fe6dc72a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/fe6dc72a
Branch: refs/heads/master
Commit: fe6dc72a755930a82ccf810e71d57fb10eac1b5b
Parents: ae2acd9
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 8 12:03:22 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 8 12:03:22 2014 -0700
----------------------------------------------------------------------
src/wp/Camera.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/fe6dc72a/src/wp/Camera.cs
----------------------------------------------------------------------
diff --git a/src/wp/Camera.cs b/src/wp/Camera.cs
index 977634b..87617e4 100644
--- a/src/wp/Camera.cs
+++ b/src/wp/Camera.cs
@@ -262,7 +262,7 @@ namespace WPCordovaClassLib.Cordova.Commands
}
int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
- int newAngle = 270;
+ int newAngle = 0;
switch (orient)
{
case ImageExifOrientation.LandscapeLeft: