Je suis les instructions étape par étape au Zxing Camera in Portrait mode on Android pour afficher le portrait pendant que l'utilisateur utilise la caméra zxing.Zxing (v3.2.0) Appareil photo en mode portrait fixe utilisant l'éclipse
Mais cela ne fonctionnera pas. Le scanner est toujours apparu en mode paysage. Je pense que c'est parce que j'utilise la dernière version (v3.2.0) de Zxing et l'instruction est obsolète.
Comment cela peut-il être fait dans v3.2.0 Zxing?
Quoi qu'il en soit, voici les étapes que j'ai essayé:
- Modifier buildLuminanceSource (..) DecodeHandler.java
code:
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width;
width = height;
height = tmp;
PlanarYUVLuminanceSource source = activity.getCameraManager().buildLuminanceSource(rotatedData, width, height);
- Modifier getFramingRectInPreview() dans CameraManager.java
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;
Modifier initFromCameraParameters (Dans Zxing (v3.2.0), je ne trouve pas le code suivant
code:
//remove the following
if (width < height) {
Log.i(TAG, "Display reports portrait orientation; assuming this is incorrect");
int temp = width;
width = height;
height = temp;
}
- Ajouter une ligne suivante pour faire pivoter la caméra dans setDesiredCameraParameters (...) dans CameraConfigurationManager.java
Code:
camera.setDisplayOrientation(90);
- Dans mon projet, modifier AndroidManifest.xml
code:
android:screenOrientation="portrait"