Commit a9ce1e93 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

image viewer: do not try to paint surfaces with invalid size

parent 14860321
......@@ -2580,6 +2580,7 @@ gth_image_viewer_paint (GthImageViewer *self,
cairo_filter_t filter)
{
int original_width;
int surface_width;
double zoom_level;
double src_dx;
double src_dy;
......@@ -2588,13 +2589,12 @@ gth_image_viewer_paint (GthImageViewer *self,
double dwidth;
double dheight;
cairo_save (cr);
cairo_rectangle (cr, 0, 0, self->visible_area.width, self->visible_area.height);
cairo_clip (cr);
surface_width = cairo_image_surface_get_width (surface);
if (surface_width <= 0)
return;
gth_image_viewer_get_original_size (self, &original_width, NULL);
zoom_level = self->priv->zoom_level * ((double) original_width / cairo_image_surface_get_width (surface));
zoom_level = self->priv->zoom_level * ((double) original_width / surface_width);
src_dx = (double) src_x / zoom_level;
src_dy = (double) src_y / zoom_level;
dest_dx = (double) dest_x / zoom_level;
......@@ -2602,6 +2602,13 @@ gth_image_viewer_paint (GthImageViewer *self,
dwidth = (double) width / zoom_level;
dheight = (double) height / zoom_level;
if ((dwidth < 1) || (dheight < 1))
return;
cairo_save (cr);
cairo_rectangle (cr, 0, 0, self->visible_area.width, self->visible_area.height);
cairo_clip (cr);
cairo_scale (cr, zoom_level, zoom_level);
cairo_set_source_surface (cr, surface, dest_dx - src_dx, dest_dy - src_dy);
cairo_pattern_set_filter (cairo_get_source (cr), filter);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment