cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vladimir-kotikov <...@git.apache.org>
Subject [GitHub] cordova-plugin-camera pull request: CB-8879 fix stripe issue with ...
Date Wed, 13 May 2015 08:21:13 GMT
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-camera/pull/94#discussion_r30210499
  
    --- Diff: src/windows/CameraProxy.js ---
    @@ -438,6 +457,61 @@ function takePictureFromCameraWP(successCallback, errorCallback,
args) {
                 });
         };
     
    +    var getAspectRatios = function (capture) {
    +        var photoAspectRatios = capture.videoDeviceController.getAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.photo).map(function
(element) {
    +            return (element.width / element.height).toFixed(1);
    +        }).filter(function (element, index, array) { if (index === array.indexOf(element))
return 1; return 0; });
    +
    +        var videoAspectRatios = capture.videoDeviceController.getAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.videoRecord).map(function
(element) {
    +            return (element.width / element.height).toFixed(1);
    +        }).filter(function (element, index, array) { if (index === array.indexOf(element))
return 1; return 0; });
    +
    +        var videoPreviewAspectRatios = capture.videoDeviceController.getAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.videoPreview).map(function
(element) {
    +            return (element.width / element.height).toFixed(1);
    +        }).filter(function (element, index, array) { if (index === array.indexOf(element))
return 1; return 0; });
    +
    +        var allAspectRatios = [].concat(photoAspectRatios, videoAspectRatios, videoPreviewAspectRatios);
    +
    +        var aspectObj = allAspectRatios.reduce(function (map, item) {
    +            if (!map[item]) {
    +                map[item] = 0;
    +            }
    +            map[item]++;
    +            return map;
    +        }, {});
    +
    +        return Object.keys(aspectObj).filter(function (k) {
    +            return aspectObj[k] === 3;
    +        });
    +    };
    +
    +    var setAspectRatio = function (capture, aspect) {
    +        // Max photo resolution with desired aspect ratio
    +        var photoResolution = capture.videoDeviceController.getAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.photo).filter(function
(elem) {
    +            return ((elem.width / elem.height).toFixed(1) === aspect) ? 1 : 0;
    --- End diff --
    
    nit: `return (elem.width / elem.height).toFixed(1) === aspect)` is sufficient for filtering,
ternary operator is excess.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message