From c1ab97ec4b1fb087a93cfb62dcad101941510b6f Mon Sep 17 00:00:00 2001 From: David Odin Date: Sun, 3 Oct 2004 16:08:01 +0000 Subject: [PATCH] limit the size of the preview to 512 pixels. This prevents plug-ins using * libgimp/gimpaspectpreview.c: limit the size of the preview to 512 pixels. This prevents plug-ins using gimp_drawable_get_thumbnail_data to crash. --- ChangeLog | 6 ++++++ libgimp/gimpaspectpreview.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 983a811d9d..a42463570a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-10-03 DindinX + + * libgimp/gimpaspectpreview.c: limit the size of the preview to 512 + pixels. This prevents plug-ins using gimp_drawable_get_thumbnail_data + to crash. + 2004-10-03 DindinX * plug-ins/common/emboss.c: ported to GimpAspectPreview and made some diff --git a/libgimp/gimpaspectpreview.c b/libgimp/gimpaspectpreview.c index 67a0e2b7d9..566ea8690b 100644 --- a/libgimp/gimpaspectpreview.c +++ b/libgimp/gimpaspectpreview.c @@ -166,6 +166,7 @@ gimp_aspect_preview_new (GimpDrawable *drawable, { GimpAspectPreview *preview; gint width, height; + gint max_width, max_height; preview = g_object_new (GIMP_TYPE_ASPECT_PREVIEW, NULL); @@ -173,7 +174,18 @@ gimp_aspect_preview_new (GimpDrawable *drawable, width = gimp_drawable_width (drawable->drawable_id); height = gimp_drawable_height (drawable->drawable_id); - gimp_preview_set_bounds (GIMP_PREVIEW (preview), 0, 0, width, height); + if (width > height) + { + max_width = MIN (width, 512); + max_height = (height * max_width) / width; + } + else + { + max_height = MIN (height, 512); + max_width = (width * max_height) / height; + } + gimp_preview_set_bounds (GIMP_PREVIEW (preview), + 0, 0, max_width, max_height); g_object_set (GIMP_PREVIEW (preview)->frame, "ratio", (gdouble) width / (gdouble) height,