Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

245 lines
7.0 KiB

  1. /**************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2000
  4. *
  5. * TITLE: scanapi.h
  6. *
  7. * VERSION: 1.0
  8. *
  9. * DATE: 18 July, 2000
  10. *
  11. * DESCRIPTION:
  12. * Fake Scanner device library
  13. *
  14. ***************************************************************************/
  15. #ifndef _SCANAPI_H
  16. #define _SCANAPI_H
  17. #include "fscanapi.h"
  18. //
  19. // helpful utils.
  20. //
  21. #ifdef UNICODE
  22. #define TSTRSTR wcsstr
  23. #define TSSCANF swscanf
  24. #else
  25. #define TSTRSTR strstr
  26. #define TSSCANF sscanf
  27. #endif
  28. //
  29. // Event Thread
  30. //
  31. VOID FakeScannerEventThread( LPVOID lpParameter );
  32. //
  33. // event file names
  34. //
  35. #define SCANBUTTON_FILE TEXT("ScanButton.wia")
  36. #define COPYBUTTON_FILE TEXT("CopyButton.wia")
  37. #define FAXBUTTON_FILE TEXT("FaxButton.wia")
  38. #define ADF_FILE TEXT("ADF.wia")
  39. //
  40. // event headers
  41. //
  42. #define LOADPAGES_HEADER TEXT("[Load Pages]")
  43. #define LOADPAGES_PAGES TEXT("Pages=")
  44. #define ADFERRORS_HEADER TEXT("[ADF Error]")
  45. #define ADFERRORS_ERROR TEXT("Error=")
  46. #define ADFERRORS_JAM TEXT("jam")
  47. #define ADFERRORS_EMPTY TEXT("empty")
  48. #define ADFERRORS_PROBLEM TEXT("problem")
  49. #define ADFERRORS_GENERAL TEXT("general")
  50. #define ADFERRORS_OFFLINE TEXT("offline")
  51. //
  52. // Scanner device constants
  53. //
  54. #define MAX_SCANNING_TIME 40000 // 40 seconds
  55. #define MAX_LAMP_WARMUP_TIME 10000 // 10 seconds
  56. #define MAX_PAGE_CAPACITY 25 // 25 pages
  57. typedef struct _RAW_DATA_INFORMATION {
  58. LONG bpp; // bits per pixel;
  59. LONG lWidthPixels; // width of image in pixels
  60. LONG lHeightPixels; // height of image in pixels
  61. LONG lOffset; // raw copy offset from top of raw buffer;
  62. LONG lXRes; // x resolution
  63. LONG lYRes; // y resolution
  64. } RAW_DATA_INFORMATION,*PRAW_DATA_INFORMATION;
  65. class CFScanAPI :public CFakeScanAPI {
  66. public:
  67. //
  68. // constructor/destructor
  69. //
  70. CFScanAPI();
  71. ~CFScanAPI();
  72. //
  73. // device initialization function
  74. //
  75. HRESULT FakeScanner_Initialize();
  76. //
  77. // device setting functions
  78. //
  79. HRESULT FakeScanner_GetRootPropertyInfo(PROOT_ITEM_INFORMATION pRootItemInfo);
  80. HRESULT FakeScanner_GetTopPropertyInfo(PTOP_ITEM_INFORMATION pTopItemInfo);
  81. HRESULT FakeScanner_GetBedWidthAndHeight(PLONG pWidth, PLONG pHeight);
  82. //
  83. // device event functions
  84. //
  85. HRESULT FakeScanner_GetDeviceEvent(LONG *pEvent);
  86. VOID FakeScanner_SetInterruptEventHandle(HANDLE hEvent);
  87. HRESULT DoEventProcessing();
  88. //
  89. // data acquisition functions
  90. //
  91. HRESULT FakeScanner_Scan(LONG lState, PBYTE pData, DWORD dwBytesToRead, PDWORD pdwBytesWritten);
  92. HRESULT FakeScanner_SetDataType(LONG lDataType);
  93. HRESULT FakeScanner_SetXYResolution(LONG lXResolution, LONG lYResolution);
  94. HRESULT FakeScanner_SetSelectionArea(LONG lXPos, LONG lYPos, LONG lXExt, LONG lYExt);
  95. HRESULT FakeScanner_SetContrast(LONG lContrast);
  96. HRESULT FakeScanner_SetIntensity(LONG lIntensity);
  97. //
  98. // standard device operations
  99. //
  100. HRESULT FakeScanner_ResetDevice();
  101. HRESULT FakeScanner_SetEmulationMode(LONG lDeviceMode);
  102. HRESULT FakeScanner_DisableDevice();
  103. HRESULT FakeScanner_EnableDevice();
  104. HRESULT FakeScanner_DeviceOnline();
  105. HRESULT FakeScanner_Diagnostic();
  106. //
  107. // Automatic document feeder functions
  108. //
  109. HRESULT FakeScanner_ADFAttached();
  110. HRESULT FakeScanner_ADFHasPaper();
  111. HRESULT FakeScanner_ADFAvailable();
  112. HRESULT FakeScanner_ADFFeedPage();
  113. HRESULT FakeScanner_ADFUnFeedPage();
  114. HRESULT FakeScanner_ADFStatus();
  115. private:
  116. #ifdef _USE_BITMAP_DATA
  117. HANDLE m_hSrcFileHandle; // Source bitmap data file handle
  118. HANDLE m_hSrcMappingHandle; // Source file mapping handle
  119. BYTE* m_pSrcData; // Source DIB pointer (24-bit only)
  120. HANDLE m_hRawDataFileHandle; // RAW data file handle
  121. HANDLE m_hRawDataMappingHandle;// RAW data file mapping handle
  122. BYTE* m_pRawData; // RAW data pointer
  123. #endif
  124. HANDLE m_hEventHandle; // Event to signal for Interrupt events
  125. HANDLE m_hKillEventThread; // Event to signal for shutdown of internal Event thread
  126. HANDLE m_hEventNotifyThread; // Event Thread handle
  127. LONG m_lLastEvent; // Last Event ID
  128. LONG m_lMode; // Fake scanner library mode
  129. LONG m_PagesInADF; // Current number of pages in the ADF
  130. BOOL m_ADFIsAvailable; // ADF available TRUE/FALSE
  131. HRESULT m_hrLastADFError; // ADF errors
  132. FILETIME m_ftScanButton; // Last Scan button file time
  133. FILETIME m_ftCopyButton; // Last Copy button file time
  134. FILETIME m_ftFaxButton; // Last Fax button file time
  135. BOOL m_bGreen; // Are We Green?
  136. LONG m_dwBytesWrittenSoFAR; // How much data have we read so far?
  137. LONG m_TotalDataInDevice; // How much will we read total?
  138. protected:
  139. //
  140. // RAW and SRC data information members
  141. //
  142. RAW_DATA_INFORMATION m_RawDataInfo; // Information about RAW data
  143. RAW_DATA_INFORMATION m_SrcDataInfo; // Information about SRC data
  144. //
  145. // RAW data conversion functions
  146. //
  147. HRESULT Load24bitScanData(LPTSTR szBitmapFileName);
  148. HRESULT Raw24bitToRawXbitData(LONG DestDepth, BYTE* pDestBuffer, BYTE* pSrcBuffer, LONG lSrcWidth, LONG lSrcHeight);
  149. HRESULT Raw24bitToRaw1bitBW(BYTE* pDestBuffer, BYTE* pSrcBuffer, LONG lSrcWidth, LONG lSrcHeight);
  150. HRESULT Raw24bitToRaw8bitGray(BYTE* pDestBuffer, BYTE* pSrcBuffer, LONG lSrcWidth, LONG lSrcHeight);
  151. HRESULT Raw24bitToRaw24bitColor(BYTE* pDestBuffer, BYTE* pSrcBuffer, LONG lSrcWidth, LONG lSrcHeight);
  152. BOOL SrcToRAW();
  153. VOID CloseRAW();
  154. //
  155. // RAW data calculation helper functions
  156. //
  157. LONG WidthToDIBWidth(LONG lWidth);
  158. LONG CalcTotalImageSize();
  159. LONG CalcRawByteWidth();
  160. LONG CalcSrcByteWidth();
  161. LONG CalcRandomDeviceDataTotalBytes();
  162. //
  163. // Byron's Rock'n Scaling routine (handles UP and DOWN samples)
  164. //
  165. HRESULT BQADScale(BYTE* pSrcBuffer, LONG lSrcWidth, LONG lSrcHeight,LONG lSrcDepth,
  166. BYTE* pDestBuffer,LONG lDestWidth,LONG lDestHeight);
  167. //
  168. // event helper functions
  169. //
  170. HRESULT CreateButtonEventFiles();
  171. BOOL IsValidDeviceEvent();
  172. HRESULT ProcessADFEvent();
  173. //
  174. // event file names w/ path information
  175. //
  176. TCHAR m_ScanButtonFile[MAX_PATH];
  177. TCHAR m_CopyButtonFile[MAX_PATH];
  178. TCHAR m_FaxButtonFile[MAX_PATH];
  179. TCHAR m_ADFEventFile[MAX_PATH];
  180. //
  181. // debugger trace helper function
  182. //
  183. VOID Trace(LPCTSTR format,...);
  184. };
  185. //
  186. // FAKE SCANNER API Class pointer (used for Event Thread)
  187. //
  188. typedef CFakeScanAPI *PSCANNERDEVICE;
  189. HRESULT CreateInstance(CFakeScanAPI **ppFakeScanAPI, LONG lMode);
  190. #endif