Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
Fix Nexus 5x portrait scanning issue #351
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushyanth Maguluru committed Aug 19, 2017
1 parent e1228f0 commit 6bced9d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [1.9.8] - August 18, 2017
* One more attempt to fix Nexus 5x portrait scanning problems

## [1.9.7] - August 2, 2017
* Fix everything that was broken since 1.9.5 (Relevant issues: #336, #315, #339, #338)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Installation

Add the following dependency to your build.gradle file.

`compile 'me.dm7.barcodescanner:zxing:1.9.7'`
`compile 'me.dm7.barcodescanner:zxing:1.9.8'`

Simple Usage
------------
Expand Down Expand Up @@ -126,7 +126,7 @@ Installation

Add the following dependency to your build.gradle file.

`compile 'me.dm7.barcodescanner:zbar:1.9.7'`
`compile 'me.dm7.barcodescanner:zbar:1.9.8'`

Simple Usage
------------
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {

allprojects {
group = 'me.dm7.barcodescanner'
version = '1.9.7'
version = '1.9.8'

repositories {
mavenCentral()
Expand Down Expand Up @@ -44,8 +44,8 @@ subprojects {
defaultConfig {
minSdkVersion versions.min_sdk
targetSdkVersion versions.target_sdk
versionCode 197
versionName "1.9.7"
versionCode 198
versionName "1.9.8"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.hardware.Camera;
import android.support.annotation.ColorInt;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
Expand Down Expand Up @@ -322,6 +323,9 @@ public byte[] getRotatedData(byte[] data, Camera camera) {
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
data = rotatedData;
int tmp = width;
width = height;
height = tmp;
}
}

Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ext.versions = [
build_tools : "25.0.2",
support_lib : "25.3.1",
zxing : "3.3.0",
barcodescanner: "1.9.7"
barcodescanner: "1.9.8"
]

ext.libraries = [
Expand Down
17 changes: 11 additions & 6 deletions zbar/src/main/java/me/dm7/barcodescanner/zbar/ZBarScannerView.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.dm7.barcodescanner.zbar;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.hardware.Camera;
import android.os.Handler;
Expand All @@ -20,6 +21,7 @@
import java.util.List;

import me.dm7.barcodescanner.core.BarcodeScannerView;
import me.dm7.barcodescanner.core.DisplayUtils;

public class ZBarScannerView extends BarcodeScannerView {
private static final String TAG = "ZBarScannerView";
Expand Down Expand Up @@ -84,13 +86,16 @@ public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Size size = parameters.getPreviewSize();
int width = size.width;
int height = size.height;
int rotationCount = getRotationCount();
if(rotationCount == 1 || rotationCount == 3) {
int tmp = width;
width = height;
height = tmp;

if (DisplayUtils.getScreenOrientation(getContext()) == Configuration.ORIENTATION_PORTRAIT) {
int rotationCount = getRotationCount();
if (rotationCount == 1 || rotationCount == 3) {
int tmp = width;
width = height;
height = tmp;
}
data = getRotatedData(data, camera);
}
data = getRotatedData(data, camera);

Rect rect = getFramingRectInPreview(width, height);
Image barcode = new Image(width, height, "Y800");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.dm7.barcodescanner.zxing;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.hardware.Camera;
import android.os.Handler;
Expand All @@ -26,6 +27,7 @@
import java.util.Map;

import me.dm7.barcodescanner.core.BarcodeScannerView;
import me.dm7.barcodescanner.core.DisplayUtils;

public class ZXingScannerView extends BarcodeScannerView {
private static final String TAG = "ZXingScannerView";
Expand Down Expand Up @@ -103,14 +105,16 @@ public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Size size = parameters.getPreviewSize();
int width = size.width;
int height = size.height;
int rotationCount = getRotationCount();
if(rotationCount == 1 || rotationCount == 3) {
int tmp = width;
width = height;
height = tmp;
}

data = getRotatedData(data, camera);
if (DisplayUtils.getScreenOrientation(getContext()) == Configuration.ORIENTATION_PORTRAIT) {
int rotationCount = getRotationCount();
if (rotationCount == 1 || rotationCount == 3) {
int tmp = width;
width = height;
height = tmp;
}
data = getRotatedData(data, camera);
}

Result rawResult = null;
PlanarYUVLuminanceSource source = buildLuminanceSource(data, width, height);
Expand Down

0 comments on commit 6bced9d

Please sign in to comment.