|
can someone tell me how to change the resolution and i also want to capture image as black and white. can someone help me? any help would be welcome.(I want to hide the UI and give the parameters from the code only)
|
|
|
|
|
// Set the X resolution
TwCapability capResX = new TwCapability(TwCap.CAP_RESX, 50, TwType.Fix32);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capResX);
if (rc != TwRC.Success) { CloseSrc(); return; }
// Set the Y resolution
TwCapability capResY = new TwCapability(TwCap.CAP_RESY, 50, TwType.Fix32);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capResY);
if (rc != TwRC.Success) { CloseSrc(); return; }
// Set the scan type // 0 = BW | 1 = Gray | 2 = Colour
TwCapability capPixelType = new TwCapability(TwCap.IPixelType, 2);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capPixelType);
if (rc != TwRC.Success) { CloseSrc(); return; }
|
|
|
|
|
|
Is there a way to get the image without the HP screen which i get when i click on acqiure
Any help would be welcome
|
|
|
|
|
In TwainLib.cs search for function Acquire().
There you will find:
TwUserInterface guif = new TwUserInterface();
guif.ShowUI = 1;
guif.ModalUI = 1;
Make this:
TwUserInterface guif = new TwUserInterface();
guif.ShowUI = 0;
guif.ModalUI = 0;
I hope that this is what you mean...
|
|
|
|
|
Thanks. That is exactly what i wanted. thank you once again.
|
|
|
|
|
First Thanks for the code. After a long day +1 of attempting to get the duplex mode running using the instructions in the below message thread
" Use Duplex with Driver Twain - Help URGENT " I finally got the duplex mode by incorporating the code from that message thread along with setting from 1 to 2 in TwainLib.cs (line 102 +-)
TwCapability cap= newTwCapability( TwCap.XferCount, 2 );
Hope this helps someone!
Morke
|
|
|
|
|
Hi, I find the application very useful, 10x to the authors. But I want to do a slightly different thing - when I choose 'acquire' to capture a picture of what is in the scanner automatically (I don't want to see the default software of the TWAIN interface, to capture a picture etc...) Simply - with a single click in my application to get a scanned picture. Is it possible? Or is there any documentation of twain_32.dll ?
|
|
|
|
|
hello,
I have Downloaded code and use same code by .NETMASTER
and is running nicely on my pc but when i port this project to other machine its not running it gives error dialog box(error-cheack originals,No originals in feeder),its allows us to select source but on acquire it gives this error, even i have installed driver for scanner .so my question is ,is there any dependency of "twain_32.dll"?
in code i didn't find any dependency .(references about twain.dll).so help me what i have to do ?As i have little knowledge of twain please help me(by email)
please ...
|
|
|
|
|
Yes TWAIN started out as a 16-bit API.
That would be on the famous 16-bit operating system (Windows) where it was used for scanning by that famous 16-bit image editor, Adobe Photoshop.
Pretty hard to find anybody who cares about those origins today, except students of technology history, and chest-pounding Apple fanboys.
I've been doing 32-bit TWAIN programming since 1996, and TWAIN has evolved far more, and is far more suitable for production/commercial scanning, than WIA.
WIA is great for digital cameras - it's the best vendor-independent digital camera API.
And it's simpler to code to than TWAIN (if your language is COM-aware), so it makes sense for small one-off projects to do simple scanning in VB or .NET, where just coming up to speed is a big part of the project effort, and you can't justify buying a commercial scanning library or component.
I think you'll find that in serious scanning software, TWAIN is almost universally supported, ISIS is fairly widely supported especially for 'high-end' applications, and WIA is explicitly supported only by a few consumer/small-office packages. Since all WIA scanners also appear as TWAIN devices thanks to a Microsoft-provided TWAIN-to-WIA bridge, the only reason for coding directly to WIA (once you support TWAIN) is to support those few scanners that don't have a native TWAIN driver AND that trigger certain long-standing bugs in the Microsoft TWAIN-to-WIA bridge.
spike _/\_ (Spike0xFF)
|
|
|
|
|
im newbies in C#.net , please help me on coding that i can save image into .pdf file .
thanks
ringku2k
|
|
|
|
|
Load you scanned image into ImagXpress and follow the below code. It should be fine.
Dim so As SaveOptions = New SaveOptions()
so.Format = ImageXFormat.Pdf
Dim pro As Processor = New Processor(ImagXpress)
pro.Image = ImageXView1.Image
pro.Crop(cropRect)
ImageXView1.Image.Save("C:\updated.pdf", so)
|
|
|
|
|
I was wondering if it would be possible to post an update with the changes you have made since the orignal post. Especially I would be interested on how to best implement the retrival of the CAP_FEEDERENABLED, CAP_FEEDERLOADED capabilities.
I can not seem to figure out how to do this.
thanks in advance
Mike
|
|
|
|
|
|
Hi Sir,
In my application i have used this twain application to scan documents.
It is working absolutely fine.
My Problem is how to detect blank page while scanning or after scanning,I need help on this issue sir,pls.......
I need help on how to detect blank page while scanning,I tried my level best to do it but failed to get results.
|
|
|
|
|
Program works great without any modification. When I try to add a new mdi child form and try to call the tw.select using a button control, nothing happens. tw.acquire scans the document but hangs up at the end of the scan. I think it has something to do with the imessagefilter but I just can't figure it out. I went through all the postings on this page. There were 2 similar problems posted but no solid replies. I have spent countless hours googling it. Please HELP.
I want to declare and call everything from the child form.
Great code. Thanx.
|
|
|
|
|
is it possible perform scanning using network scanner? how can i connect to network shared scanner?
|
|
|
|
|
Hi,
We have entered into the network scanning arena in a big way recently and here's why:
We have 18 branches all over the UK, and have a good policy of using thin client devices for all purposes we can possibly get away with; indeed more than 98% of all end users use a thin client terminal plugged into a Citrix cloud.
PC's are incumbersome, break, are prone to viruses, you can fill in the rest...
One area where PC's have been required is for scanning paper documents such as proof of deliveries, invoices etc.
To remove that requirement we have replaced the PC's with Axis 70U network scanning boxes. One end is an ethernet port, the other is a USB port. They cost approximately £400 and can work with just about any scanner. One big green button on top does it all!
I would recommend to give simplicity and cut out confusion, adopt these boxes or something equivalent. Super easy.
|
|
|
|
|
It took me about 3 hours to find out how to get a list of Epson scanner supported Twain commands so thought I'd add a reference here for all of you building on this project and using Epson scanners.
Register at www.epsondevelopers.com/sections[^] and download both the EPSON TWAIN Capabilities Reference Check List and Programming Guide for EPSON TWAIN. These documents are listed within the Programming Guide Download section.
|
|
|
|
|
I noticed when using the document feeder that it scanned and then aquired each document image at a time where as using the scanners own software it scanned through all the pages and then transferred from the buffer which was much better in performance.
To set it scan all the pages then read from the buffer use:
TwCapability capAutoScan = new TwCapability(TwCap.CAP_AUTOSCAN, 1, TwType.Bool);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capAutoScan);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
(you'll notice this is using an overload that takes the TwType)
and add the enum
CAP_AUTOSCAN = 0x1010
|
|
|
|
|
Hi sorry to bother i have added your code just above the "Dim guif As TwUserInterface = New TwUserInterface()" and i cant get it to work, and sorry just another question when you got yours to work does it do a continous scan or does it stop for a second on each page before it scans the new page thanks
|
|
|
|
|
Hi sorry me again i figured out what you meant the setting is for the actual scanner software to be continuous thanks
|
|
|
|
|
Hmm - the code you've placed this above is in VB where as the code I gave is in C#. The code needs to be placed in TwainLib.cs under the "public void Aquire". To make it easy I've added the whole of my copy of the void below:
public void Acquire()
{
TwRC rc;
CloseSrc();
if( appid.Id == IntPtr.Zero )
{
Init( hwnd );
if( appid.Id == IntPtr.Zero )
return;
}
rc = DSMident( appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds );
if( rc != TwRC.Success )
return;
TwCapability cap = new TwCapability( TwCap.XferCount, -1 );
rc = DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );
if( rc != TwRC.Success )
{
CloseSrc();
return;
}
TwCapability capDuplex = new TwCapability(TwCap.CAP_DUPLEXENABLED, 0, TwType.Bool);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capDuplex);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capResX = new TwCapability(TwCap.CAP_RESX, 150, TwType.Fix32);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capResX);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capResY = new TwCapability(TwCap.CAP_RESY, 150, TwType.Fix32);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capResY);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capPixelType = new TwCapability(TwCap.IPixelType, 0);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capPixelType);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capPaperSize = new TwCapability(TwCap.ICAP_SUPPORTEDSIZES, 1);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capPaperSize);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capAutoDeskew = new TwCapability(TwCap.ICAP_AUTOMATICDESKEW, 1, TwType.Bool);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capAutoDeskew);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capAutoScan = new TwCapability(TwCap.CAP_AUTOSCAN, 1, TwType.Bool);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capAutoScan);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capThreshold = new TwCapability(TwCap.ICAP_THRESHOLD, 100, TwType.Fix32 );
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capThreshold);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capBrightness = new TwCapability(TwCap.ICAP_BRIGHTNESS, 400, TwType.Fix32);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capBrightness);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capGamma = new TwCapability(TwCap.ICAP_GAMMA, 2, TwType.Fix32);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capGamma);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwCapability capHalfTones = new TwCapability(TwCap.ICAP_HALFTONES, "TextEnhancement Technology");
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capHalfTones);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
TwUserInterface guif = new TwUserInterface();
guif.ShowUI = 0;
guif.ModalUI = 1;
guif.ParentHand = hwnd;
rc = DSuserif( appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, guif );
if( rc != TwRC.Success )
{
CloseSrc();
return;
}
}
You then need to update the TwainDef.cs file and replace the "internal enum TwCap : short" with the following (the bits commented // DOESN'T WORK are just commands that my particular scanner wouldn't support):
internal enum TwCap : short
{
XferCount = 0x0001,
ICompression = 0x0100,
IPixelType = 0x0101,
IUnits = 0x0102,
IXferMech = 0x0103,
CAP_DUPLEXENABLED = 0x1013,
CAP_RESX = 0x1118,
CAP_RESY = 0x1119,
ICAP_SUPPORTEDSIZES = 0x1122,
ICAP_AUTOMATICDESKEW = 0x1151,
ICAP_AUTOMATICROTATE = 0x1152,
ICAP_AUTODISCARDBLANKPAGES = 0x1134,
ICAP_NOISEFILTER = 0x1148,
ICAP_AUTOBRIGHT = 0x1100,
CAP_AUTOSCAN = 0x1010,
ICAP_THRESHOLD = 0x1123,
ICAP_BRIGHTNESS = 0x1101,
ICAP_GAMMA = 0x1108,
ICAP_HALFTONES = 0x1109,
ICAP_PIXELFLAVOR = 0x111F
}
Then also in the TwainDef.cs near the bottom you'll find this:
public TwCapability(TwCap cap, string sval)
{
Cap = (short)cap;
ConType = (short)TwOn.One;
Handle = Twain.GlobalAlloc(0x42, 6);
IntPtr pv = Twain.GlobalLock(Handle);
Marshal.WriteInt16(pv, 0, (short)TwType.Str32);
Marshal.StringToHGlobalUni(sval);
Twain.GlobalUnlock(Handle);
}
Underneath this stick the following code in:
public TwCapability(TwCap cap, short sval, TwType TheType)
{
Cap = (short)cap;
ConType = (short)TwOn.One;
Handle = Twain.GlobalAlloc(0x42, 6);
IntPtr pv = Twain.GlobalLock(Handle);
if (TheType == TwType.Bool)
{
Marshal.WriteInt16(pv, 0, (short)TwType.Bool);
}
if (TheType == TwType.Fix32)
{
Marshal.WriteInt16(pv, 0, (short)TwType.Fix32);
}
Marshal.WriteInt32(pv, 2, (int)sval);
Twain.GlobalUnlock(Handle);
}
It should all work then
|
|
|
|
|
Have done all of this.
Autoscan didn't work - getting failure on line
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capAutoScan);
If autoscan capability code commented, all works good, except pauses for about a second between each list of paper.
Scanner: Fujitsu fi-5110c.
|
|
|
|
|
My scanner supports the TwCapability (ICAP_HALFTONES = 0x1109) = "TextEnhancement Technology".
So i've added into TwainLib.cs the following code:
TwCapability capHalfTones = new TwCapability(TwCap.ICAP_HALFTONES, "TextEnhancement Technology");
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capHalfTones);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
and created an overload in TwainDefs.cs:
public TwCapability(TwCap cap, string sval)
{
Cap = (short)cap;
ConType = (short)TwOn.One;
Handle = Twain.GlobalAlloc(0x42, 6);
IntPtr pv = Twain.GlobalLock(Handle);
Marshal.WriteInt16(pv, 0, (short)TwType.Str32);
Twain.GlobalUnlock(Handle);
}
My question is how to I use the Marshal object to write the string?
Many Thanks in advance
modified on Monday, September 21, 2009 7:07 AM
|
|
|
|
|