From 80a10eb9513e1f606227fa6387939b1171182468 Mon Sep 17 00:00:00 2001 From: ellson Date: Fri, 9 Jun 2006 19:22:19 +0000 Subject: [PATCH] fix the assymetries in usershape images --- lib/common/psgen.c | 13 +++++-------- lib/gvc/gvrender.c | 8 ++++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/common/psgen.c b/lib/common/psgen.c index f9381d4e7..8ace600b7 100644 --- a/lib/common/psgen.c +++ b/lib/common/psgen.c @@ -491,17 +491,17 @@ static void ps_polyline(point * A, int n) } #ifdef HAVE_LIBGD -static void writePSBitmap (gdImagePtr im, point p, point sz) +static void writePSBitmap (gdImagePtr im, boxf b) { int x, y, px; fprintf(Output_file, "gsave\n"); /* this sets the position of the image */ - fprintf(Output_file, "%d %d translate %% lower-left coordinate\n", p.x, p.y); + fprintf(Output_file, "%g %g translate %% lower-left coordinate\n", b.LL.x, b.LL.y); - /* this sets the rendered size, from 'pixels' to points (1/72 inch) */ - fprintf(Output_file,"%d %d scale\n", sz.x, sz.y); + /* this sets the rendered size to fit the box */ + fprintf(Output_file,"%g %g scale\n", b.UR.x - b.LL.x, b.UR.y - b.LL.y); /* xsize ysize bits-per-sample [matrix] */ fprintf(Output_file, "%d %d 8 [%d 0 0 %d 0 %d]\n", im->sx, im->sy, @@ -672,10 +672,7 @@ static void ps_usershape(usershape_t *us, boxf b, point *A, int n, bool filled) #ifdef HAVE_LIBGD if (gd_img) { - point sz; - sz.x = A[0].x - A[2].x; - sz.y = A[0].y - A[2].y; - writePSBitmap (gd_img, A[2], sz); + writePSBitmap (gd_img, b); return; } #endif diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index 5c6ef1487..418cdfd46 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -1029,10 +1029,14 @@ void gvrender_usershape(GVJ_t * job, char *name, pointf * a, int n, bool filled) th = us->h * scaley; } /* if image is smaller than target area then center it */ - if (tw < pw) + if (tw < pw) { b.LL.x += (pw - tw) / 2.0; - if (th < ph) + b.UR.x -= (pw - tw) / 2.0; + } + if (th < ph) { b.LL.y += (ph - th) / 2.0; + b.UR.y -= (ph - th) / 2.0; + } if (gvre && gvre->usershape) gvre->usershape(job, us, b, filled); -- 2.40.0