nr-filter-utils.h revision 0f1b8f53ed81c3a02f55223cd3eb359f123bc565
#ifndef __NR_FILTER_UTILS_H__
#define __NR_FILTER_UTILS_H__
/** \file
* filter utils. Definition of functions needed by several filters.
*
* Authors:
* Jean-Rene Reinhard <jr@komite.net>
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "round.h"
namespace NR {
/**
* Clamps an integer value to a value between 0 and 255. Needed by filters where
* rendering computations can lead to component values out of bound.
*
* \return 0 if the value is smaller than 0, 255 if it is greater 255, else v
* \param v the value to clamp
*/
int clamp(int val);
/**
* Macro to use the clamp function with double inputs and unsigned char output
*/
#define CLAMP_D_TO_U8(v) (unsigned char) clamp((int)round((v)))
} /* namespace NR */
#endif /* __NR_FILTER_UTILS_H__ */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :