1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Twain and Delphi
Acquire images from scanners, cameras and image capture devices using Delphi. See how to import (and wrap in a component) an image scan control within Delphi.
 Join the Discussion
"Post your views, comments, questions and doubts to this article."
 Related Resources
• Graphics programming

   Technology Without An Interesting Name
TWAIN is a program that lets you scan an image (using a scanner) directly into the application (such as PhotoShop, Photo Paint) where you want to work with the image. Without TWAIN, you would have to close an application that was open, open a special application to receive the image, and then move the image to the application where you wanted to work with it.

You can get a great deal of information from the TWAIN Community Web Site.

   Within Delphi
Even though you could use some of the third-party components below, you already might have everything you need to scan an image from a Delphi application. The setup program for Imaging (tool that ships with Windows > 98) installs the Image Scan control (OCX) and the 32-bit TWAIN DLLs. All you have to do is to import this ActiveX control in Delphi and generate a component wrapper:

Import Scan dll

I'll give you a code snippet on accessing the TImgScan component. Drop one on a form and provide an OnClick event handler for a Button control.

if ImgScan1.ScannerAvailable then 
    ImgScan1.ScanTo := 2;    
    ImgScan1.StartScan ; 
    ImgScan1.CloseScanner ; 

The rest of the code is yours to explore - there is an imgocxd.hlp help on the Kodak Imaging site.

Below you will find links to third-party components/tools (both free and shareware) that encapsulate TWAIN support in Delphi:

  • Delphi Twain (open source)
    This library consists in a implementation of Twain features for Borland Delphi tool.

  • TEnhTwain (shareware)
    Handles the acquisition from scanners (devices) that are TWAIN compliant

  • SkyLine Tools Imaging Corporate Suite (commercial)
    Corporate Suite Delphi and CBuilder provides robust and "easy to implement" imaging toolkit in the Delphi market. This new VCL adds "the fastest" scanning available in Twain , a new thumbnail manager, superb anti aliasing and improved annotation capability.

  • TWScan (shareware)
    Use as a component, or add the unit to the uses clause and use a few lines of code to have twain access (one to select source, one to acquire, a few to init the system). TWScan returns a DDB (TBitmap) directly into a TImage, or optionally a DIB (THandle), and functions are provided to convert between the two if you have TIFIMG. These can be loaded into a TImage and saved as a BMP, or, if using TiffiMG (another component from author) saved as GIF, BMP, TGA, JPG, TIF and more.

  • TWAIN Toolkit's (shareware)
    The TWAIN Toolkit for Delphi includes a component making it easy to implement the TWAIN standard into your application. The toolkit includes examples, showing how to use the component and API functions to create a TWAIN complaint application and source.
  • ©2017 About.com. All rights reserved.