11 Aug 2002 13:42:18 UTC
- Distribution: Win32-Scanner-EZTWAIN
- Module version: 0.01
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (41 / 0 / 0)
- KwaliteeBus factor: 0
- 90.00% Coverage
- License: unknown
- Activity24 month
- Download (4.05KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionLENNERTO Lennert Ouwerkerk
- REQUIRED MODULES
- BUGS AND QUIRKS
- SEE ALSO
Win32::Scanner::EZTWAIN - An interface to the classic EZTWAIN library
use Win32::Scanner::EZTWAIN; my $scanner = new Win32::Scanner::EZTWAIN(); $scanner->select_image_source(); $scanner->acquire_to_file("D:\\windows\\desktop\\test.bmp");
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.
- 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.
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.
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.
If the operation was a success.
Acquire failed or the user cancelled the file save dialog box.
There was an error opening the specified file.
Unable to lock DIB, probably an invalid handle (weird).
Writing bitmap to file failed, device full?
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:
Black and white bitmap, 1-bit per pixel.
Grayscale bitmap, 1, 4, or 8-bit.
True color bitmap - 24-bit RGB color.
Color bitmap, 1, 4, or 8-bit palette.
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.
This method returns 1 if TWAIN services are available, 0 if no TWAIN services are available.
This method returns the version of the used EZTWAIN library.
This module exports the following constants:
To install this module type the following:
perl Makefile.PL make make test make install
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.
Win32::Clipboard, get the scanned image from the clipboard.
Lennert Ouwerkerk <firstname.lastname@example.org>
Copyright (C) 2002 Lennert Ouwerkerk. All rights reserved.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Win32::Scanner::EZTWAIN, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Win32::Scanner::EZTWAIN
For more information on module installation, please visit the detailed CPAN module installation guide.