[Interest] QQuickProviders and proper drawing / caching?
Gunnar Roth
gunnar.roth at gmx.de
Tue Feb 26 22:29:57 CET 2019
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 and height 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 and height 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/d5d1d33a/attachment.html>
More information about the Interest
mailing list