mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-04 00:02:03 +08:00
Normalize Android Camera.takePicture with iOS and BB versions.
Both iOS and BlackBerry support the PNG image format so I added support for Android. Also, iOS and BB use targetWidth/targetHeight to specify the resolution of the image. I've swiched from using maxResolution to targetWidth/targetHeight in this change list.
This commit is contained in:
@@ -34,6 +34,21 @@ Camera.DestinationType = {
|
||||
};
|
||||
Camera.prototype.DestinationType = Camera.DestinationType;
|
||||
|
||||
/**
|
||||
* Encoding of image returned from getPicture.
|
||||
*
|
||||
* Example: navigator.camera.getPicture(success, fail,
|
||||
* { quality: 80,
|
||||
* destinationType: Camera.DestinationType.DATA_URL,
|
||||
* sourceType: Camera.PictureSourceType.CAMERA,
|
||||
* encodingType: Camera.EncodingType.PNG})
|
||||
*/
|
||||
Camera.EncodingType = {
|
||||
JPEG: 0, // Return JPEG encoded image
|
||||
PNG: 1 // Return PNG encoded image
|
||||
};
|
||||
Camera.prototype.EncodingType = Camera.EncodingType;
|
||||
|
||||
/**
|
||||
* Source to getPicture from.
|
||||
*
|
||||
@@ -92,7 +107,32 @@ Camera.prototype.getPicture = function(successCallback, errorCallback, options)
|
||||
if (typeof this.options.sourceType === "number") {
|
||||
sourceType = this.options.sourceType;
|
||||
}
|
||||
PhoneGap.exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, maxResolution]);
|
||||
var encodingType = Camera.EncodingType.JPEG;
|
||||
if (typeof options.encodingType == "number") {
|
||||
encodingType = this.options.encodingType;
|
||||
}
|
||||
|
||||
var targetWidth = -1;
|
||||
if (typeof options.targetWidth == "number") {
|
||||
targetWidth = options.targetWidth;
|
||||
} else if (typeof options.targetWidth == "string") {
|
||||
var width = new Number(options.targetWidth);
|
||||
if (isNaN(width) === false) {
|
||||
targetWidth = width.valueOf();
|
||||
}
|
||||
}
|
||||
|
||||
var targetHeight = -1;
|
||||
if (typeof options.targetHeight == "number") {
|
||||
targetHeight = options.targetHeight;
|
||||
} else if (typeof options.targetHeight == "string") {
|
||||
var height = new Number(options.targetHeight);
|
||||
if (isNaN(height) === false) {
|
||||
targetHeight = height.valueOf();
|
||||
}
|
||||
}
|
||||
|
||||
PhoneGap.exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]);
|
||||
};
|
||||
|
||||
PhoneGap.addConstructor(function() {
|
||||
|
||||
Reference in New Issue
Block a user