gnome-scan r780 - in trunk: . modules/gsane



Author: bersace
Date: Thu Jan 15 00:06:03 2009
New Revision: 780
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=780&view=rev

Log:
Fix black&white inverted

Modified:
   trunk/ChangeLog
   trunk/modules/gsane/gsane-processor.c

Modified: trunk/modules/gsane/gsane-processor.c
==============================================================================
--- trunk/modules/gsane/gsane-processor.c	(original)
+++ trunk/modules/gsane/gsane-processor.c	Thu Jan 15 00:06:03 2009
@@ -65,6 +65,11 @@
 	guint32 sample_pattern;
 	/* pointer to the processor function */
 	GSaneProcessorFunc process;
+	/* value for black pixel in 1bit, it changes whether it's grey
+	   or RGB :/ . (see SANE 1.X standard). So we put black and
+	   white value in variable to swap them transparently. */
+	guchar black;
+	guchar white;
 };
 
 
@@ -89,7 +94,7 @@
 	guint i, j;
 	for (i = 0; i < buf_len; i++)
 		for (j = 0; j < 8; j++)
-			buf8[i * 8 + j] = (buf[i] & (1 << (7 - j))) ? 0xFF : 0x00;
+			buf8[i * 8 + j] = (buf[i] & (1 << (7 - j))) ? self->priv->white : self->priv->black;
 	gegl_buffer_set(self->priv->buffer, &roi, self->priv->format, buf8, GEGL_AUTO_ROWSTRIDE);
 	g_free(buf8);
 }
@@ -375,6 +380,17 @@
 	self->priv->params = params;
 	self->priv->bytes_processed = 0;
 	self->priv->sample_offset = gsane_processor_get_sample_offset(self);
+	switch(params->format) {
+	case SANE_FRAME_GRAY:
+		/* Invert black and white. */
+		self->priv->black = 0xFF;
+		self->priv->white = 0x00;
+		break;
+	default:
+		self->priv->black = 0x00;
+		self->priv->white = 0xFF;
+		break;
+	}
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]