Skip to content

Commit d328346

Browse files
committed
fix zxing detector rotation
1 parent c82df14 commit d328346

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ allprojects {
2424
}
2525

2626
project.ext {
27-
sdkVersion='0.11.0-alpha3'
27+
sdkVersion='0.11.0-alpha4'
2828
versionCode=1
2929

3030
compileSdkVersion=28

ui/src/main/java/io/snabble/sdk/ui/scanner/ZXingBarcodeDetector.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package io.snabble.sdk.ui.scanner;
22

3+
import android.graphics.Bitmap;
4+
import android.graphics.BitmapFactory;
5+
import android.graphics.ImageFormat;
36
import android.graphics.Rect;
7+
import android.graphics.YuvImage;
48

59
import com.google.zxing.Binarizer;
610
import com.google.zxing.BinaryBitmap;
@@ -12,12 +16,17 @@
1216
import com.google.zxing.Result;
1317
import com.google.zxing.common.HybridBinarizer;
1418

19+
import java.io.ByteArrayOutputStream;
20+
import java.io.FileNotFoundException;
21+
import java.io.FileOutputStream;
1522
import java.util.ArrayList;
1623
import java.util.HashMap;
1724
import java.util.List;
1825
import java.util.Map;
1926

2027
import io.snabble.sdk.BarcodeFormat;
28+
import io.snabble.sdk.Snabble;
29+
import io.snabble.sdk.ui.SnabbleUI;
2130
import io.snabble.sdk.utils.Logger;
2231

2332
public class ZXingBarcodeDetector implements BarcodeDetector {
@@ -76,19 +85,17 @@ public Barcode detect(byte[] data, int width, int height, int bitsPerPixel, Rect
7685
}
7786

7887
private Result detectInternal(byte[] data, int width, int height, int bitsPerPixel, Rect detectionRect, int displayOrientation, boolean rotate) {
79-
byte[] buf;
80-
81-
if (rotate) {
82-
int tmp = width;
83-
width = height;
84-
height = tmp;
85-
}
86-
87-
buf = getRotatedData(data, width, height, bitsPerPixel, detectionRect, displayOrientation, rotate);
88+
byte[] buf = getRotatedData(data, width, height, bitsPerPixel, detectionRect, displayOrientation, rotate);
8889

8990
int tWidth = detectionRect.width();
9091
int tHeight = detectionRect.height();
9192

93+
if (rotate) {
94+
int tmp = tWidth;
95+
tWidth = tHeight;
96+
tHeight = tmp;
97+
}
98+
9299
LuminanceSource luminanceSource = new PlanarYUVLuminanceSource(buf, tWidth, tHeight,
93100
0, 0, tWidth, tHeight, false);
94101

0 commit comments

Comments
 (0)