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.

1105 lines
34 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1999-2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * imaging.h
  8. *
  9. * Abstract:
  10. *
  11. * Public SDK header file for the imaging library
  12. *
  13. * Notes:
  14. *
  15. * This is hand-coded for now. Eventually it'll be automatically
  16. * generated from an IDL file.
  17. *
  18. * Revision History:
  19. *
  20. * 05/10/1999 davidx
  21. * Created it.
  22. *
  23. \**************************************************************************/
  24. #ifndef _IMAGING_H
  25. #define _IMAGING_H
  26. #include "..\sdkinc\GdiplusPixelFormats.h"
  27. #include "..\sdkinc\GdiplusImaging.h"
  28. //
  29. // Imaging library GUIDS:
  30. // image file format identifiers
  31. // interface and class identifers
  32. //
  33. #include "imgguids.h"
  34. // Default bitmap resolution
  35. #define DEFAULT_RESOLUTION 96 // most display screens are set to 96 dpi
  36. // Default thumbnail image size in pixels
  37. #define DEFAULT_THUMBNAIL_SIZE 120
  38. //
  39. // Image Property types
  40. //
  41. #define TAG_TYPE_BYTE 1 // 8-bit unsigned int
  42. #define TAG_TYPE_ASCII 2 // 8-bit byte containing one 7-bit ASCII code.
  43. // NULL terminated.
  44. #define TAG_TYPE_SHORT 3 // 16-bit unsigned int
  45. #define TAG_TYPE_LONG 4 // 32-bit unsigned int
  46. #define TAG_TYPE_RATIONAL 5 // Two LONGs. The first LONG is the numerator,
  47. // the second LONG expresses the denomintor.
  48. #define TAG_TYPE_UNDEFINED 7 // 8-bit byte that can take any value depending
  49. // on field definition
  50. #define TAG_TYPE_SLONG 9 // 32-bit singed integer (2's compliment
  51. // notation)
  52. #define TAG_TYPE_SRATIONAL 10 // Two SLONGs. First is numerator, second is
  53. // denominator.
  54. //
  55. // Image property ID tags (PROPID's from the EXIF tags)
  56. //
  57. #define TAG_EXIF_IFD 0x8769
  58. #define TAG_GPS_IFD 0x8825
  59. #define TAG_NEW_SUBFILE_TYPE 0x00FE
  60. #define TAG_SUBFILE_TYPE 0x00FF
  61. #define TAG_IMAGE_WIDTH 0x0100
  62. #define TAG_IMAGE_HEIGHT 0x0101
  63. #define TAG_BITS_PER_SAMPLE 0x0102
  64. #define TAG_COMPRESSION 0x0103
  65. #define TAG_PHOTOMETRIC_INTERP 0x0106
  66. #define TAG_THRESH_HOLDING 0x0107
  67. #define TAG_CELL_WIDTH 0x0108
  68. #define TAG_CELL_HEIGHT 0x0109
  69. #define TAG_FILL_ORDER 0x010A
  70. #define TAG_DOCUMENT_NAME 0x010D
  71. #define TAG_IMAGE_DESCRIPTION 0x010E
  72. #define TAG_EQUIP_MAKE 0x010F
  73. #define TAG_EQUIP_MODEL 0x0110
  74. #define TAG_STRIP_OFFSETS 0x0111
  75. #define TAG_ORIENTATION 0x0112
  76. #define TAG_SAMPLES_PER_PIXEL 0x0115
  77. #define TAG_ROWS_PER_STRIP 0x0116
  78. #define TAG_STRIP_BYTES_COUNT 0x0117
  79. #define TAG_MIN_SAMPLE_VALUE 0x0118
  80. #define TAG_MAX_SAMPLE_VALUE 0x0119
  81. #define TAG_X_RESOLUTION 0x011A // Image resolution in width direction
  82. #define TAG_Y_RESOLUTION 0x011B // Image resolution in height direction
  83. #define TAG_PLANAR_CONFIG 0x011C // Image data arrangement
  84. #define TAG_PAGE_NAME 0x011D
  85. #define TAG_X_POSITION 0x011E
  86. #define TAG_Y_POSITION 0x011F
  87. #define TAG_FREE_OFFSET 0x0120
  88. #define TAG_FREE_BYTE_COUNTS 0x0121
  89. #define TAG_GRAY_RESPONSE_UNIT 0x0122
  90. #define TAG_GRAY_RESPONSE_CURVE 0x0123
  91. #define TAG_T4_OPTION 0x0124
  92. #define TAG_T6_OPTION 0x0125
  93. #define TAG_RESOLUTION_UNIT 0x0128 // Unit of X and Y resolution
  94. #define TAG_PAGE_NUMBER 0x0129
  95. #define TAG_TRANSFER_FUNCTION 0x012D
  96. #define TAG_SOFTWARE_USED 0x0131
  97. #define TAG_DATE_TIME 0x0132
  98. #define TAG_ARTIST 0x013B
  99. #define TAG_HOST_COMPUTER 0x013C
  100. #define TAG_PREDICTOR 0x013D
  101. #define TAG_WHITE_POINT 0x013E
  102. #define TAG_PRIMAY_CHROMATICS 0x013F
  103. #define TAG_COLOR_MAP 0x0140
  104. #define TAG_HALFTONE_HINTS 0x0141
  105. #define TAG_TILE_WIDTH 0x0142
  106. #define TAG_TILE_LENGTH 0x0143
  107. #define TAG_TILE_OFFSET 0x0144
  108. #define TAG_TILE_BYTE_COUNTS 0x0145
  109. #define TAG_INK_SET 0x014C
  110. #define TAG_INK_NAMES 0x014D
  111. #define TAG_NUMBER_OF_INKS 0x014E
  112. #define TAG_DOT_RANGE 0x0150
  113. #define TAG_TARGET_PRINTER 0x0151
  114. #define TAG_EXTRA_SAMPLES 0x0152
  115. #define TAG_SAMPLE_FORMAT 0x0153
  116. #define TAG_SMIN_SAMPLE_VALUE 0x0154
  117. #define TAG_SMAX_SAMPLE_VALUE 0x0155
  118. #define TAG_TRANSFER_RANGE 0x0156
  119. #define TAG_JPEG_PROC 0x0200
  120. #define TAG_JPEG_INTER_FORMAT 0x0201
  121. #define TAG_JPEG_INTER_LENGTH 0x0202
  122. #define TAG_JPEG_RESTART_INTERVAL 0x0203
  123. #define TAG_JPEG_LOSSLESS_PREDICTORS 0x0205
  124. #define TAG_JPEG_POINT_TRANSFORMS 0x0206
  125. #define TAG_JPEG_Q_TABLES 0x0207
  126. #define TAG_JPEG_DC_TABLES 0x0208
  127. #define TAG_JPEG_AC_TABLES 0x0209
  128. #define TAG_YCbCr_COEFFICIENTS 0x0211
  129. #define TAG_YCbCr_SUBSAMPLING 0x0212
  130. #define TAG_YCbCr_POSITIONING 0x0213
  131. #define TAG_REF_BLACK_WHITE 0x0214
  132. // ICC profile and gamma
  133. #define TAG_ICC_PROFILE 0x8773 // This TAG is defined by ICC
  134. // for embedded ICC in TIFF
  135. #define TAG_GAMMA 0x0301
  136. #define TAG_ICC_PROFILE_DESCRIPTOR 0x0302
  137. #define TAG_SRGB_RENDERING_INTENT 0x0303
  138. #define TAG_IMAGE_TITLE 0x0320
  139. #define TAG_COPYRIGHT 0x8298
  140. // Extra TAGs (Like Adobe Image Information tags etc.)
  141. #define TAG_RESOLUTION_X_UNIT 0x5001
  142. #define TAG_RESOLUTION_Y_UNIT 0x5002
  143. #define TAG_RESOLUTION_X_LENGTH_UNIT 0x5003
  144. #define TAG_RESOLUTION_Y_LENGTH_UNIT 0x5004
  145. #define TAG_PRINT_FLAGS 0x5005
  146. #define TAG_PRINT_FLAGS_VERSION 0x5006
  147. #define TAG_PRINT_FLAGS_CROP 0x5007
  148. #define TAG_PRINT_FLAGS_BLEEDWIDTH 0x5008
  149. #define TAG_PRINT_FLAGS_BLEEDWIDTHSCALE 0x5009
  150. #define TAG_HALFTONE_LPI 0x500A
  151. #define TAG_HALFTONE_LPI_UNIT 0x500B
  152. #define TAG_HALFTONE_DEGREE 0x500C
  153. #define TAG_HALFTONE_SHAPE 0x500D
  154. #define TAG_HALFTONE_MISC 0x500E
  155. #define TAG_HALFTONE_SCREEN 0x500F
  156. #define TAG_JPEG_QUALITY 0x5010
  157. #define TAG_GRID_SIZE 0x5011
  158. #define TAG_THUMBNAIL_FORMAT 0x5012 // 1 = JPEG, 0 = RAW RGB
  159. #define TAG_THUMBNAIL_WIDTH 0x5013
  160. #define TAG_THUMBNAIL_HEIGHT 0x5014
  161. #define TAG_THUMBNAIL_COLORDEPTH 0x5015
  162. #define TAG_THUMBNAIL_PLANES 0x5016
  163. #define TAG_THUMBNAIL_RAWBYTES 0x5017
  164. #define TAG_THUMBNAIL_SIZE 0x5018
  165. #define TAG_THUMBNAIL_COMPRESSED_SIZE 0x5019
  166. #define TAG_COLORTRANSFER_FUNCTION 0x501A
  167. #define TAG_THUMBNAIL_DATA 0x501B // RAW thumbnail bits in JPEG
  168. // format or RGB format depends
  169. // on TAG_THUMBNAIL_FORMAT
  170. // Thumbnail related TAGs
  171. #define TAG_THUMBNAIL_IMAGE_WIDTH 0x5020 // Thumbnail width
  172. #define TAG_THUMBNAIL_IMAGE_HEIGHT 0x5021 // Thumbnail height
  173. #define TAG_THUMBNAIL_BITS_PER_SAMPLE 0x5022 // Number of bits per component
  174. #define TAG_THUMBNAIL_COMPRESSION 0x5023 // Compression Scheme
  175. #define TAG_THUMBNAIL_PHOTOMETRIC_INTERP 0x5024 // Pixel composition
  176. #define TAG_THUMBNAIL_IMAGE_DESCRIPTION 0x5025 // Image Tile
  177. #define TAG_THUMBNAIL_EQUIP_MAKE 0x5026 // Manufacturer of Image Input
  178. // equipment
  179. #define TAG_THUMBNAIL_EQUIP_MODEL 0x5027 // Model of Image input
  180. // equipment
  181. #define TAG_THUMBNAIL_STRIP_OFFSETS 0x5028 // Image data location
  182. #define TAG_THUMBNAIL_ORIENTATION 0x5029 // Orientation of image
  183. #define TAG_THUMBNAIL_SAMPLES_PER_PIXEL 0x502A // Number of components
  184. #define TAG_THUMBNAIL_ROWS_PER_STRIP 0x502B // Number of rows per strip
  185. #define TAG_THUMBNAIL_STRIP_BYTES_COUNT 0x502C // Bytes per compressed strip
  186. #define TAG_THUMBNAIL_RESOLUTION_X 0x502D // Resolution in width direction
  187. #define TAG_THUMBNAIL_RESOLUTION_Y 0x502E // Resolution in height direc
  188. #define TAG_THUMBNAIL_PLANAR_CONFIG 0x502F // Image data arrangement
  189. #define TAG_THUMBNAIL_RESOLUTION_UNIT 0x5030 // Unit of X and Y Resolution
  190. #define TAG_THUMBNAIL_TRANSFER_FUNCTION 0x5031 // Transfer function
  191. #define TAG_THUMBNAIL_SOFTWARE_USED 0x5032 // Software used
  192. #define TAG_THUMBNAIL_DATE_TIME 0x5033 // File change date and time
  193. #define TAG_THUMBNAIL_ARTIST 0x5034 // Person who created the image
  194. #define TAG_THUMBNAIL_WHITE_POINT 0x5035 // White point chromaticity
  195. #define TAG_THUMBNAIL_PRIMAY_CHROMATICS 0x5036 // Chromaticities of primaries
  196. #define TAG_THUMBNAIL_YCbCr_COEFFICIENTS 0x5037 // Color space transformation
  197. // coefficients
  198. #define TAG_THUMBNAIL_YCbCr_SUBSAMPLING 0x5038 // Subsampling ratio of Y to C
  199. #define TAG_THUMBNAIL_YCbCr_POSITIONING 0x5039 // Y and C position
  200. #define TAG_THUMBNAIL_REF_BLACK_WHITE 0x503A // Pair of black and white
  201. // reference values
  202. #define TAG_THUMBNAIL_COPYRIGHT 0x503B // CopyRight holder
  203. #define TAG_INTEROP_INDEX 0x5041 // InteroperabilityIndex
  204. #define TAG_INTEROP_EXIFR98VER 0x5042 // ExifR98 Version
  205. // Special JPEG internal values
  206. #define TAG_LUMINANCE_TABLE 0x5090
  207. #define TAG_CHROMINANCE_TABLE 0x5091
  208. // GIF image
  209. #define TAG_FRAMEDELAY 0x5100
  210. #define TAG_LOOPCOUNT 0x5101
  211. // PNG Image
  212. #define TAG_PIXEL_UNIT 0x5110 // Unit specifier for pixel/unit
  213. #define TAG_PIXEL_PER_UNIT_X 0x5111 // Pixels per unit in X
  214. #define TAG_PIXEL_PER_UNIT_Y 0x5112 // Pixels per unit in Y
  215. #define TAG_PALETTE_HISTOGRAM 0x5113 // Palette histogram
  216. // EXIF specific tag
  217. #define EXIF_TAG_EXPOSURE_TIME 0x829A
  218. #define EXIF_TAG_F_NUMBER 0x829D
  219. #define EXIF_TAG_EXPOSURE_PROG 0x8822
  220. #define EXIF_TAG_SPECTRAL_SENSE 0x8824
  221. #define EXIF_TAG_ISO_SPEED 0x8827
  222. #define EXIF_TAG_OECF 0x8828
  223. #define EXIF_TAG_VER 0x9000
  224. #define EXIF_TAG_D_T_ORIG 0x9003 // Date & time of original
  225. #define EXIF_TAG_D_T_DIGITIZED 0x9004 // Date & time of digital data generation
  226. #define EXIF_TAG_COMP_CONFIG 0x9101
  227. #define EXIF_TAG_COMP_BPP 0x9102
  228. #define EXIF_TAG_SHUTTER_SPEED 0x9201
  229. #define EXIF_TAG_APERATURE 0x9202
  230. #define EXIF_TAG_BRIGHTNESS 0x9203
  231. #define EXIF_TAG_EXPOSURE_BIAS 0x9204
  232. #define EXIF_TAG_MAX_APERATURE 0x9205
  233. #define EXIF_TAG_SUBJECT_DIST 0x9206
  234. #define EXIF_TAG_METERING_MODE 0x9207
  235. #define EXIF_TAG_LIGHT_SOURCE 0x9208
  236. #define EXIF_TAG_FLASH 0x9209
  237. #define EXIF_TAG_FOCAL_LENGTH 0x920A
  238. #define EXIF_TAG_MAKER_NOTE 0x927C
  239. #define EXIF_TAG_USER_COMMENT 0x9286
  240. #define EXIF_TAG_D_T_SUBSEC 0x9290 // Date & Time subseconds
  241. #define EXIF_TAG_D_T_ORIG_SS 0x9291 // Date & Time original subseconds
  242. #define EXIF_TAG_D_T_DIG_SS 0x9292 // Date & TIme digitized subseconds
  243. #define EXIF_TAG_FPX_VER 0xA000
  244. #define EXIF_TAG_COLOR_SPACE 0xA001
  245. #define EXIF_TAG_PIX_X_DIM 0xA002
  246. #define EXIF_TAG_PIX_Y_DIM 0xA003
  247. #define EXIF_TAG_RELATED_WAV 0xA004 // related sound file
  248. #define EXIF_TAG_INTEROP 0xA005
  249. #define EXIF_TAG_FLASH_ENERGY 0xA20B
  250. #define EXIF_TAG_SPATIAL_FR 0xA20C // Spatial Frequency Response
  251. #define EXIF_TAG_FOCAL_X_RES 0xA20E // Focal Plane X Resolution
  252. #define EXIF_TAG_FOCAL_Y_RES 0xA20F // Focal Plane Y Resolution
  253. #define EXIF_TAG_FOCAL_RES_UNIT 0xA210 // Focal Plane Resolution Unit
  254. #define EXIF_TAG_SUBJECT_LOC 0xA214
  255. #define EXIF_TAG_EXPOSURE_INDEX 0xA215
  256. #define EXIF_TAG_SENSING_METHOD 0xA217
  257. #define EXIF_TAG_FILE_SOURCE 0xA300
  258. #define EXIF_TAG_SCENE_TYPE 0xA301
  259. #define EXIF_TAG_CFA_PATTERN 0xA302
  260. #define GPS_TAG_VER 0x0000
  261. #define GPS_TAG_LATTITUDE_REF 0x0001
  262. #define GPS_TAG_LATTITUDE 0x0002
  263. #define GPS_TAG_LONGITUDE_REF 0x0003
  264. #define GPS_TAG_LONGITUDE 0x0004
  265. #define GPS_TAG_ALTITUDE_REF 0x0005
  266. #define GPS_TAG_ALTITUDE 0x0006
  267. #define GPS_TAG_GPS_TIME 0x0007
  268. #define GPS_TAG_GPS_SATELLITES 0x0008
  269. #define GPS_TAG_GPS_STATUS 0x0009
  270. #define GPS_TAG_GPS_MEASURE_MODE 0x00A
  271. #define GPS_TAG_GPS_DOP 0x000B // Measurement precision
  272. #define GPS_TAG_SPEED_REF 0x000C
  273. #define GPS_TAG_SPEED 0x000D
  274. #define GPS_TAG_TRACK_REF 0x000E
  275. #define GPS_TAG_TRACK 0x000F
  276. #define GPS_TAG_IMG_DIR_REF 0x0010
  277. #define GPS_TAG_IMG_DIR 0x0011
  278. #define GPS_TAG_MAP_DATUM 0x0012
  279. #define GPS_TAG_DEST_LAT_REF 0x0013
  280. #define GPS_TAG_DEST_LAT 0x0014
  281. #define GPS_TAG_DEST_LONG_REF 0x0015
  282. #define GPS_TAG_DEST_LONG 0x0016
  283. #define GPS_TAG_DEST_BEAR_REF 0x0017
  284. #define GPS_TAG_DEST_BEAR 0x0018
  285. #define GPS_TAG_DEST_DIST_REF 0x0019
  286. #define GPS_TAG_DEST_DIST 0x001A
  287. #define MAKEARGB(a, r, g, b) \
  288. (((ARGB) ((a) & 0xff) << ALPHA_SHIFT) | \
  289. ((ARGB) ((r) & 0xff) << RED_SHIFT) | \
  290. ((ARGB) ((g) & 0xff) << GREEN_SHIFT) | \
  291. ((ARGB) ((b) & 0xff) << BLUE_SHIFT))
  292. typedef PixelFormat PixelFormatID;
  293. // Map COM Flags to GDI+ Flags
  294. #define PIXFMTFLAG_INDEXED PixelFormatIndexed
  295. #define PIXFMTFLAG_GDI PixelFormatGDI
  296. #define PIXFMTFLAG_ALPHA PixelFormatAlpha
  297. #define PIXFMTFLAG_PALPHA PixelFormatPAlpha
  298. #define PIXFMTFLAG_EXTENDED PixelFormatExtended
  299. #define PIXFMTFLAG_CANONICAL PixelFormatCanonical
  300. #define PIXFMT_UNDEFINED PixelFormatUndefined
  301. #define PIXFMT_DONTCARE PixelFormatDontCare
  302. #define PIXFMT_1BPP_INDEXED PixelFormat1bppIndexed
  303. #define PIXFMT_4BPP_INDEXED PixelFormat4bppIndexed
  304. #define PIXFMT_8BPP_INDEXED PixelFormat8bppIndexed
  305. #define PIXFMT_16BPP_GRAYSCALE PixelFormat16bppGrayScale
  306. #define PIXFMT_16BPP_RGB555 PixelFormat16bppRGB555
  307. #define PIXFMT_16BPP_RGB565 PixelFormat16bppRGB565
  308. #define PIXFMT_16BPP_ARGB1555 PixelFormat16bppARGB1555
  309. #define PIXFMT_24BPP_RGB PixelFormat24bppRGB
  310. #define PIXFMT_32BPP_RGB PixelFormat32bppRGB
  311. #define PIXFMT_32BPP_ARGB PixelFormat32bppARGB
  312. #define PIXFMT_32BPP_PARGB PixelFormat32bppPARGB
  313. #define PIXFMT_48BPP_RGB PixelFormat48bppRGB
  314. #define PIXFMT_64BPP_ARGB PixelFormat64bppARGB
  315. #define PIXFMT_64BPP_PARGB PixelFormat64bppPARGB
  316. #define PIXFMT_24BPP_BGR (15 | (24 << 8) | PixelFormatGDI)
  317. #define PIXFMT_MAX PixelFormatMax + 1
  318. #define PALFLAG_HASALPHA PaletteFlagsHasAlpha
  319. #define PALFLAG_GRAYSCALE PaletteFlagsGrayScale
  320. #define PALFLAG_HALFTONE PaletteFlagsHalftone
  321. #define IMGLOCK_READ ImageLockModeRead
  322. #define IMGLOCK_WRITE ImageLockModeWrite
  323. #define IMGLOCK_USERINPUTBUF ImageLockModeUserInputBuf
  324. #define IMGFLAG_NONE ImageFlagsNone
  325. #define IMGFLAG_SCALABLE ImageFlagsScalable
  326. #define IMGFLAG_HASALPHA ImageFlagsHasAlpha
  327. #define IMGFLAG_HASTRANSLUCENT ImageFlagsHasTranslucent
  328. #define IMGFLAG_PARTIALLY_SCALABLE ImageFlagsPartiallyScalable
  329. #define IMGFLAG_COLORSPACE_RGB ImageFlagsColorSpaceRGB
  330. #define IMGFLAG_COLORSPACE_CMYK ImageFlagsColorSpaceCMYK
  331. #define IMGFLAG_COLORSPACE_GRAY ImageFlagsColorSpaceGRAY
  332. #define IMGFLAG_COLORSPACE_YCBCR ImageFlagsColorSpaceYCBCR
  333. #define IMGFLAG_COLORSPACE_YCCK ImageFlagsColorSpaceYCCK
  334. #define IMGFLAG_HASREALDPI ImageFlagsHasRealDPI
  335. #define IMGFLAG_HASREALPIXELSIZE ImageFlagsHasRealPixelSize
  336. #define IMGFLAG_READONLY ImageFlagsReadOnly
  337. #define IMGFLAG_CACHING ImageFlagsCaching
  338. #define ImageFlag ImageFlags
  339. //
  340. // Decoder flags
  341. //
  342. /* Only used in COM interface */
  343. enum DecoderInitFlag
  344. {
  345. DecoderInitFlagNone = 0,
  346. // NOBLOCK indicates that the caller requires non-blocking
  347. // behavior. This will be honored only by non-blocking decoders, that
  348. // is, decoders that don't have the IMGCODEC_BLOCKING_DECODE flag.
  349. DecoderInitFlagNoBlock = 0x0001,
  350. // Choose built-in decoders first before looking at any
  351. // installed plugin decoders.
  352. DecoderInitFlagBuiltIn1st = 0x0002
  353. };
  354. #define DECODERINIT_NONE DecoderInitFlagNone
  355. #define DECODERINIT_NOBLOCK DecoderInitFlagNoBlock
  356. #define DECODERINIT_BUILTIN1ST DecoderInitFlagBuiltIn1st
  357. /* Only used in COM interface */
  358. enum BufferDisposalFlag
  359. {
  360. BufferDisposalFlagNone,
  361. BufferDisposalFlagGlobalFree,
  362. BufferDisposalFlagCoTaskMemFree,
  363. BufferDisposalFlagUnmapView
  364. };
  365. #define DISPOSAL_NONE BufferDisposalFlagNone
  366. #define DISPOSAL_GLOBALFREE BufferDisposalFlagGlobalFree
  367. #define DISPOSAL_COTASKMEMFREE BufferDisposalFlagCoTaskMemFree
  368. #define DISPOSAL_UNMAPVIEW BufferDisposalFlagUnmapView
  369. //---------------------------------------------------------------------------
  370. // Intepolation hints used by resize/rotation operations
  371. //---------------------------------------------------------------------------
  372. enum InterpolationHint
  373. {
  374. InterpolationHintDefault,
  375. InterpolationHintNearestNeighbor,
  376. InterpolationHintBilinear,
  377. InterpolationHintAveraging,
  378. InterpolationHintBicubic
  379. };
  380. #define INTERP_DEFAULT InterpolationHintDefault
  381. #define INTERP_NEAREST_NEIGHBOR InterpolationHintNearestNeighbor
  382. #define INTERP_BILINEAR InterpolationHintBilinear
  383. #define INTERP_AVERAGING InterpolationHintAveraging
  384. #define INTERP_BICUBIC InterpolationHintBicubic
  385. #define IMGCODEC_ENCODER ImageCodecFlagsEncoder
  386. #define IMGCODEC_DECODER ImageCodecFlagsDecoder
  387. #define IMGCODEC_SUPPORT_BITMAP ImageCodecFlagsSupportBitmap
  388. #define IMGCODEC_SUPPORT_VECTOR ImageCodecFlagsSupportVector
  389. #define IMGCODEC_SEEKABLE_ENCODE ImageCodecFlagsSeekableEncode
  390. #define IMGCODEC_BLOCKING_DECODE ImageCodecFlagsBlockingDecode
  391. #define IMGCODEC_BUILTIN ImageCodecFlagsBuiltin
  392. #define IMGCODEC_SYSTEM ImageCodecFlagsSystem
  393. #define IMGCODEC_USER ImageCodecFlagsUser
  394. //
  395. // Identifier for channel(s) in a pixel
  396. //
  397. /* Only used internally */
  398. enum ChannelID
  399. {
  400. ChannelID_Alpha = 0x00000001,
  401. ChannelID_Red = 0x00000002,
  402. ChannelID_Green = 0x00000004,
  403. ChannelID_Blue = 0x00000008,
  404. ChannelID_Color = ChannelID_Red|ChannelID_Green|ChannelID_Blue,
  405. ChannelID_All = ChannelID_Color|ChannelID_Alpha,
  406. ChannelID_Intensity = 0x00010000
  407. };
  408. //
  409. // Data structure for communicating to an image sink
  410. //
  411. /* Only used internally */
  412. enum SinkFlags
  413. {
  414. // Low-word: shared with ImgFlagx
  415. SinkFlagsScalable = ImageFlagsScalable,
  416. SinkFlagsHasAlpha = ImageFlagsHasAlpha,
  417. SinkFlagsPartiallyScalable = ImageFlagsPartiallyScalable,
  418. // High-word
  419. SinkFlagsTopDown = 0x00010000,
  420. SinkFlagsBottomUp = 0x00020000,
  421. SinkFlagsFullWidth = 0x00040000,
  422. SinkFlagsMultipass = 0x00080000,
  423. SinkFlagsComposite = 0x00100000,
  424. SinkFlagsWantProps = 0x00200000
  425. };
  426. #define SINKFLAG_SCALABLE SinkFlagsScalable
  427. #define SINKFLAG_HASALPHA SinkFlagsHasAlpha
  428. #define SINKFLAG_PARTIALLY_SCALABLE SinkFlagsPartiallyScalable
  429. #define SINKFLAG_TOPDOWN SinkFlagsTopDown
  430. #define SINKFLAG_BOTTOMUP SinkFlagsBottomUp
  431. #define SINKFLAG_FULLWIDTH SinkFlagsFullWidth
  432. #define SINKFLAG_MULTIPASS SinkFlagsMultipass
  433. #define SINKFLAG_COMPOSITE SinkFlagsComposite
  434. #define SINKFLAG_WANTPROPS SinkFlagsWantProps
  435. /* Only used internally */
  436. struct ImageInfo
  437. {
  438. GUID RawDataFormat;
  439. PixelFormat PixelFormat;
  440. UINT Width, Height;
  441. UINT TileWidth, TileHeight;
  442. double Xdpi, Ydpi;
  443. UINT Flags;
  444. };
  445. //
  446. // Interface and class identifiers
  447. //
  448. interface IImagingFactory;
  449. interface IImage;
  450. interface IBitmapImage;
  451. interface IImageDecoder;
  452. interface IImageEncoder;
  453. interface IImageSink;
  454. interface IBasicBitmapOps;
  455. //--------------------------------------------------------------------------
  456. // Imaging utility factory object
  457. // This is a CoCreate-able object.
  458. //--------------------------------------------------------------------------
  459. MIDL_INTERFACE("327ABDA7-072B-11D3-9D7B-0000F81EF32E")
  460. IImagingFactory : public IUnknown
  461. {
  462. public:
  463. // Create an image object from an input stream
  464. // stream doesn't have to seekable
  465. // caller should Release the stream if call is successful
  466. STDMETHOD(CreateImageFromStream)(
  467. IN IStream* stream,
  468. OUT IImage** image
  469. ) = 0;
  470. // Create an image object from a file
  471. STDMETHOD(CreateImageFromFile)(
  472. IN const WCHAR* filename,
  473. OUT IImage** image
  474. ) = 0;
  475. // Create an image object from a memory buffer
  476. STDMETHOD(CreateImageFromBuffer)(
  477. IN const VOID* buf,
  478. IN UINT size,
  479. IN BufferDisposalFlag disposalFlag,
  480. OUT IImage** image
  481. ) = 0;
  482. // Create a new bitmap image object
  483. STDMETHOD(CreateNewBitmap)(
  484. IN UINT width,
  485. IN UINT height,
  486. IN PixelFormatID pixelFormat,
  487. OUT IBitmapImage** bitmap
  488. ) = 0;
  489. // Create a bitmap image from an IImage object
  490. STDMETHOD(CreateBitmapFromImage)(
  491. IN IImage* image,
  492. IN OPTIONAL UINT width,
  493. IN OPTIONAL UINT height,
  494. IN OPTIONAL PixelFormatID pixelFormat,
  495. IN InterpolationHint hints,
  496. OUT IBitmapImage** bitmap
  497. ) = 0;
  498. // Create a new bitmap image object on user-supplied memory buffer
  499. STDMETHOD(CreateBitmapFromBuffer)(
  500. IN BitmapData* bitmapData,
  501. OUT IBitmapImage** bitmap
  502. ) = 0;
  503. // Create an image decoder object to process the given input stream
  504. STDMETHOD(CreateImageDecoder)(
  505. IN IStream* stream,
  506. IN DecoderInitFlag flags,
  507. OUT IImageDecoder** decoder
  508. ) = 0;
  509. // Create an image encoder object that can output data in the
  510. // specified image file format.
  511. STDMETHOD(CreateImageEncoderToStream)(
  512. IN const CLSID* clsid,
  513. IN IStream* stream,
  514. OUT IImageEncoder** encoder
  515. ) = 0;
  516. STDMETHOD(CreateImageEncoderToFile)(
  517. IN const CLSID* clsid,
  518. IN const WCHAR* filename,
  519. OUT IImageEncoder** encoder
  520. ) = 0;
  521. // Get a list of all currently installed image decoders
  522. STDMETHOD(GetInstalledDecoders)(
  523. OUT UINT* count,
  524. OUT ImageCodecInfo** decoders
  525. ) = 0;
  526. // Get a list of all currently installed image decoders
  527. STDMETHOD(GetInstalledEncoders)(
  528. OUT UINT* count,
  529. OUT ImageCodecInfo** encoders
  530. ) = 0;
  531. // Install an image encoder / decoder
  532. // caller should do the regular COM component
  533. // installation before calling this method
  534. STDMETHOD(InstallImageCodec)(
  535. IN const ImageCodecInfo* codecInfo
  536. ) = 0;
  537. // Uninstall an image encoder / decoder
  538. STDMETHOD(UninstallImageCodec)(
  539. IN const WCHAR* codecName,
  540. IN UINT flags
  541. ) = 0;
  542. };
  543. //--------------------------------------------------------------------------
  544. // Image interface
  545. // bitmap image
  546. // vector image
  547. // procedural image
  548. //--------------------------------------------------------------------------
  549. MIDL_INTERFACE("327ABDA9-072B-11D3-9D7B-0000F81EF32E")
  550. IImage : public IUnknown
  551. {
  552. public:
  553. // Get the device-independent physical dimension of the image
  554. // in unit of 0.01mm
  555. STDMETHOD(GetPhysicalDimension)(
  556. OUT SIZE* size
  557. ) = 0;
  558. // Get basic image info
  559. STDMETHOD(GetImageInfo)(
  560. OUT ImageInfo* imageInfo
  561. ) = 0;
  562. // Set image flags
  563. STDMETHOD(SetImageFlags)(
  564. IN UINT flags
  565. ) = 0;
  566. // Display the image in a GDI device context
  567. STDMETHOD(Draw)(
  568. IN HDC hdc,
  569. IN const RECT* dstRect,
  570. IN OPTIONAL const RECT* srcRect
  571. ) = 0;
  572. // Push image data into an IImageSink
  573. STDMETHOD(PushIntoSink)(
  574. IN IImageSink* sink
  575. ) = 0;
  576. // Get a thumbnail representation for the image object
  577. STDMETHOD(GetThumbnail)(
  578. IN OPTIONAL UINT thumbWidth,
  579. IN OPTIONAL UINT thumbHeight,
  580. OUT IImage** thumbImage
  581. ) = 0;
  582. };
  583. //--------------------------------------------------------------------------
  584. // Bitmap interface
  585. //--------------------------------------------------------------------------
  586. MIDL_INTERFACE("327ABDAA-072B-11D3-9D7B-0000F81EF32E")
  587. IBitmapImage : public IUnknown
  588. {
  589. public:
  590. // Get bitmap dimensions in pixels
  591. STDMETHOD(GetSize)(
  592. OUT SIZE* size
  593. ) = 0;
  594. // Get bitmap pixel format
  595. STDMETHOD(GetPixelFormatID)(
  596. OUT PixelFormatID* pixelFormat
  597. ) = 0;
  598. // Access bitmap data in the specified pixel format
  599. // must support at least PIXFMT_DONTCARE and
  600. // the caninocal formats.
  601. STDMETHOD(LockBits)(
  602. IN const RECT* rect,
  603. IN UINT flags,
  604. IN PixelFormatID pixelFormat,
  605. IN OUT BitmapData* lockedBitmapData
  606. ) = 0;
  607. STDMETHOD(UnlockBits)(
  608. IN const BitmapData* lockedBitmapData
  609. ) = 0;
  610. // Set/get palette associated with the bitmap image
  611. STDMETHOD(GetPalette)(
  612. OUT ColorPalette** palette
  613. ) = 0;
  614. STDMETHOD(SetPalette)(
  615. IN const ColorPalette* palette
  616. ) = 0;
  617. };
  618. //--------------------------------------------------------------------------
  619. // Interface for performing basic operations on a bitmap image
  620. // This can be QI'ed from an IBitmapImage object.
  621. //--------------------------------------------------------------------------
  622. MIDL_INTERFACE("327ABDAF-072B-11D3-9D7B-0000F81EF32E")
  623. IBasicBitmapOps : public IUnknown
  624. {
  625. public:
  626. // Clone an area of the bitmap image
  627. STDMETHOD(Clone)(
  628. IN OPTIONAL const RECT* rect,
  629. OUT IBitmapImage** outbmp,
  630. BOOL bNeedCloneProperty
  631. );
  632. // Flip the bitmap image in x- and/or y-direction
  633. STDMETHOD(Flip)(
  634. IN BOOL flipX,
  635. IN BOOL flipY,
  636. OUT IBitmapImage** outbmp
  637. ) = 0;
  638. // Resize the bitmap image
  639. STDMETHOD(Resize)(
  640. IN UINT newWidth,
  641. IN UINT newHeight,
  642. IN PixelFormatID pixelFormat,
  643. IN InterpolationHint hints,
  644. OUT IBitmapImage** outbmp
  645. ) = 0;
  646. // Rotate the bitmap image by the specified angle
  647. STDMETHOD(Rotate)(
  648. IN FLOAT angle,
  649. IN InterpolationHint hints,
  650. OUT IBitmapImage** outbmp
  651. ) = 0;
  652. // Adjust the brightness of the bitmap image
  653. STDMETHOD(AdjustBrightness)(
  654. IN FLOAT percent
  655. ) = 0;
  656. // Adjust the contrast of the bitmap image
  657. STDMETHOD(AdjustContrast)(
  658. IN FLOAT shadow,
  659. IN FLOAT highlight
  660. ) = 0;
  661. // Adjust the gamma of the bitmap image
  662. STDMETHOD(AdjustGamma)(
  663. IN FLOAT gamma
  664. ) = 0;
  665. };
  666. //--------------------------------------------------------------------------
  667. // Image decoder interface
  668. //--------------------------------------------------------------------------
  669. MIDL_INTERFACE("327ABDAB-072B-11D3-9D7B-0000F81EF32E")
  670. IImageDecoder : public IUnknown
  671. {
  672. public:
  673. // Initialize the image decoder object
  674. STDMETHOD(InitDecoder)(
  675. IN IStream* stream,
  676. IN DecoderInitFlag flags
  677. ) = 0;
  678. // Clean up the image decoder object
  679. STDMETHOD(TerminateDecoder)() = 0;
  680. // Start decoding the current frame
  681. STDMETHOD(BeginDecode)(
  682. IN IImageSink* sink,
  683. IN OPTIONAL IPropertySetStorage* newPropSet
  684. ) = 0;
  685. // Continue decoding
  686. STDMETHOD(Decode)() = 0;
  687. // Stop decoding the current frame
  688. STDMETHOD(EndDecode)(
  689. IN HRESULT statusCode
  690. ) = 0;
  691. // Query multi-frame dimensions
  692. STDMETHOD(GetFrameDimensionsCount)(
  693. OUT UINT* count
  694. ) = 0;
  695. STDMETHOD(GetFrameDimensionsList)(
  696. OUT GUID* dimensionIDs,
  697. IN OUT UINT count
  698. ) = 0;
  699. // Get number of frames for the specified dimension
  700. STDMETHOD(GetFrameCount)(
  701. IN const GUID* dimensionID,
  702. OUT UINT* count
  703. ) = 0;
  704. // Select currently active frame
  705. STDMETHOD(SelectActiveFrame)(
  706. IN const GUID* dimensionID,
  707. IN UINT frameIndex
  708. ) = 0;
  709. // Get basic information about the image
  710. STDMETHOD(GetImageInfo)(
  711. OUT ImageInfo* imageInfo
  712. ) = 0;
  713. // Get image thumbnail
  714. STDMETHOD(GetThumbnail)(
  715. IN OPTIONAL UINT thumbWidth,
  716. IN OPTIONAL UINT thumbHeight,
  717. OUT IImage** thumbImage
  718. ) = 0;
  719. // Query decoder parameters
  720. STDMETHOD(QueryDecoderParam)(
  721. IN GUID Guid
  722. ) = 0;
  723. // Set decoder parameters
  724. STDMETHOD(SetDecoderParam)(
  725. IN GUID Guid,
  726. IN UINT Length,
  727. IN PVOID Value
  728. ) = 0;
  729. // Property related functions
  730. STDMETHOD(GetPropertyCount)(
  731. OUT UINT* numOfProperty
  732. ) = 0;
  733. STDMETHOD(GetPropertyIdList)(
  734. IN UINT numOfProperty,
  735. IN OUT PROPID* list
  736. ) = 0;
  737. STDMETHOD(GetPropertyItemSize)(
  738. IN PROPID propId,
  739. OUT UINT* size
  740. ) = 0;
  741. STDMETHOD(GetPropertyItem)(
  742. IN PROPID propId,
  743. IN UINT propSize,
  744. IN OUT PropertyItem* buffer
  745. ) = 0;
  746. STDMETHOD(GetPropertySize)(
  747. OUT UINT* totalBufferSize,
  748. OUT UINT* numProperties
  749. ) = 0;
  750. STDMETHOD(GetAllPropertyItems)(
  751. IN UINT totalBufferSize,
  752. IN UINT numProperties,
  753. IN OUT PropertyItem* allItems
  754. ) = 0;
  755. STDMETHOD(RemovePropertyItem)(
  756. IN PROPID propId
  757. ) = 0;
  758. STDMETHOD(SetPropertyItem)(
  759. IN PropertyItem item
  760. ) = 0;
  761. STDMETHOD(GetRawInfo)(
  762. IN OUT VOID **ppRawInfo
  763. ) = 0;
  764. };
  765. //--------------------------------------------------------------------------
  766. // Image decode sink interface
  767. //--------------------------------------------------------------------------
  768. MIDL_INTERFACE("327ABDAE-072B-11D3-9D7B-0000F81EF32E")
  769. IImageSink : public IUnknown
  770. {
  771. public:
  772. // Begin the sink process
  773. STDMETHOD(BeginSink)(
  774. IN OUT ImageInfo* imageInfo,
  775. OUT OPTIONAL RECT* subarea
  776. ) = 0;
  777. // End the sink process
  778. STDMETHOD(EndSink)(
  779. IN HRESULT statusCode
  780. ) = 0;
  781. // Pass the color palette to the image sink
  782. STDMETHOD(SetPalette)(
  783. IN const ColorPalette* palette
  784. ) = 0;
  785. // Ask the sink to allocate pixel data buffer
  786. STDMETHOD(GetPixelDataBuffer)(
  787. IN const RECT* rect,
  788. IN PixelFormatID pixelFormat,
  789. IN BOOL lastPass,
  790. OUT BitmapData* bitmapData
  791. ) = 0;
  792. // Give the sink pixel data and release data buffer
  793. STDMETHOD(ReleasePixelDataBuffer)(
  794. IN const BitmapData* bitmapData
  795. ) = 0;
  796. // Push pixel data
  797. STDMETHOD(PushPixelData)(
  798. IN const RECT* rect,
  799. IN const BitmapData* bitmapData,
  800. IN BOOL lastPass
  801. ) = 0;
  802. // Push raw image data
  803. STDMETHOD(PushRawData)(
  804. IN const VOID* buffer,
  805. IN UINT bufsize
  806. ) = 0;
  807. STDMETHOD(NeedTransform)(
  808. OUT UINT* rotation
  809. ) = 0;
  810. STDMETHOD(NeedRawProperty)(
  811. IN void *pSrc) = 0;
  812. STDMETHOD(PushRawInfo)(
  813. IN OUT void* info
  814. ) = 0;
  815. STDMETHOD(GetPropertyBuffer)(
  816. IN UINT uiTotalBufferSize,
  817. IN OUT PropertyItem** ppBuffer
  818. ) = 0;
  819. STDMETHOD(PushPropertyItems)(
  820. IN UINT numOfItems,
  821. IN UINT uiTotalBufferSize,
  822. IN PropertyItem* item,
  823. IN BOOL fICCProfileChanged
  824. ) = 0;
  825. };
  826. //--------------------------------------------------------------------------
  827. // Image encoder interface
  828. //--------------------------------------------------------------------------
  829. MIDL_INTERFACE("327ABDAC-072B-11D3-9D7B-0000F81EF32E")
  830. IImageEncoder : public IUnknown
  831. {
  832. public:
  833. // Initialize the image encoder object
  834. STDMETHOD(InitEncoder)(
  835. IN IStream* stream
  836. ) = 0;
  837. // Clean up the image encoder object
  838. STDMETHOD(TerminateEncoder)() = 0;
  839. // Get an IImageSink interface for encoding the next frame
  840. STDMETHOD(GetEncodeSink)(
  841. OUT IImageSink** sink
  842. ) = 0;
  843. // Set active frame dimension
  844. STDMETHOD(SetFrameDimension)(
  845. IN const GUID* dimensionID
  846. ) = 0;
  847. STDMETHOD(GetEncoderParameterListSize)(
  848. OUT UINT* size
  849. ) = 0;
  850. STDMETHOD(GetEncoderParameterList)(
  851. IN UINT size,
  852. OUT EncoderParameters* Params
  853. ) = 0;
  854. STDMETHOD(SetEncoderParameters)(
  855. IN const EncoderParameters* Param
  856. ) = 0;
  857. };
  858. //--------------------------------------------------------------------------
  859. // Imaging library error codes
  860. //
  861. // !!! TODO
  862. // How does one pick a facility code?
  863. //
  864. // Standard error code used:
  865. // E_INVALIDARG
  866. // E_OUTOFMEMORY
  867. // E_NOTIMPL
  868. // E_ACCESSDENIED
  869. // E_PENDING
  870. //--------------------------------------------------------------------------
  871. #define FACILITY_IMAGING 0x87b
  872. #define MAKE_IMGERR(n) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_IMAGING, n)
  873. #define IMGERR_OBJECTBUSY MAKE_IMGERR(1)
  874. #define IMGERR_NOPALETTE MAKE_IMGERR(2)
  875. #define IMGERR_BADLOCK MAKE_IMGERR(3)
  876. #define IMGERR_BADUNLOCK MAKE_IMGERR(4)
  877. #define IMGERR_NOCONVERSION MAKE_IMGERR(5)
  878. #define IMGERR_CODECNOTFOUND MAKE_IMGERR(6)
  879. #define IMGERR_NOFRAME MAKE_IMGERR(7)
  880. #define IMGERR_ABORT MAKE_IMGERR(8)
  881. #define IMGERR_FAILLOADCODEC MAKE_IMGERR(9)
  882. #define IMGERR_PROPERTYNOTFOUND MAKE_IMGERR(10)
  883. #define IMGERR_PROPERTYNOTSUPPORTED MAKE_IMGERR(11)
  884. #endif // !_IMAGING_H