Fixed 1 bit color three-pass mode. Added 16 bit modes. Added 1 bit color

mode.
Henning Meier-Geinitz <henning@meier-geinitz.de>
DEVEL_2_0_BRANCH-1
Henning Geinitz 2002-04-01 20:55:27 +00:00
rodzic 1621c05f59
commit ec89da2212
2 zmienionych plików z 102 dodań i 10 usunięć

Wyświetl plik

@ -1,3 +1,8 @@
2002-04-01 Henning Meier-Geinitz <henning@meier-geinitz.de>
* src/preview.c: Fixed 1 bit color three-pass mode. Added 16 bit modes.
Added 1 bit color mode.
2002-03-28 Henning Meier-Geinitz <henning@meier-geinitz.de>
* Makefile.in: Remove *.tar.gz when making distclean.

Wyświetl plik

@ -563,18 +563,66 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
switch (p->params.format)
{
case SANE_FRAME_RGB:
if (p->params.depth != 8)
goto bad_depth;
for (i = 0; i < len; ++i)
switch (p->params.depth)
{
p->image_data[p->image_offset++] = buf[i];
if (p->image_offset%3 == 0)
case 1:
for (i = 0; i < len; ++i)
{
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
return;
u_char mask = buf[i];
for (j = 7; j >= 0; --j)
{
u_char gl = (mask & (1 << j)) ? 0xff : 0x00;
p->image_data[p->image_offset] = gl;
if (j > 0)
p->image_offset += 3;
else
{
if ((p->image_offset % 3) != 2)
p->image_offset -= 20;
else
p->image_offset++;
}
if ((i % 3) == 0 && ++p->image_x >= p->image_width)
{
if (increment_image_y (p) < 0)
return;
break; /* skip padding bits */
}
}
}
break;
case 8:
for (i = 0; i < len; ++i)
{
p->image_data[p->image_offset++] = buf[i];
if (p->image_offset%3 == 0)
{
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
return;
}
}
break;
case 16:
for (i = 0; i < len; ++i)
{
u_int16_t value = buf [i];
if ((i % 2) == 1)
p->image_data[p->image_offset++] = *(u_int8_t *) (&value);
if (p->image_offset%6 == 0)
{
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
return;
}
}
break;
default:
goto bad_depth;
}
break;
@ -614,6 +662,27 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
return;
}
break;
case 16:
for (i = 0; i < len; ++i)
{
u_int16_t value = buf [i];
if ((i % 2) == 1)
{
p->image_data[p->image_offset++] =
*(u_int8_t *) (&value);
p->image_data[p->image_offset++] =
*(u_int8_t *) (&value);
p->image_data[p->image_offset++] =
*(u_int8_t *) (&value);
}
if (p->image_offset%2 == 0)
{
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
return;
}
}
break;
default:
goto bad_depth;
@ -634,7 +703,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
{
u_char gl = (mask & 1) ? 0xff : 0x00;
mask >>= 1;
p->image_data[p->image_offset++] = gl;
p->image_data[p->image_offset] = gl;
p->image_offset += 3;
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
@ -653,6 +722,24 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
return;
}
break;
case 16:
for (i = 0; i < len; ++i)
{
u_int16_t value = buf [i];
if ((i % 2) == 1)
{
p->image_data[p->image_offset] = *(u_int8_t *) (&value);
p->image_offset += 3;
}
if (p->image_offset % 2 == 0)
{
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
return;
}
}
break;
default:
goto bad_depth;