Questions about image orientation

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
dcanelas
Posts: 8
Joined: Fri Jan 07, 2011 5:17 pm

Questions about image orientation

Post by dcanelas » Fri Jan 07, 2011 5:44 pm

I tested the next code (C#) with two different scanners, and both sent the same result: only works with TwainOrientation.TWOR_ROT0.

Code: Select all

if (oGdPictureImaging.TwainIsRotationAvailable()) //always returns true
{
	if (!oGdPictureImaging.TwainSetOrientation(orientation))
	{
		//throw error. It appens always, except when orientation == TwainOrientation.TWOR_ROT0
	}
}

1st question: Is this normal, or am i doing something wrong here?
2nd question: This option depends on the twain driver? Is there any way to get the supported orientations?

Models tested: fi-4340C and fi-6130 from Fujitsu.
Version: 7.3 GdPicture.Net

Thank you,
Dora Canelas

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Questions about image orientation

Post by Loïc » Fri Jan 07, 2011 7:01 pm

Hi Dora,

Yes it depends of the scanner driver. See TwainIsRotationAvailable() tho check if the feature is supported or not.

Kind regards,

Loïc

dcanelas
Posts: 8
Joined: Fri Jan 07, 2011 5:17 pm

Re: Questions about image orientation

Post by dcanelas » Mon Jan 10, 2011 6:58 pm

Hi,

I'm already checking TwainIsRotationAvailable(), and it always returns true (has you can see in the code). But the only option accepted is TWOR_ROT0, all other options in documentation returned false when I tried to set orientation.

As it depends on the driver, is there a way to get the available orientations? Or i have to test all options against the driver to know what options to make available to user?

Thanks once again,
Dora Canelas

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Questions about image orientation

Post by Loïc » Tue Jan 11, 2011 4:32 pm

Hi Dora,

I just checked with 2 scanner. One supporting rotation, other one which don't supports.
Returned values from all functions are one expected.

Maybe you are using wrong Parameter with the TwainSetOrientation() function. Keep in mind that you have to give an angle in degrees. IE: TwainSetOrientation(90)

Kind regards,

Loïc

dcanelas
Posts: 8
Joined: Fri Jan 07, 2011 5:17 pm

Re: Questions about image orientation

Post by dcanelas » Tue Jan 11, 2011 7:36 pm

I am very sorry, Loïc, but now I'm quite confused.

In the documentation, I have the following information:
public Boolean TwainSetOrientation (
TwainOrientation Orientation
);

And also that:
public enum TwainOrientation
{
TWOR_ROT0 = 0,
TWOR_ROT90 = 1,
TWOR_ROT180 = 2,
TWOR_ROT270 = 3,
TWOR_PORTRAIT = TWOR_ROT0,
TWOR_LANDSCAPE = TWOR_ROT270,
TWOR_AUTO = 4,
TWOR_AUTOTEXT = 5,
TWOR_AUTOPICTURE = 6
}

When I try the suggested code (TwainSetOrientation (90)), I get a compile error (obvious) "Argument 1: can not convert from 'int' to 'GdPicture.TwainOrientation. "

Should I be using the method GdPictureImaging.TwainSetCapCurrentNumeric with TwainCapabilities.ICAP_ORIENTATION and passing the angle as parameter? If so, what is the purpose of the method TwainSetOrientation()? And what about the last 3 options (TWOR_AUTO, TWOR_AUTOTEXT and TWOR_AUTOPICTURE)?

Again, thanks for your answers,
Dora Canelas

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Questions about image orientation

Post by Loïc » Tue Jan 11, 2011 9:52 pm

Hi Dora,

OK I understood... Both of us made confusion between TwainSetOrientation() and TwainSetRotation().

You can try that:

Code: Select all

if (oGdPictureImaging.TwainIsRotationAvailable()) //always returns true
{
   ioGdPictureImaging.TwainSetRotation(90);

}
Kind regards,

Loïc

dcanelas
Posts: 8
Joined: Fri Jan 07, 2011 5:17 pm

Re: Questions about image orientation

Post by dcanelas » Wed Jan 12, 2011 1:32 pm

Ok, I can really do that.

But setOrientation has some automatic options that still can not see working and look very interesting: TWOR_AUTO, TWOR_AUTOTEXT and TWOR_AUTOPICTURE.

As the method SetOrientation exists and is documented, why am I not able to use it? It seems that this method should do what the SetRotation does and something more.

In the documentation, I have:
TwainSetRotation: Asks to the opened source to rotate the scanned image data prior to transfer.
TwainSetOrientation: Asks to the opened source to define which edge of the “paper” the image’s “top” is aligned with. This information is used to adjust the frames to match the scanning orientation of the paper.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Questions about image orientation

Post by Loïc » Wed Jan 12, 2011 1:35 pm

Hi,
As the method SetOrientation exists and is documented, why am I not able to use it?
I suppose your scanner does not provides the option. Just use the TwainIsOrientationAvailable() method.

Kind regards,

Loïc

dcanelas
Posts: 8
Joined: Fri Jan 07, 2011 5:17 pm

Re: Questions about image orientation

Post by dcanelas » Wed Jan 12, 2011 4:53 pm

I'm getting a bit lost: (

As I said in the first message, oGdPictureImaging.TwainIsRotationAvailable () is returning true.

Moreover, the following code returns true, and works fine:

Code: Select all

oGdPictureImaging.TwainSetRotation(90)
But this returns false, and the scanning process fails:

Code: Select all

oGdPictureImaging.TwainSetOrientation(TwainOrientation.TWOR_ROT90)
It was not supposed to do the same thing?

I repeat that the aim would be to use the TwainSetOrientation because it has automatic detection options.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Questions about image orientation

Post by Loïc » Thu Jan 13, 2011 11:43 am

Hi Dora,
As I said in the first message, oGdPictureImaging.TwainIsRotationAvailable () is returning true.

OK but TwainSetOrientation() & TwainSetRotation() are different methods for different purposes !
So to use the SetOrientation() method, ensure that TwainIsOrientationAvailable() returns True.

Seems your scanner does not support this feature, so you will no able to use it.

Kind regards,

Loïc

dcanelas
Posts: 8
Joined: Fri Jan 07, 2011 5:17 pm

Re: Questions about image orientation

Post by dcanelas » Thu Jan 13, 2011 2:01 pm

Sorry, but as I tried both methods, I ended up confused.

For there are no more doubts:

TwainIsOrientationAvailable() returns true and TwainSetOrientation(TwainOrientation.TWOR_ROT90) does not work

TwainIsRotationAvailable() returns true and TwainSetRotation(90) works

And the questions remain: why?

dcanelas
Posts: 8
Joined: Fri Jan 07, 2011 5:17 pm

Re: Questions about image orientation

Post by dcanelas » Thu Jan 20, 2011 11:22 am

Hello,

I am still awaiting further clarification on this matter.

Thank you.

Dora

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Questions about image orientation

Post by Loïc » Fri Jan 21, 2011 3:37 pm

Hi Dora,

I suspect your scanner to tell that it allows this feature but only supporting TWOR_ROT0.

To check that just make the following call:

Code: Select all

Dim SupportedVaues = Imaging1.TwainGetAvailableCapValuesCount(TwainCapabilities.ICAP_ORIENTATION)
I suppose SupportedVaues = 1 at this step.

Now then use the following loop to get supported values:

Code: Select all

 For i As Integer = 1 To Imaging1.TwainGetAvailableCapValuesCount(TwainCapabilities.ICAP_ORIENTATION)
         MsgBox(CType(Imaging1.TwainGetAvailableCapValueNoNumeric(TwainCapabilities.ICAP_ORIENTATION, i), TwainOrientation).ToString)
Next
Now I suppose the loop simply displays TWOR_ROT0.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest