genesys: Use fixed float utilities instead of SANE_{FIX,UNFIX}

merge-requests/340/head
Povilas Kanapickas 2020-02-02 15:23:21 +02:00
rodzic 7ee775e983
commit 9fc3b38a9b
2 zmienionych plików z 19 dodań i 19 usunięć

Wyświetl plik

@ -162,9 +162,9 @@ static const SANE_Range u16_range = {
}; };
static const SANE_Range percentage_range = { static const SANE_Range percentage_range = {
SANE_FIX (0), /* minimum */ float_to_fixed(0), // minimum
SANE_FIX (100), /* maximum */ float_to_fixed(100), // maximum
SANE_FIX (1) /* quantization */ float_to_fixed(1) // quantization
}; };
static const SANE_Range threshold_curve_range = { static const SANE_Range threshold_curve_range = {
@ -3585,12 +3585,12 @@ static unsigned pick_resolution(const std::vector<unsigned>& resolutions, unsign
static void calc_parameters(Genesys_Scanner* s) static void calc_parameters(Genesys_Scanner* s)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
double tl_x = 0, tl_y = 0, br_x = 0, br_y = 0; float tl_x = 0, tl_y = 0, br_x = 0, br_y = 0;
tl_x = SANE_UNFIX(s->pos_top_left_x); tl_x = fixed_to_float(s->pos_top_left_x);
tl_y = SANE_UNFIX(s->pos_top_left_y); tl_y = fixed_to_float(s->pos_top_left_y);
br_x = SANE_UNFIX(s->pos_bottom_right_x); br_x = fixed_to_float(s->pos_bottom_right_x);
br_y = SANE_UNFIX(s->pos_bottom_right_y); br_y = fixed_to_float(s->pos_bottom_right_y);
s->params.last_frame = true; /* only single pass scanning supported */ s->params.last_frame = true; /* only single pass scanning supported */
@ -3704,7 +3704,7 @@ static void calc_parameters(Genesys_Scanner* s)
s->dev->settings.tl_y = tl_y; s->dev->settings.tl_y = tl_y;
// threshold setting // threshold setting
s->dev->settings.threshold = static_cast<int>(2.55 * (SANE_UNFIX(s->threshold))); s->dev->settings.threshold = static_cast<int>(2.55f * (fixed_to_float(s->threshold)));
// color filter // color filter
if (s->color_filter == "Red") { if (s->color_filter == "Red") {
@ -3730,7 +3730,7 @@ static void calc_parameters(Genesys_Scanner* s)
/* some digital processing requires the whole picture to be buffered */ /* some digital processing requires the whole picture to be buffered */
/* no digital processing takes place when doing preview, or when bit depth is /* no digital processing takes place when doing preview, or when bit depth is
* higher than 8 bits */ * higher than 8 bits */
if ((s->swdespeck || s->swcrop || s->swdeskew || s->swderotate ||(SANE_UNFIX(s->swskip)>0)) if ((s->swdespeck || s->swcrop || s->swdeskew || s->swderotate ||(fixed_to_float(s->swskip)>0))
&& (!s->preview) && (!s->preview)
&& (s->bit_depth <= 8)) && (s->bit_depth <= 8))
{ {
@ -3807,9 +3807,9 @@ init_gamma_vector_option (Genesys_Scanner * scanner, int option)
static SANE_Range create_range(float size) static SANE_Range create_range(float size)
{ {
SANE_Range range; SANE_Range range;
range.min = SANE_FIX(0.0); range.min = float_to_fixed(0.0);
range.max = SANE_FIX(size); range.max = float_to_fixed(size);
range.quant = SANE_FIX(0.0); range.quant = float_to_fixed(0.0);
return range; return range;
} }
@ -4226,7 +4226,7 @@ static void init_options(Genesys_Scanner* s)
s->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT;
s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE;
s->opt[OPT_THRESHOLD].constraint.range = &percentage_range; s->opt[OPT_THRESHOLD].constraint.range = &percentage_range;
s->threshold = SANE_FIX(50); s->threshold = float_to_fixed(50);
/* BW threshold curve */ /* BW threshold curve */
s->opt[OPT_THRESHOLD_CURVE].name = "threshold-curve"; s->opt[OPT_THRESHOLD_CURVE].name = "threshold-curve";
@ -5176,7 +5176,7 @@ static void print_option(DebugMessageHelper& dbg, const Genesys_Scanner& s, int
return; return;
} }
case SANE_TYPE_FIXED: { case SANE_TYPE_FIXED: {
dbg.vlog(DBG_proc, "value: %f", SANE_UNFIX(*reinterpret_cast<SANE_Word*>(val))); dbg.vlog(DBG_proc, "value: %f", fixed_to_float(*reinterpret_cast<SANE_Word*>(val)));
return; return;
} }
case SANE_TYPE_STRING: { case SANE_TYPE_STRING: {
@ -5904,7 +5904,7 @@ void sane_start_impl(SANE_Handle handle)
if (s->swskip > 0 && IS_ACTIVE(OPT_SWSKIP)) { if (s->swskip > 0 && IS_ACTIVE(OPT_SWSKIP)) {
auto status = sanei_magic_isBlank(&s->params, auto status = sanei_magic_isBlank(&s->params,
s->dev->img_buffer.data(), s->dev->img_buffer.data(),
SANE_UNFIX(s->swskip)); fixed_to_float(s->swskip));
if (status == SANE_STATUS_NO_DOCS && s->dev->model->is_sheetfed) { if (status == SANE_STATUS_NO_DOCS && s->dev->model->is_sheetfed) {
DBG(DBG_info, "%s: blank page, recurse\n", __func__); DBG(DBG_info, "%s: blank page, recurse\n", __func__);

Wyświetl plik

@ -143,7 +143,7 @@ public:
auto i = find_option(name, SANE_TYPE_FIXED); auto i = find_option(name, SANE_TYPE_FIXED);
int value = 0; int value = 0;
TIE(sane_control_option(handle_, i, SANE_ACTION_GET_VALUE, &value, nullptr)); TIE(sane_control_option(handle_, i, SANE_ACTION_GET_VALUE, &value, nullptr));
return static_cast<float>(SANE_UNFIX(value)); return genesys::fixed_to_float(value);
} }
void set_value_float(const std::string& name, float value) void set_value_float(const std::string& name, float value)