mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-31 12:42:50 +08:00
CB-11714: (windows) added more explicit content-type when converting to target data on canvas
This closes #232
This commit is contained in:
parent
b89645c749
commit
c98607c613
@ -79,10 +79,14 @@ var HIGHEST_POSSIBLE_Z_INDEX = 2147483647;
|
|||||||
// Resize method
|
// Resize method
|
||||||
function resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType) {
|
function resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType) {
|
||||||
var tempPhotoFileName = "";
|
var tempPhotoFileName = "";
|
||||||
|
var targetContentType = "";
|
||||||
|
|
||||||
if (encodingType == Camera.EncodingType.PNG) {
|
if (encodingType == Camera.EncodingType.PNG) {
|
||||||
tempPhotoFileName = "camera_cordova_temp_return.png";
|
tempPhotoFileName = "camera_cordova_temp_return.png";
|
||||||
|
targetContentType = "image/png";
|
||||||
} else {
|
} else {
|
||||||
tempPhotoFileName = "camera_cordova_temp_return.jpg";
|
tempPhotoFileName = "camera_cordova_temp_return.jpg";
|
||||||
|
targetContentType = "image/jpeg";
|
||||||
}
|
}
|
||||||
|
|
||||||
var storageFolder = getAppData().localFolder;
|
var storageFolder = getAppData().localFolder;
|
||||||
@ -108,7 +112,7 @@ function resizeImage(successCallback, errorCallback, file, targetWidth, targetHe
|
|||||||
|
|
||||||
canvas.getContext("2d").drawImage(this, 0, 0, imageWidth, imageHeight);
|
canvas.getContext("2d").drawImage(this, 0, 0, imageWidth, imageHeight);
|
||||||
|
|
||||||
var fileContent = canvas.toDataURL(file.contentType).split(',')[1];
|
var fileContent = canvas.toDataURL(targetContentType).split(',')[1];
|
||||||
|
|
||||||
var storageFolder = getAppData().localFolder;
|
var storageFolder = getAppData().localFolder;
|
||||||
|
|
||||||
@ -745,7 +749,7 @@ function takePictureFromCameraWindows(successCallback, errorCallback, args) {
|
|||||||
cameraCaptureUI.photoSettings.maxResolution = maxRes;
|
cameraCaptureUI.photoSettings.maxResolution = maxRes;
|
||||||
|
|
||||||
var cameraPicture;
|
var cameraPicture;
|
||||||
|
|
||||||
// define focus handler for windows phone 10.0
|
// define focus handler for windows phone 10.0
|
||||||
var savePhotoOnFocus = function () {
|
var savePhotoOnFocus = function () {
|
||||||
window.removeEventListener("focus", savePhotoOnFocus);
|
window.removeEventListener("focus", savePhotoOnFocus);
|
||||||
@ -760,7 +764,7 @@ function takePictureFromCameraWindows(successCallback, errorCallback, args) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// if windows phone 10, add and delete focus eventHandler to capture the focus back from cameraUI to app
|
// if windows phone 10, add and delete focus eventHandler to capture the focus back from cameraUI to app
|
||||||
if (navigator.appVersion.indexOf('Windows Phone 10.0') >= 0) {
|
if (navigator.appVersion.indexOf('Windows Phone 10.0') >= 0) {
|
||||||
window.addEventListener("focus", savePhotoOnFocus);
|
window.addEventListener("focus", savePhotoOnFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user