1 /*
2 This frei0r plugin generates solid color images
3 
4 Copyright (C) 2004, 2005 Martin Bayer <martin@gephex.org>
5 
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10 
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 Lesser General Public License for more details.
15 
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20 
21 #include "frei0r.hpp"
22 
23 #include <algorithm>
24 
25 class onecol0r : public frei0r::source
26 {
27 public:
onecol0r(unsigned int width,unsigned int height)28   onecol0r(unsigned int width, unsigned int height)
29   {
30     register_param(color,"Color","the color of the image");
31     color.r = color.g = color.b = 0;
32   }
33 
update(double time,uint32_t * out)34   virtual void update(double time,
35                       uint32_t* out)
36   {
37     unsigned int col;
38     unsigned char* c = reinterpret_cast<unsigned char*>(&col);
39 
40     c[0]=static_cast<unsigned char>(color.b*255);
41     c[1]=static_cast<unsigned char>(color.g*255);
42     c[2]=static_cast<unsigned char>(color.r*255);
43     c[3]=255;
44 
45     std::fill(out, out+width*height, col);
46   }
47 
48 private:
49   f0r_param_color color;
50 };
51 
52 
53 frei0r::construct<onecol0r> plugin("onecol0r",
54 				   "image with just one color",
55 				   "Martin Bayer",
56 				   0,3);
57 
58