저는 zxing zxing 2.3을 사용했으며 저의 솔루션은 저에게 효과적이었습니다.
CameraConfigurationManager 클래스
1, setDesiredCameraParameters 방법 뾰족한 행 아래 코드 아래 추가
-> Camera.Parameters 파라미터 = camera.getParameters(); CameraManager 클래스
if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
camera.setDisplayOrientation(90);
}
2, getFramingRect 메소드 CameraManager 클래스
int width = MIN_FRAME_WIDTH; int height = MIN_FRAME_HEIGHT;
if (context.getResources().getConfiguration().orientation ==Configuration.ORIENTATION_PORTRAIT) {
int tmp = 7 * screenResolution.x/8;
width = (tmp) < MIN_FRAME_WIDTH ? MIN_FRAME_WIDTH : (tmp);
tmp = 1 * screenResolution.y/3;
height = (tmp) < MIN_FRAME_WIDTH ? MIN_FRAME_WIDTH : ((tmp) > MAX_FRAME_HEIGHT ? MAX_FRAME_HEIGHT : (tmp));
}else{
// Original Code
width = findDesiredDimensionInRange(screenResolution.x, MIN_FRAME_WIDTH, > MAX_FRAME_WIDTH);
height = findDesiredDimensionInRange(screenResolution.y, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT);
}
3 아래와 같이 코드를 대체 getFramingRectInPreview 방법
DecodeHandler 클래스
if (context.getResources().getConfiguration().orientation ==Configuration.ORIENTATION_PORTRAIT) {
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;
}else{
// Original code commented
rect.left = rect.left * cameraResolution.x/screenResolution.x;
rect.right = rect.right * cameraResolution.x/screenResolution.x;
rect.top = rect.top * cameraResolution.y/screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.y/screenResolution.y;
}
4 디코드 방법 아래와 같이 코드를 대체 아래에 코드를 추가하십시오.
-> Resu lt rawResult = null;
if (activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
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];
}
data = rotatedData;
int tmp = width;
width = height;
height = tmp;
}
당신은 세로 모드에서만 작동하려면 당신은 모든 조건을 제거 할 수 있습니다 내 작업 코드
http://www.compyutech.co.in/repo/zxing-dynamic.zip
을 찾아주세요. 이 당신을 도울 것입니다
희망 ....
나는 도서관 https://github.com/xiaowei4895/zxing-android-portrait으로이 프로젝트를 추가하여 내 문제를 해결, – Kirill
당신이 대답 할 수 ? –