New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoundingBox and PageBoundingBox comments need to be adjusted for orientation and nup #2079

Closed
michaelrsweet opened this Issue Nov 3, 2006 · 6 comments

Comments

Projects
None yet
1 participant
@michaelrsweet
Collaborator

michaelrsweet commented Nov 3, 2006

Version: 1.2-current
CUPS.org User: david.gelphman

When the pstops filter processes input PS data that contains %%BoundingBox and %%PageBoundingBox comments, it needs to adjust the input BBox comments for transformations that the filter applies, such as orientation changes (rotation) or n-up and/or application of borders.

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Nov 4, 2006

CUPS.org User: mike

They should already be updated for N-up and fitplot modes...

Will look into the landscape 1-up path...

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Nov 14, 2006

CUPS.org User: mike

OK, the attached patch should take care of the PageBoundingBox issues for 1-up, non-scaled output.

Let me know if you see any other problems...

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Feb 7, 2007

CUPS.org User: mike

Re-opened since David reported that things are still not right...

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Feb 7, 2007

CUPS.org User: mike

OK, the attached patch seems to produce the right numbers for orientation-requested=4 and 5 (+90 and -90, respectively).

@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Feb 9, 2007

"str2079.patch":

Index: pstops.c

--- pstops.c (revision 6082)
+++ pstops.c (working copy)
@@ -949,7 +949,7 @@
}
else
{

  • printf("%%%%Page: %s %d\n", pageinfo->label, number);
    
  •      printf("%%%%Page: %s %d\n", pageinfo->label, number);
    
    printf("%%%%PageBoundingBox: %d %d %d %d\n",
    pageinfo->bounding_box[0], pageinfo->bounding_box[1],
    pageinfo->bounding_box[2], pageinfo->bounding_box[3]);
    @@ -1263,6 +1263,44 @@
    memcpy(bounding_box, doc->bounding_box,
    sizeof(bounding_box));
    }
  •  else if (doc->number_up == 1 && !doc->fitplot)
    
  •  {
    
  •    int    temp_bbox[4];       /\* Temporary bounding box */
    
  •    switch (Orientation)
    
  • {
  • case 0 : /\* Portrait */
    
  •          break;
    
  • case 1 : /\* Landscape */
    
  •     temp_bbox[0] = PageWidth - bounding_box[3];
    
  •     temp_bbox[1] = bounding_box[0];
    
  •     temp_bbox[2] = PageWidth - bounding_box[1];
    
  •     temp_bbox[3] = bounding_box[2];
    
  •     memcpy(bounding_box, temp_bbox, sizeof(bounding_box));
    
  •          break;
    
  • case 2 : /\* Reverse Portrait */
    
  •     temp_bbox[0] = PageWidth - bounding_box[0];
    
  •     temp_bbox[1] = PageLength - bounding_box[1];
    
  •     temp_bbox[2] = PageWidth - bounding_box[2];
    
  •     temp_bbox[3] = PageLength - bounding_box[3];
    
  •     memcpy(bounding_box, temp_bbox, sizeof(bounding_box));
    
  •          break;
    
  • case 3 : /\* Reverse Landscape */
    
  •     temp_bbox[0] = bounding_box[1];
    
  •     temp_bbox[1] = PageLength - bounding_box[2];
    
  •     temp_bbox[2] = bounding_box[3];
    
  •     temp_bbox[3] = PageLength - bounding_box[0];
    
  •     memcpy(bounding_box, temp_bbox, sizeof(bounding_box));
    
  •          break;
    
  • }
  •  }
    
    }
    #if 0
    else if (!strncmp(line, "%%PageCustomColors:", 19) ||
@michaelrsweet

This comment has been minimized.

Collaborator

michaelrsweet commented Feb 9, 2007

"str2079p2.patch":

Index: pstops.c

--- pstops.c (revision 6244)
+++ pstops.c (working copy)
@@ -3,7 +3,7 @@
*

  • PostScript filter for the Common UNIX Printing System (CUPS).
  • * Copyright 1993-2006 by Easy Software Products.
  • * Copyright 1993-2007 by Easy Software Products.
    *
  • These coded instructions, statements, and computer programs are the
  • property of Easy Software Products and are protected by Federal
    @@ -1280,43 +1280,47 @@
    memcpy(bounding_box, doc->bounding_box,
    sizeof(bounding_box));
    }
  •  else if (doc->number_up == 1 && !doc->fitplot)
    
  •  else if (doc->number_up == 1 && !doc->fitplot  && Orientation)
    
    {
    int temp_bbox[4]; /* Temporary bounding box */
  •    memcpy(temp_bbox, bounding_box, sizeof(temp_bbox));
    
  •    fprintf(stderr, "DEBUG: Orientation = %d\n", Orientation);
    
  •    fprintf(stderr, "DEBUG: original bounding_box = [ %d %d %d %d ]\n",
    
  •   bounding_box[0], bounding_box[1],
    
  •   bounding_box[2], bounding_box[3]);
    
  •    fprintf(stderr, "DEBUG: PageWidth = %.1f, PageLength = %.1f\n",
    
  •       PageWidth, PageLength);
    
    • switch (Orientation)
      {
  • case 0 : /\* Portrait */
    

- break;

  case 1 : /* Landscape */
  •     temp_bbox[0] = PageWidth - bounding_box[3];
    
  •     temp_bbox[1] = bounding_box[0];
    
  •     temp_bbox[2] = PageWidth - bounding_box[1];
    

- temp_bbox[3] = bounding_box[2];

  •     memcpy(bounding_box, temp_bbox, sizeof(bounding_box));
    
  •     bounding_box[0] = PageLength - temp_bbox[3];
    
  •     bounding_box[1] = temp_bbox[0];
    
  •     bounding_box[2] = PageLength - temp_bbox[1];
    
  •     bounding_box[3] = temp_bbox[2];
           break;
    

    case 2 : /* Reverse Portrait */

  •     temp_bbox[0] = PageWidth - bounding_box[0];
    
  •     temp_bbox[1] = PageLength - bounding_box[1];
    
  •     temp_bbox[2] = PageWidth - bounding_box[2];
    

- temp_bbox[3] = PageLength - bounding_box[3];

  •     memcpy(bounding_box, temp_bbox, sizeof(bounding_box));
    
  •     bounding_box[0] = PageWidth - temp_bbox[2];
    
  •     bounding_box[1] = PageLength - temp_bbox[3];
    
  •     bounding_box[2] = PageWidth - temp_bbox[0];
    
  •     bounding_box[3] = PageLength - temp_bbox[1];
           break;
    

    case 3 : /* Reverse Landscape */

  •     temp_bbox[0] = bounding_box[1];
    
  •     temp_bbox[1] = PageLength - bounding_box[2];
    
  •     temp_bbox[2] = bounding_box[3];
    

- temp_bbox[3] = PageLength - bounding_box[0];

  •     memcpy(bounding_box, temp_bbox, sizeof(bounding_box));
    
  •     bounding_box[0] = temp_bbox[1];
    
  •     bounding_box[1] = PageWidth - temp_bbox[2];
    
  •     bounding_box[2] = temp_bbox[3];
    
  •     bounding_box[3] = PageWidth - temp_bbox[0];
           break;
    
    }
    +
  •    fprintf(stderr, "DEBUG: updated bounding_box = [ %d %d %d %d ]\n",
    
  •   bounding_box[0], bounding_box[1],
    
  •   bounding_box[2], bounding_box[3]);
    
    }
    }
    #if 0

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment