Download | Plain Text | No Line Numbers


  1. /**
  2.  * @module cpixelformat
  3.  * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
  4.  * @brief Abstract class for handling different color bitcount of Bitmaps.
  5.  * Needed for generic use in CBitmap.
  6.  * @date 18.04.2009
  7.  */
  8.  
  9. #ifndef CPIXELFORMAT_H
  10. #define CPIXELFORMAT_H
  11.  
  12. #include <fstream>
  13. #include <stdexcept>
  14.  
  15. class CBitmap;
  16.  
  17. /**
  18.  * @class CPixelFormat
  19.  * @brief Abstract class for handling different color bitcount of Bitmaps.
  20.  *
  21.  * Needed for generic use in CBitmap.
  22.  *
  23.  * On error throw PixelFormatError.
  24.  */
  25. class CPixelFormat
  26. {
  27. public:
  28. /**
  29.   * @class PixelFormatError
  30.   * @brief Exception thrown by implemententations of CPixelFormat
  31.   */
  32. class PixelFormatError : public std::invalid_argument {
  33. public:
  34. /**
  35.   * @method PixelFormatError
  36.   * @brief Default exception ctor
  37.   * @param what message to pass along
  38.   * @return -
  39.   * @globalvars none
  40.   * @exception none
  41.   * @conditions none
  42.   */
  43. PixelFormatError(const std::string& what)
  44. : std::invalid_argument(what)
  45. {}
  46. };
  47.  
  48. /**
  49.   * @method CPixelFormat
  50.   * @brief Default ctor
  51.   * @param bitmap pointer to CBitmap instance
  52.   * @return -
  53.   * @globalvars none
  54.   * @exception none
  55.   * @conditions none
  56.   */
  57. CPixelFormat(CBitmap *bitmap)
  58. : m_bitmap(bitmap)
  59. {}
  60.  
  61. /**
  62.   * @method ~CPixelFormat
  63.   * @brief Default dtor (virtual)
  64.   * @param -
  65.   * @return -
  66.   * @globalvars none
  67.   * @exception none
  68.   * @conditions none
  69.   */
  70. virtual ~CPixelFormat()
  71. {};
  72.  
  73. /**
  74.   * @brief RGB Pixel structure
  75.   */
  76. typedef struct
  77. {
  78. /** red */
  79. uint32_t red;
  80. /** green */
  81. uint32_t green;
  82. /** blue */
  83. uint32_t blue;
  84. } RGBPIXEL;
  85.  
  86. /**
  87.   * @method getPixel
  88.   * @brief Get pixel at coordinates x, y
  89.   * @param pixel reference to pixel data
  90.   * @param x x-coordinate
  91.   * @param y y-coordinate
  92.   * @return -
  93.   * @globalvars none
  94.   * @exception PixelFormatError
  95.   * @conditions none
  96.   */
  97. virtual void getPixel(RGBPIXEL& pixel, const uint32_t x, const uint32_t y) = 0;
  98.  
  99. /**
  100.   * @method setPixel
  101.   * @brief Modifies pixel at coordinates x, y
  102.   * @param pixel reference to new pixel data
  103.   * @param x x-coordinate
  104.   * @param y y-coordinate
  105.   * @return -
  106.   * @globalvars none
  107.   * @exception PixelFormatError
  108.   * @conditions none
  109.   */
  110. virtual void setPixel(const RGBPIXEL& pixel, const uint32_t x, const uint32_t y) = 0;
  111.  
  112. /**
  113.   * @method getBitCount
  114.   * @brief returns color bitcount supported by this class
  115.   * @param -
  116.   * @return color bitcount supported by this class
  117.   * @globalvars none
  118.   * @exception none
  119.   * @conditions none
  120.   */
  121. virtual uint32_t getBitCount() = 0;
  122.  
  123. /**
  124.   * @method getMaxColor
  125.   * @brief Get maximum values for RGB pixel
  126.   * @param pixel reference to pixel struct
  127.   * @return -
  128.   * @globalvars none
  129.   * @exception none
  130.   * @conditions none
  131.   */
  132. virtual void getMaxColor(RGBPIXEL& pixel) = 0;
  133.  
  134. protected:
  135. /* members */
  136. /** pointer to CBitmap instance */
  137. CBitmap *m_bitmap;
  138. };
  139.  
  140. #endif
  141.  
  142. /* vim: set et sw=2 ts=2: */
  143.