Twain sample missing functions

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
WJO
Posts: 3
Joined: Sat Feb 19, 2011 2:10 pm

Twain sample missing functions

Post by WJO » Sat Feb 19, 2011 2:17 pm

If I try your Twain sample there are three wrong function - calls.
here are your code

Code: Select all

   Private Sub Command12_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command12.Click
        'Here we will scan in a 1bpp  form adf to multiple page pdf file
        Dim ImageID As Integer
        Dim PdfID As Integer

        If oGdPictureImaging.TwainOpenDefaultSource(Me.Handle) Then

            InitScanConfig()

            oGdPictureImaging.TwainSetAutoFeed(True) 'Set AutoFeed Enabled
            oGdPictureImaging.TwainSetAutoScan(True) 'To  achieve the maximum scanning rate
            oGdPictureImaging.TwainSetResolution(200)
            oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_BW) 'Black & White
            oGdPictureImaging.TwainSetBitDepth(1) ' 1 bpp

            PdfID = oGdPictureImaging.TwainPdfStart("output.pdf", True, "", "", "", "", "")

            Do
                ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
                If ImageID <> 0 Then
                    Call ApplyImageFilters(ImageID)
                    If chkPreview.CheckState = 1 Then Call DisplayImage(ImageID)
                    Call oGdPictureImaging.TwainAddGdPictureImageToPdf(PdfID, ImageID)
                    oGdPictureImaging.ReleaseGdPictureImage(ImageID)
                End If
            Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED
            oGdPictureImaging.TwainPdfStop(PdfID)

            Call oGdPictureImaging.TwainCloseSource()
            MsgBox("Done !")
        Else
            MsgBox("can't open default source, twain state is: " & oGdPictureImaging.TwainGetState.ToString)
        End If

    End Sub
these functions are wrong:
TwainPdfStart
TwainAddGdPictureImageToPdf
TwainPdfStop

Is there a workaround ?

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

Re: Twain sample missing functions

Post by Loïc » Sat Feb 19, 2011 3:39 pm

Hi,

Where did you find this sample ?

Kind regards,

Loïc

WJO
Posts: 3
Joined: Sat Feb 19, 2011 2:10 pm

Re: Twain sample missing functions

Post by WJO » Sat Feb 19, 2011 4:02 pm

C:\Programme\GdPicture.NET\samples\vb.net

Best regards

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

Re: Twain sample missing functions

Post by Loïc » Sat Feb 19, 2011 4:12 pm

Hi,

I think you are using an old sample with the new version.

here the code provided in our latest package:

Code: Select all

    Private Sub Command12_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command12.Click
        'Here we will scan in a 1bpp  form adf to multiple page pdf file
        Dim ImageID As Integer
        Dim PdfID As Integer

        If OpenSelectedSource() Then
            oGdPictureImaging.TwainSetHideUI(CBool(chkHideUI.CheckState))
            oGdPictureImaging.TwainSetIndicators(CBool(chkIndicator.CheckState))

            oGdPictureImaging.TwainSetAutoFeed(True) 'Set AutoFeed Enabled
            oGdPictureImaging.TwainSetAutoScan(True) 'To  achieve the maximum scanning rate
            oGdPictureImaging.TwainSetResolution(200)
            oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_BW) 'Black & White
            oGdPictureImaging.TwainSetBitDepth(1) ' 1 bpp

            PdfID = oGdPictureImaging.PdfNewPdf("output.pdf", True, "", "", "", "", "")

            Do
                ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
                If ImageID <> 0 Then
                    Call ApplyImageFilters(ImageID)
                    If chkPreview.CheckState = 1 Then Call DisplayImage(ImageID)
                    Call oGdPictureImaging.PdfAddImageFromGdPictureImage(PdfID, ImageID, False, True)
                    oGdPictureImaging.ReleaseGdPictureImage(ImageID)
                End If
            Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED
            oGdPictureImaging.PdfEndPdf(PdfID)

            Call oGdPictureImaging.TwainCloseSource()
            MsgBox("Done !")
        End If

    End Sub

Let me know if the problem persists.

WJO
Posts: 3
Joined: Sat Feb 19, 2011 2:10 pm

Re: Twain sample missing functions

Post by WJO » Sat Feb 19, 2011 4:15 pm

OK I see I mixed up your samples, and you rename some functions :(
Vers 6.X TwainPdfStart -> Vers. 7.X PdfNewPdf
Vers 6.X TwainAddGdPictureImageToPdf-> Vers. 7.X PdfAddImageFromGdPictureImage
Vers 6.X TwainPdfStart -> Vers. 7.X PdfEndPdf.

Best regards

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests