Home › Forums › TWAIN Classic › ICAP_BRIGHTNESS
- This topic has 10 replies, 2 voices, and was last updated 16 years, 1 month ago by kornjaca.
- AuthorPosts
Hello, everybody,
I’m writing a test TWAIN application. I started with codeproject twain c# project and I’m making my way up. 😉
So, I got stuck in negatiation of capabilities. Here’s my problem:
First, I do
TwCapability capGet = new TwCapability(TwCap.CAP_SUPPORTEDCAPS);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Get, capGet);in order to get supported capabilities. In them, I see that my scanner supports ICAP_BRIGHTNESS. So far, so good.
Next, I try to get allowed values for brightness:
TwCapability capGet = new TwCapability(TwCap.ICAP_BRIGHTNESS);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Get, capGet);From this I see that min value for brightness is -1000, max value is 1000, and step size is 7 (that’s a bit funny, since when I open Canon GUI, I get available values ranging from -127 to 127 – can somebody explain this difference?)
Anyway, then I proceed and set brightness to -100.
TwFix32 val = new TwFix32();
val.FromFloat(-100.0f);
TwCapability capSet = new TwCapability(TwCap.ICAP_BRIGHTNESS, val);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capSet);Now I check the value again with TwMSG.Get, and it is set to value -100. After that, I open Canon GUI, and the value is not -100 but default value of 0. 🙁
I’m new at this, but I was expecting GUI to reflect my set value for brightness. Is this the way GUI should behave? Is the only option to write my own GUI? I hope not… 🙂
Please, can somebody pont me in the right direction? What I’m doing wrong?
Thanks!
if you are using the source code from codeproject as-is (at least as-is from the last time I checked it) there is a problem with NetMaster’s twCapability ctor. He assumes in his sample a static baseAddress size where he should have either calcualted the baseAddress size based on the ItemType or assumed a slightly larger baseAddress size. The result is that FIX32 types don’t work. It’s i nthe forumn comments on tha pag.
@gabe wrote:
if you are using the source code from codeproject as-is (at least as-is from the last time I checked it) there is a problem with NetMaster’s twCapability ctor. He assumes in his sample a static baseAddress size where he should have either calcualted the baseAddress size based on the ItemType or assumed a slightly larger baseAddress size. The result is that FIX32 types don’t work. It’s i nthe forumn comments on tha pag.
Gabe, thank you for your quick reply. I added another contructor like this:
public TwCapability(TwCap cap, TwFix32 val)
{
Cap = (short)cap;
ConType = (short)TwOn.One;
Handle = Twain.GlobalAlloc(0x42, 6);
IntPtr pv = Twain.GlobalLock(Handle);
Marshal.WriteInt16(pv, 0, (short)TwType.Fix32);
Marshal.WriteInt16(pv, 2, val.Whole);
if (val.Frac > Int16.MaxValue)
{
Marshal.WriteInt16(pv, 4, Convert.ToInt16(val.Frac – 32768));
}
else
{
Marshal.WriteInt16(pv, 4, Convert.ToInt16(val.Frac));
}
Twain.GlobalUnlock(Handle);
}And I believe my Fix32 value is correctly passed into TWAIN Data Source since i get Success status, and also when I after that ask data source for it’s value, it returns me the same value I set. The problem is that GUI doesn’t reflect negotiated capabilities. Any ideas?
@kornjaca wrote:
The problem is that GUI doesn’t reflect negotiated capabilities. Any ideas?
what device are you using? It is rather common for a vendor’s Ui to not reflect what you thin kthey should. If you don’t fire the vendor’s Ui does it operate as you thin it should?
.
@gabe wrote:
what device are you using? It is rather common for a vendor’s Ui to not reflect what you thin kthey should. If you don’t fire the vendor’s Ui does it operate as you thin it should?.
Yes, if I don’t show vendor’s GUI, the scanner scans with the brightness I set! But I’d really like to use vendor’s GUI, is there any known workaround for this? I’m currently using Canon MP530 in my development environment, but who knows which one will be used in production.
no workaround that I know of. If you search thru post on ‘Canon’ you see a pattern of people who aren’t thrilled with Canon’s twain support.
Workaround,… seeing as most Canons support CAP_ENABLEDSUIONLY I would go that route. I use CAP_ENABLEDSUIONLY on Kodak scanners and I’m tickled with the flexibility.
.
@TWAIN19.pdf wrote:
CAP_ENABLEDSUIONLY – Allows an application to query a source to see if it implements the new user interface settings
dialog. If a source reports that it has the capability CAP_ENABLEDSUIONLY, then it must
implement the operation triplet DG_CONTROL/ DAT_USERINTERFACE/
MSG_ENABLEDSUIONLY to display the source user interface without acquiring an image.I don’t quite get the idea of this. What is a “new user interface settings dialog”?
ok, this is going to be slightly offtopic.. but here it is.
it isn’t new. introduced in (I think) the 1.7 spec EnableDsUiOnly allows you to retrieve all of the settings from the vendor as (basically) a string. It is used (at least by me) for building a profile of the settings I want to use for an acquisition.
Following EnableDsUiOnly the standard vendor Ui comes up, but when the user Oks the Ui instead of an acquisition starting (as is the case with EnableDs) you are able to query for the settings with CustomDsData/Get.
The idea is that you often only have a handful of settings you want to scan with -say high, medium, low, full color & blackWhite (you may have others, but follow the idea).
Users are able to use the Vendors Ui to specify what they want. You pull and store the settings. Then later when they want to scan something, instead of you manipulating the settings (as you are today when you set the brightness) you just send CustomDsData/set with the string you pulled eariler with CustomDsData/Get.
Following this kind of profile based approach you no longer need to manipulate caps one-by-one.
Plus for day-to-day production use they no longer have a chance or risk of scannign with incorrect values.If your devices support EnalbeDsUiOnly and CustomDsData (and if the twister reports are correct) then this is imho a much better model for cap negotiation.
now back to your question. Is there a setting for brightness in the Vendor Ui? And more importantly, does it make sense in your use to have the users use that settings instead of setting brightness by hand or do you really really need to set the brightness by hand?
.
gabe, thank you very much for your clarification of EnableDsUiOnly process! If I got it correctly, I might solve my problem by presenting user with EnableDsUiOnly dialog, after he clicks “OK” I retrieve the values user just set by using CustomDsData/Get. Right after that, I use CustomDsData/Set to send those values to scanner and then start acquiring process without GUI. So to user it would seem that they just entered values and started scanning.
But, if I run into device that doesn’t support CAP_ENABLEDSUIONLY, I need to have a fallback strategy using cap-by-cap approach. What is the widespread of CAP_ENABLEDSUIONLY capability these days? Is it reasonable to expect that most (every?) devices out there support it?
What I’m trying to achieve is following: when user first opens GUI, it sets some data (brightness, contrast, width, height, color, …) that I save to his profile. Then he scans images and closes application. After that, the next time the same user opens GUI, I want to “prepare” GUI with values from his previous session.
how available is EnableDsUiOnly..
Hard to say. So far it seems that Kodak supports it, Hp does in their commercial drivers but not the standard ones (HPs commercial drivers on the Cd, they just aren’t the default) Epson doesn’t seem to support it, Canon looks like they do but I’ve never tested a Canon, FUJITSU supports it and funny enough some people say that hacking the CustomDsData by hand is the only way to take advantage of some of their features…When people ask me if deviceXY2 supports EnableDsUiOnly I go over to Dosadi’s archive of twister reports looking for their model or a close match on the model#. Last time I checked Dosadi had 88 reports on hand. No, I don’t have the weblink to their archive on hand I always google for:
Dosadi twister report archive
and I get it within a click or two.My process is slightly different than what you describe, but you seem to be getting the idea.
I make the users predefine their scanning profiles. I save the CustomDsData along with some extra stuff (like whether they want it converted to Multipage Tiff or pdf, Where they want the image saved when it is done, etc..)Then later they can choose which profile they want to run.
And if their device doesn’t seem to support EnableDsUiOnly I tell them to get one that does.
There are too many fun projects and too few hours to worry about devices that make life hard(er)..
OK, gabe, thank you very much for your help and your clarifications!
- AuthorPosts