Binary&Color

Example requests & Code samples for GdPicture Toolkits.
Post Reply
ctejedav
Posts: 11
Joined: Thu Jan 07, 2010 6:22 pm

Binary&Color

Post by ctejedav » Fri Jan 22, 2010 10:14 pm

Hi,

I have a Scanner that supports Binary & Color. Need to Scan Color & Binary at a Time. That is to create 2 images.

There any way to do this?

Thank you very much

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

Re: Binary&Color

Post by Loïc » Sat Jan 23, 2010 10:00 am

Hi,

Yes you can: just acquire your image in color mode, make a clone of the color image and convert it to bitonal.

Let me know if you need a code sample for this.

With best regards,

Loïc

ctejedav
Posts: 11
Joined: Thu Jan 07, 2010 6:22 pm

Re: Binary&Color

Post by ctejedav » Sat Jan 23, 2010 8:09 pm

Thanks Loic, an example would be nice, thank you very much

ctejedav
Posts: 11
Joined: Thu Jan 07, 2010 6:22 pm

Re: Binary&Color

Post by ctejedav » Tue Jan 26, 2010 11:46 pm

Hi Loïc,

Please send me one code example when you have time.

Thanks,

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

Re: Binary&Color

Post by Loïc » Wed Jan 27, 2010 4:13 pm

Hi,

Sorry for the delay. Here a basic sample to scan all content of a document feeder to color (jpg) and binary (tiff) images:

Code: Select all

 
 Dim nImageCount As Integer
 Dim ImageID As Integer

 If oGdPictureImaging.TwainOpenDefaultSource(Me.Handle) Then
     nImageCount = 0

     oGdPictureImaging.TwainSetAutoFeed(True) 'Set AutoFeed Enabled
     oGdPictureImaging.TwainSetAutoScan(True) 'To  achieve the maximum scanning rate
     oGdPictureImaging.TwainSetResolution(300)
     oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_RGB) 'RGB
     oGdPictureImaging.TwainSetBitDepth(8) ' 24 bpp 8 bit per pixel

     Do
         ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
         If ImageID <> 0 Then
             nImageCount = nImageCount + 1
             Call oGdPictureImaging.SaveAsJPEG(ImageID, My.Application.Info.DirectoryPath & "\image" & Trim(Str(nImageCount)) & ".jpg", 75)
             oGdPictureImaging.ConvertTo1Bpp(ImageID)
             Call oGdPictureImaging.SaveAsTIFF(ImageID, My.Application.Info.DirectoryPath & "\image" & Trim(Str(nImageCount)) & ".tif", TiffCompression.TiffCompressionCCITT4)
             Call oGdPictureImaging.ReleaseGdPictureImage(ImageID)
         End If
     Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED

            Call oGdPictureImaging.TwainCloseSource()
            MsgBox("Done !")
        Else
            MsgBox("can't open default source, twain state is: " & oGdPictureImaging.TwainGetState.ToString)
        End If
Let me know if you need more assistance.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest