[goffice] Don't try to display an image with nul size in the canvas.
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Don't try to display an image with nul size in the canvas.
- Date: Wed, 14 Feb 2018 15:20:36 +0000 (UTC)
commit 08ba6dd9bea422371bc80e4d57f5a8a4dfbca69c
Author: Jean Brefort <jean brefort normalesup org>
Date: Wed Feb 14 16:19:31 2018 +0100
Don't try to display an image with nul size in the canvas.
ChangeLog | 7 +++++++
goffice/canvas/goc-image.c | 16 +++++++++++-----
goffice/utils/go-emf.c | 8 ++++++--
3 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ac1f23d..9586f0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-02-14 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/canvas/goc-image.c (goc_image_draw): don't try to display an image
+ with nul size.
+ * goffice/utils/go-emf.c (go_emf_lineto): create a path if necessary instead
+ of returning an error.
+
2017-12-28 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/goffice/canvas/goc-image.c b/goffice/canvas/goc-image.c
index ce58977..8c0c880 100644
--- a/goffice/canvas/goc-image.c
+++ b/goffice/canvas/goc-image.c
@@ -214,25 +214,31 @@ static void
goc_image_draw (GocItem const *item, cairo_t *cr)
{
GocImage *image = GOC_IMAGE (item);
- double height, width;
+ double height, width, iw, ih;
double scalex = 1., scaley = 1.;
int x;
if (image->image == NULL || image->width == 0. || image->height == 0.)
return;
+ iw = go_image_get_width (image->image);
+ ih = go_image_get_height (image->image);
+ if (iw == 0. || ih == 0.)
+ return;
+
if (image->width < 0.)
- width = go_image_get_width (image->image) * (1 - image->crop_left -image->crop_right);
+ width = iw * (1 - image->crop_left -image->crop_right);
else {
width = image->width;
- scalex = width / go_image_get_width (image->image) / (1 - image->crop_left
-image->crop_right);
+ scalex = width / iw / (1 - image->crop_left -image->crop_right);
}
if (image->height < 0.)
- height = go_image_get_height (image->image) * (1 - image->crop_top -image->crop_bottom);
+ height = ih * (1 - image->crop_top -image->crop_bottom);
else {
height = image->height;
- scaley = height / go_image_get_height (image->image) / (1 - image->crop_top
-image->crop_bottom);
+ scaley = height / ih / (1 - image->crop_top -image->crop_bottom);
}
+
cairo_save (cr);
_goc_item_transform (item, cr, TRUE);
x = (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL)?
diff --git a/goffice/utils/go-emf.c b/goffice/utils/go-emf.c
index 9790466..017c818 100644
--- a/goffice/utils/go-emf.c
+++ b/goffice/utils/go-emf.c
@@ -3818,8 +3818,12 @@ go_emf_lineto (GOEmfState *state)
{
double x, y;
d_(("lineto\n"));
- if (state->curDC->path == NULL)
- return FALSE;
+ if (state->curDC->path == NULL) {
+ state->curDC->path = go_path_new ();
+ go_path_move_to (state->curDC->path,
+ state->curDC->xpos,
+ state->curDC->ypos);
+ }
go_wmf_read_pointl (state->data, &x, &y);
go_emf_convert_coords (state, &x, &y);
go_path_line_to (state->curDC->path, x, y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]