This project has moved. For the latest updates, please go here.

Problems with image transfer

Jun 30, 2016 at 1:37 PM
Edited Jun 30, 2016 at 1:39 PM
Hello Saraff,

I have problems to get the scanned image presented in a picture box of my program.
I have used (almost) exactly the code, you provided in your sample_1 (the simple one).
If I run this sample (x86 Version) it works fine, but not, if I call the scanner from my application.
I use for testing an Epson Perfection 4990.
I can select the scanner and I can bring up the EpsonScan GUI and the scanning starts.
But when it is finished, the image is not presented in my picture box.

Have you ( or anyone else ) any Idea, what might be the reason.

I have uploaded a Screenshot which shows the relevant section of my code, the Main Window of my application with the picture box at the bottom of this window (designated in red).
And it shows the scanning in progress.

I develop using MS VisualStudio Community 2015 under Windows 10 (64 Bit) and I use the
LightPath.Set to TwLP.Transmissive (which works fine so far).

see the screenshot at:

For any hint, what might be the reason I would be very greatfull.


I have still the problem to get the ImageLayout accepted by the scanner.
It always scans the complete window ( 6 x 8 inches) when
"_twain.ShowUI = false;" is set in front of the relevant Acquire statement.

This is the code I currently use for capbility negotiation.
Is there something wrong ? (Units = inches. All values provided in inches)
        TwImageLayout theImageLayout = new TwImageLayout();  
        aFrame = new RectangleF(imgX, imgY, imgWidth, imgHeight);
        _selectedResolution = ConvertStringToFloat(theIniFile.GetIniField("stripResolution"));
        this._twain.Capabilities.XResolution.Set(_selectedResolution/10);  // reduced for testing

        theImageLayout.Frame = aFrame;
        theImageLayout.DocumentNumber = 0;
        theImageLayout.PageNumber = 0;
        theImageLayout.FrameNumber = 1;
// for testing:
        float widthF  = this._twain.ImageLayout.Width;
        float heightF = this._twain.ImageLayout.Height;
        float topF    = this._twain.ImageLayout.Top;
        float leftF   = this._twain.ImageLayout.Left;

        Console.WriteLine("657 ImageLayout Type = " + this._twain.ImageLayout.GetType()+", widthF="+widthF+", heightF="+heightF+", topF="+topF+", leftF="+leftF);
This test stetement shows the used values but the scanner does something else.

Jun 30, 2016 at 6:36 PM
Edited Jun 30, 2016 at 7:55 PM
Hello, WolfgangKurz.
Try use a Twain32.EndXfer event instead a Twain32.AcquireCompleted:
private void _twain32_EndXfer(object sender,Twain32.EndXferEventArgs e) {
    try {
        // ...
        // ...
    } catch(Exception ex) {
        // ...
About ImageLayout:
At first, you must open a data source. Whereupon, you can set a ImageLayout and a Capability:
// ...


// ...

var _layout=this._twain32.ImageLayout; // <<< get current layout

// ...

this._twain32.ImageLayout=new RectangleF(1.5f,2f,2.5f,3.5f); /* sets the layout for the next image transfer */

// ...

this._twain32.Capabilities.Frames.Set(new RectangleF(1.5f,2f,2.5f,3.5f)); /* specify the frames and their locations to be used to acquire from future pages. */

// ...


// ...
Marked as answer by SARAFF on 7/2/2016 at 7:18 AM
Jun 30, 2016 at 9:26 PM
Edited Jun 30, 2016 at 9:27 PM
Hello Saraff,

many thanks for the hints.
I will try them as soon as possible.

And again many many thanks for the provision of this wunderful product.