19 private Color[] orginalc;
20 private Color32[] targetColorARR;
21 private byte[] targetbyte;
22 private int W, H, WxH;
33 BarcodeReader barReader;
37 barReader =
new BarcodeReader();
38 barReader.AutoRotate =
true;
39 barReader.TryInverted =
true;
45 Debug.LogError(
"the Device Controller is not exsit,Please Drag DeviceCamera from project to Hierarchy");
52 if (framerate++ % 15 == 0)
54#elif UNITY_IOS || UNITY_ANDROID
55 if (framerate++ % 15== 0) {
57 if (framerate++ % 20== 0) {
64 if (W < 100 || H < 100)
return;
66 if (!isInit && W > 100 && H > 100)
68 blockWidth =
Math.Min(W, H);
72 if (targetColorARR ==
null) targetColorARR =
new Color32[blockWidth * blockWidth];
74 var posx = (W - blockWidth) >> 1;
75 var posy = (H - blockWidth) >> 1;
81 for (var i = 0; i != blockWidth; i++)
82 for (var j = 0; j != blockWidth; j++)
84 targetColorARR[i + j * blockWidth].r = (byte) (orginalc[i + j * blockWidth].r * 255);
85 targetColorARR[i + j * blockWidth].g = (byte) (orginalc[i + j * blockWidth].g * 255);
86 targetColorARR[i + j * blockWidth].b = (byte) (orginalc[i + j * blockWidth].b * 255);
87 targetColorARR[i + j * blockWidth].a = 255;
96 data = barReader.Decode(targetColorARR, blockWidth, blockWidth);
100 dataText = data.Text;
111 data = barReader.Decode(targetColorARR, blockWidth, blockWidth);
115 dataText = data.Text;
124 tempDecodeing = decoding;
135 tempDecodeing = decoding;
145 tempDecodeing = decoding;
154 tempDecodeing = decoding;
165 var codeReader =
new BarcodeReader();
166 codeReader.AutoRotate =
true;
167 codeReader.TryInverted =
true;
169 var data = codeReader.Decode(tex.GetPixels32(), tex.width, tex.height);
172 return "decode failed!";
void StartWork()
start the work.
void StopWork()
Stops the work. when you need to leave current scene ,you must call this func firstly
int Width()
get the width of the camera
int Height()
get the height of the camera
Color[] GetPixels()
get the Pixels of the camera image
static void RunAsync(Action a)
void Reset()
Reset this scan param
void StopWork()
Stops the work.
void StartWork()
Stops the work.
DeviceCameraController e_DeviceController
static string DecodeByStaticPic(Texture2D tex)
Decodes the by static picture.
delegate void QRScanFinished(string str)
QRScanFinished onQRScanFinished