Avoid unaligned 1 bit previews. Fixed 1 bit color mode (also three-pass).

Changed 1 bit color modes to most significant bit is first pixel.
DEVEL_2_0_BRANCH-1
Henning Geinitz 2002-09-30 13:48:46 +00:00
rodzic 6ea3e5ff02
commit 1247dc65b8
2 zmienionych plików z 30 dodań i 12 usunięć

Wyświetl plik

@ -1,3 +1,9 @@
2002-09-30 Henning Meier-Geinitz <henning@meier-geinitz.de>
* src/preview.c: Avoid unaligned 1 bit previews. Fixed 1 bit color mode
(also three-pass). Changed 1 bit color modes to most significant bit
is first pixel.
---- FEATURE FREEZE FOR SANE 1.0.9 ---
-- snapshot 1.0.9-pre1

Wyświetl plik

@ -589,11 +589,12 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
{
u_char mask = buf[i];
for (j = 0; j < 8; ++j)
for (j = 7; j >= 0; --j)
{
u_char gl = (mask & (1 << j)) ? 0xff : 0x00;
p->image_data[p->image_offset] = gl;
if (j < 7)
if (j != 0)
p->image_offset += 3;
else
{
@ -602,16 +603,16 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
else
p->image_offset++;
}
if ((i % 3) == 0 && ++p->image_x >= p->image_width)
if (p->image_offset % 3 == 0)
{
if (increment_image_y (p) < 0)
return;
break; /* skip padding bits */
if (++p->image_x >= p->image_width)
{
if (increment_image_y (p) < 0)
return;
}
}
}
}
break;
case 8:
@ -718,10 +719,9 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
{
u_char mask = buf[i];
for (j = 0; j < 8; ++j)
for (j = 7; j >= 0; --j)
{
u_char gl = (mask & 1) ? 0xff : 0x00;
mask >>= 1;
u_char gl = (mask & (1 << j)) ? 0xff : 0x00;
p->image_data[p->image_offset] = gl;
p->image_offset += 3;
if (++p->image_x >= p->image_width
@ -858,6 +858,18 @@ scan_start (Preview *p)
return;
}
if ((p->params.format >= SANE_FRAME_RGB &&
p->params.format <= SANE_FRAME_BLUE) &&
p->params.depth == 1 &&
p->params.pixels_per_line % 8 != 0)
{
snprintf (buf, sizeof (buf),
"Can't handle unaligned 1 bit RGB or three-pass mode.");
gsg_error (buf);
scan_done (p);
return;
}
p->image_offset = p->image_x = p->image_y = 0;
if (p->params.format >= SANE_FRAME_RED
@ -876,7 +888,7 @@ scan_start (Preview *p)
if (p->image_height < 0)
p->image_height = 32; /* may have to adjust as we go... */
p->image_data = malloc (3*p->image_width*p->image_height);
fprintf(stderr, "allocating %d bytes\n", 3*p->image_width*p->image_height);
if (!p->image_data)
{
snprintf (buf, sizeof (buf),