Issue #113: Color | Custom (green/black) partially works in scanned PDF (1.3.6)

This commit is contained in:
Jakub Melka 2023-12-08 14:44:51 +01:00
parent 8db0ae80c3
commit 147a1ea586
2 changed files with 29 additions and 4 deletions

View File

@ -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;

View File

@ -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