Windows image acquisition automation layer

Wiaaut.dll

Windows Image Acquisition Automation Layer

The Microsoft® Windows® Image Acquisition (WIA) Automation Layer version 2.0 is a high-quality, full-featured image manipulation component that provides end-to-end image processing capabilities for Microsoft Visual Basic® 6.0, Active Server Pages (ASP), and scripting languages. The WIA Automation Layer exposes features in Windows XP Service Pack 1 or later to make it easy to acquire images on digital cameras, scanners, or web cameras, and to rotate, scale, and annotate your image files. Earlier versions of Windows are not supported.

Источник: wiaaut.chm

Библиотека:

  • msdn: Windows Image Acquisition Automation Layer
    • msdn: Windows Image Acquisition
  • http://download.microsoft.com/download/WinXPHome/Utility/2.0/WXP/EN-US/WIAAutSDK.zip

Использование из 1Cv8

Источник: http://www.forum.mista.ru/topic.php?id=271373

Device = Новый COMОбъект("WIA.DeviceManager");
Количество = Device.DeviceInfos.Count;
oDevice = Новый Массив(Количество);
Для К=1 По Количество Цикл
    Если Device.DeviceInfos(к).Type = 3 Тогда
        Попытка
            oDevice[к-1] = Device.DeviceInfos(к).Connect();
        Исключение
            oDevice[к-1] = Неопределено;
        КонецПопытки;
    Иначе
        oDevice[к-1] = Неопределено;
    КонецЕсли;
КонецЦикла;
    
Для К = 1 По Количество Цикл
    Если oDevice[к-1] <> Неопределено Тогда
        Item = oDevice[к-1].ExecuteCommand("{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}");
        Image = Item.Transfer("{557CF401-1A04-11D3-9A73-0000F81EF32E}");
        Image.SaveFile("D:\aaa.jpg");
    КонецЕсли;
КонецЦикла;

Сканирование документов из JScript

Источник: http://community.terrasoft.ua/node/2324

5 октября 2008 — 16:35 Опубликовано: S.Kalishenko

А теперь немного о не менее интересном, чем печать документов. А именно, сканирование. Как я уже упоминал чуть ниже в блоге, для сканирования документов можно использовать WIA от Microsoft. Для этого необходимо предварительно установить библиотеку wiaaut.dll от MS. Т.е. ее необходимо скачать, установить (используя regsvr32.exe) и далее можно использовать методы COM-объекта WIA.

А теперь сам код.

//-----------------------------------------------------------------------------
// scr_ScanUtils
//-----------------------------------------------------------------------------
 
// Device Types
var UnspecifiedDeviceType = 0;
var ScannerDeviceType = 1;
var CameraDeviceType = 2;
var VideoDeviceType = 3;
 
// Commands
var wiaCommandSynchronize = '{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}';
var wiaCommandTakePicture = '{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}';
var wiaCommandDeleteAllItems = '{E208C170-ACAD-11D2-A093-00C04F72DC3C}';
var wiaCommandChangeDocument = '{04E725B0-ACAE-11D2-A093-00C04F72DC3C}';
var wiaCommandUnloadDocument = '{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}';

// Picture formats
var wiaFormatBMP = '{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}';
var wiaFormatPNG = '{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}';
var wiaFormatGIF = '{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}';
var wiaFormatJPEG = '{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}';
var wiaFormatTIFF = '{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}';

// Группа "Все файлы"
var RootFilesGroup = '{F03EDFB0-C246-4A9D-B0E4-DA8C8B3DD338}';

function ConvertImageFile(ImageFile, Format) {
        var IP = System.CreateObject("Wia.ImageProcess");
        IP.Filters.Add(IP.FilterInfos("Convert").FilterID);    
        IP.Filters(1).Properties("FormatID").Value = Format;
        var Img = IP.Apply(ImageFile);
        return Img;
}

// Сканирование без диалоговых окон на сканер по-умолчанию
function SilentScan(FileName) {
        try {
                System.BeginProcessing();
                var Device;
                var Dialog = System.CreateObject("WIA.CommonDialog");
                var DeviceManager = System.CreateObject("WIA.DeviceManager");
                var Count = DeviceManager.DeviceInfos.Count;
                for(var j = 1; j <= Count; j++) {
                        var DeviceInfo = DeviceManager.DeviceInfos.Item(j);
                        if (DeviceInfo.Type == ScannerDeviceType) {
                                Device = DeviceInfo.Connect();
                                break;
                        }
                }
            if (!Assigned(Device)) {
                        Log.Write(2, "Сканер не обнаружен.");
                        return;
                }
                if ((Assigned(Device.Items)) && (Assigned(Device.Items.Item(1)))) {
                        var item = Device.Items.Item(1);
                        try {
                                var Intent = 1; // цветная печать
                                /* Параметры сканирования */
                                var Properties = item.Properties;
                                for (var i = 1; i <= Properties.Count; i++) {
                                        var PropItem = Properties.Item(i);
                                        switch(PropItem.PropertyID) {
                                                /* Horizontal Resolution */
                                                case 6147: PropItem.Value = 150;
                                                        break;
                                                /* Vertical Resolution */
                                                case 6148: PropItem.Value = 150;
                                                        break;
                                                /* Horizontal Starting Position (Scanning Area) */
                                                case 6149: PropItem.Value = 0;
                                                        break;
                                                /* Vertical Starting Position (Scanning Area) */
                                                case 6150: PropItem.Value = 0;
                                                        break;
                                                /* Current Intent */
                                                case 6146: PropItem.Value = Intent;
                                                        break;
                                        }
                                }
                                /* Старт сканирования */
                                var imageFile = Dialog.ShowTransfer(item);
                            if (Assigned(imageFile)) {
                                if (CheckFileExists(FileName)) {
                                        FileName = GetTemporaryFileName(ShortFileName, false)
                                }
                                /* Преобразование полученного файла в jpeg */
                                var WIAFormat = wiaFormatJPEG;
                                var Img = ConvertImageFile(imageFile, WIAFormat);
                                Img.SaveFile(FileName);
                            }
                        } catch(e) {
                                Log.Write(2, "При сканировании произошла ошибка. Попробуйте, пожалуйста, еще раз.");
                        }
                } else {
                        Log.Write(2, "При инициализации произошла ошибка.");            
                }
        } finally {
                System.EndProcessing();
        }
}

function Main() {
        SilentScan("c:\\temp\\Test.jpg");
}

В приведенном выше коде основной является функция SilentScan(). Поэтому, чтобы начать сканирование, необходимо запускать именно ее, передав полный путь к сохраняемому файлу. В этом примере файл сохраняется в формате jpg, хотя, если это необходимо, WIA позволяет конвертировать полученный объект в ряд других форматов (bmp, png, tiff, gif, jpg). Вообще по-умолчанию после сканирования получается объект в формате bmp. Поэтому, если Вам нужен только bmp-файл, можно просто делать imageFile.SaveFile(FileName) без преобразования. Вроде бы все. Да, и не забудьте подключить к скрипту scr_Utils и scr_FileUtils.

Надеюсь кому-то это решение когда-нибудь пригодится.  :)

Windows Image Acquisition (WIA) is the still image acquisition platform in the Windows family of operating systems starting with Windows Millennium Edition (Windows Me) and Windows XP.

  • Introduction
  • Benefits of Windows Image Acquisition 2.0
    • For Application Writers
    • For Device Manufactures
    • For Scanner Users
  • Development of Windows Image Acquisition
  • Overview of Windows Image Acquisition
  • Facts about Windows Image Acquisition 2.0
  • Developer Audience
  • Run-Time Requirements
  • WIA Topics

Introduction

The WIA platform enables imaging/graphics applications to interact with imaging hardware and standardizes the interaction between different applications and scanners.
This allows those different applications to talk to and interact with those different scanners without requiring the application writers and scanner manufactures to customize their application or drivers for each application-device combination.

Graphic showing the basic architecture of WIA as a two-way layer between imaging applications and devices.

Benefits of Windows Image Acquisition 2.0

WIA provides benefits to application developers, device manufacturers, and scanner users who need to interact with imaging hardware.

For Application Writers

  • Windows runs a certification process for WIA drivers so WIA applications are guaranteed to be base-level compatible with all WIA-based scanners.
  • WIA drivers are loaded in the WIA service process, thus providing a more stable driver environment.
  • Applications can be initiated from the scanner scan button via push events supported by the WIA subsystem.
  • The WIA includes a default segmentation filter that all drivers can take advantage of; this way, applications do not have to write code for multi-region scanning for purposes such as separating out a large number of photos spread over a flatbed scanner.

For Device Manufactures

  • WIA driver certification process helps driver developers in establishing that their driver is WIA-compliant.
  • WIA drivers can take advantage of a built-in segmentation filter, image processing filter and error handler, if they choose to do so.
  • WIA-based scanners work right out of the box on Windows with Windows scanning applications such as Windows Fax and Scan and Paint.
  • WIA drivers offer better integration with Windows such as the full device experience.
  • Windows Vista release includes a WSD-WIA class driver that enables all devices compliant with Web Services for Scanner (WS-Scan) protocol to work with WIA applications without any additional driver or software.

For Scanner Users

  • WIA-based scanners can be used from Windows applications such Windows Fax and Scan and Paint without the need for any additional software.
  • WIA-based applications and scanners can also take advantage of WIA add-ons such as the segmentation filter which enables such features as processing a number of pictures on the scanner and scanning them all to individual files without user intervention.
  • WIA-based devices offers a much better integration with other Windows features such as the Device Stage feature for Windows 7.
  • WIA provides a more robust, stable and reliable scanning experience by isolating the driver and the application.

Development of Windows Image Acquisition

The imaging architecture in Windows 2000 and Windows 95 or later consisted of a low-level hardware abstraction, Still Image Architecture (STI), and a high-level set of APIs known as TWAIN.
In Windows XP and Windows Me WIA was introduced. WIA is an imaging architecture that builds on STI and does not require TWAIN, although TWAIN is still supported alongside WIA.

WIA 1.0 was introduced in Windows Me and Windows XP and supports scanners, digital cameras and digital video equipment.
WIA 2.0 was released with Windows Vista. WIA 2.0 is targeted towards scanners but continues to offer support for legacy WIA 1.0 applications and devices through a WIA 1.0 to WIA 2.0 compatibility layer provided by the WIA service.
However, video content support was removed from WIA for Windows Vista.
We recommend Windows Portable Devices (WPD) API for digital cameras and digital video equipment in the future.
WIA 1.0 as well as STI TWAIN drivers are still supported directly on Windows Vista and Windows 7 alongside native WIA 2.0 device drivers and imaging applications.

Overview of Windows Image Acquisition

WIA provides a framework that allows a device to present its unique capabilities to the operating system and allows imaging applications to invoke those unique capabilities.

The WIA platform includes a data acquisition protocol, a Device Driver Model and Interface (DDI), an API and a dedicated WIA service.
The platform also includes a set of built-in kernel mode drivers that support communication with imaging devices locally connected through USB, serial/parallel, SCSI and FireWire interfaces.
The WIA subsystem also includes a transparent compatibility layer which allows TWAIN compatible applications to employ and use WIA-driver-based devices.

Network connected imaging devices that support Web Services for Devices (WSD) protocol can also be used from WIA-compliant imaging applications on Windows Vista and Windows 7 out of the box via a WSD-WIA class driver that shipped as part of Windows Vista.
The class driver converts WIA calls to WSD calls and vice versa and makes already existing WIA applications work with WSD based scanners without any additional driver.

WIA drivers are made up of a user interface (UI) component and a core driver component, loaded into two different process spaces: UI in the application space and the driver core in the WIA service space.
The service runs in Local System context in Windows XP and runs in Local Service context starting with Windows Server 2003 and Windows Vista for enhanced security against buggy or malicious drivers.

Graphic showing the architecture of WIA and how it operates as a service.

The WIA API set exposes imaging applications to still image acquisition hardware functionality by providing support for:

  • Enumeration of available image acquisition devices.
  • Creating connections to multiple devices simultaneously.
  • Querying properties of devices in a standard and expandable manner.
  • Acquiring device data by using standard and high performance transfer mechanisms.
  • Maintaining image properties across data transfers.
  • Notification of device status and scan event handling.

Windows added scripting support to WIA by releasing the WIA Automation Library in 2002 that was incorporated in Windows Vista as Windows Image Acquisition (WIA) Automation Layer and continues to be a part of Windows 7.
The WIA Automation Library provides end-to-end image acquisition capabilities to automation-enabled application development environments and programming languages such as Microsoft Visual Basic 6.0, Active Server Pages (ASP), VBScript and C#.

For Windows 7, WIA APIs have additional support to complement the already existing push-scanning support.

  • Auto-configured device initiated scanning with scan parameters configured at the scanner on the device front panel.
  • Automatic source selection for device-initiated scan.

Facts about Windows Image Acquisition 2.0

  • The data transfer mechanism in WIA 2.0 is stream based.
    The stream abstraction removes the distinction between different transfer types and also allows exchange of mutually agreed-upon metadata between device and application.
  • WIA 2.0 subsystem also includes a basic image processing filter driver add-on that is optionally replaceable by the scanner driver, if the driver chooses to provide a customized image processing filter.
    The built-in filter enables post processing of images acquired through the scanner.
    Image processing filter also enables live software previews when small settings such as brightness and contrast are adjusted.
  • The segmentation filter is another handy WIA component that can be replaced by a more customized filter by the scanner driver.
    The segmentation filter can be used for multi-region scanning.
    Multi-region scanning, as an example, allows an application to automatically detect different scan regions without any user intervention, such as identifying a bunch of photos lying randomly on the scanner flatbed.
  • WIA 2.0 provides a replaceable/extensible error handler to gracefully handle, and possibly recover from, software, hardware and configuration errors and delays.
    The error handler is another WIA component that can be replaced with a more customized version by the scanner driver.
    This extension provides status and error messages during data acquisitions such as «Lamp warming up,» «Cover open,» «Paper jam,» and so on.
    This extension also allows cleaner support for «Cancel operations.»

Developer Audience

The WIA API is designed for use by C/C++ programmers. Familiarity with the Windows  GUI and Component Object Model (COM) interfaces is required.

For developers familiar with Microsoft Visual Basic 6.0, Active Server Pages (ASP), or scripting, WIA provides an automation layer for Windows XP Service Pack 1 (SP1) or later that builds upon and simplifies access to the foundation provided by C/C++.
For information about the automation layer, see Windows Image Acquisition Automation Layer.

Note  The WIA Automation Layer supersedes Windows Image Acquisition (WIA) 1.0 scripting.

Run-Time Requirements

Applications that use the WIA API require Windows XP or later.

WIA Topics

The WIA topics are organized as shown in the following table.

About Windows Image Acquisition General information about WIA
Windows Image Acquisition Drivers WIA driver development
Windows Image Acquisition Automation Layer WIA Automation Layer
WIA Tutorial Walkthrough of code included in the software development kit (SDK) that focuses on specific tasks
Reference Information on WIA interfaces, methods, objects, and data types used in C/C++ and scripting.

Show:

Inherited

Protected

  • Board index
    General
    Other Utilities & Resources
    • It is currently 05 May 2025, 03:25
    • All times are UTC-05:00

Post Reply

  • Email topic
  • Print view

4 posts

• Page 1 of 1

SKAN

Posts: 1639
Joined: 29 Sep 2013, 16:58

WIA 2.0 for Windows XP (Windows Image Acquisition Automation Layer)

  • @

  • Quote

21 Aug 2017, 16:28

Note: You DONT NEED to install WIA 2.0 if you are on Windows Vista and later versions.

The attachment was downloaded from following link
https://answers.microsoft.com/en-us/win … 3f1?auth=1

Tested in Windows XP SP3 x86

Spoiler

Attachments

wiaautsdk.zip
(519.19 KiB) Downloaded 451 times

My Scripts and Functions: V1  V2

Top

BoBo

Posts: 6563
Joined: 13 May 2014, 17:15

Re: WIA 2.0 for Windows XP (Windows Image Acquisition Automation Layer)

  • @

  • Quote

22 Aug 2017, 14:10

Hi SKAN,
are you still working with Windows XP??!!

Top

SKAN

Posts: 1639
Joined: 29 Sep 2013, 16:58

Re: WIA 2.0 for Windows XP (Windows Image Acquisition Automation Layer)

  • @

  • Quote

22 Aug 2017, 14:33

Hi BoBo
No. My preferred OS is Win 7 x64.
I have a multiple OS system

XP SP3 x86
WIn 7 x64
Win 8.1 x64
Win 10 x64

My Scripts and Functions: V1  V2

Top

Guest

Re: WIA 2.0 for Windows XP (Windows Image Acquisition Automation Layer)

  • @

  • Quote

27 Nov 2017, 08:01

Many thanks!

SKAN wrote:Note: You DONT NEED to install WIA 2.0 if you are on Windows Vista and later versions.

The attachment was downloaded from following link
https://answers.microsoft.com/en-us/win … 3f1?auth=1

Tested in Windows XP SP3 x86

Spoiler

Top

Display posts from previous:

Sort by


Post Reply

  • Email topic
  • Print view

4 posts

• Page 1 of 1

Return to “Other Utilities & Resources”


Jump to

  • AutoHotkey Foundation
  •    About This Community
  •    Forum Issues
  • AutoHotkey (v2, current version)
  •    Ask for Help (v2)
  •       Gaming Help (v2)
  •    Scripts and Functions (v2)
  •       Gaming Scripts (v2)
  •    Tutorials (v2)
  •       Tips and Tricks (v2)
  •    Wish List
  •       Suggestions on Documentation Improvements
  •    Bug Reports
  •    AutoHotkey Development
  •    AutoHotkey_H
  •       Ask for Help
  •       Development
  •    Editors
  •       Adventure IDE
  •          Old Topics
  •       AHK Studio
  •       Notepad++
  •       Pulovers Macro Creator
  •       SciTE4AutoHotkey
  •       Visual Studio Code
  •    Announcements
  •    General Discussion
  • AutoHotkey (v1.1 and older)
  •    Ask for Help (v1)
  •       Gaming Help (v1)
  •    Scripts and Functions (v1)
  •       Gaming Scripts (v1)
  •    Tutorials (v1)
  •       Tips and Tricks (v1)
  • General
  •    Other Utilities & Resources
  •    Other Programming Languages
  •       C/C++
  •       ASM
  •       C#
  •       KeySharp
  •    Off-topic Discussion
  •    RPA
  • Other languages
  •    Looking for Volunteers in other languages
  •    Deutsch (German)
  •       Ich brauche Hilfe
  •          Spiele
  •       Skripte und Funktionen
  •       Tutorials
  •       Tooltime
  •       Allgemeines
  •    中文 (Chinese)
  •       请求帮助
  •       脚本函数
  •       教程资料
  •       相关工具
  •       其他
  •    Español (Spanish)
  •       Pedir Ayuda
  •          Automatización de Juegos
  •       Scripts y Funciones
  •       Tutoriales
  •       Otras Utilidades y Recursos
  •       General
  •    Русский (Russian)
  •       Помощь
  •          Скрипты для Игр
  •       Скрипты и библиотеки
  •       Статьи и руководства
  •       Прочие ресурсы и ПО.
  •       Свободное общение
  •    Français (French)
  •       J’ai besoin d’aide
  •       Scripts et Fonctions
  •       Tutoriels
  •       Autres Utilitaires et Ressources
  •       Hors Sujet
  •    Português (Portuguese)
  •       Ajuda e Suporte Geral
  •       Scripts e Funções
  •       Tutoriais
  •       Outras Ferramentas e Recursos
  •       Outros Assuntos
  •    한국어 (Korean)

Who is online

Users browsing this forum: No registered users and 7 guests

1、关于WIAAL

The Windows Image Acquisition (WIA) Automation Layer 2.0 is a high-quality, full-featured image manipulation component that provides end-to-end image processing capabilities for Microsoft Visual Basic 6.0, Active Server Pages (ASP), and scripting languages. The WIA Automation Layer exposes features in Windows XP Service Pack 1 (SP1) or later to make it easy to acquire images on digital cameras, scanners, or Web cameras, and to rotate, scale, and annotate your image files. Earlier versions of Windows are not supported.

Other new features include the ability to:

  • Access the properties of image files.
  • Read and write image files and their properties to databases.
  • Modify pixels including alpha values.
  • Write ASP pages that generate thumbnail images on the fly.
  • Take pictures with your Web camera.
  • Automatically download pictures from cameras as soon as they are connected, even if a script is not already running.

This overview includes the following topics.

  • Object Hierarchy
  • Accessing Imaging Devices
  • Manipulating Image Files
  • Example Code

Object Hierarchy

The WIA Automation Layer is broken down into two types of objects. The first type of object is a creatable object. This is an object that can be directly created by calling the Microsoft Visual Basic function CreateObject. In addition, three creatable objects (DeviceManager, CommonDialog, and VideoPreview) are also controls that can be dropped on a form in Visual Basic. The second type of object is the supporting object. This object is not directly creatable but instead is returned from properties or methods. For example, the Connect method on a DeviceInfo object returns a Device object.

The following object hierarchy diagrams show the relationship between objects, collections, and reused objects for both creatable and supporting objects. The hierarchy diagrams use these symbols.

As you can see in the previous illustrations, the WIA Automation Layer reuses objects wherever possible to reduce the number of different objects you need to learn to use. For example, the Device, DeviceInfo, Filter, FilterInfo, Item, and ImageFile objects all reuse the Properties collection to expose their properties. Once you learn how to use the Properties collection on one object you will be able to use it on all the others.

Notice the naming convention in which a collection of objects uses the plural of that object name. For example, a Filters collection holds Filter objects.

Accessing Imaging Devices

The DeviceManager object and, to a limited degree, the VideoPreview object are the primary ways to access Imaging Devices. The Device object represents an active connection to an Imaging Device. From the Device object you can access its properties, access the items that might be stored on it, transfer those items to files on the computer, and run commands that cause the Imaging Device to do something. For example, you could access a digital camera’s date and time, transfer all its pictures to your computer or cause it to take a picture. These actions can be done in one of two ways, programmatically without any user intervention, or using the CommonDialog object to present dialog boxes that enable the user to precisely control the actions.

Manipulating Image Files

Once you have transferred pictures to your computer, you can use the ImageFile object to access the pictures. You can display them on forms, return them as binary data in ASP pages, or access their properties. Many digital cameras store a number of detailed properties in their pictures, from useful information like the date the picture was taken and a thumbnail image to interesting technical details like the model of camera, the focal length, aperture setting, and shutter speed. For more information about detailed properties, see Display all ImageFile Properties and Display Detailed Image Information.

In order to protect the original pictures that represent digital memories, the ImageFile object cannot directly modify the pictures. You can, however, use an ImageProcess object and one or more Filter objects to create a modified copy of the picture. The WIA Automation Layer provides filters that rotate, flip, crop, scale, stamp, modify properties, modify the individual pixels or change the file format to Tagged Image File Format (TIFF), JPEG, Portable Network Graphics (PNG), bitmap (BMP), or Graphics Interchange Format (GIF). For more information about filters, see How To Use Filters.

Example Code

All reference pages in this documentation set include example code or a link to examples in the Overviews/Tutorials section that illustrate how to use the API. Begin by reading Getting Started with Samples. This topic has the template code for a variety of development environments into which you can paste the reference examples. Shared Samples includes a number of examples that are applicable to a variety of applications.

The following examples are complete samples that you do not need to paste into template code.

  • Download New Items as They are Created
  • Use VideoPreview Control in HTML
  • Implement a Web Camera ASP Page
  • Implement a Windows Script Host Script that Runs Automatically

2、How to Use Filters

This topic provides examples that show how to use each of the filters available with the Windows Image Acquisition (WIA) Automation Library version 2.0.

These examples need to be inserted into template code to form complete samples. For the appropriate code template for your preferred development environment, see Getting Started with Samples. See also Shared Samples and the individual reference pages for additional sample code.

  • RotateFlip Filter: Rotate a Picture
  • Crop Filter: Crop a Picture
  • Scale Filter: Resize an Image
  • Stamp Filter: Stamp a Picture Over Another Picture
  • EXIF Filter: Write a New Title Tag to an Image
  • Frame Filter: Create a Multipage TIFF from Three Pictures
  • ARGB Filter: Create a Modified Version of an Image
  • Convert Filter: Create a Compressed JPEG File from Another File

RotateFlip Filter: Rotate a Picture

The following shows how to use the RotateFlip filter to rotate one of the sample pictures from Windows XP 90 degrees.

Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

IP.Filters.Add IP.FilterInfos("RotateFlip").FilterID
IP.Filters(1).Properties("RotationAngle") = 90

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\Bliss90.bmp"


Crop Filter: Crop a Picture

The following shows how to use the Crop filter to crop 25 percent of the Top, Left, Bottom, and Right of one of the sample pictures from Windows XP.

Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

IP.Filters.Add IP.FilterInfos("Crop").FilterID
IP.Filters(1).Properties("Left") = Img.Width \ 4
IP.Filters(1).Properties("Top") = Img.Height \ 4
IP.Filters(1).Properties("Right") = Img.Width \ 4
IP.Filters(1).Properties("Bottom") = Img.Height \ 4

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissCrop.bmp"


Scale Filter: Resize an Image

The following shows how to use the Scale filter to create a thumb-sized version of one of the sample pictures from Windows XP.

Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

IP.Filters.Add IP.FilterInfos("Scale").FilterID
IP.Filters(1).Properties("MaximumWidth") = 100
IP.Filters(1).Properties("MaximumHeight") = 100

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissThumb.bmp"


Stamp Filter: Stamp a Picture Over Another Picture

The following shows how to stamp the thumb-sized picture created in the previous example on top of the full-sized version of one of the sample pictures from Windows XP.

Dim Thumb 'As ImageFile
Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set Thumb = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"
Thumb.LoadFile "C:\WINDOWS\Web\Wallpaper\BlissThumb.bmp"

IP.Filters.Add IP.FilterInfos("Stamp").FilterID
Set IP.Filters(1).Properties("ImageFile") = Thumb
IP.Filters(1).Properties("Left") = Img.Width - Thumb.Width
IP.Filters(1).Properties("Top") = Img.Height - Thumb.Height

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissStamp.bmp"


EXIF Filter: Write a New Title Tag to an Image

The following example shows how to write a Title tag to a new version of one of the sample pictures from Windows XP. You can view the Title tag by right-clicking the image, clicking Properties, and clicking the Summary tab. This example uses the Exchangeable Image File (EXIF) filter.

Dim Img 'As ImageFile
Dim IP 'As ImageProcess
Dim v 'As Vector

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")
Set v = CreateObject("WIA.Vector")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Autumn.jpg"

IP.Filters.Add IP.FilterInfos("Exif").FilterID
IP.Filters(1).Properties("ID") = 40091
IP.Filters(1).Properties("Type") = VectorOfBytesImagePropertyType

v.SetFromString "This Title tag written by Windows Image Acquisition Library v2.0"

IP.Filters(1).Properties("Value") = v

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\AutumnExif.jpg"


Frame Filter: Create a Multipage TIFF from Three Pictures

The following example shows how to create a multiframe (multipage) Tagged Image File Format (TIFF) file from three of the sample pictures from Windows XP, and then create a bitmap (BMP) file from the last frame. This example uses the Frame filter.

Dim Img 'As ImageFile
Dim Page2 'As ImageFile
Dim Page3 'As ImageFile
Dim IP 'As ImageProcess
Dim v 'As Vector

Set Img = CreateObject("WIA.ImageFile")
Set Page2 = CreateObject("WIA.ImageFile")
Set Page3 = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"
Page2.LoadFile "C:\WINDOWS\Web\Wallpaper\Azul.jpg"
Page3.LoadFile "C:\WINDOWS\Web\Wallpaper\Autumn.jpg"

IP.Filters.Add IP.FilterInfos("Frame").FilterID
Set IP.Filters(IP.Filters.Count).Properties("ImageFile") = Page2

IP.Filters.Add IP.FilterInfos("Frame").FilterID
Set IP.Filters(IP.Filters.Count).Properties("ImageFile") = Page3

IP.Filters.Add IP.FilterInfos("Convert").FilterID
IP.Filters(IP.Filters.Count).Properties("FormatID") = wiaFormatTIFF

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\Bliss.tif"

Img.ActiveFrame = Img.FrameCount

Set v = Img.ARGBData

Set Img = v.ImageFile(Img.Width, Img.Height)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\Autumn.bmp"


Note  TIFF is the only format that supports saving multiple frames. If you want to preserve the frames of an animated Graphics Interchange Format (GIF) you can create a filter chain with a single Convert filter to convert the animated GIF to a TIFF. For an example that uses the Convert filter, see Convert Filter: Create a Compressed JPEG File from Another File.

ARGB Filter: Create a Modified Version of an Image

The following example shows how to create a version of one of the sample pictures from Windows XP with bright pink diagonal lines. The example uses the ARGB filter.

Note  This operation can be slow on certain computers.

Dim Img 'As ImageFile
Dim IP 'As ImageProcess
Dim v 'As Vector
Dim i 'As Long

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

Set v = Img.ARGBData

For i = 1 To v.Count Step 21
    v(i) = &HFFFF00FF 'opaque pink (A=255,R=255,G=0,B=255)
Next

IP.Filters.Add IP.FilterInfos("ARGB").FilterID
Set IP.Filters(1).Properties("ARGBData") = v

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissARGB.bmp"


Convert Filter: Create a Compressed JPEG File from Another File

The following example shows how to create a compressed JPEG version of one of the sample pictures from Windows XP. The example uses the Convert filter.

Dim Img 'As ImageFile
Dim IP 'As ImageProcess

Set Img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")

Img.LoadFile "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

IP.Filters.Add IP.FilterInfos("Convert").FilterID
IP.Filters(1).Properties("FormatID").Value = wiaFormatJPEG
IP.Filters(1).Properties("Quality").Value = 5

Set Img = IP.Apply(Img)

Img.SaveFile "C:\WINDOWS\Web\Wallpaper\BlissCompressed.jpg"


3、Getting Started with Samples

All the example code contained in the Windows Image Acquisition (WIA) Automation Layer 2.0 reference works in multiple languages. This way you can copy the examples from the reference pages into any of the following:

  • Visual Basic 6.0
  • Windows Script Host
  • HTML Application
  • Script in an HTML Application
  • Active Server Pages

Visual Basic 6.0

To create a Microsoft Visual Basic project for any of the examples in the reference topics, perform the following steps.

  1. Start the Visual Basic Development Environment.
  2. Select Standard EXE.
  3. Click Components from the Project menu (or press Ctrl-T).
  4. Scroll down and select Microsoft Windows Image Acquisition Library v2.0 by placing a checkmark in front of it. Of the three new controls that appear on in the Toolbox, double click CommonDialog and DeviceManager to add them to your form.

Note  The data types are commented out in the examples in the reference pages so you can copy and paste them into Microsoft Visual Basic Scripting Edition (VBScript) where all data types are a Variant. Visual Basic programmers should remove the comment mark (‘) in front of each data type.

Windows Script Host

To create a Windows Script Host project, copy the following into an empty file with a .wsf extension.

<job>
<reference object="WIA.DeviceManager" />
<object id="DeviceManager1" progid="WIA.DeviceManager" />
<object id="CommonDialog1" progid="WIA.CommonDialog" />
<script language="VBScript">

'Paste Sample Code Here

</script>
</job>


HTML Application

To create an HTML Application (HTA), copy the following into an empty file with an .hta extension. In addition, if you have not done so already, create the Visual Basic Script Constants file.

<html>
<title>Sample HTA</title>
<hta:application id="oHTA"/>
<object ID="DeviceManager1" Width=0 Height=0 ClassID="CLSID:E1C5D730-7E97-4D8A-9E42-BBAE87C2059F"></object>
<object ID="CommonDialog1" Width=0 Height=0 ClassID="CLSID:850D1D11-70F3-4BE5-9A11-77AA6B2BB201"></object>
<script language="vbscript" src="wiaaut.vbs"></script>
<script language="vbscript">

'Paste Sample Code Here

</script>
</head>
<body scroll="no">
</body>
</html>


Script in an HTML Application

To create an HTML file with script, copy the following into an empty file with an .htm extension. In addition, if you have not done so already, create the Visual Basic Script Constants file.

Note  Since the Windows Image Acquisition (WIA) Library is not marked safe for scripting, proper functionality is dependent on your security settings.

<html>
<title>Sample HTML</title>
<object ID="DeviceManager1" Width=0 Height=0 ClassID="CLSID:E1C5D730-7E97-4D8A-9E42-BBAE87C2059F"></object>
<object ID="CommonDialog1" Width=0 Height=0 ClassID="CLSID:850D1D11-70F3-4BE5-9A11-77AA6B2BB201"></object>
<script language="vbscript" src="wiaaut.vbs"></script>
<script language="vbscript">

'Paste Sample Code Here

</script>
</head>
<body>
</body>
</html>


Active Server Pages

To create an Active Server Page, copy the following into an empty file with an .asp extension.

Note  The script on Active Server Pages (ASP) runs on a non-interactive desktop so using the CommonDialog or VideoPreview control in an Active Server Page will not work as expected. In addition, in the interest of increased security, the default Server Security Settings needs to be adjusted before you can successfully create a DeviceManager object. For instructions on changing your security settings, see How to Configure Security Settings. Also, for security reasons you need to change any calls to the Visual Basic function CreateObject to instead use Server.CreateObject.

<%@ Language=VBScript %>
<!--METADATA TYPE="TypeLib" UUID="94A0E92D-43C0-494E-AC29-FD45948A5221"-->
<% 

'Paste Sample Code Here

%>

4、Shared Samples
参考:http://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx
 
5、Visual Basic Script Constants

When using the Windows Image Acquisition (WIA) Library from an HTML Page or HTML Application (HTA) as illustrated in the examples, you need a file named Wiaaut.vbs that contains the following Microsoft Visual Basic Scripting Edition (VBScript) code. For more information about each of these constants and enumerated types, see the reference topics.

' Miscellaneous

Const wiaIDUnknown = "{00000000-0000-0000-0000-000000000000}"
Const wiaAnyDeviceID = "*"

' FormatID

Const wiaFormatBMP = "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"
Const wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"
Const wiaFormatGIF = "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"
Const wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
Const wiaFormatTIFF = "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"

' EventID

Const wiaEventDeviceConnected = "{A28BBADE-64B6-11D2-A231-00C04FA31809}"
Const wiaEventDeviceDisconnected = "{143E4E83-6497-11D2-A231-00C04FA31809}"
Const wiaEventItemCreated = "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}"
Const wiaEventItemDeleted = "{1D22A559-E14F-11D2-B326-00C04F68CE61}"
Const wiaEventScanImage = "{A6C5A715-8C6E-11D2-977A-0000F87A926F}"
Const wiaEventScanPrintImage = "{B441F425-8C6E-11D2-977A-0000F87A926F}"
Const wiaEventScanFaxImage = "{C00EB793-8C6E-11D2-977A-0000F87A926F}"
Const wiaEventScanOCRImage = "{9D095B89-37D6-4877-AFED-62A297DC6DBE}"
Const wiaEventScanEmailImage = "{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}"
Const wiaEventScanFilmImage = "{9B2B662C-6185-438C-B68B-E39EE25E71CB}"
Const wiaEventScanImage2 = "{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}"
Const wiaEventScanImage3 = "{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}"
Const wiaEventScanImage4 = "{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}"

' CommandID

Const wiaCommandSynchronize = "{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}"
Const wiaCommandTakePicture = "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}"
Const wiaCommandDeleteAllItems = "{E208C170-ACAD-11D2-A093-00C04F72DC3C}"
Const wiaCommandChangeDocument = "{04E725B0-ACAE-11D2-A093-00C04F72DC3C}"
Const wiaCommandUnloadDocument = "{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}"

' WiaSubType enumeration

Const UnspecifiedSubType = 0
Const RangeSubType = 1
Const ListSubType = 2
Const FlagSubType = 3

' WiaDeviceType enumeration

Const UnspecifiedDeviceType = 0
Const ScannerDeviceType = 1
Const CameraDeviceType = 2
Const VideoDeviceType = 3

' WiaItemFlag enumeration

Const FreeItemFlag = &h0
Const ImageItemFlag = &h1
Const FileItemFlag = &h2
Const FolderItemFlag = &h4
Const RootItemFlag = &h8
Const AnalyzeItemFlag = &h10
Const AudioItemFlag = &h20
Const DeviceItemFlag = &h40
Const DeletedItemFlag = &h80
Const DisconnectedItemFlag = &h100
Const HPanoramaItemFlag = &h200
Const VPanoramaItemFlag = &h400
Const BurstItemFlag = &h800
Const StorageItemFlag = &h1000
Const TransferItemFlag = &h2000
Const GeneratedItemFlag = &h4000
Const HasAttachmentsItemFlag = &h8000
Const VideoItemFlag = &h10000
Const RemovedItemFlag = &h80000000

' WiaPropertyType enumeration

Const UnsupportedPropertyType = 0
Const BooleanPropertyType = 1
Const BytePropertyType = 2
Const IntegerPropertyType = 3
Const UnsignedIntegerPropertyType = 4
Const LongPropertyType = 5
Const UnsignedLongPropertyType = 6
Const ErrorCodePropertyType = 7
Const LargeIntegerPropertyType = 8
Const UnsignedLargeIntegerPropertyType = 9
Const SinglePropertyType = 10
Const DoublePropertyType = 11
Const CurrencyPropertyType = 12
Const DatePropertyType = 13
Const FileTimePropertyType = 14
Const ClassIDPropertyType = 15
Const StringPropertyType = 16
Const ObjectPropertyType = 17
Const HandlePropertyType = 18
Const VariantPropertyType = 19
Const VectorOfBooleansPropertyType = 101
Const VectorOfBytesPropertyType = 102
Const VectorOfIntegersPropertyType = 103
Const VectorOfUnsignedIntegersPropertyType = 104
Const VectorOfLongsPropertyType = 105
Const VectorOfUnsignedLongsPropertyType = 106
Const VectorOfErrorCodesPropertyType = 107
Const VectorOfLargeIntegersPropertyType = 108
Const VectorOfUnsignedLargeIntegersPropertyType = 109
Const VectorOfSinglesPropertyType = 110
Const VectorOfDoublesPropertyType = 111
Const VectorOfCurrenciesPropertyType = 112
Const VectorOfDatesPropertyType = 113
Const VectorOfFileTimesPropertyType = 114
Const VectorOfClassIDsPropertyType = 115
Const VectorOfStringsPropertyType = 116
Const VectorOfVariantsPropertyType = 119

' WiaImagePropertyType enumeration

Const UndefinedImagePropertyType = 1000
Const ByteImagePropertyType = 1001
Const StringImagePropertyType = 1002
Const UnsignedIntegerImagePropertyType = 1003
Const LongImagePropertyType = 1004
Const UnsignedLongImagePropertyType = 1005
Const RationalImagePropertyType = 1006
Const UnsignedRationalImagePropertyType = 1007
Const VectorOfUndefinedImagePropertyType = 1100
Const VectorOfBytesImagePropertyType = 1101
Const VectorOfUnsignedIntegersImagePropertyType = 1102
Const VectorOfLongsImagePropertyType = 1103
Const VectorOfUnsignedLongsImagePropertyType = 1104
Const VectorOfRationalsImagePropertyType = 1105
Const VectorOfUnsignedRationalsImagePropertyType = 1106

' WiaEventFlag enumeration

Const NotificationEvent = 1
Const ActionEvent = 2

' WiaImageIntent enumeration

Const UnspecifiedIntent = 0
Const ColorIntent = 1
Const GrayscaleIntent = 2
Const TextIntent = 4

' WiaImageBias enumeration

Const MinimizeSize = 65536
Const MaximizeQuality = 131072
 
 
6、Objects

This section contains reference information for the Windows Image Acquisition (WIA) Automation Library version 2.0 objects.

This section presents the following topics.

Objects
  • CommonDialog
  • Device
  • DeviceCommand
  • DeviceCommands
  • DeviceEvent
  • DeviceEvents
  • DeviceInfo
  • DeviceInfos
  • DeviceManager
  • Filter
  • FilterInfo
  • FilterInfos
  • Filters
  • Formats
  • ImageFile
  • ImageProcess
  • Item
  • Items
  • Properties
  • Property
  • Rational
  • Vector
  • VideoPreview
 
 
7、Constants and Enumerations

This section contains reference information for the constants and enumerations introduced in the Windows Image Acquisition (WIA) Automation Library version 2.0.

This section presents the following topics.

Constants and Enumerations
  • CommandID Constants
  • EventID Constants
  • FormatID Constants
  • Miscellaneous Constants
  • WiaDeviceType
  • WiaEventFlag
  • WiaImageBias
  • WiaImageIntent
  • WiaImagePropertyType
  • WiaItemFlag
  • WiaPropertyType
  • WiaSubType
 
 
以上来自:http://msdn.microsoft.com/en-us/library/windows/desktop/ms630827(v=vs.85).aspx
WIA下载:http://www.microsoft.com/en-us/download/details.aspx?id=18287
 

From Wikipedia, the free encyclopedia

Windows Image Acquisition (WIA; sometimes also called Windows Imaging Architecture) is a proprietary Microsoft driver model and application programming interface (API) for Microsoft Windows Me and later Windows operating systems that enables graphics software to communicate with imaging hardware such as scanners, digital cameras, and digital video equipment. It was first introduced in 2000 as part of Windows Me, and continues to be the standard imaging device and API model through successive Windows versions. It is implemented as an on-demand service in Windows XP and later Windows operating systems.[1]

WIA is a very significant superset of the support for digital still imaging drivers that was provided by the Still Image Architecture (STI) in Windows 98. Whereas STI only provided a low-level interface for doing basic transfers of data to and from the device (as well as the invocation of an image scan process on the Windows machine through the external device), WIA provides a framework through which a device can present its unique capabilities to the operating system, and applications can invoke those features.
According to Microsoft, WIA drivers are made up of a user interface (UI) component and a driver core component, loaded into two different process spaces: UI in the application space and the driver core in the WIA service space.

Certain scanners support WIA.[2][3]

Additional information

[edit]

In 2002, Microsoft released the Windows Image Acquisition Automation Library Tool, which provides access to WIA functionality through programming languages and scripting environments that support OLE Automation.

In Windows XP, WIA runs in the LocalSystem context. Because of the security ramifications of running a service as LocalSystem whereby a buggy driver or malicious person would have unrestricted access to the system, the WIA service in Windows Server 2003 and Windows Vista operates in the LocalService context. This can result in compatibility issues when using a driver designed for Windows XP.[4]

In Windows XP, support was added for automatic document feeder scanners, scroll-feed scanners without preview capabilities and multi-page TIFF generation.[5] For WIA video, a snapshot filter driver is introduced that allows still frames to be captured from the video stream.

Windows Vista introduced Windows Image Acquisition 2.0. Windows Vista also has the WIA Automation library built-in. WIA2 supports push scanning and multi-image scanning. Push scanning allows initiating scans and adjusting scanning parameters directly from the scanner control panel. Multi-image scanning allows one to scan several images at once and save them directly as separate files. However, video content support is removed from WIA for Windows Vista.[6]

Applications that use WIA

[edit]

  • Photoshop
  • Paint.net
  • ACDSee
  • Chasys Draw IES
  • IrfanView
  • FastStone Image Viewer
  • Naps2 (Not Another PDF Scanner 2)
  • ORPALIS PaperScan
  • ScanSnap Home
  • ScanSnap Manager
  • Windows Scanner and Camera Wizard
  • Serif PhotoPlus
  • Microsoft Dynamics GP
  • Image and Scanner Interface Specification (ISIS)
  • Standard for image acquisition devices (TWAIN)
  • Scanner Access Now Easy (SANE)
  1. ^ «Windows Image Acquisition (WIA)». MSDN Library. msdn.microsoft.com. Retrieved 14 January 2013.
  2. ^ List of Scanners That Are Supported by Windows Image Acquisition for Windows XP
  3. ^ List of Digital Cameras That Are Supported by Windows Image Acquisition
  4. ^ Microsoft published a paper in 2003 titled Security-related Best Practices for WIA Driver Development to assist WIA driver developers in writing drivers that will work in the lower-security context that the WIA service operates in.
  5. ^ Still Image Connectivity for Windows
  6. ^ Migrating from WIA to WPD
  • Windows Image Acquisition (WIA): MSDN
  • What’s New in Windows Image Acquisition (WIA) 2.0
  • Still Image Connectivity for Windows—describes WIA and compares it to Picture Transfer Protocol and USB mass storage methods for transferring images between a digital imaging devices and the computer.
  • Sample code creating a WIA utility class on codeproject.com
  • Try the HP Print and Scan Doctor for Windows Archived 2014-11-02 at the Wayback Machine—HP Support

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Запуск дефрагментации windows 10
  • Creative x fi platinum драйвер windows 10
  • Jhi service exe что это за процесс windows 10
  • Какая версия windows 10 легче
  • Windows server 2003 запуск в безопасном режиме