Commit 5e1ff368 authored by Henning Geinitz's avatar Henning Geinitz

Tell gimp which resolution we used for the scan. Based on patch from Aurelien

Jarno <lists@aurel32.net>.
parent 18156177
2003-02-01 Henning Meier-Geinitz <henning@meier-geinitz.de>
* src/xscanimage.c: Tell gimp which resolution we used for the scan.
Based on patch from Aurelien Jarno <lists@aurel32.net>.
****** Release of sane-frontends-1.0.10. End of code freeze *****
2003-01-31 Henning Meier-Geinitz <henning@meier-geinitz.de>
......
......@@ -394,6 +394,43 @@ null_print_func (const gchar *msg)
#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 @@ scan_start (void)
{
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 @@ scan_start (void)
}
#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_start (void)
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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment