QPainter drawimage showing to much noise, how to solve it?
-
I used the QPainter to draw a big image on screen, but image showing on the screen showed too much noise? How to solve it?
Here is my code:
painter.setRenderHint(QPainter::SmoothPixmapTransform); auto rect = m_scale_assist.get_scaled_img_rect(); painter.drawImage(rect, *m_opt_src_img);
the image showing on the screen is
while using a image viewer, it is
the image size is 5480*3648, why the
SmoothPixmapTransform
not works here?Besides, If I first scale the image to a size with SmoothPixmapTransform
auto image = m_opt_src_img->scaled(size, Qt::IgnoreAspectRatio, Qt::Smoothransformation); painter.drawImage(rect, image);
then use drawImage to show it, it don't show to much noise.
-
@aiyolo I am assuming that m_opt_src_img refers to a QImage.
Depending on the values of
rect
(first example),size
(second example), and the target space the scaling will differ. We also cannot see any other configuration you may have done to the painter.It would help if you could post a self-contained, example program that reproduces the problem along with somewhere the original image can be sourced.