/jxrgluelib/JXRGlue.h

https://github.com/curasystems/jxrlib · C Header · 637 lines · 429 code · 126 blank · 82 comment · 0 complexity · f787efa78f97108a80211c036112aa6a MD5 · raw file

  1. //*@@@+++@@@@******************************************************************
  2. //
  3. // Copyright © Microsoft Corp.
  4. // All rights reserved.
  5. //
  6. // Redistribution and use in source and binary forms, with or without
  7. // modification, are permitted provided that the following conditions are met:
  8. //
  9. // • Redistributions of source code must retain the above copyright notice,
  10. // this list of conditions and the following disclaimer.
  11. // • Redistributions in binary form must reproduce the above copyright notice,
  12. // this list of conditions and the following disclaimer in the documentation
  13. // and/or other materials provided with the distribution.
  14. //
  15. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  19. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. // POSSIBILITY OF SUCH DAMAGE.
  26. //
  27. //*@@@---@@@@******************************************************************
  28. #pragma once
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include <JXRMeta.h>
  33. #include <guiddef.h>
  34. //================================================================
  35. #define WMP_SDK_VERSION 0x0101
  36. #define PK_SDK_VERSION 0x0101
  37. #define sizeof2(array) (sizeof(array)/sizeof(*(array)))
  38. #ifndef max
  39. #define max(a,b) ((a) > (b) ? (a) : (b))
  40. #endif
  41. #ifndef min
  42. #define min(b,a) ((a) < (b) ? (a) : (b))
  43. #endif
  44. #ifdef __ANSI__
  45. //#define STRCPY_SAFE(pszDest, cbDest, pszSrc) (strcpy((pszDest), (pszSrc)) == (pszDest) ? 0 : 1)
  46. #define STRCPY_SAFE(pszDest, cbDest, pszSrc) (strlcpy((pszDest), (pszSrc), (cbDest)) < (cbDest) ? 0 : 1) // Macintosh impl, not ANSI
  47. #else
  48. #define STRCPY_SAFE(pszDest, cbDest, pszSrc) (strcpy_s((pszDest), (cbDest), (pszSrc)))
  49. #endif // __ANSI__
  50. //================================================================
  51. typedef struct tagPKRect
  52. {
  53. I32 X;
  54. I32 Y;
  55. I32 Width;
  56. I32 Height;
  57. } PKRect;
  58. //================================================================
  59. typedef U32 PKIID;
  60. EXTERN_C const PKIID IID_PKImageScanEncode;
  61. EXTERN_C const PKIID IID_PKImageFrameEncode;
  62. EXTERN_C const PKIID IID_PKImageWmpEncode;
  63. EXTERN_C const PKIID IID_PKImageWmpDecode;
  64. struct IFDEntry
  65. {
  66. U16 uTag;
  67. U16 uType;
  68. U32 uCount;
  69. U32 uValue;
  70. };
  71. EXTERN_C const U32 IFDEntryTypeSizes[13];
  72. EXTERN_C const U32 SizeofIFDEntry;
  73. //================================================================
  74. typedef float Float;
  75. typedef enum tagPKStreamFlags
  76. {
  77. PKStreamOpenRead = 0x00000000UL,
  78. PKStreamOpenWrite = 0x00000001UL,
  79. PKStreamOpenReadWrite = 0x00000002UL,
  80. PKStreamNoLock = 0x00010000UL,
  81. PKStreamNoSeek = 0x00020000UL,
  82. PKStreamCompress = 0x00040000UL,
  83. } PKStreamFlags;
  84. /* Undefined formats */
  85. #define GUID_PKPixelFormatUndefined GUID_PKPixelFormatDontCare
  86. DEFINE_GUID(GUID_PKPixelFormatDontCare, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x00);
  87. /* Indexed formats */
  88. //DEFINE_GUID(GUID_PKPixelFormat1bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x01);
  89. //DEFINE_GUID(GUID_PKPixelFormat2bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x02);
  90. //DEFINE_GUID(GUID_PKPixelFormat4bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x03);
  91. //DEFINE_GUID(GUID_PKPixelFormat8bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x04);
  92. DEFINE_GUID(GUID_PKPixelFormatBlackWhite, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x05);
  93. //DEFINE_GUID(GUID_PKPixelFormat2bppGray, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x06);
  94. //DEFINE_GUID(GUID_PKPixelFormat4bppGray, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x07);
  95. DEFINE_GUID(GUID_PKPixelFormat8bppGray, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x08);
  96. /* sRGB formats (gamma is approx. 2.2) */
  97. /* For a full definition, see the sRGB spec */
  98. /* 16bpp formats */
  99. DEFINE_GUID(GUID_PKPixelFormat16bppRGB555, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x09);
  100. DEFINE_GUID(GUID_PKPixelFormat16bppRGB565, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0a);
  101. DEFINE_GUID(GUID_PKPixelFormat16bppGray, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0b);
  102. /* 24bpp formats */
  103. DEFINE_GUID(GUID_PKPixelFormat24bppBGR, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0c);
  104. DEFINE_GUID(GUID_PKPixelFormat24bppRGB, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0d);
  105. /* 32bpp format */
  106. DEFINE_GUID(GUID_PKPixelFormat32bppBGR, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0e);
  107. DEFINE_GUID(GUID_PKPixelFormat32bppBGRA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0f);
  108. DEFINE_GUID(GUID_PKPixelFormat32bppPBGRA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x10);
  109. DEFINE_GUID(GUID_PKPixelFormat32bppGrayFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x11);
  110. DEFINE_GUID(GUID_PKPixelFormat32bppRGB, 0xd98c6b95, 0x3efe, 0x47d6, 0xbb, 0x25, 0xeb, 0x17, 0x48, 0xab, 0x0c, 0xf1);
  111. DEFINE_GUID(GUID_PKPixelFormat32bppRGBA, 0xf5c7ad2d, 0x6a8d, 0x43dd, 0xa7, 0xa8, 0xa2, 0x99, 0x35, 0x26, 0x1a, 0xe9);
  112. DEFINE_GUID(GUID_PKPixelFormat32bppPRGBA, 0x3cc4a650, 0xa527, 0x4d37, 0xa9, 0x16, 0x31, 0x42, 0xc7, 0xeb, 0xed, 0xba);
  113. /* 48bpp format */
  114. DEFINE_GUID(GUID_PKPixelFormat48bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x12);
  115. /* scRGB formats. Gamma is 1.0 */
  116. /* For a full definition, see the scRGB spec */
  117. /* 16bpp format */
  118. DEFINE_GUID(GUID_PKPixelFormat16bppGrayFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x13);
  119. /* 32bpp format */
  120. DEFINE_GUID(GUID_PKPixelFormat32bppRGB101010, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x14);
  121. /* 48bpp format */
  122. DEFINE_GUID(GUID_PKPixelFormat48bppRGB, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x15);
  123. /* 64bpp format */
  124. DEFINE_GUID(GUID_PKPixelFormat64bppRGBA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x16);
  125. DEFINE_GUID(GUID_PKPixelFormat64bppPRGBA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x17);
  126. /* 96bpp format */
  127. DEFINE_GUID(GUID_PKPixelFormat96bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x18);
  128. DEFINE_GUID(GUID_PKPixelFormat96bppRGBFloat, 0xe3fed78f, 0xe8db, 0x4acf, 0x84, 0xc1, 0xe9, 0x7f, 0x61, 0x36, 0xb3, 0x27);
  129. /* Floating point scRGB formats */
  130. DEFINE_GUID(GUID_PKPixelFormat128bppRGBAFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x19);
  131. DEFINE_GUID(GUID_PKPixelFormat128bppPRGBAFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1a);
  132. DEFINE_GUID(GUID_PKPixelFormat128bppRGBFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1b);
  133. /* CMYK formats. */
  134. DEFINE_GUID(GUID_PKPixelFormat32bppCMYK, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1c);
  135. /* Photon formats */
  136. DEFINE_GUID(GUID_PKPixelFormat64bppRGBAFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1d);
  137. DEFINE_GUID(GUID_PKPixelFormat64bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x40);
  138. DEFINE_GUID(GUID_PKPixelFormat128bppRGBAFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1e);
  139. DEFINE_GUID(GUID_PKPixelFormat128bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x41);
  140. DEFINE_GUID(GUID_PKPixelFormat64bppRGBAHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3a);
  141. DEFINE_GUID(GUID_PKPixelFormat64bppRGBHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x42);
  142. DEFINE_GUID(GUID_PKPixelFormat48bppRGBHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3b);
  143. DEFINE_GUID(GUID_PKPixelFormat32bppRGBE, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3d);
  144. DEFINE_GUID(GUID_PKPixelFormat16bppGrayHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3e);
  145. DEFINE_GUID(GUID_PKPixelFormat32bppGrayFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3f);
  146. /* More CMYK formats and n-Channel formats */
  147. DEFINE_GUID(GUID_PKPixelFormat64bppCMYK, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1f);
  148. DEFINE_GUID(GUID_PKPixelFormat24bpp3Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x20);
  149. DEFINE_GUID(GUID_PKPixelFormat32bpp4Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x21);
  150. DEFINE_GUID(GUID_PKPixelFormat40bpp5Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x22);
  151. DEFINE_GUID(GUID_PKPixelFormat48bpp6Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x23);
  152. DEFINE_GUID(GUID_PKPixelFormat56bpp7Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x24);
  153. DEFINE_GUID(GUID_PKPixelFormat64bpp8Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x25);
  154. DEFINE_GUID(GUID_PKPixelFormat48bpp3Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x26);
  155. DEFINE_GUID(GUID_PKPixelFormat64bpp4Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x27);
  156. DEFINE_GUID(GUID_PKPixelFormat80bpp5Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x28);
  157. DEFINE_GUID(GUID_PKPixelFormat96bpp6Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x29);
  158. DEFINE_GUID(GUID_PKPixelFormat112bpp7Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2a);
  159. DEFINE_GUID(GUID_PKPixelFormat128bpp8Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2b);
  160. DEFINE_GUID(GUID_PKPixelFormat40bppCMYKAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2c);
  161. DEFINE_GUID(GUID_PKPixelFormat80bppCMYKAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2d);
  162. DEFINE_GUID(GUID_PKPixelFormat32bpp3ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2e);
  163. DEFINE_GUID(GUID_PKPixelFormat40bpp4ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2f);
  164. DEFINE_GUID(GUID_PKPixelFormat48bpp5ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x30);
  165. DEFINE_GUID(GUID_PKPixelFormat56bpp6ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x31);
  166. DEFINE_GUID(GUID_PKPixelFormat64bpp7ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x32);
  167. DEFINE_GUID(GUID_PKPixelFormat72bpp8ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x33);
  168. DEFINE_GUID(GUID_PKPixelFormat64bpp3ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x34);
  169. DEFINE_GUID(GUID_PKPixelFormat80bpp4ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x35);
  170. DEFINE_GUID(GUID_PKPixelFormat96bpp5ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x36);
  171. DEFINE_GUID(GUID_PKPixelFormat112bpp6ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x37);
  172. DEFINE_GUID(GUID_PKPixelFormat128bpp7ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x38);
  173. DEFINE_GUID(GUID_PKPixelFormat144bpp8ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x39);
  174. /* YCrCb from Advanced Profile */
  175. DEFINE_GUID(GUID_PKPixelFormat12bppYCC420, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x44);
  176. DEFINE_GUID(GUID_PKPixelFormat16bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x45);
  177. DEFINE_GUID(GUID_PKPixelFormat20bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x46);
  178. DEFINE_GUID(GUID_PKPixelFormat32bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x47);
  179. DEFINE_GUID(GUID_PKPixelFormat24bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x48);
  180. DEFINE_GUID(GUID_PKPixelFormat30bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x49);
  181. DEFINE_GUID(GUID_PKPixelFormat48bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4a);
  182. DEFINE_GUID(GUID_PKPixelFormat16bpp48bppYCC444FixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4b);
  183. DEFINE_GUID(GUID_PKPixelFormat20bppYCC420Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4c);
  184. DEFINE_GUID(GUID_PKPixelFormat24bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4d);
  185. DEFINE_GUID(GUID_PKPixelFormat30bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4e);
  186. DEFINE_GUID(GUID_PKPixelFormat48bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4f);
  187. DEFINE_GUID(GUID_PKPixelFormat32bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x50);
  188. DEFINE_GUID(GUID_PKPixelFormat40bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x51);
  189. DEFINE_GUID(GUID_PKPixelFormat64bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x52);
  190. DEFINE_GUID(GUID_PKPixelFormat64bppYCC444AlphaFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x53);
  191. //YUV
  192. #define GUID_PKPixelFormat12bppYUV420 GUID_PKPixelFormat12bppYCC420
  193. #define GUID_PKPixelFormat16bppYUV422 GUID_PKPixelFormat16bppYCC422
  194. #define GUID_PKPixelFormat24bppYUV444 GUID_PKPixelFormat24bppYCC444
  195. /* CMYKDIRECT from Advanced Profile */
  196. DEFINE_GUID(GUID_PKPixelFormat32bppCMYKDIRECT, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x54);
  197. DEFINE_GUID(GUID_PKPixelFormat64bppCMYKDIRECT, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x55);
  198. DEFINE_GUID(GUID_PKPixelFormat40bppCMYKDIRECTAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x56);
  199. DEFINE_GUID(GUID_PKPixelFormat80bppCMYKDIRECTAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x43);
  200. // PhotometricInterpretation
  201. #define PK_PI_W0 0 // WhiteIsZero
  202. #define PK_PI_B0 1 // BlackIsZero
  203. #define PK_PI_RGB 2
  204. #define PK_PI_RGBPalette 3
  205. #define PK_PI_TransparencyMask 4
  206. #define PK_PI_CMYK 5
  207. #define PK_PI_YCbCr 6
  208. #define PK_PI_CIELab 8
  209. #define PK_PI_NCH 100
  210. #define PK_PI_RGBE 101
  211. #define PK_pixfmtNul 0x00000000
  212. #define PK_pixfmtHasAlpha 0x00000010
  213. #define PK_pixfmtPreMul 0x00000020
  214. #define PK_pixfmtBGR 0x00000040
  215. #define PK_pixfmtNeedConvert 0x80000000
  216. #define LOOKUP_FORWARD 0
  217. #define LOOKUP_BACKWARD_TIF 1
  218. typedef unsigned long WMP_GRBIT;
  219. typedef GUID PKPixelFormatGUID;
  220. typedef struct tagPKPixelInfo
  221. {
  222. const PKPixelFormatGUID* pGUIDPixFmt;
  223. size_t cChannel;
  224. COLORFORMAT cfColorFormat;
  225. BITDEPTH_BITS bdBitDepth;
  226. U32 cbitUnit;
  227. WMP_GRBIT grBit;
  228. // TIFF
  229. U32 uInterpretation;
  230. U32 uSamplePerPixel;
  231. U32 uBitsPerSample;
  232. U32 uSampleFormat;
  233. } PKPixelInfo;
  234. //================================================================
  235. ERR PKAlloc(void** ppv, size_t cb);
  236. ERR PKFree(void** ppv);
  237. //----------------------------------------------------------------
  238. //ERR GetPixelInfo(PKPixelFormatGUID enPixelFormat, const PKPixelInfo** ppPI);
  239. ERR PixelFormatLookup(PKPixelInfo* pPI, U8 uLookupType);
  240. const PKPixelFormatGUID* GetPixelFormatFromHash(const U8 uPFHash);
  241. ERR GetImageEncodeIID(const char* szExt, const PKIID** ppIID);
  242. ERR GetImageDecodeIID(const char* szExt, const PKIID** ppIID);
  243. //================================================================
  244. #ifdef __ANSI__
  245. struct tagPKFactory;
  246. struct tagPKCodecFactory;
  247. struct tagPKImageDecode;
  248. struct tagPKImageEncode;
  249. struct tagPKFormatConverter;
  250. #define PKFactory struct tagPKFactory
  251. #define PKCodecFactory struct tagPKCodecFactory
  252. #define PKImageDecode struct tagPKImageDecode
  253. #define PKImageEncode struct tagPKImageEncode
  254. #define PKFormatConverter struct tagPKFormatConverter
  255. #else // __ANSI__
  256. typedef struct tagPKFactory PKFactory;
  257. typedef struct tagPKCodecFactory PKCodecFactory;
  258. typedef struct tagPKImageDecode PKImageDecode;
  259. typedef struct tagPKImageEncode PKImageEncode;
  260. typedef struct tagPKFormatConverter PKFormatConverter;
  261. #endif // __ANSI__
  262. //================================================================
  263. typedef struct tagPKStream
  264. {
  265. ERR (*InitializeFromFilename)(const char*, ULong);
  266. ERR (*Release)(void);
  267. FILE* fp;
  268. } PKStream;
  269. //================================================================
  270. typedef struct tagPKFactory
  271. {
  272. ERR (*CreateStream)(PKStream**);
  273. ERR (*CreateStreamFromFilename)(struct WMPStream**, const char*, const char*);
  274. ERR (*CreateStreamFromMemory)(struct WMPStream**, void*, size_t);
  275. ERR (*Release)(PKFactory**);
  276. #ifdef __ANSI__
  277. #undef PKFactory
  278. #endif // __ANSI__
  279. } PKFactory;
  280. //----------------------------------------------------------------
  281. ERR PKCreateFactory_CreateStream(PKStream** ppStream);
  282. ERR PKCreateFactory_Release(PKFactory** ppFactory);
  283. EXTERN_C ERR PKCreateFactory(PKFactory**, U32);
  284. //================================================================
  285. typedef struct tagPKCodecFactory
  286. {
  287. ERR (*CreateCodec)(const PKIID*, void**);
  288. ERR (*CreateDecoderFromFile)(const char*, PKImageDecode**);
  289. ERR (*CreateFormatConverter)(PKFormatConverter**);
  290. ERR (*Release)(PKCodecFactory**);
  291. #ifdef __ANSI__
  292. #undef PKCodecFactory
  293. #endif // __ANSI__
  294. } PKCodecFactory;
  295. //----------------------------------------------------------------
  296. ERR PKCodecFactory_CreateCodec(const PKIID* iid, void** ppv);
  297. ERR PKCreateCodecFactory_Release(PKCodecFactory** ppCFactory);
  298. EXTERN_C ERR PKCreateCodecFactory(PKCodecFactory**, U32);
  299. //================================================================
  300. typedef enum BANDEDENCSTATE
  301. {
  302. BANDEDENCSTATE_UNINITIALIZED = 0,
  303. BANDEDENCSTATE_INIT,
  304. BANDEDENCSTATE_ENCODING,
  305. BANDEDENCSTATE_TERMINATED,
  306. BANDEDENCSTATE_NONBANDEDENCODE,
  307. } BANDEDENCSTATE;
  308. typedef struct tagPKImageEncode
  309. {
  310. //ERR (*GetPixelFormat)(MILPixelFormat*));
  311. ERR (*Initialize)(PKImageEncode*, struct WMPStream*, void*, size_t);
  312. ERR (*Terminate)(PKImageEncode*);
  313. ERR (*SetPixelFormat)(PKImageEncode*, PKPixelFormatGUID);
  314. ERR (*SetSize)(PKImageEncode*, I32, I32);
  315. ERR (*SetResolution)(PKImageEncode*, Float, Float);
  316. ERR (*SetColorContext)(PKImageEncode *pIE, const U8 *pbColorContext,
  317. U32 cbColorContext);
  318. ERR (*SetDescriptiveMetadata)(PKImageEncode *pIE,
  319. const DESCRIPTIVEMETADATA *pDescMetadata);
  320. ERR (*WritePixels)(PKImageEncode*, U32, U8*, U32);
  321. ERR (*WriteSource)(PKImageEncode*, PKFormatConverter*, PKRect*);
  322. // Banded encode API - currently only implemented for WMP encoder
  323. ERR (*WritePixelsBandedBegin)(PKImageEncode* pEncoder, struct WMPStream *pPlanarAlphaTempFile);
  324. ERR (*WritePixelsBanded)(PKImageEncode* pEncoder, U32 cLines, U8* pbPixels, U32 cbStride, Bool fLastCall);
  325. ERR (*WritePixelsBandedEnd)(PKImageEncode* pEncoder);
  326. #define TEMPFILE_COPYBUF_SIZE 8192 // Means when using tempfile for planar alpha banded encode, copy this many bytes at a time
  327. ERR (*Transcode)(PKImageEncode*, PKImageDecode*, CWMTranscodingParam*);
  328. ERR (*CreateNewFrame)(PKImageEncode*, void*, size_t);
  329. ERR (*Release)(PKImageEncode**);
  330. struct WMPStream* pStream;
  331. size_t offStart;
  332. PKPixelFormatGUID guidPixFormat;
  333. U32 uWidth;
  334. U32 uHeight;
  335. U32 idxCurrentLine;
  336. Float fResX;
  337. Float fResY;
  338. U32 cFrame;
  339. Bool fHeaderDone;
  340. size_t offPixel;
  341. size_t cbPixel;
  342. U8 *pbColorContext;
  343. U32 cbColorContext;
  344. U8 *pbEXIFMetadata;
  345. U32 cbEXIFMetadataByteCount;
  346. U8 *pbGPSInfoMetadata;
  347. U32 cbGPSInfoMetadataByteCount;
  348. U8 *pbIPTCNAAMetadata;
  349. U32 cbIPTCNAAMetadataByteCount;
  350. U8 *pbXMPMetadata;
  351. U32 cbXMPMetadataByteCount;
  352. U8 *pbPhotoshopMetadata;
  353. U32 cbPhotoshopMetadataByteCount;
  354. DESCRIPTIVEMETADATA sDescMetadata;
  355. Bool bWMP;//for the encoder in decoding
  356. struct
  357. {
  358. WmpDEMisc wmiDEMisc;
  359. CWMImageInfo wmiI;
  360. CWMIStrCodecParam wmiSCP;
  361. CTXSTRCODEC ctxSC;
  362. CWMImageInfo wmiI_Alpha;
  363. CWMIStrCodecParam wmiSCP_Alpha;
  364. CTXSTRCODEC ctxSC_Alpha;
  365. Bool bHasAlpha;
  366. Long nOffImage;
  367. Long nCbImage;
  368. Long nOffAlpha;
  369. Long nCbAlpha;
  370. ORIENTATION oOrientation;
  371. // Banded encode state variables
  372. BANDEDENCSTATE eBandedEncState;
  373. struct WMPStream *pPATempFile;
  374. } WMP;
  375. #ifdef __ANSI__
  376. #undef PKImageEncode
  377. #endif // __ANSI__
  378. } PKImageEncode;
  379. //----------------------------------------------------------------
  380. ERR PKImageEncode_Create_WMP(PKImageEncode** ppIE);
  381. ERR PKImageEncode_Initialize(PKImageEncode* pIE, struct WMPStream* pStream, void* pvParam, size_t cbParam);
  382. ERR PKImageEncode_Terminate(PKImageEncode* pIE);
  383. ERR PKImageEncode_SetPixelFormat(PKImageEncode* pIE, PKPixelFormatGUID enPixelFormat);
  384. ERR PKImageEncode_SetSize(PKImageEncode* pIE, I32 iWidth, I32 iHeight);
  385. ERR PKImageEncode_SetResolution(PKImageEncode* pIE, Float rX, Float rY);
  386. ERR PKImageEncode_SetColorContext(PKImageEncode *pIE, const U8 *pbColorContext, U32 cbColorContext);
  387. ERR PKImageEncode_SetDescriptiveMetadata(PKImageEncode *pIE, const DESCRIPTIVEMETADATA *pDescMetadata);
  388. ERR PKImageEncode_WritePixels(PKImageEncode* pIE, U32 cLine, U8* pbPixel, U32 cbStride);
  389. ERR PKImageEncode_CreateNewFrame(PKImageEncode* pIE, void* pvParam, size_t cbParam);
  390. ERR PKImageEncode_Release(PKImageEncode** ppIE);
  391. ERR PKImageEncode_SetXMPMetadata_WMP(PKImageEncode *pIE, const U8 *pbXMPMetadata, U32 cbXMPMetadata);
  392. ERR PKImageEncode_SetEXIFMetadata_WMP(PKImageEncode *pIE, const U8 *pbEXIFMetadata, U32 cbEXIFMetadata);
  393. ERR PKImageEncode_SetGPSInfoMetadata_WMP(PKImageEncode *pIE, const U8 *pbGPSInfoMetadata, U32 cbGPSInfoMetadata);
  394. ERR PKImageEncode_SetIPTCNAAMetadata_WMP(PKImageEncode *pIE, const U8 *pbIPTCNAAMetadata, U32 cbIPTCNAAMetadata);
  395. ERR PKImageEncode_SetPhotoshopMetadata_WMP(PKImageEncode *pIE, const U8 *pbPhotoshopMetadata, U32 cbPhotoshopMetadata);
  396. void FreeDescMetadata(DPKPROPVARIANT *pvar);
  397. ERR PKImageEncode_Create(PKImageEncode** ppIE);
  398. //================================================================
  399. typedef struct tagPKImageDecode
  400. {
  401. ERR (*Initialize)(PKImageDecode*, struct WMPStream* pStream);
  402. ERR (*GetPixelFormat)(PKImageDecode*, PKPixelFormatGUID*);
  403. ERR (*GetSize)(PKImageDecode*, I32*, I32*);
  404. ERR (*GetResolution)(PKImageDecode*, Float*, Float*);
  405. ERR (*GetColorContext)(PKImageDecode *pID, U8 *pbColorContext,
  406. U32 *pcbColorContext);
  407. ERR (*GetDescriptiveMetadata)(PKImageDecode *pIE,
  408. DESCRIPTIVEMETADATA *pDescMetadata);
  409. ERR (*GetRawStream)(PKImageDecode*, struct WMPStream**);
  410. ERR (*Copy)(PKImageDecode*, const PKRect*, U8*, U32);
  411. ERR (*GetFrameCount)(PKImageDecode*, U32*);
  412. ERR (*SelectFrame)(PKImageDecode*, U32);
  413. ERR (*Release)(PKImageDecode**);
  414. struct WMPStream* pStream;
  415. Bool fStreamOwner;
  416. size_t offStart;
  417. PKPixelFormatGUID guidPixFormat;
  418. U32 uWidth;
  419. U32 uHeight;
  420. U32 idxCurrentLine;
  421. Float fResX;
  422. Float fResY;
  423. U32 cFrame;
  424. struct
  425. {
  426. WmpDEMisc wmiDEMisc;
  427. CWMImageInfo wmiI;
  428. CWMIStrCodecParam wmiSCP;
  429. CTXSTRCODEC ctxSC;
  430. CWMImageInfo wmiI_Alpha;
  431. CWMIStrCodecParam wmiSCP_Alpha;
  432. CTXSTRCODEC ctxSC_Alpha;
  433. Bool bHasAlpha;
  434. Long nOffImage;
  435. Long nCbImage;
  436. Long nOffAlpha;
  437. Long nCbAlpha;
  438. Bool bIgnoreOverlap;
  439. size_t DecoderCurrMBRow;
  440. size_t DecoderCurrAlphaMBRow;
  441. size_t cMarker;
  442. size_t cLinesDecoded;
  443. size_t cLinesCropped; // Lines may be cropped from the top - buffer for subsequent decodes must be adjusted
  444. Bool fFirstNonZeroDecode;
  445. Bool fOrientationFromContainer;
  446. ORIENTATION oOrientationFromContainer; // Tag 0xBC02 in HD Photo container
  447. DESCRIPTIVEMETADATA sDescMetadata;
  448. } WMP;
  449. #ifdef __ANSI__
  450. #undef PKImageDecode
  451. #endif // __ANSI__
  452. } PKImageDecode;
  453. //----------------------------------------------------------------
  454. ERR PKImageDecode_Create_WMP(PKImageDecode** ppID);
  455. ERR PKImageDecode_Initialize(PKImageDecode* pID, struct WMPStream* pStream);
  456. ERR PKImageDecode_GetPixelFormat(PKImageDecode* pID, PKPixelFormatGUID* pPF);
  457. ERR PKImageDecode_GetSize(PKImageDecode* pID, I32* piWidth, I32* piHeight);
  458. ERR PKImageDecode_GetResolution(PKImageDecode* pID, Float* pfrX, Float* pfrY);
  459. ERR PKImageDecode_GetColorContext(PKImageDecode *pID, U8 *pbColorContext, U32 *pcbColorContext);
  460. ERR PKImageDecode_GetDescriptiveMetadata(PKImageDecode *pID, DESCRIPTIVEMETADATA *pDescMetadata);
  461. ERR PKImageDecode_Copy(PKImageDecode* pID, const PKRect* pRect, U8* pb, U32 cbStride);
  462. ERR PKImageDecode_GetFrameCount(PKImageDecode* pID, U32* puCount);
  463. ERR PKImageDecode_SelectFrame(PKImageDecode* pID, U32 uFrame);
  464. ERR PKImageDecode_Release(PKImageDecode** ppID);
  465. ERR PKImageDecode_Create(PKImageDecode** ppID);
  466. ERR PKCodecFactory_CreateDecoderFromFile(const char* szFilename, PKImageDecode** ppDecoder);
  467. //================================================================
  468. typedef struct tagPKFormatConverter
  469. {
  470. ERR (*Initialize)(PKFormatConverter*, PKImageDecode*, char *pExt, PKPixelFormatGUID);
  471. ERR (*InitializeConvert)(PKFormatConverter* pFC, const PKPixelFormatGUID enPFFrom,
  472. char *pExt, PKPixelFormatGUID enPFTTo);
  473. ERR (*GetPixelFormat)(PKFormatConverter*, PKPixelFormatGUID*);
  474. ERR (*GetSourcePixelFormat)(PKFormatConverter*, PKPixelFormatGUID*);
  475. ERR (*GetSize)(PKFormatConverter*, I32*, I32*);
  476. ERR (*GetResolution)(PKFormatConverter*, Float*, Float*);
  477. ERR (*Copy)(PKFormatConverter*, const PKRect*, U8*, U32);
  478. ERR (*Convert)(PKFormatConverter*, const PKRect*, U8*, U32);
  479. ERR (*Release)(PKFormatConverter**);
  480. PKImageDecode* pDecoder;
  481. PKPixelFormatGUID enPixelFormat;
  482. #ifdef __ANSI__
  483. #undef PKFormatConverter
  484. #endif // __ANSI__
  485. } PKFormatConverter;
  486. //----------------------------------------------------------------
  487. ERR PKImageEncode_Transcode(PKImageEncode* pIE, PKFormatConverter* pFC, PKRect* pRect);
  488. ERR PKImageEncode_WriteSource(PKImageEncode* pIE, PKFormatConverter* pFC, PKRect* pRect);
  489. ERR PKFormatConverter_Initialize(PKFormatConverter* pFC, PKImageDecode* pID, char *pExt, PKPixelFormatGUID enPF);
  490. ERR PKFormatConverter_InitializeConvert(PKFormatConverter* pFC, const PKPixelFormatGUID enPFFrom,
  491. char *pExt, PKPixelFormatGUID enPFTo);
  492. ERR PKFormatConverter_GetPixelFormat(PKFormatConverter* pFC, PKPixelFormatGUID* pPF);
  493. ERR PKFormatConverter_GetSourcePixelFormat(PKFormatConverter* pFC, PKPixelFormatGUID* pPF);
  494. ERR PKFormatConverter_GetSize(PKFormatConverter* pFC, I32* piWidth, I32* piHeight);
  495. ERR PKFormatConverter_GetResolution(PKFormatConverter* pFC, Float* pfrX, Float* pfrY);
  496. ERR PKFormatConverter_Copy(PKFormatConverter* pFC, const PKRect* pRect, U8* pb, U32 cbStride);
  497. ERR PKFormatConverter_Convert(PKFormatConverter* pFC, const PKRect* pRect, U8* pb, U32 cbStride);
  498. ERR PKFormatConverter_Release(PKFormatConverter** ppFC);
  499. // Think of this as static member of PKFormatConverter "class"
  500. ERR PKFormatConverter_EnumConversions(const PKPixelFormatGUID *pguidSourcePF,
  501. const U32 iIndex,
  502. const PKPixelFormatGUID **ppguidTargetPF);
  503. ERR PKCodecFactory_CreateFormatConverter(PKFormatConverter** ppFConverter);
  504. //----------------------------------------------------------------
  505. ERR PKAlloc(void** ppv, size_t cb);
  506. ERR PKFree(void** ppv);
  507. ERR PKAllocAligned(void** ppv, size_t cb, size_t iAlign);
  508. ERR PKFreeAligned(void** ppv);
  509. #ifdef __cplusplus
  510. } // extern "C"
  511. #endif