From 9bea88f6c7423598158c0f84491fadf64056239f Mon Sep 17 00:00:00 2001 From: ellson Date: Tue, 13 Jun 2006 22:31:14 +0000 Subject: [PATCH] - update job->width, job->height to include margins. - use job->width, job->height for initial canvas size. --- lib/common/emit.c | 4 ++++ plugin/gd/gvrender_gd.c | 13 ++++--------- plugin/pango/gvrender_pango.c | 13 ++++--------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index a9e12e273..76178b6b3 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -423,6 +423,10 @@ static void setup_page(GVJ_t * job, graph_t * g) else EXPANDBB(job->boundingBox, job->pageBoundingBox); + /* update job->width and job->height with margins */ + job->width = job->boundingBox.UR.x + job->boundingBox.LL.x; + job->height = job->boundingBox.UR.y + job->boundingBox.LL.y; + if (job->rotation) { if (job->flags & GVRENDER_Y_GOES_DOWN) { job->translation.x = -job->pageBox.UR.x - job->pageBoundingBox.LL.y / job->scale.y; diff --git a/plugin/gd/gvrender_gd.c b/plugin/gd/gvrender_gd.c index f480d954f..bde97ee4a 100644 --- a/plugin/gd/gvrender_gd.c +++ b/plugin/gd/gvrender_gd.c @@ -107,7 +107,6 @@ static void gdgen_begin_page(GVJ_t * job) bool bg_transparent_p = FALSE; int bgcolor = 0; gdImagePtr im = NULL; - int width, height; /* FIXME - ... */ @@ -131,23 +130,19 @@ static void gdgen_begin_page(GVJ_t * job) fprintf(stderr, "%s: using existing GD image\n", job->common->cmdname); im = (gdImagePtr) (job->output_file); } else { - /* device size with margins all around */ - width = job->pageBoundingBox.UR.x + job->pageBoundingBox.LL.x; - height = job->pageBoundingBox.UR.y + job->pageBoundingBox.LL.y; - if (truecolor_p) { if (job->common->verbose) fprintf(stderr, "%s: allocating a %dK TrueColor GD image\n", job->common->cmdname, - ROUND(width * height * 4 / 1024.)); - im = gdImageCreateTrueColor(width, height); + ROUND(job->width * job->height * 4 / 1024.)); + im = gdImageCreateTrueColor(job->width, job->height); } else { if (job->common->verbose) fprintf(stderr, "%s: allocating a %dK PaletteColor GD image\n", - job->common->cmdname, ROUND(width * height / 1024.)); - im = gdImageCreate(width, height); + job->common->cmdname, ROUND(job->width * job->height / 1024.)); + im = gdImageCreate(job->width, job->height); } } job->surface = (void *) im; diff --git a/plugin/pango/gvrender_pango.c b/plugin/pango/gvrender_pango.c index eb1bf74b6..831995163 100644 --- a/plugin/pango/gvrender_pango.c +++ b/plugin/pango/gvrender_pango.c @@ -128,7 +128,6 @@ static void cairogen_begin_page(GVJ_t * job) { cairo_t *cr; cairo_surface_t *surface; - double width, height; #if defined(HAVE_FENV_H) && defined(HAVE_FESETENV) && defined(HAVE_FEGETENV) && defined(HAVE_FEDISABLEEXCEPT) /* cairo generates FE_INVALID and other exceptions we @@ -141,16 +140,12 @@ static void cairogen_begin_page(GVJ_t * job) cr = (cairo_t *) job->surface; /* might be NULL */ - /* device size with margins all around */ - width = job->pageBoundingBox.UR.x + job->pageBoundingBox.LL.x; - height = job->pageBoundingBox.UR.y + job->pageBoundingBox.LL.y; - switch (job->render.id) { #ifdef CAIRO_HAS_PNG_FUNCTIONS case FORMAT_PNG: if (!cr) { surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, - width, height); + (double)(job->width), (double)(job->height)); cr = cairo_create(surface); cairo_surface_destroy (surface); } @@ -160,7 +155,7 @@ static void cairogen_begin_page(GVJ_t * job) case FORMAT_PS: if (!cr) { surface = cairo_ps_surface_create_for_stream (writer, - job->output_file, width, height); + job->output_file, (double)(job->width), (double)(job->height)); cr = cairo_create(surface); cairo_surface_destroy (surface); } @@ -170,7 +165,7 @@ static void cairogen_begin_page(GVJ_t * job) case FORMAT_PDF: if (!cr) { surface = cairo_pdf_surface_create_for_stream (writer, - job->output_file, width, height); + job->output_file, (double)(job->width), (double)(job->height)); cr = cairo_create(surface); cairo_surface_destroy (surface); } @@ -180,7 +175,7 @@ static void cairogen_begin_page(GVJ_t * job) case FORMAT_SVG: if (!cr) { surface = cairo_svg_surface_create_for_stream (writer, - job->output_file, width, height); + job->output_file, (double)(job->width), (double)(job->height)); cr = cairo_create(surface); cairo_surface_destroy (surface); } -- 2.40.0