cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-8879) [Windows] Camera picture has black/green stripes that crop image
Date Wed, 13 May 2015 08:22:00 GMT

    [ https://issues.apache.org/jira/browse/CB-8879?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14541583#comment-14541583
] 

ASF GitHub Bot commented on CB-8879:
------------------------------------

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.


> [Windows] Camera picture has black/green stripes that crop image
> ----------------------------------------------------------------
>
>                 Key: CB-8879
>                 URL: https://issues.apache.org/jira/browse/CB-8879
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Camera
>    Affects Versions: 3.6.0
>         Environment: windows
>            Reporter: Olivier VERMONT
>            Assignee: Murat Sutunc
>              Labels: camera, resolution, stripes, windows-phone-81
>
> When a photo is taken with Windows Phone 8.1 device Nokia Lumia 735, the picture returned
shows black or green stripes on the sides and is out of shape. It seems this is related to
photo resolution but I can't get it fixed in JS.
> It seems to be quite a common problem with the Media Capture API and people solved issue
in C# here is an illustration : http://stackoverflow.com/questions/23709547/captured-photo-with-stripes
> Here is what I tried without success :
> var resolutions = capture.videoDeviceController.getAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.photo);
> var maxWidth = 0;
> var maxResolution = null;
> for(var i=0; i<resolutions.length; i++){
> 	//console.log(resolutions[i].width);
> 	if(resolutions[i].width > maxResolution){
> 		maxWidth = resolutions[i].width;
> 		maxResolution = resolutions[i];
> 	}
> }					
> capture.videoDeviceController.setMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.photo,
maxResolution)
> Am I missing something ?



--
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


Mime
View raw message