From 147a1ea586fba7d60444e77dacb203b869a9b3e3 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Fri, 8 Dec 2023 14:44:51 +0100 Subject: [PATCH] Issue #113: Color | Custom (green/black) partially works in scanned PDF (1.3.6) --- Pdf4QtLibCore/sources/pdfcolorconvertor.cpp | 28 ++++++++++++++++++--- RELEASES.txt | 5 ++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Pdf4QtLibCore/sources/pdfcolorconvertor.cpp b/Pdf4QtLibCore/sources/pdfcolorconvertor.cpp index 785642f..30ccff0 100644 --- a/Pdf4QtLibCore/sources/pdfcolorconvertor.cpp +++ b/Pdf4QtLibCore/sources/pdfcolorconvertor.cpp @@ -85,9 +85,11 @@ QColor PDFColorConvertor::convert(QColor color, bool background, bool foreground } const float lightness = color.lightnessF(); - QColor hslColor = m_foregroundColor; - hslColor.setHslF(hslColor.hueF(), hslColor.saturationF(), lightness, color.alphaF()); - return hslColor.toRgb(); + QColor convertedColor = m_foregroundColor; + convertedColor.setRedF(convertedColor.redF() * lightness); + convertedColor.setGreenF(convertedColor.greenF() * lightness); + convertedColor.setBlueF(convertedColor.blueF() * lightness); + return convertedColor; } default: @@ -136,7 +138,6 @@ QImage PDFColorConvertor::convert(QImage image) const } case Mode::HighContrast: - case Mode::CustomColors: { for (int row = 0; row < image.height(); ++row) { @@ -151,6 +152,25 @@ QImage PDFColorConvertor::convert(QImage image) const return image; } + case Mode::CustomColors: + { + for (int row = 0; row < image.height(); ++row) + { + for (int column = 0; column < image.width(); ++column) + { + QColor color = image.pixelColor(column, row); + const float lightness = 1.0f - color.lightnessF(); + QColor convertedColor = m_foregroundColor; + convertedColor.setRedF(convertedColor.redF() * lightness); + convertedColor.setGreenF(convertedColor.greenF() * lightness); + convertedColor.setBlueF(convertedColor.blueF() * lightness); + image.setPixelColor(column, row, convertedColor); + } + } + + return image; + } + default: Q_ASSERT(false); break; diff --git a/RELEASES.txt b/RELEASES.txt index 41959d0..7980aa8 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -1,4 +1,9 @@ CURRENT: + - Issue #118: Adding CMAKE options for minimal builds + - Issue #116: Improve search bar (rembember searched text, allow scroll and zoom) + - Issue #115: Redesign of sidebar widget, new icons + - Issue #113: Color | Custom (green/black) partially works in scanned PDF (1.3.6) + - Issue #99: Icons for dark mode V: 1.3.6 24.11.2023 - Issue #110: PDF4QT Viewer Lite : Arbitrary Code can execute when using Send by Email