diff options
author | Alessio Treglia <quadrispro@ubuntu.com> | 2010-04-14 12:24:35 +0200 |
---|---|---|
committer | Alessio Treglia <quadrispro@ubuntu.com> | 2010-04-14 12:24:35 +0200 |
commit | a9a833c10711f1ec7060322030f11e64f44fca2c (patch) | |
tree | 2c0d84e44be6ed79c04b79540d55618ba73479aa /src/scanner.c | |
parent | c2e54e51031fa4b2512b851d13f5781118269d6b (diff) | |
parent | 6d9871f7c7de6caca9eb78683bcba499119e1469 (diff) |
Merge commit 'upstream/1.0.0'
Diffstat (limited to 'src/scanner.c')
-rw-r--r-- | src/scanner.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/scanner.c b/src/scanner.c index daf1b15..9181868 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -99,6 +99,9 @@ struct ScannerPrivate /* Last option read */ SANE_Int option_index; + + /* Option index for scan area */ + SANE_Int br_x_option_index, br_y_option_index; /* Buffer for received line */ SANE_Byte *buffer; @@ -869,6 +872,8 @@ do_open (Scanner *scanner) scanner->priv->page_number = 0; scanner->priv->notified_page = -1; scanner->priv->option_index = 0; + scanner->priv->br_x_option_index = 0; + scanner->priv->br_y_option_index = 0; if (!job->device && scanner->priv->default_device) job->device = g_strdup (scanner->priv->default_device); @@ -919,7 +924,7 @@ do_get_option (Scanner *scanner) const SANE_Option_Descriptor *option; SANE_Int option_index; ScanJob *job; - + job = (ScanJob *) scanner->priv->job_queue->data; option = sane_get_option_descriptor (scanner->priv->handle, scanner->priv->option_index); @@ -928,6 +933,28 @@ do_get_option (Scanner *scanner) scanner->priv->option_index++; if (!option) { + /* Always use maximum scan area - some scanners default to using partial areas. This should be patched in sane-backends */ + if (scanner->priv->br_x_option_index) { + option = sane_get_option_descriptor (scanner->priv->handle, scanner->priv->br_x_option_index); + g_debug ("sane_get_option_descriptor (%d)", scanner->priv->br_x_option_index); + if (option->constraint_type == SANE_CONSTRAINT_RANGE) { + if (option->type == SANE_TYPE_FIXED) + set_fixed_option (scanner->priv->handle, option, scanner->priv->br_x_option_index, SANE_UNFIX (option->constraint.range->max), NULL); + else + set_int_option (scanner->priv->handle, option, scanner->priv->br_x_option_index, option->constraint.range->max, NULL); + } + } + if (scanner->priv->br_y_option_index) { + option = sane_get_option_descriptor (scanner->priv->handle, scanner->priv->br_y_option_index); + g_debug ("sane_get_option_descriptor (%d)", scanner->priv->br_y_option_index); + if (option->constraint_type == SANE_CONSTRAINT_RANGE) { + if (option->type == SANE_TYPE_FIXED) + set_fixed_option (scanner->priv->handle, option, scanner->priv->br_y_option_index, SANE_UNFIX (option->constraint.range->max), NULL); + else + set_int_option (scanner->priv->handle, option, scanner->priv->br_y_option_index, option->constraint.range->max, NULL); + } + } + scanner->priv->state = STATE_START; return; } @@ -1091,21 +1118,10 @@ do_get_option (Scanner *scanner) if (!set_constrained_string_option (scanner->priv->handle, option, option_index, disable_compression_names, NULL)) g_warning ("Unable to disable compression, please file a bug"); } - /* Always use maximum scan area - some scanners default to using partial areas. This should be patched in sane-backends */ - else if (strcmp (option->name, SANE_NAME_SCAN_BR_X) == 0 || - strcmp (option->name, SANE_NAME_SCAN_BR_Y) == 0) { - switch (option->constraint_type) - { - case SANE_CONSTRAINT_RANGE: - if (option->type == SANE_TYPE_FIXED) - set_fixed_option (scanner->priv->handle, option, option_index, SANE_UNFIX (option->constraint.range->max), NULL); - else - set_int_option (scanner->priv->handle, option, option_index, option->constraint.range->max, NULL); - break; - default: - break; - } - } + else if (strcmp (option->name, SANE_NAME_SCAN_BR_X) == 0) + scanner->priv->br_x_option_index = option_index; + else if (strcmp (option->name, SANE_NAME_SCAN_BR_Y) == 0) + scanner->priv->br_y_option_index = option_index; else if (strcmp (option->name, SANE_NAME_PAGE_WIDTH) == 0) { if (job->page_width > 0.0) { if (option->type == SANE_TYPE_FIXED) |