~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/display/nr-filter-flood.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
11
 
 
12
#include "display/nr-filter-flood.h"
 
13
#include "display/nr-filter-utils.h"
 
14
 
 
15
namespace NR {
 
16
 
 
17
FilterFlood::FilterFlood()
 
18
{}
 
19
 
 
20
FilterPrimitive * FilterFlood::create() {
 
21
    return new FilterFlood();
 
22
}
 
23
 
 
24
FilterFlood::~FilterFlood()
 
25
{}
 
26
 
 
27
int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) {
 
28
    NRPixBlock *in = slot.get(_input);
 
29
    if (!in) {
 
30
        g_warning("Missing source image for feFlood (in=%d)", _input);
 
31
        return 1;
 
32
    }
 
33
 
 
34
    int i;
 
35
    int in_w = in->area.x1 - in->area.x0;
 
36
    int in_h = in->area.y1 - in->area.y0;
 
37
 
 
38
    NRPixBlock *out = new NRPixBlock;
 
39
 
 
40
    nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N,
 
41
                           in->area.x0, in->area.y0, in->area.x1, in->area.y1,
 
42
                           true);
 
43
 
 
44
    unsigned char *out_data = NR_PIXBLOCK_PX(out);
 
45
 
 
46
    unsigned char r,g,b,a;
 
47
    r = CLAMP_D_TO_U8((color >> 24) % 256);
 
48
    g = CLAMP_D_TO_U8((color >> 16) % 256);
 
49
    b = CLAMP_D_TO_U8((color >>  8) % 256);
 
50
    a = CLAMP_D_TO_U8(opacity*255);
 
51
 
 
52
    for(i=0; i < 4*in_h*in_w; i+=4){
 
53
            out_data[i]=r;
 
54
            out_data[i+1]=g;
 
55
            out_data[i+2]=b;
 
56
            out_data[i+3]=a;
 
57
    }
 
58
 
 
59
    out->empty = FALSE;
 
60
    slot.set(_output, out);
 
61
    return 0;
 
62
}
 
63
 
 
64
void FilterFlood::set_color(guint32 c) {
 
65
    color = c;
 
66
}
 
67
 
 
68
void FilterFlood::set_opacity(double o) {
 
69
    opacity = o;
 
70
}
 
71
 
 
72
void FilterFlood::area_enlarge(NRRectL &/*area*/, Matrix const &/*trans*/)
 
73
{
 
74
}
 
75
 
 
76
} /* namespace NR */
 
77
 
 
78
/*
 
79
  Local Variables:
 
80
  mode:c++
 
81
  c-file-style:"stroustrup"
 
82
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
83
  indent-tabs-mode:nil
 
84
  fill-column:99
 
85
  End:
 
86
*/
 
87
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :