TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

BadValue at Image/ImageMemXfer/Get triplet, buffered memory.

Forums › TWAIN Classic › BadValue at Image/ImageMemXfer/Get triplet, buffered memory.

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 2 months ago by peterp.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 21, 2011 at 2:08 pm #22713 Reply
    fcetrini
    Participant
    • Topics - 2
    • Replies - 0
    • Total Posts - 2

    Hi all!
    I’m having problem trying the buffered memory image transfer.

    I’m working with VB.NET, and I’m currently able to manage sources, retrieve parameters, set capabilities, scan and retrieve image in native mode.

    Now, the memory transfer issue:
    when the sources notifies TransferReady, I can retrieve the twImageInfo, then correcly setup Tw_SetupMemXFer to retrieve buffer size, then allocate the buffer as needed. When I call the ImageMemXfer/Get, it fails with BadValue status.

    Twain specs tell that this status is due to an incorrect buffer size.

    This is how I defined the ImageMemXfer class:

     Friend Class Tw_ImageMemXfer
    Public Compression As UInt16
    Public BytesPerRow As UInt32
    Public Columns As UInt32
    Public Rows As UInt32
    Public XOffset As UInt32
    Public YOffset As UInt32
    Public BytesWritten As UInt32
    Public Memory As Tw_Memory

    Public Sub New(ByVal tws As DataStructures.Tw_SetupMemXFer)
    Me.Compression = UInt16.MaxValue
    Me.BytesPerRow = UInt32.MaxValue
    Me.Columns = UInt32.MaxValue
    Me.Rows = UInt32.MaxValue
    Me.XOffset = UInt32.MaxValue
    Me.YOffset = UInt32.MaxValue
    Me.BytesWritten = UInt32.MaxValue

    Dim lHBuffer As IntPtr = IntPtr.Zero
    Dim lBuffer As IntPtr = IntPtr.Zero

    lHBuffer = DllImports.kernel32.GlobalAlloc(&H42, tws.Preferred)
    lBuffer = DllImports.kernel32.GlobalLock(lHBuffer)

    Me.Memory = New Tw_Memory
    Me.Memory.Flags = Enumerations.TW_MEMORY_FLAGS.TWMF_APPOWNS Or Enumerations.TW_MEMORY_FLAGS.TWMF_POINTER
    Me.Memory.Lenght = tws.Preferred
    Me.Memory.TheMem = lBuffer
    End Sub

    End Class

    Please help: what am I doing wrong?

    Thank you, Fabio

    November 15, 2011 at 8:56 pm #25488 Reply
    peterp
    Participant
    • Topics - 0
    • Replies - 30
    • Total Posts - 30

    Me.Memory.Lenght = tws.Preferred <– spelled Length wrong

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: BadValue at Image/ImageMemXfer/Get triplet, buffered memory.
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • To get the list of scanners from javascript client side (browser)
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.