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.

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