1 /*
2 * feFlood filter primitive renderer
3 *
4 * Authors:
5 * Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
6 *
7 * Copyright (C) 2007 authors
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifdef HAVE_CONFIG_H
13 # include "config.h"
14 #endif
16 #include "display/nr-filter-flood.h"
17 #include "display/nr-filter-utils.h"
18 #include "svg/svg-icc-color.h"
19 #include "svg/svg-color.h"
21 namespace Inkscape {
22 namespace Filters {
24 FilterFlood::FilterFlood()
25 {}
27 FilterPrimitive * FilterFlood::create() {
28 return new FilterFlood();
29 }
31 FilterFlood::~FilterFlood()
32 {}
34 int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) {
35 g_message("rendering feflood");
36 NRPixBlock *in = slot.get(_input);
37 if (!in) {
38 g_warning("Missing source image for feFlood (in=%d)", _input);
39 return 1;
40 }
42 int i;
43 int in_w = in->area.x1 - in->area.x0;
44 int in_h = in->area.y1 - in->area.y0;
46 NRPixBlock *out = new NRPixBlock;
48 nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N,
49 in->area.x0, in->area.y0, in->area.x1, in->area.y1,
50 true);
52 unsigned char *out_data = NR_PIXBLOCK_PX(out);
53 unsigned char r,g,b,a;
56 r = CLAMP_D_TO_U8((color >> 24) % 256);
57 g = CLAMP_D_TO_U8((color >> 16) % 256);
58 b = CLAMP_D_TO_U8((color >> 8) % 256);
59 a = CLAMP_D_TO_U8(opacity*255);
61 #if ENABLE_LCMS
62 icc_color_to_sRGB(icc, &r, &g, &b);
63 g_message("result: r:%d g:%d b:%d", r, g, b);
64 #endif //ENABLE_LCMS
66 for(i=0; i < 4*in_h*in_w; i+=4){
67 out_data[i]=r;
68 out_data[i+1]=g;
69 out_data[i+2]=b;
70 out_data[i+3]=a;
71 }
73 out->empty = FALSE;
74 slot.set(_output, out);
75 return 0;
76 }
78 void FilterFlood::set_color(guint32 c) {
79 color = c;
80 }
82 void FilterFlood::set_opacity(double o) {
83 opacity = o;
84 }
86 void FilterFlood::set_icc(SVGICCColor *icc_color) {
87 icc = icc_color;
88 }
90 void FilterFlood::area_enlarge(NRRectL &/*area*/, Geom::Matrix const &/*trans*/)
91 {
92 }
94 } /* namespace Filters */
95 } /* namespace Inkscape */
97 /*
98 Local Variables:
99 mode:c++
100 c-file-style:"stroustrup"
101 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
102 indent-tabs-mode:nil
103 fill-column:99
104 End:
105 */
106 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :