mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-01-03 03:50:53 +01:00
Issue #165: Insert > Inline Text latency issues on Flatpak and Appimage packages
This commit is contained in:
parent
30d2d8080f
commit
4359109157
@ -790,6 +790,32 @@ QImage PDFImage::getImage(const PDFCMS* cms,
|
||||
return QImage();
|
||||
}
|
||||
|
||||
bool PDFImage::canBeConvertedToMonochromatic(const QImage& image)
|
||||
{
|
||||
for (int y = 0; y < image.height(); ++y)
|
||||
{
|
||||
for (int x = 0; x < image.width(); ++x)
|
||||
{
|
||||
QRgb pixel = image.pixel(x, y);
|
||||
int red = qRed(pixel);
|
||||
int green = qGreen(pixel);
|
||||
int blue = qBlue(pixel);
|
||||
int alpha = qAlpha(pixel);
|
||||
|
||||
if (alpha != 255)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Zkontrolujte, zda jsou kanály stejné (odstín šedi) a zda jsou pouze 0 (černá) nebo 255 (bílá)
|
||||
if ((red != green || green != blue) || (red != 0 && red != 255)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
OPJ_SIZE_T PDFJPEG2000ImageData::read(void* p_buffer, OPJ_SIZE_T p_nb_bytes, void* p_user_data)
|
||||
{
|
||||
PDFJPEG2000ImageData* data = reinterpret_cast<PDFJPEG2000ImageData*>(p_user_data);
|
||||
|
@ -112,6 +112,8 @@ public:
|
||||
const PDFImageData& getImageData() const { return m_imageData; }
|
||||
const PDFImageData& getSoftMaskData() const { return m_softMask; }
|
||||
|
||||
static bool canBeConvertedToMonochromatic(const QImage& image);
|
||||
|
||||
private:
|
||||
PDFImageData m_imageData;
|
||||
PDFImageData m_softMask;
|
||||
|
@ -3021,6 +3021,11 @@ void PDFPageContentProcessor::paintXObjectImage(const PDFStream* stream)
|
||||
|
||||
if (!image.isNull())
|
||||
{
|
||||
if (PDFImage::canBeConvertedToMonochromatic(image))
|
||||
{
|
||||
image.convertTo(QImage::Format_Mono);
|
||||
}
|
||||
|
||||
performImagePainting(image);
|
||||
}
|
||||
else
|
||||
|
@ -683,13 +683,6 @@ void PDFPrecompiledPage::addClip(QPainterPath path)
|
||||
|
||||
void PDFPrecompiledPage::addImage(QImage image)
|
||||
{
|
||||
// Convert the image into format Format_ARGB32_Premultiplied for fast drawing.
|
||||
// If this format is used, then no image conversion is performed while drawing.
|
||||
if (image.format() != QImage::Format_ARGB32_Premultiplied)
|
||||
{
|
||||
image.convertTo(QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
|
||||
m_instructions.emplace_back(InstructionType::DrawImage, m_images.size());
|
||||
m_images.emplace_back(qMove(image));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ CURRENT:
|
||||
- Issue #205: Editor cannot create white, whitesmoke or transparent annotations
|
||||
- Issue #202: Certain raster content not rendered
|
||||
- Issue #185: Latest git fails to build in linux
|
||||
- Issue #165: Insert > Inline Text latency issues on Flatpak and Appimage packages
|
||||
|
||||
V: 1.4.0.0 4.7.2024
|
||||
- Issue #190: PageMaster crash + black bubbles instead of bubbles with correct color
|
||||
|
Loading…
Reference in New Issue
Block a user