summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorFelipe Corr??a da Silva Sanches <juca@members.fsf.org>2007-08-05 20:22:48 +0000
committerjucablues <jucablues@users.sourceforge.net>2007-08-05 20:22:48 +0000
commitaa16883300757708ee4b924d6d987c584bfe47bb (patch)
tree4ce7545771118cffb71456e2c482ba7fa6297fa2 /src/display
parentupdated Slovak translation in trunk (diff)
downloadinkscape-aa16883300757708ee4b924d6d987c584bfe47bb.tar.gz
inkscape-aa16883300757708ee4b924d6d987c584bfe47bb.zip
refactoring:
*using CLAMP_D_TO_U8 *Changed edgeMode field of ConvolveMatrix filter to use an enum rather than a plain int (bzr r3378)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/nr-filter-convolve-matrix.cpp24
-rw-r--r--src/display/nr-filter-convolve-matrix.h11
2 files changed, 17 insertions, 18 deletions
diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp
index 9c9cf5f21..8ce9241fe 100644
--- a/src/display/nr-filter-convolve-matrix.cpp
+++ b/src/display/nr-filter-convolve-matrix.cpp
@@ -10,6 +10,7 @@
*/
#include "display/nr-filter-convolve-matrix.h"
+#include "display/nr-filter-utils.h"
#include <vector>
namespace NR {
@@ -19,7 +20,7 @@ FilterConvolveMatrix::FilterConvolveMatrix()
targetX((int)(orderX/2)),
targetY((int)(orderY/2)),
bias(0),
- edgeMode(0),
+ edgeMode((NR::FilterConvolveMatrixEdgeMode) 0),
preserveAlpha(false)
{}
@@ -80,20 +81,11 @@ int FilterConvolveMatrix::render(FilterSlot &slot, Matrix const &trans) {
}
}
}
- result_R = result_R / div + bias;
- result_G = result_G / div + bias;
- result_B = result_B / div + bias;
- result_A = result_A / div + bias;
-
- result_R = (result_R > 0 ? result_R : 0);
- result_G = (result_G > 0 ? result_G : 0);
- result_B = (result_B > 0 ? result_B : 0);
- result_A = (result_A > 0 ? result_A : 0);
-
- out_data[4*( x + width*y )] = (result_R < 255 ? (unsigned char)result_R : 255);
- out_data[4*( x + width*y )+1] = (result_G < 255 ? (unsigned char)result_G : 255);
- out_data[4*( x + width*y )+2] = (result_B < 255 ? (unsigned char)result_B : 255);
- out_data[4*( x + width*y )+3] = (result_A < 255 ? (unsigned char)result_A : 255);
+
+ out_data[4*( x + width*y )] = CLAMP_D_TO_U8(result_R / div + bias);
+ out_data[4*( x + width*y )+1] = CLAMP_D_TO_U8(result_G / div + bias);
+ out_data[4*( x + width*y )+2] = CLAMP_D_TO_U8(result_B / div + bias);
+ out_data[4*( x + width*y )+3] = CLAMP_D_TO_U8(result_A / div + bias);
}
}
@@ -130,7 +122,7 @@ void FilterConvolveMatrix::set_kernelMatrix(std::vector<gdouble> &km) {
kernelMatrix = km;
}
-void FilterConvolveMatrix::set_edgeMode(int mode){
+void FilterConvolveMatrix::set_edgeMode(FilterConvolveMatrixEdgeMode mode){
edgeMode = mode;
}
diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h
index f4a823012..2a397abf2 100644
--- a/src/display/nr-filter-convolve-matrix.h
+++ b/src/display/nr-filter-convolve-matrix.h
@@ -20,6 +20,13 @@
namespace NR {
+enum FilterConvolveMatrixEdgeMode {
+ CONVOLVEMATRIX_EDGEMODE_DUPLICATE,
+ CONVOLVEMATRIX_EDGEMODE_WRAP,
+ CONVOLVEMATRIX_EDGEMODE_NONE,
+ CONVOLVEMATRIX_EDGEMODE_ENDTYPE
+};
+
class FilterConvolveMatrix : public FilterPrimitive {
public:
FilterConvolveMatrix();
@@ -36,7 +43,7 @@ public:
void set_kernelMatrix(std::vector<gdouble>& km);
void set_bias(double b);
void set_divisor(double d);
- void set_edgeMode(int mode);
+ void set_edgeMode(FilterConvolveMatrixEdgeMode mode);
void set_preserveAlpha(bool pa);
private:
@@ -45,7 +52,7 @@ private:
int orderX, orderY;
gdouble divisor, bias;
int dx, dy, kernelUnitLength;
- int edgeMode;
+ FilterConvolveMatrixEdgeMode edgeMode;
bool preserveAlpha;
};