[Interest] QPixmap or QImage::scaled() crash on iOS with smoothTransformation
maitai
maitai at virtual-winds.org
Mon Jul 20 08:02:53 CEST 2015
Hello again,
FYI there is no such thing as Qt::SmoothScale in QPainter::drawImage or
QPainter::drawPixmap so I ended up with something like:
QPixmap pixscaled(QSize(scaleX, scaleY));
if(scaleX > pix.width() || scaleY > pix.height()) {
pixscaled.fill(Qt::transparent);
QPainter painter(&pixscaled);
painter.setBackgroundMode(Qt::TransparentMode);
painter.setRenderHints(QPainter::Antialiasing, true);
painter.setRenderHints(QPainter::SmoothPixmapTransform, true);
painter.drawPixmap(QRect(QPoint(0, 0), QSize(scaleX, scaleY)),
pix);
painter.end();
} else {
pixscaled = pix.scaled(scaleX, scaleY, Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
}
and no crash anymore...
Thanks once more
Philippe Lelong
Le 20-07-2015 05:17, maitai a écrit :
> Ok, it's good there is a workaround
>
> Thank you very much
>
>
> Le 19-07-2015 23:16, Allan Sandfeld Jensen a écrit :
>> On Sunday 19 July 2015, maitai wrote:
>>> Arf...
>>>
>>> Only solution is to go back to 5.4.2 for iOS?
>>>
>> It should be fixed by 5.5.1, if you need smooth-scaling before then
>> and
>> can
>> not build a new Qt binary, you can either overallocate the from image
>> by one
>> pixel or scale using the painter, something like this:
>>
>> QImage dst(dstSize);
>> QPainter painter(&dst);
>> painter.drawImage(srcImage, dstImage, QRect(QPoint(), dstSize),
>> Qt::SmoothScale);
>> painter.end();
>>
>> For downscaling, QImage smooth scaling is better than the qpainter
>> scaling,
>> but for upscaling they are the same.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list