|
|
Comments and Discussions
|
|
 |

|
many thanks, under testing
|
|
|
|

|
HI All
How can i scan multi pages? Please help me.
|
|
|
|

|
Hi
when i'm scanning on samsung-scx-483x 5x3x scanner not getting full page even i set Page type-A4 and 300dpi, it's cutting off at the bottom not scanning full Page...
|
|
|
|

|
Hi guys.
It works great in Windows XP whereas in Win 7 64 bit it throws an error below.
Unable to load DLL 'twain_32.dll': The device is not ready. (Exception from HRESULT: 0x80070015)
Please help me guys. That will be really appreciated.
Thanks,
Raja.S
|
|
|
|

|
i want to set image color not blackandwhite
and set brightness and contrast ? how ?
|
|
|
|

|
hi i open twaingui_src project with visual studio 2012 and when i build it dot give me any error but when i run it gave this error error is in this line : <pre lang="c#">TwRC rc = DSMparent( appid, IntPtr.Zero, TwDG.Control, TwDAT.Parent, TwMSG.OpenDSM, ref hwndp );</pre> <a href=""><a href="http://s2.picofile.com/file/7726514080/Scanner_error.jpg">http://s2.picofile.com/file/7726514080/Scanner_error.jpg</a>[<a href="http://s2.picofile.com/file/7726514080/Scanner_error.jpg" target="_blank" title="New Window">^</a>]</a> Please help me. Thanks
|
|
|
|

|
bool IMessageFilter.PreFilterMessage( ref Message m ) { TwainCommand cmd = tw.PassMessage( ref m ); if( cmd == TwainCommand.Not ) return false; switch( cmd ) { case TwainCommand.CloseRequest: { EndingScan(); tw.CloseSrc(); break; } case TwainCommand.CloseOk: { EndingScan(); tw.CloseSrc(); break; } case TwainCommand.DeviceEvent: { break; } case TwainCommand.TransferReady: { System.Collections.ArrayList pics = tw.TransferPictures(); EndingScan(); tw.CloseSrc(); picnumber++; for (int i = 0; i < pics.Count; i++) { IntPtr img = (IntPtr)pics[i]; Bitmap bmp = Bitmap.FromHbitmap(img); pictureBox1.Image = bmp; // PicForm newpic = new PicForm( img ); // newpic.MdiParent = this; // int picnum = i + 1; // newpic.Text = "ScanPass" + picnumber.ToString() + "_Pic" + picnum.ToString(); // newpic.Show(); } break; } } return true; } The program runs at Bitmap bmp = Bitmap.FromHbitmap(img); Error: GDI + generic error occurred.
|
|
|
|

|
The "twaingui_demo.zip" is damaged?
|
|
|
|

|
Hello,
The article works greatly,
But i have faced a problem on win7 64bit i need to know if there is solution for this issue ?
If there is solution then what is it ?
The exception at win7 64bit :
"
System.BadImageFormatException : An attempt was made to load a program with an incorrectformat(Exceptio from HRESULT:0x8007000B)
"
Failed on the following line :
DSMparent(appid, IntPtr.Zero, TwDG.Control, TwDAT.Parent, TwMSG.OpenDSM, ref hwndp);
Thnx,
khalil
|
|
|
|

|
yo tenia el mismo problema lo solucione asi.
compile my proyecto con plataforma (x86). Generar --> Administrador de Configuracion.... y en la opcion de "plataforma de soluciones activas" seleccione "nueva" y (x86), aceptar, y aceptar, lo compile y lo probe y funciono
|
|
|
|

|
Is it possible to use it in an asp.net application?
Thanks a lot in advance,
Kalpana Volety
PDF Tools Online
|
|
|
|

|
Hi all ,
I am a .net developer , i have got an issue with WIA driver. I am able to scan single page with WIA driver ,however I am not able to scann multiple pages with WIA driver.
I have gone throw the Twain software site they told that this code will be work for twain and WIA drivers
Can you give me the suggestion please?
thanks
|
|
|
|

|
You need to change the capability to -1(for muftipage) in your Acquire method.
TwCapability cap = new TwCapability( TwCap.XferCount, -1 );
rc = DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );
if( rc != TwRC.Success )
{
CloseSrc();
return;
}
fsdfsdfsdfsdfsdfsdf
|
|
|
|

|
i tried in various mode to set , but I always get an error
i see in the source needless to set the types bool, because?
could this be the problem must be set differently and how ?
thanks
|
|
|
|

|
Thank you for the great post.
I want to know how to stop the scanning in between during a multipage scan.
|
|
|
|

|
Hi,
can you scanning multi page ? i can't it (
|
|
|
|

|
"short of memory" after 16 pages in 600DPI.
how can i fix that?
|
|
|
|

|
you need to release the memory after every page you scan. and dispose the image
fsdfsdfsdfsdfsdfsdf
|
|
|
|

|
hi thank you for great post. how can i change to scan mulltipage?
|
|
|
|

|
You need to change the capability to -1(for muftipage) in your Acquire method.
TwCapability cap = new TwCapability( TwCap.XferCount, -1 );
rc = DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );
if( rc != TwRC.Success )
{
CloseSrc();
return;
}
fsdfsdfsdfsdfsdfsdf
|
|
|
|

|
thank you for the great post.i read your post and i downloaded your code ,i want to know how can i change the twain to scan multipage ,because in my company we need to scan multipage? thank you
|
|
|
|

|
How can i it work with multi page scanner?
Now it scan page by page.
|
|
|
|

|
I am using .net twain image scanner program. but i am facing issue that when i give command of acquisition, it scan document successfully, but when i save to exit, this program does not exit to go back from where acquisition command given, kindly guide me about this. Thanks
|
|
|
|

|
My problem is still waiting for positive response from this forum, If any one have experience then kindly guide me. Thanks
|
|
|
|

|
I did not understand you well. When you scan a paper you get picture in new MDI Child form. Then you can save it using File/Save as.. Then you can exit application. What is not like this at your side?
|
|
|
|

|
we want to one MDI child for scanning multi page and we want to know how we can save its a output file.this default code; when we scan a page doing per page per output file. (
|
|
|
|
|

|
Hi,
Image always stored at 96dpi. I am not able to find the solution for that.
|
|
|
|

|
Hello guys, i am using this lib with vb.net winform application. it works fine when i try to scan pages using my scanner. But after that when i try to scan images using this lib it throws the Out of memory exception. It works when i close my app then run again. I came on conclusion that this lib stores the scanned images in memory and not free the memory after transfering pictures. i study the code and find that there is a function of GlobleFree which is not run after acquire or transferpictures I tried to change some code but no luck. Is anyone having same issues or handled the same situation then please help me.
Thanking You,
Jaydeep Jadav
|
|
|
|

|
Dear Jaydeep,
I am Suffering from the same issue but little Diffident.
Have you reach to some Solution for OUT of memory Exception?
Because when I am scanning 100-110 pages it works Smoothly but Some time it gets Out of Memory Exception when I restart app it Again run Smoothly
Can you please Suggest
|
|
|
|

|
I fixed it by forcing GC to collect garbage after every transfer of picture.
I used
GC.Finalize()
Thanks and Regards,
Jaydeep Jadav
|
|
|
|

|
Please help on this .. when I run the program I am able to select the scanner but when I click Acquire image it gives me exception as below
LoaderLock was detected
Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
I am using Visual Studio 2008, is it causing the problem..
Thanks & Regards
Leena
|
|
|
|

|
I have the same problem. Did you find any solutions? Thanks.
modified 11 Jul '12 - 8:22.
|
|
|
|

|
Great article. Thank you very much.
But I want to enable duplex scan using this code.
Can anyone help me.
Thank you.
|
|
|
|

|
I tried many ways to hide progress indicator when ShowuI=False; But not working. Please help me.
|
|
|
|

|
Hi,
When I downloaded the source code and run debug mode on the 64 bits machine, it throws an error when calling the Init() method. it's complaining invalid format ... please advise
asda
|
|
|
|

|
You might check your project output - and make sure it is specify 32 bit code only...
|
|
|
|

|
where we check 32 bit code in vs ?
|
|
|
|

|
hi,
i have a question how set Flatbed of Feader.
in twaindef
CAPFEnabled = 0x1002
in twainlib in acquire method
TwCapability capF = new TwCapability(TwCap.CAPFEnabled, 1);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Get, capF);
if (rc != TwRC.Success)
{
Console.WriteLine("No feeder");
}
it's correct???
|
|
|
|

|
please i want to ask i can user that classes in asp.net webform
|
|
|
|

|
The code opens a window to select the parameters I want to redefine
the resolution the area of scan etc
Can you send the code
golan87@walla.co.il
Thanks
|
|
|
|

|
Provide the dll used for development, please.
|
|
|
|

|
It's posible to change scaning variable from code?
|
|
|
|

|
TwUserInterface guif = new TwUserInterface();
guif.ShowUI = 0;
guif.ModalUI = 1;
|
|
|
|

|
if scanner is not connected then that freeze whole application so is there any method to check whether any scanner is connected before calling of Acquire?
plz help...
|
|
|
|

|
Hi, thanks for app really very usefull but how can i show scanned image to picturebox?
|
|
|
|

|
bool IMessageFilter.PreFilterMessage( ref Message m )
{
TwainCommand cmd = tw.PassMessage( ref m );
if( cmd == TwainCommand.Not )
return false;
switch( cmd )
{
case TwainCommand.CloseRequest:
{
EndingScan();
tw.CloseSrc();
break;
}
case TwainCommand.CloseOk:
{
EndingScan();
tw.CloseSrc();
break;
}
case TwainCommand.DeviceEvent:
{
break;
}
case TwainCommand.TransferReady:
{
ArrayList pics = tw.TransferPictures();
EndingScan();
tw.CloseSrc();
picnumber++;
MessageBox.Show("Number of Scanned Docs: " + pics.Count.ToString());
for( int i = 0; i < pics.Count; i++ )
{
IntPtr img = (IntPtr) pics[ i ];
this.pictureBox1.Image = TwainHelper.ImageFromIntPtr(img);
}
break;
}
}
return true;
}
----------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
namespace TwainGui
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public class BITMAPINFOHEADER
{
public uint biSize;
public int biWidth;
public int biHeight;
public ushort biPlanes;
public ushort biBitCount;
public uint biCompression;
public uint biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public uint biClrUsed;
public uint biClrImportant;
public void Init() { this.biSize = (uint)Marshal.SizeOf(this); }
}
class TwainHelper
{
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();
for (int j = 0; j < encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
public static Image ImageFromIntPtr(IntPtr imagePtr)
{
BITMAPINFOHEADER bmpInfoHeader = new BITMAPINFOHEADER();
IntPtr bmpptr = GlobalLock(imagePtr);
IntPtr pixptr = GetPixelInfo(bmpptr, bmpInfoHeader);
Bitmap bitmap = new Bitmap(bmpInfoHeader.biWidth, bmpInfoHeader.biHeight);
Graphics graphics = Graphics.FromImage(bitmap);
IntPtr hdc = graphics.GetHdc();
SetDIBitsToDevice(hdc, 0, 0, bmpInfoHeader.biWidth, bmpInfoHeader.biHeight,
0, 0, 0, bmpInfoHeader.biHeight, pixptr, bmpptr, 0);
graphics.ReleaseHdc(hdc);
return (Image)bitmap;
}
private static IntPtr GetPixelInfo(IntPtr bmpptr, BITMAPINFOHEADER bmpInfoHeader)
{
Marshal.PtrToStructure(bmpptr, bmpInfoHeader);
if (bmpInfoHeader.biSizeImage == 0)
bmpInfoHeader.biSizeImage = (uint)(((((uint)bmpInfoHeader.biWidth * (uint)bmpInfoHeader.biBitCount) + 31) & ~31) >> 3) * (uint)bmpInfoHeader.biHeight;
int p = (int)bmpInfoHeader.biClrUsed;
if ((p == 0) && (bmpInfoHeader.biBitCount <= 8))
p = 1 << bmpInfoHeader.biBitCount;
p = (p * 4) + (int)bmpInfoHeader.biSize + (int)bmpptr;
return (IntPtr)p;
}
[DllImport("gdi32.dll", ExactSpelling = true)]
internal static extern int SetDIBitsToDevice(IntPtr hdc, int xdst, int ydst,
int width, int height, int xsrc, int ysrc, int start, int lines,
IntPtr bitsptr, IntPtr bmiptr, int color);
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GlobalLock(IntPtr handle);
[DllImport("gdiplus.dll", ExactSpelling = true)]
internal static extern int GdipCreateBitmapFromGdiDib(IntPtr bminfo, IntPtr pixdat, out IntPtr image);
}
}
|
|
|
|

|
The binary "TestTwainLib.exe" run Ok, but the source show compilation error "LoaderLock" in the:
rc = DSM_Ident(appid, IntPtr.Zero, TwDG.TwDG_Control, TwDAT.TwDAT_Identity, TwMSG.TwMSG_CloseDS, SelectedDataSource)
Whats Happen?
|
|
|
|

|
I was getting that until i went into Debug, Exceptions, Managed Debugging Assistants, and turned off LoaderLock exceptions.
|
|
|
|

|
Change the platform target to x86. That should fix this issue.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Using TWAIN API to scan images
| Type | Article |
| Licence | Public Domain |
| First Posted | 16 Sep 2001 |
| Views | 2,231,175 |
| Bookmarked | 374 times |
|
|