kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Extract conversion of ScanColorMode to separate functions
rodzic
3ad5a92414
commit
42a58387b6
|
@ -70,4 +70,29 @@ ScanMethod option_string_to_scan_method(const std::string& str)
|
|||
throw SaneException("Unknown scan method option %s", str.c_str());
|
||||
}
|
||||
|
||||
const char* scan_color_mode_to_option_string(ScanColorMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case ScanColorMode::COLOR_SINGLE_PASS: return SANE_VALUE_SCAN_MODE_COLOR;
|
||||
case ScanColorMode::GRAY: return SANE_VALUE_SCAN_MODE_GRAY;
|
||||
case ScanColorMode::HALFTONE: return SANE_VALUE_SCAN_MODE_HALFTONE;
|
||||
case ScanColorMode::LINEART: return SANE_VALUE_SCAN_MODE_LINEART;
|
||||
}
|
||||
throw SaneException("Unknown scan mode %d", static_cast<unsigned>(mode));
|
||||
}
|
||||
|
||||
ScanColorMode option_string_to_scan_color_mode(const std::string& str)
|
||||
{
|
||||
if (str == SANE_VALUE_SCAN_MODE_COLOR) {
|
||||
return ScanColorMode::COLOR_SINGLE_PASS;
|
||||
} else if (str == SANE_VALUE_SCAN_MODE_GRAY) {
|
||||
return ScanColorMode::GRAY;
|
||||
} else if (str == SANE_VALUE_SCAN_MODE_HALFTONE) {
|
||||
return ScanColorMode::HALFTONE;
|
||||
} else if (str == SANE_VALUE_SCAN_MODE_LINEART) {
|
||||
return ScanColorMode::LINEART;
|
||||
}
|
||||
throw SaneException("Unknown scan color mode %s", str.c_str());
|
||||
}
|
||||
|
||||
} // namespace genesys
|
||||
|
|
|
@ -94,6 +94,8 @@ inline void serialize(std::ostream& str, ScanColorMode& x)
|
|||
serialize(str, value);
|
||||
}
|
||||
|
||||
const char* scan_color_mode_to_option_string(ScanColorMode mode);
|
||||
ScanColorMode option_string_to_scan_color_mode(const std::string& str);
|
||||
|
||||
enum class ColorFilter : unsigned {
|
||||
RED = 0,
|
||||
|
|
|
@ -3511,15 +3511,7 @@ static void calc_parameters(Genesys_Scanner* s)
|
|||
bytes_per_line *= 3;
|
||||
}
|
||||
|
||||
if (s->mode == SANE_VALUE_SCAN_MODE_COLOR) {
|
||||
s->dev->settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
|
||||
} else if (s->mode == SANE_VALUE_SCAN_MODE_GRAY) {
|
||||
s->dev->settings.scan_mode = ScanColorMode::GRAY;
|
||||
} else if (s->mode == SANE_TITLE_HALFTONE) {
|
||||
s->dev->settings.scan_mode = ScanColorMode::HALFTONE;
|
||||
} else { /* Lineart */
|
||||
s->dev->settings.scan_mode = ScanColorMode::LINEART;
|
||||
}
|
||||
s->dev->settings.scan_mode = option_string_to_scan_color_mode(s->mode);
|
||||
|
||||
s->dev->settings.lines = s->params.lines;
|
||||
s->dev->settings.pixels = pixels_per_line;
|
||||
|
|
Ładowanie…
Reference in New Issue