Download | Plain Text | No Line Numbers


  1. /**
  2.  * @module cpixelformat
  3.  * @author 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. #include "cbitmap.h"
  17.  
  18. /**
  19.  * @class CPixelFormat
  20.  * @brief Abstract class for handling different color bitcount of Bitmaps.
  21.  *
  22.  * Needed for generic use in CBitmap.
  23.  *
  24.  * On error throw PixelFormatError.
  25.  */
  26. class CPixelFormat
  27. {
  28. public:
  29. /**
  30.   * @class PixelFormatError
  31.   * @brief Exception thrown by implemententations of CPixelFormat
  32.   */
  33. class PixelFormatError : public std::invalid_argument {
  34. public:
  35. /**
  36.   * @method PixelFormatError
  37.   * @brief Default exception ctor
  38.   * @param what message to pass along
  39.   * @return -
  40.   * @globalvars none
  41.   * @exception none
  42.   * @conditions none
  43.   */
  44. PixelFormatError(const std::string& what)
  45. : std::invalid_argument(what)
  46. {}
  47. };
  48.  
  49. /**
  50.   * @method CBitmap
  51.   * @brief Default ctor
  52.   * @param bitmap pointer to CBitmap instance
  53.   * @return -
  54.   * @globalvars none
  55.   * @exception none
  56.   * @conditions none
  57.   */
  58. CPixelFormat(CBitmap *bitmap)
  59. : m_bitmap(bitmap)
  60. {}
  61.  
  62. /**
  63.   * @method ~CPixelFormat
  64.   * @brief Default dtor (virtual)
  65.   * @param -
  66.   * @return -
  67.   * @globalvars none
  68.   * @exception none
  69.   * @conditions none
  70.   */
  71. virtual ~CPixelFormat()
  72. {};
  73.  
  74. /**
  75.   * @method setPixel
  76.   * @brief Modifies pixel at coordinates x, y
  77.   * @param pixel pointer to new pixel data
  78.   * @param x x-coordinate
  79.   * @param y y-coordinate
  80.   * @return -
  81.   * @globalvars none
  82.   * @exception PixelFormatError
  83.   * @conditions none
  84.   */
  85. virtual void setPixel(const uint32_t *pixel, const uint32_t x, const uint32_t y) = 0;
  86.  
  87. /**
  88.   * @method getBitCount
  89.   * @brief returns color bitcount supported by this class
  90.   * @param -
  91.   * @return color bitcount supported by this class
  92.   * @globalvars none
  93.   * @exception none
  94.   * @conditions none
  95.   */
  96. virtual uint32_t getBitCount() = 0;
  97.  
  98. protected:
  99. /* members */
  100. /** pointer to CBitmap instance */
  101. CBitmap *m_bitmap;
  102. };
  103.  
  104. #endif
  105.  
  106. /* vim: set et sw=2 ts=2: */
  107.