diff --git a/dlls/sane.ds/Makefile.in b/dlls/sane.ds/Makefile.in index d8646fecb38..d13659406e6 100644 --- a/dlls/sane.ds/Makefile.in +++ b/dlls/sane.ds/Makefile.in @@ -10,6 +10,7 @@ C_SRCS = \ capability.c \ ds_ctrl.c \ ds_image.c \ + options.c \ sane_main.c \ ui.c diff --git a/dlls/sane.ds/ds_image.c b/dlls/sane.ds/ds_image.c index 9a88bb5dcb7..5bb6cbb26dc 100644 --- a/dlls/sane.ds/ds_image.c +++ b/dlls/sane.ds/ds_image.c @@ -86,6 +86,7 @@ TW_UINT16 SANE_ImageInfoGet (pTW_IDENTITY pOrigin, TW_UINT16 twRC = TWRC_SUCCESS; pTW_IMAGEINFO pImageInfo = (pTW_IMAGEINFO) pData; SANE_Status status; + SANE_Int resolution; TRACE("DG_IMAGE/DAT_IMAGEINFO/MSG_GET\n"); @@ -111,9 +112,11 @@ TW_UINT16 SANE_ImageInfoGet (pTW_IDENTITY pOrigin, activeDS.sane_param_valid = TRUE; } - pImageInfo->XResolution.Whole = -1; + if (sane_option_get_int(activeDS.deviceHandle, "resolution", &resolution) == SANE_STATUS_GOOD) + pImageInfo->XResolution.Whole = pImageInfo->YResolution.Whole = resolution; + else + pImageInfo->XResolution.Whole = pImageInfo->YResolution.Whole = -1; pImageInfo->XResolution.Frac = 0; - pImageInfo->YResolution.Whole = -1; pImageInfo->YResolution.Frac = 0; pImageInfo->ImageWidth = activeDS.sane_param.pixels_per_line; pImageInfo->ImageLength = activeDS.sane_param.lines; diff --git a/dlls/sane.ds/options.c b/dlls/sane.ds/options.c new file mode 100644 index 00000000000..0ac5c454600 --- /dev/null +++ b/dlls/sane.ds/options.c @@ -0,0 +1,49 @@ +/* + * Copyright 2009 Jeremy White for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" + +#include +#include "twain.h" +#include "sane_i.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(twain); + +#ifdef SONAME_LIBSANE +SANE_Status sane_option_get_int(SANE_Handle h, const char *option_name, SANE_Int *val) +{ + SANE_Status rc; + SANE_Int optcount; + const SANE_Option_Descriptor *opt; + int i; + + rc = psane_control_option(h, 0, SANE_ACTION_GET_VALUE, &optcount, NULL); + if (rc != SANE_STATUS_GOOD) + return rc; + + for (i = 1; i < optcount; i++) + { + opt = psane_get_option_descriptor(h, i); + if (opt && (opt->name && strcmp(opt->name, option_name) == 0) && + opt->type == SANE_TYPE_INT ) + return psane_control_option(h, i, SANE_ACTION_GET_VALUE, val, NULL); + } + return SANE_STATUS_EOF; +} +#endif diff --git a/dlls/sane.ds/sane_i.h b/dlls/sane.ds/sane_i.h index 5a3a6d05278..7e2f1177005 100644 --- a/dlls/sane.ds/sane_i.h +++ b/dlls/sane.ds/sane_i.h @@ -211,4 +211,10 @@ TW_UINT16 SANE_RGBResponseSet BOOL DoScannerUI(void); HWND ScanningDialogBox(HWND dialog, LONG progress); +/* Option functions */ +#ifdef SONAME_LIBSANE +SANE_Status sane_option_get_int(SANE_Handle h, const char *option_name, SANE_Int *val); +#endif + + #endif