Code

Translations. French translation minor update.
[inkscape.git] / display / nr-filter-utils.h
1 #ifndef __NR_FILTER_UTILS_H__
2 #define __NR_FILTER_UTILS_H__
4 /** \file
5  * filter utils. Definition of functions needed by several filters.
6  *
7  * Authors:
8  *   Jean-Rene Reinhard <jr@komite.net>
9  *
10  * Copyright (C) 2007 authors
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include "round.h"
17 /* Shouldn't these be inlined? */
18 namespace Inkscape {
19 namespace Filters {
21 /**
22  * Clamps an integer value to a value between 0 and 255. Needed by filters where
23  * rendering computations can lead to component values out of bound.
24  *
25  * \return 0 if the value is smaller than 0, 255 if it is greater 255, else v
26  * \param v the value to clamp
27  */
28 int clamp(int const val);
30 /**
31  * Clamps an integer value to a value between 0 and 255^3.
32  *
33  * \return 0 if the value is smaller than 0, 255^3 (16581375) if it is greater than 255^3, else v
34  * \param v the value to clamp
35  */
36 int clamp3(int const val);
38 /**
39  * Macro to use the clamp function with double inputs and unsigned char output
40  */
41 #define CLAMP_D_TO_U8(v) (unsigned char) clamp((int)round((v)))
43 /**
44  * Clamps an integer to a value between 0 and alpha. Useful when handling
45  * images with premultiplied alpha, as setting some of RGB channels
46  * to a value bigger than alpha confuses the alpha blending in Inkscape
47  * \return 0 if val is negative, alpha if val is bigger than alpha, val otherwise
48  * \param val the value to clamp
49  * \param alpha the maximum value to clamp to
50  */
51 int clamp_alpha(int const val, int const alpha);
53 } /* namespace Filters */
54 } /* namespace Inkscape */
56 #endif /* __NR_FILTER_UTILS_H__ */
57 /*
58   Local Variables:
59   mode:c++
60   c-file-style:"stroustrup"
61   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
62   indent-tabs-mode:nil
63   fill-column:99
64   End:
65 */
66 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :