GdiPlusPixelFormats.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //Download by http://www.NewXing.com
  2. /**************************************************************************\
  3. *
  4. * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
  5. *
  6. * Module Name:
  7. *
  8. * Gdiplus Pixel Formats
  9. *
  10. * Abstract:
  11. *
  12. * GDI+ Pixel Formats
  13. *
  14. \**************************************************************************/
  15. #ifndef _GDIPLUSPIXELFORMATS_H
  16. #define _GDIPLUSPIXELFORMATS_H
  17. typedef DWORD ARGB;
  18. typedef DWORDLONG ARGB64;
  19. #define ALPHA_SHIFT 24
  20. #define RED_SHIFT 16
  21. #define GREEN_SHIFT 8
  22. #define BLUE_SHIFT 0
  23. #define ALPHA_MASK ((ARGB) 0xff << ALPHA_SHIFT)
  24. // In-memory pixel data formats:
  25. // bits 0-7 = format index
  26. // bits 8-15 = pixel size (in bits)
  27. // bits 16-23 = flags
  28. // bits 24-31 = reserved
  29. typedef INT PixelFormat;
  30. #define PixelFormatIndexed 0x00010000 // Indexes into a palette
  31. #define PixelFormatGDI 0x00020000 // Is a GDI-supported format
  32. #define PixelFormatAlpha 0x00040000 // Has an alpha component
  33. #define PixelFormatPAlpha 0x00080000 // Pre-multiplied alpha
  34. #define PixelFormatExtended 0x00100000 // Extended color 16 bits/channel
  35. #define PixelFormatCanonical 0x00200000
  36. #define PixelFormatUndefined 0
  37. #define PixelFormatDontCare 0
  38. #define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
  39. #define PixelFormat4bppIndexed (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
  40. #define PixelFormat8bppIndexed (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
  41. #define PixelFormat16bppGrayScale (4 | (16 << 8) | PixelFormatExtended)
  42. #define PixelFormat16bppRGB555 (5 | (16 << 8) | PixelFormatGDI)
  43. #define PixelFormat16bppRGB565 (6 | (16 << 8) | PixelFormatGDI)
  44. #define PixelFormat16bppARGB1555 (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
  45. #define PixelFormat24bppRGB (8 | (24 << 8) | PixelFormatGDI)
  46. #define PixelFormat32bppRGB (9 | (32 << 8) | PixelFormatGDI)
  47. #define PixelFormat32bppARGB (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
  48. #define PixelFormat32bppPARGB (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
  49. #define PixelFormat48bppRGB (12 | (48 << 8) | PixelFormatExtended)
  50. #define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended)
  51. #define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended)
  52. #define PixelFormatMax 15
  53. inline UINT
  54. GetPixelFormatSize(
  55. PixelFormat pixfmt
  56. )
  57. {
  58. return (pixfmt >> 8) & 0xff;
  59. }
  60. inline BOOL
  61. IsIndexedPixelFormat(
  62. PixelFormat pixfmt
  63. )
  64. {
  65. return (pixfmt & PixelFormatIndexed) != 0;
  66. }
  67. inline BOOL
  68. IsAlphaPixelFormat(
  69. PixelFormat pixfmt
  70. )
  71. {
  72. return (pixfmt & PixelFormatAlpha) != 0;
  73. }
  74. inline BOOL
  75. IsExtendedPixelFormat(
  76. PixelFormat pixfmt
  77. )
  78. {
  79. return (pixfmt & PixelFormatExtended) != 0;
  80. }
  81. //--------------------------------------------------------------------------
  82. // Determine if the Pixel Format is Canonical format:
  83. // PixelFormat32bppARGB
  84. // PixelFormat32bppPARGB
  85. // PixelFormat64bppARGB
  86. // PixelFormat64bppPARGB
  87. //--------------------------------------------------------------------------
  88. inline BOOL
  89. IsCanonicalPixelFormat(
  90. PixelFormat pixfmt
  91. )
  92. {
  93. return (pixfmt & PixelFormatCanonical) != 0;
  94. }
  95. enum PaletteFlags
  96. {
  97. PaletteFlagsHasAlpha = 0x0001,
  98. PaletteFlagsGrayScale = 0x0002,
  99. PaletteFlagsHalftone = 0x0004
  100. };
  101. struct ColorPalette
  102. {
  103. public:
  104. UINT Flags; // Palette flags
  105. UINT Count; // Number of color entries
  106. ARGB Entries[1]; // Palette color entries
  107. };
  108. #endif