genesys: Implement host-side gray support

pixma-add-canon-ts-3400-series
Povilas Kanapickas 2021-12-27 22:21:03 +02:00
rodzic 2f030f04e2
commit 7bbb6d8fdb
4 zmienionych plików z 30 dodań i 1 usunięć

Wyświetl plik

@ -526,6 +526,9 @@ enum class ModelFlag : unsigned
// disable fast feeding mode on this scanner
DISABLE_FAST_FEEDING = 1 << 14,
// scan gray scans as color and combine on host side
HOST_SIDE_GRAY = 1 << 15,
// the scanner uses multi-segment sensors that must be handled during calibration
SIS_SENSOR = 1 << 16,

Wyświetl plik

@ -445,6 +445,10 @@ Image read_unshuffled_image_from_scanner(Genesys_Device* dev, const ScanSession&
pipeline.push_node<ImagePipelineNodeMergeMonoLinesToColor>(dev->model->line_mode_color_order);
}
if (session.use_host_side_gray) {
pipeline.push_node<ImagePipelineNodeMergeColorToGray>();
}
if (pipeline.get_output_format() == PixelFormat::BGR888) {
pipeline.push_node<ImagePipelineNodeFormatConvert>(PixelFormat::RGB888);
}
@ -954,6 +958,14 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se
s.output_startx = static_cast<unsigned>(
static_cast<int>(s.params.startx) + sensor.output_pixel_offset);
if (has_flag(dev->model->flags, ModelFlag::HOST_SIDE_GRAY) && s.params.channels == 1 &&
s.params.color_filter == ColorFilter::NONE)
{
s.use_host_side_gray = true;
s.params.channels = 3;
s.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS;
}
s.stagger_x = sensor.stagger_x;
s.stagger_y = sensor.stagger_y;
@ -1280,6 +1292,14 @@ ImagePipelineStack build_image_pipeline(const Genesys_Device& dev, const ScanSes
}
}
if (session.use_host_side_gray) {
pipeline.push_node<ImagePipelineNodeMergeColorToGray>();
if (log_image_data) {
pipeline.push_node<ImagePipelineNodeDebug>(debug_prefix + "_10_after_nogray.tiff");
}
}
if (pipeline.get_output_width() != session.params.get_requested_pixels()) {
pipeline.push_node<ImagePipelineNodeScaleRows>(session.params.get_requested_pixels());
}

Wyświetl plik

@ -129,7 +129,8 @@ bool ScanSession::operator==(const ScanSession& other) const
shading_pixel_offset == other.shading_pixel_offset &&
buffer_size_read == other.buffer_size_read &&
enable_ledadd == other.enable_ledadd &&
use_host_side_calib == other.use_host_side_calib;
use_host_side_calib == other.use_host_side_calib &&
use_host_side_gray == other.use_host_side_gray;
}
std::ostream& operator<<(std::ostream& out, const ScanSession& session)
@ -166,6 +167,7 @@ std::ostream& operator<<(std::ostream& out, const ScanSession& session)
<< " buffer_size_read: " << session.buffer_size_read << '\n'
<< " enable_ledadd: " << session.enable_ledadd << '\n'
<< " use_host_side_calib: " << session.use_host_side_calib << '\n'
<< " use_host_side_gray: " << session.use_host_side_gray << '\n'
<< " params: " << format_indent_braced_list(4, session.params) << '\n'
<< "}";
return out;

Wyświetl plik

@ -324,6 +324,9 @@ struct ScanSession {
// whether calibration should be performed host-side
bool use_host_side_calib = false;
// whether gray scanning should be performed host-side (scan as color and merge to gray)
bool use_host_side_gray = false;
void assert_computed() const
{
if (!computed) {
@ -375,6 +378,7 @@ void serialize(Stream& str, ScanSession& x)
serialize(str, x.buffer_size_read);
serialize(str, x.enable_ledadd);
serialize(str, x.use_host_side_calib);
serialize(str, x.use_host_side_gray);
}
std::ostream& operator<<(std::ostream& out, const SANE_Parameters& params);