Windows Imaging Architecture - WIA
Note: Complete information about WIA support is provided in the current Windows DDK.
Windows Image Acquisition (WIA) architecture includes various components provided by the ISV, the IHV, and Microsoft, as shown in the following illustration.
The majority of the services are provided natively in Microsoft Windows XP and Windows Millennium Edition (Windows Me). Each of the components shown in the architecture provides services for the WIA clients as follows:
Windows Explorer User Interface
To allow users to think of WIA devices as natural extensions of Windows, various UI components have been added as Windows Explorer extensions. For example, once a WIA device is installed, an icon automatically appears on My Computer. When "browsing" a digital camera, a view is available that allows users to interact with pictures on the camera and with the camera itself.
To install or configure a WIA device, a new Scanners and Cameras folder has been added to the Control Panel. From the Scanners and Cameras folder, the user can configure various device options such as Color Management profiles, default event handlers, default behavior on events (such as a connect event for a USB camera), and more.
To make installation easier, the Imaging Class Installer has been enhanced to support easy removal and installation of WIA devices. The class installer supports Plug and Play devices for USB, SCSI, and IEEE 1394 buses. It also supports serial-based digital still cameras.
The class installer is also linked to the new device upgrade API, which is the recommended way to upgrade WIA device drivers.
Scanner and Camera Wizard
The Scanner and Camera Wizard allows users to easily retrieve images from all supported devices. Depending on the device type, the wizard presents the user with device-specific features. For example, when a WIA scanner is being used, a preview page is shown where the user can select the scan area, zoom on the scan area, adjust settings (DPI, Brightness and Contrast, and so on), and select the image type (Color, Black & White, Text).
For a still digital camera, the wizard allows the user to select one or more pictures, rotate them if necessary, and view picture information (when taken, size, resolution, and so on).
For a video camera, the wizard allows the user to select all already-captured still images, rotate them, and view picture information. Note that, to capture still images, the user needs to capture either from within a WIA application (such as MS Paint) or through the advanced mode (Windows Explorer namespace extension).
The wizard also allows the user to name the pictures, save it in My Pictures folder, categorize pictures through sub-folders, and more.
The wizard is also the default event handler for WIA scanners' scan event and for Plug and Play still digital cameras' connect event. The wizard is not launched by default for video cameras.
For non-Plug and Play devices, the wizard can be launched from the Accessories menu (click Start > Programs > Accessories > Scanner and Camera Wizard).
Visual Basic and others
WIA includes a scripting model, which presents most WIA device features to a scripting based application. This feature is primarily for advanced users and IS professionals who want to develop WIA applications using Microsoft Visual Basic, Visual Basic for Applications (VBA), Visual Basic for Scripting (VBS), and other scripting languages.
Examples of applications may include: Microsoft Office-based applications using VBA, a Microsoft Access-based employee database that takes pictures and automatically populates the database, web pages that allow users to upload pictures directly from WIA devices, and more.
The automation layer is a provided by the WIA architecture. This ensures consistency and minimizes the amount of work by the IHV to get its drivers accessible through Visual Basic and other scripting languages. This layer also provides the "safe for scripting" security layer.
Note: Once a WIA driver is written, this component exposes the scripting interfaces to applications. Driver developers do not need to provide IDispatch interfaces.
An application writer has four choices for communicating with WIA devices:
Use the WIA high-level interfaces, which are tied to the WIA common dialogs. With minimal effort, this approach provides direct communication to WIA devices
Program directly to the WIA interfaces. This adds flexibility to the application developer to implement custom solutions such as UI-less mode support for devices
Use the TWAIN compatibility layer, which exposes WIA devices as TWAIN devices.In Windows Me, the compatibility layer is limited to the following:
UI-mode only (cannot suppress the UI)
Single image transfers (including from Automatic Document Feeders [ADFs])
These limitations do not apply for Windows XP.
Support the common file open/insert dialog (see the Comdlg32.dll documentation for details). In this case, applications can "open" or "insert" pictures directly from actively connected WIA cameras. For example, Microsoft Outlook Express can "insert picture" from a WIA camera without knowing anything about WIA.
Note: The common file open/insert dialog is not supported for scanners, and it is only supported with video cameras after frames have been captured.
When programming directly to the WIA interfaces (option 2 above), application developers receive the following benefits:
A robust and stable environment (for example, if a driver faults, the application is not affected)
Fast data transfer with banded support
An event registration model for registering applications to device events (for example, scan, connect, and so on)
Support for callback for true status update
Connection to multiple devices at the same time
System-provided common dialogs for scanners, still cameras, and frame capture from supported video devices
Support for suppressed UI mode
For details about these interfaces, see WIA SDK in the Microsoft Platform SDK (available at http://msdn.microsoft.com/).
To provide the TWAIN compatibility layer to applications, the TWAIN Data Source Manager (DSM) has been updated to dynamically enumerate WIA device drivers. The latest version of DSM is 1.7.1. Note that this version may be different from the version supplied by the TWAIN Working Group.
Note: The DSM version that ships with Windows is a system component and is not re-distributable.
Compatibility Data Source
This TWAIN data source exposes the functionality from a WIA device driver to TWAIN applications. When applications communicate with this data source, they do not notice any difference between a native TWAIN data source and the WIA compatibility data source.
As previously mentioned, in Windows Me, this data source is limited to UI-only mode and single image transfers. In Windows Me, the file transfer feature is limited to BMP type. These limitations do not apply for Windows XP.
Common / IHV dialogs
By default, all drivers that ship in Windows use the WIA common system dialogs. There currently are four dialogs as follows:
Scanner common dialog: This dialog allows the user to preview, crop, scan, and set scan properties (brightness, contrast, and so on).
This dialog also includes three macro settings: Color picture, Grayscale picture, and Black-and-White picture or text. The dialog also allows the user to set custom settings.
When the device has an ADF, the dialog exposes two more selections: Paper source and Page size.
Because the dialog is resizable, the preview window can be as large as the size of the screen.
This dialog is extensible by IHVs through the
custom settings page. The page can host various property sheets.
Still camera common dialog: This dialog allows the user to view thumbnails, preview full-sized pictures, view picture information, and delete pictures.
As with the scanner dialog, this dialog is resizable.
This dialog is extensible through the picture information page. The page can host various property sheets.
Video camera common dialog: This dialog allows the user to view a live or recorded (DV camcorder) video stream and capture one or more frames from the stream. Once captured, the frames can be retrieved as standard WIA pictures.
This dialog is not extensible.
Device selection dialog: This dialog allows the user to select which WIA device to work with when multiple WIA devices are installed. It also allows the user to see and set the device property information.
Aside from the extensibility model, IHVs can register their own UI for their WIA devices and present their own experience to an application.
Suppressed UI Mode
In some cases, applications want to preserve their own predefined UI experience. To help with this, WIA can be always called in suppressed-UI mode. This allows applications to create their own acquisition pages and to communicate directly with the WIA device without going through the system or IHV UI.
WIA is based on Microsoft COM / DCOM, which creates a client/server environment between the application and the WIA services and drivers. Using this industry standard model, applications can recover from conditions such as faulty drivers.
Once a WIA device driver has been instantiated through the Device Manager, a device object is created. This newly instantiated device object allows the application to communicate with the hardware.
There are four types of possible device objects:
WIA minidriver. A WIA minidriver is the most versatile and extensible model provided by WIA. Using a WIA minidriver, IHVs can expose extensions, private interfaces, custom settings, and device-specific behavior. For example, a scanner manufacturer may choose to write a WIA scanner minidriver that exposes OCR functionality to applications. This is the driver model shown in the architecture diagram at the beginning of this discussion.
WIA generic scanner minidriver. This driver is targeted specifically at flatbed and simple ADF scanners. With minimal effort, IHVs can write drivers for their scanners using this model. The key part the vendor needs to write is a relatively simple micro-driver to provide the device-specific protocol. Using this device object instead of a minidriver requires fewer tests and offers less possibility for errors. This driver model was developed with Windows Logo Program for hardware requirements in mind.
WIA generic PTP 15740 camera. This driver is targeted at digital still cameras. By supporting the PTP 15740 protocol on the camera firmware, a camera manufacturer is not required to provide a driver for the host PC. WIA recognizes all PTP 15740 digital still cameras and provides all the end user services as outlined in the architecture diagram.
WIA generic video camera object. To allow users to retrieve stills (frames) from streaming devices, WIA now includes a Microsoft DirectShow filter that's exposed as a WIA device to the Windows Explorer UI, the application dialogs, and to a WIA application that uses the WIA APIs.
If the streaming device has a still pin, the filter uses it. If the still pin is not available, the filter creates a software-based still pin on the fly. Supported devices include USB web cams that use Usbcamd2.sys and IEEE 1394-based DV camcorders that conform to IEC 61883-1 and 61883-2.
For a web cam to work with this driver, the IHV must provide an INF and use the Usbcamd2.sys WDM driver. For more details about the INF, see the WIA DDK in the Windows DDK.
Note: All device objects are in the context of the application. This means that multiple applications can instantiate the same device object, modify its settings, and communicate with the same physical device.
WIA Device Manager Object
The WIA Device Manager can be thought of as a broker. When an application first attempts to communicate with a device, the WIA Device Manager enumerates all the devices, instantiates the device objects, establishes the link between the application and the device object, retrieves and sets device properties, sets up and manages device events, manages locking and unlocking, monitors status, and more.
Driver Services Library
This library includes driver services specific to WIA devices. The functions are exported as driver services, which include the most common device-independent operations.
The WIA architecture is built upon the foundation established by the Microsoft Still Image Architecture (STI), which is based on the Windows Driver Model (WDM) introduced in Windows 98 for imaging devices.
The WDM drivers supplied by WIA are for USB, SCSI, and IEEE 1394 (through SBP2 only). These drivers are also known as the STI kernel-mode drivers.
Even though these drivers are pass through from the WIA device driver perspective, they provide services such as power management, and others.
Note: A WIA user mode minidriver can be written without using one of these drivers. However, IHVs are strongly encouraged to use these drivers because writing WDM kernel-mode drivers is an involved task.
Other Imaging Features Associated with WIA
Because acquisition is only part of the digital imaging end-user experience, other features have been added to Windows to provide the end-to-end experience.
My Pictures folder
This folder was first introduced in Windows 2000. In Windows Me and Windows XP, this folder has been enhanced with the following:
Improved thumbnail generation
Link to launch the WIA Scanner and Camera Wizard: This link shows up only if there are WIA devices installed on the PC. When clicked, this link launches the wizard and allows the user to switch between the device and My Pictures folder.
A slideshow applet: To immediately enjoy all acquired pictures, the user can launch a built-in slideshow. The slideshow is preset to switch between pictures every few seconds.
An enhanced preview window: the preview window now allows the user to rotate pictures, view various file types including PNG, TIFF, GIF, JPEG, BMP, and more.
Print pictures from the preview window: To get the best possible picture, a print applet has been added to print PNG, JPG, and other file types.
A screensaver called My Pictures Screensaver is included for users to further enjoy their pictures. The screensaver supports transitions, password protection, traversing folder hierarchies, and more.
The screensaver can be accessed through the Desktop Properties (for example, right click the desktop, click Properties, click Screensaver tab, and select My Pictures Screensaver).
Microsoft Paint has been modified to support WIA. When a WIA device is present, the From Scanner or Camera menu item is enabled on the MS Paint File menu. This allows users to retrieve pictures directly from WIA devices.