⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eztwain.h

📁 扫描仪设置
💻 H
📖 第 1 页 / 共 2 页
字号:
// EZTWAIN.H - interface to Easy TWAIN library
//
// EZTWAIN is not a product, and is not the work of any company involved
// in promoting or using the TWAIN standard.  This code is sample code,
// provided without charge, and you use it entirely at your own risk.
// No rights or ownership is claimed by the author, or by any company
// or organization.  There are no restrictions on use or (re)distribution.
//
// 0.0	05/11/94	created
// 1.0a	06/23/94	first alpha version
// 1.04 05/03/95	added: WriteNativeToFile, WriteNativeToFilename,
//					FreeNative, SetHideUI, GetHideUI, SetCurrentUnits,
//					GetCurrentUnits, SetCurrentResolution, SetBitDepth,
//					SetCurrentPixelType, SetCapOneValue.
// 1.05 11/06/96	32-bit conversion
// 1.06 08/21/97        correction to message hook, fixed 32-bit exports

#ifndef EZTWAIN_H
#define EZTWAIN_H

#ifndef _WINDOWS_
#include "windows.h"
#endif

#ifdef __cplusplus
extern "C" {            /* Assume C declarations for C++ */
#endif	/* __cplusplus */

/*#ifndef EZTAPI
  #ifdef _WIN32
	 #define EZTAPI WINAPI
  #else
	 #define EZTAPI FAR PASCAL
  #endif
#endif replace with below -- dsn */
#ifndef EZTAPI
  #ifdef _WIN32
	 #define EZTAPI _stdcall
  #else
	 #define EZTAPI FAR PASCAL
  #endif
#endif

//--------- Basic calls

HANDLE EZTAPI TWAIN_AcquireNative(HWND hwndApp, unsigned wPixTypes);
// The minimal use of EZTWAIN.DLL is to just call this routine, with 0 for
// both params.  EZTWAIN creates a window if hwndApp is 0.
//
// Acquires a single image, from the currently selected Data Source, using
// Native-mode transfer. It waits until the source closes (if it's modal) or
// forces the source closed if not.  The return value is a handle to the
// acquired image.  Only one image can be acquired per call.
//
// Under Windows, the return value is a global memory handle - applying
// GlobalLock to it will return a (huge) pointer to the DIB, which
// starts with a BITMAPINFOHEADER.
// NOTE: You are responsible for disposing of the returned DIB - these things
// can eat up your Windows memory fast!  See TWAIN_FreeNative below.
//
// The image type can be restricted using the following masks.  A mask of 0
// means 'any pixel type is welcome'.
// Caution: You should not assume that the source will honor a pixel type
// restriction!  If you care, check the parameters of the DIB.

#define TWAIN_BW		0x0001	// 1-bit per pixel, B&W 	(== TWPT_BW)
#define TWAIN_GRAY		0x0002	// 1,4, or 8-bit grayscale  (== TWPT_GRAY)
#define TWAIN_RGB		0x0004	// 24-bit RGB color         (== TWPT_RGB)
#define TWAIN_PALETTE	0x0008	// 1,4, or 8-bit palette    (== TWPT_PALETTE)
#define TWAIN_ANYTYPE	0x0000	// any of the above

void EZTAPI TWAIN_FreeNative(HANDLE hdib);
// Release the memory allocated to a native format image, as returned by
// TWAIN_AcquireNative. (If you are coding in C or C++, this is just a call
// to GlobalFree.)
// If you use TWAIN_AcquireNative and don't free the returned image handle,
// it stays around taking up Windows (virtual) memory until your application
// terminates.  Memory required per square inch:
//             1 bit B&W       8-bit grayscale     24-bit color
// 100 dpi      1.25KB              10KB               30KB
// 200 dpi        5KB               40KB              120KB
// 300 dpi      11.25KB             90KB              270KB
// 400 dpi       20KB              160KB              480KB
//

int EZTAPI TWAIN_AcquireToClipboard(HWND hwndApp, unsigned wPixTypes);
// Like AcquireNative, but puts the resulting image, if any, into the system
// clipboard.  Under Windows, this will put a CF_DIB item in the clipboard
// if successful.  If this call fails, the clipboard is either empty or
// contains the old contents.
// A return value of 1 indicates success, 0 indicates failure.
//
// Useful for environments like Visual Basic where it is hard to make direct
// use of a DIB handle.  In fact, TWAIN_AcquireToClipboard uses
// TWAIN_AcquireNative for all the hard work.

int EZTAPI TWAIN_AcquireToFilename(HWND hwndApp, char *pszFile);
// Acquire an image and write it to a .BMP (Windows Bitmap) file.
// The file name and path in pszFile are used.  If pszFile is NULL or
// points to an empty string, the user is prompted with a Save File dialog.
// Return values:
// -1 means the Acquire failed.
//  0 means the Save failed (or was cancelled)
//  1 indicates success.

int EZTAPI TWAIN_SelectImageSource(HWND hwnd);
// This is the routine to call when the user chooses the "Select Source..."
// menu command from your application's File menu.  Your app has one of
// these, right?  The TWAIN spec calls for this feature to be available in
// your user interface, preferably as described.
// Note: If only one TWAIN device is installed on a system, it is selected
// automatically, so there is no need for the user to do Select Source.
// You should not require your users to do Select Source before Acquire.
//
// This function posts the Source Manager's Select Source dialog box.
// It returns after the user either OK's or CANCEL's that dialog.
// A return of 1 indicates OK, 0 indicates one of the following:
//   a) The user cancelled the dialog
//   b) The Source Manager found no data sources installed
//   c) There was a failure before the Select Source dialog could be posted
// -- details --
// Only sources that can return images (that are in the DG_IMAGE group) are
// displayed.  The current default source will be highlighted initially.
// In the standard implementation of "Select Source...", your application
// doesn't need to do anything except make this one call.
//
// If you want to be meticulous, disable your "Acquire" and "Select Source"
// menu items or buttons if TWAIN_IsAvailable() returns 0 - see below.


//--------- Basic TWAIN Inquiries

int EZTAPI TWAIN_IsAvailable(void);
// Call this function any time to find out if TWAIN is installed on the
// system.  It takes a little time on the first call, after that it's fast,
// just testing a flag.  It returns 1 if the TWAIN Source Manager is
// installed & can be loaded, 0 otherwise. 


int EZTAPI TWAIN_EasyVersion(void);
// Returns the version number of EZTWAIN.DLL, multiplied by 100.
// So e.g. version 2.01 will return 201 from this call.

int EZTAPI TWAIN_State(void);
// Returns the TWAIN Protocol State per the spec.
#define TWAIN_PRESESSION		1	// source manager not loaded
#define TWAIN_SM_LOADED			2	// source manager loaded
#define TWAIN_SM_OPEN			3	// source manager open
#define TWAIN_SOURCE_OPEN		4	// source open but not enabled
#define TWAIN_SOURCE_ENABLED	5	// source enabled to acquire
#define TWAIN_TRANSFER_READY	6	// image ready to transfer
#define TWAIN_TRANSFERRING		7	// image in transit

//--------- Callback mechanism -------------
// Added by DSN 7/98, this allows the user to specify an
// optional callback function to be called each time a new image comes
// in.  This can be a potentially powerful way to increase the primary
// application's efficiency, because upon receipt of an hdib the app
// could start a background thread to begin processing the images as
// needed.  Why bother with this?  Because on my Pentium 150, the Windows
// NT task monitor indicates that when I download images at 112kbps that
// I'm only using 15% of the processor's power, and the remaining 85% of
// the time it is idle!  It's silly to wait to begin processing because
// there's so much untapped processing capacity here.

typedef void (EZTAPI *HDIBCALLBACKPROC)(HANDLE, int);
void EZTAPI TWAIN_RegisterCallback(HDIBCALLBACKPROC *fxn);
void EZTAPI TWAIN_UnRegisterCallback();

//--------- DIB handling utilities ---------
// The next three functions were added by DSN 7/98
// They are used to clear the list of hDibs as well as provide
// access to the total number of images scanned and access any
// particular image's hDib.

void EZTAPI TWAIN_ClearDibList(void);
int EZTAPI TWAIN_GetNumDibs();
HANDLE EZTAPI TWAIN_GetDib(int n);

int EZTAPI TWAIN_DibDepth(HANDLE hdib);
// Depth of DIB, in bits i.e. bits per pixel.
int EZTAPI TWAIN_DibWidth(HANDLE hdib);
// Width of DIB, in pixels (columns)
int EZTAPI TWAIN_DibHeight(HANDLE hdib);
// Height of DIB, in lines (rows)
int EZTAPI TWAIN_DibNumColors(HANDLE hdib);
// Number of colors in color table of DIB

HPALETTE EZTAPI TWAIN_CreateDibPalette(HANDLE hdib);
// Create and return a logical palette to be used for drawing the DIB.
// For 1, 4, and 8-bit DIBs the palette contains the DIB color table.
// For 24-bit DIBs, a default halftone palette is returned.

void EZTAPI TWAIN_DrawDibToDC(
		HDC hDC,		// destination device context
		int dx, int dy,	// destination (x,y)
		int w, int h,	// width and height
		HANDLE hdib,	// DIB handle
		int sx, int sy	// source (x,y) in DIB
		);
// Draws a DIB on a device context.
// You should call CreateDibPalette, select that palette
// into the DC, and do a RealizePalette(hDC) first.

//--------- BMP file utilities
 
int EZTAPI TWAIN_WriteNativeToFilename(HANDLE hdib, LPCSTR pszFile);
// Writes a DIB handle to a .BMP file
//
// hdib		= DIB handle, as returned by TWAIN_AcquireNative
// pszFile	= far pointer to NUL-terminated filename
// If pszFile is NULL or points to a null string, prompts the user
// for the filename with a standard file-save dialog.
//
// Return values:
//	 0	success
//	-1	user cancelled File Save dialog
//	-2	file open error (invalid path or name, or access denied)
//	-3	(weird) unable to lock DIB - probably an invalid handle.
//	-4	writing BMP data failed, possibly output device is full

int EZTAPI TWAIN_WriteNativeToFile(HANDLE hdib, HFILE fh);
// Writes a DIB to a file in .BMP format.
//
// hdib		= DIB handle, as returned by TWAIN_AcquireNative
// fh		= file handle, as returned by _open, _lopen or OpenFile
//
// Return value as for TWAIN_WriteNativeToFilename

HANDLE EZTAPI TWAIN_LoadNativeFromFilename(LPCSTR pszFile);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -