Images don't look blurry in epub files
BUG: 391625
aacid |
Okular |
Images don't look blurry in epub files
BUG: 391625
I tested the file mentioned in the bug report. Pictures don't look blurry anymore.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Thanks for the patch!
Unfortunately, I don't think this solves 391625. The jaggedness may be smoothed, but that's just a symptom of the root cause, which is that the source images are appearing in low-resolution and are being scaled up rather than displaying in high resolution and scaling down as required.
You might want to go back and look at the image size calculation itself.
That said, this patch does improve the appearance of low-res images that are scaled up compared to the status quo, so we might want to take it anyway while you keep looking for the root cause of 391625. @aacid, what do you think?
I tried commenting out the two lines (+if clause, so line 88 - 91) and all pictures are looking fine. Except that they are sometimes to big and break layout. So I would argue Okular does load all pictures with the correct solution, but the down-scaling part made them look blurry.
Well, conceptually, reducing the size of a too-large image should never cause blurriness; that should only happen if you have to scale up an image that's too small.
For me, if use your patch but comment out the conditionals, the image is still blurry rather than sharp (though, again, better than it was without your patch):
This implies that the images are being loaded too small in the first place. Could epub_get_data() be returning the wrong size, perhaps?
I did some more tests and epub_get_data() always returned the correct size.
Original image file from ebook:
/*if(img.height() > maxHeight) img = img.scaledToHeight(maxHeight); if(img.width() > maxWidth) img = img.scaledToWidth(maxWidth);*/
So I would argue Okular does load all images with the correct size. HOWEVER if you use Okulars zoom functionality the image gets blurry again:
I don't know for sure what causes this behavior. Maybe this is a QTextDocument issue? I will try to look into this.
Same here: Regular DPI without scaling.
I did a quick search in Okular source and everywhere, where the QImage scaled*() function is used, it is called with Qt::SmoothTransformation parameter. Except in the epub generator.
This makes it a bit better so i will commit it, but it is still not as good as it could/should be. See https://i.imgur.com/HDn9QIX.png
The top is okular with your patch, the bottom is Ark opening the JPEG inside the epub file, you'll notice that it is much sharper.