~ubuntu-branches/debian/squeeze/inkscape/squeeze

« back to all changes in this revision

Viewing changes to src/display/nr-filter-utils.h

  • 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
#ifndef __NR_FILTER_UTILS_H__
 
2
#define __NR_FILTER_UTILS_H__
 
3
 
 
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
 */
 
14
 
 
15
#include "round.h"
 
16
 
 
17
/* Shouldn't these be inlined? */
 
18
namespace NR {
 
19
 
 
20
/**
 
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.
 
23
 *
 
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
 
26
 */
 
27
int clamp(int const val);
 
28
 
 
29
/**
 
30
 * Clamps an integer value to a value between 0 and 255^3.
 
31
 *
 
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
 
34
 */
 
35
int clamp3(int const val);
 
36
 
 
37
/**
 
38
 * Macro to use the clamp function with double inputs and unsigned char output
 
39
 */
 
40
#define CLAMP_D_TO_U8(v) (unsigned char) clamp((int)round((v)))
 
41
 
 
42
/**
 
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
 
49
 */
 
50
int clamp_alpha(int const val, int const alpha);
 
51
 
 
52
} /* namespace NR */
 
53
 
 
54
#endif /* __NR_FILTER_UTILS_H__ */
 
55
/*
 
56
  Local Variables:
 
57
  mode:c++
 
58
  c-file-style:"stroustrup"
 
59
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
60
  indent-tabs-mode:nil
 
61
  fill-column:99
 
62
  End:
 
63
*/
 
64
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :