gnome-scan r726 - in trunk: . modules/gsane
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r726 - in trunk: . modules/gsane
- Date: Sun, 21 Dec 2008 14:31:27 +0000 (UTC)
Author: bersace
Date: Sun Dec 21 14:31:27 2008
New Revision: 726
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=726&view=rev
Log:
Support 1bit three-pass acquisition.
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 Sun Dec 21 14:31:27 2008
@@ -50,7 +50,9 @@
guint32 max_target_sample_value;
/* exact portion of bytes used to reprÃsent one pixel in the frame */
gdouble bytes_per_pixel;
- /* minimal amount of bytes needed to contain one pixel */
+ /* minimal amount of bytes needed to contain one pixel, this
+ is usualy the final stride since we don't convert but just
+ normalize to 8bit-multiple depth. */
guint pixel_stride;
/* minimal amount of bytes needed to contain one sample in the frame */
guint sample_stride;
@@ -183,10 +185,29 @@
}
static void
+gsane_processor_process_three_pass_1bit(GSaneProcessor *self, guchar *buf, guint buf_len)
+{
+ GeglRectangle roi = self->priv->rect;
+ guchar *buf3 = g_new0(guchar, self->priv->frame_count * buf_len * 8);
+ guint i, j;
+ guint dest;
+ gegl_buffer_get(self->priv->buffer, 1.0, &roi, self->priv->format, buf3, GEGL_AUTO_ROWSTRIDE);
+ for (i = 0; i < buf_len; i++) {
+ for (j = 0; j < 8; j++) {
+ dest = (i * 8 + j) * self->priv->frame_count + self->priv->sample_offset;
+ buf3[dest] = (buf[i] & (1 << (7 - j))) ? 0xFF : 0x00;
+ }
+ }
+ /* send */
+ gegl_buffer_set(self->priv->buffer, &roi, self->priv->format, buf3, GEGL_AUTO_ROWSTRIDE);
+ g_free(buf3);
+}
+
+static void
gsane_processor_process_three_pass_8bit(GSaneProcessor *self, guchar *buf, guint buf_len)
{
GeglRectangle roi = self->priv->rect;
- guchar *buf3 = g_new0(guchar, self->priv->frame_count*buf_len);
+ guchar *buf3 = g_new0(guchar, self->priv->frame_count * buf_len);
guint i;
guint src_pos, dest_pos;
gegl_buffer_get(self->priv->buffer, 1.0, &roi, self->priv->format, buf3, GEGL_AUTO_ROWSTRIDE);
@@ -221,8 +242,10 @@
case SANE_FRAME_RED:
case SANE_FRAME_GREEN:
case SANE_FRAME_BLUE:
- if (self->priv->params->depth%8 == 0)
+ if (self->priv->params->depth % 8 == 0)
func = gsane_processor_process_three_pass_8bit;
+ else if (self->priv->params->depth == 1)
+ func = gsane_processor_process_three_pass_1bit;
else
g_warning("Unsupported %dbit three-pass frame format", self->priv->params->depth);
break;
@@ -277,7 +300,7 @@
}
/* Return the offset in pixel stride of the samples acquired in
- current frame.*/
+ current frame. */
static guint
gsane_processor_get_sample_offset(GSaneProcessor *self)
{
@@ -285,9 +308,9 @@
case SANE_FRAME_RED:
return 0;
case SANE_FRAME_GREEN:
- return self->priv->bytes_per_pixel;
+ return self->priv->pixel_stride;
case SANE_FRAME_BLUE:
- return 2 * self->priv->bytes_per_pixel;
+ return 2 * self->priv->pixel_stride;
default:
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]