# BbScanner (Component) `Bit.BbScanner.BbScanner` - inherits `ComponentBase` - implements `IAsyncDisposable`, `IComponent`, `IHandleAfterRender`, `IHandleEvent` A camera barcode scanner. The component owns the camera, the frame loop and one BbBarcodeDecoder. Frames never enter the Blazor render tree: the video element paints itself, the decoder reads pixels out of a buffer JavaScript writes into directly, and the component only re-renders when something a user can see actually changes. A scanner running at twenty frames a second typically renders a handful of times a minute. Continuous camera scanning requires Blazor WebAssembly, because it depends on the browser interop that lets JavaScript write into managed memory. On other render modes the component reports BbScannerErrorKind.NotSupported rather than silently degrading. ## Parameter - **AdditionalAttributes** : `IReadOnlyDictionary` - Any other attributes are applied to the root element. - **AriaLabel** : `string` = `"Barcode scanner"` - Accessible name for the scanner region. - **AutoStart** : `bool` = `true` - Start the camera as soon as the component is ready. - **ChildContent** : `RenderFragment` - Arbitrary content rendered on top of the scanner. - **ControlsContent** : `RenderFragment` - Extra controls appended to the built-in control bar. - **CssClass** : `string` - Extra CSS classes for the root element. - **DeviceId** : `string` - A specific camera to open, from BbScanner.GetCamerasAsync. Changing it while the scanner is running switches cameras. - **DuplicateSuppressionWindow** : `TimeSpan?` - How long the same value is suppressed after being reported. When not set, the value from BbScanner.Options applies, and failing that two seconds. - **EnableFileScanning** : `bool` = `true` - Offer the built-in still image scanning control. - **Facing** : `BbCameraFacing` = `BbCameraFacing.Rear` - Which camera to prefer when BbScanner.DeviceId is not set. - **Fill** : `bool` = `false` - Stretch to the size of the parent instead of keeping the camera's aspect ratio. The video is cropped to fill; overlays and highlights are mapped onto the visible part. - **Formats** : `BbBarcodeFormat` = `BbBarcodeFormat.All` - The symbologies to look for. - **HighlightResults** : `bool` = `true` - Outline a decoded symbol where it was found in the frame. - **MaxProcessingSize** : `int` = `640` - Longest edge, in pixels, of the image the decoder actually sees. Frames are scaled down to this by the browser before they cross into managed code, which is the single most effective performance control the component exposes. - **MessageTemplate** : `RenderFragment` - Replaces the rendering of status and error messages. - **OnCameraChanged** : `EventCallback` = `default` - Raised when a camera is opened, with what the browser negotiated. - **OnDiagnostics** : `EventCallback` = `default` - Raised at most twice a second with the timings of the most recent frame. Subscribing has no cost when nothing is listening. - **OnError** : `EventCallback` = `default` - Raised when the scanner fails to start or the camera is lost. - **OnScan** : `EventCallback` = `default` - Raised for every accepted scan, after duplicate suppression. - **OnStatusChanged** : `EventCallback` = `default` - Raised whenever BbScanner.Status changes. - **Options** : `BbScannerOptions` - Advanced tuning. When supplied, BbScanner.Formats, BbScanner.Region and an explicitly set BbScanner.DuplicateSuppressionWindow are still applied on top of it, so the common cases do not need this at all. - **Overlay** : `RenderFragment` - Replaces the built-in reticle entirely. - **Region** : `BbScanRegion` = `BbScanRegion.Full` - The part of the frame to search, in normalized coordinates. The default searches the whole frame; a centred square is the usual choice for an aiming user interface. Still images scanned through the file picker are always searched in full. - **RequestedHeight** : `int` = `720` - Camera height to ask the browser for. - **RequestedWidth** : `int` = `1280` - Camera width to ask the browser for. The browser is free to negotiate something else. - **ShowControls** : `bool` = `true` - Show the built-in control bar. - **ShowMask** : `bool` = `true` - Dim the area outside BbScanner.Region. - **ShowReticle** : `bool` = `true` - Draw the corner reticle. Ignored when BbScanner.Overlay is supplied. - **ShowStatusBar** : `bool` = `true` - Show the built-in status bar. - **TargetFrameRate** : `int` = `15` - How many frames a second to decode. Higher costs battery for little benefit above about twenty. ## Property - **Camera** : `BbCameraInfo` - What the browser negotiated for the open camera, or null. - **Cameras** : `IReadOnlyList` = `new List()` - Cameras discovered by the last call to BbScanner.GetCamerasAsync. - **Diagnostics** : `BbScanDiagnostics` = `default` - Timings from the most recently decoded frame. - **FramesDecoded** : `long` = `0` - Number of camera frames decoded since the scanner was created. - **FramesWithSymbol** : `long` = `0` - Number of camera frames that contained a symbol, before duplicate suppression. - **IsTorchOn** : `bool` = `false` - Whether the torch is currently on. - **ProcessingSize** : `ValueTuple` = `default` - Size of the frames handed to the decoder, or zero before the camera has opened. - **Status** : `BbScannerStatus` = `BbScannerStatus.Idle` - Current lifecycle state. - **Zoom** : `double` = `0` - Current zoom value, or zero when zoom is not supported. ## Method - **DecodeImage**(ReadOnlySpan pixels, int width, int height, BbPixelFormat format) : `BbBarcodeResult` - Decodes an image already loaded into a pixel buffer, for applications that source images themselves rather than through the built-in picker. The whole image is searched with the still image settings, using the symbologies and options of this scanner. - **DisposeAsync**() : `ValueTask` - **GetCamerasAsync**() : `Task>` - Enumerates the available cameras. Browsers withhold camera labels until permission has been granted once, so calling this before BbScanner.StartAsync tends to return generic names. - **OpenFilePickerAsync**() : `Task` - Opens the file picker so the user can scan a still image. - **Pause**() : `void` - Stops decoding but keeps the camera open, so resuming is instant. - **Resume**() : `void` - Resumes decoding after BbScanner.Pause. - **SetTorchAsync**(bool on) : `Task` - Turns the torch on or off where the camera supports it. - **SetZoomAsync**(double zoom) : `Task` - Sets the zoom where the camera supports it. - **StartAsync**(string deviceId = null) : `Task` - Opens the camera and starts decoding. Calling this while a previous start is still waiting for the permission prompt supersedes that start: only the most recent request ever ends up owning the camera. - **StopAsync**() : `Task` - Stops decoding and releases the camera. - **SwitchCameraAsync**(string deviceId) : `Task` - Switches to another camera without tearing the component down.