8#ifndef QT_NO_SVGRENDERER
11#include "private/qsvgdocument_p.h"
28 bool load(QIODevice *device);
52 if (
q->format().isEmpty())
58 QBuffer *buf = qobject_cast<QBuffer *>(device);
61 res = r.load(QByteArray::fromRawData(ba.constData() + buf->pos(), ba.size() - buf->pos()));
64 }
else if (
q->format() ==
"svgz") {
65 res = r.load(device->readAll());
68 xmlReader.setDevice(device);
69 res = r.load(&xmlReader);
73 defaultSize = r.defaultSize();
76 const int duration = r.animationDuration();
77 const int fps = r.framesPerSecond();
78 frameCount = qMax(1,
static_cast<
int>(qint64(duration) * fps / 1000));
114 bool isCompressed =
false;
115 if (QSvgDocument::isLikelySvg(device(), &isCompressed)) {
116 setFormat(isCompressed ?
"svgz" :
"svg");
128 if (!d->r.animated()) {
138 bool xform = (d->clipRect.isValid() || d->scaledSize.isValid() || d->scaledClipRect.isValid());
139 QSize finalSize = d->defaultSize;
141 if (xform && !d->defaultSize.isEmpty()) {
142 bounds = QRectF(QPointF(0,0), QSizeF(d->defaultSize));
145 if (d->clipRect.isValid()) {
146 tr1 = -d->clipRect.topLeft();
147 finalSize = d->clipRect.size();
149 if (d->scaledSize.isValid()) {
150 sc = QSizeF(qreal(d->scaledSize.width()) / finalSize.width(),
151 qreal(d->scaledSize.height()) / finalSize.height());
152 finalSize = d->scaledSize;
154 if (d->scaledClipRect.isValid()) {
155 tr2 = -d->scaledClipRect.topLeft();
156 finalSize = d->scaledClipRect.size();
159 t.translate(tr2.x(), tr2.y());
160 t.scale(sc.width(), sc.height());
161 t.translate(tr1.x(), tr1.y());
162 bounds = t.mapRect(bounds);
164 if (finalSize.isEmpty()) {
167 if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
169 if (!QImageIOHandler::allocateImage(finalSize, QImage::Format_ARGB32_Premultiplied, image))
171 image->fill(d->backColor.rgba());
173 d->r.render(&p, bounds);
188 return QImage::Format_ARGB32_Premultiplied;
192 return d->defaultSize;
198 return d->scaledSize;
201 return d->scaledClipRect;
203 case BackgroundColor:
208 return d->r.animated();
221 d->clipRect = value.toRect();
224 d->scaledSize = value.toSize();
227 d->scaledClipRect = value.toRect();
229 case BackgroundColor:
230 d->backColor = value.value<QColor>();
247 case BackgroundColor:
297 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.