Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Scanner - image scanning!

Scanner - image scanning!

Scheduled Pinned Locked Moved Visual Basic
csharphelpcomquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FeRtoll
    wrote on last edited by
    #1

    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 Structure

    and

    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

    F 1 Reply Last reply
    0
    • F FeRtoll

      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 Structure

      and

      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

      F Offline
      F Offline
      FeRtoll
      wrote on last edited by
      #2

      ahhhh i hate this! :P i made it work! thanks anyway

      FeRtoll Software.net ------------ E-Mail me WebPage

      W 1 Reply Last reply
      0
      • F FeRtoll

        ahhhh i hate this! :P i made it work! thanks anyway

        FeRtoll Software.net ------------ E-Mail me WebPage

        W Offline
        W Offline
        Wayne Gaylard
        wrote on last edited by
        #3

        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:

        F 1 Reply Last reply
        0
        • W Wayne Gaylard

          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:

          F Offline
          F Offline
          FeRtoll
          wrote on last edited by
          #4

          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 here

          FeRtoll Software.net ------------ E-Mail me WebPage

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups