-added TXT button for option text line adding to image
 with name, date and time info.
 font_6x11.h  file and add_text routine taken from the (GPLed)
 webcam.c file, part of xawtv, (c) 1998-2002 Gerd Knorr.
 add_text was modified for this program (xcam_add_text).

-added RGB/BGR button option to switch the colors if needed.

-solved segment fault when no usb scanner/vidcam devices
 is attached to system ( bug report from Henning Meier-Geinitz)

-patch update for recording feature (SANE bugreport 300224)
 added SAVE Frame button, output filename box.
 With Save Frame button image can be saved as
 .pnm .pgm .pbm or .ppm file

-added info row with x, y, image-size, fps count, fps, fps_ava

-added -V and -h option (version and help

-added option -B -buffersize so instead of default input buffer of
32*1024 a buffer of 1024*1024 can be chosen, so for vidcams for example
640x480, usb 2.0, 30fps less time is needed to fill input buffer.

fond_6x11.h file added

Also some small updates to (for debug output):
xscanimage.c
preview.c
gtkglue.c
merge-requests/2/head
Gerard Klaver 2005-04-11 20:09:04 +00:00
rodzic 98320c775b
commit 98f467fd31
5 zmienionych plików z 4768 dodań i 621 usunięć

3337
src/font_6x11.h 100644

Plik diff jest za duży Load Diff

Wyświetl plik

@ -32,7 +32,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h> /* Apollo/DomainOS needs this _before_ sys/stat.h */
#include <sys/types.h> /* Apollo/DomainOS needs this _before_ sys/stat.h */
#include <sys/stat.h>
#include "gtkglue.h"
@ -47,8 +47,7 @@
#define DBG_info 3
#define DBG_debug 4
#define DEBUG_NOT_STATIC
#define BACKEND_NAME xscanimage
#define BACKEND_NAME gtkglue
#include "../include/sane/sanei_debug.h"
int gsg_message_dialog_active = 0;
@ -63,11 +62,16 @@ unit_string (SANE_Unit unit)
switch (unit)
{
case SANE_UNIT_NONE: return "none";
case SANE_UNIT_PIXEL: return "pixel";
case SANE_UNIT_BIT: return "bit";
case SANE_UNIT_DPI: return "dpi";
case SANE_UNIT_PERCENT: return "%";
case SANE_UNIT_NONE:
return "none";
case SANE_UNIT_PIXEL:
return "pixel";
case SANE_UNIT_BIT:
return "bit";
case SANE_UNIT_DPI:
return "dpi";
case SANE_UNIT_PERCENT:
return "%";
case SANE_UNIT_MM:
d = preferences.length_unit;
if (d > 9.9 && d < 10.1)
@ -75,13 +79,14 @@ unit_string (SANE_Unit unit)
else if (d > 25.3 && d < 25.5)
return "in";
return "mm";
case SANE_UNIT_MICROSECOND: return "us";
case SANE_UNIT_MICROSECOND:
return "us";
}
return 0;
}
static void
set_tooltip (GtkTooltips *tooltips, GtkWidget *widget, const char *desc)
set_tooltip (GtkTooltips * tooltips, GtkWidget * widget, const char *desc)
{
if (desc && desc[0])
#ifdef HAVE_GTK_TOOLTIPS_SET_TIPS
@ -95,8 +100,7 @@ set_tooltip (GtkTooltips *tooltips, GtkWidget *widget, const char *desc)
int
gsg_make_path (size_t buf_size, char *buf,
const char *prog_name,
const char *prefix, const char *dev_name,
const char *postfix)
const char *prefix, const char *dev_name, const char *postfix)
{
struct passwd *pw;
size_t len, extra;
@ -112,7 +116,7 @@ gsg_make_path (size_t buf_size, char *buf,
return -1;
}
snprintf (buf, buf_size, "%s/.sane", pw->pw_dir);
mkdir (buf, 0777); /* ensure ~/.sane directory exists */
mkdir (buf, 0777); /* ensure ~/.sane directory exists */
len = strlen (buf);
@ -146,8 +150,8 @@ gsg_make_path (size_t buf_size, char *buf,
if (dev_name)
{
/* Turn devicename into valid filename by replacing slashes by
"+-". A lonely `+' gets translated into "++" so we can tell
it from a substituted slash. */
"+-". A lonely `+' gets translated into "++" so we can tell
it from a substituted slash. */
for (i = 0; dev_name[i]; ++i)
{
@ -162,7 +166,7 @@ gsg_make_path (size_t buf_size, char *buf,
break;
#ifdef HAVE_OS2_H
case ':': /* OS2 can not handle colons in filenames */
case ':': /* OS2 can not handle colons in filenames */
buf[len++] = '+';
buf[len++] = '_';
break;
@ -208,8 +212,8 @@ set_option (GSGDialog * dialog, int opt_num, void *val, SANE_Action action)
if (status != SANE_STATUS_GOOD)
{
snprintf (buf, sizeof (buf), "Failed to set value of option %s: %s.",
sane_get_option_descriptor (dialog->dev, opt_num)->name,
sane_strstatus (status));
sane_get_option_descriptor (dialog->dev, opt_num)->name,
sane_strstatus (status));
gsg_error (buf);
return;
}
@ -231,7 +235,7 @@ gsg_close_dialog_callback (GtkWidget * widget, gpointer data)
}
void
gsg_message (gchar *title, gchar *message)
gsg_message (gchar * title, gchar * message)
{
GtkWidget *main_vbox, *label;
GtkWidget *button, *message_dialog;
@ -282,7 +286,7 @@ gsg_warning (gchar * warning)
}
static void
get_filename_button_clicked (GtkWidget *w, gpointer data)
get_filename_button_clicked (GtkWidget * w, gpointer data)
{
int *clicked = data;
*clicked = 1;
@ -297,9 +301,10 @@ gsg_get_filename (const char *label, const char *default_name,
filesel = gtk_file_selection_new ((char *) label);
gtk_window_set_modal(GTK_WINDOW(filesel), TRUE);
gtk_window_set_modal (GTK_WINDOW (filesel), TRUE);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filesel)->cancel_button),
gtk_signal_connect (GTK_OBJECT
(GTK_FILE_SELECTION (filesel)->cancel_button),
"clicked", (GtkSignalFunc) get_filename_button_clicked,
&cancel);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
@ -371,8 +376,8 @@ autobutton_update (GtkWidget * widget, GSGDialogElement * elem)
}
static void
autobutton_new (GtkWidget *parent, GSGDialogElement *elem,
GtkWidget *label, GtkTooltips *tooltips)
autobutton_new (GtkWidget * parent, GSGDialogElement * elem,
GtkWidget * label, GtkTooltips * tooltips)
{
GtkWidget *button, *alignment;
@ -380,8 +385,7 @@ autobutton_new (GtkWidget *parent, GSGDialogElement *elem,
gtk_container_border_width (GTK_CONTAINER (button), 0);
gtk_widget_set_usize (button, 20, 20);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) autobutton_update,
elem);
(GtkSignalFunc) autobutton_update, elem);
set_tooltip (tooltips, button, "Turns on automatic mode.");
alignment = gtk_alignment_new (0.0, 1.0, 0.5, 0.5);
@ -411,7 +415,7 @@ button_update (GtkWidget * widget, GSGDialogElement * elem)
static void
button_new (GtkWidget * parent, const char *name, SANE_Word val,
GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc,
GSGDialogElement * elem, GtkTooltips * tooltips, const char *desc,
gint is_settable)
{
GtkWidget *button;
@ -419,8 +423,7 @@ button_new (GtkWidget * parent, const char *name, SANE_Word val,
button = gtk_check_button_new_with_label ((char *) name);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), val);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) button_update,
elem);
(GtkSignalFunc) button_update, elem);
gtk_box_pack_start (GTK_BOX (parent), button, FALSE, TRUE, 0);
if (!is_settable)
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
@ -440,6 +443,11 @@ scale_update (GtkAdjustment * adj_data, GSGDialogElement * elem)
double d;
SANE_Status status;
DBG_INIT ();
DBG (DBG_debug, "scale_update\n");
opt_num = elem - dialog->element;
opt = sane_get_option_descriptor (dialog->dev, opt_num);
switch (opt->type)
@ -460,11 +468,13 @@ scale_update (GtkAdjustment * adj_data, GSGDialogElement * elem)
return;
}
set_option (dialog, opt_num, &val, SANE_ACTION_SET_VALUE);
status = sane_control_option (dialog->dev, opt_num, SANE_ACTION_GET_VALUE, &new_val,
0);
status =
sane_control_option (dialog->dev, opt_num, SANE_ACTION_GET_VALUE,
&new_val, 0);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_fatal, "scale_update: sane_control_option failed: %s\n", sane_strstatus (status));
DBG (DBG_fatal, "scale_update: sane_control_option failed: %s\n",
sane_strstatus (status));
return;
}
@ -502,7 +512,7 @@ value_changed:
static void
scale_new (GtkWidget * parent, const char *name, gfloat val,
gfloat min, gfloat max, gfloat quant, int automatic,
GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc,
GSGDialogElement * elem, GtkTooltips * tooltips, const char *desc,
gint is_settable)
{
GtkWidget *hbox, *label, *scale;
@ -603,10 +613,9 @@ option_menu_callback (GtkWidget * widget, gpointer data)
}
static void
option_menu_new (GtkWidget *parent, const char *name, char *str_list[],
option_menu_new (GtkWidget * parent, const char *name, char *str_list[],
const char *val, GSGDialogElement * elem,
GtkTooltips *tooltips, const char *desc,
gint is_settable)
GtkTooltips * tooltips, const char *desc, gint is_settable)
{
GtkWidget *hbox, *label, *option_menu, *menu, *item;
GSGMenuItem *menu_items;
@ -657,7 +666,7 @@ option_menu_new (GtkWidget *parent, const char *name, char *str_list[],
}
static void
text_entry_callback (GtkWidget *w, gpointer data)
text_entry_callback (GtkWidget * w, gpointer data)
{
GSGDialogElement *elem = data;
const SANE_Option_Descriptor *opt;
@ -687,8 +696,7 @@ text_entry_callback (GtkWidget *w, gpointer data)
static void
text_entry_new (GtkWidget * parent, const char *name, const char *val,
GSGDialogElement * elem,
GtkTooltips *tooltips, const char *desc,
gint is_settable)
GtkTooltips * tooltips, const char *desc, gint is_settable)
{
GtkWidget *hbox, *text, *label;
@ -716,9 +724,9 @@ text_entry_new (GtkWidget * parent, const char *name, const char *val,
}
static GtkWidget *
group_new (GtkWidget *parent, const char * title)
group_new (GtkWidget * parent, const char *title)
{
GtkWidget * frame, * vbox;
GtkWidget *frame, *vbox;
frame = gtk_frame_new ((char *) title);
gtk_container_border_width (GTK_CONTAINER (frame), 4);
@ -732,10 +740,10 @@ group_new (GtkWidget *parent, const char * title)
return vbox;
}
static GtkWidget*
curve_new (GSGDialog *dialog, int optnum)
static GtkWidget *
curve_new (GSGDialog * dialog, int optnum)
{
const SANE_Option_Descriptor * opt;
const SANE_Option_Descriptor *opt;
gfloat fmin, fmax, val, *vector;
SANE_Word *optval, min, max;
GtkWidget *curve, *gamma;
@ -747,7 +755,7 @@ curve_new (GSGDialog *dialog, int optnum)
curve = GTK_GAMMA_CURVE (gamma)->curve;
dev = dialog->dev;
opt = sane_get_option_descriptor (dev, optnum);
opt = sane_get_option_descriptor (dev, optnum);
optlen = opt->size / sizeof (SANE_Word);
vector = alloca (optlen * (sizeof (vector[0]) + sizeof (optval[0])));
optval = (SANE_Word *) (vector + optlen);
@ -818,7 +826,7 @@ curve_new (GSGDialog *dialog, int optnum)
}
static void
vector_new (GSGDialog * dialog, GtkWidget *vbox, int num_vopts, int *vopts)
vector_new (GSGDialog * dialog, GtkWidget * vbox, int num_vopts, int *vopts)
{
GtkWidget *notebook, *label, *curve;
const SANE_Option_Descriptor *opt;
@ -833,7 +841,7 @@ vector_new (GSGDialog * dialog, GtkWidget *vbox, int num_vopts, int *vopts)
opt = sane_get_option_descriptor (dialog->dev, vopts[i]);
label = gtk_label_new ((char *) opt->title);
vbox = gtk_vbox_new (/* homogeneous */ FALSE, 0);
vbox = gtk_vbox_new ( /* homogeneous */ FALSE, 0);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
gtk_widget_show (vbox);
gtk_widget_show (label);
@ -863,7 +871,7 @@ panel_destroy (GSGDialog * dialog)
gtk_object_sink (GTK_OBJECT (dialog->tooltips));
# else
gtk_object_unref (GTK_OBJECT (dialog->tooltips));
# endif /* GTK_MAJOR_VERSION == 2 */
# endif /* GTK_MAJOR_VERSION == 2 */
#endif
gtk_widget_destroy (dialog->main_hbox);
@ -886,7 +894,7 @@ panel_destroy (GSGDialog * dialog)
}
}
memset (dialog->element, 0,
dialog->num_elements*sizeof (dialog->element[0]));
dialog->num_elements * sizeof (dialog->element[0]));
}
static void
@ -907,40 +915,40 @@ panel_build (GSGDialog * dialog)
int num_vector_opts = 0, *vector_opts;
main_hbox = gtk_hbox_new (FALSE, 2);
if (dialog->twocolumn)
{
option_vbox = gtk_hbox_new (FALSE, 2); /* two column display */
}
else
{
option_vbox = gtk_vbox_new (FALSE, 2); /* one column display */
}
{
option_vbox = gtk_hbox_new (FALSE, 2); /* two column display */
}
else
{
option_vbox = gtk_vbox_new (FALSE, 2); /* one column display */
}
gtk_box_pack_start (GTK_BOX (main_hbox), option_vbox, FALSE, FALSE, 0);
gtk_widget_show (option_vbox);
/* standard options vbox */
standard_vbox = gtk_vbox_new (/* homogeneous */ FALSE, 0);
standard_vbox = gtk_vbox_new ( /* homogeneous */ FALSE, 0);
gtk_widget_show (standard_vbox);
gtk_box_pack_start (GTK_BOX (option_vbox), standard_vbox, FALSE, FALSE, 0);
/* advanced options page */
advanced_vbox = gtk_vbox_new (/* homogeneous */ FALSE, 0);
advanced_vbox = gtk_vbox_new ( /* homogeneous */ FALSE, 0);
gtk_box_pack_start (GTK_BOX (option_vbox), advanced_vbox, TRUE, TRUE, 0);
/* use black as foreground: */
dialog->tooltips = gtk_tooltips_new ();
dialog->tooltips_fg.red = 0;
dialog->tooltips_fg.red = 0;
dialog->tooltips_fg.green = 0;
dialog->tooltips_fg.blue = 0;
dialog->tooltips_fg.blue = 0;
/* postit yellow (khaki) as background: */
gdk_color_alloc (gtk_widget_get_colormap (main_hbox), &dialog->tooltips_fg);
dialog->tooltips_bg.red = 61669;
dialog->tooltips_bg.red = 61669;
dialog->tooltips_bg.green = 59113;
dialog->tooltips_bg.blue = 35979;
dialog->tooltips_bg.blue = 35979;
gdk_color_alloc (gtk_widget_get_colormap (main_hbox), &dialog->tooltips_bg);
/* GTK2 doesn't have the function (seems like it's not needed with GTK2 anyway) */
@ -1027,7 +1035,7 @@ panel_build (GSGDialog * dialog)
goto get_value_failed;
button_new (parent, title, val, elem, dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
SANE_OPTION_IS_SETTABLE (opt->cap));
gtk_widget_show (parent->parent);
break;
@ -1058,7 +1066,7 @@ panel_build (GSGDialog * dialog)
opt->constraint.range->max, quant,
(opt->cap & SANE_CAP_AUTOMATIC), elem,
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
SANE_OPTION_IS_SETTABLE (opt->cap));
gtk_widget_show (parent->parent);
break;
@ -1075,14 +1083,14 @@ panel_build (GSGDialog * dialog)
sprintf (str, "%d", val);
option_menu_new (parent, title, str_list, str, elem,
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
SANE_OPTION_IS_SETTABLE (opt->cap));
free (str_list);
gtk_widget_show (parent->parent);
break;
case SANE_CONSTRAINT_NONE:
/* having no constraint for an int is strange but allowed
by the SANE standard so we just ignore such options here */
by the SANE standard so we just ignore such options here */
break;
default:
@ -1128,7 +1136,7 @@ panel_build (GSGDialog * dialog)
scale_new (parent, title, dval, dmin, dmax, dquant,
(opt->cap & SANE_CAP_AUTOMATIC), elem,
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
SANE_OPTION_IS_SETTABLE (opt->cap));
gtk_widget_show (parent->parent);
break;
@ -1146,14 +1154,14 @@ panel_build (GSGDialog * dialog)
sprintf (str, "%g", SANE_UNFIX (val));
option_menu_new (parent, title, str_list, str, elem,
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
SANE_OPTION_IS_SETTABLE (opt->cap));
free (str_list);
gtk_widget_show (parent->parent);
break;
case SANE_CONSTRAINT_NONE:
/* having no constraint for a fixed is strange but allowed
by the SANE standard so we just ignore such options here */
by the SANE standard so we just ignore such options here */
break;
default:
@ -1184,14 +1192,14 @@ panel_build (GSGDialog * dialog)
option_menu_new (parent, title,
(char **) opt->constraint.string_list, buf,
elem, dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
SANE_OPTION_IS_SETTABLE (opt->cap));
gtk_widget_show (parent->parent);
break;
case SANE_CONSTRAINT_NONE:
text_entry_new (parent, title, buf, elem,
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
SANE_OPTION_IS_SETTABLE (opt->cap));
gtk_widget_show (parent->parent);
break;
@ -1265,8 +1273,9 @@ panel_rebuild (GSGDialog * dialog)
GSGDialog *
gsg_create_dialog (GtkWidget * window, const char *device_name,
GSGCallback option_reload_callback, void *option_reload_arg,
GSGCallback param_change_callback, void *param_change_arg)
GSGCallback option_reload_callback,
void *option_reload_arg, GSGCallback param_change_callback,
void *param_change_arg)
{
SANE_Int num_elements;
GSGDialog *dialog;
@ -1313,7 +1322,7 @@ gsg_create_dialog (GtkWidget * window, const char *device_name,
}
void
gsg_refresh_dialog (GSGDialog *dialog)
gsg_refresh_dialog (GSGDialog * dialog)
{
panel_rebuild (dialog);
if (dialog->param_change_callback)
@ -1321,7 +1330,7 @@ gsg_refresh_dialog (GSGDialog *dialog)
}
void
gsg_update_scan_window (GSGDialog *dialog)
gsg_update_scan_window (GSGDialog * dialog)
{
const SANE_Option_Descriptor *opt;
double old_val, new_val;
@ -1339,10 +1348,9 @@ gsg_update_scan_window (GSGDialog *dialog)
opt = sane_get_option_descriptor (dialog->dev, optnum);
status = sane_control_option (dialog->dev, optnum,
SANE_ACTION_GET_VALUE,
&word, 0);
SANE_ACTION_GET_VALUE, &word, 0);
if (status != SANE_STATUS_GOOD)
continue; /* sliently ignore errors */
continue; /* sliently ignore errors */
switch (opt->constraint_type)
{
@ -1373,7 +1381,8 @@ gsg_update_scan_window (GSGDialog *dialog)
sprintf (str, "%g", SANE_UNFIX (word));
/* XXX maybe we should call this only when the value changes... */
gtk_option_menu_set_history (GTK_OPTION_MENU (elem->widget),
option_menu_lookup (elem->menu, str));
option_menu_lookup (elem->menu,
str));
break;
default:
@ -1386,7 +1395,7 @@ gsg_update_scan_window (GSGDialog *dialog)
vectors, all option values are kept current. Vectors are
downloaded into the device during this call. */
void
gsg_sync (GSGDialog *dialog)
gsg_sync (GSGDialog * dialog)
{
const SANE_Option_Descriptor *opt;
gfloat val, *vector;
@ -1400,8 +1409,7 @@ gsg_sync (GSGDialog *dialog)
if (!SANE_OPTION_IS_ACTIVE (opt->cap))
continue;
if (opt->type != SANE_TYPE_INT &&
opt->type != SANE_TYPE_FIXED)
if (opt->type != SANE_TYPE_INT && opt->type != SANE_TYPE_FIXED)
continue;
if (opt->size == sizeof (SANE_Word))
@ -1429,14 +1437,14 @@ gsg_sync (GSGDialog *dialog)
}
void
gsg_set_advanced (GSGDialog *dialog, int advanced)
gsg_set_advanced (GSGDialog * dialog, int advanced)
{
dialog->advanced = advanced;
panel_rebuild (dialog);
}
void
gsg_set_tooltips (GSGDialog *dialog, int enable)
gsg_set_tooltips (GSGDialog * dialog, int enable)
{
if (!dialog->tooltips)
return;
@ -1448,14 +1456,14 @@ gsg_set_tooltips (GSGDialog *dialog, int enable)
}
void
gsg_set_twocolumn (GSGDialog *dialog, int twocolumn)
gsg_set_twocolumn (GSGDialog * dialog, int twocolumn)
{
dialog->twocolumn = twocolumn;
panel_rebuild (dialog);
panel_rebuild (dialog);
}
void
gsg_set_sensitivity (GSGDialog *dialog, int sensitive)
gsg_set_sensitivity (GSGDialog * dialog, int sensitive)
{
const SANE_Option_Descriptor *opt;
int i;
@ -1465,8 +1473,7 @@ gsg_set_sensitivity (GSGDialog *dialog, int sensitive)
opt = sane_get_option_descriptor (dialog->dev, i);
if (!SANE_OPTION_IS_ACTIVE (opt->cap)
|| opt->type == SANE_TYPE_GROUP
|| !dialog->element[i].widget)
|| opt->type == SANE_TYPE_GROUP || !dialog->element[i].widget)
continue;
if (!(opt->cap & SANE_CAP_ALWAYS_SETTABLE))

Wyświetl plik

@ -85,8 +85,7 @@
#define DBG_info 3
#define DBG_debug 4
#define DEBUG_DECLARE_ONLY
#define BACKEND_NAME xscanimage
#define BACKEND_NAME preview
#include "../include/sane/sanei_debug.h"
#ifndef PATH_MAX
@ -111,11 +110,11 @@
#endif
/* forward declarations */
static void scan_start (Preview *p);
static void scan_done (Preview *p);
static void scan_start (Preview * p);
static void scan_done (Preview * p);
static void
draw_rect (GdkWindow *win, GdkGC *gc, int coord[4])
draw_rect (GdkWindow * win, GdkGC * gc, int coord[4])
{
gint x, y, w, h;
@ -137,7 +136,7 @@ draw_rect (GdkWindow *win, GdkGC *gc, int coord[4])
}
static void
draw_selection (Preview *p)
draw_selection (Preview * p)
{
if (!p->gc)
/* window isn't mapped yet */
@ -153,7 +152,7 @@ draw_selection (Preview *p)
}
static void
update_selection (Preview *p)
update_selection (Preview * p)
{
float min, max, normal, dev_selection[4];
const SANE_Option_Descriptor *opt;
@ -192,8 +191,9 @@ update_selection (Preview *p)
normal = ((i == 0) ? p->preview_width : p->preview_height) - 1;
normal /= (max - min);
p->selection.active = TRUE;
p->selection.coord[i] = ((dev_selection[i] - min)*normal) + 0.5;
p->selection.coord[i + 2] = ((dev_selection[i + 2] - min)*normal) + 0.5;
p->selection.coord[i] = ((dev_selection[i] - min) * normal) + 0.5;
p->selection.coord[i + 2] =
((dev_selection[i + 2] - min) * normal) + 0.5;
if (p->selection.coord[i + 2] < p->selection.coord[i])
p->selection.coord[i + 2] = p->selection.coord[i];
}
@ -201,7 +201,7 @@ update_selection (Preview *p)
}
static void
get_image_scale (Preview *p, float *xscalep, float *yscalep)
get_image_scale (Preview * p, float *xscalep, float *yscalep)
{
float xscale, yscale;
@ -209,9 +209,9 @@ get_image_scale (Preview *p, float *xscalep, float *yscalep)
xscale = 1.0;
else
{
xscale = p->image_width/(float) p->preview_width;
if (p->image_height > 0 && p->preview_height*xscale < p->image_height)
xscale = p->image_height/(float) p->preview_height;
xscale = p->image_width / (float) p->preview_width;
if (p->image_height > 0 && p->preview_height * xscale < p->image_height)
xscale = p->image_height / (float) p->preview_height;
}
yscale = xscale;
@ -222,32 +222,32 @@ get_image_scale (Preview *p, float *xscalep, float *yscalep)
float swidth, sheight;
assert (p->surface_type == SANE_TYPE_INT);
swidth = (p->surface[GSG_BR_X] - p->surface[GSG_TL_X] + 1);
swidth = (p->surface[GSG_BR_X] - p->surface[GSG_TL_X] + 1);
sheight = (p->surface[GSG_BR_Y] - p->surface[GSG_TL_Y] + 1);
xscale = 1.0;
yscale = 1.0;
if (p->image_width > 0 && swidth < INF)
xscale = p->image_width/swidth;
xscale = p->image_width / swidth;
if (p->image_height > 0 && sheight < INF)
yscale = p->image_height/sheight;
yscale = p->image_height / sheight;
}
*xscalep = xscale;
*yscalep = yscale;
}
static void
paint_image (Preview *p)
paint_image (Preview * p)
{
float xscale, yscale, src_x, src_y;
int dst_x, dst_y, height, x, y, src_offset;
gint gwidth, gheight;
gwidth = p->preview_width;
gwidth = p->preview_width;
gheight = p->preview_height;
get_image_scale (p, &xscale, &yscale);
memset (p->preview_row, 0xff, 3*gwidth);
memset (p->preview_row, 0xff, 3 * gwidth);
/* don't draw last line unless it's complete: */
height = p->image_y;
@ -262,7 +262,7 @@ paint_image (Preview *p)
y = (int) (src_y + 0.5);
if (y >= height)
break;
src_offset = y*3*p->image_width;
src_offset = y * 3 * p->image_width;
if (p->image_data)
for (dst_x = 0; dst_x < gwidth; ++dst_x)
@ -271,9 +271,12 @@ paint_image (Preview *p)
if (x >= p->image_width)
break;
p->preview_row[3*dst_x + 0] = p->image_data[src_offset + 3*x + 0];
p->preview_row[3*dst_x + 1] = p->image_data[src_offset + 3*x + 1];
p->preview_row[3*dst_x + 2] = p->image_data[src_offset + 3*x + 2];
p->preview_row[3 * dst_x + 0] =
p->image_data[src_offset + 3 * x + 0];
p->preview_row[3 * dst_x + 1] =
p->image_data[src_offset + 3 * x + 1];
p->preview_row[3 * dst_x + 2] =
p->image_data[src_offset + 3 * x + 2];
src_x += xscale;
}
gtk_preview_draw_row (GTK_PREVIEW (p->window), p->preview_row,
@ -284,7 +287,7 @@ paint_image (Preview *p)
}
static void
display_partial_image (Preview *p)
display_partial_image (Preview * p)
{
paint_image (p);
@ -293,8 +296,8 @@ display_partial_image (Preview *p)
GtkPreview *preview = GTK_PREVIEW (p->window);
int src_x, src_y;
src_x = (p->window->allocation.width - preview->buffer_width)/2;
src_y = (p->window->allocation.height - preview->buffer_height)/2;
src_x = (p->window->allocation.width - preview->buffer_width) / 2;
src_y = (p->window->allocation.height - preview->buffer_height) / 2;
gtk_preview_put (preview, p->window->window, p->window->style->black_gc,
src_x, src_y,
0, 0, p->preview_width, p->preview_height);
@ -302,7 +305,7 @@ display_partial_image (Preview *p)
}
static void
display_maybe (Preview *p)
display_maybe (Preview * p)
{
time_t now;
@ -315,13 +318,13 @@ display_maybe (Preview *p)
}
static void
display_image (Preview *p)
display_image (Preview * p)
{
if (p->params.lines <= 0 && p->image_y < p->image_height)
{
p->image_height = p->image_y;
p->image_data = realloc (p->image_data,
3*p->image_width*p->image_height);
3 * p->image_width * p->image_height);
assert (p->image_data);
}
display_partial_image (p);
@ -329,20 +332,20 @@ display_image (Preview *p)
}
static void
preview_area_resize (GtkWidget *widget)
preview_area_resize (GtkWidget * widget)
{
float min_x, max_x, min_y, max_y, xscale, yscale, f;
Preview *p;
p = gtk_object_get_data (GTK_OBJECT (widget), "PreviewPointer");
p->preview_width = widget->allocation.width;
p->preview_width = widget->allocation.width;
p->preview_height = widget->allocation.height;
if (p->preview_row)
p->preview_row = realloc (p->preview_row, 3*p->preview_width);
p->preview_row = realloc (p->preview_row, 3 * p->preview_width);
else
p->preview_row = malloc (3*p->preview_width);
p->preview_row = malloc (3 * p->preview_width);
/* set the ruler ranges: */
@ -351,7 +354,7 @@ preview_area_resize (GtkWidget *widget)
min_x = 0.0;
max_x = p->surface[GSG_BR_X];
if (max_x >= INF)
if (max_x >= INF)
max_x = p->preview_width - 1;
min_y = p->surface[GSG_TL_Y];
@ -359,35 +362,38 @@ preview_area_resize (GtkWidget *widget)
min_y = 0.0;
max_y = p->surface[GSG_BR_Y];
if (max_y >= INF)
if (max_y >= INF)
max_y = p->preview_height - 1;
/* convert mm to inches if that's what the user wants: */
if (p->surface_unit == SANE_UNIT_MM)
{
double factor = 1.0/preferences.length_unit;
min_x *= factor; max_x *= factor; min_y *= factor; max_y *= factor;
double factor = 1.0 / preferences.length_unit;
min_x *= factor;
max_x *= factor;
min_y *= factor;
max_y *= factor;
}
get_image_scale (p, &xscale, &yscale);
if (p->surface_unit == SANE_UNIT_PIXEL)
f = 1.0/xscale;
f = 1.0 / xscale;
else if (p->image_width)
f = xscale*p->preview_width/p->image_width;
f = xscale * p->preview_width / p->image_width;
else
f = 1.0;
gtk_ruler_set_range (GTK_RULER (p->hruler), f*min_x, f*max_x, f*min_x,
gtk_ruler_set_range (GTK_RULER (p->hruler), f * min_x, f * max_x, f * min_x,
/* max_size */ 20);
if (p->surface_unit == SANE_UNIT_PIXEL)
f = 1.0/yscale;
f = 1.0 / yscale;
else if (p->image_height)
f = yscale*p->preview_height/p->image_height;
f = yscale * p->preview_height / p->image_height;
else
f = 1.0;
gtk_ruler_set_range (GTK_RULER (p->vruler), f*min_y, f*max_y, f*min_y,
gtk_ruler_set_range (GTK_RULER (p->vruler), f * min_y, f * max_y, f * min_y,
/* max_size */ 20);
paint_image (p);
@ -395,13 +401,13 @@ preview_area_resize (GtkWidget *widget)
}
static void
get_bounds (const SANE_Option_Descriptor *opt, float *minp, float *maxp)
get_bounds (const SANE_Option_Descriptor * opt, float *minp, float *maxp)
{
float min, max;
int i;
min = -INF;
max = INF;
max = INF;
switch (opt->constraint_type)
{
case SANE_CONSTRAINT_RANGE:
@ -410,7 +416,7 @@ get_bounds (const SANE_Option_Descriptor *opt, float *minp, float *maxp)
break;
case SANE_CONSTRAINT_WORD_LIST:
min = INF;
min = INF;
max = -INF;
for (i = 1; i <= opt->constraint.word_list[0]; ++i)
{
@ -436,7 +442,7 @@ get_bounds (const SANE_Option_Descriptor *opt, float *minp, float *maxp)
}
static void
save_option (Preview *p, int option, SANE_Word *save_loc, int *valid)
save_option (Preview * p, int option, SANE_Word * save_loc, int *valid)
{
SANE_Status status;
@ -451,7 +457,7 @@ save_option (Preview *p, int option, SANE_Word *save_loc, int *valid)
}
static void
restore_option (Preview *p, int option, SANE_Word saved_value, int valid)
restore_option (Preview * p, int option, SANE_Word saved_value, int valid)
{
const SANE_Option_Descriptor *opt;
SANE_Status status;
@ -474,7 +480,7 @@ restore_option (Preview *p, int option, SANE_Word saved_value, int valid)
}
static SANE_Status
set_option_float (Preview *p, int option, float value)
set_option_float (Preview * p, int option, float value)
{
const SANE_Option_Descriptor *opt;
SANE_Handle dev;
@ -504,7 +510,7 @@ set_option_float (Preview *p, int option, float value)
}
static void
set_option_bool (Preview *p, int option, SANE_Bool value)
set_option_bool (Preview * p, int option, SANE_Bool value)
{
SANE_Handle dev;
SANE_Status status;
@ -513,7 +519,8 @@ set_option_bool (Preview *p, int option, SANE_Bool value)
return;
dev = p->dialog->dev;
status = sane_control_option (dev, option, SANE_ACTION_SET_VALUE, &value, 0);
status =
sane_control_option (dev, option, SANE_ACTION_SET_VALUE, &value, 0);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_fatal, "set_option_bool: sane_control_option failed: %s\n",
@ -523,7 +530,7 @@ set_option_bool (Preview *p, int option, SANE_Bool value)
}
static int
increment_image_y (Preview *p)
increment_image_y (Preview * p)
{
size_t extra_size, offset;
char buf[256];
@ -532,8 +539,8 @@ increment_image_y (Preview *p)
++p->image_y;
if (p->params.lines <= 0 && p->image_y >= p->image_height)
{
offset = 3*p->image_width*p->image_height;
extra_size = 3*32*p->image_width;
offset = 3 * p->image_width * p->image_height;
extra_size = 3 * 32 * p->image_width;
p->image_height += 32;
p->image_data = realloc (p->image_data, offset + extra_size);
if (!p->image_data)
@ -560,6 +567,10 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
SANE_Int len;
int i, j;
DBG_INIT ();
DBG (DBG_debug, "input_available: enter\n");
dev = p->dialog->dev;
while (1)
{
@ -596,7 +607,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
scan_done (p);
return;
}
if (!len) /* out of data for now */
if (!len) /* out of data for now */
{
if (p->input_tag < 0)
{
@ -618,7 +629,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
for (i = 0; i < len; ++i)
{
u_char mask = buf[i];
for (j = 7; j >= 0; --j)
{
u_char gl = (mask & (1 << j)) ? 0xff : 0x00;
@ -649,7 +660,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
for (i = 0; i < len; ++i)
{
p->image_data[p->image_offset++] = buf[i];
if (p->image_offset%3 == 0)
if (p->image_offset % 3 == 0)
{
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
@ -660,10 +671,10 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
case 16:
for (i = 0; i < len; ++i)
{
guint16 value = buf [i];
guint16 value = buf[i];
if ((i % 2) == 1)
p->image_data[p->image_offset++] = *(guint8 *) (&value);
if (p->image_offset%6 == 0)
if (p->image_offset % 6 == 0)
{
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
@ -715,17 +726,14 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
case 16:
for (i = 0; i < len; ++i)
{
guint16 value = buf [i];
guint16 value = buf[i];
if ((i % 2) == 1)
{
p->image_data[p->image_offset++] =
*(guint8 *) (&value);
p->image_data[p->image_offset++] =
*(guint8 *) (&value);
p->image_data[p->image_offset++] =
*(guint8 *) (&value);
p->image_data[p->image_offset++] = *(guint8 *) (&value);
p->image_data[p->image_offset++] = *(guint8 *) (&value);
p->image_data[p->image_offset++] = *(guint8 *) (&value);
}
if (p->image_offset%2 == 0)
if (p->image_offset % 2 == 0)
{
if (++p->image_x >= p->image_width
&& increment_image_y (p) < 0)
@ -771,14 +779,14 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
return;
}
break;
case 16:
for (i = 0; i < len; ++i)
{
guint16 value = buf [i];
guint16 value = buf[i];
if ((i % 2) == 1)
{
p->image_data[p->image_offset] = *(guint8 *) (&value);
p->image_data[p->image_offset] = *(guint8 *) (&value);
p->image_offset += 3;
}
if (p->image_offset % 2 == 0)
@ -820,7 +828,7 @@ bad_depth:
}
static void
scan_done (Preview *p)
scan_done (Preview * p)
{
int i;
@ -846,7 +854,7 @@ scan_done (Preview *p)
}
static void
scan_start (Preview *p)
scan_start (Preview * p)
{
SANE_Handle dev = p->dialog->dev;
SANE_Status status;
@ -859,7 +867,7 @@ scan_start (Preview *p)
gtk_widget_set_sensitive (p->dialog->window->parent->parent->parent, FALSE);
/* clear old preview: */
memset (p->preview_row, 0xff, 3*p->preview_width);
memset (p->preview_row, 0xff, 3 * p->preview_width);
for (y = 0; y < p->preview_height; ++y)
gtk_preview_draw_row (GTK_PREVIEW (p->window), p->preview_row,
0, y, p->preview_width);
@ -892,10 +900,9 @@ scan_start (Preview *p)
return;
}
if ((p->params.format >= SANE_FRAME_RGB &&
if ((p->params.format >= SANE_FRAME_RGB &&
p->params.format <= SANE_FRAME_BLUE) &&
p->params.depth == 1 &&
p->params.pixels_per_line % 8 != 0)
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.");
@ -903,7 +910,7 @@ scan_start (Preview *p)
scan_done (p);
return;
}
p->image_offset = p->image_x = p->image_y = 0;
if (p->params.format >= SANE_FRAME_RED
@ -917,7 +924,7 @@ scan_start (Preview *p)
if (p->image_data)
free (p->image_data);
p->image_width = p->params.pixels_per_line;
p->image_width = p->params.pixels_per_line;
p->image_height = p->params.lines;
if (p->image_height < 0)
p->image_height = 32; /* may have to adjust as we go... */
@ -931,7 +938,7 @@ scan_start (Preview *p)
scan_done (p);
return;
}
memset (p->image_data, 0xff, 3*p->image_width*p->image_height);
memset (p->image_data, 0xff, 3 * p->image_width * p->image_height);
}
if (p->selection.active)
@ -944,13 +951,15 @@ scan_start (Preview *p)
if (sane_set_io_mode (dev, SANE_TRUE) == SANE_STATUS_GOOD
&& sane_get_select_fd (dev, &fd) == SANE_STATUS_GOOD)
p->input_tag = gdk_input_add (fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, input_available, p);
p->input_tag =
gdk_input_add (fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
input_available, p);
else
input_available (p, -1, GDK_INPUT_READ);
}
static void
establish_selection (Preview *p)
establish_selection (Preview * p)
{
float min, max, normal, dev_selection[4];
int i;
@ -966,10 +975,11 @@ establish_selection (Preview *p)
if (max >= INF)
max = p->preview_width;
normal = 1.0/(((i == 0) ? p->preview_width : p->preview_height) - 1);
normal =
1.0 / (((i == 0) ? p->preview_width : p->preview_height) - 1);
normal *= (max - min);
dev_selection[i] = p->selection.coord[i]*normal + min;
dev_selection[i + 2] = p->selection.coord[i + 2]*normal + min;
dev_selection[i] = p->selection.coord[i] * normal + min;
dev_selection[i + 2] = p->selection.coord[i + 2] * normal + min;
}
for (i = 0; i < 4; ++i)
set_option_float (p, p->dialog->well_known.coord[i], dev_selection[i]);
@ -980,14 +990,14 @@ establish_selection (Preview *p)
}
static int
make_preview_image_path (Preview *p, size_t filename_size, char *filename)
make_preview_image_path (Preview * p, size_t filename_size, char *filename)
{
return gsg_make_path (filename_size, filename, 0, "preview-",
p->dialog->dev_name, ".ppm");
}
static void
restore_preview_image (Preview *p)
restore_preview_image (Preview * p)
{
u_int psurface_type, psurface_unit;
char filename[PATH_MAX];
@ -1009,8 +1019,7 @@ restore_preview_image (Preview *p)
(e.g., consider an image whose first image byte is 13 (`\r'). */
if (fscanf (in, "P6\n# surface: %g %g %g %g %u %u\n%d %d\n255%*[\n]",
psurface + 0, psurface + 1, psurface + 2, psurface + 3,
&psurface_type, &psurface_unit,
&width, &height) != 8)
&psurface_type, &psurface_unit, &width, &height) != 8)
return;
if (GROSSLY_DIFFERENT (psurface[0], p->surface[0])
@ -1025,19 +1034,19 @@ restore_preview_image (Preview *p)
p->image_height = height;
if ((width == 0) || (height == 0))
return;
p->image_data = malloc (3*width*height);
p->image_data = malloc (3 * width * height);
if (!p->image_data)
return;
nread = fread (p->image_data, 3, width*height, in);
nread = fread (p->image_data, 3, width * height, in);
p->image_y = nread/width;
p->image_x = nread%width;
p->image_y = nread / width;
p->image_x = nread % width;
}
/* This is executed _after_ the gtkpreview's expose routine. */
static gint
expose_handler (GtkWidget *window, GdkEvent *event, gpointer data)
expose_handler (GtkWidget * window, GdkEvent * event, gpointer data)
{
Preview *p = data;
@ -1047,7 +1056,7 @@ expose_handler (GtkWidget *window, GdkEvent *event, gpointer data)
}
static gint
event_handler (GtkWidget *window, GdkEvent *event, gpointer data)
event_handler (GtkWidget * window, GdkEvent * event, gpointer data)
{
Preview *p = data;
int i, tmp;
@ -1135,19 +1144,19 @@ event_handler (GtkWidget *window, GdkEvent *event, gpointer data)
}
static void
start_button_clicked (GtkWidget *widget, gpointer data)
start_button_clicked (GtkWidget * widget, gpointer data)
{
preview_scan (data);
}
static void
cancel_button_clicked (GtkWidget *widget, gpointer data)
cancel_button_clicked (GtkWidget * widget, gpointer data)
{
scan_done (data);
}
static void
top_destroyed (GtkWidget *widget, gpointer call_data)
top_destroyed (GtkWidget * widget, gpointer call_data)
{
Preview *p = call_data;
@ -1155,7 +1164,7 @@ top_destroyed (GtkWidget *widget, gpointer call_data)
}
Preview *
preview_new (GSGDialog *dialog)
preview_new (GSGDialog * dialog)
{
static int first_time = 1;
GtkWidget *table, *frame;
@ -1200,7 +1209,7 @@ preview_new (GSGDialog *dialog)
/* padding */ 0);
/* the empty box in the top-left corner */
frame = gtk_frame_new (/* label */ 0);
frame = gtk_frame_new ( /* label */ 0);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_table_attach (GTK_TABLE (table), frame, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
@ -1223,8 +1232,7 @@ preview_new (GSGDialog *dialog)
GDK_EXPOSURE_MASK |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
gtk_signal_connect (GTK_OBJECT (p->window), "event",
(GtkSignalFunc) event_handler, p);
gtk_signal_connect_after (GTK_OBJECT (p->window), "expose_event",
@ -1254,7 +1262,7 @@ preview_new (GSGDialog *dialog)
gtk_signal_connect_object (GTK_OBJECT (p->window), "motion_notify_event",
signal_func, GTK_OBJECT (p->vruler));
p->viewport = gtk_frame_new (/* label */ 0);
p->viewport = gtk_frame_new ( /* label */ 0);
gtk_frame_set_shadow_type (GTK_FRAME (p->viewport), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (p->viewport), p->window);
@ -1297,7 +1305,7 @@ preview_new (GSGDialog *dialog)
}
void
preview_update (Preview *p)
preview_update (Preview * p)
{
float val, width, height, max_width, max_height;
const SANE_Option_Descriptor *opt;
@ -1352,16 +1360,16 @@ preview_update (Preview *p)
/* guess the initial preview window size: */
width = p->surface[GSG_BR_X] - p->surface[GSG_TL_X];
width = p->surface[GSG_BR_X] - p->surface[GSG_TL_X];
height = p->surface[GSG_BR_Y] - p->surface[GSG_TL_Y];
if (p->surface_type == SANE_TYPE_INT)
{
width += 1.0;
width += 1.0;
height += 1.0;
}
else
{
width += SANE_UNFIX (1.0);
width += SANE_UNFIX (1.0);
height += SANE_UNFIX (1.0);
}
@ -1370,46 +1378,46 @@ preview_update (Preview *p)
if (width >= INF || height >= INF)
p->aspect = 1.0;
else
p->aspect = width/height;
p->aspect = width / height;
if (surface_changed)
{
max_width = 0.5 * gdk_screen_width();
max_height = 0.5 * gdk_screen_height();
max_width = 0.5 * gdk_screen_width ();
max_height = 0.5 * gdk_screen_height ();
}
else
{
max_width = p->window->allocation.width;
max_width = p->window->allocation.width;
max_height = p->window->allocation.height;
}
if (p->surface_unit != SANE_UNIT_PIXEL)
{
width = max_width;
width = max_width;
height = width / p->aspect;
if (height > max_height)
{
height = max_height;
width = height * p->aspect;
width = height * p->aspect;
}
}
else
{
if (width > max_width)
width = max_width;
width = max_width;
if (height > max_height)
height = max_height;
}
/* re-adjust so we maintain aspect without exceeding max size: */
if (width/height != p->aspect)
if (width / height != p->aspect)
{
if (p->aspect > 1.0)
height = width/p->aspect;
height = width / p->aspect;
else
width = height*p->aspect;
width = height * p->aspect;
}
p->preview_width = width + 0.5;
@ -1428,7 +1436,7 @@ preview_update (Preview *p)
}
void
preview_scan (Preview *p)
preview_scan (Preview * p)
{
float min, max, swidth, sheight, width, height, dpi = 0;
const SANE_Option_Descriptor *opt;
@ -1450,25 +1458,25 @@ preview_scan (Preview *p)
opt = sane_get_option_descriptor (p->dialog->dev,
p->dialog->well_known.dpi);
gwidth = p->preview_width;
gwidth = p->preview_width;
gheight = p->preview_height;
height = gheight;
width = height*p->aspect;
width = height * p->aspect;
if (width > gwidth)
{
width = gwidth;
height = width/p->aspect;
width = gwidth;
height = width / p->aspect;
}
swidth = (p->surface[GSG_BR_X] - p->surface[GSG_TL_X]);
if (swidth < INF)
dpi = MM_PER_INCH*width/swidth;
dpi = MM_PER_INCH * width / swidth;
else
{
sheight = (p->surface[GSG_BR_Y] - p->surface[GSG_TL_Y]);
if (sheight < INF)
dpi = MM_PER_INCH*height/sheight;
dpi = MM_PER_INCH * height / sheight;
else
dpi = 18.0;
}
@ -1493,7 +1501,7 @@ preview_scan (Preview *p)
}
void
preview_destroy (Preview *p)
preview_destroy (Preview * p)
{
char filename[PATH_MAX];
FILE *out;
@ -1512,7 +1520,7 @@ preview_destroy (Preview *p)
p->surface[0], p->surface[1], p->surface[2], p->surface[3],
p->surface_type, p->surface_unit,
p->image_width, p->image_height);
fwrite (p->image_data, 3, p->image_width*p->image_height, out);
fwrite (p->image_data, 3, p->image_width * p->image_height, out);
fclose (out);
}
}

1039
src/xcam.c

Plik diff jest za duży Load Diff

Plik diff jest za duży Load Diff