8#ifndef QT_NO_SVGRENDERER
11#include "private/qsvgdocument_p.h"
28 bool load(QIODevice *device);
52 if (
q->format().isEmpty())
59 QBuffer *buf = qobject_cast<QBuffer *>(device);
62 res = r.load(QByteArray::fromRawData(ba.constData() + buf->pos(), ba.size() - buf->pos()));
65 }
else if (
q->format() ==
"svgz") {
66 res = r.load(device->readAll());
69 xmlReader.setDevice(device);
70 res = r.load(&xmlReader);
74 defaultSize = r.defaultSize();
77 const int duration = r.animationDuration();
78 const int fps = r.framesPerSecond();
79 frameCount = qMax(1,
static_cast<
int>(qint64(duration) * fps / 1000));
115 bool isCompressed =
false;
116 if (QSvgDocument::isLikelySvg(device(), &isCompressed)) {
117 setFormat(isCompressed ?
"svgz" :
"svg");
129 if (!d->r.animated()) {
139 bool xform = (d->clipRect.isValid() || d->scaledSize.isValid() || d->scaledClipRect.isValid());
140 QSize finalSize = d->defaultSize;
142 if (xform && !d->defaultSize.isEmpty()) {
143 bounds = QRectF(QPointF(0,0), QSizeF(d->defaultSize));
146 if (d->clipRect.isValid()) {
147 tr1 = -d->clipRect.topLeft();
148 finalSize = d->clipRect.size();
150 if (d->scaledSize.isValid()) {
151 sc = QSizeF(qreal(d->scaledSize.width()) / finalSize.width(),
152 qreal(d->scaledSize.height()) / finalSize.height());
153 finalSize = d->scaledSize;
155 if (d->scaledClipRect.isValid()) {
156 tr2 = -d->scaledClipRect.topLeft();
157 finalSize = d->scaledClipRect.size();
160 t.translate(tr2.x(), tr2.y());
161 t.scale(sc.width(), sc.height());
162 t.translate(tr1.x(), tr1.y());
163 bounds = t.mapRect(bounds);
165 if (finalSize.isEmpty()) {
168 if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
170 if (!QImageIOHandler::allocateImage(finalSize, QImage::Format_ARGB32_Premultiplied, image))
172 image->fill(d->backColor.rgba());
174 d->r.render(&p, bounds);
189 return QImage::Format_ARGB32_Premultiplied;
193 return d->defaultSize;
199 return d->scaledSize;
202 return d->scaledClipRect;
204 case BackgroundColor:
209 return d->r.animated();
222 d->clipRect = value.toRect();
225 d->scaledSize = value.toSize();
228 d->scaledClipRect = value.toRect();
230 case BackgroundColor:
231 d->backColor = value.value<QColor>();
248 case BackgroundColor:
303 return QSvgDocument::isLikelySvg(device);
QIODevice * device() const
Returns the device currently assigned to QImageReader, or \nullptr if no device has been assigned.
\inmodule QtCore\reentrant
bool load(QIODevice *device)
QXmlStreamReader xmlReader
QSvgIOHandlerPrivate(QSvgIOHandler *qq)
int currentImageNumber() const override
For image formats that support animation, this function returns the sequence number of the current im...
bool jumpToImage(int imageNumber) override
For image formats that support animation, this function jumps to the image whose sequence number is i...
bool canRead() const override
Returns true if an image can be read from the device (i.e., the image format is supported,...
QVariant option(ImageOption option) const override
Returns the value assigned to option as a QVariant.
bool read(QImage *image) override
Read an image from the device, and stores it in image.
int imageCount() const override
For image formats that support animation, this function returns the number of images in the animation...
int loopCount() const override
For image formats that support animation, this function returns the number of times the animation sho...
bool supportsOption(ImageOption option) const override
Returns true if the QImageIOHandler supports the option option; otherwise returns false.
void setOption(ImageOption option, const QVariant &value) override
Sets the option option with the value value.
static bool canRead(QIODevice *device)
int nextImageDelay() const override
For image formats that support animation, this function returns the number of milliseconds to wait un...
bool jumpToNextImage() override
For image formats that support animation, this function jumps to the next image.
Combined button and popup list for selecting options.