mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Editor plugin: Color convertor
This commit is contained in:
@@ -225,6 +225,20 @@ QColor PDFColorConvertor::getForegroundColor() const
|
||||
return m_foregroundColor;
|
||||
}
|
||||
|
||||
QPen PDFColorConvertor::convert(const QPen& pen, bool background, bool foreground) const
|
||||
{
|
||||
QPen newPen = pen;
|
||||
newPen.setColor(convert(pen.color(), background, foreground));
|
||||
return newPen;
|
||||
}
|
||||
|
||||
QBrush PDFColorConvertor::convert(const QBrush& brush, bool background, bool foreground) const
|
||||
{
|
||||
QBrush newBrush = brush;
|
||||
newBrush.setColor(convert(brush.color(), background, foreground));
|
||||
return newBrush;
|
||||
}
|
||||
|
||||
QColor PDFColorConvertor::getBackgroundColor() const
|
||||
{
|
||||
return m_backgroundColor;
|
||||
|
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "pdfglobal.h"
|
||||
|
||||
#include <QPen>
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
|
||||
@@ -103,6 +105,9 @@ public:
|
||||
QColor getBackgroundColor() const;
|
||||
QColor getForegroundColor() const;
|
||||
|
||||
QPen convert(const QPen& pen, bool background = false, bool foreground = true) const;
|
||||
QBrush convert(const QBrush& brush, bool background = false, bool foreground = true) const;
|
||||
|
||||
private:
|
||||
/// Correct lightness using sigmoid function
|
||||
/// \return Adjusted lightness normalized in range [0.0, 1.0]
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "pdftextlayout.h"
|
||||
#include "pdfutils.h"
|
||||
#include "pdfexecutionpolicy.h"
|
||||
#include "pdfcms.h"
|
||||
|
||||
#include <QtMath>
|
||||
#include <QMutex>
|
||||
@@ -1509,7 +1510,11 @@ PDFTextLayout PDFTextLayoutStorageGetter::getTextLayoutImpl() const
|
||||
return m_storage ? m_storage->getTextLayout(m_pageIndex) : PDFTextLayout();
|
||||
}
|
||||
|
||||
void PDFTextSelectionPainter::draw(QPainter* painter, PDFInteger pageIndex, PDFTextLayoutGetter& textLayoutGetter, const QTransform& matrix)
|
||||
void PDFTextSelectionPainter::draw(QPainter* painter,
|
||||
PDFInteger pageIndex,
|
||||
PDFTextLayoutGetter& textLayoutGetter,
|
||||
const QTransform& matrix,
|
||||
const PDFColorConvertor& convertor)
|
||||
{
|
||||
Q_ASSERT(painter);
|
||||
|
||||
@@ -1548,8 +1553,8 @@ void PDFTextSelectionPainter::draw(QPainter* painter, PDFInteger pageIndex, PDFT
|
||||
QColor brushColor = item.color;
|
||||
brushColor.setAlphaF(SELECTION_ALPHA);
|
||||
|
||||
painter->setPen(penColor);
|
||||
painter->setBrush(QBrush(brushColor, Qt::SolidPattern));
|
||||
painter->setPen(convertor.convert(QPen(penColor)));
|
||||
painter->setBrush(convertor.convert(QBrush(brushColor, Qt::SolidPattern)));
|
||||
painter->drawPath(path);
|
||||
}
|
||||
|
||||
|
@@ -35,6 +35,7 @@ namespace pdf
|
||||
class PDFTextLayout;
|
||||
class PDFTextLayoutStorage;
|
||||
struct PDFCharacterPointer;
|
||||
class PDFColorConvertor;
|
||||
|
||||
struct PDFTextCharacterInfo
|
||||
{
|
||||
@@ -522,7 +523,7 @@ public:
|
||||
/// \param pageIndex Page index
|
||||
/// \param textLayoutGetter Text layout getter
|
||||
/// \param matrix Matrix which translates from page space to device space
|
||||
void draw(QPainter* painter, PDFInteger pageIndex, PDFTextLayoutGetter& textLayoutGetter, const QTransform& matrix);
|
||||
void draw(QPainter* painter, PDFInteger pageIndex, PDFTextLayoutGetter& textLayoutGetter, const QTransform& matrix, const PDFColorConvertor& convertor);
|
||||
|
||||
/// Prepares geometry for text selection drawing, using text layout and matrix. If current text selection
|
||||
/// doesn't contain items from active page, then text layout is not accessed.
|
||||
|
Reference in New Issue
Block a user