I was hoping for a little help with regard to multi-page tif files as I am completely new to GDPicture.NET. I have a program written where I can acquire from my scanner, which works no problem. I'm having a little problem saving the files though.
My situation is where I need to acquire my images in tif format, then store them on another server. Currently, I'm doing this through a web service. I would acquire the image(s) into a multi-page tif file, convert it to an array of byte, then pass that to the web service which creates the file on the server's side. For single page files, it works just fine, but for multi page files, I'm only getting the first page, and its probably because of the ImageID. I'm using some of the code from the examples:
Code: Select all
Do
ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
If ImageID <> 0 Then
nImageCount = nImageCount + 1
If nImageCount = 1 Then
MultiPageID = ImageID
oGdPictureImaging.TiffSaveAsMultiPageFile(MultiPageID, My.Application.Info.DirectoryPath & "\multipage.tif", TiffCompression.TiffCompressionNONE)
Else
oGdPictureImaging.TiffAddToMultiPageFile(MultiPageID, ImageID)
oGdPictureImaging.ReleaseGdPictureImage(ImageID)
End If
End If
Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED
' MultiPageID = oGdPictureImaging.TiffCreateMultiPageFromFile(My.Application.Info.DirectoryPath & "\multipage.tif")
oGdPictureImaging.SaveAsByteArray(MultiPageID, PicBytes, BytesRead, DocumentFormat.DocumentFormatTIFF, 6)
DL.SaveImage(PicBytes) ' Call to web service which sends the file to the server side.
oGdPictureImaging.TiffCloseMultiPageFile(MultiPageID)
oGdPictureImaging.TwainCloseSource()
By the way, the file created ("multipage.tif") is correct and contains two pages. I've tried a few other ways like:
MultiPageID = oGdPictureImaging.TiffCreateMultiPageFromFile(My.Application.Info.DirectoryPath & "\multipage.tif")
then I would try to create the byte array from that, but it crashes the program and I'm not sure why because the crash comes from the GDPicture DLL and I can't debug that.
If there's another way to do this (send the data another way) I'm open to that. Whatever gets the job done.
Thanks,
Joe