Небольшой обзор.
В поставке есть пример для Xbase.
Он спокойно собирается Harbour , подключить нужно
только HBXPP для функций DLLCALL ,DLLUnload ,DLLLoad
#include "Common.ch"
#include "dtwain32.ch"
#include "dll.ch"
PROCEDURE Main
LOCAL TwainSource, nDLLHandle, TwainOK, status, fileOption
fileOption := DTWAIN_USENATIVE + DTWAIN_USELONGNAME
status := 0
// Load the DTWAIN DLL
nDLLHandle := DLLLoad( "DTWAIN32.DLL" )
// Check if TWAIN is available
TwainOK := DLLCall( nDLLHandle, DLL_STDCALL, "DTWAIN_IsTwainAvailable" )
IF TwainOK == 1
// Initialize DTWAIN
DLLCall ( nDLLHandle, DLL_STDCALL, "DTWAIN_SysInitialize" )
// Select a TWAIN Source
TwainSource := DLLCall( nDLLHandle, DLL_STDCALL, "DTWAIN_SelectSource2", 0, ;
"Select Source", 0, 0, DTWAIN_DLG_CENTER_SCREEN )
IF TwainSource <> 0
// Acquire a file
DLLCall ( nDLLHandle, DLL_STDCALL, "DTWAIN_AcquireFile", TwainSource, ;
"Test.bmp", DTWAIN_BMP, fileOption, DTWAIN_PT_DEFAULT, 1, 1, 1, @status )
ENDIF
// Uninitialize DTWAIN
DLLCall( nDLLHandle, DLL_STDCALL, "DTWAIN_SysDestroy" )
ENDIF
// Unload the DLL
DLLUnload( nDLLHandle )
RETURN
Функция DTWAIN_AcquireFile может сразу писать в разных графических форматах.
Проверил выборочно на JPG и WEBP , работает.
Вот список:
Скрытый текст #define DTWAIN_BMP 100 /* Windows BMP file */ #define DTWAIN_JPEG 200 /* JPEG - See DTWAIN_SetJpegValues */ #define DTWAIN_PDF 250 /* Adobe Acrobat PDF File */ #define DTWAIN_PDFMULTI 251 /* Multi-page PDF file */ #define DTWAIN_PCX 300 /* ZSoft file */ #define DTWAIN_DCX 301 /* Multi-page PCX file */ #define DTWAIN_TGA 400 /* TARGA */ #define DTWAIN_TIFFLZW 500 /* TIFF with LZW compression */ #define DTWAIN_TIFFNONE 600 /* Uncompressed TIFF */ #define DTWAIN_TIFFG3 700 /* Group 3 CCITT Tiff (FAX format) */ #define DTWAIN_TIFFG4 800 /* Group 4 CCITT Tiff (FAX format) */ #define DTWAIN_TIFFPACKBITS 801 /* Huffman encoded Tiff */ #define DTWAIN_TIFFDEFLATE 802 /* TIFF packed with z-lib encoded data*/ #define DTWAIN_TIFFJPEG 803 #define DTWAIN_TIFFJBIG 804 /* TIFF-JBIG compression (not implemented due to patent) */ #define DTWAIN_TIFFPIXARLOG 805 /* TIFF Pixar Log compression (not implemented )*/ #define DTWAIN_TIFFNONEMULTI 900 /* Multi-page TIFF, No compression by default */ #define DTWAIN_TIFFG3MULTI 901 /* Multi-page TIFF, Group 3 */ #define DTWAIN_TIFFG4MULTI 902 /* Multi-page TIFF, Group 4 */ #define DTWAIN_TIFFPACKBITSMULTI 903 /* Multi-page TIFF, Huffman encoded */ #define DTWAIN_TIFFDEFLATEMULTI 904 /* Multi-pageTIFF, zlib compression */ #define DTWAIN_TIFFJPEGMULTI 905 /* Multi-pageTIFF, JPEG compression */ #define DTWAIN_TIFFLZWMULTI 906 /* Multi-page TIFF, LZW compression */ #define DTWAIN_TIFFJBIGMULTI 907 /* Multi-page TIFF, JBIG compression (not implememted due to patent) */ #define DTWAIN_TIFFPIXARLOGMULTI 908 /* Multi-page TIFF Pixar Log compression (not implemented )*/ #define DTWAIN_WMF 850 /* Windows meta-file */ #define DTWAIN_EMF 851 /* Enhanced Windows meta-file */ #define DTWAIN_GIF 950 /* GIF Format */ #define DTWAIN_PNG 1000 /* Portable Network Graphics */ #define DTWAIN_PSD 2000 /* Adobe Photoshop PSD file */ #define DTWAIN_JPEG2000 3000 /* JPEG-2000 file */ #define DTWAIN_POSTSCRIPT1 4000 /* Postscript Level 1 */ #define DTWAIN_POSTSCRIPT2 4001 /* Postscript Level 2 */ #define DTWAIN_POSTSCRIPT3 4002 /* Postscript Level 3 */ #define DTWAIN_POSTSCRIPT1MULTI 4003 /* Postscript Level 1 Multipage */ #define DTWAIN_POSTSCRIPT2MULTI 4004 /* Postscript Level 2 Multipage */ #define DTWAIN_POSTSCRIPT3MULTI 4005 /* Postscript Level 3 Multipage */ #define DTWAIN_TEXT 6000 /* Text file produced from OCR */ #define DTWAIN_TEXTMULTI 6001 /* Multi-page text file */ #define DTWAIN_TIFFMULTI 7000 /* Only to be used for standalone OCR engines */ #define DTWAIN_ICO 8000 /* Windows ICO (icon) format */ #define DTWAIN_ICO_VISTA 8001 /* Windows ICO (icon) format for Vista and above OS */ #define DTWAIN_ICO_RESIZED 8002 /* Windows ICO (icon) format for bitmaps with height > 255 or width > 255 pixels */ #define DTWAIN_WBMP 8500 /* Wireless Bitmap (WBMP) format */ #define DTWAIN_WEBP 8501 /* Google webp format */ #define DTWAIN_PCD 9000 /* Kodak PCD */ #define DTWAIN_PBM 10000 /* Portable bitmap*/ #define DTWAIN_PPM DTWAIN_PBM /* Portable bitmap*/ #define DTWAIN_WBMP_RESIZED 11000 /* Wireless Bitmap (WBMP) format for bitmaps with height > 255 or width > 255 pixels */ #define DTWAIN_TGA_RLE 11001 /* Targa with Run Length Encoding */ #define DTWAIN_BMP_RLE 11002 /* BMP with Run Length Encoding */ #define DTWAIN_BIGTIFFLZW 11003 /* BigTIFF with LZW compression */ #define DTWAIN_BIGTIFFLZWMULTI 11004 /* BigTIFF with LZW compression, multipage */ #define DTWAIN_BIGTIFFNONE 11005 /* BigTIFF with no compression */ #define DTWAIN_BIGTIFFNONEMULTI 11006 /* BigTIFF with no compression, multipage */ #define DTWAIN_BIGTIFFPACKBITS 11007 /* BigTIFF with Packbits compression */ #define DTWAIN_BIGTIFFPACKBITSMULTI 11008 /* BigTIFF with Packbits compression, multipage */ #define DTWAIN_BIGTIFFDEFLATE 11009 /* BigTIFF packed with z-lib encoded data */ #define DTWAIN_BIGTIFFDEFLATEMULTI 11010 /* BigTIFF packed with z-lib encoded data (multipage) */ #define DTWAIN_BIGTIFFG3 11011 /* BigTIFF Group 3 CCITT Tiff (FAX format) */ #define DTWAIN_BIGTIFFG3MULTI 11012 /* BigTIFF Group 3 CCITT Tiff (FAX format) (multipage) */ #define DTWAIN_BIGTIFFG4 11013 /* BigTIFF Group 4 CCITT Tiff (FAX format) */ #define DTWAIN_BIGTIFFG4MULTI 11014 /* BigTIFF Group 4 CCITT Tiff (FAX format) (multipage) */ #define DTWAIN_BIGTIFFJPEG 11015 /* BigTIFF JPEG */ #define DTWAIN_BIGTIFFJPEGMULTI 11016 /* BigTIFF JPEG (Multipage) */
|
Что бы пример запустился , в папке с программой должны жить файлы:
dtwain32.dll
twaininfo.txt
dtwain32.ini
Странное решение конечно насчет twaininfo.txt и dtwain32.ini , ну да ладно.
DLL может быть как 32 битная так и 64 битная , так же они могут быть ANSI
или UNICODE , все есть в поставке.
Функций в DLL порядка 390. Копать и копать :)
Копал в общем тему по функции DTWAIN_SelectSource2 или DTWAIN_SelectSource ,
вернет она если был выбор TwainSource (Handle).
Как понять это камера или это сканер ?