Forums › TWAIN Classic › How to dynamically determine scanned paper size › Reply To: How to dynamically determine scanned paper size
January 11, 2008 at 10:05 pm
#24262
timing. you call it in twState 6 or 7 (pg 238 of the 1.9pspec or my previous post) I call the previous code from the sub that gets the images, and actually when you read most of the sample code available the code you posted is usually unside an if stmt that doesn’t execute unless the code I posted returned True.
Dim PendingXfers As Boolean = True
Do While PendingXfers = True
If GetImageInfo() Then
'Transfer the image natively
hbitmap = IntPtr.Zero
Select Case OperationTriplets.Image.ImageNativeXfer.Get(hbitmap)
Case Enumerations.ReturnCode.XferDone
fileName = NextAvailableFilename(sessionDir.FullName, _
_CurrentImageFileFormat.ToString.ToLower) 'sfd.FileName
Trace.WriteLine(" " & fileName)
Plumbing.DibToBmp.DibHandToBmp(hbitmap).Save(fileName)
_Images.Add(fileName)
PendingXfers = DoEndXfer()
Case Enumerations.ReturnCode.Cancel
PendingXfers = DoEndXfer()
Case Enumerations.ReturnCode.Failure
Dim mStatusShort As Enumerations.ConditionCode
mStatusShort = OperationTriplets.Control.Status.Get()
If mStatusShort <> Enumerations.ConditionCode.Success Then
myTrace.WriteLine(" " & System.Enum.GetName(GetType(Enumerations.ConditionCode), mStatusShort), Instrumentation.TraceLevelEnum.Information)
myTrace.WriteLine(" " & DataStructures.twStatus.ConditionDescription(mStatusShort), Instrumentation.TraceLevelEnum.Information)
End If
DoAbortXfer()
PendingXfers = False
End Select
End If
Loop
Trace.WriteLine("Native loop finished")
the rest of this code is over at http://www.codeplex.com/openTwain on the releases tab in a zip, in a file named cTwain.vb around line 1100ish
.