Lines 56-61
Link Here
|
56 |
#include <config.h> |
56 |
#include <config.h> |
57 |
#include <cfloat> |
57 |
#include <cfloat> |
58 |
#include <poppler-config.h> |
58 |
#include <poppler-config.h> |
|
|
59 |
#include <math.h> |
59 |
#include <PDFDoc.h> |
60 |
#include <PDFDoc.h> |
60 |
#include <Catalog.h> |
61 |
#include <Catalog.h> |
61 |
#include <Form.h> |
62 |
#include <Form.h> |
Lines 67-72
Link Here
|
67 |
#include <Rendition.h> |
68 |
#include <Rendition.h> |
68 |
#include <SplashOutputDev.h> |
69 |
#include <SplashOutputDev.h> |
69 |
#include <splash/SplashBitmap.h> |
70 |
#include <splash/SplashBitmap.h> |
|
|
71 |
#if defined(HAVE_CAIRO) |
72 |
# include <CairoOutputDev.h> |
73 |
#endif |
70 |
|
74 |
|
71 |
#include "poppler-private.h" |
75 |
#include "poppler-private.h" |
72 |
#include "poppler-page-transition-private.h" |
76 |
#include "poppler-page-transition-private.h" |
Lines 597-602
QImage Page::renderToImage(double xres, double yres, int xPos, int yPos, int w,
Link Here
|
597 |
img = tmpimg; |
601 |
img = tmpimg; |
598 |
break; |
602 |
break; |
599 |
} |
603 |
} |
|
|
604 |
case Poppler::Document::CairoBackend: { |
605 |
#if defined(HAVE_CAIRO) |
606 |
CairoOutputDev *output_dev = new CairoOutputDev(); |
607 |
output_dev->startDoc(m_page->parentDoc->doc); |
608 |
int buffer_width, buffer_height, rotate; |
609 |
cairo_surface_t *surface; |
610 |
cairo_t *cairo; |
611 |
|
612 |
// If w or h are -1, that indicates the whole page, so we need to |
613 |
// calculate how many pixels that corresponds to. Otherwise, we can use w |
614 |
// or h directly for our buffer size. |
615 |
const QSize pageSize = this->pageSize(); |
616 |
if (w == -1) { |
617 |
const double xscale = xres / 72.0; |
618 |
const double width = pageSize.width();; |
619 |
buffer_width = (int) ceil(width * xscale); |
620 |
} else { |
621 |
buffer_width = w; |
622 |
} |
623 |
if (h == -1) { |
624 |
const double yscale = yres / 72.0; |
625 |
const double height = pageSize.height(); |
626 |
buffer_height = (int) ceil(height * yscale); |
627 |
} else { |
628 |
buffer_height = h; |
629 |
} |
630 |
|
631 |
rotate = rotation + m_page->page->getRotate(); |
632 |
|
633 |
// FIXME: Okular never provides a rotation value, so I don't have any way |
634 |
// of testing this right now. The result is that subpixels are ordered |
635 |
// incorrectly when the page is rotated. |
636 |
|
637 |
//if (rotate == 90 || rotate == 270) { |
638 |
// const double temp = height; |
639 |
// height = width; |
640 |
// width = temp; |
641 |
//} |
642 |
|
643 |
img = QImage(buffer_width, buffer_height, QImage::Format_ARGB32); |
644 |
img.fill(Qt::white); // Never transparent |
645 |
|
646 |
surface = cairo_image_surface_create_for_data( |
647 |
img.bits(), |
648 |
CAIRO_FORMAT_ARGB32, |
649 |
buffer_width, buffer_height, |
650 |
img.bytesPerLine()); |
651 |
|
652 |
cairo = cairo_create(surface); |
653 |
output_dev->setCairo(cairo); |
654 |
|
655 |
m_page->parentDoc->doc->displayPageSlice( |
656 |
output_dev, m_page->index + 1, xres, yres, rotation, false, true, |
657 |
false, xPos, yPos, w, h); |
658 |
|
659 |
// Clean up |
660 |
output_dev->setCairo(nullptr); |
661 |
cairo_destroy(cairo); |
662 |
cairo_surface_destroy(surface); |
663 |
delete output_dev; |
664 |
#endif |
665 |
break; |
666 |
} |
600 |
} |
667 |
} |
601 |
|
668 |
|
602 |
if (shouldAbortRenderCallback && shouldAbortRenderCallback(payload)) { |
669 |
if (shouldAbortRenderCallback && shouldAbortRenderCallback(payload)) { |
Lines 622-627
bool Page::renderToPainter(QPainter *painter, double xres, double yres, int x, i
Link Here
|
622 |
|
689 |
|
623 |
return renderToQPainter(&qpainter_output, painter, m_page, xres, yres, x, y, w, h, rotate, flags); |
690 |
return renderToQPainter(&qpainter_output, painter, m_page, xres, yres, x, y, w, h, rotate, flags); |
624 |
} |
691 |
} |
|
|
692 |
case Poppler::Document::CairoBackend: { |
693 |
return false; |
694 |
} |
625 |
} |
695 |
} |
626 |
return false; |
696 |
return false; |
627 |
} |
697 |
} |