Skip to content

Commit fbdc483

Browse files
committed
Fix PWG ImageBox values (top left is 0,0)
1 parent b2aa6c3 commit fbdc483

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

cups/raster-stream.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ cupsRasterInitHeader(
334334
h->cupsPageSize[0] = 72.0f * media->width / 2540.0f;
335335
h->cupsPageSize[1] = 72.0f * media->length / 2540.0f;
336336

337-
h->ImagingBoundingBox[2] = h->PageSize[0];
338-
h->ImagingBoundingBox[3] = h->PageSize[1];
337+
h->ImagingBoundingBox[0] = 72.0f * media->left / 2540.0f;
338+
h->ImagingBoundingBox[1] = 72.0f * media->bottom / 2540.0f;
339+
h->ImagingBoundingBox[2] = 72.0f * (media->width - media->right) / 2540.0f;
340+
h->ImagingBoundingBox[3] = 72.0f * (media->length - media->top) / 2540.0f;
339341

340342
h->HWResolution[0] = (unsigned)xdpi;
341343
h->HWResolution[1] = (unsigned)ydpi;
@@ -349,8 +351,10 @@ cupsRasterInitHeader(
349351
return (false);
350352
}
351353

352-
h->cupsInteger[CUPS_RASTER_PWG_ImageBoxRight] = h->cupsWidth;
353-
h->cupsInteger[CUPS_RASTER_PWG_ImageBoxBottom] = h->cupsHeight;
354+
h->cupsInteger[CUPS_RASTER_PWG_ImageBoxBottom] = (unsigned)(ydpi * (media->length - media->bottom) / 2540);
355+
h->cupsInteger[CUPS_RASTER_PWG_ImageBoxLeft] = (unsigned)(xdpi * media->left / 2540);
356+
h->cupsInteger[CUPS_RASTER_PWG_ImageBoxRight] = (unsigned)(xdpi * (media->width - media->right) / 2540 - 1);
357+
h->cupsInteger[CUPS_RASTER_PWG_ImageBoxTop] = (unsigned)(ydpi * media->top / 2540 - 1);
354358

355359
// Colorspace and bytes per line...
356360
if (!strcmp(type, "adobe-rgb_8"))

0 commit comments

Comments
 (0)