[sane-devel] New snapshots available: sane 1.0.10-pre2

Andrea Suatoni a.suatoni at telefonica.net
Fri Jan 24 02:56:18 GMT 2003


Henning Meier-Geinitz wrote:

> There are new snapshots of ssane-backends and sane-frontends avilable
> at http://www.mostang.com/sane/ .

So, please find the attached patches I've applied to build this release on
IRIX. Some comments:

1) If HAVE_STRSEP and/or HAVE_STRNDUP are not defined, sane-backends _MUST_
define in some way the supplied functions prototypes. The compiler must know
that these two functions return char *, otherwise it will assume int and will
issue errors when the functions result is assigned to a char *. I've moved the
two prototypes in sanei.h, but maybe there is a better place for them.

2) The test backend had an incorrect comment suggesting that test-picture
could assume the value "Color patterns". Instead, the correct value is "Color
pattern": trying to use the wrong value makes xcam to crash.

3) I've tried to fix the xcam code related to the GdkImage data buffer
filling. I've resorted to the RGB shift values contained in the GdkVisual
associated to the image. It seems to work pretty well now, and should be more
portable among different platforms and X11 visuals. The code should be tested
on little endian architectures, and with 15 or 16 bits visuals. Also note that
I didn't implement the support for the 30 bits visuals offered by the SGI Fuel
graphic engine (that would be RGB or BGR format, with each channel having real
10 bits of range).

4) To the author of the HP backend: why the bits depth parameter is a string
instead of an integer? And why is so slow when switching modes (eg, from
Lineart to Color)? I've used an HP 6300C (without XPA) for the test.

Hope it helps,
Andrea
-------------- next part --------------
diff -ruN sane-backends-1.0.10-pre2/acinclude.m4 sane-backends-1.0.10-pre2-patched/acinclude.m4
--- sane-backends-1.0.10-pre2/acinclude.m4	Mon Dec  9 11:43:38 2002
+++ sane-backends-1.0.10-pre2-patched/acinclude.m4	Wed Jan 22 21:29:44 2003
@@ -336,8 +336,7 @@
 
 			CPPFLAGS="${CPPFLAGS} `gphoto2-config --cflags`"
 			GPHOTO2_LIBS="`gphoto2-config --libs`"
-			SANE_EXTRACT_LDFLAGS(LDFLAGS, GPHOTO2_LIBS)
-			LIBS="${LIBS} ${GPHOTO2_LIBS}"
+			AC_SUBST(GPHOTO2_LIBS)
 		fi
 ])	fi
 ])
diff -ruN sane-backends-1.0.10-pre2/backend/Makefile.in sane-backends-1.0.10-pre2-patched/backend/Makefile.in
--- sane-backends-1.0.10-pre2/backend/Makefile.in	Mon Jan 13 22:38:09 2003
+++ sane-backends-1.0.10-pre2-patched/backend/Makefile.in	Wed Jan 22 21:31:36 2003
@@ -46,6 +46,7 @@
 CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
 BACKENDLIBS = @LIBS@ @DL_LIB@
+GPHOTO2_LIBS = @GPHOTO2_LIBS@
 DEFS = @DEFS@
 DYNAMIC_FLAG=@DYNAMIC_FLAG@
 
@@ -147,6 +148,11 @@
 
 
 .PHONY: all clean depend dist distclean install uninstall
+
+libsane-gphoto2.la: gphoto2.lo gphoto2-s.lo $(EXTRA) $(LIBOBJS)
+	@$(LIBTOOL) $(MLINK) $(CC) -export-dynamic -o $@ $($*_LIBS) \
+	$(LDFLAGS) $(GPHOTO2_LIBS) $(BACKENDLIBS) $^ -rpath $(libsanedir) \
+	-version-info $(V_MAJOR):$(V_REV):$(V_MINOR) $(DYNAMIC_FLAG)
 
 libsane-%.la: %.lo %-s.lo $(EXTRA) $(LIBOBJS)
 	@$(LIBTOOL) $(MLINK) $(CC) -export-dynamic -o $@ $($*_LIBS) \
diff -ruN sane-backends-1.0.10-pre2/backend/bh.c sane-backends-1.0.10-pre2-patched/backend/bh.c
--- sane-backends-1.0.10-pre2/backend/bh.c	Fri Nov 22 00:08:45 2002
+++ sane-backends-1.0.10-pre2-patched/backend/bh.c	Wed Jan 22 21:32:50 2003
@@ -135,7 +135,7 @@
 {
   return (i > 0 && i < NELEMS(barcode_search_bar_list)) ? 
     barcode_search_bar_list[i] : 
-    (const SANE_String) "unknown";
+    (SANE_String_Const) "unknown";
 }
 
 static SANE_String_Const
diff -ruN sane-backends-1.0.10-pre2/backend/coolscan.c sane-backends-1.0.10-pre2-patched/backend/coolscan.c
--- sane-backends-1.0.10-pre2/backend/coolscan.c	Thu Oct 10 18:29:29 2002
+++ sane-backends-1.0.10-pre2-patched/backend/coolscan.c	Wed Jan 22 21:34:11 2003
@@ -1700,7 +1700,7 @@
 
   DBG (10, "get_inquiry_values\n");
 
-  inquiry_block = s->buffer;
+  inquiry_block = (char *) s->buffer;
   s->inquiry_len = 36;
 
   get_inquiry_vendor (inquiry_block, s->vendor);
diff -ruN sane-backends-1.0.10-pre2/backend/dc210.c sane-backends-1.0.10-pre2-patched/backend/dc210.c
--- sane-backends-1.0.10-pre2/backend/dc210.c	Fri Jan 10 12:21:51 2003
+++ sane-backends-1.0.10-pre2-patched/backend/dc210.c	Wed Jan 22 21:37:09 2003
@@ -412,9 +412,9 @@
    /* and wait for it to recover from the break */
 
 #ifdef HAVE_USLEEP
-   usleep (breakpause);
+  usleep (breakpause);
 #else
-+  sleep (1);
+  sleep (1);
 #endif
 
   if (send_pck (camera->fd, init_pck) == -1)
diff -ruN sane-backends-1.0.10-pre2/backend/test.c sane-backends-1.0.10-pre2-patched/backend/test.c
--- sane-backends-1.0.10-pre2/backend/test.c	Fri Jan 24 01:50:24 2003
+++ sane-backends-1.0.10-pre2-patched/backend/test.c	Wed Dec 18 12:15:38 2002
@@ -415,7 +415,7 @@
     SANE_I18N ("Select the kind of test picture. Available options:\n"
 	       "Solid black: fills the whole scan with black.\n"
 	       "Solid white: fills the whole scan with white.\n"
-	       "Color patterns: draws various color test patterns "
+	       "Color pattern: draws various color test patterns "
 	       "depending on the mode.\n"
 	       "Grid: draws a black/white grid with a width and "
 	       "height of 10 mm per square.");
diff -ruN sane-backends-1.0.10-pre2/backend/test.conf sane-backends-1.0.10-pre2-patched/backend/test.conf
--- sane-backends-1.0.10-pre2/backend/test.conf	Fri Jan 24 01:50:41 2003
+++ sane-backends-1.0.10-pre2-patched/backend/test.conf	Wed Jul 24 20:48:30 2002
@@ -28,7 +28,7 @@
 resolution_quant 1.0
 resolution 50.0
 
-# Draw test picture ("Solid black", "Solid white", "Color patterns", "Grid")
+# Draw test picture ("Solid black", "Solid white", "Color pattern", "Grid")
 test-picture "Solid black"
 
 # Invert upper and lower byte in 16 bit modes
diff -ruN sane-backends-1.0.10-pre2/include/sane/sanei.h sane-backends-1.0.10-pre2-patched/include/sane/sanei.h
--- sane-backends-1.0.10-pre2/include/sane/sanei.h	Thu Feb 14 23:25:33 2002
+++ sane-backends-1.0.10-pre2-patched/include/sane/sanei.h	Thu Jan 23 00:47:10 2003
@@ -65,6 +65,16 @@
 
 #include <sane/sane.h>
 
+/* Define a the function prototypes if these function are missing. */
+#ifndef HAVE_STRSEP
+char *strsep(char **stringp, const char *delim);
+#endif
+
+#ifndef HAVE_STRNDUP
+#include <sys/types.h>
+char *strndup(const char * s, size_t n);
+#endif
+
 /** @name Public macros and functions
  * @{
  */
-------------- next part --------------
diff -ruN sane-frontends-1.0.10-pre2/src/xcam.c sane-frontends-1.0.10-pre2-patched/src/xcam.c
--- sane-frontends-1.0.10-pre2/src/xcam.c	Thu Jan  9 14:02:30 2003
+++ sane-frontends-1.0.10-pre2-patched/src/xcam.c	Fri Jan 24 03:23:45 2003
@@ -653,42 +653,37 @@
       break;								\
 									\
     case 15:								\
-      rgb = (  (((r) >> 11) << 10)	/* 5 bits of red */		\
-	     | (((g) >> 11) <<  5)	/* 5 bits of green */		\
-	     | (((b) >> 11) <<  0));	/* 5 bits of blue */		\
-      ((guint16 *)buf)[0] = rgb;					\
-      buf += (bpp);							\
-      break;								\
-									\
     case 16:								\
-      rgb = (  (((r) >> 11) << 11)	/* 5 bits of red */		\
-	     | (((g) >> 10) <<  5)	/* 6 bits of green */		\
-	     | (((b) >> 11) <<  0));	/* 5 bits of blue */		\
+      rgb = (  (((r) >> 8) << r_shift)					\
+	     | (((g) >> 8) << g_shift)					\
+	     | (((b) >> 8) << b_shift));				\
       ((guint16 *)buf)[0] = rgb;					\
       buf += (bpp);							\
       break;								\
 									\
     case 24:								\
-      /* Is this correctly handling all byte order cases? */		\
-      if ((endian) == GDK_LSB_FIRST)					\
+    case 32:								\
+      if (bpp == 4)							\
 	{								\
-	  buf[0] = (b) >> 8; buf[1] = (g) >> 8; buf[2] = (r) >> 8;	\
+	  rgb = (  (((r) >> 8) << r_shift)				\
+		 | (((g) >> 8) << g_shift)				\
+		 | (((b) >> 8) << b_shift));				\
+	  ((guint32 *)buf)[0] = rgb;					\
 	}								\
       else								\
 	{								\
-	  buf[0] = (r) >> 8; buf[1] = (g) >> 8; buf[2] = (b) >> 8;	\
+	  if (   ((endian) == GDK_LSB_FIRST && r_shift == 0)		\
+	      || ((endian) == GDK_MSB_FIRST && b_shift == 0))		\
+	    {								\
+	       buf[0] = (r) >> 8; buf[1] = (g) >> 8; buf[2] = (b) >> 8;	\
+	    }								\
+	  else								\
+	    {								\
+	       buf[0] = (b) >> 8; buf[1] = (g) >> 8; buf[2] = (r) >> 8;	\
+	    }								\
 	}								\
       buf += (bpp);							\
       break;								\
-									\
-    case 32:								\
-      /* Is this correctly handling all byte order cases?  It assumes	\
-	 the byte order of the host is the same as that of the		\
-	 pixmap. */							\
-      rgb = (((r) >> 8) << 16) | (((g) >> 8) << 8) | ((b) >> 8);	\
-      ((guint32 *)buf)[0] = rgb;					\
-      buf += (bpp);							\
-      break;								\
     }									\
 }
 
@@ -697,6 +692,7 @@
 {
   int x, pixels_per_line, bytes_per_line, dst_depth, src_depth;
   guint32 r = 0, g = 0, b = 0, lum, rgb, src_mask, dst_mask;
+  gint r_shift, b_shift, g_shift;
   size_t buf_size, remaining = win.remaining;
   SANE_Byte *src, *src_end;
   GdkByteOrder byte_order;
@@ -723,6 +719,10 @@
   dst = win.data;
   src_mask = 0x80;	/* SANE has left most bit is most significant bit */
   dst_mask = 0x01;
+
+  r_shift = win.canvas.gdk_image->visual->red_shift;
+  g_shift = win.canvas.gdk_image->visual->green_shift;
+  b_shift = win.canvas.gdk_image->visual->blue_shift;
 
   while (1)
     {


More information about the sane-devel mailing list