You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/05/09 00:41:49 UTC
[1/2] git commit: CB-6613 Use WinJS functionality to get
base64-encoded content of image instead of File plugin functionality
Repository: cordova-plugin-camera
Updated Branches:
refs/heads/master 10e545535 -> 707426ece
CB-6613 Use WinJS functionality to get base64-encoded content of image instead of File plugin functionality
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/87a50307
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/87a50307
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/87a50307
Branch: refs/heads/master
Commit: 87a5030771b031962a2d3db14337ee3f38438a13
Parents: 0c9de56
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Fri May 2 12:46:15 2014 +0400
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Fri May 2 12:46:45 2014 +0400
----------------------------------------------------------------------
src/windows8/CameraProxy.js | 59 +++++++++++++---------------------------
1 file changed, 19 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/87a50307/src/windows8/CameraProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/CameraProxy.js b/src/windows8/CameraProxy.js
index d46553b..9f21c44 100644
--- a/src/windows8/CameraProxy.js
+++ b/src/windows8/CameraProxy.js
@@ -133,55 +133,34 @@ module.exports = {
// because of asynchronous method, so let the successCallback be called in it.
var resizeImageBase64 = function (file) {
- var imgObj = new Image();
- var success = function (fileEntry) {
- var successCB = function (filePhoto) {
- var fileType = file.contentType,
- reader = new FileReader();
- reader.onloadend = function () {
- var image = new Image();
- image.src = reader.result;
- image.onload = function () {
- var imageWidth = targetWidth,
- imageHeight = targetHeight;
- var canvas = document.createElement('canvas');
+ Windows.Storage.FileIO.readBufferAsync(file).done( function(buffer) {
+ var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);
+ var imageData = "data:" + file.contentType + ";base64," + strBase64;
- canvas.width = imageWidth;
- canvas.height = imageHeight;
+ var image = new Image();
+ image.src = imageData;
- var ctx = canvas.getContext("2d");
- ctx.drawImage(this, 0, 0, imageWidth, imageHeight);
+ image.onload = function() {
+ var imageWidth = targetWidth,
+ imageHeight = targetHeight;
+ var canvas = document.createElement('canvas');
- // The resized file ready for upload
- var finalFile = canvas.toDataURL(fileType);
+ canvas.width = imageWidth;
+ canvas.height = imageHeight;
- // Remove the prefix such as "data:" + contentType + ";base64," , in order to meet the Cordova API.
- var arr = finalFile.split(",");
- var newStr = finalFile.substr(arr[0].length + 1);
- successCallback(newStr);
- };
- };
+ var ctx = canvas.getContext("2d");
+ ctx.drawImage(this, 0, 0, imageWidth, imageHeight);
- reader.readAsDataURL(filePhoto);
+ // The resized file ready for upload
+ var finalFile = canvas.toDataURL(file.contentType);
+ // Remove the prefix such as "data:" + contentType + ";base64," , in order to meet the Cordova API.
+ var arr = finalFile.split(",");
+ var newStr = finalFile.substr(arr[0].length + 1);
+ successCallback(newStr);
};
- var failCB = function () {
- errorCallback("File not found.");
- };
- fileEntry.file(successCB, failCB);
- };
-
- var storageFolder = Windows.Storage.ApplicationData.current.localFolder;
- file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
- success(new FileEntry(storageFile.name, "ms-appdata:///local/" + storageFile.name));
- }, function () {
- fail(FileError.INVALID_MODIFICATION_ERR);
- }, function () {
- errorCallback("Folder not access.");
});
-
-
};
if (sourceType != Camera.PictureSourceType.CAMERA) {
[2/2] git commit: Merge branch 'CB-6613' of
https://github.com/MSOpenTech/cordova-plugin-camera
Posted by pu...@apache.org.
Merge branch 'CB-6613' of https://github.com/MSOpenTech/cordova-plugin-camera
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/707426ec
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/707426ec
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/707426ec
Branch: refs/heads/master
Commit: 707426ece2c853f3c9b099cde9fc4b8a6f98e5bc
Parents: 10e5455 87a5030
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 8 15:31:46 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 8 15:31:46 2014 -0700
----------------------------------------------------------------------
src/windows8/CameraProxy.js | 59 +++++++++++++---------------------------
1 file changed, 19 insertions(+), 40 deletions(-)
----------------------------------------------------------------------