Acquisition Questions

Top  Previous  Next

Q: I called DTWAIN_AcquireNative, but the device is not responding.  Why?

A: First, you may be using modeless acquisition processing. DTWAIN_AcquireNative and all of the other DTWAIN Acquisition functions return immediately if modeless acquisitions are being done.  If you are not using modeless processing, the return value will be NULL, indicating that an error occurred.  The error can be determined by inspecting the last parameter of the DTWAIN Acquisition call (pStatus), or by calling DTWAIN_GetLastError.

 

 

Q: How do you specify to acquire a certain number of pages?

A: The third parameter to all of the DTWAIN Acquisition functions, MaxPages, allows you to set the number of pages to acquire.

 

 

Q: When I attempt to acquire multiple pages, I only get a single page and then the acquisition terminates.   I have enabled the document feeder by calling DTWAIN_EnableFeeder, and I have specified DTWAIN_ACQUIREALL for the DTWAIN_Acquire... functions.  What could be the problem?

A: Check if you have DTWAIN notifications enabled, and if they are, check that you are returning TRUE from your window procedure or callback that captures the DTWAIN messages.   If you do not do this, the DTWAIN_TN_PAGECONTINUE notification will be sent to your window when attempting to acquire the next page,and your window procedure may be returning FALSE by mistake, which in effect stops the acqusition.  Remember that DTWAIN_TN_PAGECONTINUE expects a return value of TRUE to continue acquiring pages.  If the return value is FALSE for this notification, acquisition terminates.

 

By default, DTWAIN always starts with notifications disabled when DTWAIN_SysInitialize is called.  To check if DTWAIN notification processing is enabled, the DTWAIN_IsMsgNotifyEnabled function can be called.  To enable or disable DTWAIN Notification processing, call the DTWAIN_EnableMsgNotify function before acquiring any images.

 

 

Q: When I acquire images and close the Source user interface, I can't reopen the Source user interface again if I try to acquire more images.  Why does this happen?

A: You might be using a Source that does not behave correctly if the Source remains opened after the user interface is shut down.  Remember that a Source can remain open, even though the user interface has been closed, however some Sources are poorly written and do not respond well if they remain open when you make subsequent attempts to acquire images.  These Sources require that they must be closed once the user interface is shut down.  To circumvent this problem, the Source should be closed after the UI has been closed.  All of the DTWAIN acquisition functions have a DTWAIN_BOOL argument denoting whether the Source should automatically close if the user interface is closed.  Make sure that you specify TRUE for this value.  If not, your application can still call DTWAIN_CloseSource to close the Source.

 

 

Q: How do I get the returned image data once the acquisition has completed?  I do not want to save the image data to a file.

A: For DTWAIN_MODAL processing Call the DTWAIN_GetAcquiredImage, DTWAIN_GetCurrentAcquiredImage, or the, DTWAIN_GetAcquiredImageArray  on the return value of the DTWAIN_AcquireNative or DTWAIN_AcquireBuffered function.  These functions allow you to access the returned DIBs or raw image data.  If the image data is a DIB, your application must use GlobalLock on the returned HANDLEs to get the image data.  Your application is also responsible for calling GlobalUnlock (if the memory was locked) and GlobalFree to free the image memory.

 

For DTWAIN_MODELESS operation, the DTWAIN_GetSourceAcquisitions function returns the array of Source acquisitions.  This array of values is the same value that is returned when DTWAIN_AcquireNative or DTWAIN_AcquireBuffered is called in DTWAIN_MODAL mode.  This function should be called when DTWAIN sends the DTWAIN_TN_ACQUIREDONE notification during image acquisition.

 

 

Q: Do I need to process the images once they are retrieved, or will DTWAIN delete them if not processed?

A: It must be emphasized that except for DTWAIN_AcquireFile and DTWAIN_AcquireFileEx, DTWAIN does not delete any images generated by the image device.  Your application must be ready to process any image that is generated by the Source.  This includes deletion of the images (using GlobalFree).  If not, the program will have a memory leak, since DTWAIN resets the acquisition count to zero when the DTWAIN Acquisition function is called, and there is no way for DTWAIN to remember the addresses of the image data that was previously acquired.

 

The reason why DTWAIN does not do anything with the image is that the application should be responsible for handling the image.  Other TWAIN related libraries may delete the image at a specific time, however this is a restrictive and dangerous practice.  Since image handling is somewhat independent of acquiring the image, DTWAIN's responsibility stops at the point that the image has been generated.  Once this is done, the image is independent of DTWAIN.  You can even unload DTWAIN (DTWAIN_SysDestroy) and the acquired images are still valid.  This frees your application from having to worry about a 'surprise' deletion of the image by DTWAIN.

 

 

Q: I am trying to acquire an image with no UI, however the DTWAIN Acquisition functions return with an error and the DTWAIN_GetLastError is equal to DTWAIN_ERR_UI_ERROR.  Why can't I acquire an image without the default UI?

A: Some Sources do not allow acquisitions without the UI displayed.  DTWAIN returns an error if you attempt to acquire an image without a UI for the Sources that do not allow this mode.  You can test if the Source will allow operation without a UI by calling the DTWAIN_IsUIControllable function.

 

 

Q: I want to acquire an image to an image file, however DTWAIN does not support the file format that I desire.  What do I do now?

A: Acquire the image using the native (DTWAIN_AcquireNative) or buffered (DTWAIN_AcquireBuffered) mode, and handle the returned images using a third-party library or source code that converts and saves image's to the file format that you desire.

 

 

Q: Can I check if a Source is acquiring an image?  I need to disable some controls so that the user doesn't inadvertently start another TWAIN session.

A: Yes.  Use the DTWAIN_IsSourceAcquiring and DTWAIN_IsAcquiringfunctions.  You should also use these functions to test if it is safe to close your application.

 

 

Q: Does DTWAIN support the 'Acquire To File' that some Sources include internally?

A: Yes.  If you specify DTWAIN_USESOURCEMODE as one of the flags when you call DTWAIN_AcquireFile, DTWAIN will attempt to use the Source's internal file support.

 

 

Q How do I set the acquisition pixel type when I scan an image?

A: The PixelType parameter in the DTWAIN Acquire Functions sets the pixel type (color) of the acquired image.

 

 

Q: Does DTWAIN_AcquireBuffered support compression?

A: Yes.  You must call DTWAIN_SetCompressionType to set the compression to use.

 

 

Q: Does DTWAIN_AcquireBuffered support tiled data?

A: No.  Currently, only strips are supported.

 

 

Q: I want to acquire an area of the image and not the entire page.  How do I do this with DTWAIN?

A: Call the DTWAIN_SetAcquireArea function or DTWAIN_SetAcquireArea2function.

 

 

Q: I want to get the handle to the images as they are being acquired by the Source.  How do I do this?

A:  Handle the DTWAIN_TN_ACQUIREDONE notification.  To get the handle to the image call the DTWAIN_GetCurrentAcquiredImagefunction.  Handling notifications can be done with either Modal or Modeless acquisitions.

 

 

Q: I need to get/set a capability when I get a MSG_XFERREADY message from TWAIN.  What is the equivalent of doing this with DTWAIN?

A: Capture the DTWAIN_TN_TRANSFERREADY notification.  You can then get/set the device capability.

 

 

Q: DTWAIN notifications simplify things a lot, however I'm a hard-core TWAIN programmer and would like to receive all of the TWAIN messages.  Can I do this with DTWAIN?

A: Yes. To get the handle to the TWAIN window, call DTWAIN_GetTwainHwnd.

Once you get the HWND, you can then subclass this window and intercept the messages before DTWAIN sees them (subclassing involves writing a custom window procedure).  Make sure that every message that is processed by your window procedure is sent to DTWAIN.  The topic of subclassing a window is advanced, so no further discussion of this topic will be done.

 

If your application called DTWAIN_StartTwainSession with a NULL window handle, or if you allowed DTWAIN to start the TWAIN session automatically without a window handle, DTWAIN creates a window for that will receive the messages. Otherwise the HWND specified by DTWAIN_StartTwainSession is used as the message window.  Even though the window may be have been created by your application, you still must subclass the window for DTWAIN to work properly.

 

 

Q: Can I limit the number of acquisitions attempted when using the Modal Processing?  I want the Source UI to close as soon as the acquisitions are completed.

A: Yes.  Call DTWAIN_SetMaxAcquisitions before calling the DTWAIN Acquisition function.  To allow the Source to close immediately, set the count parameter in DTWAIN_SetMaxAcquisitions to 1.

 

 

Q: Describe the process of acquiring with no UI.

A: DTWAIN allows your application to acquire images with no Source UI (if the Source allows this operation).  DTWAIN will acquire one and only one set of images each time a DTWAIN Acquisition function is called.  Basically this means that DTWAIN automatically sets the maximum number of acquisition attempts to one when no UI is used.

 

 

Q: I am using DTWAIN Modal Acquisition.  I can acquire images, however the application gives a General Protection Fault, or closes down for no reason after the user closes the UI.  What could be the problem?

A: The problem could be a number of things.  The first thing is to make sure that only one DTWAIN Acquisition function is attempted per application message.  Successive calls to the DTWAIN Acquisition functions (one call right after the other) while using modal acquisitions results in message processing problems with some Sources. One possible reason for this is that the Source UI is implemented in such a way that the there may be a conflict in the processing of the application's message loop, and the messages that are sent to the Source UI.

 

Also, make sure that you are not calling DTWAIN_IsTwainMsg, since DTWAIN handles the message processing when doing a Modal Acquisition.

 

Another reason is that the Source may have bugs.  The way to test this is to either a) use the Modeless Acquisition processing or b) run another application (such as Photoshop) that allows you to choose a Source and acquire an image. If the problem persists in none of the above cases, the Source is not the problem.  If the problem persists only in the DTWAIN Modeless application, the problem is with DTWAIN and you should send a bug report to Dynarithmic Technologies.  If the DTWAIN Modeless application works fine, then you should also send a bug report to Dynarithmic Technologies, since the Source does not like Modal Acquisitions

 

 

Q: I am using DTWAIN Modeless Acquisition, but the Source UI does not respond to any mouse clicks, accelerator keys, etc.  Why?

A: Make sure that DTWAIN_IsTwainMsg is called in your application's main message loop before calling TranslateMessage and DispatchMessage  See the topic Modeless Acquisition Processing for more information.