[英]Zxing (v3.2.0) Camera fixed portrait mode using eclipse
我在Android的人像模式下按照Zxing Camera的说明逐步操作,以在用户使用zxing相机时显示人像。
但这是行不通的。 扫描仪仍以横向模式出现。 我认为这是因为我使用的是Zxing的最新版本(v3.2.0) ,并且该指令已弃用。
Zxing v3.2.0中该如何完成?
无论如何,这是我尝试的步骤:
码:
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);
码:
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;
在CameraConfigurationManager.java中修改initFromCameraParameters(...)
在Zxing(v3.2.0)中,我找不到以下代码
码:
//remove the following
if (width < height) {
Log.i(TAG, "Display reports portrait orientation; assuming this is incorrect");
int temp = width;
width = height;
height = temp;
}
码:
camera.setDisplayOrientation(90);
码:
android:screenOrientation="portrait"
经过几天的反复试验,这是我的工作解决方案:
它需要额外的工作,比方说第6步。无论如何,始终设置纵向。 而且有效。
步骤6.在CaptureActivity.java中修改onResume
if (prefs.getBoolean(PreferencesActivity.KEY_DISABLE_AUTO_ORIENTATION, true)) {
//setRequestedOrientation(getCurrentOrientation()); // mark this line
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else {
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); // mark this line
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.