|
|
I'm still not getting it to work.
internal enum TwCap : short<br />
{<br />
XferCount = 0x0001,
ICompression = 0x0100,
IPixelType = 0x0101,<br />
IUnits = 0x0102,<br />
IXferMech = 0x0103,<br />
BITDEPTH = 0x112b,<br />
ICAP_IMAGEFILEFORMAT = 0x110c,<br />
ICAP_XRESOLUTION =0x1118,<br />
ICAP_YRESOLUTION =0x1119,<br />
ICAP_XNATIVERESOLUTION =0x1116,<br />
ICAP_YNATIVERESOLUTION =0x1117<br />
<br />
}
TwCapability capXRes = new TwCapability( TwCap.ICAP_XRESOLUTION , 300);<br />
rc = DScap( appid, srcds, TwDG.Control , TwDAT.Capability , TwMSG.Set , capXRes );<br />
if( rc != TwRC.Success )<br />
{<br />
CloseSrc();<br />
getStaus();<br />
return;<br />
}<br />
GetStatus it telling me the condition code is 11 TWCC_SEQERROR : DG DAT MSG out of expected sequence
public void getStaus(){<br />
TwRC rc = new TwRC();<br />
TwStatus tws = new TwStatus() ;<br />
rc = DSstatus(appid,srcds,TwDG.Control,TwDAT.Status,TwMSG.Get,tws);<br />
System.Windows.Forms.MessageBox.Show(tws.ConditionCode.ToString());<br />
return;<br />
}
Any Ideas???
|
|
|
|
|
Hi,
Finally managed to get the resolution changed on the Scanner, very simple really once you know what's happening. The clue is Resolutions that I'm using are DPI, so
First line should read
TwCapability capUnit = new TwCapability( TwCap.IUnits, 0 );
Set the units to inches, the rest follows.
|
|
|
|
|
Please can you explain what I must do to change the resoltution of scanning?
Thanks you very much,
Mosquets
|
|
|
|
|
Hey NetMaster,
Nice code, but how come the application only scans one page at a time?
How come when you scan in a number of pages (i set cap = -1 to get ADF running) that the scanner produces individual images? how would i go about specifying that i wanted one multipage document instead of 6 individual pages?
Is this a built-in feature to the code?
do i need to modify the original code?
Has anyone else noticed this?
Regards,
Max
Dublin
Ireland
|
|
|
|
|
MaxJam wrote:
Is this a built-in feature to the code?
No, instead of saving individual images you have to create multiframe TIFF file. This article should help you start:
http://www.codeproject.com/csharp/TiffManager.asp
MaxJam wrote:
do i need to modify the original code?
Original code of what? You mean this sample application? Of course...
|
|
|
|
|
i am working on a document management system..
which will be developed using VB.NET and ASP.NET.
THe VB application will first scan the documents and add the details on the sam epage the images should be stored as the document code name .gif/jpg and also th eimages shoul dbe optimised..
can anyone help me with
1) finding an dll which i can use to scan it thorugh my application.
2) image optimiser dll which would act on it and optimise it as per the requirement.
an immidiate response would be a life saver..
Mansoor Baig
Cyber Link
Saudi Arabia
mansoor@mansoorbaig.com
|
|
|
|
|
First of all lemme thank the developer. You're awesome dude!
Now, Herez my question. How do I scan multiple pages using the code? I would like to specify if I am scanning one page, or more, or specific number of pages, is this possible ?
If at first you don't succeed, then skydiving isn't for you.
|
|
|
|
|
Respected Sir,
I want to change DPI of scanning device. Default DPI is 1200 which results too much processing overhead.
How can I change DPI of a scanner.
using TWAIN API.
Regards
Ahmad Javed
|
|
|
|
|
Following method will change the DPI settings:
---------------------------------------------
internal void ChangeImageQuality(int val)
{
try
{
// following lines will set the unit of measure as pixel.
mobjTwain.Capability = PegasusImaging.WinForms.TwainPro4.tagenumCapability.TWCAP_UNITS;
if (mobjTwain.CapSupported == true)
{
mobjTwain.CapTypeOut = PegasusImaging.WinForms.TwainPro4.tagenumCapType.TWCAP_ONEVALUE;
mobjTwain.CapValueOut = 5;
mobjTwain.SetCapOut();
}
// Change the XResolution.
mobjTwain.Capability = PegasusImaging.WinForms.TwainPro4.tagenumCapability.TWCAP_XRESOLUTION;
if (mobjTwain.CapSupported == true)
{
mobjTwain.CapTypeOut = PegasusImaging.WinForms.TwainPro4.tagenumCapType.TWCAP_ONEVALUE;
mobjTwain.CapValueOut = val;
mobjTwain.SetCapOut();
}
// Change the YResolution
mobjTwain.Capability = PegasusImaging.WinForms.TwainPro4.tagenumCapability.TWCAP_YRESOLUTION;
if (mobjTwain.CapSupported == true)
{
mobjTwain.CapTypeOut = PegasusImaging.WinForms.TwainPro4.tagenumCapType.TWCAP_ONEVALUE;
mobjTwain.CapValueOut = val;
mobjTwain.SetCapOut();
}
}
catch (Exception ex)
{
this.ThrowException(ex);
}
}
|
|
|
|
|
Hi, I will really appreciate if you can help me…
I was wondering if there is a possible way to use twain source to take snapshots (every 200miliseconds) with a webcam? Or how difficult it would be..
I saw that twain has an interface to take picture with the webcam, but I don’t know if it is configurable to take snapshots within an interval time.
Thanks so much
Regards,
|
|
|
|
|
Hello, programmers!
Can anyone show me the way, how i can get image from scaner from client machine and upload it onto server, using asp.net!
Specifically i am interested in: how to upload Image on server, how to use above mentioned code in web, which does not supports message-pools?
I will be glad to receive some example code or advice!
You can also send solutions on my email: AGorbushkin@gse.ge
Thanks in advance!
|
|
|
|
|
I would like to save the image scanned to a Stream so i can use it internally.
I have been searching and found a function called "GdipSaveImageToStream" which allows saving to a stream, but i have no idea how to make this call from c#. It uses a IStream parameter and i don’t know how i must configure the DLLImport. Can somebody please help me?
Tnx
chsfly
|
|
|
|
|
I figured out an easier way of doing this than GdipSaveImageToStream. Create a bitmap and get the Graphics dc from it.
Bitmap me = new Bitmap(bmprect.Width, bmprect.Height);
Graphics g = Graphics.FromImage(me);
IntPtr hdc = g.GetHdc();
SetDIBitsToDevice(hdc, 0, 0, bmprect.Width, bmprect.Height,
0, 0, 0, bmprect.Height, pixptr, bmpptr, 0);
g.ReleaseHdc(hdc);
The image is now in the bitmap for you to save or do whatever!;)
|
|
|
|
|
Concerning the code to create the bitmap. Where are you placing it? Should it go in the PicForm of the sample or does it need to go in the MainForm? New to this graphics stuff so I am looking for a little guidence......
Thanks, TD
|
|
|
|
|
thank you very much for above code
|
|
|
|
|
Dim oStream As IStream
CreateStreamOnHGlobal(Nothing, True, oStream)
'Dim oStream As New MemoryStream
st = GdipSaveImageToStream(img, oStream, clsid, IntPtr.Zero)
oStream.Seek(Nothing, StreamSeekType.STREAM_SEEK_END, curMax) ' get the size of the stream
oStream.Seek(Nothing, StreamSeekType.STREAM_SEEK_SET, Nothing) ' return to the beginning
Dim bBmpBits() As Byte
ReDim bBmpBits(curMax(0).QuadPart - 1)
oStream.Read(bBmpBits, curMax(0).QuadPart, lBytesRead) ' note that lBytesRead could overflow, please fix this if you're reading more than 2 Gigs :P
Dim fs As New FileStream("c:\1.tif", FileMode.Create)
Dim os As New System.IO.BinaryWriter(fs)
os.Write(bBmpBits)
|
|
|
|
|
Does anyone know how to use GdipSaveImageToStream for this project? Please, I need it urgently.
|
|
|
|
|
I figured out an easier way of doing this than GdipSaveImageToStream. Create a bitmap and get the Graphics dc from it.
Bitmap me = new Bitmap(bmprect.Width, bmprect.Height);
Graphics g = Graphics.FromImage(me);
IntPtr hdc = g.GetHdc();
SetDIBitsToDevice(hdc, 0, 0, bmprect.Width, bmprect.Height,
0, 0, 0, bmprect.Height, pixptr, bmpptr, 0);
g.ReleaseHdc(hdc);
The image is now in the bitmap for you to save or do whatever!
|
|
|
|
|
I want to know about some DLL that I can use for both Scanner Image Acquiring and Fax through Fax Modem. What do i need to do???
Please reply and tell some location of DLL
regards
Hammad
Hammad Aslma kHan
Graduate Software Engineer
UET Lahore, Pakistan
|
|
|
|
|
Hi
I am currently using this solution to scan from an Fujitsu 4340c scanner that has Automatic Document Feeder but realise this can only retrive a single image from the scanner. I need to be able to retrieve multiply scanned image documents. What modifications do I need to make to this code.
Thank you
Murpheux
|
|
|
|
|
Here comes the great scanner having enemies like above and me.
all other scanners are ok but this one is the biggest block in makin my one of the best application successful.
please help netmaster
Jwalant Soneji (BE IT)
Mobile: +91 9969059127
http://jnsoneji.spaces.live.com
http://jnsoneji.blogspot.com
|
|
|
|
|
in this code i can disable the interface that come from driver,
and put parameter of scanning myself?
matanya2004zx-7
|
|
|
|
|
Try this:
TwUserInterface guif = new TwUserInterface();<br />
guif.ShowUI = 0;
guif.ModalUI = 0;
guif.ParentHand = IntPtr.Zero ;
rc = DSuserif( appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, guif );<br />
if( rc != TwRC.Success )<br />
{<br />
CloseSrc();<br />
return;<br />
}
It worked for me.
|
|
|
|
|
In the following code I get an error attempting to retrieve the property (which in my calling code is TwCap.CAP_FEEDERENABLED and it's, ok, a boolean rather than the example shown, TwCap.XferCount, a TW_INT16). This is not the biggest shock I've had today.
internal object GetProp( TwCap cap)
{
TwRC rc;
rc = DSMident( appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds );
if( rc != TwRC.Success )
{
return null;
}
TwCapability tcap = new TwCapability( cap, (short) TwOn.One );
rc = DScap( appid, srcds, TwDG.Image, TwDAT.Capability, TwMSG.Get, tcap );
if( rc != TwRC.Success )
{
TwainLib.TwStatus dsmstat = new TwStatus();
rc = DSMstatus( appid, IntPtr.Zero, TwDG.Control, TwDAT.Status, TwMSG.Get, dsmstat );
Console.WriteLine( dsmstat.ConditionCode );
return null;
}
object o = tcap.Cap;
return o;
}
So I want to retrieve the condition code to help understand WHY it failed. I can execute the get-status request, but the condition code is 0. I'd expect something like TWCC_BADVALUE or TWCC_CAPUNSUPPORTED.
So the question is, "Why don't I get a non-zero condition code?"
I have read enough to be dangerous. For example I notice that the capability information is in a class with explicit marshalling etc. whereas the status information is not. I ASSUME (and we know what that does) that this is because the source allocates the storage for the get capability and uses supplied storage for status. I just don't know whether this bears any resemblence to reality.
Thanks for any comments.
Ramsey Schaffnit
|
|
|
|
|