[okular] [Bug 370382] Using non-default size for custom stamp pixelates the stamp

Keyu Tao bugzilla_noreply at kde.org
Wed Jul 31 18:59:46 BST 2024


https://bugs.kde.org/show_bug.cgi?id=370382

Keyu Tao <taoky1999 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |taoky1999 at gmail.com

--- Comment #4 from Keyu Tao <taoky1999 at gmail.com> ---
This looks like a bug related to QPixmap scaling and DPI stuffs. In
setPopplerStampAnnotationCustomImage() it calls
Okular::AnnotationUtils::loadStamp() with a rect size calculated from page size
and annotation size. However it looks like this code assumes that 1 pts = 1
pixel on screen (72 DPI?), then in Okular::AnnotationUtils::loadStamp() the
stamp is scaled too small, and results in a blurry result.
setStampCustomImage() stores the scaled image in PDF, so stamps saved by Okular
would also be blurry in other PDF readers.

A very dirty workaround is to enforce it to be at least 288 (=72*4) DPI in
setPopplerStampAnnotationCustomImage():

diff --git a/generators/poppler/annots.cpp b/generators/poppler/annots.cpp
index 20ad117ea..9d0680919 100644
--- a/generators/poppler/annots.cpp
+++ b/generators/poppler/annots.cpp
@@ -285,7 +285,7 @@ static void setPopplerStampAnnotationCustomImage(const
Poppler::Page *page, Popp
     const QSize size = page->pageSize();
     const QRect rect =
Okular::AnnotationUtils::annotationGeometry(oStampAnnotation, size.width(),
size.height());

-    QImage image =
Okular::AnnotationUtils::loadStamp(oStampAnnotation->stampIconName(),
qMax(rect.width(), rect.height())).toImage();
+    QImage image =
Okular::AnnotationUtils::loadStamp(oStampAnnotation->stampIconName(),
qMax(rect.width(), rect.height())*4).toImage();

     if (!image.isNull()) {
         pStampAnnotation->setStampCustomImage(image);


I don't think it's a nice fix that should be included in upstream, but at least
my signature image looks clear with this workaround.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Okular-devel mailing list