public void ReceiveProc(long pData, int lWidth, int lHeight, int lBitCount, int lSize, int bTopDown) { if (!_owner.IsDisposed && !_owner.Disposing) { try { if (_width != lWidth || _height != lHeight || _bitCount != lBitCount || _topDown != bTopDown) { if (_image != null) { _image.Dispose(); } _image = new RasterImage(RasterMemoryFlags.Conventional, lWidth, lHeight, lBitCount, RasterByteOrder.Bgr, bTopDown == 1 ? RasterViewPerspective.TopLeft : RasterViewPerspective.BottomLeft, null, null, lSize); _width = lWidth; _height = lHeight; _bitCount = lBitCount; _topDown = bTopDown; } _image.Access(); _image.SetRow(0, new IntPtr(pData), lSize); _image.Release(); Form1 form = _owner as Form1; if (form != null) { GuideRect = CreditCardScanner.GetGuideFrame(_owner.ClientRectangle.Width, _owner.ClientRectangle.Height, form.CaptureCtrl.Width, form.CaptureCtrl.Height); _owner.Invalidate(); } if (!_isRecognized && _threading == false) { byte[] data = new byte[lSize]; System.Runtime.InteropServices.Marshal.Copy(new IntPtr(pData), data, 0, lSize); Task processFrame = Task.Factory.StartNew(() => ProcessFrame(data, lWidth, lHeight, bTopDown, lBitCount)); } if (_isRecognized == true) { MessageBox.Show(_recognizedCardNumber); _recognizedCardNumber = ""; _isRecognized = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public Callback(Control owner) { _owner = owner; _scanner = new CreditCardScanner(); }