mirror of https://github.com/GNOME/gimp.git
Made the preview respect the aspect ratio and resolutions of the image.
2003-09-29 Simon Budig <simon@gimp.org> * app/widgets/gimppreviewrenderervectors.c: Made the preview respect the aspect ratio and resolutions of the image. There apparently still is an off-by-one error in it. * app/tools/gimpvectortool.c: (Hopefully) fixed a crash when a new image gets opened with the vectors tool active.
This commit is contained in:
parent
6f0619705d
commit
02f375b8d4
|
@ -1,3 +1,12 @@
|
|||
2003-09-29 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/widgets/gimppreviewrenderervectors.c: Made the preview
|
||||
respect the aspect ratio and resolutions of the image. There
|
||||
apparently still is an off-by-one error in it.
|
||||
|
||||
* app/tools/gimpvectortool.c: (Hopefully) fixed a crash when a new
|
||||
image gets opened with the vectors tool active.
|
||||
|
||||
2003-09-29 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimppreviewrenderer.[ch]: made draw a virtual method
|
||||
|
|
|
@ -1165,6 +1165,7 @@ gimp_vector_tool_status_set (GimpTool *tool,
|
|||
GimpDisplay *orig_gdisp;
|
||||
|
||||
if (vector_tool->status_gdisp != gdisp ||
|
||||
(! vector_tool->status_msg && message) ||
|
||||
strcmp (vector_tool->status_msg, message) != 0)
|
||||
{
|
||||
orig_gdisp = tool->gdisp;
|
||||
|
@ -1174,7 +1175,8 @@ gimp_vector_tool_status_set (GimpTool *tool,
|
|||
tool->gdisp = vector_tool->status_gdisp;
|
||||
gimp_tool_pop_status (tool);
|
||||
vector_tool->status_gdisp = NULL;
|
||||
g_free (vector_tool->status_msg);
|
||||
if (vector_tool->status_msg)
|
||||
g_free (vector_tool->status_msg);
|
||||
vector_tool->status_msg = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,11 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "vectors/gimpvectors.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpitem.h"
|
||||
|
||||
#include "vectors/gimpstroke.h"
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "gimppreviewrenderervectors.h"
|
||||
|
||||
|
@ -94,48 +97,102 @@ gimp_preview_renderer_vectors_draw (GimpPreviewRenderer *renderer,
|
|||
const GdkRectangle *expose_area)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
GimpItem *item;
|
||||
GimpStroke *stroke;
|
||||
GdkRectangle rect;
|
||||
GimpImage *gimage;
|
||||
GdkRectangle previewarea;
|
||||
GdkRectangle rect, rect2;
|
||||
GArray *coordinates;
|
||||
GdkPoint *points;
|
||||
gboolean closed;
|
||||
gint i;
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
gboolean scaling_up;
|
||||
gdouble xscale, yscale;
|
||||
|
||||
if (! gdk_rectangle_intersect ((GdkRectangle *) draw_area,
|
||||
(GdkRectangle *) expose_area, &rect))
|
||||
(GdkRectangle *) expose_area, &rect2))
|
||||
return;
|
||||
|
||||
vectors = GIMP_VECTORS (renderer->viewable);
|
||||
item = GIMP_ITEM (vectors);
|
||||
gimage = gimp_item_get_image (item);
|
||||
|
||||
width = renderer->width;
|
||||
height = renderer->height;
|
||||
|
||||
if (gimage && ! renderer->is_popup)
|
||||
{
|
||||
width = MAX (1, ROUND (((gdouble) width / (gdouble) gimage->width) *
|
||||
(gdouble) item->width));
|
||||
height = MAX (1, ROUND (((gdouble) height / (gdouble) gimage->height) *
|
||||
(gdouble) item->height));
|
||||
|
||||
gimp_viewable_calc_preview_size (renderer->viewable,
|
||||
item->width,
|
||||
item->height,
|
||||
width,
|
||||
height,
|
||||
renderer->dot_for_dot,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&(previewarea.width),
|
||||
&(previewarea.height),
|
||||
&scaling_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_viewable_calc_preview_size (renderer->viewable,
|
||||
item->width,
|
||||
item->height,
|
||||
width,
|
||||
height,
|
||||
renderer->dot_for_dot,
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&(previewarea.width),
|
||||
&(previewarea.height),
|
||||
&scaling_up);
|
||||
}
|
||||
|
||||
|
||||
previewarea.width = previewarea.width;
|
||||
previewarea.height = previewarea.height;
|
||||
previewarea.x = (renderer->width - previewarea.width ) / 2
|
||||
+ draw_area->x + renderer->border_width;
|
||||
previewarea.y = (renderer->height - previewarea.height) / 2
|
||||
+ draw_area->y + renderer->border_width;
|
||||
|
||||
if (! gdk_rectangle_intersect (&rect2, &previewarea, &rect))
|
||||
return;
|
||||
|
||||
gdk_draw_rectangle (window, widget->style->white_gc, TRUE,
|
||||
rect.x, rect.y, rect.width, rect.height);
|
||||
|
||||
vectors = GIMP_VECTORS (renderer->viewable);
|
||||
|
||||
xscale = (gdouble) GIMP_ITEM (vectors)->width / (gdouble) renderer->width;
|
||||
yscale = (gdouble) GIMP_ITEM (vectors)->height / (gdouble) renderer->height;
|
||||
xscale = (gdouble) item->width / (gdouble) previewarea.width;
|
||||
yscale = (gdouble) item->height / (gdouble) previewarea.height;
|
||||
|
||||
gdk_gc_set_clip_rectangle (widget->style->black_gc, &rect);
|
||||
|
||||
x = draw_area->x + renderer->border_width;
|
||||
y = draw_area->y + renderer->border_width;
|
||||
|
||||
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
|
||||
stroke != NULL;
|
||||
stroke = gimp_vectors_stroke_get_next (vectors, stroke))
|
||||
{
|
||||
coordinates = gimp_stroke_interpolate (stroke,
|
||||
MIN (xscale, yscale), &closed);
|
||||
points = g_new (GdkPoint, coordinates->len);
|
||||
coordinates = gimp_stroke_interpolate (stroke, MIN (xscale, yscale),
|
||||
&closed);
|
||||
points = g_new (GdkPoint, coordinates->len + (closed ? 1 : 0));
|
||||
|
||||
for (i = 0; i < coordinates->len; i++)
|
||||
{
|
||||
GimpCoords *coords = &(g_array_index (coordinates, GimpCoords, i));
|
||||
|
||||
points[i].x = x + ROUND (coords->x / xscale);
|
||||
points[i].y = y + ROUND (coords->y / yscale);
|
||||
points[i].x = previewarea.x + ROUND (coords->x / xscale);
|
||||
points[i].y = previewarea.y + ROUND (coords->y / yscale);
|
||||
}
|
||||
|
||||
if (closed)
|
||||
g_array_append_val (coordinates, points[0]);
|
||||
|
||||
gdk_draw_lines (window, widget->style->black_gc,
|
||||
points, coordinates->len);
|
||||
|
||||
|
|
|
@ -28,8 +28,11 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "vectors/gimpvectors.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpitem.h"
|
||||
|
||||
#include "vectors/gimpstroke.h"
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "gimppreviewrenderervectors.h"
|
||||
|
||||
|
@ -94,48 +97,102 @@ gimp_preview_renderer_vectors_draw (GimpPreviewRenderer *renderer,
|
|||
const GdkRectangle *expose_area)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
GimpItem *item;
|
||||
GimpStroke *stroke;
|
||||
GdkRectangle rect;
|
||||
GimpImage *gimage;
|
||||
GdkRectangle previewarea;
|
||||
GdkRectangle rect, rect2;
|
||||
GArray *coordinates;
|
||||
GdkPoint *points;
|
||||
gboolean closed;
|
||||
gint i;
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
gboolean scaling_up;
|
||||
gdouble xscale, yscale;
|
||||
|
||||
if (! gdk_rectangle_intersect ((GdkRectangle *) draw_area,
|
||||
(GdkRectangle *) expose_area, &rect))
|
||||
(GdkRectangle *) expose_area, &rect2))
|
||||
return;
|
||||
|
||||
vectors = GIMP_VECTORS (renderer->viewable);
|
||||
item = GIMP_ITEM (vectors);
|
||||
gimage = gimp_item_get_image (item);
|
||||
|
||||
width = renderer->width;
|
||||
height = renderer->height;
|
||||
|
||||
if (gimage && ! renderer->is_popup)
|
||||
{
|
||||
width = MAX (1, ROUND (((gdouble) width / (gdouble) gimage->width) *
|
||||
(gdouble) item->width));
|
||||
height = MAX (1, ROUND (((gdouble) height / (gdouble) gimage->height) *
|
||||
(gdouble) item->height));
|
||||
|
||||
gimp_viewable_calc_preview_size (renderer->viewable,
|
||||
item->width,
|
||||
item->height,
|
||||
width,
|
||||
height,
|
||||
renderer->dot_for_dot,
|
||||
gimage->xresolution,
|
||||
gimage->yresolution,
|
||||
&(previewarea.width),
|
||||
&(previewarea.height),
|
||||
&scaling_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_viewable_calc_preview_size (renderer->viewable,
|
||||
item->width,
|
||||
item->height,
|
||||
width,
|
||||
height,
|
||||
renderer->dot_for_dot,
|
||||
gimage ? gimage->xresolution : 1.0,
|
||||
gimage ? gimage->yresolution : 1.0,
|
||||
&(previewarea.width),
|
||||
&(previewarea.height),
|
||||
&scaling_up);
|
||||
}
|
||||
|
||||
|
||||
previewarea.width = previewarea.width;
|
||||
previewarea.height = previewarea.height;
|
||||
previewarea.x = (renderer->width - previewarea.width ) / 2
|
||||
+ draw_area->x + renderer->border_width;
|
||||
previewarea.y = (renderer->height - previewarea.height) / 2
|
||||
+ draw_area->y + renderer->border_width;
|
||||
|
||||
if (! gdk_rectangle_intersect (&rect2, &previewarea, &rect))
|
||||
return;
|
||||
|
||||
gdk_draw_rectangle (window, widget->style->white_gc, TRUE,
|
||||
rect.x, rect.y, rect.width, rect.height);
|
||||
|
||||
vectors = GIMP_VECTORS (renderer->viewable);
|
||||
|
||||
xscale = (gdouble) GIMP_ITEM (vectors)->width / (gdouble) renderer->width;
|
||||
yscale = (gdouble) GIMP_ITEM (vectors)->height / (gdouble) renderer->height;
|
||||
xscale = (gdouble) item->width / (gdouble) previewarea.width;
|
||||
yscale = (gdouble) item->height / (gdouble) previewarea.height;
|
||||
|
||||
gdk_gc_set_clip_rectangle (widget->style->black_gc, &rect);
|
||||
|
||||
x = draw_area->x + renderer->border_width;
|
||||
y = draw_area->y + renderer->border_width;
|
||||
|
||||
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
|
||||
stroke != NULL;
|
||||
stroke = gimp_vectors_stroke_get_next (vectors, stroke))
|
||||
{
|
||||
coordinates = gimp_stroke_interpolate (stroke,
|
||||
MIN (xscale, yscale), &closed);
|
||||
points = g_new (GdkPoint, coordinates->len);
|
||||
coordinates = gimp_stroke_interpolate (stroke, MIN (xscale, yscale),
|
||||
&closed);
|
||||
points = g_new (GdkPoint, coordinates->len + (closed ? 1 : 0));
|
||||
|
||||
for (i = 0; i < coordinates->len; i++)
|
||||
{
|
||||
GimpCoords *coords = &(g_array_index (coordinates, GimpCoords, i));
|
||||
|
||||
points[i].x = x + ROUND (coords->x / xscale);
|
||||
points[i].y = y + ROUND (coords->y / yscale);
|
||||
points[i].x = previewarea.x + ROUND (coords->x / xscale);
|
||||
points[i].y = previewarea.y + ROUND (coords->y / yscale);
|
||||
}
|
||||
|
||||
if (closed)
|
||||
g_array_append_val (coordinates, points[0]);
|
||||
|
||||
gdk_draw_lines (window, widget->style->black_gc,
|
||||
points, coordinates->len);
|
||||
|
||||
|
|
Loading…
Reference in New Issue