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.

69 lines
2.5 KiB

  1. #ifndef _PixInfo_h
  2. #define _PixInfo_h
  3. // File: PixInfo.h
  4. // Author: Michael Marr (mikemarr)
  5. //
  6. // Description:
  7. // Store the PixelFormat information in a form that is actually useful
  8. // to an application.
  9. //
  10. // ***Hungarian: pixi
  11. //
  12. // History:
  13. // -@- 06/24/97 (mikemarr) created -- snarfed from PalMap.h
  14. // -@- 09/23/97 (mikemarr) moved to DXCConv to do color conversion stuff
  15. // -@- 10/09/97 (mikemarr) - added 8 bit RGB
  16. // - added flags
  17. // - bug fixes for pixel formats with alpha
  18. #define flagPixiRGB 0x1
  19. #define flagPixiAlpha 0x2
  20. class CPixelInfo {
  21. public:
  22. HRESULT Init(BYTE nBPP = 0, DWORD dwRedMask = 0, DWORD dwGreenMask = 0,
  23. DWORD dwBlueMask = 0, DWORD dwAlphaMask = 0);
  24. HRESULT Init(const DDPIXELFORMAT &ddpf) {
  25. return Init(BYTE(ddpf.dwRGBBitCount), ddpf.dwRBitMask, ddpf.dwGBitMask,
  26. ddpf.dwBBitMask, ddpf.dwRGBAlphaBitMask); }
  27. CPixelInfo(BYTE nBPP = 0, DWORD dwRedMask = 0, DWORD dwGreenMask = 0,
  28. DWORD dwBlueMask = 0, DWORD dwAlphaMask = 0) {
  29. Init(nBPP, dwRedMask, dwGreenMask, dwBlueMask, dwAlphaMask); }
  30. CPixelInfo(const DDPIXELFORMAT &ddpf) { Init(ddpf); }
  31. void GetDDPF(DDPIXELFORMAT &ddpf) const;
  32. BOOL IsRGB() const { return uchFlags & flagPixiRGB; }
  33. BOOL HasAlpha() const { return uchFlags & flagPixiAlpha; }
  34. BOOL operator==(const CPixelInfo &pixi) const;
  35. BOOL operator!=(const CPixelInfo &pixi) const { return !(*this == pixi); };
  36. BOOL operator==(const DDPIXELFORMAT &ddpf) const;
  37. BOOL operator!=(const DDPIXELFORMAT &ddpf) const { return !(*this == ddpf); }
  38. // generic pack
  39. DWORD Pack(const BYTE *pPixels) const;
  40. DWORD Pack(BYTE r, BYTE g, BYTE b) const;
  41. DWORD Pack(BYTE r, BYTE g, BYTE b, BYTE a) const;
  42. DWORD Pack(const PALETTEENTRY &pe) const { return Pack(pe.peRed, pe.peGreen, pe.peBlue, pe.peFlags); }
  43. void UnPack(DWORD dwPixel, BYTE *pR, BYTE *pG, BYTE *pB, BYTE *pA) const;
  44. void UnPack(DWORD dwPixel, BYTE *pR, BYTE *pG, BYTE *pB) const;
  45. DWORD TranslatePack(DWORD dwSrcPixel, const CPixelInfo &pixiSrcFmt) const;
  46. // explicit pack
  47. WORD Pack16(BYTE r, BYTE g, BYTE b) const;
  48. WORD Pack16(BYTE r, BYTE g, BYTE b, BYTE a) const;
  49. WORD Pack16(const PALETTEENTRY &pe) const { return Pack16(pe.peRed, pe.peGreen, pe.peBlue); }
  50. public:
  51. BYTE nBPP, uchFlags;
  52. BYTE nRedShift, nRedResidual;
  53. BYTE nGreenShift, nGreenResidual;
  54. BYTE nBlueShift, nBlueResidual;
  55. BYTE nAlphaShift, nAlphaResidual;
  56. BYTE iRed, iBlue;
  57. };
  58. #endif