summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c98f4a4)
raw | patch | inline | side by side (parent: c98f4a4)
author | jucablues <jucablues@users.sourceforge.net> | |
Sun, 5 Aug 2007 20:22:48 +0000 (20:22 +0000) | ||
committer | jucablues <jucablues@users.sourceforge.net> | |
Sun, 5 Aug 2007 20:22:48 +0000 (20:22 +0000) |
*using CLAMP_D_TO_U8
*Changed edgeMode field of ConvolveMatrix filter to use an enum rather than a plain int
*Changed edgeMode field of ConvolveMatrix filter to use an enum rather than a plain int
src/display/nr-filter-convolve-matrix.cpp | patch | blob | history | |
src/display/nr-filter-convolve-matrix.h | patch | blob | history | |
src/sp-feconvolvematrix.cpp | patch | blob | history |
index 9c9cf5f210c222709a1034c3fb23278955cdfa73..8ce9241fed2f74eb1a5494ef977bb21af09e231b 100644 (file)
*/
#include "display/nr-filter-convolve-matrix.h"
+#include "display/nr-filter-utils.h"
#include <vector>
namespace NR {
targetX((int)(orderX/2)),
targetY((int)(orderY/2)),
bias(0),
- edgeMode(0),
+ edgeMode((NR::FilterConvolveMatrixEdgeMode) 0),
preserveAlpha(false)
{}
}
}
}
- 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);
}
}
kernelMatrix = km;
}
-void FilterConvolveMatrix::set_edgeMode(int mode){
+void FilterConvolveMatrix::set_edgeMode(FilterConvolveMatrixEdgeMode mode){
edgeMode = mode;
}
index f4a8230126fab961ea817ae062bb9fc1c95d2bbf..2a397abf20563f0e03abf099db5a873a554e1263 100644 (file)
namespace NR {
+enum FilterConvolveMatrixEdgeMode {
+ CONVOLVEMATRIX_EDGEMODE_DUPLICATE,
+ CONVOLVEMATRIX_EDGEMODE_WRAP,
+ CONVOLVEMATRIX_EDGEMODE_NONE,
+ CONVOLVEMATRIX_EDGEMODE_ENDTYPE
+};
+
class FilterConvolveMatrix : public FilterPrimitive {
public:
FilterConvolveMatrix();
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:
int orderX, orderY;
gdouble divisor, bias;
int dx, dy, kernelUnitLength;
- int edgeMode;
+ FilterConvolveMatrixEdgeMode edgeMode;
bool preserveAlpha;
};
index 87e737dfeaada7b616ba570d60713f286b35151f..434689385b04255d502d055dc216c88c960f0769 100644 (file)
((SPObjectClass *) feConvolveMatrix_parent_class)->release(object);
}
-static int sp_feConvolveMatrix_read_edgeMode(gchar const *value){
- if (!value) return 0; //duplicate is default
+static NR::FilterConvolveMatrixEdgeMode sp_feConvolveMatrix_read_edgeMode(gchar const *value){
+ if (!value) return NR::CONVOLVEMATRIX_EDGEMODE_DUPLICATE; //duplicate is default
switch(value[0]){
case 'd':
- if (strncmp(value, "duplicate", 9) == 0) return 0;
+ if (strncmp(value, "duplicate", 9) == 0) return NR::CONVOLVEMATRIX_EDGEMODE_DUPLICATE;
break;
case 'w':
- if (strncmp(value, "wrap", 4) == 0) return 1;
+ if (strncmp(value, "wrap", 4) == 0) return NR::CONVOLVEMATRIX_EDGEMODE_WRAP;
break;
case 'n':
- if (strncmp(value, "none", 4) == 0) return 2;
+ if (strncmp(value, "none", 4) == 0) return NR::CONVOLVEMATRIX_EDGEMODE_NONE;
break;
}
- return 0; //duplicate is default
+ return NR::CONVOLVEMATRIX_EDGEMODE_DUPLICATE; //duplicate is default
}
/**
double read_num;
int read_int;
bool read_bool;
+ NR::FilterConvolveMatrixEdgeMode read_mode;
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
}
break;
case SP_ATTR_EDGEMODE:
- read_int = (int) sp_feConvolveMatrix_read_edgeMode(value);
- if (read_int != feConvolveMatrix->edgeMode){
- feConvolveMatrix->edgeMode = read_int;
+ read_mode = sp_feConvolveMatrix_read_edgeMode(value);
+ if (read_mode != feConvolveMatrix->edgeMode){
+ feConvolveMatrix->edgeMode = read_mode;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;