Lennert Ouwerkerk > Win32-Scanner-EZTWAIN-0.01 > Win32::Scanner::EZTWAIN

Download:
Win32-Scanner-EZTWAIN-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Win32::Scanner::EZTWAIN - An interface to the classic EZTWAIN library

SYNOPSIS ^

    use Win32::Scanner::EZTWAIN;

    my $scanner = new Win32::Scanner::EZTWAIN();
    $scanner->select_image_source();
    $scanner->acquire_to_file("D:\\windows\\desktop\\test.bmp");

ABSTRACT ^

The EZTWAIN library has been around for a long time. With Visual C and Visual Basic it is pretty easy to import the API calls from eztw32.dll, and fire up the scanner user interface from your application. With this module you can do this from a perl application.

EZTWAIN comes in two flavours: classic EZTWAIN and EZTWAIN pro. This module was written for the first flavour, but it also seems to run fine with the latter. You can download classic EZTWAIN (freeware) from the site http://www.dosadi.com/. Place eztw32.dll in your windows system directory or just place it in the directory where your perl application is located.

DESCRIPTION ^

Constructor

new Win32::Scanner::EZTWAIN(-dll => $path_to_dll, -hwnd => $window_handle)

Constructor for a new object. The options -dll and -hwnd are optional. If your dll is not in a standard place you can use this option to tell where eztw32.dll is located, use a trailing slash.

The second option, -hwnd, is used to pass your window handle of your application. TWAIN seems to want to disable the window that called him. If you don't build windows gui applications, and your application is a plain console application, don't pass anything. When nothing is passed eztw32.dll will create a dummy window, and will pass that handle to TWAIN.

Methods

select_image_source()

This method allows the user to select the appropriate device. Returns 1 if a device was selected. Returns 0 if no device was selected, i.e. the operation was cancelled by the user.

acquire_to_file($file)

This method starts the scanner user interface and stores the scanned image in the given filename. Classic EZTWAIN only support windows bitmaps, so make sure the given filename has a .bmp extension. If you omit a filename the standard windows file save dialog pops up, which allows the user to save the image manually.

Return values:

TWAIN_ACQUIRE_SUCCESS

If the operation was a success.

TWAIN_ACQUIRE_FAILED

Acquire failed or the user cancelled the file save dialog box.

TWAIN_ACQUIRE_ERROPENFILE

There was an error opening the specified file.

TWAIN_ACQUIRE_WEIRD

Unable to lock DIB, probably an invalid handle (weird).

TWAIN_ACQUIRE_ERRWRITEFILE

Writing bitmap to file failed, device full?

acquire_to_clipboard($pix_type)

This method starts the scanner user interface and pastes the scanned image as a bitmap to the windows clipboard. You can force the user interface to scan the image in a specified pixel type.

Possible pixel types:

TWAIN_BW

Black and white bitmap, 1-bit per pixel.

TWAIN_GRAY

Grayscale bitmap, 1, 4, or 8-bit.

TWAIN_RGB

True color bitmap - 24-bit RGB color.

TWAIN_PALETTE

Color bitmap, 1, 4, or 8-bit palette.

TWAIN_ANYTYPE

Any of the above, whatever pixel type is available for the specific device.

Only use pixel types that are supported by your scanner device, this implies that you know what your scanner is capable of. Use TWAIN_ANYTYPE if you are not sure. If you omit the pixel type argument, TWAIN_ANYTYPE is passed. You can combine different pixel types with OR, like this &TWAIN_BG | &TWAIN_GRAY.

is_available()

This method returns 1 if TWAIN services are available, 0 if no TWAIN services are available.

easy_version()

This method returns the version of the used EZTWAIN library.

EXPORT ^

This module exports the following constants:

TWAIN_BW
TWAIN_GRAY
TWAIN_RGB
TWAIN_PALETTE
TWAIN_ANYTYPE
TWAIN_ACQUIRE_SUCCESS
TWAIN_ACQUIRE_FAILED
TWAIN_ACQUIRE_ERROPENFILE
TWAIN_ACQUIRE_WEIRD
TWAIN_ACQUIRE_ERRWRITEFILE

INSTALLATION ^

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install

REQUIRED MODULES ^

Win32::API

BUGS AND QUIRKS ^

I noticed that this module doesn't work flawlessly with all scanners, I had no problems, with my AGFA StudioStar SCSII scanner. On the other hand, the TWAIN service of my Pinnacle Sys TV card caused some problems. Don't say I didn't warn you.

SEE ALSO ^

Win32::Clipboard, get the scanned image from the clipboard.

AUTHOR ^

Lennert Ouwerkerk <lennert@kabelfoon.nl>

COPYRIGHT ^

Copyright (C) 2002 Lennert Ouwerkerk. All rights reserved.

LICENSE ^

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: