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.

204 lines
6.2 KiB

  1. /**************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2002
  4. *
  5. * TITLE: scanapi.h
  6. *
  7. * VERSION: 1.1
  8. *
  9. * DATE: 08 March, 2002
  10. *
  11. * DESCRIPTION:
  12. * Fake Scanner device library
  13. *
  14. ***************************************************************************/
  15. #ifndef _SCANAPI_H
  16. #define _SCANAPI_H
  17. //
  18. // ID mappings to events
  19. //
  20. #define ID_FAKE_NOEVENT 0
  21. #define ID_FAKE_SCANBUTTON 100
  22. #define ID_FAKE_COPYBUTTON 200
  23. #define ID_FAKE_FAXBUTTON 300
  24. #define ID_FAKE_ADFEVENT 400
  25. //
  26. // Scanner library modes
  27. //
  28. #define FLATBED_SCANNER_MODE 100
  29. #define UNKNOWN_FEEDER_ONLY_SCANNER_MODE 200
  30. //
  31. // Scanning states
  32. //
  33. #define SCAN_START 0
  34. #define SCAN_CONTINUE 1
  35. #define SCAN_END 3
  36. //
  37. // Root Item information (for property initialization)
  38. //
  39. typedef struct _ROOT_ITEM_INFORMATION {
  40. LONG ScanBedWidth; // 1/1000ths of an inch
  41. LONG ScanBedHeight; // 1/1000ths of an inch
  42. LONG OpticalXResolution; // Optical X Resolution of device
  43. LONG OpticalYResolution; // Optical X Resolution of device
  44. LONG MaxScanTime; // Milliseconds (total scan time)
  45. LONG DocumentFeederWidth; // 1/1000ths of an inch
  46. LONG DocumentFeederHeight; // 1/1000ths of an inch
  47. LONG DocumentFeederCaps; // Capabilites of the device with feeder
  48. LONG DocumentFeederStatus; // Status of document feeder
  49. LONG MaxPageCapacity; // Maximum page capacity of feeder
  50. LONG DocumentFeederReg; // document feeder alignment
  51. LONG DocumentFeederHReg; // document feeder justification alignment (HORIZONTAL)
  52. LONG DocumentFeederVReg; // document feeder justification alignment (VERTICAL)
  53. WCHAR FirmwareVersion[25]; // Firmware version of device
  54. }ROOT_ITEM_INFORMATION, *PROOT_ITEM_INFORMATION;
  55. //
  56. // Range data type helper structure (used below)
  57. //
  58. typedef struct _RANGEPROPERTY {
  59. LONG lMin; // minimum value
  60. LONG lMax; // maximum value
  61. LONG lNom; // numinal value
  62. LONG lInc; // increment/step value
  63. } RANGEPROPERTY,*PRANGEPROPERTY;
  64. //
  65. // Top Item information (for property initialization)
  66. //
  67. typedef struct _TOP_ITEM_INFORMATION {
  68. BOOL bUseResolutionList; // TRUE - use default Resolution list,
  69. // FALSE - use RANGEPROPERTY values
  70. RANGEPROPERTY Contrast; // valid values for contrast
  71. RANGEPROPERTY Brightness; // valid values for brightness
  72. RANGEPROPERTY Threshold; // valid values for threshold
  73. RANGEPROPERTY XResolution; // valid values for x resolution
  74. RANGEPROPERTY YResolution; // valid values for y resolution
  75. LONG lMinimumBufferSize; // minimum buffer size
  76. LONG lMaxLampWarmupTime; // maximum lamp warmup time
  77. } TOP_ITEM_INFORMATION, *PTOP_ITEM_INFORMATION;
  78. //
  79. // Scanner device constants
  80. //
  81. #define MAX_SCANNING_TIME 40000 // 40 seconds
  82. #define MAX_LAMP_WARMUP_TIME 10000 // 10 seconds
  83. #define MAX_PAGE_CAPACITY 25 // 25 pages
  84. typedef struct _RAW_DATA_INFORMATION {
  85. LONG bpp; // bits per pixel;
  86. LONG lWidthPixels; // width of image in pixels
  87. LONG lHeightPixels; // height of image in pixels
  88. LONG lOffset; // raw copy offset from top of raw buffer;
  89. LONG lXRes; // x resolution
  90. LONG lYRes; // y resolution
  91. } RAW_DATA_INFORMATION,*PRAW_DATA_INFORMATION;
  92. class CFakeScanAPI {
  93. public:
  94. //
  95. // constructor/destructor
  96. //
  97. CFakeScanAPI();
  98. ~CFakeScanAPI();
  99. //
  100. // device initialization function
  101. //
  102. HRESULT FakeScanner_Initialize();
  103. //
  104. // device setting functions
  105. //
  106. HRESULT FakeScanner_GetRootPropertyInfo(PROOT_ITEM_INFORMATION pRootItemInfo);
  107. HRESULT FakeScanner_GetTopPropertyInfo(PTOP_ITEM_INFORMATION pTopItemInfo);
  108. HRESULT FakeScanner_GetBedWidthAndHeight(PLONG pWidth, PLONG pHeight);
  109. //
  110. // data acquisition functions
  111. //
  112. HRESULT FakeScanner_Scan(LONG lState, PBYTE pData, DWORD dwBytesToRead, PDWORD pdwBytesWritten);
  113. HRESULT FakeScanner_SetDataType(LONG lDataType);
  114. HRESULT FakeScanner_SetXYResolution(LONG lXResolution, LONG lYResolution);
  115. HRESULT FakeScanner_SetSelectionArea(LONG lXPos, LONG lYPos, LONG lXExt, LONG lYExt);
  116. HRESULT FakeScanner_SetContrast(LONG lContrast);
  117. HRESULT FakeScanner_SetIntensity(LONG lIntensity);
  118. //
  119. // standard device operations
  120. //
  121. HRESULT FakeScanner_ResetDevice();
  122. HRESULT FakeScanner_SetEmulationMode(LONG lDeviceMode);
  123. HRESULT FakeScanner_DisableDevice();
  124. HRESULT FakeScanner_EnableDevice();
  125. HRESULT FakeScanner_DeviceOnline();
  126. HRESULT FakeScanner_Diagnostic();
  127. //
  128. // Automatic document feeder functions
  129. //
  130. HRESULT FakeScanner_ADFAttached();
  131. HRESULT FakeScanner_ADFHasPaper();
  132. HRESULT FakeScanner_ADFAvailable();
  133. HRESULT FakeScanner_ADFFeedPage();
  134. HRESULT FakeScanner_ADFUnFeedPage();
  135. HRESULT FakeScanner_ADFStatus();
  136. private:
  137. LONG m_lLastEvent; // Last Event ID
  138. LONG m_lMode; // Fake scanner library mode
  139. LONG m_PagesInADF; // Current number of pages in the ADF
  140. BOOL m_ADFIsAvailable; // ADF available TRUE/FALSE
  141. HRESULT m_hrLastADFError; // ADF errors
  142. BOOL m_bGreen; // Are We Green?
  143. LONG m_dwBytesWrittenSoFAR; // How much data have we read so far?
  144. LONG m_TotalDataInDevice; // How much will we read total?
  145. protected:
  146. //
  147. // RAW and SRC data information members
  148. //
  149. RAW_DATA_INFORMATION m_RawDataInfo; // Information about RAW data
  150. RAW_DATA_INFORMATION m_SrcDataInfo; // Information about SRC data
  151. //
  152. // RAW data calculation helper functions
  153. //
  154. LONG WidthToDIBWidth(LONG lWidth);
  155. LONG CalcTotalImageSize();
  156. LONG CalcRawByteWidth();
  157. LONG CalcSrcByteWidth();
  158. LONG CalcRandomDeviceDataTotalBytes();
  159. };
  160. HRESULT CreateFakeScanner(CFakeScanAPI **ppFakeScanAPI, LONG lMode);
  161. #endif