internal void Read(WABarcodeReader reader, string image, string types = "", string directions = "", uint tbr_code = 0) { bShowDiag = reader.diagCallback != null; try { if (bUseAsync) { if (callback == null) // Set callback for asynchronous calls { callback = ReaderCallback; } reader.ReadAsync(image, callback, image, types, directions, tbr_code); } else { WABarcode[] barcodes = reader.Read(image, types, directions, tbr_code); if (showBarcodes != null) { showBarcodes(barcodes); } } } catch (Exception ex) { if (showError != null) { showError(ex); } } }
internal void ReadAsync(string image, delReaderCallback callback, Object obj, string types = "", string directions = "", uint tbr_code = 0) { _barcodes = new WABarcode[] { }; _error = ""; WACallback cb = new WACallback(); if (callback != null) { cb.callback = callback; cb.obj = obj; cb.isAsync = true; } else { cb.callback = _ReaderCallback; cb.obj = this; cb.isAsync = false; } _image = image; cb.call("image", image); string[] names = image.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); List <string> urls = new List <string>(), files = new List <string>(), images = new List <string>(); foreach (string name1 in names) { string name = name1.Trim(); string s = name.ToLower(); if (s.StartsWith("http://") || s.StartsWith("https://") || s.StartsWith("ftp://") || s.StartsWith("file://")) { urls.Add(name); } else if (File.Exists(name)) { files.Add(name); } else if (name.StartsWith("data:") || WAUtils.isBase64(name)) { images.Add(name); } else { throw new Exception("Invalid image source: " + name.Substring(0, Math.Min(name.Length, 256))); } } ReadLocal(urls, files, images, types, directions, tbr_code, cb); }