Code

Use g_base64_encode_step when importing images via drag and drop.
[inkscape.git] / src / display / nr-filter-flood.cpp
1 /*
2  * feFlood filter primitive renderer
3  *
4  * Authors:
5  *   Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
6  *
7  * Copyright (C) 2007 authors
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #include "display/nr-filter-flood.h"
13 #include "display/nr-filter-utils.h"
15 namespace Inkscape {
16 namespace Filters {
18 FilterFlood::FilterFlood()
19 {}
21 FilterPrimitive * FilterFlood::create() {
22     return new FilterFlood();
23 }
25 FilterFlood::~FilterFlood()
26 {}
28 int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) {
29     NRPixBlock *in = slot.get(_input);
30     if (!in) {
31         g_warning("Missing source image for feFlood (in=%d)", _input);
32         return 1;
33     }
35     int i;
36     int in_w = in->area.x1 - in->area.x0;
37     int in_h = in->area.y1 - in->area.y0;
38  
39     NRPixBlock *out = new NRPixBlock;
41     nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N,
42                            in->area.x0, in->area.y0, in->area.x1, in->area.y1,
43                            true);
45     unsigned char *out_data = NR_PIXBLOCK_PX(out);
47     unsigned char r,g,b,a;
48     r = CLAMP_D_TO_U8((color >> 24) % 256);
49     g = CLAMP_D_TO_U8((color >> 16) % 256);
50     b = CLAMP_D_TO_U8((color >>  8) % 256);
51     a = CLAMP_D_TO_U8(opacity*255);
53     for(i=0; i < 4*in_h*in_w; i+=4){
54             out_data[i]=r;
55             out_data[i+1]=g;
56             out_data[i+2]=b;
57             out_data[i+3]=a;
58     }
60     out->empty = FALSE;
61     slot.set(_output, out);
62     return 0;
63 }
65 void FilterFlood::set_color(guint32 c) {
66     color = c;
67 }
69 void FilterFlood::set_opacity(double o) {
70     opacity = o;
71 }
73 void FilterFlood::area_enlarge(NRRectL &/*area*/, Geom::Matrix const &/*trans*/)
74 {
75 }
77 } /* namespace Filters */
78 } /* namespace Inkscape */
80 /*
81   Local Variables:
82   mode:c++
83   c-file-style:"stroustrup"
84   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
85   indent-tabs-mode:nil
86   fill-column:99
87   End:
88 */
89 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :