|
1 | 1 | package io.snabble.sdk.ui.scanner; |
2 | 2 |
|
| 3 | +import android.graphics.Bitmap; |
| 4 | +import android.graphics.BitmapFactory; |
| 5 | +import android.graphics.ImageFormat; |
3 | 6 | import android.graphics.Rect; |
| 7 | +import android.graphics.YuvImage; |
4 | 8 |
|
5 | 9 | import com.google.zxing.Binarizer; |
6 | 10 | import com.google.zxing.BinaryBitmap; |
|
12 | 16 | import com.google.zxing.Result; |
13 | 17 | import com.google.zxing.common.HybridBinarizer; |
14 | 18 |
|
| 19 | +import java.io.ByteArrayOutputStream; |
| 20 | +import java.io.FileNotFoundException; |
| 21 | +import java.io.FileOutputStream; |
15 | 22 | import java.util.ArrayList; |
16 | 23 | import java.util.HashMap; |
17 | 24 | import java.util.List; |
18 | 25 | import java.util.Map; |
19 | 26 |
|
20 | 27 | import io.snabble.sdk.BarcodeFormat; |
| 28 | +import io.snabble.sdk.Snabble; |
| 29 | +import io.snabble.sdk.ui.SnabbleUI; |
21 | 30 | import io.snabble.sdk.utils.Logger; |
22 | 31 |
|
23 | 32 | public class ZXingBarcodeDetector implements BarcodeDetector { |
@@ -76,19 +85,17 @@ public Barcode detect(byte[] data, int width, int height, int bitsPerPixel, Rect |
76 | 85 | } |
77 | 86 |
|
78 | 87 | 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); |
88 | 89 |
|
89 | 90 | int tWidth = detectionRect.width(); |
90 | 91 | int tHeight = detectionRect.height(); |
91 | 92 |
|
| 93 | + if (rotate) { |
| 94 | + int tmp = tWidth; |
| 95 | + tWidth = tHeight; |
| 96 | + tHeight = tmp; |
| 97 | + } |
| 98 | + |
92 | 99 | LuminanceSource luminanceSource = new PlanarYUVLuminanceSource(buf, tWidth, tHeight, |
93 | 100 | 0, 0, tWidth, tHeight, false); |
94 | 101 |
|
|
0 commit comments