app/commands.[ch] app/edit_selection.c app/gdisplay.[ch]

Sat Dec  5 21:31:57 GMT 1998  Austin Donnelly  <austin@greenend.org.uk>

	* app/commands.[ch]
	* app/edit_selection.c
	* app/gdisplay.[ch]
	* app/gdisplay_ops.[ch]
	* app/image_render.c
	* app/info_window.c
	* app/magnify.c
	* app/menus.c
	* app/scale.c: image rendering now happens with float scale
	factors, independent in X and Y axes.  Turning on dot-for-dot in view
	menu does what gimp always used to do (ie one image pixel becomes
	one monitor pixel).  Dot-for-dot is on by default so people
	shouldn't notice any difference unless they load an image that's
	not at 72 dpi and also turn off dot-for-dot.

	* app/app_procs.c
	* app/gimprc.[ch]
	* app/preferences_dialog.c: new gimprc options
	(monitor-xresolution <float>) and corresponding
 	(monitor-yresolution <float>).  Uglyness in preferences dialog to
	add a "Monitor" page to the notebook, allowing user to set their
	monitor's resolution or take it from the X server instead.  This
	badly needs cleaned up :(

	* plug-ins/newsprint/newsprint.c: oops - this hasn't been working
	for grayscale images since my last checkin.  Now fixed.
This commit is contained in:
GMT 1998 Austin Donnelly 1998-12-05 21:48:37 +00:00 committed by Austin Donnelly
parent 7a0ad46070
commit ccfeb2549d
45 changed files with 1409 additions and 358 deletions

View File

@ -419,6 +419,17 @@ select_save_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
view_dot_for_dot_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
gdisp = gdisplay_active ();
gdisplay_set_dot_for_dot (gdisp, GTK_CHECK_MENU_ITEM (widget)->active);
}
void
view_zoomin_cmd_callback (GtkWidget *widget,
gpointer client_data)

View File

@ -37,6 +37,7 @@ void select_grow_cmd_callback (GtkWidget *, gpointer);
void select_shrink_cmd_callback (GtkWidget *, gpointer);
void select_by_color_cmd_callback (GtkWidget *, gpointer);
void select_save_cmd_callback (GtkWidget *, gpointer);
void view_dot_for_dot_callback (GtkWidget *, gpointer);
void view_zoomin_cmd_callback (GtkWidget *, gpointer);
void view_zoomout_cmd_callback (GtkWidget *, gpointer);
void view_zoom_16_1_callback (GtkWidget *, gpointer);

View File

@ -34,6 +34,7 @@
#include "curves.h"
#include "devices.h"
#include "gdisplay.h"
#include "gdisplay_ops.h"
#include "colormaps.h"
#include "errorconsole.h"
#include "fileops.h"
@ -488,6 +489,13 @@ app_init (void)
if (always_restore_session)
restore_session = TRUE;
/* make sure the monitor resolution is valid */
if (monitor_xres < 1e-5 || monitor_yres < 1e-5)
{
gdisplay_xserver_resolution (&monitor_xres, &monitor_yres);
using_xserver_resolution = TRUE;
}
/* Now we are ready to draw the splash-screen-image to the start-up window */
if (no_interface == FALSE)
{

View File

@ -419,6 +419,17 @@ select_save_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
view_dot_for_dot_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
gdisp = gdisplay_active ();
gdisplay_set_dot_for_dot (gdisp, GTK_CHECK_MENU_ITEM (widget)->active);
}
void
view_zoomin_cmd_callback (GtkWidget *widget,
gpointer client_data)

View File

@ -37,6 +37,7 @@ void select_grow_cmd_callback (GtkWidget *, gpointer);
void select_shrink_cmd_callback (GtkWidget *, gpointer);
void select_by_color_cmd_callback (GtkWidget *, gpointer);
void select_save_cmd_callback (GtkWidget *, gpointer);
void view_dot_for_dot_callback (GtkWidget *, gpointer);
void view_zoomin_cmd_callback (GtkWidget *, gpointer);
void view_zoomout_cmd_callback (GtkWidget *, gpointer);
void view_zoom_16_1_callback (GtkWidget *, gpointer);

View File

@ -100,6 +100,7 @@ gdisplay_new (GimpImage *gimage,
gdisp->offset_x = gdisp->offset_y = 0;
gdisp->scale = scale;
gdisp->dot_for_dot = TRUE;
gdisp->gimage = gimage;
gdisp->window_info_dialog = NULL;
gdisp->depth = g_visual->depth;
@ -686,7 +687,7 @@ gdisplay_find_guide (GDisplay *gdisp,
{
GList *tmp_list;
Guide *guide;
double scale;
double scalex, scaley;
int offset_x, offset_y;
int pos;
@ -694,7 +695,8 @@ gdisplay_find_guide (GDisplay *gdisp,
{
offset_x = gdisp->offset_x - gdisp->disp_xoffset;
offset_y = gdisp->offset_y - gdisp->disp_yoffset;
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) : 1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
tmp_list = gdisp->gimage->guides;
while (tmp_list)
@ -705,14 +707,14 @@ gdisplay_find_guide (GDisplay *gdisp,
switch (guide->orientation)
{
case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y);
pos = (int) (scaley * guide->position - offset_y);
if ((guide->position != -1) &&
(pos > (y - EPSILON)) &&
(pos < (y + EPSILON)))
return guide;
break;
case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x);
pos = (int) (scalex * guide->position - offset_x);
if ((guide->position != -1) &&
(pos > (x - EPSILON)) &&
(pos < (x + EPSILON)))
@ -734,7 +736,7 @@ gdisplay_snap_point (GDisplay *gdisp,
{
GList *tmp_list;
Guide *guide;
double scale;
double scalex, scaley;
int offset_x, offset_y;
int minhdist, minvdist;
int pos, dist;
@ -748,7 +750,8 @@ gdisplay_snap_point (GDisplay *gdisp,
{
offset_x = gdisp->offset_x - gdisp->disp_xoffset;
offset_y = gdisp->offset_y - gdisp->disp_yoffset;
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) : 1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
minhdist = G_MAXINT;
minvdist = G_MAXINT;
@ -762,7 +765,7 @@ gdisplay_snap_point (GDisplay *gdisp,
switch (guide->orientation)
{
case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y);
pos = (int) (scaley * guide->position - offset_y);
if ((pos > (y - EPSILON)) &&
(pos < (y + EPSILON)))
{
@ -777,7 +780,7 @@ gdisplay_snap_point (GDisplay *gdisp,
}
break;
case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x);
pos = (int) (scalex * guide->position - offset_x);
if ((pos > (x - EPSILON)) &&
(pos < (x + EPSILON)))
{
@ -909,6 +912,19 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
gdisplay_flush (gdisp);
}
void
gdisplay_set_dot_for_dot (GDisplay *gdisp, int value)
{
if (value != gdisp->dot_for_dot)
{
gdisp->dot_for_dot = value;
resize_display (gdisp, allow_resize_windows, TRUE);
}
}
void
gdisplay_resize_cursor_label (GDisplay *gdisp)
{
@ -1016,8 +1032,8 @@ gdisplay_display_area (GDisplay *gdisp,
int dx, dy;
int i, j;
sx = SCALE (gdisp, gdisp->gimage->width);
sy = SCALE (gdisp, gdisp->gimage->height);
sx = SCALEX (gdisp, gdisp->gimage->width);
sy = SCALEY (gdisp, gdisp->gimage->height);
/* Bounds check */
x1 = BOUNDS (x, 0, gdisp->disp_width);
@ -1157,12 +1173,13 @@ gdisplay_transform_coords (GDisplay *gdisp,
int *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
/* transform from image coordinates to screen coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1171,8 +1188,8 @@ gdisplay_transform_coords (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (int) (scale * (x + offset_x) - gdisp->offset_x);
*ny = (int) (scale * (y + offset_y) - gdisp->offset_y);
*nx = (int) (scalex * (x + offset_x) - gdisp->offset_x);
*ny = (int) (scaley * (y + offset_y) - gdisp->offset_y);
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
@ -1188,15 +1205,16 @@ gdisplay_untransform_coords (GDisplay *gdisp,
int round,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
/* transform from screen coordinates to image coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1207,13 +1225,13 @@ gdisplay_untransform_coords (GDisplay *gdisp,
if (round)
{
*nx = ROUND ((x + gdisp->offset_x) / scale - offset_x);
*ny = ROUND ((y + gdisp->offset_y) / scale - offset_y);
*nx = ROUND ((x + gdisp->offset_x) / scalex - offset_x);
*ny = ROUND ((y + gdisp->offset_y) / scaley - offset_y);
}
else
{
*nx = (int) ((x + gdisp->offset_x) / scale - offset_x);
*ny = (int) ((y + gdisp->offset_y) / scale - offset_y);
*nx = (int) ((x + gdisp->offset_x) / scalex - offset_x);
*ny = (int) ((y + gdisp->offset_y) / scaley - offset_y);
}
}
@ -1226,12 +1244,13 @@ gdisplay_transform_coords_f (GDisplay *gdisp,
double *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
/* transform from gimp coordinates to screen coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X(gdisp);
scaley = SCALEFACTOR_Y(gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1240,8 +1259,8 @@ gdisplay_transform_coords_f (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = scale * (x + offset_x) - gdisp->offset_x;
*ny = scale * (y + offset_y) - gdisp->offset_y;
*nx = scalex * (x + offset_x) - gdisp->offset_x;
*ny = scaley * (y + offset_y) - gdisp->offset_y;
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
@ -1256,15 +1275,16 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
double *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
/* transform from screen coordinates to gimp coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X(gdisp);
scaley = SCALEFACTOR_Y(gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1273,8 +1293,8 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (x + gdisp->offset_x) / scale - offset_x;
*ny = (y + gdisp->offset_y) / scale - offset_y;
*nx = (x + gdisp->offset_x) / scalex - offset_x;
*ny = (y + gdisp->offset_y) / scaley - offset_y;
}
@ -1379,6 +1399,7 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
menus_set_state (_("<Image>/View/Toggle Guides"), gdisp->draw_guides);
menus_set_state (_("<Image>/View/Snap To Guides"), gdisp->snap_to_guides);
menus_set_state (_("<Image>/View/Toggle Statusbar"), GTK_WIDGET_VISIBLE (gdisp->statusarea) ? 1 : 0);
menus_set_state (_("<Image>/View/Dot for dot"), gdisp->dot_for_dot);
plug_in_set_menu_sensitivity (type);
}

View File

@ -31,10 +31,29 @@
/* some useful macros */
/* unpacking the user scale level (char) */
#define SCALESRC(g) (g->scale & 0x00ff)
#define SCALEDEST(g) (g->scale >> 8)
#define SCALE(g,x) ((x * SCALEDEST(g)) / SCALESRC(g))
#define UNSCALE(g,x) ((x * SCALESRC(g)) / SCALEDEST(g))
/* finding the effective screen resolution (float) */
#define SCREEN_XRES(g) (g->dot_for_dot? g->gimage->xresolution : monitor_xres)
#define SCREEN_YRES(g) (g->dot_for_dot? g->gimage->yresolution : monitor_yres)
/* calculate scale factors (float) */
#define SCALEFACTOR_X(g) ((SCALEDEST(g) * SCREEN_XRES(g)) / \
(SCALESRC(g) * g->gimage->xresolution))
#define SCALEFACTOR_Y(g) ((SCALEDEST(g) * SCREEN_YRES(g)) / \
(SCALESRC(g) * g->gimage->yresolution))
/* scale values */
#define SCALEX(g,x) ((int)(x * SCALEFACTOR_X(g)))
#define SCALEY(g,y) ((int)(y * SCALEFACTOR_Y(g)))
/* unscale values */
#define UNSCALEX(g,x) ((int)(x / SCALEFACTOR_X(g)))
#define UNSCALEY(g,y) ((int)(y / SCALEFACTOR_Y(g)))
#define LOWPASS(x) ((x>0) ? x : 0)
/* #define HIGHPASS(x,y) ((x>y) ? y : x) */ /* unused - == MIN */
@ -96,6 +115,7 @@ struct _GDisplay
int offset_x, offset_y; /* offset of display image into raw image */
int scale; /* scale factor from original raw image */
int dot_for_dot; /* is monitor resolution being ignored? */
short draw_guides; /* should the guides be drawn? */
short snap_to_guides; /* should the guides be snapped to? */
@ -146,6 +166,7 @@ Guide* gdisplay_find_guide (GDisplay *, int, int);
void gdisplay_snap_point (GDisplay *, double , double, double *, double *);
void gdisplay_snap_rectangle (GDisplay *, int, int, int, int, int *, int *);
void gdisplay_update_cursor (GDisplay *, int, int);
void gdisplay_set_dot_for_dot (GDisplay *, int);
void gdisplay_resize_cursor_label (GDisplay *);
/* function declarations */

View File

@ -205,7 +205,7 @@ info_window_update (InfoDialog *info_win,
gdisp->gimage->xresolution,
gdisp->gimage->yresolution);
/* zoom ratio */
/* user zoom ratio */
sprintf (iwd->scale_str, "%d:%d",
SCALEDEST (gdisp), SCALESRC (gdisp));

View File

@ -105,6 +105,9 @@ static char * old_pattern_path;
static char * old_palette_path;
static char * old_plug_in_path;
static char * old_gradient_path;
static float old_monitor_xres;
static float old_monitor_yres;
static int old_using_xserver_resolution;
static char * edit_temp_path = NULL;
static char * edit_swap_path = NULL;
@ -122,6 +125,8 @@ static int edit_last_opened_size;
static GtkWidget *tile_cache_size_spinbutton = NULL;
static int divided_tile_cache_size;
static int mem_size_unit;
static GtkWidget *xres_spinbutton = NULL;
static GtkWidget *yres_spinbutton = NULL;
/* Some information regarding preferences, compiled by Raph Levien 11/3/97.
@ -227,10 +232,20 @@ file_prefs_ok_callback (GtkWidget *widget,
g_message (_("Error: Default height must be one or greater."));
default_height = old_default_height;
return;
}
}
if (monitor_xres < 1e-5 || monitor_yres < 1e-5)
{
g_message (_("Error: monitor resolution must not be zero."));
monitor_xres = old_monitor_xres;
monitor_yres = old_monitor_yres;
return;
}
gtk_widget_destroy (dlg);
prefs_dlg = NULL;
xres_spinbutton = NULL;
yres_spinbutton = NULL;
if (show_tool_tips)
gtk_tooltips_enable (tool_tips);
@ -238,6 +253,8 @@ file_prefs_ok_callback (GtkWidget *widget,
gtk_tooltips_disable (tool_tips);
}
static void
file_prefs_save_callback (GtkWidget *widget,
GtkWidget *dlg)
@ -342,6 +359,12 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "transparency-type");
if (transparency_size != old_transparency_size)
update = g_list_append (update, "transparency-size");
if (using_xserver_resolution != old_using_xserver_resolution ||
ABS(monitor_xres - old_monitor_xres) > 1e-5)
update = g_list_append (update, "monitor-xresolution");
if (using_xserver_resolution != old_using_xserver_resolution ||
ABS(monitor_yres - old_monitor_yres) > 1e-5)
update = g_list_append (update, "monitor-yresolution");
if (edit_stingy_memory_use != stingy_memory_use)
{
update = g_list_append (update, "stingy-memory-use");
@ -414,8 +437,19 @@ file_prefs_save_callback (GtkWidget *widget,
gradient_path = edit_gradient_path;
restart_notification = TRUE;
}
if (using_xserver_resolution)
{
/* special value of 0 for either x or y res in the gimprc file
* means use the xserver's current resolution */
monitor_xres = 0.0;
monitor_yres = 0.0;
}
save_gimprc (&update, &remove);
if (using_xserver_resolution)
gdisplay_xserver_resolution (&monitor_xres, &monitor_yres);
/* Restore variables which must not change */
stingy_memory_use = save_stingy_memory_use;
tile_cache_size = save_tile_cache_size;
@ -454,6 +488,8 @@ file_prefs_cancel_callback (GtkWidget *widget,
{
gtk_widget_destroy (dlg);
prefs_dlg = NULL;
xres_spinbutton = NULL;
yres_spinbutton = NULL;
levels_of_undo = old_levels_of_undo;
marching_speed = old_marching_speed;
@ -471,6 +507,9 @@ file_prefs_cancel_callback (GtkWidget *widget,
default_width = old_default_width;
default_height = old_default_height;
default_type = old_default_type;
monitor_xres = old_monitor_xres;
monitor_yres = old_monitor_yres;
using_xserver_resolution = old_using_xserver_resolution;
if (preview_size != old_preview_size)
{
@ -604,6 +643,16 @@ file_prefs_spinbutton_callback (GtkWidget *widget,
*val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
}
static void
file_prefs_float_spinbutton_callback (GtkWidget *widget,
gpointer data)
{
float *val;
val = data;
*val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
}
static void
file_prefs_string_callback (GtkWidget *widget,
gpointer data)
@ -622,6 +671,36 @@ file_prefs_clear_session_info_callback (GtkWidget *widget,
session_info_updates = NULL;
}
static void
file_prefs_res_source_callback (GtkWidget *widget,
gpointer data)
{
if (xres_spinbutton)
gtk_widget_set_sensitive (xres_spinbutton,
! GTK_TOGGLE_BUTTON (widget)->active);
if (yres_spinbutton)
gtk_widget_set_sensitive (yres_spinbutton,
! GTK_TOGGLE_BUTTON (widget)->active);
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gdisplay_xserver_resolution (&monitor_xres, &monitor_yres);
using_xserver_resolution = TRUE;
}
else
{
if (xres_spinbutton)
monitor_xres = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON
(xres_spinbutton));
if (yres_spinbutton)
monitor_yres = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON
(yres_spinbutton));
using_xserver_resolution = FALSE;
}
}
void
file_pref_cmd_callback (GtkWidget *widget,
gpointer client_data)
@ -756,6 +835,9 @@ file_pref_cmd_callback (GtkWidget *widget,
old_install_cmap = edit_install_cmap;
old_cycled_marching_ants = edit_cycled_marching_ants;
old_last_opened_size = edit_last_opened_size;
old_monitor_xres = monitor_xres;
old_monitor_yres = monitor_yres;
old_using_xserver_resolution = using_xserver_resolution;
file_prefs_strset (&old_temp_path, edit_temp_path);
file_prefs_strset (&old_swap_path, edit_swap_path);
file_prefs_strset (&old_brush_path, edit_brush_path);
@ -1321,6 +1403,100 @@ file_pref_cmd_callback (GtkWidget *widget,
label = gtk_label_new (_("Directories"));
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
/* Monitor */
out_frame = gtk_frame_new (_("Monitor information"));
gtk_container_border_width (GTK_CONTAINER (out_frame), 10);
gtk_widget_set_usize (out_frame, 320, 200);
gtk_widget_show (out_frame);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (vbox), 1);
gtk_container_add (GTK_CONTAINER (out_frame), vbox);
gtk_widget_show (vbox);
label = gtk_label_new (_("Get monitor resolution"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
group = NULL;
button = gtk_radio_button_new_with_label (group, _("from X server"));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
GTK_SIGNAL_FUNC (file_prefs_res_source_callback),
NULL);
gtk_widget_show (button);
{
float xres, yres;
char buf[80];
gdisplay_xserver_resolution (&xres, &yres);
sprintf (buf, _("(currently %d x %d dpi)"),
(int)(xres + 0.5), (int)(yres + 0.5));
label = gtk_label_new (buf);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
}
button = gtk_radio_button_new_with_label (group, _("manually:"));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (!using_xserver_resolution)
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
abox = gtk_alignment_new (0.5, 0.5, 0.0, 1.0);
gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0);
gtk_widget_show (abox);
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (abox), hbox);
gtk_widget_show (hbox);
adj = (GtkAdjustment *) gtk_adjustment_new (monitor_xres, 1.0,
32768, 1.0,
15.0, 0.0);
xres_spinbutton = gtk_spin_button_new (adj, 1.0, 2.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(xres_spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (xres_spinbutton), TRUE);
gtk_widget_set_usize (xres_spinbutton, 70, 0);
gtk_box_pack_start (GTK_BOX (hbox), xres_spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (xres_spinbutton), "changed",
GTK_SIGNAL_FUNC (file_prefs_float_spinbutton_callback),
&monitor_xres);
gtk_widget_set_sensitive (xres_spinbutton, !using_xserver_resolution);
gtk_widget_show (xres_spinbutton);
label = gtk_label_new ( _(" by "));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
adj = (GtkAdjustment *) gtk_adjustment_new (monitor_yres, 1.0,
32768, 1.0,
15.0, 0.0);
yres_spinbutton = gtk_spin_button_new (adj, 1.0, 2.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (yres_spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (yres_spinbutton), TRUE);
gtk_widget_set_usize (yres_spinbutton, 70, 0);
gtk_box_pack_start (GTK_BOX (hbox), yres_spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (yres_spinbutton), "changed",
GTK_SIGNAL_FUNC (file_prefs_float_spinbutton_callback),
&monitor_yres);
gtk_widget_set_sensitive (yres_spinbutton, !using_xserver_resolution);
gtk_widget_show (yres_spinbutton);
label = gtk_label_new ( _("dpi"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
label = gtk_label_new (_("Monitor"));
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
gtk_widget_show (notebook);
gtk_widget_show (prefs_dlg);

View File

@ -69,6 +69,33 @@ gdisplay_color_pixel (GDisplay *gdisp)
}
void
gdisplay_xserver_resolution (float *xres, float *yres)
{
gint width, height;
gint widthMM, heightMM;
width = gdk_screen_width ();
height = gdk_screen_height ();
widthMM = gdk_screen_width_mm ();
heightMM = gdk_screen_height_mm ();
/*
* From xdpyinfo.c:
*
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
*
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
* = N pixels / (M inch / 25.4)
* = N * 25.4 pixels / M inch
*/
*xres = (width * 25.4) / ((float)widthMM);
*yres = (height * 25.4) / ((float)heightMM);
}
void
gdisplay_new_view (GDisplay *gdisp)
{
@ -124,8 +151,8 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
width = SCALE (gdisp, gdisp->gimage->width);
height = SCALE (gdisp, gdisp->gimage->height);
width = SCALEX (gdisp, gdisp->gimage->width);
height = SCALEY (gdisp, gdisp->gimage->height);
disp_width = gdisp->disp_width;
disp_height = gdisp->disp_height;
@ -233,8 +260,8 @@ gdisplay_resize_image (GDisplay *gdisp)
int width, height;
/* Calculate the width and height of the new canvas */
sx = SCALE (gdisp, gdisp->gimage->width);
sy = SCALE (gdisp, gdisp->gimage->height);
sx = SCALEX (gdisp, gdisp->gimage->width);
sy = SCALEY (gdisp, gdisp->gimage->height);
width = MINIMUM (sx, gdisp->disp_width);
height = MINIMUM (sy, gdisp->disp_height);

View File

@ -25,6 +25,7 @@ gulong gdisplay_black_pixel (GDisplay *);
gulong gdisplay_gray_pixel (GDisplay *);
gulong gdisplay_white_pixel (GDisplay *);
gulong gdisplay_color_pixel (GDisplay *);
void gdisplay_xserver_resolution (float *, float *);
void gdisplay_new_view (GDisplay *);
void gdisplay_close_window (GDisplay *, int);
void gdisplay_shrink_wrap (GDisplay *);

View File

@ -41,8 +41,8 @@ struct _RenderInfo
guchar *dest;
int x, y;
int w, h;
int scalesrc;
int scaledest;
float scalex;
float scaley;
int src_x, src_y;
int src_bpp;
int dest_bpp;
@ -190,9 +190,7 @@ static void render_image_init_info (RenderInfo *info,
static guint* render_image_init_alpha (int mult);
static guchar* render_image_accelerate_scaling (int width,
int start,
int bpp,
int scalesrc,
int scaledest);
float scalex);
static guchar* render_image_tile_fault (RenderInfo *info);
@ -240,6 +238,11 @@ render_image (GDisplay *gdisp,
return;
}
/* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998. */
if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE)
g_warning ("using untested projection type %d", image_type);
(* render_funcs[image_type]) (&info);
}
@ -263,6 +266,8 @@ render_image_indexed (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -273,13 +278,18 @@ render_image_indexed (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -302,13 +312,17 @@ render_image_indexed (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -330,6 +344,8 @@ render_image_indexed_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -341,13 +357,18 @@ render_image_indexed_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -389,13 +410,17 @@ render_image_indexed_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -412,6 +437,8 @@ render_image_gray (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -421,13 +448,18 @@ render_image_gray (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -450,13 +482,17 @@ render_image_gray (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -476,6 +512,8 @@ render_image_gray_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -486,13 +524,18 @@ render_image_gray_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -524,13 +567,17 @@ render_image_gray_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -546,6 +593,8 @@ render_image_rgb (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -555,13 +604,18 @@ render_image_rgb (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= (int)error - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -584,13 +638,17 @@ render_image_rgb (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -612,6 +670,8 @@ render_image_rgb_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -622,13 +682,18 @@ render_image_rgb_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -697,13 +762,17 @@ render_image_rgb_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -721,17 +790,17 @@ render_image_init_info (RenderInfo *info,
info->y = y + gdisp->offset_y;
info->w = w;
info->h = h;
info->scalesrc = SCALESRC (gdisp);
info->scaledest = SCALEDEST (gdisp);
info->src_x = UNSCALE (gdisp, info->x);
info->src_y = UNSCALE (gdisp, info->y);
info->scalex = SCALEFACTOR_X (gdisp);
info->scaley = SCALEFACTOR_Y (gdisp);
info->src_x = UNSCALEX (gdisp, info->x);
info->src_y = UNSCALEY (gdisp, info->y);
info->src_bpp = gimage_projection_bytes (gdisp->gimage);
info->dest = gximage_get_data ();
info->dest_bpp = gximage_get_bpp ();
info->dest_bpl = gximage_get_bpl ();
info->dest_width = info->w * info->dest_bpp;
info->byte_order = gximage_get_byte_order ();
info->scale = render_image_accelerate_scaling (w, info->x, info->src_bpp, info->scalesrc, info->scaledest);
info->scale = render_image_accelerate_scaling (w, info->x, info->scalex);
info->alpha = NULL;
switch (gimage_projection_type (gdisp->gimage))
@ -765,28 +834,28 @@ render_image_init_alpha (int mult)
}
static guchar*
render_image_accelerate_scaling (int width,
int start,
int bpp,
int scalesrc,
int scaledest)
render_image_accelerate_scaling (int width,
int start,
float scalex)
{
static guchar *scale = NULL;
static int swidth = -1;
static int sstart = -1;
guchar step;
float error;
float step;
int i;
if ((swidth != width) || (sstart != start))
{
if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1);
if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1);
step = scalesrc * bpp;
step = 1.0 / scalex;
for (i = 0; i <= width; i++)
scale[i] = ((i + start + 1) % scaledest) ? 0 : step;
}
error = start * step;
error -= ((int)error) - step;
for (i = 0; i <= width; i++)
{
scale[i] = ((int)error);
error += step - (int)error;
}
return scale;
}
@ -802,6 +871,7 @@ render_image_tile_fault (RenderInfo *info)
int tilex;
int tiley;
int step;
int bpp = info->src_bpp;
int x, b;
tilex = info->src_x / TILE_WIDTH;
@ -815,7 +885,6 @@ render_image_tile_fault (RenderInfo *info)
info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
scale = info->scale;
step = info->scalesrc * info->src_bpp;
dest = tile_buf;
x = info->src_x;
@ -823,13 +892,14 @@ render_image_tile_fault (RenderInfo *info)
while (width--)
{
for (b = 0; b < info->src_bpp; b++)
for (b = 0; b < bpp; b++)
*dest++ = data[b];
if (*scale++ != 0)
step = *scale++;
if (step != 0)
{
x += info->scalesrc;
data += step;
x += step;
data += step * bpp;
if ((x >> tile_shift) != tilex)
{

View File

@ -30,8 +30,8 @@ bounds_checking (GDisplay *gdisp)
{
int sx, sy;
sx = SCALE(gdisp, gdisp->gimage->width);
sy = SCALE(gdisp, gdisp->gimage->height);
sx = SCALEX(gdisp, gdisp->gimage->width);
sy = SCALEY(gdisp, gdisp->gimage->height);
gdisp->offset_x = BOUNDS (gdisp->offset_x, 0,
LOWPASS (sx - gdisp->disp_width));
@ -93,6 +93,7 @@ change_scale (GDisplay *gdisp,
double offset_x, offset_y;
long sx, sy;
/* user zoom control, so resolution versions not needed -- austin */
scalesrc = SCALESRC(gdisp);
scaledest = SCALEDEST(gdisp);
@ -163,23 +164,24 @@ setup_scale (GDisplay *gdisp)
GtkRuler *hruler;
GtkRuler *vruler;
gfloat sx, sy;
gfloat step;
gfloat stepx, stepy;
sx = SCALE(gdisp, gdisp->gimage->width);
sy = SCALE(gdisp, gdisp->gimage->height);
step = SCALE(gdisp, 1);
sx = SCALEX(gdisp, gdisp->gimage->width);
sy = SCALEY(gdisp, gdisp->gimage->height);
stepx = SCALEX(gdisp, 1);
stepy = SCALEY(gdisp, 1);
gdisp->hsbdata->value = gdisp->offset_x;
gdisp->hsbdata->upper = sx;
gdisp->hsbdata->page_size = MIN (sx, gdisp->disp_width);
gdisp->hsbdata->page_increment = (gdisp->disp_width / 2);
gdisp->hsbdata->step_increment = step;
gdisp->hsbdata->step_increment = stepx;
gdisp->vsbdata->value = gdisp->offset_y;
gdisp->vsbdata->upper = sy;
gdisp->vsbdata->page_size = MIN (sy, gdisp->disp_height);
gdisp->vsbdata->page_increment = (gdisp->disp_height / 2);
gdisp->vsbdata->step_increment = step;
gdisp->vsbdata->step_increment = stepy;
gtk_signal_emit_by_name (GTK_OBJECT (gdisp->hsbdata), "changed");
gtk_signal_emit_by_name (GTK_OBJECT (gdisp->vsbdata), "changed");
@ -188,37 +190,37 @@ setup_scale (GDisplay *gdisp)
vruler = GTK_RULER (gdisp->vrule);
hruler->lower = 0;
hruler->upper = UNSCALE (gdisp, gdisp->disp_width);
hruler->upper = UNSCALEX (gdisp, gdisp->disp_width);
hruler->max_size = MAXIMUM (gdisp->gimage->width, gdisp->gimage->height);
vruler->lower = 0;
vruler->upper = UNSCALE (gdisp, gdisp->disp_height);
vruler->upper = UNSCALEY (gdisp, gdisp->disp_height);
vruler->max_size = MAXIMUM (gdisp->gimage->width, gdisp->gimage->height);
if (sx < gdisp->disp_width)
{
gdisp->disp_xoffset = (gdisp->disp_width - sx) / 2;
hruler->lower -= UNSCALE (gdisp, (double) gdisp->disp_xoffset);
hruler->upper -= UNSCALE (gdisp, (double) gdisp->disp_xoffset);
hruler->lower -= UNSCALEX (gdisp, (double) gdisp->disp_xoffset);
hruler->upper -= UNSCALEX (gdisp, (double) gdisp->disp_xoffset);
}
else
{
gdisp->disp_xoffset = 0;
hruler->lower += UNSCALE (gdisp, (double) gdisp->offset_x);
hruler->upper += UNSCALE (gdisp, (double) gdisp->offset_x);
hruler->lower += UNSCALEX (gdisp, (double) gdisp->offset_x);
hruler->upper += UNSCALEX (gdisp, (double) gdisp->offset_x);
}
if (sy < gdisp->disp_height)
{
gdisp->disp_yoffset = (gdisp->disp_height - sy) / 2;
vruler->lower -= UNSCALE (gdisp, (double) gdisp->disp_yoffset);
vruler->upper -= UNSCALE (gdisp, (double) gdisp->disp_yoffset);
vruler->lower -= UNSCALEY (gdisp, (double) gdisp->disp_yoffset);
vruler->upper -= UNSCALEY (gdisp, (double) gdisp->disp_yoffset);
}
else
{
gdisp->disp_yoffset = 0;
vruler->lower += UNSCALE (gdisp, (double) gdisp->offset_y);
vruler->upper += UNSCALE (gdisp, (double) gdisp->offset_y);
vruler->lower += UNSCALEY (gdisp, (double) gdisp->offset_y);
vruler->upper += UNSCALEY (gdisp, (double) gdisp->offset_y);
}
gtk_widget_draw (GTK_WIDGET (hruler), NULL);

View File

@ -100,6 +100,7 @@ gdisplay_new (GimpImage *gimage,
gdisp->offset_x = gdisp->offset_y = 0;
gdisp->scale = scale;
gdisp->dot_for_dot = TRUE;
gdisp->gimage = gimage;
gdisp->window_info_dialog = NULL;
gdisp->depth = g_visual->depth;
@ -686,7 +687,7 @@ gdisplay_find_guide (GDisplay *gdisp,
{
GList *tmp_list;
Guide *guide;
double scale;
double scalex, scaley;
int offset_x, offset_y;
int pos;
@ -694,7 +695,8 @@ gdisplay_find_guide (GDisplay *gdisp,
{
offset_x = gdisp->offset_x - gdisp->disp_xoffset;
offset_y = gdisp->offset_y - gdisp->disp_yoffset;
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) : 1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
tmp_list = gdisp->gimage->guides;
while (tmp_list)
@ -705,14 +707,14 @@ gdisplay_find_guide (GDisplay *gdisp,
switch (guide->orientation)
{
case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y);
pos = (int) (scaley * guide->position - offset_y);
if ((guide->position != -1) &&
(pos > (y - EPSILON)) &&
(pos < (y + EPSILON)))
return guide;
break;
case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x);
pos = (int) (scalex * guide->position - offset_x);
if ((guide->position != -1) &&
(pos > (x - EPSILON)) &&
(pos < (x + EPSILON)))
@ -734,7 +736,7 @@ gdisplay_snap_point (GDisplay *gdisp,
{
GList *tmp_list;
Guide *guide;
double scale;
double scalex, scaley;
int offset_x, offset_y;
int minhdist, minvdist;
int pos, dist;
@ -748,7 +750,8 @@ gdisplay_snap_point (GDisplay *gdisp,
{
offset_x = gdisp->offset_x - gdisp->disp_xoffset;
offset_y = gdisp->offset_y - gdisp->disp_yoffset;
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) : 1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
minhdist = G_MAXINT;
minvdist = G_MAXINT;
@ -762,7 +765,7 @@ gdisplay_snap_point (GDisplay *gdisp,
switch (guide->orientation)
{
case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y);
pos = (int) (scaley * guide->position - offset_y);
if ((pos > (y - EPSILON)) &&
(pos < (y + EPSILON)))
{
@ -777,7 +780,7 @@ gdisplay_snap_point (GDisplay *gdisp,
}
break;
case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x);
pos = (int) (scalex * guide->position - offset_x);
if ((pos > (x - EPSILON)) &&
(pos < (x + EPSILON)))
{
@ -909,6 +912,19 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
gdisplay_flush (gdisp);
}
void
gdisplay_set_dot_for_dot (GDisplay *gdisp, int value)
{
if (value != gdisp->dot_for_dot)
{
gdisp->dot_for_dot = value;
resize_display (gdisp, allow_resize_windows, TRUE);
}
}
void
gdisplay_resize_cursor_label (GDisplay *gdisp)
{
@ -1016,8 +1032,8 @@ gdisplay_display_area (GDisplay *gdisp,
int dx, dy;
int i, j;
sx = SCALE (gdisp, gdisp->gimage->width);
sy = SCALE (gdisp, gdisp->gimage->height);
sx = SCALEX (gdisp, gdisp->gimage->width);
sy = SCALEY (gdisp, gdisp->gimage->height);
/* Bounds check */
x1 = BOUNDS (x, 0, gdisp->disp_width);
@ -1157,12 +1173,13 @@ gdisplay_transform_coords (GDisplay *gdisp,
int *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
/* transform from image coordinates to screen coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1171,8 +1188,8 @@ gdisplay_transform_coords (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (int) (scale * (x + offset_x) - gdisp->offset_x);
*ny = (int) (scale * (y + offset_y) - gdisp->offset_y);
*nx = (int) (scalex * (x + offset_x) - gdisp->offset_x);
*ny = (int) (scaley * (y + offset_y) - gdisp->offset_y);
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
@ -1188,15 +1205,16 @@ gdisplay_untransform_coords (GDisplay *gdisp,
int round,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
/* transform from screen coordinates to image coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1207,13 +1225,13 @@ gdisplay_untransform_coords (GDisplay *gdisp,
if (round)
{
*nx = ROUND ((x + gdisp->offset_x) / scale - offset_x);
*ny = ROUND ((y + gdisp->offset_y) / scale - offset_y);
*nx = ROUND ((x + gdisp->offset_x) / scalex - offset_x);
*ny = ROUND ((y + gdisp->offset_y) / scaley - offset_y);
}
else
{
*nx = (int) ((x + gdisp->offset_x) / scale - offset_x);
*ny = (int) ((y + gdisp->offset_y) / scale - offset_y);
*nx = (int) ((x + gdisp->offset_x) / scalex - offset_x);
*ny = (int) ((y + gdisp->offset_y) / scaley - offset_y);
}
}
@ -1226,12 +1244,13 @@ gdisplay_transform_coords_f (GDisplay *gdisp,
double *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
/* transform from gimp coordinates to screen coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X(gdisp);
scaley = SCALEFACTOR_Y(gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1240,8 +1259,8 @@ gdisplay_transform_coords_f (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = scale * (x + offset_x) - gdisp->offset_x;
*ny = scale * (y + offset_y) - gdisp->offset_y;
*nx = scalex * (x + offset_x) - gdisp->offset_x;
*ny = scaley * (y + offset_y) - gdisp->offset_y;
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
@ -1256,15 +1275,16 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
double *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
/* transform from screen coordinates to gimp coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X(gdisp);
scaley = SCALEFACTOR_Y(gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1273,8 +1293,8 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (x + gdisp->offset_x) / scale - offset_x;
*ny = (y + gdisp->offset_y) / scale - offset_y;
*nx = (x + gdisp->offset_x) / scalex - offset_x;
*ny = (y + gdisp->offset_y) / scaley - offset_y;
}
@ -1379,6 +1399,7 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
menus_set_state (_("<Image>/View/Toggle Guides"), gdisp->draw_guides);
menus_set_state (_("<Image>/View/Snap To Guides"), gdisp->snap_to_guides);
menus_set_state (_("<Image>/View/Toggle Statusbar"), GTK_WIDGET_VISIBLE (gdisp->statusarea) ? 1 : 0);
menus_set_state (_("<Image>/View/Dot for dot"), gdisp->dot_for_dot);
plug_in_set_menu_sensitivity (type);
}

View File

@ -31,10 +31,29 @@
/* some useful macros */
/* unpacking the user scale level (char) */
#define SCALESRC(g) (g->scale & 0x00ff)
#define SCALEDEST(g) (g->scale >> 8)
#define SCALE(g,x) ((x * SCALEDEST(g)) / SCALESRC(g))
#define UNSCALE(g,x) ((x * SCALESRC(g)) / SCALEDEST(g))
/* finding the effective screen resolution (float) */
#define SCREEN_XRES(g) (g->dot_for_dot? g->gimage->xresolution : monitor_xres)
#define SCREEN_YRES(g) (g->dot_for_dot? g->gimage->yresolution : monitor_yres)
/* calculate scale factors (float) */
#define SCALEFACTOR_X(g) ((SCALEDEST(g) * SCREEN_XRES(g)) / \
(SCALESRC(g) * g->gimage->xresolution))
#define SCALEFACTOR_Y(g) ((SCALEDEST(g) * SCREEN_YRES(g)) / \
(SCALESRC(g) * g->gimage->yresolution))
/* scale values */
#define SCALEX(g,x) ((int)(x * SCALEFACTOR_X(g)))
#define SCALEY(g,y) ((int)(y * SCALEFACTOR_Y(g)))
/* unscale values */
#define UNSCALEX(g,x) ((int)(x / SCALEFACTOR_X(g)))
#define UNSCALEY(g,y) ((int)(y / SCALEFACTOR_Y(g)))
#define LOWPASS(x) ((x>0) ? x : 0)
/* #define HIGHPASS(x,y) ((x>y) ? y : x) */ /* unused - == MIN */
@ -96,6 +115,7 @@ struct _GDisplay
int offset_x, offset_y; /* offset of display image into raw image */
int scale; /* scale factor from original raw image */
int dot_for_dot; /* is monitor resolution being ignored? */
short draw_guides; /* should the guides be drawn? */
short snap_to_guides; /* should the guides be snapped to? */
@ -146,6 +166,7 @@ Guide* gdisplay_find_guide (GDisplay *, int, int);
void gdisplay_snap_point (GDisplay *, double , double, double *, double *);
void gdisplay_snap_rectangle (GDisplay *, int, int, int, int, int *, int *);
void gdisplay_update_cursor (GDisplay *, int, int);
void gdisplay_set_dot_for_dot (GDisplay *, int);
void gdisplay_resize_cursor_label (GDisplay *);
/* function declarations */

View File

@ -41,8 +41,8 @@ struct _RenderInfo
guchar *dest;
int x, y;
int w, h;
int scalesrc;
int scaledest;
float scalex;
float scaley;
int src_x, src_y;
int src_bpp;
int dest_bpp;
@ -190,9 +190,7 @@ static void render_image_init_info (RenderInfo *info,
static guint* render_image_init_alpha (int mult);
static guchar* render_image_accelerate_scaling (int width,
int start,
int bpp,
int scalesrc,
int scaledest);
float scalex);
static guchar* render_image_tile_fault (RenderInfo *info);
@ -240,6 +238,11 @@ render_image (GDisplay *gdisp,
return;
}
/* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998. */
if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE)
g_warning ("using untested projection type %d", image_type);
(* render_funcs[image_type]) (&info);
}
@ -263,6 +266,8 @@ render_image_indexed (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -273,13 +278,18 @@ render_image_indexed (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -302,13 +312,17 @@ render_image_indexed (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -330,6 +344,8 @@ render_image_indexed_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -341,13 +357,18 @@ render_image_indexed_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -389,13 +410,17 @@ render_image_indexed_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -412,6 +437,8 @@ render_image_gray (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -421,13 +448,18 @@ render_image_gray (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -450,13 +482,17 @@ render_image_gray (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -476,6 +512,8 @@ render_image_gray_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -486,13 +524,18 @@ render_image_gray_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -524,13 +567,17 @@ render_image_gray_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -546,6 +593,8 @@ render_image_rgb (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -555,13 +604,18 @@ render_image_rgb (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= (int)error - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -584,13 +638,17 @@ render_image_rgb (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -612,6 +670,8 @@ render_image_rgb_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -622,13 +682,18 @@ render_image_rgb_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -697,13 +762,17 @@ render_image_rgb_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -721,17 +790,17 @@ render_image_init_info (RenderInfo *info,
info->y = y + gdisp->offset_y;
info->w = w;
info->h = h;
info->scalesrc = SCALESRC (gdisp);
info->scaledest = SCALEDEST (gdisp);
info->src_x = UNSCALE (gdisp, info->x);
info->src_y = UNSCALE (gdisp, info->y);
info->scalex = SCALEFACTOR_X (gdisp);
info->scaley = SCALEFACTOR_Y (gdisp);
info->src_x = UNSCALEX (gdisp, info->x);
info->src_y = UNSCALEY (gdisp, info->y);
info->src_bpp = gimage_projection_bytes (gdisp->gimage);
info->dest = gximage_get_data ();
info->dest_bpp = gximage_get_bpp ();
info->dest_bpl = gximage_get_bpl ();
info->dest_width = info->w * info->dest_bpp;
info->byte_order = gximage_get_byte_order ();
info->scale = render_image_accelerate_scaling (w, info->x, info->src_bpp, info->scalesrc, info->scaledest);
info->scale = render_image_accelerate_scaling (w, info->x, info->scalex);
info->alpha = NULL;
switch (gimage_projection_type (gdisp->gimage))
@ -765,28 +834,28 @@ render_image_init_alpha (int mult)
}
static guchar*
render_image_accelerate_scaling (int width,
int start,
int bpp,
int scalesrc,
int scaledest)
render_image_accelerate_scaling (int width,
int start,
float scalex)
{
static guchar *scale = NULL;
static int swidth = -1;
static int sstart = -1;
guchar step;
float error;
float step;
int i;
if ((swidth != width) || (sstart != start))
{
if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1);
if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1);
step = scalesrc * bpp;
step = 1.0 / scalex;
for (i = 0; i <= width; i++)
scale[i] = ((i + start + 1) % scaledest) ? 0 : step;
}
error = start * step;
error -= ((int)error) - step;
for (i = 0; i <= width; i++)
{
scale[i] = ((int)error);
error += step - (int)error;
}
return scale;
}
@ -802,6 +871,7 @@ render_image_tile_fault (RenderInfo *info)
int tilex;
int tiley;
int step;
int bpp = info->src_bpp;
int x, b;
tilex = info->src_x / TILE_WIDTH;
@ -815,7 +885,6 @@ render_image_tile_fault (RenderInfo *info)
info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
scale = info->scale;
step = info->scalesrc * info->src_bpp;
dest = tile_buf;
x = info->src_x;
@ -823,13 +892,14 @@ render_image_tile_fault (RenderInfo *info)
while (width--)
{
for (b = 0; b < info->src_bpp; b++)
for (b = 0; b < bpp; b++)
*dest++ = data[b];
if (*scale++ != 0)
step = *scale++;
if (step != 0)
{
x += info->scalesrc;
data += step;
x += step;
data += step * bpp;
if ((x >> tile_shift) != tilex)
{

View File

@ -30,8 +30,8 @@ bounds_checking (GDisplay *gdisp)
{
int sx, sy;
sx = SCALE(gdisp, gdisp->gimage->width);
sy = SCALE(gdisp, gdisp->gimage->height);
sx = SCALEX(gdisp, gdisp->gimage->width);
sy = SCALEY(gdisp, gdisp->gimage->height);
gdisp->offset_x = BOUNDS (gdisp->offset_x, 0,
LOWPASS (sx - gdisp->disp_width));
@ -93,6 +93,7 @@ change_scale (GDisplay *gdisp,
double offset_x, offset_y;
long sx, sy;
/* user zoom control, so resolution versions not needed -- austin */
scalesrc = SCALESRC(gdisp);
scaledest = SCALEDEST(gdisp);
@ -163,23 +164,24 @@ setup_scale (GDisplay *gdisp)
GtkRuler *hruler;
GtkRuler *vruler;
gfloat sx, sy;
gfloat step;
gfloat stepx, stepy;
sx = SCALE(gdisp, gdisp->gimage->width);
sy = SCALE(gdisp, gdisp->gimage->height);
step = SCALE(gdisp, 1);
sx = SCALEX(gdisp, gdisp->gimage->width);
sy = SCALEY(gdisp, gdisp->gimage->height);
stepx = SCALEX(gdisp, 1);
stepy = SCALEY(gdisp, 1);
gdisp->hsbdata->value = gdisp->offset_x;
gdisp->hsbdata->upper = sx;
gdisp->hsbdata->page_size = MIN (sx, gdisp->disp_width);
gdisp->hsbdata->page_increment = (gdisp->disp_width / 2);
gdisp->hsbdata->step_increment = step;
gdisp->hsbdata->step_increment = stepx;
gdisp->vsbdata->value = gdisp->offset_y;
gdisp->vsbdata->upper = sy;
gdisp->vsbdata->page_size = MIN (sy, gdisp->disp_height);
gdisp->vsbdata->page_increment = (gdisp->disp_height / 2);
gdisp->vsbdata->step_increment = step;
gdisp->vsbdata->step_increment = stepy;
gtk_signal_emit_by_name (GTK_OBJECT (gdisp->hsbdata), "changed");
gtk_signal_emit_by_name (GTK_OBJECT (gdisp->vsbdata), "changed");
@ -188,37 +190,37 @@ setup_scale (GDisplay *gdisp)
vruler = GTK_RULER (gdisp->vrule);
hruler->lower = 0;
hruler->upper = UNSCALE (gdisp, gdisp->disp_width);
hruler->upper = UNSCALEX (gdisp, gdisp->disp_width);
hruler->max_size = MAXIMUM (gdisp->gimage->width, gdisp->gimage->height);
vruler->lower = 0;
vruler->upper = UNSCALE (gdisp, gdisp->disp_height);
vruler->upper = UNSCALEY (gdisp, gdisp->disp_height);
vruler->max_size = MAXIMUM (gdisp->gimage->width, gdisp->gimage->height);
if (sx < gdisp->disp_width)
{
gdisp->disp_xoffset = (gdisp->disp_width - sx) / 2;
hruler->lower -= UNSCALE (gdisp, (double) gdisp->disp_xoffset);
hruler->upper -= UNSCALE (gdisp, (double) gdisp->disp_xoffset);
hruler->lower -= UNSCALEX (gdisp, (double) gdisp->disp_xoffset);
hruler->upper -= UNSCALEX (gdisp, (double) gdisp->disp_xoffset);
}
else
{
gdisp->disp_xoffset = 0;
hruler->lower += UNSCALE (gdisp, (double) gdisp->offset_x);
hruler->upper += UNSCALE (gdisp, (double) gdisp->offset_x);
hruler->lower += UNSCALEX (gdisp, (double) gdisp->offset_x);
hruler->upper += UNSCALEX (gdisp, (double) gdisp->offset_x);
}
if (sy < gdisp->disp_height)
{
gdisp->disp_yoffset = (gdisp->disp_height - sy) / 2;
vruler->lower -= UNSCALE (gdisp, (double) gdisp->disp_yoffset);
vruler->upper -= UNSCALE (gdisp, (double) gdisp->disp_yoffset);
vruler->lower -= UNSCALEY (gdisp, (double) gdisp->disp_yoffset);
vruler->upper -= UNSCALEY (gdisp, (double) gdisp->disp_yoffset);
}
else
{
gdisp->disp_yoffset = 0;
vruler->lower += UNSCALE (gdisp, (double) gdisp->offset_y);
vruler->upper += UNSCALE (gdisp, (double) gdisp->offset_y);
vruler->lower += UNSCALEY (gdisp, (double) gdisp->offset_y);
vruler->upper += UNSCALEY (gdisp, (double) gdisp->offset_y);
}
gtk_widget_draw (GTK_WIDGET (hruler), NULL);

View File

@ -27,6 +27,7 @@
#include "gimage_mask.h"
#include "gdisplay.h"
#include "undo.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
@ -322,8 +323,8 @@ edit_selection_draw (Tool *tool)
gdisp = (GDisplay *) tool->gdisp_ptr;
select = gdisp->select;
diff_x = SCALE (gdisp, (edit_select.x - edit_select.origx));
diff_y = SCALE (gdisp, (edit_select.y - edit_select.origy));
diff_x = SCALEX (gdisp, (edit_select.x - edit_select.origx));
diff_y = SCALEY (gdisp, (edit_select.y - edit_select.origy));
switch (edit_select.edit_type)
{

View File

@ -100,6 +100,7 @@ gdisplay_new (GimpImage *gimage,
gdisp->offset_x = gdisp->offset_y = 0;
gdisp->scale = scale;
gdisp->dot_for_dot = TRUE;
gdisp->gimage = gimage;
gdisp->window_info_dialog = NULL;
gdisp->depth = g_visual->depth;
@ -686,7 +687,7 @@ gdisplay_find_guide (GDisplay *gdisp,
{
GList *tmp_list;
Guide *guide;
double scale;
double scalex, scaley;
int offset_x, offset_y;
int pos;
@ -694,7 +695,8 @@ gdisplay_find_guide (GDisplay *gdisp,
{
offset_x = gdisp->offset_x - gdisp->disp_xoffset;
offset_y = gdisp->offset_y - gdisp->disp_yoffset;
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) : 1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
tmp_list = gdisp->gimage->guides;
while (tmp_list)
@ -705,14 +707,14 @@ gdisplay_find_guide (GDisplay *gdisp,
switch (guide->orientation)
{
case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y);
pos = (int) (scaley * guide->position - offset_y);
if ((guide->position != -1) &&
(pos > (y - EPSILON)) &&
(pos < (y + EPSILON)))
return guide;
break;
case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x);
pos = (int) (scalex * guide->position - offset_x);
if ((guide->position != -1) &&
(pos > (x - EPSILON)) &&
(pos < (x + EPSILON)))
@ -734,7 +736,7 @@ gdisplay_snap_point (GDisplay *gdisp,
{
GList *tmp_list;
Guide *guide;
double scale;
double scalex, scaley;
int offset_x, offset_y;
int minhdist, minvdist;
int pos, dist;
@ -748,7 +750,8 @@ gdisplay_snap_point (GDisplay *gdisp,
{
offset_x = gdisp->offset_x - gdisp->disp_xoffset;
offset_y = gdisp->offset_y - gdisp->disp_yoffset;
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) : 1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
minhdist = G_MAXINT;
minvdist = G_MAXINT;
@ -762,7 +765,7 @@ gdisplay_snap_point (GDisplay *gdisp,
switch (guide->orientation)
{
case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y);
pos = (int) (scaley * guide->position - offset_y);
if ((pos > (y - EPSILON)) &&
(pos < (y + EPSILON)))
{
@ -777,7 +780,7 @@ gdisplay_snap_point (GDisplay *gdisp,
}
break;
case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x);
pos = (int) (scalex * guide->position - offset_x);
if ((pos > (x - EPSILON)) &&
(pos < (x + EPSILON)))
{
@ -909,6 +912,19 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
gdisplay_flush (gdisp);
}
void
gdisplay_set_dot_for_dot (GDisplay *gdisp, int value)
{
if (value != gdisp->dot_for_dot)
{
gdisp->dot_for_dot = value;
resize_display (gdisp, allow_resize_windows, TRUE);
}
}
void
gdisplay_resize_cursor_label (GDisplay *gdisp)
{
@ -1016,8 +1032,8 @@ gdisplay_display_area (GDisplay *gdisp,
int dx, dy;
int i, j;
sx = SCALE (gdisp, gdisp->gimage->width);
sy = SCALE (gdisp, gdisp->gimage->height);
sx = SCALEX (gdisp, gdisp->gimage->width);
sy = SCALEY (gdisp, gdisp->gimage->height);
/* Bounds check */
x1 = BOUNDS (x, 0, gdisp->disp_width);
@ -1157,12 +1173,13 @@ gdisplay_transform_coords (GDisplay *gdisp,
int *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
/* transform from image coordinates to screen coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1171,8 +1188,8 @@ gdisplay_transform_coords (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (int) (scale * (x + offset_x) - gdisp->offset_x);
*ny = (int) (scale * (y + offset_y) - gdisp->offset_y);
*nx = (int) (scalex * (x + offset_x) - gdisp->offset_x);
*ny = (int) (scaley * (y + offset_y) - gdisp->offset_y);
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
@ -1188,15 +1205,16 @@ gdisplay_untransform_coords (GDisplay *gdisp,
int round,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
/* transform from screen coordinates to image coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X (gdisp);
scaley = SCALEFACTOR_Y (gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1207,13 +1225,13 @@ gdisplay_untransform_coords (GDisplay *gdisp,
if (round)
{
*nx = ROUND ((x + gdisp->offset_x) / scale - offset_x);
*ny = ROUND ((y + gdisp->offset_y) / scale - offset_y);
*nx = ROUND ((x + gdisp->offset_x) / scalex - offset_x);
*ny = ROUND ((y + gdisp->offset_y) / scaley - offset_y);
}
else
{
*nx = (int) ((x + gdisp->offset_x) / scale - offset_x);
*ny = (int) ((y + gdisp->offset_y) / scale - offset_y);
*nx = (int) ((x + gdisp->offset_x) / scalex - offset_x);
*ny = (int) ((y + gdisp->offset_y) / scaley - offset_y);
}
}
@ -1226,12 +1244,13 @@ gdisplay_transform_coords_f (GDisplay *gdisp,
double *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
/* transform from gimp coordinates to screen coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X(gdisp);
scaley = SCALEFACTOR_Y(gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1240,8 +1259,8 @@ gdisplay_transform_coords_f (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = scale * (x + offset_x) - gdisp->offset_x;
*ny = scale * (y + offset_y) - gdisp->offset_y;
*nx = scalex * (x + offset_x) - gdisp->offset_x;
*ny = scaley * (y + offset_y) - gdisp->offset_y;
*nx += gdisp->disp_xoffset;
*ny += gdisp->disp_yoffset;
@ -1256,15 +1275,16 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
double *ny,
int use_offsets)
{
double scale;
double scalex;
double scaley;
int offset_x, offset_y;
x -= gdisp->disp_xoffset;
y -= gdisp->disp_yoffset;
/* transform from screen coordinates to gimp coordinates */
scale = (SCALESRC (gdisp) == 1) ? SCALEDEST (gdisp) :
1.0 / SCALESRC (gdisp);
scalex = SCALEFACTOR_X(gdisp);
scaley = SCALEFACTOR_Y(gdisp);
if (use_offsets)
drawable_offsets (gimage_active_drawable (gdisp->gimage), &offset_x, &offset_y);
@ -1273,8 +1293,8 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
offset_x = offset_y = 0;
}
*nx = (x + gdisp->offset_x) / scale - offset_x;
*ny = (y + gdisp->offset_y) / scale - offset_y;
*nx = (x + gdisp->offset_x) / scalex - offset_x;
*ny = (y + gdisp->offset_y) / scaley - offset_y;
}
@ -1379,6 +1399,7 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
menus_set_state (_("<Image>/View/Toggle Guides"), gdisp->draw_guides);
menus_set_state (_("<Image>/View/Snap To Guides"), gdisp->snap_to_guides);
menus_set_state (_("<Image>/View/Toggle Statusbar"), GTK_WIDGET_VISIBLE (gdisp->statusarea) ? 1 : 0);
menus_set_state (_("<Image>/View/Dot for dot"), gdisp->dot_for_dot);
plug_in_set_menu_sensitivity (type);
}

View File

@ -31,10 +31,29 @@
/* some useful macros */
/* unpacking the user scale level (char) */
#define SCALESRC(g) (g->scale & 0x00ff)
#define SCALEDEST(g) (g->scale >> 8)
#define SCALE(g,x) ((x * SCALEDEST(g)) / SCALESRC(g))
#define UNSCALE(g,x) ((x * SCALESRC(g)) / SCALEDEST(g))
/* finding the effective screen resolution (float) */
#define SCREEN_XRES(g) (g->dot_for_dot? g->gimage->xresolution : monitor_xres)
#define SCREEN_YRES(g) (g->dot_for_dot? g->gimage->yresolution : monitor_yres)
/* calculate scale factors (float) */
#define SCALEFACTOR_X(g) ((SCALEDEST(g) * SCREEN_XRES(g)) / \
(SCALESRC(g) * g->gimage->xresolution))
#define SCALEFACTOR_Y(g) ((SCALEDEST(g) * SCREEN_YRES(g)) / \
(SCALESRC(g) * g->gimage->yresolution))
/* scale values */
#define SCALEX(g,x) ((int)(x * SCALEFACTOR_X(g)))
#define SCALEY(g,y) ((int)(y * SCALEFACTOR_Y(g)))
/* unscale values */
#define UNSCALEX(g,x) ((int)(x / SCALEFACTOR_X(g)))
#define UNSCALEY(g,y) ((int)(y / SCALEFACTOR_Y(g)))
#define LOWPASS(x) ((x>0) ? x : 0)
/* #define HIGHPASS(x,y) ((x>y) ? y : x) */ /* unused - == MIN */
@ -96,6 +115,7 @@ struct _GDisplay
int offset_x, offset_y; /* offset of display image into raw image */
int scale; /* scale factor from original raw image */
int dot_for_dot; /* is monitor resolution being ignored? */
short draw_guides; /* should the guides be drawn? */
short snap_to_guides; /* should the guides be snapped to? */
@ -146,6 +166,7 @@ Guide* gdisplay_find_guide (GDisplay *, int, int);
void gdisplay_snap_point (GDisplay *, double , double, double *, double *);
void gdisplay_snap_rectangle (GDisplay *, int, int, int, int, int *, int *);
void gdisplay_update_cursor (GDisplay *, int, int);
void gdisplay_set_dot_for_dot (GDisplay *, int);
void gdisplay_resize_cursor_label (GDisplay *);
/* function declarations */

View File

@ -69,6 +69,33 @@ gdisplay_color_pixel (GDisplay *gdisp)
}
void
gdisplay_xserver_resolution (float *xres, float *yres)
{
gint width, height;
gint widthMM, heightMM;
width = gdk_screen_width ();
height = gdk_screen_height ();
widthMM = gdk_screen_width_mm ();
heightMM = gdk_screen_height_mm ();
/*
* From xdpyinfo.c:
*
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
*
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
* = N pixels / (M inch / 25.4)
* = N * 25.4 pixels / M inch
*/
*xres = (width * 25.4) / ((float)widthMM);
*yres = (height * 25.4) / ((float)heightMM);
}
void
gdisplay_new_view (GDisplay *gdisp)
{
@ -124,8 +151,8 @@ gdisplay_shrink_wrap (GDisplay *gdisp)
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
width = SCALE (gdisp, gdisp->gimage->width);
height = SCALE (gdisp, gdisp->gimage->height);
width = SCALEX (gdisp, gdisp->gimage->width);
height = SCALEY (gdisp, gdisp->gimage->height);
disp_width = gdisp->disp_width;
disp_height = gdisp->disp_height;
@ -233,8 +260,8 @@ gdisplay_resize_image (GDisplay *gdisp)
int width, height;
/* Calculate the width and height of the new canvas */
sx = SCALE (gdisp, gdisp->gimage->width);
sy = SCALE (gdisp, gdisp->gimage->height);
sx = SCALEX (gdisp, gdisp->gimage->width);
sy = SCALEY (gdisp, gdisp->gimage->height);
width = MINIMUM (sx, gdisp->disp_width);
height = MINIMUM (sy, gdisp->disp_height);

View File

@ -25,6 +25,7 @@ gulong gdisplay_black_pixel (GDisplay *);
gulong gdisplay_gray_pixel (GDisplay *);
gulong gdisplay_white_pixel (GDisplay *);
gulong gdisplay_color_pixel (GDisplay *);
void gdisplay_xserver_resolution (float *, float *);
void gdisplay_new_view (GDisplay *);
void gdisplay_close_window (GDisplay *, int);
void gdisplay_shrink_wrap (GDisplay *);

View File

@ -47,6 +47,7 @@ typedef enum {
TT_STRING,
TT_PATH,
TT_DOUBLE,
TT_FLOAT,
TT_INT,
TT_BOOLEAN,
TT_POSITION,
@ -128,6 +129,9 @@ int default_height_units = GTK_INCHES;
int show_tips = TRUE;
int last_tip = -1;
int show_tool_tips = TRUE;
float monitor_xres = 72.0;
float monitor_yres = 72.0;
int using_xserver_resolution = FALSE;
static int get_next_token (void);
static int peek_next_token (void);
@ -136,6 +140,7 @@ static int parse_statement (void);
static int parse_string (gpointer val1p, gpointer val2p);
static int parse_path (gpointer val1p, gpointer val2p);
static int parse_double (gpointer val1p, gpointer val2p);
static int parse_float (gpointer val1p, gpointer val2p);
static int parse_int (gpointer val1p, gpointer val2p);
static int parse_boolean (gpointer val1p, gpointer val2p);
static int parse_position (gpointer val1p, gpointer val2p);
@ -159,6 +164,7 @@ static char* value_to_str (char *name);
static char* string_to_str (gpointer val1p, gpointer val2p);
static char* path_to_str (gpointer val1p, gpointer val2p);
static char* double_to_str (gpointer val1p, gpointer val2p);
static char* float_to_str (gpointer val1p, gpointer val2p);
static char* int_to_str (gpointer val1p, gpointer val2p);
static char* boolean_to_str (gpointer val1p, gpointer val2p);
static char* position_to_str (gpointer val1p, gpointer val2p);
@ -244,7 +250,9 @@ static ParseFunc funcs[] =
{ "plug-in-def", TT_XPLUGINDEF, NULL, NULL },
{ "menu-path", TT_XMENUPATH, NULL, NULL },
{ "device", TT_XDEVICE, NULL, NULL },
{ "session-info", TT_XSESSIONINFO, NULL, NULL}
{ "session-info", TT_XSESSIONINFO, NULL, NULL},
{ "monitor-xresolution", TT_FLOAT, &monitor_xres, NULL },
{ "monitor-yresolution", TT_FLOAT, &monitor_yres, NULL }
};
static int nfuncs = sizeof (funcs) / sizeof (funcs[0]);
@ -605,6 +613,8 @@ parse_statement ()
return parse_path (funcs[i].val1p, funcs[i].val2p);
case TT_DOUBLE:
return parse_double (funcs[i].val1p, funcs[i].val2p);
case TT_FLOAT:
return parse_float (funcs[i].val1p, funcs[i].val2p);
case TT_INT:
return parse_int (funcs[i].val1p, funcs[i].val2p);
case TT_BOOLEAN:
@ -725,6 +735,31 @@ parse_double (gpointer val1p,
return OK;
}
static int
parse_float (gpointer val1p,
gpointer val2p)
{
int token;
float *nump;
g_assert (val1p != NULL);
nump = (float *)val1p;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
*nump = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static int
parse_int (gpointer val1p,
gpointer val2p)
@ -1940,6 +1975,8 @@ value_to_str (char *name)
return path_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_DOUBLE:
return double_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_FLOAT:
return float_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_INT:
return int_to_str (funcs[i].val1p, funcs[i].val2p);
case TT_BOOLEAN:
@ -1995,6 +2032,17 @@ double_to_str (gpointer val1p,
return str;
}
static char *
float_to_str (gpointer val1p,
gpointer val2p)
{
char *str;
str = g_malloc (20);
sprintf (str, "%f", (double)(*((float *)val1p)));
return str;
}
static char *
int_to_str (gpointer val1p,
gpointer val2p)

View File

@ -66,6 +66,10 @@ extern int always_restore_session;
extern int show_tips;
extern int last_tip;
extern int show_tool_tips;
extern float monitor_xres;
extern float monitor_yres;
extern int using_xserver_resolution;
/* function prototypes */
char * gimp_directory (void);

View File

@ -419,6 +419,17 @@ select_save_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
view_dot_for_dot_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
gdisp = gdisplay_active ();
gdisplay_set_dot_for_dot (gdisp, GTK_CHECK_MENU_ITEM (widget)->active);
}
void
view_zoomin_cmd_callback (GtkWidget *widget,
gpointer client_data)

View File

@ -37,6 +37,7 @@ void select_grow_cmd_callback (GtkWidget *, gpointer);
void select_shrink_cmd_callback (GtkWidget *, gpointer);
void select_by_color_cmd_callback (GtkWidget *, gpointer);
void select_save_cmd_callback (GtkWidget *, gpointer);
void view_dot_for_dot_callback (GtkWidget *, gpointer);
void view_zoomin_cmd_callback (GtkWidget *, gpointer);
void view_zoomout_cmd_callback (GtkWidget *, gpointer);
void view_zoom_16_1_callback (GtkWidget *, gpointer);

View File

@ -419,6 +419,17 @@ select_save_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
view_dot_for_dot_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
gdisp = gdisplay_active ();
gdisplay_set_dot_for_dot (gdisp, GTK_CHECK_MENU_ITEM (widget)->active);
}
void
view_zoomin_cmd_callback (GtkWidget *widget,
gpointer client_data)

View File

@ -37,6 +37,7 @@ void select_grow_cmd_callback (GtkWidget *, gpointer);
void select_shrink_cmd_callback (GtkWidget *, gpointer);
void select_by_color_cmd_callback (GtkWidget *, gpointer);
void select_save_cmd_callback (GtkWidget *, gpointer);
void view_dot_for_dot_callback (GtkWidget *, gpointer);
void view_zoomin_cmd_callback (GtkWidget *, gpointer);
void view_zoomout_cmd_callback (GtkWidget *, gpointer);
void view_zoom_16_1_callback (GtkWidget *, gpointer);

View File

@ -205,7 +205,7 @@ info_window_update (InfoDialog *info_win,
gdisp->gimage->xresolution,
gdisp->gimage->yresolution);
/* zoom ratio */
/* user zoom ratio */
sprintf (iwd->scale_str, "%d:%d",
SCALEDEST (gdisp), SCALESRC (gdisp));

View File

@ -124,6 +124,7 @@ static GtkItemFactoryEntry image_entries[] =
{ N_("/View/Zoom/1:4"), NULL, view_zoom_1_4_callback, 0 },
{ N_("/View/Zoom/1:8"), NULL, view_zoom_1_8_callback, 0 },
{ N_("/View/Zoom/1:16"), NULL, view_zoom_1_16_callback, 0 },
{ N_("/View/Dot for dot"), NULL, view_dot_for_dot_callback, 0, "<ToggleItem>"},
{ N_("/View/Window Info..."), "<control><shift>I", view_window_info_cmd_callback, 0 },
{ N_("/View/Toggle Rulers"), "<control><shift>R", view_toggle_rulers_cmd_callback, 0, "<ToggleItem>" },
{ N_("/View/Toggle Statusbar"), "<control><shift>S", view_toggle_statusbar_cmd_callback, 0, "<ToggleItem>" },

View File

@ -105,6 +105,9 @@ static char * old_pattern_path;
static char * old_palette_path;
static char * old_plug_in_path;
static char * old_gradient_path;
static float old_monitor_xres;
static float old_monitor_yres;
static int old_using_xserver_resolution;
static char * edit_temp_path = NULL;
static char * edit_swap_path = NULL;
@ -122,6 +125,8 @@ static int edit_last_opened_size;
static GtkWidget *tile_cache_size_spinbutton = NULL;
static int divided_tile_cache_size;
static int mem_size_unit;
static GtkWidget *xres_spinbutton = NULL;
static GtkWidget *yres_spinbutton = NULL;
/* Some information regarding preferences, compiled by Raph Levien 11/3/97.
@ -227,10 +232,20 @@ file_prefs_ok_callback (GtkWidget *widget,
g_message (_("Error: Default height must be one or greater."));
default_height = old_default_height;
return;
}
}
if (monitor_xres < 1e-5 || monitor_yres < 1e-5)
{
g_message (_("Error: monitor resolution must not be zero."));
monitor_xres = old_monitor_xres;
monitor_yres = old_monitor_yres;
return;
}
gtk_widget_destroy (dlg);
prefs_dlg = NULL;
xres_spinbutton = NULL;
yres_spinbutton = NULL;
if (show_tool_tips)
gtk_tooltips_enable (tool_tips);
@ -238,6 +253,8 @@ file_prefs_ok_callback (GtkWidget *widget,
gtk_tooltips_disable (tool_tips);
}
static void
file_prefs_save_callback (GtkWidget *widget,
GtkWidget *dlg)
@ -342,6 +359,12 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "transparency-type");
if (transparency_size != old_transparency_size)
update = g_list_append (update, "transparency-size");
if (using_xserver_resolution != old_using_xserver_resolution ||
ABS(monitor_xres - old_monitor_xres) > 1e-5)
update = g_list_append (update, "monitor-xresolution");
if (using_xserver_resolution != old_using_xserver_resolution ||
ABS(monitor_yres - old_monitor_yres) > 1e-5)
update = g_list_append (update, "monitor-yresolution");
if (edit_stingy_memory_use != stingy_memory_use)
{
update = g_list_append (update, "stingy-memory-use");
@ -414,8 +437,19 @@ file_prefs_save_callback (GtkWidget *widget,
gradient_path = edit_gradient_path;
restart_notification = TRUE;
}
if (using_xserver_resolution)
{
/* special value of 0 for either x or y res in the gimprc file
* means use the xserver's current resolution */
monitor_xres = 0.0;
monitor_yres = 0.0;
}
save_gimprc (&update, &remove);
if (using_xserver_resolution)
gdisplay_xserver_resolution (&monitor_xres, &monitor_yres);
/* Restore variables which must not change */
stingy_memory_use = save_stingy_memory_use;
tile_cache_size = save_tile_cache_size;
@ -454,6 +488,8 @@ file_prefs_cancel_callback (GtkWidget *widget,
{
gtk_widget_destroy (dlg);
prefs_dlg = NULL;
xres_spinbutton = NULL;
yres_spinbutton = NULL;
levels_of_undo = old_levels_of_undo;
marching_speed = old_marching_speed;
@ -471,6 +507,9 @@ file_prefs_cancel_callback (GtkWidget *widget,
default_width = old_default_width;
default_height = old_default_height;
default_type = old_default_type;
monitor_xres = old_monitor_xres;
monitor_yres = old_monitor_yres;
using_xserver_resolution = old_using_xserver_resolution;
if (preview_size != old_preview_size)
{
@ -604,6 +643,16 @@ file_prefs_spinbutton_callback (GtkWidget *widget,
*val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
}
static void
file_prefs_float_spinbutton_callback (GtkWidget *widget,
gpointer data)
{
float *val;
val = data;
*val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
}
static void
file_prefs_string_callback (GtkWidget *widget,
gpointer data)
@ -622,6 +671,36 @@ file_prefs_clear_session_info_callback (GtkWidget *widget,
session_info_updates = NULL;
}
static void
file_prefs_res_source_callback (GtkWidget *widget,
gpointer data)
{
if (xres_spinbutton)
gtk_widget_set_sensitive (xres_spinbutton,
! GTK_TOGGLE_BUTTON (widget)->active);
if (yres_spinbutton)
gtk_widget_set_sensitive (yres_spinbutton,
! GTK_TOGGLE_BUTTON (widget)->active);
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gdisplay_xserver_resolution (&monitor_xres, &monitor_yres);
using_xserver_resolution = TRUE;
}
else
{
if (xres_spinbutton)
monitor_xres = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON
(xres_spinbutton));
if (yres_spinbutton)
monitor_yres = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON
(yres_spinbutton));
using_xserver_resolution = FALSE;
}
}
void
file_pref_cmd_callback (GtkWidget *widget,
gpointer client_data)
@ -756,6 +835,9 @@ file_pref_cmd_callback (GtkWidget *widget,
old_install_cmap = edit_install_cmap;
old_cycled_marching_ants = edit_cycled_marching_ants;
old_last_opened_size = edit_last_opened_size;
old_monitor_xres = monitor_xres;
old_monitor_yres = monitor_yres;
old_using_xserver_resolution = using_xserver_resolution;
file_prefs_strset (&old_temp_path, edit_temp_path);
file_prefs_strset (&old_swap_path, edit_swap_path);
file_prefs_strset (&old_brush_path, edit_brush_path);
@ -1321,6 +1403,100 @@ file_pref_cmd_callback (GtkWidget *widget,
label = gtk_label_new (_("Directories"));
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
/* Monitor */
out_frame = gtk_frame_new (_("Monitor information"));
gtk_container_border_width (GTK_CONTAINER (out_frame), 10);
gtk_widget_set_usize (out_frame, 320, 200);
gtk_widget_show (out_frame);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (vbox), 1);
gtk_container_add (GTK_CONTAINER (out_frame), vbox);
gtk_widget_show (vbox);
label = gtk_label_new (_("Get monitor resolution"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
group = NULL;
button = gtk_radio_button_new_with_label (group, _("from X server"));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
GTK_SIGNAL_FUNC (file_prefs_res_source_callback),
NULL);
gtk_widget_show (button);
{
float xres, yres;
char buf[80];
gdisplay_xserver_resolution (&xres, &yres);
sprintf (buf, _("(currently %d x %d dpi)"),
(int)(xres + 0.5), (int)(yres + 0.5));
label = gtk_label_new (buf);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
}
button = gtk_radio_button_new_with_label (group, _("manually:"));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (!using_xserver_resolution)
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
abox = gtk_alignment_new (0.5, 0.5, 0.0, 1.0);
gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0);
gtk_widget_show (abox);
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (abox), hbox);
gtk_widget_show (hbox);
adj = (GtkAdjustment *) gtk_adjustment_new (monitor_xres, 1.0,
32768, 1.0,
15.0, 0.0);
xres_spinbutton = gtk_spin_button_new (adj, 1.0, 2.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(xres_spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (xres_spinbutton), TRUE);
gtk_widget_set_usize (xres_spinbutton, 70, 0);
gtk_box_pack_start (GTK_BOX (hbox), xres_spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (xres_spinbutton), "changed",
GTK_SIGNAL_FUNC (file_prefs_float_spinbutton_callback),
&monitor_xres);
gtk_widget_set_sensitive (xres_spinbutton, !using_xserver_resolution);
gtk_widget_show (xres_spinbutton);
label = gtk_label_new ( _(" by "));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
adj = (GtkAdjustment *) gtk_adjustment_new (monitor_yres, 1.0,
32768, 1.0,
15.0, 0.0);
yres_spinbutton = gtk_spin_button_new (adj, 1.0, 2.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (yres_spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (yres_spinbutton), TRUE);
gtk_widget_set_usize (yres_spinbutton, 70, 0);
gtk_box_pack_start (GTK_BOX (hbox), yres_spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (yres_spinbutton), "changed",
GTK_SIGNAL_FUNC (file_prefs_float_spinbutton_callback),
&monitor_yres);
gtk_widget_set_sensitive (yres_spinbutton, !using_xserver_resolution);
gtk_widget_show (yres_spinbutton);
label = gtk_label_new ( _("dpi"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
label = gtk_label_new (_("Monitor"));
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
gtk_widget_show (notebook);
gtk_widget_show (prefs_dlg);

View File

@ -41,8 +41,8 @@ struct _RenderInfo
guchar *dest;
int x, y;
int w, h;
int scalesrc;
int scaledest;
float scalex;
float scaley;
int src_x, src_y;
int src_bpp;
int dest_bpp;
@ -190,9 +190,7 @@ static void render_image_init_info (RenderInfo *info,
static guint* render_image_init_alpha (int mult);
static guchar* render_image_accelerate_scaling (int width,
int start,
int bpp,
int scalesrc,
int scaledest);
float scalex);
static guchar* render_image_tile_fault (RenderInfo *info);
@ -240,6 +238,11 @@ render_image (GDisplay *gdisp,
return;
}
/* Currently, only RGBA and GRAYA projection types are used - the rest
* are in case of future need. -- austin, 28th Nov 1998. */
if (image_type != RGBA_GIMAGE && image_type != GRAYA_GIMAGE)
g_warning ("using untested projection type %d", image_type);
(* render_funcs[image_type]) (&info);
}
@ -263,6 +266,8 @@ render_image_indexed (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -273,13 +278,18 @@ render_image_indexed (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -302,13 +312,17 @@ render_image_indexed (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -330,6 +344,8 @@ render_image_indexed_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -341,13 +357,18 @@ render_image_indexed_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -389,13 +410,17 @@ render_image_indexed_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -412,6 +437,8 @@ render_image_gray (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -421,13 +448,18 @@ render_image_gray (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -450,13 +482,17 @@ render_image_gray (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -476,6 +512,8 @@ render_image_gray_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -486,13 +524,18 @@ render_image_gray_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -524,13 +567,17 @@ render_image_gray_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -546,6 +593,8 @@ render_image_rgb (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -555,13 +604,18 @@ render_image_rgb (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= (int)error - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest))
if (!initial && (error < 1.0))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -584,13 +638,17 @@ render_image_rgb (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -612,6 +670,8 @@ render_image_rgb_a (RenderInfo *info)
int y, ye;
int x, xe;
int initial;
float error;
float step;
lookup_red = g_lookup_red;
lookup_green = g_lookup_green;
@ -622,13 +682,18 @@ render_image_rgb_a (RenderInfo *info)
ye = info->y + info->h;
xe = info->x + info->w;
step = 1.0 / info->scaley;
error = y * step;
error -= ((int)error) - step;
initial = TRUE;
byte_order = info->byte_order;
info->src = render_image_tile_fault (info);
for (; y < ye; y++)
{
if (!initial && (y % info->scaledest) && (y & check_mod))
if (!initial && (error < 1.0) && (y & check_mod))
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
else
{
@ -697,13 +762,17 @@ render_image_rgb_a (RenderInfo *info)
info->dest += info->dest_bpl;
if (((y + 1) % info->scaledest) == 0)
initial = FALSE;
if (error >= 1.0)
{
info->src_y += info->scalesrc;
info->src_y += (int)error;
error -= (int)error;
info->src = render_image_tile_fault (info);
initial = TRUE;
}
initial = FALSE;
error += step;
}
}
@ -721,17 +790,17 @@ render_image_init_info (RenderInfo *info,
info->y = y + gdisp->offset_y;
info->w = w;
info->h = h;
info->scalesrc = SCALESRC (gdisp);
info->scaledest = SCALEDEST (gdisp);
info->src_x = UNSCALE (gdisp, info->x);
info->src_y = UNSCALE (gdisp, info->y);
info->scalex = SCALEFACTOR_X (gdisp);
info->scaley = SCALEFACTOR_Y (gdisp);
info->src_x = UNSCALEX (gdisp, info->x);
info->src_y = UNSCALEY (gdisp, info->y);
info->src_bpp = gimage_projection_bytes (gdisp->gimage);
info->dest = gximage_get_data ();
info->dest_bpp = gximage_get_bpp ();
info->dest_bpl = gximage_get_bpl ();
info->dest_width = info->w * info->dest_bpp;
info->byte_order = gximage_get_byte_order ();
info->scale = render_image_accelerate_scaling (w, info->x, info->src_bpp, info->scalesrc, info->scaledest);
info->scale = render_image_accelerate_scaling (w, info->x, info->scalex);
info->alpha = NULL;
switch (gimage_projection_type (gdisp->gimage))
@ -765,28 +834,28 @@ render_image_init_alpha (int mult)
}
static guchar*
render_image_accelerate_scaling (int width,
int start,
int bpp,
int scalesrc,
int scaledest)
render_image_accelerate_scaling (int width,
int start,
float scalex)
{
static guchar *scale = NULL;
static int swidth = -1;
static int sstart = -1;
guchar step;
float error;
float step;
int i;
if ((swidth != width) || (sstart != start))
{
if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1);
if (!scale)
scale = g_new (guchar, GXIMAGE_WIDTH + 1);
step = scalesrc * bpp;
step = 1.0 / scalex;
for (i = 0; i <= width; i++)
scale[i] = ((i + start + 1) % scaledest) ? 0 : step;
}
error = start * step;
error -= ((int)error) - step;
for (i = 0; i <= width; i++)
{
scale[i] = ((int)error);
error += step - (int)error;
}
return scale;
}
@ -802,6 +871,7 @@ render_image_tile_fault (RenderInfo *info)
int tilex;
int tiley;
int step;
int bpp = info->src_bpp;
int x, b;
tilex = info->src_x / TILE_WIDTH;
@ -815,7 +885,6 @@ render_image_tile_fault (RenderInfo *info)
info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT);
scale = info->scale;
step = info->scalesrc * info->src_bpp;
dest = tile_buf;
x = info->src_x;
@ -823,13 +892,14 @@ render_image_tile_fault (RenderInfo *info)
while (width--)
{
for (b = 0; b < info->src_bpp; b++)
for (b = 0; b < bpp; b++)
*dest++ = data[b];
if (*scale++ != 0)
step = *scale++;
if (step != 0)
{
x += info->scalesrc;
data += step;
x += step;
data += step * bpp;
if ((x >> tile_shift) != tilex)
{

View File

@ -205,7 +205,7 @@ info_window_update (InfoDialog *info_win,
gdisp->gimage->xresolution,
gdisp->gimage->yresolution);
/* zoom ratio */
/* user zoom ratio */
sprintf (iwd->scale_str, "%d:%d",
SCALEDEST (gdisp), SCALESRC (gdisp));

View File

@ -222,6 +222,8 @@ magnify_button_release (Tool *tool,
x2 = x1 + w;
y2 = y1 + h;
/* these change the user zoom level, so should not be changed to
* the resolution-aware scale macros -- austin */
scalesrc = SCALESRC(gdisp);
scaledest = SCALEDEST(gdisp);

View File

@ -124,6 +124,7 @@ static GtkItemFactoryEntry image_entries[] =
{ N_("/View/Zoom/1:4"), NULL, view_zoom_1_4_callback, 0 },
{ N_("/View/Zoom/1:8"), NULL, view_zoom_1_8_callback, 0 },
{ N_("/View/Zoom/1:16"), NULL, view_zoom_1_16_callback, 0 },
{ N_("/View/Dot for dot"), NULL, view_dot_for_dot_callback, 0, "<ToggleItem>"},
{ N_("/View/Window Info..."), "<control><shift>I", view_window_info_cmd_callback, 0 },
{ N_("/View/Toggle Rulers"), "<control><shift>R", view_toggle_rulers_cmd_callback, 0, "<ToggleItem>" },
{ N_("/View/Toggle Statusbar"), "<control><shift>S", view_toggle_statusbar_cmd_callback, 0, "<ToggleItem>" },

View File

@ -124,6 +124,7 @@ static GtkItemFactoryEntry image_entries[] =
{ N_("/View/Zoom/1:4"), NULL, view_zoom_1_4_callback, 0 },
{ N_("/View/Zoom/1:8"), NULL, view_zoom_1_8_callback, 0 },
{ N_("/View/Zoom/1:16"), NULL, view_zoom_1_16_callback, 0 },
{ N_("/View/Dot for dot"), NULL, view_dot_for_dot_callback, 0, "<ToggleItem>"},
{ N_("/View/Window Info..."), "<control><shift>I", view_window_info_cmd_callback, 0 },
{ N_("/View/Toggle Rulers"), "<control><shift>R", view_toggle_rulers_cmd_callback, 0, "<ToggleItem>" },
{ N_("/View/Toggle Statusbar"), "<control><shift>S", view_toggle_statusbar_cmd_callback, 0, "<ToggleItem>" },

View File

@ -105,6 +105,9 @@ static char * old_pattern_path;
static char * old_palette_path;
static char * old_plug_in_path;
static char * old_gradient_path;
static float old_monitor_xres;
static float old_monitor_yres;
static int old_using_xserver_resolution;
static char * edit_temp_path = NULL;
static char * edit_swap_path = NULL;
@ -122,6 +125,8 @@ static int edit_last_opened_size;
static GtkWidget *tile_cache_size_spinbutton = NULL;
static int divided_tile_cache_size;
static int mem_size_unit;
static GtkWidget *xres_spinbutton = NULL;
static GtkWidget *yres_spinbutton = NULL;
/* Some information regarding preferences, compiled by Raph Levien 11/3/97.
@ -227,10 +232,20 @@ file_prefs_ok_callback (GtkWidget *widget,
g_message (_("Error: Default height must be one or greater."));
default_height = old_default_height;
return;
}
}
if (monitor_xres < 1e-5 || monitor_yres < 1e-5)
{
g_message (_("Error: monitor resolution must not be zero."));
monitor_xres = old_monitor_xres;
monitor_yres = old_monitor_yres;
return;
}
gtk_widget_destroy (dlg);
prefs_dlg = NULL;
xres_spinbutton = NULL;
yres_spinbutton = NULL;
if (show_tool_tips)
gtk_tooltips_enable (tool_tips);
@ -238,6 +253,8 @@ file_prefs_ok_callback (GtkWidget *widget,
gtk_tooltips_disable (tool_tips);
}
static void
file_prefs_save_callback (GtkWidget *widget,
GtkWidget *dlg)
@ -342,6 +359,12 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "transparency-type");
if (transparency_size != old_transparency_size)
update = g_list_append (update, "transparency-size");
if (using_xserver_resolution != old_using_xserver_resolution ||
ABS(monitor_xres - old_monitor_xres) > 1e-5)
update = g_list_append (update, "monitor-xresolution");
if (using_xserver_resolution != old_using_xserver_resolution ||
ABS(monitor_yres - old_monitor_yres) > 1e-5)
update = g_list_append (update, "monitor-yresolution");
if (edit_stingy_memory_use != stingy_memory_use)
{
update = g_list_append (update, "stingy-memory-use");
@ -414,8 +437,19 @@ file_prefs_save_callback (GtkWidget *widget,
gradient_path = edit_gradient_path;
restart_notification = TRUE;
}
if (using_xserver_resolution)
{
/* special value of 0 for either x or y res in the gimprc file
* means use the xserver's current resolution */
monitor_xres = 0.0;
monitor_yres = 0.0;
}
save_gimprc (&update, &remove);
if (using_xserver_resolution)
gdisplay_xserver_resolution (&monitor_xres, &monitor_yres);
/* Restore variables which must not change */
stingy_memory_use = save_stingy_memory_use;
tile_cache_size = save_tile_cache_size;
@ -454,6 +488,8 @@ file_prefs_cancel_callback (GtkWidget *widget,
{
gtk_widget_destroy (dlg);
prefs_dlg = NULL;
xres_spinbutton = NULL;
yres_spinbutton = NULL;
levels_of_undo = old_levels_of_undo;
marching_speed = old_marching_speed;
@ -471,6 +507,9 @@ file_prefs_cancel_callback (GtkWidget *widget,
default_width = old_default_width;
default_height = old_default_height;
default_type = old_default_type;
monitor_xres = old_monitor_xres;
monitor_yres = old_monitor_yres;
using_xserver_resolution = old_using_xserver_resolution;
if (preview_size != old_preview_size)
{
@ -604,6 +643,16 @@ file_prefs_spinbutton_callback (GtkWidget *widget,
*val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
}
static void
file_prefs_float_spinbutton_callback (GtkWidget *widget,
gpointer data)
{
float *val;
val = data;
*val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
}
static void
file_prefs_string_callback (GtkWidget *widget,
gpointer data)
@ -622,6 +671,36 @@ file_prefs_clear_session_info_callback (GtkWidget *widget,
session_info_updates = NULL;
}
static void
file_prefs_res_source_callback (GtkWidget *widget,
gpointer data)
{
if (xres_spinbutton)
gtk_widget_set_sensitive (xres_spinbutton,
! GTK_TOGGLE_BUTTON (widget)->active);
if (yres_spinbutton)
gtk_widget_set_sensitive (yres_spinbutton,
! GTK_TOGGLE_BUTTON (widget)->active);
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gdisplay_xserver_resolution (&monitor_xres, &monitor_yres);
using_xserver_resolution = TRUE;
}
else
{
if (xres_spinbutton)
monitor_xres = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON
(xres_spinbutton));
if (yres_spinbutton)
monitor_yres = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON
(yres_spinbutton));
using_xserver_resolution = FALSE;
}
}
void
file_pref_cmd_callback (GtkWidget *widget,
gpointer client_data)
@ -756,6 +835,9 @@ file_pref_cmd_callback (GtkWidget *widget,
old_install_cmap = edit_install_cmap;
old_cycled_marching_ants = edit_cycled_marching_ants;
old_last_opened_size = edit_last_opened_size;
old_monitor_xres = monitor_xres;
old_monitor_yres = monitor_yres;
old_using_xserver_resolution = using_xserver_resolution;
file_prefs_strset (&old_temp_path, edit_temp_path);
file_prefs_strset (&old_swap_path, edit_swap_path);
file_prefs_strset (&old_brush_path, edit_brush_path);
@ -1321,6 +1403,100 @@ file_pref_cmd_callback (GtkWidget *widget,
label = gtk_label_new (_("Directories"));
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
/* Monitor */
out_frame = gtk_frame_new (_("Monitor information"));
gtk_container_border_width (GTK_CONTAINER (out_frame), 10);
gtk_widget_set_usize (out_frame, 320, 200);
gtk_widget_show (out_frame);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (vbox), 1);
gtk_container_add (GTK_CONTAINER (out_frame), vbox);
gtk_widget_show (vbox);
label = gtk_label_new (_("Get monitor resolution"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
group = NULL;
button = gtk_radio_button_new_with_label (group, _("from X server"));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
GTK_SIGNAL_FUNC (file_prefs_res_source_callback),
NULL);
gtk_widget_show (button);
{
float xres, yres;
char buf[80];
gdisplay_xserver_resolution (&xres, &yres);
sprintf (buf, _("(currently %d x %d dpi)"),
(int)(xres + 0.5), (int)(yres + 0.5));
label = gtk_label_new (buf);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
}
button = gtk_radio_button_new_with_label (group, _("manually:"));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (!using_xserver_resolution)
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
abox = gtk_alignment_new (0.5, 0.5, 0.0, 1.0);
gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0);
gtk_widget_show (abox);
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (abox), hbox);
gtk_widget_show (hbox);
adj = (GtkAdjustment *) gtk_adjustment_new (monitor_xres, 1.0,
32768, 1.0,
15.0, 0.0);
xres_spinbutton = gtk_spin_button_new (adj, 1.0, 2.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON(xres_spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (xres_spinbutton), TRUE);
gtk_widget_set_usize (xres_spinbutton, 70, 0);
gtk_box_pack_start (GTK_BOX (hbox), xres_spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (xres_spinbutton), "changed",
GTK_SIGNAL_FUNC (file_prefs_float_spinbutton_callback),
&monitor_xres);
gtk_widget_set_sensitive (xres_spinbutton, !using_xserver_resolution);
gtk_widget_show (xres_spinbutton);
label = gtk_label_new ( _(" by "));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
adj = (GtkAdjustment *) gtk_adjustment_new (monitor_yres, 1.0,
32768, 1.0,
15.0, 0.0);
yres_spinbutton = gtk_spin_button_new (adj, 1.0, 2.0);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (yres_spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (yres_spinbutton), TRUE);
gtk_widget_set_usize (yres_spinbutton, 70, 0);
gtk_box_pack_start (GTK_BOX (hbox), yres_spinbutton, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (yres_spinbutton), "changed",
GTK_SIGNAL_FUNC (file_prefs_float_spinbutton_callback),
&monitor_yres);
gtk_widget_set_sensitive (yres_spinbutton, !using_xserver_resolution);
gtk_widget_show (yres_spinbutton);
label = gtk_label_new ( _("dpi"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
label = gtk_label_new (_("Monitor"));
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
gtk_widget_show (notebook);
gtk_widget_show (prefs_dlg);

View File

@ -30,8 +30,8 @@ bounds_checking (GDisplay *gdisp)
{
int sx, sy;
sx = SCALE(gdisp, gdisp->gimage->width);
sy = SCALE(gdisp, gdisp->gimage->height);
sx = SCALEX(gdisp, gdisp->gimage->width);
sy = SCALEY(gdisp, gdisp->gimage->height);
gdisp->offset_x = BOUNDS (gdisp->offset_x, 0,
LOWPASS (sx - gdisp->disp_width));
@ -93,6 +93,7 @@ change_scale (GDisplay *gdisp,
double offset_x, offset_y;
long sx, sy;
/* user zoom control, so resolution versions not needed -- austin */
scalesrc = SCALESRC(gdisp);
scaledest = SCALEDEST(gdisp);
@ -163,23 +164,24 @@ setup_scale (GDisplay *gdisp)
GtkRuler *hruler;
GtkRuler *vruler;
gfloat sx, sy;
gfloat step;
gfloat stepx, stepy;
sx = SCALE(gdisp, gdisp->gimage->width);
sy = SCALE(gdisp, gdisp->gimage->height);
step = SCALE(gdisp, 1);
sx = SCALEX(gdisp, gdisp->gimage->width);
sy = SCALEY(gdisp, gdisp->gimage->height);
stepx = SCALEX(gdisp, 1);
stepy = SCALEY(gdisp, 1);
gdisp->hsbdata->value = gdisp->offset_x;
gdisp->hsbdata->upper = sx;
gdisp->hsbdata->page_size = MIN (sx, gdisp->disp_width);
gdisp->hsbdata->page_increment = (gdisp->disp_width / 2);
gdisp->hsbdata->step_increment = step;
gdisp->hsbdata->step_increment = stepx;
gdisp->vsbdata->value = gdisp->offset_y;
gdisp->vsbdata->upper = sy;
gdisp->vsbdata->page_size = MIN (sy, gdisp->disp_height);
gdisp->vsbdata->page_increment = (gdisp->disp_height / 2);
gdisp->vsbdata->step_increment = step;
gdisp->vsbdata->step_increment = stepy;
gtk_signal_emit_by_name (GTK_OBJECT (gdisp->hsbdata), "changed");
gtk_signal_emit_by_name (GTK_OBJECT (gdisp->vsbdata), "changed");
@ -188,37 +190,37 @@ setup_scale (GDisplay *gdisp)
vruler = GTK_RULER (gdisp->vrule);
hruler->lower = 0;
hruler->upper = UNSCALE (gdisp, gdisp->disp_width);
hruler->upper = UNSCALEX (gdisp, gdisp->disp_width);
hruler->max_size = MAXIMUM (gdisp->gimage->width, gdisp->gimage->height);
vruler->lower = 0;
vruler->upper = UNSCALE (gdisp, gdisp->disp_height);
vruler->upper = UNSCALEY (gdisp, gdisp->disp_height);
vruler->max_size = MAXIMUM (gdisp->gimage->width, gdisp->gimage->height);
if (sx < gdisp->disp_width)
{
gdisp->disp_xoffset = (gdisp->disp_width - sx) / 2;
hruler->lower -= UNSCALE (gdisp, (double) gdisp->disp_xoffset);
hruler->upper -= UNSCALE (gdisp, (double) gdisp->disp_xoffset);
hruler->lower -= UNSCALEX (gdisp, (double) gdisp->disp_xoffset);
hruler->upper -= UNSCALEX (gdisp, (double) gdisp->disp_xoffset);
}
else
{
gdisp->disp_xoffset = 0;
hruler->lower += UNSCALE (gdisp, (double) gdisp->offset_x);
hruler->upper += UNSCALE (gdisp, (double) gdisp->offset_x);
hruler->lower += UNSCALEX (gdisp, (double) gdisp->offset_x);
hruler->upper += UNSCALEX (gdisp, (double) gdisp->offset_x);
}
if (sy < gdisp->disp_height)
{
gdisp->disp_yoffset = (gdisp->disp_height - sy) / 2;
vruler->lower -= UNSCALE (gdisp, (double) gdisp->disp_yoffset);
vruler->upper -= UNSCALE (gdisp, (double) gdisp->disp_yoffset);
vruler->lower -= UNSCALEY (gdisp, (double) gdisp->disp_yoffset);
vruler->upper -= UNSCALEY (gdisp, (double) gdisp->disp_yoffset);
}
else
{
gdisp->disp_yoffset = 0;
vruler->lower += UNSCALE (gdisp, (double) gdisp->offset_y);
vruler->upper += UNSCALE (gdisp, (double) gdisp->offset_y);
vruler->lower += UNSCALEY (gdisp, (double) gdisp->offset_y);
vruler->upper += UNSCALEY (gdisp, (double) gdisp->offset_y);
}
gtk_widget_draw (GTK_WIDGET (hruler), NULL);

View File

@ -27,6 +27,7 @@
#include "gimage_mask.h"
#include "gdisplay.h"
#include "undo.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
@ -322,8 +323,8 @@ edit_selection_draw (Tool *tool)
gdisp = (GDisplay *) tool->gdisp_ptr;
select = gdisp->select;
diff_x = SCALE (gdisp, (edit_select.x - edit_select.origx));
diff_y = SCALE (gdisp, (edit_select.y - edit_select.origy));
diff_x = SCALEX (gdisp, (edit_select.x - edit_select.origx));
diff_y = SCALEY (gdisp, (edit_select.y - edit_select.origy));
switch (edit_select.edit_type)
{

View File

@ -27,6 +27,7 @@
#include "gimage_mask.h"
#include "gdisplay.h"
#include "undo.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
@ -322,8 +323,8 @@ edit_selection_draw (Tool *tool)
gdisp = (GDisplay *) tool->gdisp_ptr;
select = gdisp->select;
diff_x = SCALE (gdisp, (edit_select.x - edit_select.origx));
diff_y = SCALE (gdisp, (edit_select.y - edit_select.origy));
diff_x = SCALEX (gdisp, (edit_select.x - edit_select.origx));
diff_y = SCALEY (gdisp, (edit_select.y - edit_select.origy));
switch (edit_select.edit_type)
{

View File

@ -222,6 +222,8 @@ magnify_button_release (Tool *tool,
x2 = x1 + w;
y2 = y1 + h;
/* these change the user zoom level, so should not be changed to
* the resolution-aware scale macros -- austin */
scalesrc = SCALESRC(gdisp);
scaledest = SCALEDEST(gdisp);

View File

@ -222,6 +222,8 @@ magnify_button_release (Tool *tool,
x2 = x1 + w;
y2 = y1 + h;
/* these change the user zoom level, so should not be changed to
* the resolution-aware scale macros -- austin */
scalesrc = SCALESRC(gdisp);
scaledest = SCALEDEST(gdisp);

View File

@ -124,6 +124,7 @@ static GtkItemFactoryEntry image_entries[] =
{ N_("/View/Zoom/1:4"), NULL, view_zoom_1_4_callback, 0 },
{ N_("/View/Zoom/1:8"), NULL, view_zoom_1_8_callback, 0 },
{ N_("/View/Zoom/1:16"), NULL, view_zoom_1_16_callback, 0 },
{ N_("/View/Dot for dot"), NULL, view_dot_for_dot_callback, 0, "<ToggleItem>"},
{ N_("/View/Window Info..."), "<control><shift>I", view_window_info_cmd_callback, 0 },
{ N_("/View/Toggle Rulers"), "<control><shift>R", view_toggle_rulers_cmd_callback, 0, "<ToggleItem>" },
{ N_("/View/Toggle Statusbar"), "<control><shift>S", view_toggle_statusbar_cmd_callback, 0, "<ToggleItem>" },

View File

@ -23,7 +23,7 @@
*/
/*
* version 0.50
* version 0.51
* This version requires gtk-1.0.4 or above.
*
* This plug-in puts an image through a screen at a particular angle
@ -52,7 +52,7 @@
static char rcsid[] = "$Id$";
#endif
#define VERSION "v0.50"
#define VERSION "v0.51"
/* Some useful macros */
#ifdef DEBUG
@ -826,7 +826,7 @@ newsprint_menu_callback(GtkWidget *widget,
/* we shouldn't need recursion protection, but if lock_channels is
* set, and gtk_option_menu_set_history ever generates an
* "activated" signmal, then we'll get back here. So we've defensive. */
* "activated" signal, then we'll get back here. So we've defensive. */
if (in_progress)
{
printf("newsprint_menu_callback: unexpected recursion: "
@ -1134,12 +1134,13 @@ gen_channels(NewsprintDialog_st *st, gint colourspace)
{
chst[i] = new_channel(ct);
gtk_signal_connect(GTK_OBJECT(chst[i]->ch_menuitem), "activate",
(GtkSignalFunc)newsprint_channel_select_callback,
st);
/* only link in the menuitem if we're doing multiple channels */
if (st->channel_menu)
{
gtk_signal_connect(GTK_OBJECT(chst[i]->ch_menuitem), "activate",
(GtkSignalFunc)newsprint_channel_select_callback,
st);
gtk_menu_append(GTK_MENU(st->channel_menu),
GTK_WIDGET(chst[i]->ch_menuitem));
chst[i]->ch_menu_num = cur_menu_num;
@ -1432,8 +1433,9 @@ newsprint_dialog (GDrawable *drawable)
gtk_widget_show(GTK_WIDGET(chst[i]->ch_menuitem));
/* select the first channel to edit */
gtk_option_menu_set_history(GTK_OPTION_MENU(st.channel_option),
chst[0]->ch_menu_num);
if (st.channel_option)
gtk_option_menu_set_history(GTK_OPTION_MENU(st.channel_option),
chst[0]->ch_menu_num);
gtk_menu_item_activate(GTK_MENU_ITEM(chst[0]->ch_menuitem));
}

View File

@ -23,7 +23,7 @@
*/
/*
* version 0.50
* version 0.51
* This version requires gtk-1.0.4 or above.
*
* This plug-in puts an image through a screen at a particular angle
@ -52,7 +52,7 @@
static char rcsid[] = "$Id$";
#endif
#define VERSION "v0.50"
#define VERSION "v0.51"
/* Some useful macros */
#ifdef DEBUG
@ -826,7 +826,7 @@ newsprint_menu_callback(GtkWidget *widget,
/* we shouldn't need recursion protection, but if lock_channels is
* set, and gtk_option_menu_set_history ever generates an
* "activated" signmal, then we'll get back here. So we've defensive. */
* "activated" signal, then we'll get back here. So we've defensive. */
if (in_progress)
{
printf("newsprint_menu_callback: unexpected recursion: "
@ -1134,12 +1134,13 @@ gen_channels(NewsprintDialog_st *st, gint colourspace)
{
chst[i] = new_channel(ct);
gtk_signal_connect(GTK_OBJECT(chst[i]->ch_menuitem), "activate",
(GtkSignalFunc)newsprint_channel_select_callback,
st);
/* only link in the menuitem if we're doing multiple channels */
if (st->channel_menu)
{
gtk_signal_connect(GTK_OBJECT(chst[i]->ch_menuitem), "activate",
(GtkSignalFunc)newsprint_channel_select_callback,
st);
gtk_menu_append(GTK_MENU(st->channel_menu),
GTK_WIDGET(chst[i]->ch_menuitem));
chst[i]->ch_menu_num = cur_menu_num;
@ -1432,8 +1433,9 @@ newsprint_dialog (GDrawable *drawable)
gtk_widget_show(GTK_WIDGET(chst[i]->ch_menuitem));
/* select the first channel to edit */
gtk_option_menu_set_history(GTK_OPTION_MENU(st.channel_option),
chst[0]->ch_menu_num);
if (st.channel_option)
gtk_option_menu_set_history(GTK_OPTION_MENU(st.channel_option),
chst[0]->ch_menu_num);
gtk_menu_item_activate(GTK_MENU_ITEM(chst[0]->ch_menuitem));
}