[gimp/gimp-2-8] Bug 725577 - file-pdf-save fails to export images larger than 32768 pixels
- From: Hartmut Kuhse <hartmutkuhse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] Bug 725577 - file-pdf-save fails to export images larger than 32768 pixels
- Date: Tue, 29 Apr 2014 15:49:28 +0000 (UTC)
commit d03203973e9898b6fc158cb7316f3e80ee0d499a
Author: Hartmut Kuhse <hk_priv gmx de>
Date: Tue Apr 29 17:46:05 2014 +0200
Bug 725577 - file-pdf-save fails to export images larger than 32768 pixels
Due to a restriction in libcairo, creating surfaces larger than 32768 pixels
fails, so saving a larger file in gimp as PDF, is rejected.
related to commit: f6328244a2932f292454beba70ffddd2bcacbeae
plug-ins/common/file-pdf-save.c | 116 ++++++++++++++++++++++++++++++---------
1 files changed, 90 insertions(+), 26 deletions(-)
---
diff --git a/plug-ins/common/file-pdf-save.c b/plug-ins/common/file-pdf-save.c
index ff579ce..5207557 100644
--- a/plug-ins/common/file-pdf-save.c
+++ b/plug-ins/common/file-pdf-save.c
@@ -157,43 +157,51 @@ typedef struct {
} Page;
-static gboolean init_vals (const gchar *name,
- gint nparams,
+static gboolean init_vals (const gchar *name,
+ gint nparams,
const GimpParam *param,
- gboolean *single,
- gboolean *defaults,
- GimpRunMode *run_mode);
+ gboolean *single,
+ gboolean *defaults,
+ GimpRunMode *run_mode);
-static void init_image_list_defaults (gint32 image);
+static void init_image_list_defaults (gint32 image);
static void validate_image_list (void);
static gboolean gui_single (void);
+
static gboolean gui_multi (void);
-static void choose_file_call (GtkWidget* browse_button,
- gpointer file_entry);
+static void choose_file_call (GtkWidget *browse_button,
+ gpointer file_entry);
static gboolean get_image_list (void);
+
static GtkTreeModel* create_model (void);
-static void add_image_call (GtkWidget *widget,
- gpointer img_combo);
-static void del_image_call (GtkWidget *widget,
- gpointer icon_view);
-static void remove_call (GtkTreeModel *tree_model,
- GtkTreePath *path,
- gpointer user_data);
+static void add_image_call (GtkWidget *widget,
+ gpointer img_combo);
+
+static void del_image_call (GtkWidget *widget,
+ gpointer icon_view);
+
+static void remove_call (GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ gpointer user_data);
+
static void recount_pages (void);
-static cairo_surface_t *get_drawable_image (GimpDrawable *drawable);
-static GimpRGB get_layer_color (GimpDrawable *layer,
- gboolean *single);
-static void drawText (GimpDrawable* text_layer,
- gdouble opacity,
- cairo_t *cr,
- gdouble x_res,
- gdouble y_res);
+static cairo_surface_t *get_drawable_image (GimpDrawable *drawable,
+ GError **error);
+
+static GimpRGB get_layer_color (GimpDrawable *layer,
+ gboolean *single);
+
+static void drawText (GimpDrawable *text_layer,
+ gdouble opacity,
+ cairo_t *cr,
+ gdouble x_res,
+ gdouble y_res);
static void query (void);
static void run (const gchar *name,
@@ -369,6 +377,7 @@ run (const gchar *name,
GimpDrawable *mask = NULL;
cairo_surface_t *mask_image = NULL;
FILE *fp;
+ GError *error = NULL;
INIT_I18N ();
@@ -495,7 +504,22 @@ run (const gchar *name,
if (mask_id != -1)
{
mask = gimp_drawable_get (mask_id);
- mask_image = get_drawable_image (mask);
+ mask_image = get_drawable_image (mask, &error);
+ if (error != NULL)
+ {
+ *nreturn_vals = 2;
+
+ /* free the resources */
+ cairo_surface_destroy (pdf_file);
+ cairo_destroy (cr);
+ fclose (fp);
+
+ values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
+
+ values[1].type = GIMP_PDB_STRING;
+ values[1].data.d_string = error->message;
+ return;
+ }
}
gimp_drawable_offsets (layer->drawable_id, &x, &y);
@@ -517,7 +541,22 @@ run (const gchar *name,
else
{
cairo_clip (cr);
- layer_image = get_drawable_image (layer);
+ layer_image = get_drawable_image (layer, &error);
+ if (error != NULL)
+ {
+ *nreturn_vals = 2;
+
+ /* free the resources */
+ cairo_surface_destroy (pdf_file);
+ cairo_destroy (cr);
+ fclose (fp);
+
+ values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
+
+ values[1].type = GIMP_PDB_STRING;
+ values[1].data.d_string = error->message;
+ return;
+ }
cairo_set_source_surface (cr, layer_image, x, y);
cairo_push_group (cr);
cairo_paint_with_alpha (cr, opacity);
@@ -1224,12 +1263,14 @@ convert_from_indexeda_to_rgba (const guchar *src,
}
static cairo_surface_t *
-get_drawable_image (GimpDrawable *drawable)
+get_drawable_image (GimpDrawable *drawable,
+ GError **error)
{
gint32 drawable_ID = drawable->drawable_id;
GimpPixelRgn region;
GimpImageType image_type = gimp_drawable_type (drawable_ID);
cairo_surface_t *surface;
+ cairo_status_t status;
cairo_format_t format;
const gint width = drawable->width;
const gint height = drawable->height;
@@ -1280,6 +1321,29 @@ get_drawable_image (GimpDrawable *drawable)
surface = cairo_image_surface_create (format, width, height);
+ status = cairo_surface_status (surface);
+ if (status != CAIRO_STATUS_SUCCESS)
+ {
+ switch (status)
+ {
+ case CAIRO_STATUS_INVALID_SIZE:
+ g_set_error_literal (error,
+ 1,
+ 0,
+ _("Cannot handle the size (either width or height) of the Image."));
+ break;
+ default:
+ g_set_error (error,
+ 1,
+ 0,
+ "Cairo error: %s",
+ cairo_status_to_string (status));
+ break;
+ }
+
+ return NULL;
+ }
+
pixels = cairo_image_surface_get_data (surface);
stride = cairo_image_surface_get_stride (surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]