Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

GdiplusPixelFormats.h 6.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved.
  4. *
  5. * Module Name:
  6. *
  7. * Gdiplus pixel formats
  8. *
  9. * Abstract:
  10. *
  11. * Definitions for color types, palettes, pixel format IDs.
  12. *
  13. \**************************************************************************/
  14. #ifndef _GDIPLUSPIXELFORMATS_H
  15. #define _GDIPLUSPIXELFORMATS_H
  16. /*
  17. * 32-bit and 64-bit ARGB pixel value
  18. */
  19. typedef DWORD ARGB;
  20. typedef DWORDLONG ARGB64;
  21. #define ALPHA_SHIFT 24
  22. #define RED_SHIFT 16
  23. #define GREEN_SHIFT 8
  24. #define BLUE_SHIFT 0
  25. #define ALPHA_MASK ((ARGB) 0xff << ALPHA_SHIFT)
  26. /*
  27. * In-memory pixel data formats:
  28. * bits 0-7 = format index
  29. * bits 8-15 = pixel size (in bits)
  30. * bits 16-23 = flags
  31. * bits 24-31 = reserved
  32. */
  33. #ifndef DCR_USE_NEW_105760
  34. enum PixelFormat
  35. {
  36. PixelFormatIndexed = 0x00010000, // Indexes into a palette
  37. PixelFormatGDI = 0x00020000, // Is a GDI-supported format
  38. PixelFormatAlpha = 0x00040000, // Has an alpha component
  39. PixelFormatPAlpha = 0x00080000, // Uses pre-multiplied alpha
  40. PixelFormatExtended = 0x00100000, // Uses extended color (16 bits per channel)
  41. PixelFormatCanonical = 0x00200000, // ?
  42. PixelFormatUndefined = 0,
  43. PixelFormatDontCare = 0,
  44. PixelFormat1bppIndexed = 1 | ( 1 << 8) | PixelFormatIndexed
  45. | PixelFormatGDI,
  46. PixelFormat4bppIndexed = 2 | ( 4 << 8) | PixelFormatIndexed
  47. | PixelFormatGDI,
  48. PixelFormat8bppIndexed = 3 | ( 8 << 8) | PixelFormatIndexed
  49. | PixelFormatGDI,
  50. PixelFormat16bppGrayScale = 4 | (16 << 8) | PixelFormatExtended,
  51. PixelFormat16bppRGB555 = 5 | (16 << 8) | PixelFormatGDI,
  52. PixelFormat16bppRGB565 = 6 | (16 << 8) | PixelFormatGDI,
  53. PixelFormat16bppARGB1555 = 7 | (16 << 8) | PixelFormatAlpha
  54. | PixelFormatGDI,
  55. PixelFormat24bppRGB = 8 | (24 << 8) | PixelFormatGDI,
  56. PixelFormat32bppRGB = 9 | (32 << 8) | PixelFormatGDI,
  57. PixelFormat32bppARGB = 10 | (32 << 8) | PixelFormatAlpha
  58. | PixelFormatGDI
  59. | PixelFormatCanonical,
  60. PixelFormat32bppPARGB = 11 | (32 << 8) | PixelFormatAlpha
  61. | PixelFormatPAlpha
  62. | PixelFormatGDI,
  63. PixelFormat48bppRGB = 12 | (48 << 8) | PixelFormatExtended,
  64. PixelFormat64bppARGB = 13 | (64 << 8) | PixelFormatAlpha
  65. | PixelFormatCanonical
  66. | PixelFormatExtended,
  67. PixelFormat64bppPARGB = 14 | (64 << 8) | PixelFormatAlpha
  68. | PixelFormatPAlpha
  69. | PixelFormatExtended,
  70. PixelFormat24bppBGR = 15 | (24 << 8) | PixelFormatGDI,
  71. PixelFormatMax = 16
  72. };
  73. #else
  74. typedef INT PixelFormat;
  75. #define PixelFormatIndexed 0x00010000 // Indexes into a palette
  76. #define PixelFormatGDI 0x00020000 // Is a GDI-supported format
  77. #define PixelFormatAlpha 0x00040000 // Has an alpha component
  78. #define PixelFormatPAlpha 0x00080000 // Uses pre-multiplied alpha
  79. #define PixelFormatExtended 0x00100000 // Uses extended color (16 bits per channel)
  80. #define PixelFormatCanonical 0x00200000 // ?
  81. #define PixelFormatUndefined 0
  82. #define PixelFormatDontCare 0
  83. #define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
  84. #define PixelFormat4bppIndexed (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
  85. #define PixelFormat8bppIndexed (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
  86. #define PixelFormat16bppGrayScale (4 | (16 << 8) | PixelFormatExtended)
  87. #define PixelFormat16bppRGB555 (5 | (16 << 8) | PixelFormatGDI)
  88. #define PixelFormat16bppRGB565 (6 | (16 << 8) | PixelFormatGDI)
  89. #define PixelFormat16bppARGB1555 (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
  90. #define PixelFormat24bppRGB (8 | (24 << 8) | PixelFormatGDI)
  91. #define PixelFormat32bppRGB (9 | (32 << 8) | PixelFormatGDI)
  92. #define PixelFormat32bppARGB (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
  93. #define PixelFormat32bppPARGB (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
  94. #define PixelFormat48bppRGB (12 | (48 << 8) | PixelFormatExtended)
  95. #define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended)
  96. #define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended)
  97. #define PixelFormatMax 15
  98. #endif
  99. /*
  100. * Return the pixel size for the specified format (in bits)
  101. */
  102. inline UINT
  103. GetPixelFormatSize(
  104. PixelFormat pixfmt
  105. )
  106. {
  107. return (pixfmt >> 8) & 0xff;
  108. }
  109. /*
  110. * Determine if the specified pixel format is an indexed color format
  111. */
  112. inline BOOL
  113. IsIndexedPixelFormat(
  114. PixelFormat pixfmt
  115. )
  116. {
  117. return (pixfmt & PixelFormatIndexed) != 0;
  118. }
  119. /*
  120. * Determine if the pixel format can have alpha channel
  121. */
  122. inline BOOL
  123. IsAlphaPixelFormat(
  124. PixelFormat pixfmt
  125. )
  126. {
  127. return (pixfmt & PixelFormatAlpha) != 0;
  128. }
  129. /*
  130. * Determine if the pixel format is an extended format,
  131. * i.e. supports 16-bit per channel
  132. */
  133. inline BOOL
  134. IsExtendedPixelFormat(
  135. PixelFormat pixfmt
  136. )
  137. {
  138. return (pixfmt & PixelFormatExtended) != 0;
  139. }
  140. /*
  141. * Determine if the pixel format is canonical format:
  142. * PixelFormat32bppARGB
  143. * PixelFormat32bppPARGB
  144. * PixelFormat64bppARGB
  145. * PixelFormat64bppPARGB
  146. */
  147. inline BOOL
  148. IsCanonicalPixelFormat(
  149. PixelFormat pixfmt
  150. )
  151. {
  152. return (pixfmt & PixelFormatCanonical) != 0;
  153. }
  154. /*
  155. * Color palette
  156. * palette entries are limited to 32bpp ARGB pixel format
  157. */
  158. enum PaletteFlags
  159. {
  160. PaletteFlagsHasAlpha = 0x0001,
  161. PaletteFlagsGrayScale = 0x0002,
  162. PaletteFlagsHalftone = 0x0004
  163. };
  164. struct ColorPalette
  165. {
  166. public:
  167. UINT Flags; // palette flags
  168. UINT Count; // number of color entries
  169. ARGB Entries[1]; // palette color entries
  170. };
  171. #endif