Home › Forums › TWAIN Classic › Set X / YResolution returned TWRC_CHECKSTATUS! Fujitsu C#
- This topic has 16 replies, 3 voices, and was last updated 16 years, 2 months ago by black_ghost.
- AuthorPosts
Sorry I already do the Search but can’t find the answer!!
I am trying to set the scanner’s Resolution (DPI) in C# with segment of codes below. My scanner is Fujitsu fi-5120C.
…..TwFix32 f32 = new TwFix32();
f32.FromFloat(X_DPI);
tc = new TwCapability(TwCap.XResolution, f32.Whole);
tc.ConType = (short)TwOn.One;
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);
if (rc != TwRC.Success && rc != TwRC.CheckStatus)
{
CloseSrc();
return;
}f32.FromFloat(Y_DPI);
tc = new TwCapability(TwCap.YResolution, f32.Whole);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);
if (rc != TwRC.Success && rc != TwRC.CheckStatus)
{
CloseSrc();
return;
}tc = new TwCapability(TwCap.IPixelType, (short)_ScanMode);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
I have no problem to set the pixeltype and scan in duplex mode, but setting the resolutions to 600×600 failed.I tried this on other scanner and works fine, but not the Fujitsu scanner.
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);
The Fujitsu fi-5120c scanner returned this TwRC.CheckStatus
The Brother MFC-7820N retuned TWRC.SuccessBTW: My computer is running Vista business. Tested both scanner on the same computer as well..
try to set that cap with twacker. if twacker can’t do it either, then it isn’t your code – it is entirely possible that the scanner doesn’t support setting that cap to that value… If you send a get for xresolution you often get the allowed values for the set operation – try setting to one of the value you recieve from the get op.
What do you have for units when you are trying to set the resolution?
And as with everything else, what is the condition code returned?@gabe wrote:
try to set that cap with twacker. if twacker can’t do it either, then it isn’t your code – it is entirely possible that the scanner doesn’t support setting that cap to that value… If you send a get for xresolution you often get the allowed values for the set operation – try setting to one of the value you recieve from the get op.
I just tried to set xResolution cap with Twacker..and it worked. I think something wrong with the type?
In Twacker, the itemtype is TWTY_FIX32 and the value I set to 50 for X Resolution.
If the value set to XResolution must be TWTY_FIX32, for my app it is the TwFix32 object.
But, TwCapability() doesn’t take the twfix32 object as value. It only take the value in Short!
TwFix32 f32 = new TwFix32();
f32.FromFloat(50);
tc = new TwCapability(TwCap.XResolution, f32.Whole);
tc.ConType = (short)TwOn.One;
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);rc will return CheckStatus. But Twacker tell me that the value can be set to the scanner!! Other CAP are alright, except this one taking the TwFix32 .
I am not sure how to get the xresolution from the get op in the code. Can you give me a sample code?
@gabe wrote:
What do you have for units when you are trying to set the resolution?
And as with everything else, what is the condition code returned?I tried to set the units to pixels and got success returned!
tc = new TwCapability(TwCap.IUnits, (short)TwUn.PIXELS);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, tc);so it sounds like your scanner will take the value,
good (thank you twacker)if you’re unable to send a fix32 to your twCap it sounds like you need to work over your twain library a bit, which brings up a question – how are you talking to twain from c#? are you using a library you write or the library you found on codeproject by netMaster?
to get the values for the cap you send get instead of set in the op and then read the values it puts in the container that you sent in (mostly)
a condition code is like a return code except is describes (in most cases) why you recieved the preious return code – I typically only check the cc when the previous call produced an rc != success. read through the twain spec for more on that… hell read through the twain spec regardless. then read though it again.
do I have code for setting the xresolution… yes and no. I don’t take the setting caps one-by-one approach (I believe it is a flawed design for working with twain), but I can probably find some code to approximate what you’re doing. first, lets talk about your library and then how you defined you twCap class. I have something of an example for the twCap class if you’re using the 2.0 framework and either read vb.net or have a decent converter (sharpdevelop 2.1 comes to mind if you want to convert it to c#) the code is over at http://www.codeplex.com/opentwain. you won’t find xresolution setting in the class but you can compare the twCap class.
.
@gabe wrote:
so it sounds like your scanner will take the value,
good (thank you twacker)if you’re unable to send a fix32 to your twCap it sounds like you need to work over your twain library a bit, which brings up a question – how are you talking to twain from c#? are you using a library you write or the library you found on codeproject by netMaster?
Yes, download from codeproject! so I should make the fix32 send to twCap right? the code from netMaster, never have that part done!!
@gabe wrote:
to get the values for the cap you send get instead of set in the op and then read the values it puts in the container that you sent in (mostly)
a condition code is like a return code except is describes (in most cases) why you recieved the preious return code – I typically only check the cc when the previous call produced an rc != success. read through the twain spec for more on that… hell read through the twain spec regardless. then read though it again.
do I have code for setting the xresolution… yes and no. I don’t take the setting caps one-by-one approach (I believe it is a flawed design for working with twain), but I can probably find some code to approximate what you’re doing. first, lets talk about your library and then how you defined you twCap class. I have something of an example for the twCap class if you’re using the 2.0 framework and either read vb.net or have a decent converter (sharpdevelop 2.1 comes to mind if you want to convert it to c#) the code is over at http://www.codeplex.com/opentwain. you won’t find xresolution setting in the class but you can compare the twCap class.
.[/quote]I got OpenTwain already.. looks like it is not complete!
so you suggest I should look at it?Thanks!!
openTwain its not complete in the sense that there are more to do – seems like there always is. Buffered memory transfers aren’t in there and I like to finish fleshing out the standard caps so that they take the appropriate params and types and expose the ops supported appropriately. In the current build you have to build up each of the caps the same way you do with netmaster code and I don’t think that is a particuarly useful design. The parts that are there work and are stable. the parts that don’t work should all be commented as ‘not live’ and you’ll find the classes there empty.
Do I suggest you look at it… it may help. it is based on netmasters code. I added the rest of the enumerations, cc checking, a custom message loop so that you don’t have to modify your message loop in you app – just handle the events from the library, added tracking for the twState and fixed a problem he had with his transitions. added ImageInfo and ExtImageInfo checking…look at the constructors for twCapability it should look something more like opentwain in that the size of memory reserved should depend on the cap coming in , if I remember right he hard coded a number that should be looked up. [EDITED: the value he hardcoded was the size of memory to allocate for the container – the method I use to determine the size is named ‘m_itemSizeOf’ – you’ll find it in DataStructures.vb, in the twCapability classs, his method will fail for several of the standard caps] I’ll look back over my notes from when I did the first couple reviews to see is there was anything else in his code that I tripped up on.
and don’t get me wrong, his code is brilliant – especially in the sense that there really didn’t exist (m)any alternatives for people that wanted to talk directly to twain from .net without buying a library – but at the same time, as he says in the article it is mostly a demonstration of interop not twain.
if you have questions just ask, I’m fairly familliar with netMasters code.
.
Where can I find DataStructures.vb? I’m looking for it, becaues I’m also working with NetMaster’s code and I’ve got hardcoded size of memory.
2 posts (3 if you count this one) i post a link to opentwain. then in follow the directory tree down to .openTwainTwainDataStructures and you’ll see the .vb file
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.Any ideas? 🙂
what page? it’s a file. you download the zip file. you open the zip file, then you go down a couple directories,..
.
OK, sorry, my fault.
Will be in VB.NET and C# the size of data types the same?
yes, slightly different signatures, declarations between c# and vb.net, but the the common type system (CTS) is a fundamental part of the common runtime language (CLR) for all .net languages.
.
and if you’re looking for a simple converter (c# <-> vb.net) it seems to me that #develop does the best job – http://www.icsharpcode.net/
.
ok, but can you tell me, why is someone (you?) add to each size of data type OneValue.baseSize (I’m talking about DataStructures.vb)?
I’m asking, because I’m trying fix the constructor of cTwCapability in NetMaster’s code.
- AuthorPosts