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.

219 lines
8.2 KiB

  1. /**************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2001
  4. *
  5. * TITLE: FScam.h
  6. *
  7. * VERSION: 1.0
  8. *
  9. * DATE: 15 Nov, 2000
  10. *
  11. * DESCRIPTION:
  12. * File System Device object library
  13. *
  14. ***************************************************************************/
  15. //
  16. // Macro for getting size of array
  17. //
  18. #ifndef ARRAYSIZE
  19. #define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
  20. #endif
  21. #ifndef _CAMAPI_H
  22. #define _CAMAPI_H
  23. //
  24. // GetItemData state bit masks
  25. //
  26. const LONG STATE_NEXT = 0x00;
  27. const LONG STATE_FIRST = 0x01;
  28. const LONG STATE_LAST = 0x02;
  29. const LONG STATE_CANCEL = 0x04;
  30. //
  31. // Constants and structures for supporting a generic camera
  32. //
  33. typedef LONG FORMAT_CODE;
  34. /*
  35. const FORMAT_CODE TYPE_UNKNOWN = 0x00;
  36. const FORMAT_CODE TYPE_FOLDER = 0x01;
  37. const FORMAT_CODE TYPE_TXT = 0x02;
  38. const FORMAT_CODE TYPE_HTML = 0x03;
  39. const FORMAT_CODE TYPE_RTF = 0x04;
  40. const FORMAT_CODE TYPE_DPOF = 0x05;
  41. const FORMAT_CODE TYPE_AIFF = 0x06;
  42. const FORMAT_CODE TYPE_WAV = 0x07;
  43. const FORMAT_CODE TYPE_MP3 = 0x08;
  44. const FORMAT_CODE TYPE_AVI = 0x09;
  45. const FORMAT_CODE TYPE_MPEG = 0x0a;
  46. const FORMAT_CODE TYPE_UNKNOWNIMG = 0x10;
  47. const FORMAT_CODE TYPE_JPEG = 0x11;
  48. const FORMAT_CODE TYPE_TIFF = 0x12;
  49. const FORMAT_CODE TYPE_FLASHPIX = 0x13;
  50. const FORMAT_CODE TYPE_BMP = 0x14;
  51. const FORMAT_CODE TYPE_DIB = 0x15;
  52. const FORMAT_CODE TYPE_GIF = 0x16;
  53. const FORMAT_CODE TYPE_JPEG2000 = 0x17;
  54. const FORMAT_CODE TYPE_IMAGEMASK = 0x10;
  55. */
  56. typedef struct _DEVICE_INFO {
  57. BOOL bSyncNeeded; // Should be set if the driver can get out-of-sync with the camera (i.e. for serial cameras)
  58. BSTR FirmwareVersion; // String allocated and freed by camera library
  59. LONG PicturesTaken; // Number of pictures stored on the camera
  60. LONG PicturesRemaining; // Space available on the camera, in pictures at the current resolution
  61. LONG TotalItems; // Total number of items on the camera, including folders, images, audio, etc.
  62. SYSTEMTIME Time; // Current time on the device
  63. LONG ExposureMode; // See WIA_DPC_EXPOSURE_MODE
  64. LONG ExposureComp; // See WIA_DPC_EXPOSURE_COMP
  65. } DEVICE_INFO, *PDEVICE_INFO;
  66. typedef struct _ITEM_INFO {
  67. struct _ITEM_INFO
  68. *Parent; // Pointer to this item's parent, equal to ROOT_ITEM if this is a top level item
  69. BSTR pName; // String allocated and freed by camera library
  70. SYSTEMTIME Time; // Last modified time of the item
  71. FORMAT_CODE Format; // Index to g_FormatInfo[] array.
  72. BOOL bHasAttachments; // Indicates whether an image has attachments
  73. LONG Width; // Width of the image in pixels, zero for non-images
  74. LONG Height; // Height of the image in pixels, zero for non-images
  75. LONG Depth; // Pixel depth in pixels (e.g. 8, 16, 24)
  76. LONG Channels; // Number of color channels per pixel (e.g. 1, 3)
  77. LONG BitsPerChannel; // Number of bits per color channel, normally 8
  78. LONG Size; // Size of the image in bytes
  79. LONG SequenceNum; // If image is part of a sequence, the sequence number
  80. // FORMAT_CODE ThumbFormat; // Indicates the format of the thumbnail
  81. LONG ThumbWidth; // Width of thumbnail (can be set to zero until thumbnail is read by app)
  82. LONG ThumbHeight; // Height of thumbnail (can be set to zero until thumbnail is read by app)
  83. BOOL bReadOnly; // Indicates if item can or cannot be deleted by app
  84. BOOL bCanSetReadOnly; // Indicates if the app can change the read-only status on and off
  85. BOOL bIsFolder; // Indicates if the item is a folder
  86. } ITEM_INFO, *PITEM_INFO;
  87. typedef ITEM_INFO *ITEM_HANDLE;
  88. const ITEM_HANDLE ROOT_ITEM_HANDLE = NULL;
  89. typedef CWiaArray<ITEM_HANDLE> ITEM_HANDLE_ARRAY;
  90. #define FFD_ALLOCATION_INCREMENT 64 // this must be a power of 2 !!!
  91. typedef struct _FSUSD_FILE_DATA {
  92. DWORD dwFileAttributes;
  93. FILETIME ftFileTime;
  94. DWORD dwFileSize;
  95. TCHAR cFileName[MAX_PATH];
  96. DWORD dwProcessed;
  97. } FSUSD_FILE_DATA, *PFSUSD_FILE_DATA;
  98. #ifndef FORMAT_INFO_STRUCTURE
  99. #define FORMAT_INFO_STRUCTURE
  100. #define MAXEXTENSIONSTRINGLENGTH 8
  101. typedef struct _FORMAT_INFO
  102. {
  103. GUID FormatGuid; // WIA format GUID
  104. WCHAR ExtensionString[MAXEXTENSIONSTRINGLENGTH]; // File extension
  105. LONG ItemType; // WIA item type
  106. } FORMAT_INFO, *PFORMAT_INFO;
  107. #endif
  108. //
  109. // Generic camera class definition
  110. //
  111. class FakeCamera
  112. {
  113. public:
  114. //
  115. // Methods for accessing the camera
  116. //
  117. FakeCamera();
  118. ~FakeCamera();
  119. HRESULT Open(LPWSTR pPortName);
  120. HRESULT Close();
  121. HRESULT GetDeviceInfo(DEVICE_INFO *pDeviceInfo);
  122. VOID FreeDeviceInfo(DEVICE_INFO *pDeviceInfo);
  123. HRESULT GetItemList(ITEM_HANDLE *pItemArray);
  124. HRESULT SearchDirEx(ITEM_HANDLE_ARRAY *pItemArray,
  125. ITEM_HANDLE ParentHandle, LPOLESTR Path);
  126. HRESULT SearchForAttachments(ITEM_HANDLE_ARRAY *pItemArray,
  127. ITEM_HANDLE ParentHandle, LPOLESTR Path, FSUSD_FILE_DATA *pFFD, DWORD dwNumFiles);
  128. HRESULT CreateFolderEx(ITEM_HANDLE ParentHandle,
  129. FSUSD_FILE_DATA *pFindData, ITEM_HANDLE *pFolderHandle);
  130. HRESULT CreateItemEx(ITEM_HANDLE ParentHandle,
  131. FSUSD_FILE_DATA *pFileData, ITEM_HANDLE *pImageHandle, UINT nFormatCode);
  132. VOID ConstructFullName(WCHAR *pFullName, ITEM_INFO *pItemInfo, BOOL bAddExt = TRUE);
  133. VOID FreeItemInfo(ITEM_INFO *pItemInfo);
  134. HRESULT GetNativeThumbnail(ITEM_HANDLE ItemHandle, int *pThumbSize, BYTE **ppThumb);
  135. HRESULT CreateThumbnail(ITEM_HANDLE ItemHandle, int *pThumbSize, BYTE **ppThumb, BMP_IMAGE_INFO *pBmpInfo);
  136. HRESULT CreateVideoThumbnail(ITEM_HANDLE ItemHandle, int *pThumbSize, BYTE **ppThumb, BMP_IMAGE_INFO *pBmpInfo);
  137. VOID FreeThumbnail(BYTE *pThumb);
  138. HRESULT GetItemData(ITEM_HANDLE ItemHandle, LONG lState, BYTE *pBuf, DWORD lLength);
  139. HRESULT DeleteItem(ITEM_HANDLE ItemHandle);
  140. HRESULT TakePicture(ITEM_HANDLE *pItemHandle);
  141. HRESULT Status();
  142. HRESULT Reset();
  143. ULONG GetImageTypeFromFilename(WCHAR *pFilename, UINT *pFormatCode);
  144. void SetWiaLog(IWiaLog **ppILog) { m_pIWiaLog = *ppILog; };
  145. private:
  146. WCHAR m_RootPath[MAX_PATH];
  147. ITEM_HANDLE_ARRAY m_ItemHandles;
  148. int m_NumImages;
  149. int m_NumItems;
  150. HANDLE m_hFile;
  151. IWiaLog *m_pIWiaLog;
  152. public:
  153. FORMAT_INFO *m_FormatInfo;
  154. UINT m_NumFormatInfo;
  155. };
  156. //
  157. // Constants for reading Exif files
  158. //
  159. const WORD TIFF_XRESOLUTION = 0x11a;
  160. const WORD TIFF_YRESOLUTION = 0x11b;
  161. const WORD TIFF_JPEG_DATA = 0x201;
  162. const WORD TIFF_JPEG_LEN = 0x202;
  163. const int APP1_OFFSET = 6; // Offset between the start of the APP1 segment and the start of the TIFF tags
  164. //
  165. // Structures for reading Exif files
  166. //
  167. typedef struct _DIR_ENTRY
  168. {
  169. WORD Tag;
  170. WORD Type;
  171. DWORD Count;
  172. DWORD Offset;
  173. } DIR_ENTRY, *PDIR_ENTRY;
  174. typedef struct _IFD
  175. {
  176. DWORD Offset;
  177. WORD Count;
  178. DIR_ENTRY *pEntries;
  179. DWORD NextIfdOffset;
  180. } IFD, *PIFD;
  181. //
  182. // Functions for reading Exif files
  183. //
  184. HRESULT ReadDimFromJpeg(LPOLESTR FullName, WORD *pWidth, WORD *pHeight);
  185. HRESULT ReadJpegHdr(LPOLESTR FileName, BYTE **ppBuf);
  186. HRESULT ReadExifJpeg(BYTE *pBuf, IFD *pImageIfd, IFD *pThumbIfd, BOOL *pbSwap);
  187. HRESULT ReadTiff(BYTE *pBuf, IFD *pImageIfd, IFD *pThumbIfd, BOOL *pbSwap);
  188. HRESULT ReadIfd(BYTE *pBuf, IFD *pIfd, BOOL bSwap);
  189. VOID FreeIfd(IFD *pIfd);
  190. WORD ByteSwapWord(WORD w);
  191. DWORD ByteSwapDword(DWORD dw);
  192. WORD GetWord(BYTE *pBuf, BOOL bSwap);
  193. DWORD GetDword(BYTE *pBuf, BOOL bSwap);
  194. DWORD GetRational(BYTE *pBuf, BOOL bSwap);
  195. #endif // #ifndef _CAMAPI_H