1 /* Copyright ® 2008-2009 Fulvio Satta
3 * If you want contact me, send an email to Yota_VGA@users.sf.net
5 * This file is part of Biscotto
7 * Biscotto is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Biscotto is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <memory> //For auto_ptr
25 #include <boost/smart_ptr.hpp> //For scoped_array
27 #include <ImfOutputFile.h>
29 /* Read and write in an image */
39 inline RGBA() : r(0), g(0), b(0), a(0) {}
41 inline RGBA(float red
, float green
, float blue
, float alpha
) :
42 r(red
), g(green
), b(blue
), a(alpha
) {}
44 inline RGBA
&operator+=(const RGBA
&ob
)
54 inline RGBA
operator/(double ob
) const
56 RGBA
rgba(r
, g
, b
, a
);
68 /* Pointers used in the class. Automatic remotion */
69 boost::scoped_array
<RGBA
> data
;
70 std::auto_ptr
<Imf::OutputFile
> file
;
72 /* Size of the image */
73 unsigned int m_w
, m_h
;
76 /* Actions for the class (only image creation for now) */
79 /* Accept file name, the size of the image and the action */
80 Image(const std::string
&filename
, unsigned int w
, unsigned int h
,
83 /* Write the next n lines, from top to bottom */
84 void writeLines(unsigned int n
);
86 /* Like writeLines(1) */
89 /* Get the pointer of a pixel column.
90 * It is possible access to the RGBA structure with image[x][y] */
91 inline RGBA
*operator[](unsigned int x
)
93 return &data
[x
* m_h
];
96 /* Like the previous, but for consts */
97 inline const RGBA
*operator[](unsigned int x
) const
99 return &data
[x
* m_h
];
102 /* Sizes of the image */
103 inline unsigned int w() const
108 inline unsigned int h() const