📄 oopstwain.pas
字号:
//--------------------------------------------------------------------------
// TOopsTwain: version 4.0, Aug 2, 2004.
// Copyright (C) 1995-2004,OopsWare.CHINA.
//
// HomePage: http://oopsware.delphibbs.com/
// Compiler: Borland Delphi 6
//
// History:
// version 3.1, Mar 15, 2002. Support twain protocal 1.6
// version 2.0, May 30, 2000.
// version 1.2, May 06, 1998. First Release, Support twain protocal 1.5
//--------------------------------------------------------------------------
unit OopsTwain;
interface
{$D+}
uses
Windows, Messages, SysUtils, Classes, Controls, Graphics;
const
APP_PROTOCOLMAJOR = 4;
APP_PROTOCOLMINOR = 0;
VALID_HANDLE = 32;
const
TWON_PROTOCOLMAJOR = 1;
TWON_PROTOCOLMINOR = 7; // Changed for Version 1.7
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
// Added for 1.8
TWLG_USERLOCALE = $FFFF; // -1;
TWLG_CHINESE = 37;
TWLG_CHINESE_PRC = 39; // People's Republic of China
TWLG_CHINESE_SIMPLIFIED = 41;
TWLG_CHINESE_TAIWAN = 42;
TWLG_CHINESE_TRADITIONAL = 43;
TWTY_INT8 = $0000; // Means Item is a TW_INT8
TWTY_INT16 = $0001; // Means Item is a TW_INT16
TWTY_INT32 = $0002; // Means Item is a TW_INT32
TWTY_UINT8 = $0003; // Means Item is a TW_UINT8
TWTY_UINT16 = $0004; // Means Item is a TW_UINT16
TWTY_UINT32 = $0005; // Means Item is a TW_UINT32
TWTY_BOOL = $0006; // Means Item is a TW_BOOL
TWTY_FIX32 = $0007; // Means Item is a TW_FIX32
TWTY_FRAME = $0008; // Means Item is a TW_FRAME
TWTY_STR32 = $0009; // Means Item is a TW_STR32
TWTY_STR64 = $000a; // Means Item is a TW_STR64
TWTY_STR128 = $000b; // Means Item is a TW_STR128
TWTY_STR255 = $000c; // Means Item is a TW_STR255
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
MSG_XFERREADY =$0101; // The data source has data ready
MSG_CLOSEDSREQ =$0102; // Request for App. to close DS
MSG_CLOSEDSOK =$0103; // Tell the Application. to save the state.
// 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;
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_Entry
// ICAP_UNITS values (UN_ means UNits)
TWUN_INCHES =0;
TWUN_CENTIMETERS =1;
TWUN_PICAS =2;
TWUN_POINTS =3;
TWUN_TWIPS =4;
TWUN_PIXELS =5;
// ICAP_PIXELTYPE values (PT_ means Pixel Type)
TWPT_BW =0;
TWPT_GRAY =1;
TWPT_RGB =2;
TWPT_PALETTE =3;
TWPT_CMY =4;
TWPT_CMYK =5;
TWPT_YUV =6;
TWPT_YUVK =7;
TWPT_CIEXYZ =8;
// Flags used in TW_MEMORY structure.
TWMF_APPOWNS =$01;
TWMF_DSMOWNS =$02;
TWMF_DSOWNS =$04;
TWMF_POINTER =$08;
TWMF_HANDLE =$10;
// ICAP_PIXELFLAVOR values (PF_ means Pixel Flavor)
TWPF_CHOCOLATE =0; // zero pixel represents darkest shade
TWPF_VANILLA =1; // zero pixel represents lightest shade
// ICAP_IMAGEFILEFORMAT values (FF_means File Format)
TWFF_TIFF =0; // Tagged Image File Format
TWFF_PICT =1; // Macintosh PICT
TWFF_BMP =2; // Windows Bitmap
TWFF_XBM =3; // X-Windows Bitmap
TWFF_JFIF =4; // JPEG File Interchange Format
TWFF_FPX =5; // Flash Pix
TWFF_TIFFMULTI =6; // Multi-page tiff file
TWFF_PNG =7;
TWFF_SPIFF =8;
TWFF_EXIF =9;
TWSX_NATIVE =0;
TWSX_FILE =1;
TWSX_MEMORY =2;
type
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 = Word; // Unsinged integer !!!
TW_UINT32 = Longword;
TW_BOOL = Word; // Unsinged Short Boolean !!!
pTW_UINT16 = ^TW_UINT16;
TW_FIX32 = packed record // Fixed point structure type.
Whole : TW_INT16; // maintains the sign
Frac : TW_UINT16;
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_UINT16; // How the data is compressed (TWCP_xxxx)
end;
pTW_IMAGEINFO = ^TW_IMAGEINFO;
TW_ONEVALUE = packed record
ItemType: TW_UINT16;
Item : TW_UINT32;
end;
pTW_ONEVALUE = ^TW_ONEVALUE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -