1
#ifndef __NR_FILTER_UTILS_H__
2
#define __NR_FILTER_UTILS_H__
5
* filter utils. Definition of functions needed by several filters.
8
* Jean-Rene Reinhard <jr@komite.net>
10
* Copyright (C) 2007 authors
12
* Released under GNU GPL, read the file 'COPYING' for more information
17
/* Shouldn't these be inlined? */
21
* Clamps an integer value to a value between 0 and 255. Needed by filters where
22
* rendering computations can lead to component values out of bound.
24
* \return 0 if the value is smaller than 0, 255 if it is greater 255, else v
25
* \param v the value to clamp
27
int clamp(int const val);
30
* Clamps an integer value to a value between 0 and 255^3.
32
* \return 0 if the value is smaller than 0, 255^3 (16581375) if it is greater than 255^3, else v
33
* \param v the value to clamp
35
int clamp3(int const val);
38
* Macro to use the clamp function with double inputs and unsigned char output
40
#define CLAMP_D_TO_U8(v) (unsigned char) clamp((int)round((v)))
43
* Clamps an integer to a value between 0 and alpha. Useful when handling
44
* images with premultiplied alpha, as setting some of RGB channels
45
* to a value bigger than alpha confuses the alpha blending in Inkscape
46
* \return 0 if val is negative, alpha if val is bigger than alpha, val otherwise
47
* \param val the value to clamp
48
* \param alpha the maximum value to clamp to
50
int clamp_alpha(int const val, int const alpha);
54
#endif /* __NR_FILTER_UTILS_H__ */
58
c-file-style:"stroustrup"
59
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
64
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :