Code

1aba770a37abe54df14bbb9e147a5ba40e23b963
[inkscape.git] / src / display / nr-filter-getalpha.cpp
1 /*
2  * Functions for extracting alpha channel from NRPixBlocks.
3  *
4  * Author:
5  *   Niko Kiirala <niko@kiirala.com>
6  *
7  * Copyright (C) 2007 Niko Kiirala
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #include "display/nr-filter-getalpha.h"
13 #include "libnr/nr-blit.h"
14 #include "libnr/nr-pixblock.h"
16 namespace NR {
18 NRPixBlock *filter_get_alpha(NRPixBlock *src)
19 {
20     NRPixBlock *dst = new NRPixBlock;
21     nr_pixblock_setup_fast(dst, NR_PIXBLOCK_MODE_R8G8B8A8P,
22                            src->area.x0, src->area.y0,
23                            src->area.x1, src->area.y1, false);
24     nr_blit_pixblock_pixblock(dst, src);
26     unsigned char *data = NR_PIXBLOCK_PX(dst);
27     int end = dst->rs * (dst->area.y1 - dst->area.y0);
28     for (int i = 0 ; i < end ; i += 4) {
29         data[i + 0] = 0;
30         data[i + 1] = 0;
31         data[i + 2] = 0;
32     }
33     dst->empty = false;
35     return dst;
36 }
38 } // namespace NR
40 /*
41   Local Variables:
42   mode:c++
43   c-file-style:"stroustrup"
44   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
45   indent-tabs-mode:nil
46   fill-column:99
47   End:
48 */
49 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :