Commit 550aa9b4 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/layers_dialog.c app/lc_dialog.c another try on bug #31098. This time

2000-12-14  Sven Neumann  <sven@gimp.org>

	* app/layers_dialog.c
	* app/lc_dialog.c
	* app/nav_window.c: another try on bug #31098. This time limited the
	preview scale ratio in the calling functions. Please test!

	* app/gimpimage.c: small cleanup
parent 6130edbf
2000-12-14 Sven Neumann <sven@gimp.org>
* app/layers_dialog.c
* app/lc_dialog.c
* app/nav_window.c: another try on bug #31098. This time limited the
preview scale ratio in the calling functions. Please test!
* app/gimpimage.c: small cleanup
2000-12-14 Sven Neumann <sven@gimp.org>
 
* app/menus.c: modified debug function to help to find missing
......
......@@ -324,8 +324,9 @@ void
gimp_image_set_filename (GimpImage *gimage,
gchar *filename)
{
gchar *new_filename, *old_filename;
gboolean free_old;
gchar *new_filename;
gchar *old_filename;
gboolean free_old;
/*
* WARNING: this function will free the current filename even if you are
......@@ -764,15 +765,20 @@ gimp_image_apply_image (GimpImage *gimage,
* If an alternative to using the drawable's data as src1 was provided...
*/
if (src1_tiles)
pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&src1PR, src1_tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
else
pixel_region_init (&src1PR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR, src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1));
pixel_region_init (&src1PR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
(x2 - x1), (y2 - y1));
if (mask)
{
int mx, my;
gint mx, my;
/* configure the mask pixel region
* don't use x1 and y1 because they are in layer
......
......@@ -324,8 +324,9 @@ void
gimp_image_set_filename (GimpImage *gimage,
gchar *filename)
{
gchar *new_filename, *old_filename;
gboolean free_old;
gchar *new_filename;
gchar *old_filename;
gboolean free_old;
/*
* WARNING: this function will free the current filename even if you are
......@@ -764,15 +765,20 @@ gimp_image_apply_image (GimpImage *gimage,
* If an alternative to using the drawable's data as src1 was provided...
*/
if (src1_tiles)
pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&src1PR, src1_tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
else
pixel_region_init (&src1PR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR, src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1));
pixel_region_init (&src1PR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
(x2 - x1), (y2 - y1));
if (mask)
{
int mx, my;
gint mx, my;
/* configure the mask pixel region
* don't use x1 and y1 because they are in layer
......
......@@ -324,8 +324,9 @@ void
gimp_image_set_filename (GimpImage *gimage,
gchar *filename)
{
gchar *new_filename, *old_filename;
gboolean free_old;
gchar *new_filename;
gchar *old_filename;
gboolean free_old;
/*
* WARNING: this function will free the current filename even if you are
......@@ -764,15 +765,20 @@ gimp_image_apply_image (GimpImage *gimage,
* If an alternative to using the drawable's data as src1 was provided...
*/
if (src1_tiles)
pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&src1PR, src1_tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
else
pixel_region_init (&src1PR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR, src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1));
pixel_region_init (&src1PR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
(x2 - x1), (y2 - y1));
if (mask)
{
int mx, my;
gint mx, my;
/* configure the mask pixel region
* don't use x1 and y1 because they are in layer
......
......@@ -324,8 +324,9 @@ void
gimp_image_set_filename (GimpImage *gimage,
gchar *filename)
{
gchar *new_filename, *old_filename;
gboolean free_old;
gchar *new_filename;
gchar *old_filename;
gboolean free_old;
/*
* WARNING: this function will free the current filename even if you are
......@@ -764,15 +765,20 @@ gimp_image_apply_image (GimpImage *gimage,
* If an alternative to using the drawable's data as src1 was provided...
*/
if (src1_tiles)
pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&src1PR, src1_tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
else
pixel_region_init (&src1PR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR, src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1));
pixel_region_init (&src1PR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
(x2 - x1), (y2 - y1));
if (mask)
{
int mx, my;
gint mx, my;
/* configure the mask pixel region
* don't use x1 and y1 because they are in layer
......
......@@ -324,8 +324,9 @@ void
gimp_image_set_filename (GimpImage *gimage,
gchar *filename)
{
gchar *new_filename, *old_filename;
gboolean free_old;
gchar *new_filename;
gchar *old_filename;
gboolean free_old;
/*
* WARNING: this function will free the current filename even if you are
......@@ -764,15 +765,20 @@ gimp_image_apply_image (GimpImage *gimage,
* If an alternative to using the drawable's data as src1 was provided...
*/
if (src1_tiles)
pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&src1PR, src1_tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
else
pixel_region_init (&src1PR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR, src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1));
pixel_region_init (&src1PR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
(x2 - x1), (y2 - y1));
if (mask)
{
int mx, my;
gint mx, my;
/* configure the mask pixel region
* don't use x1 and y1 because they are in layer
......
......@@ -324,8 +324,9 @@ void
gimp_image_set_filename (GimpImage *gimage,
gchar *filename)
{
gchar *new_filename, *old_filename;
gboolean free_old;
gchar *new_filename;
gchar *old_filename;
gboolean free_old;
/*
* WARNING: this function will free the current filename even if you are
......@@ -764,15 +765,20 @@ gimp_image_apply_image (GimpImage *gimage,
* If an alternative to using the drawable's data as src1 was provided...
*/
if (src1_tiles)
pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&src1PR, src1_tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
else
pixel_region_init (&src1PR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR, src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1));
pixel_region_init (&src1PR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
(x2 - x1), (y2 - y1));
if (mask)
{
int mx, my;
gint mx, my;
/* configure the mask pixel region
* don't use x1 and y1 because they are in layer
......
......@@ -324,8 +324,9 @@ void
gimp_image_set_filename (GimpImage *gimage,
gchar *filename)
{
gchar *new_filename, *old_filename;
gboolean free_old;
gchar *new_filename;
gchar *old_filename;
gboolean free_old;
/*
* WARNING: this function will free the current filename even if you are
......@@ -764,15 +765,20 @@ gimp_image_apply_image (GimpImage *gimage,
* If an alternative to using the drawable's data as src1 was provided...
*/
if (src1_tiles)
pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&src1PR, src1_tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
else
pixel_region_init (&src1PR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR, src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1));
pixel_region_init (&src1PR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
(x2 - x1), (y2 - y1));
if (mask)
{
int mx, my;
gint mx, my;
/* configure the mask pixel region
* don't use x1 and y1 because they are in layer
......
......@@ -251,19 +251,27 @@ nav_window_draw_sqr (NavWinData *iwd,
gdk_gc_set_function (iwd->gc, GDK_INVERT);
if(undraw)
if (undraw)
{
/* first undraw from last co-ords */
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
iwd->dispx, iwd->dispy,
iwd->dispwidth-BORDER_PEN_WIDTH+1,
iwd->dispheight-BORDER_PEN_WIDTH+1);
if (iwd->dispx != 0 || iwd->dispy != 0 ||
iwd->pwidth != iwd->dispwidth || iwd->pheight != iwd->dispheight)
{
/* first undraw from last co-ords */
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
iwd->dispx, iwd->dispy,
iwd->dispwidth - BORDER_PEN_WIDTH + 1,
iwd->dispheight - BORDER_PEN_WIDTH + 1);
}
}
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
x,y,
w-BORDER_PEN_WIDTH+1,
h-BORDER_PEN_WIDTH+1);
if (x != 0 || y != 0 ||
w != iwd->pwidth || h != iwd->pheight)
{
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
x, y,
w - BORDER_PEN_WIDTH + 1,
h - BORDER_PEN_WIDTH + 1);
}
iwd->dispx = x;
iwd->dispy = y;
......@@ -299,7 +307,7 @@ set_size_data (NavWinData *iwd)
sel_width = gimage->width;
sel_height = gimage->height;
if(!gdisp->dot_for_dot)
if (!gdisp->dot_for_dot)
sel_width =
(sel_width * gdisp->gimage->yresolution) / gdisp->gimage->xresolution;
......@@ -307,21 +315,18 @@ set_size_data (NavWinData *iwd)
{
pwidth = iwd->nav_preview_width;
/* pheight = sel_height * pwidth / sel_width; */
iwd->ratio = (gdouble) pwidth / ((gdouble) sel_width);
pheight = sel_height * iwd->ratio + 0.5;
iwd->ratio = (gdouble) pheight / (gdouble) sel_height;
pwidth = sel_width * iwd->ratio + 0.5;
iwd->ratio = MIN (1.0, (gdouble) pwidth / (gdouble) sel_width);
}
else
{
pheight = iwd->nav_preview_height;
/* pwidth = sel_width * pheight / sel_height; */
iwd->ratio = (gdouble) pheight / ((gdouble) sel_height);
pwidth = sel_width * iwd->ratio + 0.5;
iwd->ratio = (gdouble) pwidth / (gdouble) sel_width;
pheight = sel_height * iwd->ratio + 0.5;
iwd->ratio = MIN (1.0, (gdouble) pheight / (gdouble) sel_height);
}
pwidth = sel_width * iwd->ratio + 0.5;
pheight = sel_height * iwd->ratio + 0.5;
iwd->pwidth = pwidth;
iwd->pheight = pheight;
}
......@@ -616,7 +621,7 @@ nav_window_update_preview_blank (NavWinData *iwd)
}
gtk_preview_draw_row (GTK_PREVIEW (iwd->preview),
(guchar *)buf,
(guchar *) buf,
0, y, iwd->pwidth);
}
......
......@@ -251,19 +251,27 @@ nav_window_draw_sqr (NavWinData *iwd,
gdk_gc_set_function (iwd->gc, GDK_INVERT);
if(undraw)
if (undraw)
{
/* first undraw from last co-ords */
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
iwd->dispx, iwd->dispy,
iwd->dispwidth-BORDER_PEN_WIDTH+1,
iwd->dispheight-BORDER_PEN_WIDTH+1);
if (iwd->dispx != 0 || iwd->dispy != 0 ||
iwd->pwidth != iwd->dispwidth || iwd->pheight != iwd->dispheight)
{
/* first undraw from last co-ords */
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
iwd->dispx, iwd->dispy,
iwd->dispwidth - BORDER_PEN_WIDTH + 1,
iwd->dispheight - BORDER_PEN_WIDTH + 1);
}
}
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
x,y,
w-BORDER_PEN_WIDTH+1,
h-BORDER_PEN_WIDTH+1);
if (x != 0 || y != 0 ||
w != iwd->pwidth || h != iwd->pheight)
{
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
x, y,
w - BORDER_PEN_WIDTH + 1,
h - BORDER_PEN_WIDTH + 1);
}
iwd->dispx = x;
iwd->dispy = y;
......@@ -299,7 +307,7 @@ set_size_data (NavWinData *iwd)
sel_width = gimage->width;
sel_height = gimage->height;
if(!gdisp->dot_for_dot)
if (!gdisp->dot_for_dot)
sel_width =
(sel_width * gdisp->gimage->yresolution) / gdisp->gimage->xresolution;
......@@ -307,21 +315,18 @@ set_size_data (NavWinData *iwd)
{
pwidth = iwd->nav_preview_width;
/* pheight = sel_height * pwidth / sel_width; */
iwd->ratio = (gdouble) pwidth / ((gdouble) sel_width);
pheight = sel_height * iwd->ratio + 0.5;
iwd->ratio = (gdouble) pheight / (gdouble) sel_height;
pwidth = sel_width * iwd->ratio + 0.5;
iwd->ratio = MIN (1.0, (gdouble) pwidth / (gdouble) sel_width);
}
else
{
pheight = iwd->nav_preview_height;
/* pwidth = sel_width * pheight / sel_height; */
iwd->ratio = (gdouble) pheight / ((gdouble) sel_height);
pwidth = sel_width * iwd->ratio + 0.5;
iwd->ratio = (gdouble) pwidth / (gdouble) sel_width;
pheight = sel_height * iwd->ratio + 0.5;
iwd->ratio = MIN (1.0, (gdouble) pheight / (gdouble) sel_height);
}
pwidth = sel_width * iwd->ratio + 0.5;
pheight = sel_height * iwd->ratio + 0.5;
iwd->pwidth = pwidth;
iwd->pheight = pheight;
}
......@@ -616,7 +621,7 @@ nav_window_update_preview_blank (NavWinData *iwd)
}
gtk_preview_draw_row (GTK_PREVIEW (iwd->preview),
(guchar *)buf,
(guchar *) buf,
0, y, iwd->pwidth);
}
......
......@@ -324,8 +324,9 @@ void
gimp_image_set_filename (GimpImage *gimage,
gchar *filename)
{
gchar *new_filename, *old_filename;
gboolean free_old;
gchar *new_filename;
gchar *old_filename;
gboolean free_old;
/*
* WARNING: this function will free the current filename even if you are
......@@ -764,15 +765,20 @@ gimp_image_apply_image (GimpImage *gimage,
* If an alternative to using the drawable's data as src1 was provided...
*/
if (src1_tiles)
pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&src1PR, src1_tiles,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
else
pixel_region_init (&src1PR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR, src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1));
pixel_region_init (&src1PR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_resize (src2PR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
(x2 - x1), (y2 - y1));
if (mask)
{
int mx, my;
gint mx, my;
/* configure the mask pixel region
* don't use x1 and y1 because they are in layer
......
......@@ -987,9 +987,11 @@ layers_dialog_preview_extents (void)
/* Get the image width and height variables, based on the gimage */
if (gimage->width > gimage->height)
layersD->ratio = (gdouble) preview_size / (gdouble) gimage->width;
layersD->ratio =
MIN (1.0, (gdouble) preview_size / (gdouble) gimage->width);
else
layersD->ratio = (gdouble) preview_size / (gdouble) gimage->height;
layersD->ratio =
MIN (1.0, (gdouble) preview_size / (gdouble) gimage->height);
if (preview_size)
{
......
......@@ -987,9 +987,11 @@ layers_dialog_preview_extents (void)
/* Get the image width and height variables, based on the gimage */
if (gimage->width > gimage->height)
layersD->ratio = (gdouble) preview_size / (gdouble) gimage->width;
layersD->ratio =
MIN (1.0, (gdouble) preview_size / (gdouble) gimage->width);
else
layersD->ratio = (gdouble) preview_size / (gdouble) gimage->height;
layersD->ratio =
MIN (1.0, (gdouble) preview_size / (gdouble) gimage->height);
if (preview_size)
{
......
......@@ -438,6 +438,7 @@ lc_dialog_fill_preview_with_thumb (GtkWidget *widget,
gdouble r, g, b, a;
gdouble c0, c1;
guchar *p0, *p1, *even, *odd;
gdouble ratio;
bpp = 0; /* Only returned */
......@@ -447,15 +448,19 @@ lc_dialog_fill_preview_with_thumb (GtkWidget *widget,
/* Get right aspect ratio */
if (dwidth > dheight)
{
height = RINT (((gdouble)width * (gdouble)dheight) / (gdouble)dwidth);
width = RINT (((gdouble)dwidth * (gdouble)height) / (gdouble)dheight);
ratio = MIN (1.0, (gdouble) width / (gdouble) dwidth);
}
else
{
width = RINT (((gdouble)height * (gdouble)dwidth) / (gdouble)dheight);
height = RINT (((gdouble)dheight * (gdouble)width) / (gdouble)dwidth);
ratio = MIN (1.0, (gdouble) height / (gdouble) dheight);
}
width = RINT (ratio * (gdouble) dwidth);
height = RINT (ratio * (gdouble) dheight);
if (width < 1) width = 1;
if (height < 1) height = 1;
buf = gimp_image_construct_composite_preview (gimage, width, height);
drawable_data = temp_buf_data (buf);
bpp = buf->bytes;
......
......@@ -251,19 +251,27 @@ nav_window_draw_sqr (NavWinData *iwd,
gdk_gc_set_function (iwd->gc, GDK_INVERT);
if(undraw)
if (undraw)
{
/* first undraw from last co-ords */
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
iwd->dispx, iwd->dispy,
iwd->dispwidth-BORDER_PEN_WIDTH+1,
iwd->dispheight-BORDER_PEN_WIDTH+1);
if (iwd->dispx != 0 || iwd->dispy != 0 ||
iwd->pwidth != iwd->dispwidth || iwd->pheight != iwd->dispheight)
{
/* first undraw from last co-ords */
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
iwd->dispx, iwd->dispy,
iwd->dispwidth - BORDER_PEN_WIDTH + 1,
iwd->dispheight - BORDER_PEN_WIDTH + 1);
}
}
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
x,y,
w-BORDER_PEN_WIDTH+1,
h-BORDER_PEN_WIDTH+1);
if (x != 0 || y != 0 ||
w != iwd->pwidth || h != iwd->pheight)
{
gdk_draw_rectangle (iwd->preview->window, iwd->gc, FALSE,
x, y,
w - BORDER_PEN_WIDTH + 1,
h - BORDER_PEN_WIDTH + 1);
}
iwd->dispx = x;
iwd->dispy = y;
......@@ -299,7 +307,7 @@ set_size_data (NavWinData *iwd)
sel_width = gimage->width;