private Result[] ReadQRLocationsFromScreen() { using (var bitmap = ReadPrimaryScreenBitmap()) { var hBitmap = bitmap.GetHbitmap(); Logger.Info("Scanning for barcodes"); var decoder = new BarcodeDecoder(); var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); DeleteObject(hBitmap); var writeableBitmap = new WriteableBitmap(bitmapSource); Result[] ret = decoder.DecodeMultiple(writeableBitmap); Logger.Info("Done!"); return(ret); } }
public static Result[] ReadQRsFromScreen(int sourceX, int sourceY, Size size) { Logger.Info("Scanning for barcodes"); using (var bitmap = ReadPrimaryScreenBitmap(sourceX, sourceY, size)) { var hBitmap = bitmap.GetHbitmap(); var decoder = new BarcodeDecoder(); var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); DeleteObject(hBitmap); var writeableBitmap = new WriteableBitmap(bitmapSource); Result[] results = decoder.DecodeMultiple(writeableBitmap); Logger.Info("Done!"); return(results); } }