diff --git a/src/calibre/ebooks/pdf/render/engine.py b/src/calibre/ebooks/pdf/render/engine.py index 7987bd9c6e..6afbef223f 100644 --- a/src/calibre/ebooks/pdf/render/engine.py +++ b/src/calibre/ebooks/pdf/render/engine.py @@ -153,12 +153,12 @@ class PdfEngine(QPaintEngine): def drawTiledPixmap(self, rect, pixmap, point): self.apply_graphics_state() brush = QBrush(pixmap) + bl = rect.topLeft() color, opacity, pattern, do_fill = self.graphics.convert_brush( - brush, -point, 1.0, self.pdf, self.pdf_system, + brush, bl-point, 1.0, self.pdf, self.pdf_system, self.painter().transform()) self.pdf.save_stack() self.pdf.apply_fill(color, pattern) - bl = rect.topLeft() self.pdf.draw_rect(bl.x(), bl.y(), rect.width(), rect.height(), stroke=False, fill=True) self.pdf.restore_stack() diff --git a/src/calibre/ebooks/pdf/render/test.py b/src/calibre/ebooks/pdf/render/test.py index 3ea447dfc7..7a53741ca8 100644 --- a/src/calibre/ebooks/pdf/render/test.py +++ b/src/calibre/ebooks/pdf/render/test.py @@ -11,8 +11,9 @@ import os from tempfile import gettempdir from PyQt4.Qt import (QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF, - QApplication, QPainter, Qt, QImage) -QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF, Qt + QApplication, QPainter, Qt, QImage, QLinearGradient, + QPointF) +QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF, Qt, QPointF from calibre.ebooks.pdf.render.engine import PdfDevice @@ -66,7 +67,14 @@ def full(dev): w = xmax/4 p.fillRect(0, ymax/3, w, w, b) p.fillRect(xmax/3, ymax/3, w, w, QBrush(pix)) - p.drawTiledPixmap(QRectF(2*xmax/3, ymax/3, w, w), pix) + x, y = 2*xmax/3, ymax/3 + p.drawTiledPixmap(QRectF(x, y, w, w), pix, QPointF(10, 10)) + + x, y = 1, ymax/1.9 + g = QLinearGradient(QPointF(x, y), QPointF(x+w, y+w)) + g.setColorAt(0, QColor('#00f')) + g.setColorAt(1, QColor('#006')) + p.fillRect(x, y, w, w, QBrush(g)) finally: p.end() if isinstance(dev, PdfDevice):