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

TW_IMAGEINFO

Forums › TWAIN Classic › TW_IMAGEINFO

  • This topic has 6 replies, 4 voices, and was last updated 6 years, 9 months ago by kgudi.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • May 2, 2008 at 9:30 pm #22329 Reply
    alvise
    Participant
    • Topics - 10
    • Replies - 23
    • Total Posts - 33

    Hi, I have prepared the following TW_IMAGEINFO structure:

    TW_FIX32 resolution;
    resolution . Whole = 200;
    resolution . Frac = 0;
    TW_IMAGEINFO twImageInfo;
    twImageInfo . XResolution = resolution;
    twImageInfo . YResolution = resolution;
    twImageInfo . ImageWidth = 1728;
    twImageInfo . ImageLength = 2336;
    twImageInfo . SamplesPerPixel = 1;
    twImageInfo . BitsPerSample[0] = 1;
    twImageInfo . BitsPerSample[1] = 0;
    twImageInfo . BitsPerSample[2] = 0;
    twImageInfo . BitsPerSample[3] = 0;
    twImageInfo . BitsPerSample[4] = 0;
    twImageInfo . BitsPerSample[5] = 0;
    twImageInfo . BitsPerSample[6] = 0;
    twImageInfo . BitsPerSample[7] = 0;
    twImageInfo . BitsPerPixel = 1;
    twImageInfo . Planar = false;
    twImageInfo . PixelType = TWPT_BW;
    twImageInfo . Compression = TWCP_NONE;

    and I use the following triplet to se the values int the scanner’s embedded controller: DG_IMAGE, DAT_IMAGELAYOUT, MSG_SET

    Whichever the values I use, I always get a “TWCC_BADVALUE” condition code. Does anybody see which kind of error have I done ?

    Thanks from Alvise

    May 4, 2008 at 10:50 am #24478 Reply
    kazham
    Participant
    • Topics - 1
    • Replies - 3
    • Total Posts - 4

    Why are you using TW_IMAGEINFO structure with this triplet?
    Shouldn’t it be the TW_IMAGELAYOUT structure?

    May 4, 2008 at 3:35 pm #24479 Reply
    alvise
    Participant
    • Topics - 10
    • Replies - 23
    • Total Posts - 33

    I don’t want the user interface to be displayed, and I want to set the resolution and the scanning area programatically.

    I have read more accurately paragraph “Changing the Image Attributes” (TWAIN 1.9a spec, page 4-88) and you’re right: TW_IMAGEINFO can’t be used to set scanning parameters using the DG_IMAGE / DAT_IMAGELAYOUT / MSG_SET triplet.

    According to that paragraph I should use TW_IMAGELAYOUT, but the contents of this latter structure can’t be used to set the parameters that I need. TW_IMAGEINFO, on the contrary, is exactly the structure containing the parameters that I want to set. And it works: every parameter appears to be properly set. The only problem is that I get the “TWCC_BADVALUE” condition code. That’s all.

    I just want to perform one simple task: scan a B&W letter size sheet at 200 dpi and get the uncompressed data. But it appears to be a pretty difficult task using TWAIN.

    Regards from Alvise.

    May 4, 2008 at 4:42 pm #24480 Reply
    kazham
    Participant
    • Topics - 1
    • Replies - 3
    • Total Posts - 4

    @alvise wrote:

    TW_IMAGEINFO, on the contrary, is exactly the structure containing the parameters that I want to set.

    I just want to perform one simple task: scan a B&W letter size sheet at 200 dpi and get the uncompressed data.

    Nevertheless, I’m quite sure that you should use a set of Capability negotiation commands. And yes all of your values in TW_IMAGEINFO structure are legitimate, but as I understand TWAIN doesn’t allow to use SET command with this structure.

    May 4, 2008 at 4:49 pm #24481 Reply
    kazham
    Participant
    • Topics - 1
    • Replies - 3
    • Total Posts - 4

    @alvise wrote:

    I have read more accurately paragraph “Changing the Image Attributes” (TWAIN 1.9a spec, page 4-88) and you’re right: TW_IMAGEINFO can’t be used to set scanning parameters using the DG_IMAGE / DAT_IMAGELAYOUT / MSG_SET triplet.

    I think that TW_IMAGEINFO structure can’t be used even with “DG_IMAGE / DAT_IMAGEINFO / MSG_SET” triplet. See same page.

    July 16, 2013 at 9:35 pm #24482 Reply
    si_ben
    Participant
    • Topics - 7
    • Replies - 22
    • Total Posts - 29

    TW_IMAGEINFO can only be Requested. Each Capability has to be set manually

    I haven’t figured this out yet but I’m assuming its around the lines….

    This is what your IMAGE INFO should look like…

    [StructLayout(LayoutKind.Sequential, Pack = 2)]
    internal class TwImageInfo
    { // TW_IMAGEINFO
    public int XResolution;
    public int YResolution;
    public int ImageWidth;
    public int ImageLength;
    public short SamplesPerPixel;
    // Initialized to 8 Bits (Constant)
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
    public short[] BitsPerSample;
    public short BitsPerPixel;
    public short Planar;
    public short PixelType;
    public short Compression;
    }

    Using this — you would need these capabilities declared
    (OF Type ‘TwCap’)

    ICompression = 0x0100
    IPixelType = 0x0101
    IBitDepth = 0x112b
    IXResolution = 0x1118
    IYResolution = 0x1119

    (I think there is one called IPhysicalHeight, IPhysicalWidth) Still converting.

    Then what you would do is use the Triplet :

    FIRST You need to get the Memory Location so you use GET

    ‘cap is set to TypeOf(IBitDepth)

    (appid, appid, Control, Capability, Get, cap);

    ‘change it to what you want it to be –> Then

    (appid, appid, Control, Capability, Set, cap);
    __________________________________________________________________

    This is how I understand it. There is some MemLock and Release in there somewhere, I’m still learning the process here too, If anyone can improve upon this answer or at least make it what it should be, I could sure use the help as well

    Ben @ Software Innovations

    July 18, 2014 at 7:21 pm #24483 Reply
    kgudi
    Participant
    • Topics - 0
    • Replies - 1
    • Total Posts - 1

    We are facing an issue with scanner, it’s default resolution in twain settings seems through program seems to be high. Trying to set lower resolution with these for TWcap:
    IXResolution = 0x1118
    IYResolution = 0x1119

    But what are the valid values I should use? Any help is appreciated.

    Thanks

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: TW_IMAGEINFO
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

  • TWAIN for dental imaging integration
  • PDF/R For who and where?
  • Making searchable PDF with PDF/R
  • Backward compatibility with PDF/A and traditional PDF
  • could not open the twain source. Make sure there is a valid source for your sca
  • 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.