Updated November 7, 2014 11:38 pm - Windows 8.1 now supports scanning, so your users can capture images directly in Windows Store apps. By choosing to integrate scanners in your apps, your users can interact with their devices to easily get photos and documents straight from physical media. The digitized versions can then be stored or even shared on social media. You can customize how your scanning UI looks and feels to your users. You can even brand your app on the scan experience it provides, setting yourself apart from other apps.
Let’s take a look at how your app can use the new Scan Runtime APIs to scan documents and photos.
Why should your app incorporate image scanning?
Great apps enable your users to be more productive; users can archive, modify, and share content in streamlined experiences when you provide the right tools to transform media from the physical to the digital world.
If your app needs a user’s signature from a printed page, you need to ensure that the page can be scanned in and identified by your app. Users might want to load non digital photos into your app. Without scanning capabilities, they won’t be able to do this.
Supporting document acquisition can help integrate your users’ existing documents and paper-based processes into your service, thereby increasing its value.
Whether you’re building apps that need to quickly acquire sketches for creative projects, bring in high resolution photos to organize and archive, or process documents with text-recognition work, you can easily orchestrate this by using the Windows.Devices.Scanners namespace.
Identifying scanners and drivers for your apps
The majority of consumer scanners connected to Windows are multi-function (or all-in-one) printer devices. These types of devices do more than just print; they scan, copy, and even fax. The scanner components typically consist of a flatbed that contains a glass panel on which images or documents are placed, or a feeder that allows users to scan in multiple pages without manual intervention. There are also standalone scanners that have no printer capabilities.
In order for your users to scan from your app, they must have a WIA (Windows Image Acquisition) compatible scanner that has been installed on their machine and that uses a WIA 2.0 scan driver. (WIA 2.0 has been a logo requirement for all locally-connected scanner devices since June 2010.) The installed device must appear listed in Device Manager, Devices and Printers, Scanners and Cameras, etc. A quick way to check to see if the system is configured properly to use a scanner is to run a test scan with the inbox Scan app.
Windows helps make the vast majority of scanners work by giving driver support. Windows provides a single in-box driver solution for all Wi-Fi and Ethernet connected scanners that implement the Microsoft WSD (Web Services on Devices) scanning protocol, WS-Scan. This allows network-connected scanners to just work with Windows without additional drivers. If a scanner is connected via USB, there’s a good chance that the right WIA driver is available on the user’s system. Their system may use a Windows provided in-box driver, a driver pulled from Windows Update, or manually downloaded driver from the scanner manufacturer’s website. Feel confident that using the Scan Runtime APIs is supported on the top scanners and multi-function devices available in the ecosystem today.
What are the new scan APIs built on?
Apps need not be developed specifically for particular scanner devices. The Windows Image Acquisition (WIA) platform standardizes the interaction between apps and scanner devices. Any app in Windows 8.1 can use a scanner device as long as the device is WIA-compatible and a WIA 2.0 driver is installed on the machine.
WIA provides a framework that allows a device to present its unique capabilities, and for apps to invoke those capabilities. Those familiar with Windows Imaging Acquisition (WIA) can appreciate the muscle this platform brings to table; it’s the stability and power that the new Scan Runtime APIs are built on top of. The WIA platform consists of the WIA COM APIs, WIA services, and kernel-mode drivers. You can learn more about WIA Windows Image Acquisition (WIA).
Figure 1: Your Store app can use the Scan Runtime APIs built on the Windows Imaging Acquisition platform.
How to implement scanning in your app
Check out the Quickstart: Scanning guide for a jump start on building apps that scan. Watch this video for a quick overview on how to add scanning to your app.
Figure 2: This image summarizes the steps to add scanning to your app- from getting the scanner object, to previewing and scanning using specified scan settings.
The Scan Runtime APIs supports scanning from three sources: Flatbed, Feeder, and Auto-configured. After the scan source is selected, the remaining settings become available for specification, or your app can scan immediately using the defaults.
Here are some common settings you may want to expose in your app.
Note: It’s best to keep the scanning experience as simple as possible for your users. You might want to hide more advanced settings so that users can quickly get what they need scanned.
Resolution: A user may want to scan photos at very high resolutions but documents at much lower resolutions providing greater scanning speed. Your app can specify resolution, the fidelity at which an image is scanned, using the DesiredResolution property. A device provides the range of values supported by providing the minimum and maximum resolution, but won’t list all values supported. You can get this information by setting the DesiredResolution property, and this property chooses the closest resolution value, which is ActualResolution property. In this example, a flatbed scanner is set to scan at a resolution of 100 DPI, given that the resolution is supported by the scanner.
ImageScannerResolution resolution = new ImageScannerResolution();
Resolution.DpiX = resolution.DpiY = 100;
myScanner.FlatbedConfiguration.DesiredResoltuion = resolution;
File type: When you use the ImageScannerFormat enumeration, your app can directly scan to the following document and image file types, only if they are supported by your device: Bitmap, JPEG, PNG, XPS, OXPS, PDF, TIFF.
myScanner.FlatbedConfiguration.Format = ImageScannerFormat.jpeg;
If a device fails to provide a certain format, you can supplement the functionality by making it available. Your app can use the file-conversion APIs (see the BitmapEncoder and BitmapDecoder classes in the Windows.Grapics.Imaging namespace) to convert the scanner’s native file type to the desired file type. You can even add text recognition features so that your users can scan papers into reconstructed documents with formatted, selectable text. You can provide filters or other enhancements so that scanned images can be adjusted by a user. Ultimately, you should not feel limited by what your users’ devices can or cannot do.
As you bring new functionality into your app, keep the scan experiences simple and consistent for your users. If a user needs to quickly scan many documents, avoid cluttering the UI with scan settings decisions (like brightness/contrast), in order to let the user get their jobs done. A good example of a simple, yet powerful Windows Store app that scans is the Scan app, which is included in Windows 8.1. You can find it by searching for Scan using the Search charm.
How to handle errors from the device
Your app can capture error cases returned by the Scan Runtime APIs with WIA HRESULTS, which are defined in the WIA Error Codes list. These include errors like device busy, paper jam, and other device-specific situations. Unless an error is actionable, like a paper jam, it’s best to represent errors with a general error message that something went wrong with the scan job. You can get codes based on the Microsoft Platform SDK, file: /Include/WiaDef.h
Apps that scan can do more
Scanning in Windows Store apps is now possible in Windows 8.1. Windows has the hardware ecosystem and you have a great opportunity to create apps that provide the best end-to-end experience. Your apps can bring together user’s documents to the business logic of your app. They can provide users with new capabilities for their data-rich, physical papers, or they can post-process acquired visuals. Scanning technology has the potential to make your apps do more, by acquiring data and images from media directly from the real world.
–Monica Czarny, Program Manager, Windows