另外关于扫描这方面的文章在网上实在是太少了!!! 那位大哥有这方面的参考资料??
给小弟一份. thanks
俺找了点源代码,可惜是DELPHI 的. 俺看不懂 :( 谁能给俺翻译以下 ????
________________________________________
{ ********************************************************************* }
{ * TOopsTwain:      version 2.0, Jan 12, 2000.                       * }
{ * Copyright (C) 1995-2000 OopsWare Company. Oops!                   * }
{ *            OopsWare Company.  All rights reserved.                * }
{ * E-mail:    [email protected]                           * }
{ * Compiler:  Borland Delphi 4.0                                     * }
{ ********************************************************************* }unit OopsTwain;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, extctrls;const
  PM_XFERDONE        = WM_USER + 0 ;  TWON_PROTOCOLMAJOR =   1;
  TWON_PROTOCOLMINOR =   5;  // Changed for Version 1.5  TWON_ARRAY         =   3;  // indicates TW_ARRAY container
  TWON_ENUMERATION   =   4;  // indicates TW_ENUMERATION container
  TWON_ONEVALUE      =   5;  // indicates TW_ONEVALUE container
  TWON_RANGE         =   6;  // indicates TW_RANGE container
  TWON_ICONID        = 962;  // res Id of icon used in USERSELECT lbox
  TWON_DSMID         = 461;  // res Id of the DSM version num resource
  TWON_DSMCODEID     =  63;  // res Id of the Mac SM Code resource
  TWON_DONTCARE8     =$ff;
  TWON_DONTCARE16    =$ffff;
  TWON_DONTCARE32    =$ffffffff;  TWCY_USA           = 1;
  TWCY_CANADA        = 2;
  TWCY_MEXICO        = 3;
  TWCY_BRITAIN       = 6;
  TWCY_FRANCE        = 33;
  TWCY_JAPAN         = 81;
  TWCY_KOREA         = 82;
  TWCY_CHINA         = 86;
  TWCY_HONGKONG      = 852;
  TWCY_TAIWAN        = 886;  TWLG_DAN           = 0;  //Danish
  TWLG_DUT           = 1;  //Dutch
  TWLG_ENG           = 2;  //International English
  TWLG_FCF           = 3;  //French Canadian
  TWLG_FIN           = 4;  //Finnish
  TWLG_FRN           = 5;  //French
  TWLG_GER           = 6;  //German
  TWLG_ICE           = 7;  //Icelandic
  TWLG_ITN           = 8;  //Italian
  TWLG_NOR           = 9;  //Norwegian
  TWLG_POR           = 10; //Portuguese
  TWLG_SPA           = 11; //Spanish
  TWLG_SWE           = 12; //Swedish
  TWLG_USA           = 13; //U.S. English  DG_CONTROL          =$00000001; // data pertaining to control
  DG_IMAGE            =$00000002; // data pertaining to raster images
  DG_IMAGE_OR_CONTROL =$00000003;  //is " DG_CONTROL|DG_IMAGE " in C++  DAT_NULL            =$0000; // No data or structure.
  DAT_CUSTOMBASE      =$8000; // Base of custom DATs.
          // Data Argument Types for the DG_CONTROL Data Group.
  DAT_CAPABILITY      =$0001; // TW_CAPABILITY
  DAT_EVENT           =$0002; // TW_EVENT
  DAT_IDENTITY        =$0003; // TW_IDENTITY
  DAT_PARENT          =$0004; // TW_HANDLE, app win handle in Windows
  DAT_PENDINGXFERS    =$0005; // TW_PENDINGXFERS
  DAT_SETUPMEMXFER    =$0006; // TW_SETUPMEMXFER
  DAT_SETUPFILEXFER   =$0007; // TW_SETUPFILEXFER
  DAT_STATUS          =$0008; // TW_STATUS
  DAT_USERINTERFACE   =$0009; // TW_USERINTERFACE
  DAT_XFERGROUP       =$000a; // TW_UINT32
  DAT_TWUNKIDENTITY   =$000b; // TW_TWUNKIDENTITY
          // Data Argument Types for the DG_IMAGE Data Group.
  DAT_IMAGEINFO       =$0101;   // TW_IMAGEINFO
  DAT_IMAGELAYOUT     =$0102;   //TW_IMAGELAYOUT
  DAT_IMAGEMEMXFER    =$0103;   //TW_IMAGEMEMXFER
  DAT_IMAGENATIVEXFER =$0104;   //TW_UINT32 loword is hDIB, PICHandle
  DAT_IMAGEFILEXFER   =$0105;   //Null data
  DAT_CIECOLOR        =$0106;   //TW_CIECOLOR
  DAT_GRAYRESPONSE    =$0107;   //TW_GRAYRESPONSE
  DAT_RGBRESPONSE     =$0108;   //TW_RGBRESPONSE
  DAT_JPEGCOMPRESSION =$0109;   //TW_JPEGCOMPRESSION
  DAT_PALETTE8        =$010a;   //TW_PALETTE8  // All message constants are unique.
  MSG_NULL           =$0000;  // Used in TW_EVENT structure
  MSG_CUSTOMBASE     =$8000;  // Base of custom messages
     // Generic messages may be used with any of several DATs.
  MSG_GET            =$0001;  // Get one or more values
  MSG_GETCURRENT     =$0002;  // Get current value
  MSG_GETDEFAULT     =$0003;  // Get default (e.g. power up) value
  MSG_GETFIRST       =$0004;  // Get first of a series of items, e.g. DSs
  MSG_GETNEXT        =$0005;  // Iterate through a series of items.
  MSG_SET            =$0006;  // Set one or more values
  MSG_RESET          =$0007;  // Set current value to default value
     // Messages used with DAT_NULL

解决方案 »

  1.   

    MSG_XFERREADY      =$0101;  // The data source has data ready
      MSG_CLOSEDSREQ     =$0102;  // Request for App. to close DS
         // Messages used with a pointer to a DAT_STATUS structure
      MSG_CHECKSTATUS    =$0201;  // Get status information
         // Messages used with a pointer to DAT_PARENT data
      MSG_OPENDSM        =$0301;  // Open the DSM
      MSG_CLOSEDSM       =$0302;  // Close the DSM
         // Messages used with a pointer to a DAT_IDENTITY structure
      MSG_OPENDS         =$0401;  // Open a data source
      MSG_CLOSEDS        =$0402;  // Close a data source
      MSG_USERSELECT     =$0403;  // Put up a dialog of all DS
        // Messages used with a pointer to a DAT_USERINTERFACE structure
      MSG_DISABLEDS      =$0501;  // Disable data transfer in the DS
      MSG_ENABLEDS       =$0502;  // Enable data transfer in the DS
        // Messages used with a pointer to a DAT_EVENT structure
      MSG_PROCESSEVENT   =$0601;
        // Messages used with a pointer to a DAT_PENDINGXFERS structure
      MSG_ENDXFER        =$0701;  // Capabilities  CAP_CUSTOMBASE       =$8000;  //Base of custom capabilities
       // all data sources are REQUIRED to support these caps
      CAP_XFERCOUNT        =$0001;
       // image data sources are REQUIRED to support these caps
      ICAP_COMPRESSION     =$0100;
      ICAP_PIXELTYPE       =$0101;
      ICAP_UNITS           =$0102;  //default is TWUN_INCHES
      ICAP_XFERMECH        =$0103;
       // all data sources MAY support these caps
      CAP_AUTHOR           =$1000;
      CAP_CAPTION          =$1001;
      CAP_FEEDERENABLED    =$1002;
      CAP_FEEDERLOADED     =$1003;
      CAP_TIMEDATE         =$1004;
      CAP_SUPPORTEDCAPS    =$1005;
      CAP_EXTENDEDCAPS     =$1006;
      CAP_AUTOFEED         =$1007;
      CAP_CLEARPAGE        =$1008;
      CAP_FEEDPAGE         =$1009;
      CAP_REWINDPAGE       =$100a;
      CAP_INDICATORS       =$100b;   //Added 1.1
      CAP_SUPPORTEDCAPSEXT =$100c; // Added 1.6
      CAP_PAPERDETECTABLE  =$100d; // Added 1.6
      CAP_UICONTROLLABLE   =$100e; // Added 1.6
       // image data sources MAY support these caps
      ICAP_AUTOBRIGHT      =$1100;
      ICAP_BRIGHTNESS      =$1101;
      ICAP_CONTRAST        =$1103;
      ICAP_CUSTHALFTONE    =$1104;
      ICAP_EXPOSURETIME    =$1105;
      ICAP_FILTER          =$1106;
      ICAP_FLASHUSED       =$1107;
      ICAP_GAMMA           =$1108;
      ICAP_HALFTONES       =$1109;
      ICAP_HIGHLIGHT       =$110a;
      ICAP_IMAGEFILEFORMAT =$110c;
      ICAP_LAMPSTATE       =$110d;
      ICAP_LIGHTSOURCE     =$110e;
      ICAP_ORIENTATION     =$1110;
      ICAP_PHYSICALWIDTH   =$1111;
      ICAP_PHYSICALHEIGHT  =$1112;
      ICAP_SHADOW          =$1113;
      ICAP_FRAMES          =$1114;
      ICAP_XNATIVERESOLUTION =$1116;
      ICAP_YNATIVERESOLUTION =$1117;
      ICAP_XRESOLUTION     =$1118;
      ICAP_YRESOLUTION     =$1119;
      ICAP_MAXFRAMES       =$111a;
      ICAP_TILES           =$111b;
      ICAP_BITORDER        =$111c;
      ICAP_CCITTKFACTOR    =$111d;
      ICAP_LIGHTPATH       =$111e;
      ICAP_PIXELFLAVOR     =$111f;
      ICAP_PLANARCHUNKY    =$1120;
      ICAP_ROTATION        =$1121;
      ICAP_SUPPORTEDSIZES  =$1122;
      ICAP_THRESHOLD       =$1123;
      ICAP_XSCALING        =$1124;
      ICAP_YSCALING        =$1125;
      ICAP_BITORDERCODES   =$1126;
      ICAP_PIXELFLAVORCODES=$1127;
      ICAP_JPEGPIXELTYPE   =$1128;
      ICAP_TIMEFILL        =$112a;
      ICAP_BITDEPTH        =$112b;
      ICAP_BITDEPTHREDUCTION =$112c;            //Added 1.5   //Return Codes and Condition Codes section
       // Return Codes: DSM_Entry and DS_Entry may return any one of these values.
      TWRC_CUSTOMBASE   =$8000;
      TWRC_SUCCESS      =0;
      TWRC_FAILURE      =1;  //App may get TW_STATUS for info on failure
      TWRC_CHECKSTATUS  =2;  //"tried hard"; get status
      TWRC_CANCEL       =3;
      TWRC_DSEVENT      =4;
      TWRC_NOTDSEVENT   =5;
      TWRC_XFERDONE     =6;
      TWRC_ENDOFLIST    =7;  //After MSG_GETNEXT if nothing left
        //Condition Codes: App gets these by doing DG_CONTROL DAT_STATUS MSG_GET.
      TWCC_CUSTOMBASE     =$8000;
      

  2.   

    TWCC_SUCCESS        =0;  //It worked!
      TWCC_BUMMER         =1;  //Failure due to unknown causes
      TWCC_LOWMEMORY      =2;  //Not enough memory to perform operation
      TWCC_NODS           =3;  //No Data Source
      TWCC_MAXCONNECTIONS =4;  //DS is connected to max possible apps
      TWCC_OPERATIONERROR =5;  //DS or DSM reported error, app shouldn't
      TWCC_BADCAP         =6;  //Unknown capability
      TWCC_BADPROTOCOL    =9;  //Unrecognized MSG DG DAT combination
      TWCC_BADVALUE       =10;  //Data parameter out of range
      TWCC_SEQERROR       =11;  //DG DAT MSG out of expected sequence
      TWCC_BADDEST        =12;  //Unknown destination App/Src in DSM_Entrytype
      TW_HANDLE = Word;
      TW_MEMREF = pointer;// TW_HUGE   = Longint;
      TW_STR32  = Array [0..33] of Char;
    // TW_STR64  = Array [0..65] of Char;
    // TW_STR128 = Array [0..129] of Char;
    // TW_STR255 = Array [0..255] of Char;
    // TW_INT8   = ShortInt;
      TW_INT16  = Smallint;
      TW_INT32  = Longint;
    // TW_UINT8  = Byte;
      TW_UINT16 = Smallint;  // Unsinged  integer  !!!
      TW_UINT32 = Longint;
      TW_BOOL   = Byte;  // Unsinged  Short Boolean  !!!  TW_FIX32  =  packed record // Fixed point structure type.
             Whole  :  TW_INT16;        // maintains the sign
             Frac   :  TW_INT16;
            end;
      pTW_FIX32 = ^TW_FIX32;  TW_VERSION =  packed record
           MajorNum : TW_UINT16;  // Major revision number of the software.
           MinorNum : TW_UINT16;  // Incremental revision number of the software.
           Language : TW_UINT16;  // e.g. TWLG_SWISSFRENCH
           Country  : TW_UINT16;  // e.g. TWCY_SWITZERLAND
           Info     : TW_STR32;   // e.g. "1.0b3 Beta release"
         end;  TW_IDENTITY =  packed record
           Id              : TW_UINT32;  // Unique number.  In Windows, app hWnd
           Version         : TW_VERSION; // Identifies the piece of code
           ProtocolMajor   : TW_UINT16;  // App and DS must set to TWON_PROTOCOLMAJOR
           ProtocolMinor   : TW_UINT16;  // App and DS must set to TWON_PROTOCOLMINOR
           SupportedGroups : TW_UINT32;  // Bit field OR combination of DG_ constants
           Manufacturer    : TW_STR32;   // Manufacturer name, e.g. "Hewlett-Packard"
           ProductFamily   : TW_STR32;   // Product family name, e.g. "ScanJet"
           ProductName     : TW_STR32;   // Product name, e.g. "ScanJet Plus"
         end;
      pTW_IDENTITY = ^TW_IDENTITY;  TW_IMAGEINFO =  packed record // DAT_IMAGEINFO. App gets detailed image info from DS with this.
           XResolution     :TW_FIX32;        // Resolution in the horizontal
           YResolution     :TW_FIX32;        // Resolution in the vertical
           ImageWidth      :TW_INT32;        // Columns in the image, -1 if unknown by DS
           ImageLength     :TW_INT32;        // Rows in the image, -1 if unknown by DS
           SamplesPerPixel :TW_INT16;        // Number of samples per pixel, 3 for RGB
           BitsPerSample   :Array[0..7]of TW_INT16;    // Number of bits for each sample
           BitsPerPixel    :TW_INT16;        // Number of bits for each padded pixel
           Planar          :TW_BOOL;         // True if Planar, False if chunky
           PixelType       :TW_INT16;        // How to interp data; photo interp (TWPT_)
           Compression     :TW_INT16;       // How the data is compressed (TWCP_xxxx)
         end;
      pTW_IMAGEINFO = ^TW_IMAGEINFO;  TW_CAPABILITY =  packed record //DAT_CAPABILITY. Used by app to get/set capability from/in a data source.
            Cap,
            ConType    : TW_UINT16;
            hContainer : THandle;
         end;
      pTW_CAPABILITY = ^TW_CAPABILITY;  TW_USERINTERFACE =  packed record
           ShowUI     : TW_BOOL;  // TRUE if DS should bring up its UI
           ModalUI    : TW_BOOL; // For Mac only - true if the DS's UI is modal
           hParent    : TW_HANDLE; // For windows only - App window handle
         end;
      pTW_USERINTERFACE = ^TW_USERINTERFACE;  TW_EVENT      =  packed record
           pEvent     :TW_MEMREF;    // Windows pMSG or Mac pEvent.
           TWMessage  :TW_UINT16;    // TW msg from data source, e.g. MSG_XFERREADY
         end;
      pTW_EVENT = ^TW_EVENT;  TW_PENDINGXFERS = packed record
           Count      :TW_UINT16;    // Number of additional "images" pending.
           Reserved   :TW_UINT32;
         end;
      pTW_PENDINGXFERS = ^TW_PENDINGXFERS;
    {**********************************************************************
     * Function: DSM_Entry, the only entry point into the Data Source Manager.
     * Parameters:
     *  pOrigin Identifies the source module of the message. This could
      

  3.   

    小妹正在找VB可以支持批量扫描的控件 (只要调用TWAIN的就可以)不知道imgscan控件如何使用,在哪里找到? 请指教!还有, 提供批量扫描吗?
      

  4.   

    想请教一下!
    imgscan.multipage 是否指一次扫描多张? :>  请指点小妹!