|
Hello,
I used the code from the example. My windows form application can scan directly inside the code and save images to local path successfully, but I've a major problem about this scanning process. I have to set pageSize,dpi,scanning side,deskew vs. settings inside the code.
I read all the messages at this forum but I couldn't figure out how to set these settings. For example someone said that we can add the code below for the resolution setting.
I added "IXResolution=0x1118" under the TwCap and also created a overload for TwCapability. When I try this code or similar codes like this, I am getting an failure from "rc". Also there is a capability order for these settings but I couldn't figure out. Can anyone send me a working code with these settings ?
TwCapability capResX = new TwCapability(TwCap.IXResolution, 100, TwType.Fix32);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capResX);
if (rc != TwRC.Success)
{
CloseSrc();
MessageBox.Show("IXResolution");
return;
}
|
|
|
|
|
Can you Please post Your Scan and save image code to localpath directly.
I am searching from last few days .please post this code to tiru.jogu123@yahoo.com
|
|
|
|
|
Hi,
Is possible compile this on x64? I know that it throw exception BadImageFormatException because twain_32.dll is only for x86. But what if I use TWAINDSM.dll? I try it. If I compiled it on x86, everything is ok, but it I compiled it on x64 it doesn't throw any exception but it doesn't work too.
I need compile my application on x64. Any idea?
|
|
|
|
|
Hi,
When I just download the .exe from this article it works fine. But when I compile the source code, it compiles fine, but when I try to run it stops at the following line (ln 59 TwainLib.cs):
TwRC rc = DSMparent( appid, IntPtr.Zero, TwDG.Control, TwDAT.Parent, TwMSG.OpenDSM, ref hwndp );
And the output shows:
The thread 'vshost.LoadReference' (0x1730) has exited with code 0 (0x0).
'TwainGui.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Users\xxxxx\Desktop\twaingui_src\TwainGui\bin\Debug\TwainGui.exe', Symbols loaded.
A first chance exception of type 'System.BadImageFormatException' occurred in TwainGui.exe
'TwainGui.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[2472] TwainGui.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[2472] TwainGui.vshost.exe: Managed (v2.0.50727)' has exited with code 0 (0x0).
It is working on Windows 7 32 bit, I can compile and run.
I tryed to download and install both 32 and 64 bits versions found in www.twain.org, compiled only to 32 bit, tryed to change the reference to twain_32.dll to twain.dll from dllimport, since both dlls exists, but it still doesn´t work.
Thank you,
Edgar
|
|
|
|
|
Change the setting of your project and set the platform target as 'x86'.
Michela
|
|
|
|
|
Hello everyone:
I want to show UI only,do not transfer the image to program.
I try that:
TwUserInterface guif = new TwUserInterface();
guif.ShowUI = 1;
guif.ModalUI = 0;
guif.ParentHand = hwnd;
rc = DSuserif(appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDSUIOnly, guif);
but it always returns failure.
I want to know why? does driver not support?or other problem?
how can I do?
thank you
|
|
|
|
|
I use your code but I want to insert imagelist ....
case TwainCommand.TransferReady:
{
ArrayList pics = tw.TransferPictures();
EndingScan();
tw.CloseSrc();
picnumber++;
for( int i = 0; i < pics.Count; i++ )
{
IntPtr img = (IntPtr) pics[ i ];
PicForm newpic = new PicForm( img );
newpic.MdiParent = this;
int picnum = i + 1;
imageList1.ImageSize= new Size(200, 200);
newpic.Text = "ScanPass" + picnumber.ToString() + "_Pic" + picnum.ToString();
newpic.Show();
}
break;
}
in that peace of code I want to create from the pics = tw.TransferPictures(); an ImageList , but I dnt know how to convert using the GDI library from the IntPtr to Bitmap ...
please help me....
|
|
|
|
|
Hello every one,
I need to get duplex capability i used these couple of methods but i get "Success" with canon 2200 and Failure with hp laserjet1522 (its actually supports duplex scanning ) so i couldn't identified problem that is it device dependent or what ..please help me what should i do...?
//for duplex scanning capability
public TwCapability(TwCap cap, short sval, bool blnType)
{
Cap = (short)cap;
ConType = (short)TwOn.One;
Handle = Twain.GlobalAlloc(0x42, 6);
IntPtr pv = Twain.GlobalLock(Handle);
Marshal.WriteInt16(pv, 0, (short)TwType.Bool);
Marshal.WriteInt32(pv, 2, (int)sval);
//Marshal.WriteInt16(pv, 2, (int)sval);
Twain.GlobalUnlock(Handle);
}
//This is for duplex setting
TwCapability capDuplex = new TwCapability(TwCap.CAP_DUPLEXENABLED, 0, true);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capDuplex);
if (rc != TwRC.Success)
{
CloseSrc();
return;
}
//For capability
public TwCapability( TwCap cap, short sval )
{
Cap = (short) cap;
ConType = (short) TwOn.One;
Handle = Twain.GlobalAlloc( 0x42, 6 );
IntPtr pv = Twain.GlobalLock( Handle );
Marshal.WriteInt16(pv, 0, (short)TwType.Int16);//original
//Marshal.WriteInt16(pv, 0, (short)TwType.Fix32);
Marshal.WriteInt32( pv, 2, (int) sval );
Twain.GlobalUnlock( Handle );
}
please anybody help...
|
|
|
|
|
Hello ,
I have develop an application using twain API and create an application in both platform 32 and 64 bit machine .
but when i installed 64bit exe it gives some error so i have tried 32 exe and its working but there is some problem with ShowUI ,if i set it to true application hang but if i dnt try to open showUI its working. what is the problem what i need to do to work my application in both platform ?
please any help me . i have big issue on this topic ..
|
|
|
|
|
Hi,
i think you have to compile your app for 32-bit. A 64-bit app can't use a 32-bit dll.
Michael
|
|
|
|
|
hello ,,thanks for reply but i did it ..but problem is not about platform but shoUI not working ..
|
|
|
|
|
Trying this on xerox scanner
With ADf, say I am scanning 1..n pages, with xfercount set to -1 and using adf but disabling the twain gui from scanner, only page 1 is seen, the rest of the pages in the viewer show up as garbage.
Any ideas?
|
|
|
|
|
hi, i need to scan an image then show it in picturebox but this project is professional then i cant change it, i worked on it but i couldnt
please put easier sample for beginners
modified on Tuesday, September 14, 2010 4:51 PM
|
|
|
|
|
error in memory with framework 2 and win 7 professional
|
|
|
|
|
Hi there. I am just having the same exact problem. Have you manage to solve it?
|
|
|
|
|
Hi,
how can i add twain ui into my applicaiton. I want to open it in my applicaiton panel.
|
|
|
|
|
Hi,
My program is working good with ICAP_XFERMETH = TWSX_NATIVe and Duplex = TRUE.
My problem is that I need to acquire more then 300 documents and my memory always is full.
How do I change to save the images automaticaly to a file?
Sorry my bad english and thank you advice.
|
|
|
|
|
I need Twain ActiveX thats not required UI for Source Selection and Other
Just direct scan at one Click
|
|
|
|
|
How can i read the image directly into a picture box using vb.net
|
|
|
|
|
Hi, i want to take images by time from my camera automatically, for example every 5 seconds, but i dont know how to send take snapshot message to the twain interface of my camera ! is it possible to send messages from my application to cameras twain interface or do i have to write that interface myself ? And How ? Thank you
|
|
|
|
|
Hi,
I have been looking through the twain spec and am not too sure how to return a lets of all possible values for a capability.
Using the code below I can get the currnent value:
Dim XRes As TwCapability = New TwCapability(TwCap.ICAP_XRESOLUTION, 0, TwType.Fix32)
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.GetCurrent, XRes)
If rc = TwRC.Success Then
Dim inptr As IntPtr = DirectCast(GlobalLock(XRes.Handle), IntPtr)
Dim scanvalue As Integer = Marshal.ReadInt32(inptr, 2)
GlobalUnlock(cap.Handle)
GlobalFree(cap.Handle)
MsgBox(scanvalue)
End If
What I want to be able to do is get the range of values that are possible. I just am unsure how to use the specification to make the datatypes and do the conversions.
If anyone could help I would be extremely appreciated.
James
ps. I dont mind C# code as I can work through that to understand.
|
|
|
|
|
Hallo,
can you say me, how is the syntax for AUTODISCARDBLANKPAGES?
The code:
Dim capDiscardBlank As TwCapability = New TwCapability(TwCap.ICAP_AUTODISCARDBLANKPAGES, 1)
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capDiscardBlank)
has no effect. By using the original driver (guif.ShowUI = 1), the empty sides are removed. My scanner is a CANON DR-2580C document scanner.
There is in the meantime a possibility to makes PDFs?
My code:
Dim img As IntPtr = IntPtr.Zero
Dim st As Integer = GdipCreateBitmapFromGdiDib(bminfo, pixdat, img)
If (st <> 0) Or (Equals(img, IntPtr.Zero)) Then
Return False
End If
picname = "c:\temp\" + picname
st = GdipSaveImageToFile(img, picname, clsid, IntPtr.Zero)
GdipDisposeImage(img)
Return st = 0
Thanks for an answer .
Norbert
|
|
|
|
|
Yeah, i wanna know too about this topic. Urgent!!
|
|
|
|
|
I am vs 2008 and win 7 64 bit the compiled program works correctly but the source code shows the BadImageFormat Exception. Please Help
|
|
|
|
|
Which image format uses you?
Did you see that?
If Not GetCodecClsid(picname, clsid) Then
MessageBox.Show("Unbekanntes Format " + Path.GetExtension(picname), _
"Image Codec", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return False
End If
And that:
Private Shared Function GetCodecClsid(ByVal filename As String, ByRef clsid As Guid) As Boolean
clsid = Guid.Empty
Dim ext As String = Path.GetExtension(filename)
If IsNothing(ext) Then
Return False
End If
ext = "*" + ext.ToUpper()
Dim codec As ImageCodecInfo
For Each codec In codecs
If (codec.FilenameExtension.IndexOf(ext) >= 0) Then
clsid = codec.Clsid
Return True
End If
Next
Return False
End Function
|
|
|
|
|