Skip to content

Commit

Permalink
fix boolean parameter type in c++ plugins
Browse files Browse the repository at this point in the history
Resolves #48
  • Loading branch information
rrrapha authored and ddennedy committed Sep 7, 2018
1 parent 1cb2cc2 commit dd07f13
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 29 deletions.
5 changes: 3 additions & 2 deletions include/frei0r.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ namespace frei0r
switch (s_params[param_index].m_type)
{
case F0R_PARAM_BOOL :
*static_cast<f0r_param_bool*>(param) = ptr ? 0.0 : 1.0;
*static_cast<f0r_param_bool*>(param)
= *static_cast<f0r_param_bool*>(ptr) > 0.5 ? 1.0 : 0.0;
break;
case F0R_PARAM_DOUBLE:
*static_cast<f0r_param_double*>(param)
= *static_cast<double*>(ptr);
= *static_cast<f0r_param_double*>(ptr);
break;
case F0R_PARAM_COLOR:
*static_cast<f0r_param_color*>(param)
Expand Down
14 changes: 7 additions & 7 deletions src/filter/facebl0r/facebl0r.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class FaceBl0r: public frei0r::filter {

// plugin parameters
std::string classifier;
f0r_param_bool ellipse;
f0r_param_double recheck;
f0r_param_double threads;
f0r_param_double search_scale;
f0r_param_double neighbors;
f0r_param_double smallest;
f0r_param_double largest;
bool ellipse;
double recheck;
double threads;
double search_scale;
double neighbors;
double smallest;
double largest;

std::string old_classifier;

Expand Down
32 changes: 16 additions & 16 deletions src/filter/lightgraffiti/lightgraffiti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,22 +1039,22 @@ class LightGraffiti : public frei0r::filter
std::vector<RGBFloat> m_prevMask;
#endif

f0r_param_double m_pLongAlpha;
f0r_param_double m_pSensitivity;
f0r_param_double m_pBackgroundWeight;
f0r_param_double m_pThresholdBrightness;
f0r_param_double m_pThresholdDifference;
f0r_param_double m_pThresholdDiffSum;
f0r_param_double m_pDim;
f0r_param_double m_pSaturation;
f0r_param_double m_pLowerOverexposure;
f0r_param_bool m_pStatsBrightness;
f0r_param_bool m_pStatsDiff;
f0r_param_bool m_pStatsDiffSum;
f0r_param_bool m_pTransparentBackground;
f0r_param_bool m_pBlackReference;
f0r_param_bool m_pNonlinearDim;
f0r_param_bool m_pReset;
double m_pLongAlpha;
double m_pSensitivity;
double m_pBackgroundWeight;
double m_pThresholdBrightness;
double m_pThresholdDifference;
double m_pThresholdDiffSum;
double m_pDim;
double m_pSaturation;
double m_pLowerOverexposure;
bool m_pStatsBrightness;
bool m_pStatsDiff;
bool m_pStatsDiffSum;
bool m_pTransparentBackground;
bool m_pBlackReference;
bool m_pNonlinearDim;
bool m_pReset;

};

Expand Down
5 changes: 3 additions & 2 deletions src/filter/premultiply/premultiply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Premultiply : public frei0r::filter
uint8_t *src = (uint8_t*) in;
uint8_t *dst = (uint8_t*) out;
unsigned int n = width * height + 1;
if (m_unpremultiply == 0.0) {
if (!m_unpremultiply) {
// premultiply
while (--n) {
uint8_t a = src[3];
Expand Down Expand Up @@ -73,7 +73,8 @@ class Premultiply : public frei0r::filter
}

private:
f0r_param_bool m_unpremultiply;
bool m_unpremultiply;

};

frei0r::construct<Premultiply> plugin("Premultiply or Unpremultiply",
Expand Down
4 changes: 2 additions & 2 deletions src/filter/tutorial/tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ class Tutorial : public frei0r::filter
private:
// The various f0r_params are adjustable parameters.
// This one determines the size of the black bar in this example.
f0r_param_double m_barSize;
f0r_param_bool m_pointerMethod;
double m_barSize;
bool m_pointerMethod;
std::vector<uint8_t> lookupTable;
std::vector<uint8_t> additionTable;

Expand Down

0 comments on commit dd07f13

Please sign in to comment.