[Interest] QQuickProviders and proper drawing / caching?

Gunnar Roth gunnar.roth at gmx.de
Tue Feb 26 22:33:04 CET 2019


Hi Jason,
another adavantage of the default is that the cached image can be used 
for multiple items with different sizes using the same image by default.

Regards,
Gunnar



>QR Code with ALL the bits. Scaling blends the edges.
>
>
>
>>Thanks, so that gets requestedSize to stop being (-1, -1) and my code 
>>works.
>>
>>I still would have assumed that initially the sourceSize would be 
>>equivelent to the item's size? Pixel for pixel is not an unreasonable 
>>default?
>>
>Well, the name source size implies for me the size of the source, but I 
>am not a native speaker.
>
>Pixel for Pixel is an reasonable default imho, as width and height, if 
>not set explictly are using the source size of the image.
>The default is made in a way, that an image item by default uses the 
>image natural size, if no height, width or sourceSize is set.
>
>Why does your application use images, which need to be scaled up or 
>down? This hurts quality and performance.
>
>
>>
>>Hi Jason,
>>it seems you missed this in the docs:
>>
>>sourceSize : QSize
>>
>>This property holds the actual width and height of the loaded image.
>>
>>Unlike the width 
>><https://doc.qt.io/qt-5/qml-qtquick-item.html#width-prop> and height 
>><https://doc.qt.io/qt-5/qml-qtquick-item.html#height-prop> properties, 
>>which scale the painting of the image, this property sets the actual 
>>number of pixels stored for the loaded image so that large images do 
>>not use more memory than necessary. For example, this ensures the 
>>image in memory is no larger than 1024x1024 pixels, regardless of the 
>>Image's width 
>><https://doc.qt.io/qt-5/qml-qtquick-item.html#width-prop> and height 
>><https://doc.qt.io/qt-5/qml-qtquick-item.html#height-prop> values:
>>
>>Rectangle {
>>     width: ...
>>     height: ...
>>
>>     Image {
>>        anchors.fill: parent
>>        source: "reallyBigImage.jpg"
>>        sourceSize.width: 1024
>>        sourceSize.height: 1024
>>     }
>>}
>>
>>Regards,
>>Gunnar Roth
>>
>>------ Original Message ------
>>From: "Jason H" <jhihn at gmx.com>
>>To: "interestqt-project.org" <interest at qt-project.org>
>>Sent: 26/02/2019 19:42:42
>>Subject: [Interest] QQuickProviders and proper drawing / caching?
>>
>>>I've got a custom QQuickImageProvider that I want to have always rendered at native resolution.
>>>However on every call requestedSize is QSize(-1, -1) forcing me to use my default resolution which then gets scaled, which gives me fuzzy pixels.
>>>
>>>I thought maybe fillMode was an issue, but is it not. Even with an explicit height and width in the Image, it never changes from QSize(-1, -1).
>>>
>>>Then, I was reading the docs and it says
>>>'''
>>>Image Caching
>>>Images returned by a QQuickImageProvider are automatically cached, similar to any image loaded by the QML engine. When an image with a "image://" prefix is loaded from cache, requestImage() and requestPixmap() will not be called for the relevant image provider. If an image should always be fetched from the image provider, and should not be cached at all, set the cache property to false for the relevant Image, BorderImage or AnimatedImage object.
>>>'''
>>>
>>>However setting cache: false in the Image element does not change anything.
>>>
>>>I've also set
>>>painter.setRenderHint(QPainter::Antialiasing, false);
>>>painter.setRenderHint(QPainter::SmoothPixmapTransform, false);
>>>In painter and I still get blurry output. I want aliased pixels like in the Concentric Circles example.
>>>
>>>I've tried various achorings, fillModes, widths and heights.
>>>
>>>Does anyone have any pointers? I would expect that the requested size be the pixel dimensions of the Image requesting it?
>>>
>>>_______________________________________________
>>>Interest mailing list
>>>Interest at qt-project.org
>>>https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190226/1834ff71/attachment.html>


More information about the Interest mailing list