RgbaImage.h
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @class RgbaImage 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @date January 2008 00005 00006 @brief 00007 Image class supporting a standard 32-bit Rgba pixel format 00008 <!-------------------------------------------------------------------->**/ 00009 00010 #ifndef MILTON_RGBA_IMAGE_H_ 00011 #define MILTON_RGBA_IMAGE_H_ 00012 00013 #include <common/image/Image.h> 00014 00015 class QImage; 00016 00017 class RgbaImage : public Image { 00018 public: 00019 ///@name Constructors 00020 //@{----------------------------------------------------------------- 00021 00022 inline RgbaImage(unsigned width = 640, unsigned height = 480); 00023 explicit RgbaImage(QImage &image); 00024 virtual ~RgbaImage(); 00025 00026 00027 //@}----------------------------------------------------------------- 00028 ///@name Data Accessors / Mutators 00029 ///@note 00030 /// You can extract a particular pixel via [][]. 00031 /// For example:<br /> 00032 /// RgbaImage image;<br /> 00033 /// image[2][0] = Rgba32(255, 0, 0);<br /> 00034 /// This example sets the pixel in the third row, first column to red. 00035 //@{----------------------------------------------------------------- 00036 00037 /** 00038 * @returns whether or not the underlying data for this image is stored 00039 * in a floating-point HDR format 00040 * 00041 * @note that some operations will be more of less efficient when 00042 * performed on an HDR image versus a standard 32-bit Rgba image, 00043 * and knowing whether or not an image is in HDR format can 00044 * facilitate efficient usage (cutting down on the number of 00045 * implicit conversions between HDR and non-HDR pixel formats that 00046 * must be performed) 00047 * 00048 * @note returns false for RgbaImage 00049 */ 00050 virtual bool isHDR() const; 00051 00052 /// @returns the underlying data in the given row index 00053 inline Rgba32 *operator[](unsigned index); 00054 00055 /// @returns the underlying data in the given row index 00056 inline const Rgba32 *operator[](unsigned index) const; 00057 00058 /// @returns the underlying data in row major order 00059 inline Rgba32 *getData(); 00060 00061 /// @returns the underlying data in row major order 00062 inline const Rgba32 *getData() const; 00063 00064 /** 00065 * @returns the luminance of the pixel at the given row and column which 00066 * is guaranteed to lie in [0, 1] 00067 */ 00068 virtual real_t getLuminance(unsigned row, unsigned col) const; 00069 00070 00071 //@}----------------------------------------------------------------- 00072 ///@name Mutators 00073 //@{----------------------------------------------------------------- 00074 00075 /** 00076 * @brief 00077 * Sets the dimensions of this image, most likely allocating a new 00078 * underlying buffer and erasing its previous contents 00079 */ 00080 virtual void setSize(unsigned width, unsigned height); 00081 00082 00083 //@}----------------------------------------------------------------- 00084 ///@name Miscellaneous 00085 //@{----------------------------------------------------------------- 00086 00087 /** 00088 * @returns a copy of this Image and its underlying data 00089 */ 00090 virtual Image *clone() const; 00091 00092 /** 00093 * @brief 00094 * Overwrites this image's data with the given image which is assumed 00095 * to have the same dimensions as this image (and may have been created 00096 * from this image by, for example, the clone function) 00097 */ 00098 virtual void copyData(const Image *image); 00099 00100 00101 //@}----------------------------------------------------------------- 00102 00103 protected: 00104 virtual Rgba32 _getPixelRgba32 (unsigned row, unsigned col) const; 00105 virtual RgbaHDR _getPixelRgbaHDR(unsigned row, unsigned col) const; 00106 00107 virtual void _setPixel(unsigned row, unsigned col, const Rgba32 &val); 00108 virtual void _setPixel(unsigned row, unsigned col, const RgbaHDR &val); 00109 00110 virtual void _setData(const Rgba32 *data); 00111 virtual void _setData(const RgbaHDR *data); 00112 00113 protected: 00114 Rgba32 *m_data; 00115 bool m_ownData; 00116 }; 00117 00118 // include inline definitions 00119 #include <common/image/RgbaImage.inl> 00120 00121 #endif // MILTON_RGBA_IMAGE_H_ 00122
Generated on 28 Feb 2009 for Milton by
1.5.6