Hi, and thanks for the input!

QQuickImageProvider is an interface that returns rasterized images and is very 
specifically for use with the Image component. It doesn't have support for 
returning encoded files in any format (it doesn't have any requestPNG() or 
requestJPEG(), and I don't think it would fit to have a requestSVG()). So I 
don't think QQuickImageProvider is relevant here, except perhaps as inspiration 
for a solution. I do agree that VectorImage is one of the places where it might 
be useful to load generated formatted file data from memory, but I think there 
are other such places, so ideally we would have a general solution for this. 
Maybe we can continue the discussion on 
https://bugreports.qt.io/browse/QTBUG-134656?

As for generating scalable vector graphics in Qt Quick, this should already be 
possible without going via SVG as long as you control the code that does it. 
You should be able to use Qt Quick Shapes (which is what VectorImage will use 
under the hood), and either create nodes dynamically or generate QML code which 
you parse at runtime. Using SVG as a carrier format would actually be overhead 
in this case.

And for your final point about small SVGs being ugly: Granted that you 
rasterize the SVG at the same size as it is being shown, I would not expect any 
increase in quality from using VectorImage instead. Qt SVG uses what should be 
fairly close to pixel perfect software rendering, so if the output is ugly, it 
could be worth looking into in case there is a bug. VectorImage uses the same 
parser as Qt SVG, so if it does have a bug then it would likely show up in Qt 
Quick as well.


Eskil Abrahamsen Blomfeldt
Principal Manager, Graphics Engines

The Qt Company
Sandakerveien 116
0484 Oslo, Norway
eskil.abrahamsen-blomfe...@qt.io
http://qt.io
________________________________
From: Development <development-boun...@qt-project.org> on behalf of 
Schimkowitsch Robert <robert.schimkowit...@andritz.com>
Sent: Friday, March 14, 2025 9:33 AM
To: Qt Development <development@qt-project.org>
Subject: Re: [Development] Why does QQuickImageProvider not support SVG images?

Hi Shawn,

> FWIW QQuickImageProvider is for images: you can see from its API that it
> generates QImage or QPixmap or a texture.

I would argue that an SVG IS an image, see e.g. the definition from Wikipedia:
" A representation of the form of a person or object[...]"
So why should QQuickImageProvider not have a 'requestSvg'  function (naturally 
without size parameter)?

> An Image can render an SVG, but then you really
> generate a fixed-size image: you can set sourceSize, and then the SVG has to
> be re-rendered on the CPU each time.  It’s less efficient.

I do that currently and cache the pixmaps in their correct size. It's fine for 
most use cases, but small SVGs become really ugly when rendered with 
QSvgRenderer. I was hoping for better quality using VectorImage.

>
> But you are welcome to write up a bug to ask for some way of supplying an
> SVG to VectorImage from a memory buffer rather than a file.

Done in the meantime, see https://bugreports.qt.io/browse/QTBUG-134656 and 
https://bugreports.qt.io/browse/QTBUG-134666

>
> If you are generating the SVG on the fly anyway, maybe it’s better to generate
> a QPainterPath rather than serializing to SVG and getting Qt to deserialize it
> right away?

My use case is this: I take existing (potentially customer-provided) SVGs and 
modify them on the fly (colorization to match my current color scheme).
I know there is a mechanism to convert SVGs to QML files, this may be an 
alternative to look at, but it is a lot more complex to integrate.

Kind regards

Robert

________________________________

This message and any attachments are solely for the use of the intended 
recipients. They may contain privileged and/or confidential information or 
other information protected from disclosure. If you are not an intended 
recipient, you are hereby notified that you received this email in error and 
that any review, dissemination, distribution or copying of this email and any 
attachment is strictly prohibited. If you have received this email in error, 
please contact the sender and delete the message and any attachment from your 
system.

ANDRITZ HYDRO GmbH


Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806


Thank You
________________________________
--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to