TwainSetImageLayout on HP Scanjet Enterprise 7000 s2

Discussions about TWAIN scanning in GdPicture.NET using GdPictureImaging.
Post Reply
Starceaker
Posts: 7
Joined: Tue Nov 05, 2013 4:38 pm

TwainSetImageLayout on HP Scanjet Enterprise 7000 s2

Post by Starceaker » Wed Nov 06, 2013 3:06 pm

Scanner used: HP Scanjet Enterprise 7000 s2
Goal: specify which area of the document the scanner needs to use
Other: TwainGetState returns 4, which is what it should be as far as I know

To make sure the PaperSize is set to Custom I use:

Code: Select all

TwainSetPaperSize(GdPicture_NET_10_TwainPaperSize_TwainPaperSize_NONE, bLOk)
I know that the function TwainSetImageLayout accepts values in Inches.
However, when calling the function with these dummy parameters:

Code: Select all

TwainSetImageLayout(1.5, 1.5, 3.5, 3.5, bLOk)
The Receive Boolean bLOk is set to TRUE but the dialog, that is set by TwainSetHideUI(FALSE), still shows the default values. When I change the values in this dialog and then do a TwainGetImageLayout I do receive the new values.

Screenshot of the dialog:
PageSize.png
Request:
Could you tell me if I'm using the TwainSetImageLayout correctly or not? If not, please advise what I can do to make this work.

Cedric
Posts: 257
Joined: Sun Sep 02, 2012 7:30 pm

Re: TwainSetImageLayout on HP Scanjet Enterprise 7000 s2

Post by Cedric » Thu Nov 07, 2013 11:33 am

Since GdPicture.NET accesses to the TWAIN Data Source Manager only, it cannot have any control over the drivers generated settings window so there is absolutely no relation between what you set in your code and what you see and set in the drivers settings window.
Setting the image layout in your code and then displaying the driver UI will overwrite your previous image layout with the driver's one.
Basically you have to make a choice: either hide the driver UI and set the values in your code or show the driver UI and let the user set the values in it.

Starceaker
Posts: 7
Joined: Tue Nov 05, 2013 4:38 pm

Re: TwainSetImageLayout on HP Scanjet Enterprise 7000 s2

Post by Starceaker » Thu Nov 07, 2013 12:26 pm

Ok, thank you. I will see what I can do without showing the UI.

Starceaker
Posts: 7
Joined: Tue Nov 05, 2013 4:38 pm

Re: TwainSetImageLayout on HP Scanjet Enterprise 7000 s2

Post by Starceaker » Thu Nov 07, 2013 4:51 pm

Cedric, when I don't show the User Interface it still scans the entire page.

I have tried multiple functions, that all return TRUE so I'm out of ideas at the moment:

Code: Select all

TwainSetPaperSize(GdPicture_NET_10_TwainPaperSize_TwainPaperSize_NONE, bLOk)
TwainSetAutoSize(FALSE, bLOk)
TwainSetImageLayout(0, 0, 3, 3, bLOk)
Do you know if there are functions that would cancel the effect of TwainSetImageLayout? A detailed example in the help file would be great :-).

Cedric
Posts: 257
Joined: Sun Sep 02, 2012 7:30 pm

Re: TwainSetImageLayout on HP Scanjet Enterprise 7000 s2

Post by Cedric » Thu Nov 07, 2013 5:52 pm

I'm not sure setting the paper size to none is a good idea actually, because even though you don't want to acquire the whole page, I think you need to tell the device what kind of paper is expected prior setting a region of interest.
I think your best shot would be to call the TwainGetImageLayout to be sure it has been set correctly and call it again at different steps in your setting process to find out if it is modified and if yes, when.
You should also call the TwainResetImageLayout method before setting anything else regarding the image layout in order to clear it out, but I doubt that it is the issue here.

Starceaker
Posts: 7
Joined: Tue Nov 05, 2013 4:38 pm

Re: TwainSetImageLayout on HP Scanjet Enterprise 7000 s2

Post by Starceaker » Thu Nov 07, 2013 6:07 pm

Ok, I'll try those suggestions soon. Thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest