[sane-devel] Re: [patch] xscanimage: resolution of the resulting GIMP image
Aurelien Jarno
lists at aurel32.net
Sun Jan 12 20:17:45 GMT 2003
Oups, forgotten the patch...
-------------- next part --------------
--- xscanimage.c 2003-01-12 20:45:27.000000000 +0100
+++ /home/aurel32/xscanimage.c 2003-01-12 20:45:09.000000000 +0100
@@ -380,4 +380,29 @@
#endif /* HAVE_LIBGIMP_GIMP_H */
+static SANE_Word get_resolution(SANE_Handle dev)
+{
+ int i;
+ SANE_Word resolution;
+ SANE_Int num_options;
+ const SANE_Option_Descriptor *option_desc;
+
+ sane_control_option (dev, 0, SANE_ACTION_GET_VALUE, &num_options, 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);
+ return resolution;
+ }
+ }
+ return 0;
+}
+
static void
update_preview (GSGDialog *dialog, void *arg)
@@ -864,4 +889,9 @@
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];
@@ -1013,6 +1043,12 @@
}
+
scan_win.image_ID = gimp_image_new (scan_win.param.pixels_per_line,
scan_win.param.lines, image_type);
+ resolution = get_resolution(dev);
+ if (resolution != 0) gimp_image_set_resolution(scan_win.image_ID,
+ resolution,
+ resolution);
+
layer_ID = gimp_layer_new (scan_win.image_ID, "Background",
scan_win.param.pixels_per_line,
More information about the sane-devel
mailing list