Hi, On Sun, Jan 12, 2003 at 11:17:37PM +0100, Aurelien Jarno wrote: > > A bit too late for 1.0.10 but after that we can include the patch.
I've added a patch based on your code to CVS now. > I modified my patch using your advices, it should be better. Two more changes: I check if the option type is SANE_TYPE_INT or SANE_TYPE_FIXED. And calling sane_control_option should be done before sane_start. Bye, Henning Index: src/xscanimage.c =================================================================== RCS file: /cvsroot/external/sane/sane-frontends/src/xscanimage.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -u -r1.19 -r1.20 --- src/xscanimage.c 30 Dec 2002 14:32:32 -0000 1.19 +++ src/xscanimage.c 2 Feb 2003 00:21:07 -0000 1.20 @@ -394,6 +394,43 @@ #endif /* HAVE_LIBGIMP_GIMP_H */ +static +SANE_Word get_resolution (SANE_Handle dev) +{ + SANE_Status status; + SANE_Word resolution; + SANE_Int num_options, i; + const SANE_Option_Descriptor *option_desc; + + status = sane_control_option (dev, 0, SANE_ACTION_GET_VALUE, &num_options, 0); + if (status != SANE_STATUS_GOOD) + return 0; + + for (i = 1; i < num_options; i++) + { + option_desc = sane_get_option_descriptor (dev, i); + if (option_desc) + if (option_desc->name) + { + if (strncmp (option_desc->name, SANE_NAME_SCAN_RESOLUTION, + sizeof(SANE_NAME_SCAN_RESOLUTION)) == 0) + { + sane_control_option (dev, i, SANE_ACTION_GET_VALUE, + &resolution, 0); + if (status == SANE_STATUS_GOOD) + { + if (option_desc->type == SANE_TYPE_INT) + return resolution; + else if (option_desc->type == SANE_TYPE_FIXED) + return (SANE_Word) SANE_UNFIX (resolution); + } + return 0; + } + } + } + return 0; +} + static void update_preview (GSGDialog *dialog, void *arg) { @@ -923,6 +960,11 @@ { SANE_Status status; SANE_Handle dev = gsg_dialog_get_device (dialog); + +#ifdef HAVE_LIBGIMP_GIMP_H + SANE_Word resolution; +#endif /* HAVE_LIBGIMP_GIMP_H */ + const char *frame_type = 0; char buf[256]; int fd; @@ -958,6 +1000,10 @@ } #endif /* HAVE_LIBGIMP_GIMP_H */ +#ifdef GIMP_HAVE_RESOLUTION_INFO + resolution = get_resolution(dev); +#endif + scan_win.x = scan_win.y = 0; while (gtk_events_pending ()) @@ -1087,6 +1133,14 @@ scan_win.image_ID = gimp_image_new (scan_win.param.pixels_per_line, scan_win.param.lines, image_type); + +/* the following is supported since gimp-1.1.0 */ +#ifdef GIMP_HAVE_RESOLUTION_INFO + if (resolution > 0) + gimp_image_set_resolution(scan_win.image_ID, resolution, + resolution); +#endif + layer_ID = gimp_layer_new (scan_win.image_ID, "Background", scan_win.param.pixels_per_line, scan_win.param.lines,