Paradox Community
Search:

 Welcome |  What is Paradox |  Paradox Folk |  Paradox Solutions |
 Interactive Paradox |  Paradox Programming |  Internet/Intranet Development |
 Support Options |  Classified Ads |  Wish List |  Submissions 


Paradox Programming Articles  |  Beyond Help Articles  |  Tips & Tricks Articles  


TWAIN Support in ObjectPAL®
Advanced Techniques
© 2001 Paul Cronk

Advanced Techniques

In this article, the samples use some advanced techniques which should be explored while designing a TWAIN implementation. These techniques are not mandatory for any TWAIN enabled application. If the application does not employ the advanced techniques, the application will still function.


Saving the Application Default Source
Code should never rely on the system default source for acquisition. A straight acquire() could acquire from a different source than expected, and thus yield unexpected results. Creating and maintaining the default source for the application prevents users from acquiring from unwanted or unsupported sources. This concept can be expanded to include user default sources as well.

Handling Graphics
Graphics require special handling. When a graphic is read from a file, the file is converted from its original format to a native bitmap form. This is typical in other applications. In Paradox 10, graphics can be exported to disk in more compressed formats, such as GIF, and JPEG. The largest advantage of leveraging the new graphic features in Paradox 10 is size.

Graphics are generally not stored in tables since the BDE expands graphic files into bitmaps before storing the graphic. Thus, if a developer reads an item into a graphic type, and places the graphic type into the table, the internal format of the file is not preserved. This causes the table to grow increasingly large with each graphic. By storing the filename of the graphic object as a reference to the graphic, the size of the table is reduced, and the number of entries is only limited to the size of the drive where the table is located.

Setting the System Default Source
One trick to get the default TWAIN source without showing the Select Source dialog is to read the profile entries that correspond to the default data source. The filename is stored in the 'Default Source' entry of the 'TWAIN' section in the 'win.ini' file.
strDSFileName = readProfileString( "win.ini", "TWAIN", "Default Source" )
returns the complete path and filename of the system default data source. It is then left up to the developer to equate the friendly name displayed in the Select Source dialog to the filename returned from the above function.

Conversely, the code
writeProfileString( "win.ini", "TWAIN", "Default Source", "digicam.ds")
writes the filename of a data source to the windows profile. The onus is on the developer to ensure the filename exists on the local machine.

The TWAIN Working Group does not support these methods of getting and setting the default data source. If the system data source changes in the midst of a twain session, it is conceivable that the user could acquire from a different data source than the one selected. Thus, the only supported means of setting and getting the system data source is through the source manager.

Caveats with TWAIN support in ObjectPAL
With the current implementation of Paradox 10 SP1, the function twain.acquire( var gr graphic, var bShow Logical) does not work as documented. However, one could acquire to a file, then perform a graphic.readFromFile() method after the acquisition was complete to achieve the same results. Paradox 10 SP2 has corrected the behavior of the acquire method.

The table view has no user interface for acquiring images. This appears to be an oversight in the original implementation.

The function twain.isAssigned() is not documented in the help.

The help panel for twain.showSelectSourceDlg() states that the prototype for this function is showSelectSourceDialog(), not showSelectSourceDlg().

The documentation for TWAIN support is quite limited, and in most cases incorrect. Most of the arguments are actually of const type, not var. The help does not automatically point to the correct help panel from the source code window.

Paradox is not capable of acquiring 32bit graphic images to graphic objects, or graphic field objects. If a 32bit image is acquired to one of these objects, the image will appear slanted, or distorted. 32bit images can be acquired to a file successfully. In general, applications should not acquire images greater than 24bits to adhere to the limitations of Paradox.

Paradox can only receive one image per acquisition. Acquiring multiple images, such as time-lapsed stills, or a roll of film on a digital camera cannot be performed using the Paradox TWAIN implementation. This is working as designed. To acquire time-lapsed stills, perform an acquire with no UI, sleep for a period of time, and acquire the next image. This gives the flexibility of posting a record, or storing the image on disk before the next acquisition takes place.

Where can I find more information about TWAIN?
The TWAIN working group can be found on the web, at www.twain.org.


First: Series Content, Definitions and Requirements
Previous: Sample Projects


Discussion of this article


 Feedback |  Paradox Day |  Who Uses Paradox |  I Use Paradox |  Downloads 


 The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation.
 Paradox is a registered trademark of Corel Corporation.


 Modified: 15 May 2003
 Terms of Use / Legal Disclaimer


 Copyright © 2001- 2003 Paradox Community. All rights reserved. 
 Company and product names are trademarks or registered trademarks of their respective companies. 
 Authors hold the copyrights to their own works. Please contact the author of any article for details.