Slow display of a source's user interface

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
GRezniczek
Posts: 4
Joined: Fri May 08, 2009 1:13 pm

Slow display of a source's user interface

Post by GRezniczek » Fri May 08, 2009 1:18 pm

Hey,
I am currently testing several TWAIN frameworks to include in a project. Yours is a candidate. I am using the latest version, downloaded a couple of days ago from your website. Everything works fine, except for one annoying detail: When I call any of the "Acquire" methods with the source's user interface displayed, it's buildup (ie. appearing of controls, buttons, icons, etc.) is really slow, taking several seconds. I see this with both the UI of a real scanner (Epson V100), as well as with the TWAIN.org sample data source.

Any ideas :?:

I am using Visual Studio 2008, targetting .NET 2.0, on Windows XP SP3.

Thanks.

G. Rezniczek

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Slow display of a source's user interface

Post by Loïc » Fri May 08, 2009 1:27 pm

Hi,

Could you give me the code you are using to acquire image ?

Kind regards,

Loïc

GRezniczek
Posts: 4
Joined: Fri May 08, 2009 1:13 pm

Re: Slow display of a source's user interface

Post by GRezniczek » Fri May 08, 2009 1:46 pm

This is just some quick'n'dirty code to test the basics.
Look at the event handler for button2.

I did the same also with the TWAIN toolkit from LEAD, no problems there.
Before I gave up on it, I also tried to write a TWAIN module myself, so I guess the problem lies somewhere in your processing/routing of the WINMSG through the DSM.

Regards,
Gunther

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GdPicture;

namespace GDTwainTest
{
    public partial class Form1 : Form
    {
        private GdPicture.GdPictureImaging gd = new GdPicture.GdPictureImaging();
        private string sourceName = string.Empty;

        public Form1()
        {
            InitializeComponent();

            Text = "GDScanTest";

            gd.SetLicenseNumber("REMOVED");
            gdViewer1.SetLicenseNumber("REMOVED");

            button2.Enabled = button3.Enabled = false;
        }


        private void EnableButtons(bool enabled)
        {
            button1.Enabled = button2.Enabled = button3.Enabled = enabled;
        }

        private void ClearImage()
        {
            gdViewer1.Clear();
            gdViewer1.Update();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            bool rv = gd.TwainSelectSource(Handle);
            if (rv)
            {
                sourceName = gd.TwainGetDefaultSourceName(Handle);
                Text = "GDScanTest :: " + sourceName;
                EnableButtons(true);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ClearImage();
            EnableButtons(false);
            gd.TwainOpenSource(Handle, sourceName);
            gd.TwainSetHideUI(false);
            gd.TwainSetIndicators(true);
            int picId = gd.TwainAcquireToGdPictureImage(Handle);
            gd.TwainCloseSource();
            if (picId != 0)
            {
                gdViewer1.DisplayFromGdPictureImage(picId);
            }
            EnableButtons(true);
        }


        private void button3_Click(object sender, EventArgs e)
        {
            ClearImage();
            EnableButtons(false);
            gd.TwainOpenSource(Handle, sourceName);
            gd.TwainSetHideUI(true);
            gd.TwainSetIndicators(false);
            gd.TwainSetPixelType(GdPicture.TwainPixelType.TWPT_RGB);
            gd.TwainSetBitDepth(24);
            gd.TwainSetXferCount(1);
            gd.TwainSetResolution(300);
            gd.TwainSetImageLayout(1, 0.5, 5, 3);
            int picId = gd.TwainAcquireToGdPictureImage(Handle);
            gd.TwainCloseSource();
            if (picId != 0)
            {
                gdViewer1.DisplayFromGdPictureImage(picId);
            }
            EnableButtons(true);
        }
    }
}

GRezniczek
Posts: 4
Joined: Fri May 08, 2009 1:13 pm

Re: Slow display of a source's user interface

Post by GRezniczek » Fri May 08, 2009 1:53 pm

Here is also the log for manually acquiring from the TWAIN sample source (ie. what goes on when button2 is clicked in the code above).

Code: Select all

#GdTwain Log Start. Version: 622

RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
Start: OpenSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS
-------------------
Start: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS
-------------------
End: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
End: OpenSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS
-------------------
Start: AcquireNative.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
Source: TWAIN_32 Sample Source
Manufacturer: TWAIN Working Group
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS
-------------------
Start: WaitForXfer.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS
-------------------
Start: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS
-------------------
End: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
Start: EnableSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_USERINTERFACE - MSG: MSG_ENABLEDS ->RC: TWRC_SUCCESS
-------------------
End: EnableSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 5
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_NOTDSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_EVENT - MSG: MSG_PROCESSEVENT ->RC: TWRC_DSEVENT CC: TWCC_SUCCESS
-------------------
MessageHook: MSG_XFERREADY.
RC:   TWRC_DSEVENT
CC:   TWCC_SUCCESS
State: 6
-------------------
Start: DoOneTransfer.
RC:   TWRC_DSEVENT
CC:   TWCC_SUCCESS
State: 6
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS
-------------------
Start: NativeXferHandler.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 6
-------------------
::DS operation. DG: DG_IMAGE - DAT: DAT_IMAGENATIVEXFER - MSG: MSG_GET ->RC: TWRC_XFERDONE CC: TWCC_SUCCESS
-------------------
End: NativeXferHandler.
RC:   TWRC_XFERDONE
CC:   TWCC_SUCCESS
State: 7
-------------------
Start: EndXfer.
RC:   TWRC_XFERDONE
CC:   TWCC_SUCCESS
State: 7
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_PENDINGXFERS - MSG: MSG_ENDXFER ->RC: TWRC_SUCCESS
-------------------
Start: Extended check for pending xfers.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 5
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_PENDINGXFERS - MSG: MSG_GET ->RC: TWRC_SUCCESS
-------------------
End: Extended check for pending xfers.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 6
-------------------
End: EndXfer.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 6
-------------------
End: DoOneTransfer.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 6
-------------------
End: ModalEventLoop.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 6
-------------------
End: WaitForXfer.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 6
-------------------
Start: AbortAllPendingXfers.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 6
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_PENDINGXFERS - MSG: MSG_RESET ->RC: TWRC_SUCCESS
-------------------
End: AbortAllPendingXfers.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 5
-------------------
Start: DisableSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 5
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_USERINTERFACE - MSG: MSG_DISABLEDS ->RC: TWRC_SUCCESS
-------------------
End: DisableSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
End: AcquireNative.
RC:   TWRC_XFERDONE
CC:   TWCC_SUCCESS
State: 4
-------------------
Start: CloseSource.
RC:   TWRC_XFERDONE
CC:   TWCC_SUCCESS
State: 4
Source: TWAIN_32 Sample Source
Manufacturer: TWAIN Working Group
-------------------
End: CloseSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
#GdTwain Log Stop.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Slow display of a source's user interface

Post by Loïc » Fri May 08, 2009 2:15 pm

Hi Gunther,

Thanks for all informations.

The slow displaying of your driver GUI is due to a hook of GdPicture which intercepts all message of the operating system.

I can see some ways to improve speed:
- (a) Turn off TWAIN log report
- Close unused applications
- (b) Start your program in release mode

If at least a & b points don't solve your issue, let me know.

Kind regards,

Loïc

GRezniczek
Posts: 4
Joined: Fri May 08, 2009 1:13 pm

Re: Slow display of a source's user interface

Post by GRezniczek » Fri May 08, 2009 2:56 pm

Hey,

thanks for the fast answers!

I had tried your suggestions before even reporting this. So unfortunately, they do not help. :(

Regards,
Gunther

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest