}
#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,
#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
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);