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.

97 lines
3.1 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Colspace.h 1.3 1998/04/29 22:43:30 tomz Exp $
  2. #ifndef __COLSPACE_H
  3. #define __COLSPACE_H
  4. #ifndef __MYTYPES_H
  5. #include "mytypes.h"
  6. #endif
  7. typedef DWORD FOURCC; /*a four character code */
  8. /* constants for the biCompression field from windows.h*/
  9. #define BI_RGB 0L
  10. #define BI_RLE8 1L
  11. #define BI_RLE4 2L
  12. #define BI_BITFIELDS 3L
  13. #ifndef __COLFRMAT_H
  14. #include "colfrmat.h"
  15. #endif
  16. /* Class: ColorSpace:
  17. * Purpose: This class provides the functionality of the BtPisces color
  18. * space converter
  19. * Attributes: CurColor_: ColFmt - current color format
  20. * Operations:
  21. SetColorFormat( ColFmt aColor ): - this method sets the color format
  22. ColFmt GetColorFormat(): - this method returns the current color format
  23. BYTE GetBitCount(): - this method returns number of bpp for the current
  24. color format.
  25. */
  26. class ColorSpace
  27. {
  28. private:
  29. ColFmt CurColor_;
  30. static const BYTE BitCount_ [];
  31. static const BYTE XRestriction_ [];
  32. static const BYTE YRestriction_ [];
  33. static const BYTE YPlaneBitCount_ [];
  34. static const FOURCC FourccArr_ [];
  35. static const GUID *VideoGUIDs [];
  36. ColorSpace();
  37. public:
  38. void SetColorFormat( ColFmt aColor ) { CurColor_ = aColor; }
  39. DWORD GetBitCount() const;
  40. DWORD GetPitchBpp() const;
  41. FOURCC GetFourcc() const;
  42. bool CheckDimentions( const SIZE &aSize ) const;
  43. bool CheckLeftTop( const MPoint &aSize ) const;
  44. ColorSpace( ColFmt aColForm ) : CurColor_( aColForm ) {}
  45. ColorSpace( FOURCC fcc, int bitCount );
  46. ColorSpace( const GUID &guid );
  47. ColFmt GetColorFormat() const;
  48. bool IsValid()
  49. { return bool( CurColor_ > CF_BelowRange && CurColor_ < CF_AboveRange ); }
  50. };
  51. /* Method: ColorSpace::GetBitCount
  52. * Purpose: Returns number of bpp for a given color
  53. */
  54. inline DWORD ColorSpace::GetBitCount() const { return BitCount_ [CurColor_]; }
  55. /* Method: ColorSpace::GetPitchBpp
  56. * Purpose: Used to calculate pitch of data buffers. Most useful for planar modes
  57. * where bpp used for pitch calculation is different from 'real' bpp of a
  58. * data format
  59. */
  60. inline DWORD ColorSpace::GetPitchBpp() const { return YPlaneBitCount_ [CurColor_]; }
  61. /* Method: ColorSpace::GetColorFormat
  62. * Purpose: a query function
  63. */
  64. inline ColFmt ColorSpace::GetColorFormat() const { return CurColor_; }
  65. /* Method: ColorSpace::GetFourcc
  66. * Purpose: returns a FOURCC corresponding to the current color format
  67. */
  68. inline FOURCC ColorSpace::GetFourcc() const { return FourccArr_ [CurColor_]; }
  69. /* Function: IsDivisible
  70. * Purpose: This function checks that the first value passed in is
  71. * evenly divisible by the second
  72. * Input: ToCheck: int - value to be checked
  73. * Divisor: int
  74. * Output: bool
  75. * Note: The function assumes Divisor is a power of 2
  76. */
  77. inline bool IsDivisible( int ToCheck, int Divisor )
  78. {
  79. return bool( !( ToCheck & ( Divisor - 1 ) ) );
  80. }
  81. #endif __COLSPACE_H