Scan a multipage document to a TIFF file in memory
Scan a multipage document to a TIFF file in memory
Hello,
I need some help with this..
Scan a multipage document to a TIFF file in memory (not as a file). As a byte array Or memory stream. Is there any different way to do "acquire" vs the actual scan? (for the purpose of loading the thumnails)
Thanks!
I need some help with this..
Scan a multipage document to a TIFF file in memory (not as a file). As a byte array Or memory stream. Is there any different way to do "acquire" vs the actual scan? (for the purpose of loading the thumnails)
Thanks!
Re: Scan a multipage document to a TIFF file in memory
Hi,
Hope this helps !
Scan a multipage document to a TIFF file in memory (not as a file).
Code: Select all
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
'Here we will scan in a 1bpp ccitt4 & 200 DPI from adf to multipage tif file
Dim oGdPictureImaging As New GdPictureImaging
Dim nImageCount As Integer
Dim TiffID 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(200)
oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_BW) 'Black & White
oGdPictureImaging.TwainSetBitDepth(1) ' 1 bpp
Do
Dim ImageID As Integer = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
If ImageID <> 0 Then
nImageCount = nImageCount + 1
If nImageCount = 1 Then
TiffID = oGdPictureImaging.TiffCreateMultiPageFromGdPictureImage(ImageID)
Else
oGdPictureImaging.TiffAppendPageFromGdPictureImage(TiffID, ImageID)
End If
oGdPictureImaging.ReleaseGdPictureImage(ImageID)
End If
Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED
oGdPictureImaging.TwainCloseSource()
oGdPictureImaging.TiffSaveMultiPageToFile(TiffID, "c:\multipage.tif", TiffCompression.TiffCompressionAUTO)
oGdPictureImaging.ReleaseGdPictureImage(TiffID)
MsgBox("Done !")
End If
End Sub
Sorry but I do not understand.Is there any different way to do "acquire" vs the actual scan? (for the purpose of loading the thumnails)
Hope this helps !
Re: Scan a multipage document to a TIFF file in memory
Isn't this line for saving it to a file?
oGdPictureImaging.TiffSaveMultiPageToFile(TiffID, "c:\multipage.tif", TiffCompression.TiffCompressionAUTO)
I need to save this (the entire multipage tiff) as a stream or byte array WITHOUT saving it to a file first. I have seen a method called SaveAsByteArray which might work, but I am not sure how to save the entire multipage file, since one of the parameters is the ImageID.
As far as the 2nd question, scanners usually have two scanning modes, what I call "acquire", which is a quick scan just to generate a preview (really fast.. it might take 2 or 3 secs to swipe a full page), and the 2nd one which is the actual scan, where the full resolution image is generated. Since I am planning on having users select the images they want from the thumbnail control and then do the scan, It would be good if the user don't have to spend time waiting for a full scan before deciding what would the final pages be.
oGdPictureImaging.TiffSaveMultiPageToFile(TiffID, "c:\multipage.tif", TiffCompression.TiffCompressionAUTO)
I need to save this (the entire multipage tiff) as a stream or byte array WITHOUT saving it to a file first. I have seen a method called SaveAsByteArray which might work, but I am not sure how to save the entire multipage file, since one of the parameters is the ImageID.
As far as the 2nd question, scanners usually have two scanning modes, what I call "acquire", which is a quick scan just to generate a preview (really fast.. it might take 2 or 3 secs to swipe a full page), and the 2nd one which is the actual scan, where the full resolution image is generated. Since I am planning on having users select the images they want from the thumbnail control and then do the scan, It would be good if the user don't have to spend time waiting for a full scan before deciding what would the final pages be.
Re: Scan a multipage document to a TIFF file in memory
Yes, the SaveAsByteArray() or SaveAsStream() method create a multipage tiff.Isn't this line for saving it to a file?
oGdPictureImaging.TiffSaveMultiPageToFile(TiffID, "c:\multipage.tif", TiffCompression.TiffCompressionAUTO)
I need to save this (the entire multipage tiff) as a stream or byte array WITHOUT saving it to a file first. I have seen a method called SaveAsByteArray which might work, but I am not sure how to save the entire multipage file, since one of the parameters is the ImageID.
For the second issue, to create a preview just scan using a low resolution. This is the way used by almost all drivers.
Kind regards,
Loïc
Who is online
Users browsing this forum: Bing [Bot] and 1 guest