File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
wrappers/android/zxingcpp/src/main/java/com/zxingcpp Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -20,11 +20,19 @@ import android.graphics.Bitmap
20
20
import android.graphics.ImageFormat
21
21
import android.graphics.Point
22
22
import android.graphics.Rect
23
+ import android.os.Build
23
24
import androidx.camera.core.ImageProxy
24
25
import java.lang.RuntimeException
25
26
import java.nio.ByteBuffer
26
27
27
28
public class BarcodeReader {
29
+ private val supportedYUVFormats: List <Int > =
30
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
31
+ listOf (ImageFormat .YUV_420_888 , ImageFormat .YUV_422_888 , ImageFormat .YUV_444_888 )
32
+ } else {
33
+ listOf (ImageFormat .YUV_420_888 )
34
+ }
35
+
28
36
init {
29
37
System .loadLibrary(" zxing_android" )
30
38
}
@@ -71,9 +79,8 @@ public class BarcodeReader {
71
79
public var options : Options = Options ()
72
80
73
81
public fun read (image : ImageProxy ): Result ? {
74
- val supportedYUVFormats = arrayOf(ImageFormat .YUV_420_888 , ImageFormat .YUV_422_888 , ImageFormat .YUV_444_888 )
75
- if (image.format !in supportedYUVFormats) {
76
- error(" invalid image format" )
82
+ check(image.format in supportedYUVFormats) {
83
+ " Invalid image format: ${image.format} . Must be one of: $supportedYUVFormats "
77
84
}
78
85
79
86
var result = Result ()
You can’t perform that action at this time.
0 commit comments