You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/04/03 19:57:55 UTC
[jira] [Commented] (CB-8706) Camera should use filepicker if
saveToPhotoAlbum is true
[ https://issues.apache.org/jira/browse/CB-8706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14394777#comment-14394777 ]
ASF GitHub Bot commented on CB-8706:
------------------------------------
Github user muratsu commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-camera/pull/78#discussion_r27744001
--- Diff: src/windows/CameraProxy.js ---
@@ -43,399 +43,468 @@ module.exports = {
// 11 cameraDirection:0
takePicture: function (successCallback, errorCallback, args) {
- var encodingType = args[5];
- var targetWidth = args[3];
- var targetHeight = args[4];
var sourceType = args[2];
- var destinationType = args[1];
- var mediaType = args[6];
- var allowCrop = !!args[7];
- var saveToPhotoAlbum = args[9];
- var cameraDirection = args[11];
-
- // resize method :)
- var resizeImage = function (file) {
- var tempPhotoFileName = "";
- if (encodingType == Camera.EncodingType.PNG) {
- tempPhotoFileName = "camera_cordova_temp_return.png";
- } else {
- tempPhotoFileName = "camera_cordova_temp_return.jpg";
- }
-
- var storageFolder = Windows.Storage.ApplicationData.current.localFolder;
- file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).then(function (storageFile) {
- Windows.Storage.FileIO.readBufferAsync(storageFile).then(function(buffer) {
- var strBase64 = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);
- var imageData = "data:" + file.contentType + ";base64," + strBase64;
- var image = new Image();
- image.src = imageData;
- image.onload = function() {
- var imageWidth = targetWidth,
- imageHeight = targetHeight;
- var canvas = document.createElement('canvas');
-
- canvas.width = imageWidth;
- canvas.height = imageHeight;
- canvas.getContext("2d").drawImage(this, 0, 0, imageWidth, imageHeight);
-
- var fileContent = canvas.toDataURL(file.contentType).split(',')[1];
-
- var storageFolder = Windows.Storage.ApplicationData.current.localFolder;
+ if (sourceType != Camera.PictureSourceType.CAMERA) {
+ takePictureFromFile(successCallback, errorCallback, args);
+ } else {
+ takePictureFromCamera(successCallback, errorCallback, args);
+ }
+ }
+};
- storageFolder.createFileAsync(tempPhotoFileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (storagefile) {
- var content = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(fileContent);
- Windows.Storage.FileIO.writeBufferAsync(storagefile, content).then(function () {
- successCallback("ms-appdata:///local/" + storagefile.name);
- }, function () {
- errorCallback("Resize picture error.");
- });
- });
- };
- });
- }, function () {
- errorCallback("Can't access localStorage folder");
- });
- };
+// Resize method
+function resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType) {
--- End diff --
I'll make this change in a separate commit I think.
> Camera should use filepicker if saveToPhotoAlbum is true
> --------------------------------------------------------
>
> Key: CB-8706
> URL: https://issues.apache.org/jira/browse/CB-8706
> Project: Apache Cordova
> Issue Type: Bug
> Components: Plugin Camera
> Reporter: Murat Sutunc
> Assignee: Murat Sutunc
> Priority: Minor
>
> Currently camera plugin is saving pictures programmatically to pictures library. It should use filePicker to not require unnecessary capabilities.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org