Scanner - image scanning!
-
i am trying to convert c# to vb.net of this project! .NET TWAIN image scanner[^] i did it and it works on select source, and scan preview but not when i click scan then it throws me error "Arithmetic operation resulted in an overflow." in winmsga.x = CShort(pos) much of code! :( here is what i have done: TwainLib[^] Twain[^] GDIPlusLib[^] And my form[^] only two things got errors when i converted code! first one is:
<StructLayout(LayoutKind.Sequential, Pack:=4)> _
Friend Structure WINMSG
Public hwnd As IntPtr
Public message As Integer
Public wParam As IntPtr
Public lParam As IntPtr
Public time As Integer
Public x As Integer
Public y As Integer
End Structureand
Private winmsg As WINMSG
so i just renamed it to winmsga maybe i did something wrong here? and other error was:
Protected Function GetPixelInfo(ByVal bmpptr As IntPtr) As IntPtr
bmi = New BITMAPINFOHEADER()
Marshal.PtrToStructure(bmpptr, bmi)bmprect.X = InlineAssignHelper(bmprect.Y, 0) bmprect.Width = bmi.biWidth bmprect.Height = bmi.biHeight If bmi.biSizeImage = 0 Then bmi.biSizeImage = ((((bmi.biWidth \* bmi.biBitCount) + 31) And Not 31) >> 3) \* bmi.biHeight End If Dim p As Integer = bmi.biClrUsed If (p = 0) AndAlso (bmi.biBitCount <= 8) Then p = 1 << bmi.biBitCount End If p = (p \* 4) + bmi.biSize + CInt(bmpptr) **Return New (p,IntPtr)** 'so i made like this (Return New System.IntPtr(p)) End Function
can annyone help? thanks!
FeRtoll Software.net ------------ E-Mail me
-
i am trying to convert c# to vb.net of this project! .NET TWAIN image scanner[^] i did it and it works on select source, and scan preview but not when i click scan then it throws me error "Arithmetic operation resulted in an overflow." in winmsga.x = CShort(pos) much of code! :( here is what i have done: TwainLib[^] Twain[^] GDIPlusLib[^] And my form[^] only two things got errors when i converted code! first one is:
<StructLayout(LayoutKind.Sequential, Pack:=4)> _
Friend Structure WINMSG
Public hwnd As IntPtr
Public message As Integer
Public wParam As IntPtr
Public lParam As IntPtr
Public time As Integer
Public x As Integer
Public y As Integer
End Structureand
Private winmsg As WINMSG
so i just renamed it to winmsga maybe i did something wrong here? and other error was:
Protected Function GetPixelInfo(ByVal bmpptr As IntPtr) As IntPtr
bmi = New BITMAPINFOHEADER()
Marshal.PtrToStructure(bmpptr, bmi)bmprect.X = InlineAssignHelper(bmprect.Y, 0) bmprect.Width = bmi.biWidth bmprect.Height = bmi.biHeight If bmi.biSizeImage = 0 Then bmi.biSizeImage = ((((bmi.biWidth \* bmi.biBitCount) + 31) And Not 31) >> 3) \* bmi.biHeight End If Dim p As Integer = bmi.biClrUsed If (p = 0) AndAlso (bmi.biBitCount <= 8) Then p = 1 << bmi.biBitCount End If p = (p \* 4) + bmi.biSize + CInt(bmpptr) **Return New (p,IntPtr)** 'so i made like this (Return New System.IntPtr(p)) End Function
can annyone help? thanks!
FeRtoll Software.net ------------ E-Mail me
-
ahhhh i hate this! :P i made it work! thanks anyway
FeRtoll Software.net ------------ E-Mail me WebPage
You should be chuffed you got it working. It also shows the guys on CP that you are willing to work at it yourself, and so will be much more willing to help in the future. Congrats :thumbsup:
-
You should be chuffed you got it working. It also shows the guys on CP that you are willing to work at it yourself, and so will be much more willing to help in the future. Congrats :thumbsup:
thanks! :P btw i forgot to post a solution! the only thing why it wasnt working was this part:
winmsga.hwnd = m.HWnd
winmsga.message = m.Msg
winmsga.wParam = m.WParam
winmsga.lParam = m.LParam
winmsga.time = GetMessageTime()
winmsga.x = pos 'just removed CShort()
winmsga.y = (pos >> 16) 'same hereFeRtoll Software.net ------------ E-Mail me WebPage