Reputation: 12228
We are currently using a commercial library for image rendering with Windows. When displaying monochrome images in sizes smaller than the images original size, this library gray scales images so that still most of them can be recognized:
Now i tried the same with a Qt 4.8 Application. Basically whats done is calling:
QImage mImage;
...
mImage.load(...);
...
painter.drawImage(paintRect, mImage, mImage.rect());
Where paintRect is smaller than mImage.rect(). That works well, but the output is much less satisfying:
I tried several renderHints (QPainter::SmoothPixmapTransform, Antialiasing, HighQualityAntialiasing) and also converted the Image using
mImage = mImage.convertToFormat(QImage::Format_RGB32);
QPainter::SmoothPixmapTransform seemed to improve the output a little bit (its included in the screen shot). All the other things do not seem to change anything.
Am i missing something?
How can display of images with decrease size be improved?
Upvotes: 3
Views: 2143
Reputation: 22910
It is possible that during
painter.drawImage(paintRect, mImage, mImage.rect());
the painter just interpolate which pixel to take in the initial image when the size differs. Which will explain the second image.
Scale manual using
QImage todraw = mImage.scaled(
paintRect.size(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
...
painter.drawImage(paintRect, todraw, mImage.rect());
You compute the image todraw
only on resize events (to avoid scaling every paint event)
and you use it instead with the painter.
Upvotes: 5