Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><p>In order to make screen work in portrait, set portrait orientation for the activity (e.g. in manifest) and then config the camera: Use camera.setDisplayOrientation(90) in CameraConfigurationManager.setDesiredCameraParameters(Camera camera). But be aware that: </p> <ul> <li>setDisplayOrientation(int) requires Android 2.2 </li> <li>setDisplayOrientation(int) does not affect the order of byte array passed in PreviewCallback.onPreviewFrame. (Refer to JavaDoc for additional info)</li> </ul></li> <li><p>Because preview frames are always in "landscape", we need to rotate them. I used clockwise rotation offered by <a href="https://code.google.com/p/zxing/issues/detail?id=178#c11" rel="nofollow">comment #11</a>. Do not forget to swap width and height parameters after rotation. DecodeHandler.java, rotate data before buildLuminanceSource in decode(byte[] data, int width, int height)</p> <pre><code>rotatedData = new byte[data.length]; for (int y = 0; y &lt; height; y++) { for (int x = 0; x &lt; width; x++) rotatedData[x * height + height - y - 1] = data[x + y * width]; } int tmp = width; // Here we are swapping, that's the difference to #11 width = height; height = tmp; </code></pre></li> <li><p>I also modified CameraManager.java, getFramingRectInPreview(), as recommended by #c11:</p> <pre><code>rect.left = rect.left * cameraResolution.y / screenResolution.x; rect.right = rect.right * cameraResolution.y / screenResolution.x; rect.top = rect.top * cameraResolution.x / screenResolution.y; rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y; </code></pre></li> <li><p>I did not modify getCameraResolution(). That's the second difference to #c11.</p></li> </ol> <p>As a result, I've got UPC and other 1D codes scanning work in portrait.</p> <p>P.S. Also you may adjust the size of FramingRect (that's the rectangle visible on the screen during scanning), and FramingRectInPreview will be adjusted automatically.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload