E
E
Evgeny Popov2014-07-08 17:31:04
Android
Evgeny Popov, 2014-07-08 17:31:04

How to fix camera in portrait mode when capturing image in cocoonjs?

I looked for a solution both in the code and in the documentation, but the problem does not seem to exist.
Essence:
We launch the project through the command line npm module cocoonjs:
cocoonjs serve
We open the project through the application (primarily interested in android) CocoonJs Launcher
The capture code corresponds to the example (the discrepancies are not significant) from the documentation:

var cimage= document.getElementById("camera");
...
var cctx= cimage.getContext("2d");
...
var camera = CocoonJS.Camera;
var im = camera.startCapturing(0, 640, 640, 30);
if (im != null){
  setInterval( function() {
  cctx.drawImage( im, 0, 0, cimage.width, cimage.height );
  }, 60 );
}
...

As a result, if the launcher is forced to specify the landscape mode in the settings, then everything is "as if ok", but it is worth changing it to the mode dependent on the position of the phone or only portrait, then we can immediately observe that the picture is rotated 90 ', in other words, the camera "continues" to shoot in landscape mode.
A live example can be viewed in one of the official demos (VideoPuzzle) by specifying portrait mode in the settings. If someone came across or just knows the solution, thanks in advance for the help.
So I wanted to add that I switched to cocoonjs with phonegap without finding on it, in principle, a solution for capturing images in canvas (when capturing, the application itself goes into the background, and a standard application for photo and video shooting opens "above"), if anyone- I can suggest something like this, then I will also be grateful - this will essentially become a solution to the problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question