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.

175 lines
4.9 KiB

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