From a2af61540c571f9ee61ca73d56dc83031f6ff72b Mon Sep 17 00:00:00 2001 From: Henning Geinitz Date: Sat, 13 Oct 2001 15:54:38 +0000 Subject: [PATCH] Don't send gimp images with more then 8 bits/color. Patches from mh . Changed name of find-scanner to sane-find-scanner. Henning Meier-Geinitz --- src/xscanimage.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/xscanimage.c b/src/xscanimage.c index ad89853..2399c26 100644 --- a/src/xscanimage.c +++ b/src/xscanimage.c @@ -923,8 +923,9 @@ scan_start (void) case SANE_FRAME_RED: case SANE_FRAME_GREEN: case SANE_FRAME_BLUE: - fprintf (scan_win.out, "P6\n# SANE data follows\n%d %d\n255\n", - scan_win.param.pixels_per_line, scan_win.param.lines); + fprintf (scan_win.out, "P6\n# SANE data follows\n%d %d\n%d\n", + scan_win.param.pixels_per_line, scan_win.param.lines, + (scan_win.param.depth <= 8) ? 255 : 65535); break; case SANE_FRAME_GRAY: @@ -932,8 +933,9 @@ scan_start (void) fprintf (scan_win.out, "P4\n# SANE data follows\n%d %d\n", scan_win.param.pixels_per_line, scan_win.param.lines); else - fprintf (scan_win.out, "P5\n# SANE data follows\n%d %d\n255\n", - scan_win.param.pixels_per_line, scan_win.param.lines); + fprintf (scan_win.out, "P5\n# SANE data follows\n%d %d\n%d\n", + scan_win.param.pixels_per_line, scan_win.param.lines, + (scan_win.param.depth <= 8) ? 255 : 65535); break; } scan_win.header_size = ftell (scan_win.out); @@ -952,6 +954,15 @@ scan_start (void) size_t tile_size; /* We are running under the GIMP */ + /* Check whether the selected bit depth is supported by the Gimp */ + if (scan_win.param.depth > 8) + { + gsg_set_sensitivity (dialog, TRUE); + snprintf (buf, sizeof (buf), "The Gimp doesn't support images " + "with %d bits/channel.", scan_win.param.depth); + gsg_error (buf); + return; + } scan_win.tile_offset = 0; tile_size = scan_win.param.pixels_per_line * gimp_tile_height (); @@ -1769,7 +1780,7 @@ interface (int argc, char **argv) { DBG (DBG_fatal, "No scanners were identified. If you were expecting something\n" " different, check that the scanner is plugged in, turned on and\n" - " detected by the find-scanner tool (if appropriate). Please read\n" + " detected by sane-find-scanner (if appropriate). Please read\n" " the documentation which came with this software (README, FAQ,\n" " manpages).\n"); quit_xscanimage ();