summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/cpixelformat.h
blob: 911a141d0c5793534b994165f6924f13ed1652aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
 * @module cpixelformat
 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
 * @brief  Abstract class for handling different color bitcount of Bitmaps.
 *         Needed for generic use in CBitmap.
 * @date   18.04.2009
 */

#ifndef CPIXELFORMAT_H
#define CPIXELFORMAT_H

#include <fstream>
#include <stdexcept>

class CBitmap;
#include "cbitmap.h"

/**
 * @class CPixelFormat
 * @brief Abstract class for handling different color bitcount of Bitmaps.
 *
 * Needed for generic use in CBitmap.
 *
 * On error throw PixelFormatError.
 */
class CPixelFormat
{
  public:
    /**
     * @class PixelFormatError
     * @brief Exception thrown by implemententations of CPixelFormat
     */
    class PixelFormatError : public std::invalid_argument {
      public:
        /**
         * @method PixelFormatError
         * @brief  Default exception ctor
         * @param  what message to pass along
         * @return -
         * @globalvars none
         * @exception  none
         * @conditions none
         */
        PixelFormatError(const std::string& what)
          : std::invalid_argument(what)
        {}
    };

    /**
     * @method CPixelFormat
     * @brief  Default ctor
     * @param  bitmap pointer to CBitmap instance
     * @return -
     * @globalvars none
     * @exception  none
     * @conditions none
     */
    CPixelFormat(CBitmap *bitmap)
      : m_bitmap(bitmap)
    {}

    /**
     * @method ~CPixelFormat
     * @brief  Default dtor (virtual)
     * @param  -
     * @return -
     * @globalvars none
     * @exception  none
     * @conditions none
     */
    virtual ~CPixelFormat()
    {};

    /**
     * @method setPixel
     * @brief  Modifies pixel at coordinates x, y
     * @param  pixel pointer to new pixel data
     * @param  x     x-coordinate
     * @param  y     y-coordinate
     * @return -
     * @globalvars none
     * @exception  PixelFormatError
     * @conditions none
     */
    virtual void setPixel(const uint32_t *pixel, const uint32_t x, const uint32_t y) = 0;

    /**
     * @method getPixel
     * @brief  Get pixel at coordinates x, y
     * @param  pixel pointer to pixel data
     * @param  x     x-coordinate
     * @param  y     y-coordinate
     * @return -
     * @globalvars none
     * @exception  PixelFormatError
     * @conditions none
     */
    virtual void getPixel(uint32_t *pixel, const uint32_t x, const uint32_t y) = 0;

    /**
     * @method getBitCount
     * @brief  returns color bitcount supported by this class
     * @param  -
     * @return color bitcount supported by this class
     * @globalvars none
     * @exception  none
     * @conditions none
     */
    virtual uint32_t getBitCount() = 0;

    /*
     * TODO
     */
    virtual void getMaxColor(unsigned int *red, unsigned int *green, unsigned int *blue) = 0;

  protected:
    /* members */
    /** pointer to CBitmap instance */
    CBitmap *m_bitmap;
};

#endif

/* vim: set et sw=2 ts=2: */