-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indexed images appear dithered in previews #25436
Comments
I believe such strong compression exists for a reason |
It's not a compression issue, image itself doesn't look dithered or noisy, that problem happens only in previews. So it's more like a visual glitch than anything else |
The preview is jpeg compressed IIRC |
Is there any reason why images are compressed in previews? |
Yeah, I believe there is, I don't know which one exactly though |
hatkidchan, Have you interface scale? Can you try to build telegram with qt5 and check? qt6/X11 with UI scale 1.5x by KDE settings all images looks like they upscaled from 4x4 image And all chat/groups icons, all emoji, all pictures looks like that. I see that bug at least a year, maybe more. |
It's sadly a KDE bug and AFAIK no one still reported it to them. They tell scale factor to Qt in a wrong way that overrides the High-DPI scale factor rounding policy tdesktop sets to Qt. After that override the scaling in tdesktop just can't work properly. |
See #25126, it has the link to first discussion |
@hatkidchan there was some work related to color spaces support, do you see any changes? Note that you should use an official build in order to see the difference as all changes were in Qt patches. |
|
Honestly saying I don't see anything abnormal on the screenshot. Some comparison would be nice. |
I meant comparison with how it should look like |
I think I found the problem. It happens when Telegram tries to scale down image with indexed palette. When converting same image to rgb24 instead of pal8, it looks like it should: Though, I don't really get the reason of that problem: there's definitely less than 256 colors on that image, and scaling indexed should not resolve it appearing dithered. Maybe there's a problem somewhere in png/pal8->jpeg/rgb24 conversion? I tried converting it myself to jpeg using imagemagick's |
I looked at the code generating the preview and there's no conversation in jpeg. It only uses Qt's QImage::scaledToWidth and then writes with white color on transparent pixels if the image has alpha channel tdesktop/Telegram/SourceFiles/storage/storage_media_prepare.cpp Lines 334 to 336 in 23e1c61
https://github.com/desktop-app/lib_ui/blob/3fea35ff19b52da94fa3ed17695f00b79bfb1917/ui/image/image_prepare.cpp#L1180-L1199 |
Both those findings seem to be right. Since Qt 6.0, it doesn't seem to follow the SmoothTransformation hint if scaling more than 2x down and the format is not one of whitelisted: qt/qtbase@b0b4fcd |
You can try to revert the commit on your system Qt package and install tdesktop via package manager or I can provide a build with the Qt commit reverted for test. What do you want? |
It's not that significant issue, just a small annoyance. I think it'd be better for me to change title of that issue to more meaningful and close this, since it's a problem in third-party library |
Though, I just noticed that it also happens in sent images as well, are they being scaled down before sending using the same function as for preview? It doesn't happen when I send the same image using bot, so it may be the case here.. |
Yeah, compressed images should be affected as well |
I've created an Indexed image in GIMP and can confirm the issue. Can also confirm it doesn't happen with Qt 5. |
Maybe it'd be better to convert image from indexed to rgb24 or any other supported format and then scale it down? I can't imagine any other way of fixing that within app itself without making changes in Qt6 |
Will see what approach @john-preston will choose. Converting everything to RGB or patching Qt. |
I don't see any note in Qt documentation that SmoothTransformation doesn't even apply, wonder whether it could be reported as a Qt bug... |
Looking more at the code, it seems the image I test with fits the requirements for smoothScaled (its size is more than 1<<20), so apparently it's caused by Qt converting it back to Indexed8 format. |
I can confirm patching Qt to remove |
There's sadly too much candidates for pre-converting to RGB format and I likely miss some of them, there are also may appear new places that may forget converting. Since it would be too easy to regress, I think patching Qt is the best way forward. If they will reject to fix this or request to invest too much time (like requiring a minimum reproducible example), I will leave fixing this in 3rd party builds for 3rd party redistributors (or any other interested party) if they need such a fix (i.e. to pick up the bug report or tdesktop Qt patchset). |
It's more than enough already for such a small issue. It is an annoyance, for sure, but this should be done on Qt side, since it was working flawlessly in older versions. I'm gonna check from the to time on that bug report in At in hope they fix it eventually, but for the time being I guess I'm just gonna convert images from indexed palette myself, no big deal |
Steps to reproduce
Expected behaviour
Image should look crispy clear
Actual behaviour
Image looks noisy, almost like it's dithered. Sent image itself is untouched, only previews are suffering.
Operating system
Arch Linux, i3
Version of Telegram Desktop
4.3.1-2
Installation source
Other (unofficial) source
Logs
No response
The text was updated successfully, but these errors were encountered: