+
+ mediaBox = getMediaBox();
+ cropBox = getCropBox();
+ if (sliceW >= 0 && sliceH >= 0) {
+ baseBox = useMediaBox ? mediaBox : cropBox;
+ kx = 72.0 / hDPI;
+ ky = 72.0 / vDPI;
+ if (rotate == 90) {
+ if (out->upsideDown()) {
+ box.x1 = baseBox->x1 + ky * sliceY;
+ box.x2 = baseBox->x1 + ky * (sliceY + sliceH);
+ } else {
+ box.x1 = baseBox->x2 - ky * (sliceY + sliceH);
+ box.x2 = baseBox->x2 - ky * sliceY;
+ }
+ box.y1 = baseBox->y1 + kx * sliceX;
+ box.y2 = baseBox->y1 + kx * (sliceX + sliceW);
+ } else if (rotate == 180) {
+ box.x1 = baseBox->x2 - kx * (sliceX + sliceW);
+ box.x2 = baseBox->x2 - kx * sliceX;
+ if (out->upsideDown()) {
+ box.y1 = baseBox->y1 + ky * sliceY;
+ box.y2 = baseBox->y1 + ky * (sliceY + sliceH);
+ } else {
+ box.y1 = baseBox->y2 - ky * (sliceY + sliceH);
+ box.y2 = baseBox->y2 - ky * sliceY;
+ }
+ } else if (rotate == 270) {
+ if (out->upsideDown()) {
+ box.x1 = baseBox->x2 - ky * (sliceY + sliceH);
+ box.x2 = baseBox->x2 - ky * sliceY;
+ } else {
+ box.x1 = baseBox->x1 + ky * sliceY;
+ box.x2 = baseBox->x1 + ky * (sliceY + sliceH);
+ }
+ box.y1 = baseBox->y2 - kx * (sliceX + sliceW);
+ box.y2 = baseBox->y2 - kx * sliceX;
+ } else {
+ box.x1 = baseBox->x1 + kx * sliceX;
+ box.x2 = baseBox->x1 + kx * (sliceX + sliceW);
+ if (out->upsideDown()) {
+ box.y1 = baseBox->y2 - ky * (sliceY + sliceH);
+ box.y2 = baseBox->y2 - ky * sliceY;
+ } else {
+ box.y1 = baseBox->y1 + ky * sliceY;
+ box.y2 = baseBox->y1 + ky * (sliceY + sliceH);
+ }
+ }
+ } else if (useMediaBox) {
+ box = *mediaBox;
+ } else {
+ box = *cropBox;
+ crop = gFalse;
+ }
+
+ if (globalParams->getPrintCommands()) {
+ printf("***** MediaBox = ll:%g,%g ur:%g,%g\n",
+ mediaBox->x1, mediaBox->y1, mediaBox->x2, mediaBox->y2);
+ printf("***** CropBox = ll:%g,%g ur:%g,%g\n",
+ cropBox->x1, cropBox->y1, cropBox->x2, cropBox->y2);
+ printf("***** Rotate = %d\n", attrs->getRotate());
+ }
+
+ gfx = new Gfx(xref, out, num, attrs->getResourceDict(),
+ hDPI, vDPI, &box, crop ? cropBox : (PDFRectangle *)NULL,
+ rotate, abortCheckCbk, abortCheckCbkData);
+ contents.fetch(xref, &obj);