Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
nr-filter-utils.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_NR_FILTER_UTILS_H
3#define SEEN_NR_FILTER_UTILS_H
4
9/*
10 * Authors:
11 * Jean-Rene Reinhard <jr@komite.net>
12 *
13 * Copyright (C) 2007 authors
14 *
15 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
16 */
17
18namespace Inkscape {
19namespace Filters {
20
28inline int clamp(int const val) {
29 if (val < 0) return 0;
30 if (val > 255) return 255;
31 return val;
32}
33
40inline int clamp3(int const val) {
41 if (val < 0) return 0;
42 if (val > 16581375) return 16581375;
43 return val;
44}
45
49#define CLAMP_D_TO_U8(v) (unsigned char) clamp((int)round((v)))
50
59inline int clamp_alpha(int const val, int const alpha) {
60 if (val < 0) return 0;
61 if (val > alpha) return alpha;
62 return val;
63}
64
68#define CLAMP_D_TO_U8_ALPHA(v,a) (unsigned char) clamp_alpha((int)round((v)),(a))
69
70} /* namespace Filters */
71} /* namespace Inkscape */
72
73#endif /* SEEN_INKSCAPE_NR_FILTER_UTILS_H */
74/*
75 Local Variables:
76 mode:c++
77 c-file-style:"stroustrup"
78 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
79 indent-tabs-mode:nil
80 fill-column:99
81 End:
82*/
83// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
int clamp_alpha(int const val, int const alpha)
Clamps an integer to a value between 0 and alpha.
int clamp3(int const val)
Clamps an integer value to a value between 0 and 255^3.
int clamp(int const val)
Clamps an integer value to a value between 0 and 255.
Helper class to stream background task notifications as a series of messages.