Code

Patch from codedread. Prevents rendering of title/desc/metadata elements in text...
[inkscape.git] / src / display / nr-filter-utils.h
index b591b37cb759662d8f76e5cb3cedb5f8ad16e50e..91c295e94e7a052897e9f49a8315d86ef415569b 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "round.h"
 
+/* Shouldn't these be inlined? */
 namespace NR {
 
 /**
@@ -23,13 +24,31 @@ namespace NR {
  * \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);
+int clamp(int const val);
+
+/**
+ * Clamps an integer value to a value between 0 and 255^3.
+ *
+ * \return 0 if the value is smaller than 0, 255^3 (16581375) if it is greater than 255^3, else v
+ * \param v the value to clamp
+ */
+int clamp3(int const 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)))
 
+/**
+ * Clamps an integer to a value between 0 and alpha. Useful when handling
+ * images with premultiplied alpha, as setting some of RGB channels
+ * to a value bigger than alpha confuses the alpha blending in Inkscape
+ * \return 0 if val is negative, alpha if val is bigger than alpha, val otherwise
+ * \param val the value to clamp
+ * \param alpha the maximum value to clamp to
+ */
+int clamp_alpha(int const val, int const alpha);
+
 } /* namespace NR */
 
 #endif /* __NR_FILTER_UTILS_H__ */