Jeremy White : sane.ds: Get resolution from sane, instead of hard coding -1 .

Alexandre Julliard julliard at winehq.org
Mon Feb 16 09:34:57 CST 2009


Module: wine
Branch: master
Commit: 4b794bee9a3bad1a3744e5563d61a4861cff83b9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4b794bee9a3bad1a3744e5563d61a4861cff83b9

Author: Jeremy White <jwhite at codeweavers.com>
Date:   Fri Feb 13 13:14:30 2009 -0600

sane.ds: Get resolution from sane, instead of hard coding -1.

---

 dlls/sane.ds/Makefile.in |    1 +
 dlls/sane.ds/ds_image.c  |    7 ++++-
 dlls/sane.ds/options.c   |   49 ++++++++++++++++++++++++++++++++++++++++++++++
 dlls/sane.ds/sane_i.h    |    6 +++++
 4 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/dlls/sane.ds/Makefile.in b/dlls/sane.ds/Makefile.in
index d8646fe..d136594 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 9a88bb5..5bb6cbb 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 0000000..0ac5c45
--- /dev/null
+++ b/dlls/sane.ds/options.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009 Jeremy White <jwhite at codeweavers.com> 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 <stdlib.h>
+#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 5a3a6d0..7e2f117 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




More information about the wine-cvs mailing list