Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qimageiohandler.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
227#include "qimageiohandler.h"
228#include "qimage_p.h"
229
230#include <qbytearray.h>
231#include <qimagereader.h>
232#include <qloggingcategory.h>
233#include <qvariant.h>
234
236
237Q_LOGGING_CATEGORY(lcImageIo, "qt.gui.imageio")
238
239class QIODevice;
240
253
259
263
271
281
288
301{
302 Q_D(QImageIOHandler);
303 d->device = device;
304}
305
311{
312 Q_D(const QImageIOHandler);
313 return d->device;
314}
315
323{
324 Q_D(QImageIOHandler);
325 d->format = format;
326}
327
337{
338 Q_D(const QImageIOHandler);
339 d->format = format;
340}
341
350{
351 Q_D(const QImageIOHandler);
352 return d->format;
353}
354
391{
393 return false;
394}
395
406
419
429{
431 return false;
432}
433
445{
446 return 0;
447}
448
457{
458 return QRect();
459}
460
471{
472 return canRead() ? 1 : 0;
473}
474
482{
483 return false;
484}
485
493bool QImageIOHandler::jumpToImage(int imageNumber)
494{
495 Q_UNUSED(imageNumber);
496 return false;
497}
498
505{
506 return 0;
507}
508
516{
517 return 0;
518}
519
533{
535 if (size.isEmpty() || format <= QImage::Format_Invalid || format >= QImage::NImageFormats)
536 return false;
537
538 if (image->size() == size && image->format() == format) {
539 image->detach();
540 } else {
541 if (const int mbLimit = QImageReader::allocationLimit()) {
542 qsizetype depth = qMax(qt_depthForFormat(format), 32); // Effective gui depth = 32
545 if (!szp.isValid())
546 return false;
547 const qsizetype mb = szp.totalSize >> 20;
548 if (mb > mbLimit || (mb == mbLimit && szp.totalSize % (1 << 20))) {
549 qCWarning(lcImageIo, "QImageIOHandler: Rejecting image as it exceeds the current "
550 "allocation limit of %i megabytes", mbLimit);
551 return false;
552 }
553 }
554 *image = QImage(size, format);
555 }
556 return !image->isNull();
557}
558
559#ifndef QT_NO_IMAGEFORMATPLUGIN
560
566 : QObject(parent)
567{
568}
569
579
611#endif // QT_NO_IMAGEFORMATPLUGIN
612
614
615#include "moc_qimageiohandler.cpp"
IOBluetoothDevice * device
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore \reentrant
Definition qiodevice.h:34
QImageIOHandlerPrivate(QImageIOHandler *q)
The QImageIOHandler class defines the common image I/O interface for all image formats in Qt.
virtual QRect currentImageRect() const
Returns the rect of the current image.
virtual int nextImageDelay() const
For image formats that support animation, this function returns the number of milliseconds to wait un...
virtual int imageCount() const
For image formats that support animation, this function returns the number of images in the animation...
QImageIOHandler()
Constructs a QImageIOHandler object.
ImageOption
This enum describes the different options supported by QImageIOHandler.
virtual bool jumpToNextImage()
For image formats that support animation, this function jumps to the next image.
virtual int currentImageNumber() const
For image formats that support animation, this function returns the sequence number of the current im...
virtual bool canRead() const =0
Returns true if an image can be read from the device (i.e., the image format is supported,...
virtual bool write(const QImage &image)
Writes the image image to the assigned device.
static bool allocateImage(QSize size, QImage::Format format, QImage *image)
virtual void setOption(ImageOption option, const QVariant &value)
Sets the option option with the value value.
QByteArray format() const
Returns the format that is currently assigned to QImageIOHandler.
virtual bool supportsOption(ImageOption option) const
Returns true if the QImageIOHandler supports the option option; otherwise returns false.
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
virtual QVariant option(ImageOption option) const
Returns the value assigned to option as a QVariant.
void setDevice(QIODevice *device)
Sets the device of the QImageIOHandler to device.
virtual bool jumpToImage(int imageNumber)
For image formats that support animation, this function jumps to the image whose sequence number is i...
virtual ~QImageIOHandler()
Destructs the QImageIOHandler object.
virtual int loopCount() const
For image formats that support animation, this function returns the number of times the animation sho...
void setFormat(const QByteArray &format)
Sets the format of the QImageIOHandler to format.
~QImageIOPlugin()
Destroys the picture format plugin.
QImageIOPlugin(QObject *parent=nullptr)
Constructs an image plugin with the given parent.
static int allocationLimit()
\inmodule QtGui
Definition qimage.h:37
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ NImageFormats
Definition qimage.h:80
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
Definition qvariant.h:65
#define this
Definition dialogs.cpp:9
Combined button and popup list for selecting options.
Definition image.cpp:4
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qt_depthForFormat(QImage::Format format)
Definition qimage_p.h:142
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint GLenum option
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_UNUSED(x)
ptrdiff_t qsizetype
Definition qtypes.h:165
static ImageSizeParameters calculateImageParameters(qsizetype width, qsizetype height, qsizetype depth)
Definition qimage_p.h:89