tmyroadctfig / twaindotnet Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
hi!
thanks for the excellent library!
how do i set TwainDotNet to scan 1 bit depth tif images?
at the moment even if i set the color to B&W, it still saves at 24bit
thank you very much!
p.s. im using TDN in WPF, if it matters.
thanks.
I try to get and set gamma capability for my DS.
I use:
int gamma = 10;
var cap = new Capability(Capabilities.Gamma, TwainType.Fix32, _applicationId, SourceId);
var basicCapResult = cap.GetBasicValueCurrent();
if (gamma != basicCapResult.Int32Value)
Capability.SetBasicCapability(Capabilities.Gamma, gamma, TwainType.Fix32, _applicationId, SourceId);
The value of current capability is always 858980354
, and setting the value will fail. Twain32Native.DsCapability()
throws an exception at protected void SetValue<T>(T value)
in Capability.cs.
Any suggestions?
Hi,
In working with an Epson S-9000 scanner to scan banking checks we've run into a problem wherein after scanning ~300 or so, we'll get an exception (Parameter is not valid.) thrown from BitmapRender.RenderToBitmap on the sixth line: IntPtr hdc = graphics.GetHdc();
This would seem to indicate that the memory is not being collected over time but it looks like all of the appropriate precautions to dispose of the BitmapRender and the associated memory from the device were taken. As I'm not familiar with the twain_32 dll I was hoping you could provide some more assistance.
Kevin W
Error: Unsupported capability FeederEnabled
how to solve this problem?
Thanks.
With some canon scanners, it only scans about 1/4th of the entire flatbed. That 1/4th area is blown up and takes up the entire page. I tried the test Wpf App that comes with this project and it has the same issue.
I'm using Canon PIXMA MP 280, BTW. I have a lot of scanners to test with. It's just the canon scanner that has this issue.
Example : (this is just the bottom right 1/4th of the page that is getting scanned)
hi i m using hp scan-jet 2400 and hp scan software user interface, to check image processing. but after scan complete it will manually click to finish button and transfer image from hp scan UI to Twaindotnet app. there any way to automatically close hp scan UI after scan complete and transfer image to Twaindotnet.
Any help in this Solution is greatly appreciated.
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Expected proper scanning with 11.5-inch height
This happens when AreaSetting is added in the scan setting. Without AreaSetting it works fine.
Hi,
I m trying to set the capability but it doesn't work, maybe a limitation of twain32.dll used by the lib ?
with the twain tool, if i do :
DG_CONTROL DAT_CAPABILITY MSG_SET
with
0xF00C,TWON_ONEVALUE,TWTY_BOOL,1
it works.
I tried with the lib but no luck so far even with changing the struct from short to long because 0XF00C is not a short number...
thanx for any guidance...
Hi,
I faced an issue in "TestAppWpf", Saying "error opening data source". Following are the steps to reproduce the issue:
If user says cancel in any stage, it should cancel the job and should be ready to re scan.
Please let me know if there is any fix for this.
Thanks and Regards,
Saira
Hi!
I scan images with 8bit grayscale, this is the setting in Twain UI.
But in my code after each page
args.Image.Pixelformat is set to Format32bppArgb.
How can i change this Pixelformat?
Greetings,
Ulrich
Hi! Is there a way to reset a scanner if it hangs? I have tested a EPSON Workforce 7500DS with twaindotnet, sometimes the scanner freezes after large scanjobs(25 pages) and it takes a long time to get it working again. Turning the scanner off / on doesn't help. Turning off the PC doesn't help.
Waiting for a long time (10-30min) helps....
When I set the scanner setting of 'Automatic Rotate', the image(s) won't scan, and it gives an error, stating that 'Unsupported capability, Automaticrotate'. The error is thrown from the Capability class, in the GetBasicValue() method.
When the error occurs:
The parameters of the one value field are TwainType: Bool; Value: 0;
The twainCapability is 'TwainDotNet.TwainNative.Capabilities.Automaticrotate'
The conditionCode is 'TwainDotNet.TwainNative.ConditionCode.CapabilityUnsupported'
The other scanner settings, such as 'Use ADF', 'Use UI', and 'B & W' are working successfully.
The scanner is a 'Canon DR-G1130 TWAIN 1.123 (32-32)'.
Does anyone have thoughts on troubleshooting steps or on what may be the cause of the issue?
Hi everyone,
I m working with Fujitsu fi-65F on a C# project. I want to get image with max DPI (600).
how to do that ?
I'm using an officejet J4660 all-in -one from HP everything works fine, but at this time I have not found an option that lets me select the amount of pages to scan, the main target of my project is scanning 2 or more pages and save them in a single PDF document, can you explain a little how to do this? thanks
Are you planning to push you library to NuGet?
can anyone tell how to set BRIGHTNESS & CONTRAST?thanks.
Can anyone explain me how to access the Blank page skip Sensitivity property in Fujitsu scanner? I am working with .net 4.0 c#.
Hi everyone,
I m working with Canon Imageformula DR-C130L on a WPF C# project. I want to set scan settings with custom attributes. Please see the below image:
I am getting error when below settings are apply like "Do nothing if the data source does not support the requested capability".
This is custom screen I have designed:
Some attributes are not applied like page size, page orientation, page auto rotate, scanning side simplex etc.
I have tried many times, Please help me.
I am really stuck on utilizing this codebase because in my case, interaction with the scanner must be on a separate thread from my MDI style windows form application.
My form app that starts a background thread (BGthread). The BGthread creates a System.Collection.Concurrent.BlockingCollection and processes the commands that get added to the collection. This BGthread uses the TwainDotNet classes to interact with the downstream scanner.
My MDI app puts a command into the collection monitored by the BGthread. For example, an instance of command would be a command to instantiate the TwainDotNet.Twain class. A follow-up instance of command would be to execute TwainDotNet.Twain.StartScanning(). And so onβ¦
My issue is that the TwainDotNet.WinFroms.WinFormsWindowMessageHook.PrefilterMessage() method is not ever executed. The scanner behavior at this point is that the motor starts up as if to engage the document feeder. However, the actual scan behavior never starts up. The scanner holds in this state for a few seconds and then the motor shuts off and goes into an idle state. Additionally, the MDI app is in a non-responsive state (maybe because the ImageHasTransferred/ScanningComplete events are not posted).
Suspect that this behavior is because TwainDotNet.Twain.StartScanning() is executed on my BGthread -not on my MDI app thread. When I remove the threading, things are working successfully.
Very grateful for any help, suggestions and especially answers!
The instant I add "new Twain(new WinFormsWindowMessageHook(this));" to my winform, that form falls out of the foreground when it starts up. It ends up jumping behind other windows and I have to click on it or its start bar icon to bring it forward again. I'm not sure what the issue since the message prefilter isn't called until a scan, but it is definatly related to this line of code.
I am trying to set 1200 DPI on my Epson Perfection V550 scanner. I end up getting a TWAINException indicating "TwainDotNet.TwainNative.ConditionCode.CapabilitySequenceError". The scanner is certainly capable of 1200pi (as well as even high dpi values).
I am using TWAINDotNet from VB.Net 2010
I'm trying to create a bridge application (external exe) to allow the acquisition of images from a 64bit application by a 32bit twain driver.
My first problem is that the acquired image is very big (7700x7200 pixels) and the size is about 166MB.
The problem is that during the full scan sequence the memory reach 700MB and more and I'm not able to save the image on disk (GDI+ raise a generic exception but I'm sure that it is related to the memory).
I don't know it there is a possibility to reduce this memory usage, what I have seen is that there are three allocation of 166MB: the acquisition made by the twain driver (DsImageTransfer), the render of the bitmap (RenderToBitmap), and the last is in my code, the convertion in a buffer to allow the send to the main application.
I have found a small workaround by moving the call of the event TransferImage (in the DataSourceManager) outside the block using (using (var renderer = new BitmapRenderer(hbitmap))) in this way the framework is able to reuse the memory allocated with the RenderToBitmap method.
The code changed is in the DataSourceManager.cs at line 235:
TransferImageEventArgs args;
using (var renderer = new BitmapRenderer(hbitmap))
{
args = new TransferImageEventArgs(renderer.RenderToBitmap(), pendingTransfer.Count != 0);
}
TransferImage(this, args);
if (!args.ContinueScanning)
break;
Any other suggestions are appreciated
Well, for scanning a single side of the page is working perfect.
I tested on a Lexmark MX711 and Fujitsu fi-6140
But when is for scanning the two sides of the page (i think it would be the duplex option = true) it scan like default option.
Any hint what it could be or maybe how we fix it?
I was wonder how difficult it might be to add in support for selected DocumentType (in Epson terms) where the 2 choices would be Reflective and Film?
Is this source run on (.net 4.0) windows x64 platform? when I run the source it throws me the below error: "An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B"
Have anyone tried this? thanks.
Hi, I want to scan 16bit gray document. But it just stopped. Scanning other color depth is fine though. Plz help!!!
I have a rogue scanning driver which likes to mess with the default selected scanner every time I take an image. I'm not sure of what is actually happening, but what ends up happening is that TWAIN is unable to detect the default scanner. On other scanning programs this shows up as an error when I try to acquire an image, but I can go to the device selection dialog and select it again.
However, TwainDotNet initialization will fail if this happens, because on method
public static DataSource GetDefault(Identity applicationId, IWindowsMessageHook messageHook)
which is called on initialization, it will throw an exception if it can't detect the scanner.
(I get the condition code MaxConntions
which is not too useful).
So far I've been able to 'hack' it by just commenting the throw clause and letting TwainDotNet continue initialization, and in my simple use case this hasn't caused problems so far, though I believe some more work has to be done to adapt TwainDotNet in case there's no default scanner.
Thanks, throwaway1290304032.
Hi Guys,
I'm trying to figure out how to Set Default Scanner without using the GUI.
I read this post: https://stackoverflow.com/questions/16555951/setting-default-twain-data-source-without-using-api-ui-menu
But I don't know how I can use DSM 2.0 and add it to TwainDotNet DataSourceManager.
I'm stuck with it, so if anyone has any idea.
Maybe I'm going the wrong way, so if there is another way to hide the GUI. (I want the user to use my own GUI)
Hi,
In one of my scanning devices, I was getting no image transferred when I sent the scan request through TwainDotNet, even though the device itself did the scanning.
After some guesswork I found the offending line:
bitmap.SetResolution(PpmToDpi(_bitmapInfo.XPelsPerMeter), PpmToDpi(_bitmapInfo.YPelsPerMeter));
It looks like my scanning device is setting _bitmapInfo.XPelsPerMeter = 0
and _bitmapInfo.YPelsPerMeter == 0
, so the call to SetResolution fails with 'Invalid Parameter'.
Fixing it is trivial by skipping the call or setting some sensible default if those fields are set to zero.
Thanks, throwaway1290304032
The TWAIN Resources appears to unavailable.
Is there any optional link?
Hi, I'm getting this error
An error occurred creating the form. See Inner.Exception for details. Th error is: Could not load file or assembly 'TwainDotnet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3cd6e1539fa8c71' or one of its dependencies. An attempt was made to load a program with an incorrect format.
its a new project, not the sample..my project is set to .Net Framework 4, platform to AnyCPU...when i try to change the platform target to AnyCPU of TwainDotNet & TwainDotNet.WinFroms..the above exception is gone, but there will be another error on the DataSourceManager BadImageFormatException on TwainDotnet
Thanks @sivaktamilan. I gone through your article of Scanning. Everything is work perfect till now. Can I use your code for Commercial Purpose?
Hello,
I'm using this library in a bigger project and since now everything was fine. But now, we've changed our OS to Win 8.1 x64 and things get complicated. We use a Fujitsu fi6130z, which has worked fine in the past. Now, if I want to trigger a scan, I get an AccessViolation-Exception, when the DataSource is trying to close (for example, I try to select source in the test app).
Twain32Native.DsUserInterface(_applicationId, SourceId, DataGroup.Control, DataArgumentType.UserInterface, Message.DisableDS, userInterface); gets a "failure"-Result, and I cant figure out why. Windows 7 and XP don't have any problems there. My guess was, that there are any problems with access privileges under Win8.1, which are set to other default values than Win 7. But I don't know, which ones could it be. Other tools like IrfanView are working fine with TWAIN, so I'm not really sure, what I sould do now.
And then there is no activity on this project for 6-12 months, so my hope is going away, while writing this here. Is there any chance to get some informations about this?
Thanks
_settings = new ScanSettings();
_settings.Page = new PageSettings();
_settings.Resolution = new ResolutionSettings();
_settings.UseDocumentFeeder = useAdfCheckBox.Checked;
_settings.ShowTwainUI = useUICheckBox.Checked;
_settings.ShowProgressIndicatorUI = showProgressIndicatorUICheckBox.Checked;
_settings.UseDuplex = useDuplexCheckBox.Checked;
_settings.Resolution.Dpi = 800;
_settings.Page.Size = TwainDotNet.TwainNative.PageType.MaxSize;
**hello i want to set custom page size like (1527,800)**
This message come form China.I use twaindotnet coding my exe.But,I don't know how to set twaindotnet use dual memory from ScanSettings not from Use UI.Thank you for your answer.This libary is the best I Have seem.
hi
i want to use the library in a console application. i implemented the IWindowsMessageHook and used process handle for intPtr handle. but after starting the scan and when scanner finishes the scan , the "TransferImage" and "TransferComplete" never fires.is there something i can do ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.