Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QPainter drawImage seems different with original image



  • Hello everyone. I implement a class which extend QQuickPaintedItem and rewrite the paint( QPainter * ) to show an image of PDF page. I find the QPainter draw image do not work very well. Here is my drawing code:

    painter->setRenderHint(QPainter::HighQualityAntialiasing, true);
    m_iPDFImage.load("D:\\a.bmp");
    painter->drawImage(m_rTarget, m_iPDFImage);
    

    and the following is a.bmp(part of image):
    0_1472803426354_a.bmp
    but the result of drawImage looks like:
    0_1472803574457_QQ图片20160902160548.png
    here I hardly to see "-" in command "dpkg -i ".
    It cost my one day to try to solve it but fail. So what's the problem? Can anyone give me an advise? thx.


  • Moderators

    @webberg
    What is the type of m_rTarget? Is it a rect or a point?
    I assume it's a rect, so the image will be scaled to fit into it.

    If it's a point check if the painter itself is scaling, which means that the item is scaled?



  • Did you use the painter->setRenderHint(QPainter::SmoothPixmapTransform)?



  • @raven-worx m_rTarget is a QRectF.



  • @Devopia53 thx! now I can see the "-". I forgot it because I scaled the image using SmoothTransformation and didn't use it in painter again.


Log in to reply