Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qimagewriter.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
4/*!
5 \class QImageWriter
6 \brief The QImageWriter class provides a format independent interface
7 for writing images to files or other devices.
8
9 \inmodule QtGui
10 \reentrant
11 \ingroup painting
12
13 QImageWriter supports setting format specific options, such as
14 compression level and quality, prior to storing the
15 image. If you do not need such options, you can use QImage::save()
16 or QPixmap::save() instead.
17
18 To store an image, you start by constructing a QImageWriter
19 object. Pass either a file name or a device pointer, and the
20 image format to QImageWriter's constructor. You can then set
21 several options, such as quality (by calling setQuality()).
22 canWrite() returns \c true if QImageWriter can write the image
23 (i.e., the image format is supported and the device is open for
24 writing). Call write() to write the image to the device.
25
26 If any error occurs when writing the image, write() will return
27 false. You can then call error() to find the type of error that
28 occurred, or errorString() to get a human readable description of
29 what went wrong.
30
31 Call supportedImageFormats() for a list of formats that
32 QImageWriter can write. QImageWriter supports all built-in image
33 formats, in addition to any image format plugins that support
34 writing.
35
36 \note QImageWriter assumes exclusive control over the file or
37 device that is assigned. Any attempts to modify the assigned file
38 or device during the lifetime of the QImageWriter object will
39 yield undefined results. If immediate access to a resource is
40 desired, the use of a scope is the recommended method.
41
42 For example:
43
44 \snippet qimagewriter/main.cpp 0
45
46 \sa QImageReader, QImageIOHandler, QImageIOPlugin, QColorSpace
47*/
48
49/*!
50 \enum QImageWriter::ImageWriterError
51
52 This enum describes errors that can occur when writing images with
53 QImageWriter.
54
55 \value DeviceError QImageWriter encountered a device error when
56 writing the image data. Consult your device for more details on
57 what went wrong.
58
59 \value UnsupportedFormatError Qt does not support the requested
60 image format.
61
62 \value InvalidImageError An attempt was made to write an invalid QImage. An
63 example of an invalid image would be a null QImage.
64
65 \value UnknownError An unknown error occurred. If you get this
66 value after calling write(), it is most likely caused by a bug in
67 QImageWriter.
68*/
69
70#include "qimagewriter.h"
71
72#include <qbytearray.h>
73#include <qfile.h>
74#include <qfileinfo.h>
75#include <qimage.h>
76#include <qimageiohandler.h>
77#include <qset.h>
78#include <qvariant.h>
79#include <qloggingcategory.h>
80
81// factory loader
82#include <qcoreapplication.h>
83#include <private/qfactoryloader_p.h>
84
85// image handlers
86#include <private/qbmphandler_p.h>
87#include <private/qppmhandler_p.h>
88#include <private/qxbmhandler_p.h>
89#include <private/qxpmhandler_p.h>
90#ifndef QT_NO_IMAGEFORMAT_PNG
91#include <private/qpnghandler_p.h>
92#endif
93
94#include <private/qimagereaderwriterhelpers_p.h>
95
96#include <algorithm>
97
98QT_BEGIN_NAMESPACE
99
100Q_STATIC_LOGGING_CATEGORY(lcImageWriter, "qt.gui.imageio.writer")
101
102using namespace Qt::StringLiterals;
103
105 const QByteArray &format)
106{
107 QByteArray form = format.toLower();
108 QByteArray suffix;
109 QImageIOHandler *handler = nullptr;
110
111 qCDebug(lcImageWriter) << "Finding write handler for" << device << "and format" << format;
112
113#ifndef QT_NO_IMAGEFORMATPLUGIN
114 typedef QMultiMap<int, QString> PluginKeyMap;
115
116 // check if any plugins can write the image
117 auto l = QImageReaderWriterHelpers::pluginLoader();
118 const PluginKeyMap keyMap = l->keyMap();
119 int suffixPluginIndex = -1;
120
121 qCDebug(lcImageWriter) << keyMap.uniqueKeys().size() << "plugins available:" << keyMap.values();
122#endif
123
124 if (device && format.isEmpty()) {
125 // if there's no format, see if \a device is a file, and if so, find
126 // the file suffix and find support for that format among our plugins.
127 // this allows plugins to override our built-in handlers.
128 if (QFileDevice *file = qobject_cast<QFileDevice *>(device)) {
129 if (!(suffix = QFileInfo(file->fileName()).suffix().toLower().toLatin1()).isEmpty()) {
130 qCDebug(lcImageWriter) << "Resolved format" << suffix << "from file name suffix";
131#ifndef QT_NO_IMAGEFORMATPLUGIN
132 const int index = keyMap.key(QString::fromLatin1(suffix), -1);
133 if (index != -1)
134 suffixPluginIndex = index;
135#endif
136 }
137 }
138 }
139
140 QByteArray testFormat = !form.isEmpty() ? form : suffix;
141
142#ifndef QT_NO_IMAGEFORMATPLUGIN
143 if (suffixPluginIndex != -1) {
144 // when format is missing, check if we can find a plugin for the
145 // suffix.
146 qCDebug(lcImageWriter) << "Checking if any plugins have explicitly declared support"
147 << "for the format" << testFormat;
148 const int index = keyMap.key(QString::fromLatin1(suffix), -1);
149 if (index != -1) {
150 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(index));
151 if (plugin && (plugin->capabilities(device, suffix) & QImageIOPlugin::CanWrite)) {
152 handler = plugin->create(device, suffix);
153 qCDebug(lcImageWriter) << plugin << "can write the format" << testFormat;
154 }
155 }
156 }
157#endif // QT_NO_IMAGEFORMATPLUGIN
158
159 // check if any built-in handlers can write the image
160 if (!handler && !testFormat.isEmpty()) {
161 qCDebug(lcImageWriter) << "Checking if any built in handlers recognize the format"
162 << testFormat;
163 if (false) {
164#ifndef QT_NO_IMAGEFORMAT_PNG
165 } else if (testFormat == "png") {
166 handler = new QPngHandler;
167#endif
168#ifndef QT_NO_IMAGEFORMAT_BMP
169 } else if (testFormat == "bmp") {
170 handler = new QBmpHandler;
171 } else if (testFormat == "dib") {
172 handler = new QBmpHandler(QBmpHandler::DibFormat);
173#endif
174#ifndef QT_NO_IMAGEFORMAT_XPM
175 } else if (testFormat == "xpm") {
176 handler = new QXpmHandler;
177#endif
178#ifndef QT_NO_IMAGEFORMAT_XBM
179 } else if (testFormat == "xbm") {
180 handler = new QXbmHandler;
181 handler->setOption(QImageIOHandler::SubType, testFormat);
182#endif
183#ifndef QT_NO_IMAGEFORMAT_PPM
184 } else if (testFormat == "pbm" || testFormat == "pbmraw" || testFormat == "pgm"
185 || testFormat == "pgmraw" || testFormat == "ppm" || testFormat == "ppmraw") {
186 handler = new QPpmHandler;
187 handler->setOption(QImageIOHandler::SubType, testFormat);
188#endif
189 }
190
191 if (handler)
192 qCDebug(lcImageWriter) << "Using the built-in handler for format" << testFormat;
193 }
194
195#ifndef QT_NO_IMAGEFORMATPLUGIN
196 if (!handler && !testFormat.isEmpty()) {
197 qCDebug(lcImageWriter) << "Checking if any plugins recognize the format" << testFormat;
198 const int keyCount = keyMap.size();
199 for (int i = 0; i < keyCount; ++i) {
200 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i));
201 if (plugin && (plugin->capabilities(device, testFormat) & QImageIOPlugin::CanWrite)) {
202 handler = plugin->create(device, testFormat);
203 qCDebug(lcImageWriter) << plugin << "can write the format" << testFormat;
204 break;
205 }
206 }
207 }
208#endif // QT_NO_IMAGEFORMATPLUGIN
209
210 if (!handler) {
211 qCDebug(lcImageWriter, "No handlers found. Giving up.");
212 return nullptr;
213 }
214
215 handler->setDevice(device);
216 if (!testFormat.isEmpty())
217 handler->setFormat(testFormat);
218 return handler;
219}
220
251
252/*!
253 \internal
254*/
256{
257 device = nullptr;
258 deleteDevice = false;
259 handler = nullptr;
260 quality = -1;
261 compression = -1;
262 gamma = 0.0;
263 optimizedWrite = false;
264 progressiveScanWrite = false;
265 imageWriterError = QImageWriter::UnknownError;
266 errorString = QImageWriter::tr("Unknown error");
267 transformation = QImageIOHandler::TransformationNone;
268
269 q = qq;
270}
271
273{
274 if (!device) {
275 imageWriterError = QImageWriter::DeviceError;
276 errorString = QImageWriter::tr("Device is not set");
277 return false;
278 }
279 if (!device->isOpen()) {
280 if (!device->open(QIODevice::WriteOnly)) {
281 imageWriterError = QImageWriter::DeviceError;
282 errorString = QImageWriter::tr("Cannot open device for writing: %1").arg(device->errorString());
283 return false;
284 }
285 }
286 if (!device->isWritable()) {
287 imageWriterError = QImageWriter::DeviceError;
288 errorString = QImageWriter::tr("Device not writable");
289 return false;
290 }
291 if (!handler && (handler = createWriteHandlerHelper(device, format)) == nullptr) {
292 imageWriterError = QImageWriter::UnsupportedFormatError;
293 errorString = QImageWriter::tr("Unsupported image format");
294 return false;
295 }
296 return true;
297}
298
299/*!
300 Constructs an empty QImageWriter object. Before writing, you must
301 call setFormat() to set an image format, then setDevice() or
302 setFileName().
303*/
304QImageWriter::QImageWriter()
305 : d(new QImageWriterPrivate(this))
306{
307}
308
309/*!
310 Constructs a QImageWriter object using the device \a device and
311 image format \a format.
312*/
313QImageWriter::QImageWriter(QIODevice *device, const QByteArray &format)
314 : d(new QImageWriterPrivate(this))
315{
316 d->device = device;
317 d->format = format;
318}
319
320/*!
321 Constructs a QImageWriter objects that will write to a file with
322 the name \a fileName, using the image format \a format. If \a
323 format is not provided, QImageWriter will detect the image format
324 by inspecting the extension of \a fileName.
325*/
326QImageWriter::QImageWriter(const QString &fileName, const QByteArray &format)
327 : QImageWriter(new QFile(fileName), format)
328{
329 d->deleteDevice = true;
330}
331
332/*!
333 Destructs the QImageWriter object.
334*/
335QImageWriter::~QImageWriter()
336{
337 delete d->handler;
338 if (d->deleteDevice)
339 delete d->device;
340 delete d;
341}
342
343/*!
344 Sets the format QImageWriter will use when writing images, to \a
345 format. \a format is a case insensitive text string. Example:
346
347 \snippet code/src_gui_image_qimagewriter.cpp 0
348
349 You can call supportedImageFormats() for the full list of formats
350 QImageWriter supports.
351
352 \sa format()
353*/
354void QImageWriter::setFormat(const QByteArray &format)
355{
356 d->format = format;
357}
358
359/*!
360 Returns the format QImageWriter uses for writing images.
361
362 \sa setFormat()
363*/
364QByteArray QImageWriter::format() const
365{
366 return d->format;
367}
368
369/*!
370 Sets QImageWriter's device to \a device. If a device has already
371 been set, the old device is removed from QImageWriter and is
372 otherwise left unchanged.
373
374 If the device is not already open, QImageWriter will attempt to
375 open the device in \l QIODeviceBase::WriteOnly mode by calling
376 open(). Note that this does not work for certain devices, such as
377 QProcess, QTcpSocket and QUdpSocket, where more logic is required
378 to open the device.
379
380 \sa device(), setFileName()
381*/
382void QImageWriter::setDevice(QIODevice *device)
383{
384 delete d->handler;
385 d->handler = nullptr;
386 if (d->device && d->deleteDevice)
387 delete d->device;
388
389 d->device = device;
390 d->deleteDevice = false;
391}
392
393/*!
394 Returns the device currently assigned to QImageWriter, or \nullptr
395 if no device has been assigned.
396*/
397QIODevice *QImageWriter::device() const
398{
399 return d->device;
400}
401
402/*!
403 Sets the file name of QImageWriter to \a fileName. Internally,
404 QImageWriter will create a QFile and open it in \l
405 QIODevice::WriteOnly mode, and use this file when writing images.
406
407 \sa fileName(), setDevice()
408*/
409void QImageWriter::setFileName(const QString &fileName)
410{
411 setDevice(new QFile(fileName));
412 d->deleteDevice = true;
413}
414
415/*!
416 If the currently assigned device is a file, or if setFileName()
417 has been called, this function returns the name of the file
418 QImageWriter writes to. Otherwise (i.e., if no device has been
419 assigned or the device is not a file), an empty QString is
420 returned.
421
422 \sa setFileName(), setDevice()
423*/
424QString QImageWriter::fileName() const
425{
426 QFileDevice *file = qobject_cast<QFileDevice *>(d->device);
427 return file ? file->fileName() : QString();
428}
429
430/*!
431 Sets the quality setting of the image format to \a quality.
432
433 Some image formats, in particular lossy ones, entail a tradeoff between a)
434 visual quality of the resulting image, and b) encoding execution time and
435 compression level. This function sets the level of that tradeoff for image
436 formats that support it. For other formats, this value is ignored.
437
438 The value range of \a quality depends on the image format. For example,
439 the "jpeg" format supports a quality range from 0 (low visual quality, high
440 compression) to 100 (high visual quality, low compression).
441
442 \sa quality()
443*/
444void QImageWriter::setQuality(int quality)
445{
446 d->quality = quality;
447}
448
449/*!
450 Returns the quality setting of the image format.
451
452 \sa setQuality()
453*/
454int QImageWriter::quality() const
455{
456 return d->quality;
457}
458
459/*!
460 This is an image format specific function that set the compression
461 of an image. For image formats that do not support setting the
462 compression, this value is ignored.
463
464 The value range of \a compression depends on the image format. For
465 example, the "tiff" format supports two values, 0(no compression) and
466 1(LZW-compression).
467
468 \sa compression()
469*/
470void QImageWriter::setCompression(int compression)
471{
472 d->compression = compression;
473}
474
475/*!
476 Returns the compression of the image.
477
478 \sa setCompression()
479*/
480int QImageWriter::compression() const
481{
482 return d->compression;
483}
484
485/*!
486 \since 5.4
487
488 This is an image format specific function that sets the
489 subtype of the image to \a type. Subtype can be used by
490 a handler to determine which format it should use while
491 saving the image.
492
493 For example, saving an image in DDS format with A8R8G8R8 subtype:
494
495 \snippet code/src_gui_image_qimagewriter.cpp 3
496*/
497void QImageWriter::setSubType(const QByteArray &type)
498{
499 d->subType = type;
500}
501
502/*!
503 \since 5.4
504
505 Returns the subtype of the image.
506
507 \sa setSubType()
508*/
509QByteArray QImageWriter::subType() const
510{
511 return d->subType;
512}
513
514/*!
515 \since 5.4
516
517 Returns the list of subtypes supported by an image.
518*/
519QList<QByteArray> QImageWriter::supportedSubTypes() const
520{
521 if (!supportsOption(QImageIOHandler::SupportedSubTypes))
522 return QList<QByteArray>();
523 return qvariant_cast<QList<QByteArray> >(d->handler->option(QImageIOHandler::SupportedSubTypes));
524}
525
526/*!
527 \since 5.5
528
529 This is an image format-specific function which sets the \a optimize flags when
530 writing images. For image formats that do not support setting an \a optimize flag,
531 this value is ignored.
532
533 The default is false.
534
535 \sa optimizedWrite()
536*/
537void QImageWriter::setOptimizedWrite(bool optimize)
538{
539 d->optimizedWrite = optimize;
540}
541
542/*!
543 \since 5.5
544
545 Returns whether optimization has been turned on for writing the image.
546
547 \sa setOptimizedWrite()
548*/
549bool QImageWriter::optimizedWrite() const
550{
551 return d->optimizedWrite;
552}
553
554/*!
555 \since 5.5
556
557 This is an image format-specific function which turns on \a progressive scanning
558 when writing images. For image formats that do not support setting a \a progressive
559 scan flag, this value is ignored.
560
561 The default is false.
562
563 \sa progressiveScanWrite()
564*/
565
566void QImageWriter::setProgressiveScanWrite(bool progressive)
567{
568 d->progressiveScanWrite = progressive;
569}
570
571/*!
572 \since 5.5
573
574 Returns whether the image should be written as a progressive image.
575
576 \sa setProgressiveScanWrite()
577*/
578bool QImageWriter::progressiveScanWrite() const
579{
580 return d->progressiveScanWrite;
581}
582
583/*!
584 \since 5.5
585
586 Sets the image transformations metadata including orientation to \a transform.
587
588 If transformation metadata is not supported by the image format,
589 the transform is applied before writing.
590
591 \sa transformation(), write()
592*/
593void QImageWriter::setTransformation(QImageIOHandler::Transformations transform)
594{
595 d->transformation = transform;
596}
597
598/*!
599 \since 5.5
600
601 Returns the transformation and orientation the image has been set to written with.
602
603 \sa setTransformation()
604*/
605QImageIOHandler::Transformations QImageWriter::transformation() const
606{
607 return d->transformation;
608}
609
610/*!
611 Sets the image text associated with the key \a key to
612 \a text. This is useful for storing copyright information
613 or other information about the image. Example:
614
615 \snippet code/src_gui_image_qimagewriter.cpp 1
616
617 If you want to store a single block of data
618 (e.g., a comment), you can pass an empty key, or use
619 a generic key like "Description".
620
621 The key and text will be embedded into the
622 image data after calling write().
623
624 Support for this option is implemented through
625 QImageIOHandler::Description.
626
627 \sa QImage::setText(), QImageReader::text()
628*/
629void QImageWriter::setText(const QString &key, const QString &text)
630{
631 if (!d->description.isEmpty())
632 d->description += "\n\n"_L1;
633 d->description += key.simplified() + ": "_L1 + text.simplified();
634}
635
636/*!
637 Returns \c true if QImageWriter can write the image; i.e., the image
638 format is supported and the assigned device is open for reading.
639
640 \sa write(), setDevice(), setFormat()
641*/
642bool QImageWriter::canWrite() const
643{
644 if (QFile *file = qobject_cast<QFile *>(d->device)) {
645 const bool remove = !file->isOpen() && !file->exists();
646 const bool result = d->canWriteHelper();
647
648 // This looks strange (why remove if it doesn't exist?) but the issue
649 // here is that canWriteHelper will create the file in the process of
650 // checking if the write can succeed. If it subsequently fails, we
651 // should remove that empty file.
652 if (!result && remove)
653 file->remove();
654 return result;
655 }
656
657 return d->canWriteHelper();
658}
659
660extern void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient);
661
662/*!
663 Writes the image \a image to the assigned device or file
664 name. Returns \c true on success; otherwise returns \c false. If the
665 operation fails, you can call error() to find the type of error
666 that occurred, or errorString() to get a human readable
667 description of the error.
668
669 \sa canWrite(), error(), errorString()
670*/
671bool QImageWriter::write(const QImage &image)
672{
673 // Do this before canWrite, so it doesn't create a file if this fails.
674 if (Q_UNLIKELY(image.isNull())) {
675 d->imageWriterError = QImageWriter::InvalidImageError;
676 d->errorString = QImageWriter::tr("Image is empty");
677 return false;
678 }
679
680 if (!canWrite())
681 return false;
682
683 QImage img = image;
684 if (d->handler->supportsOption(QImageIOHandler::Quality))
685 d->handler->setOption(QImageIOHandler::Quality, d->quality);
686 if (d->handler->supportsOption(QImageIOHandler::CompressionRatio))
687 d->handler->setOption(QImageIOHandler::CompressionRatio, d->compression);
688 if (d->handler->supportsOption(QImageIOHandler::Gamma))
689 d->handler->setOption(QImageIOHandler::Gamma, d->gamma);
690 if (!d->description.isEmpty() && d->handler->supportsOption(QImageIOHandler::Description))
691 d->handler->setOption(QImageIOHandler::Description, d->description);
692 if (!d->subType.isEmpty() && d->handler->supportsOption(QImageIOHandler::SubType))
693 d->handler->setOption(QImageIOHandler::SubType, d->subType);
694 if (d->handler->supportsOption(QImageIOHandler::OptimizedWrite))
695 d->handler->setOption(QImageIOHandler::OptimizedWrite, d->optimizedWrite);
696 if (d->handler->supportsOption(QImageIOHandler::ProgressiveScanWrite))
697 d->handler->setOption(QImageIOHandler::ProgressiveScanWrite, d->progressiveScanWrite);
698 if (d->handler->supportsOption(QImageIOHandler::ImageTransformation))
699 d->handler->setOption(QImageIOHandler::ImageTransformation, int(d->transformation));
700 else
701 qt_imageTransform(img, d->transformation);
702
703 if (!d->handler->write(img))
704 return false;
705 if (QFileDevice *file = qobject_cast<QFileDevice *>(d->device))
706 file->flush();
707 return true;
708}
709
710/*!
711 Returns the type of error that last occurred.
712
713 \sa ImageWriterError, errorString()
714*/
715QImageWriter::ImageWriterError QImageWriter::error() const
716{
717 return d->imageWriterError;
718}
719
720/*!
721 Returns a human readable description of the last error that occurred.
722
723 \sa error()
724*/
725QString QImageWriter::errorString() const
726{
727 return d->errorString;
728}
729
730/*!
731 Returns \c true if the writer supports \a option; otherwise returns
732 false.
733
734 Different image formats support different options. Call this function to
735 determine whether a certain option is supported by the current format. For
736 example, the PNG format allows you to embed text into the image's metadata
737 (see text()).
738
739 \snippet code/src_gui_image_qimagewriter.cpp 2
740
741 Options can be tested after the writer has been associated with a format.
742
743 \sa QImageReader::supportsOption(), setFormat()
744*/
745bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const
746{
747 if (!d->handler && (d->handler = createWriteHandlerHelper(d->device, d->format)) == nullptr) {
748 d->imageWriterError = QImageWriter::UnsupportedFormatError;
749 d->errorString = QImageWriter::tr("Unsupported image format");
750 return false;
751 }
752
753 return d->handler->supportsOption(option);
754}
755
756/*!
757 Returns the list of image formats supported by QImageWriter.
758
759 By default, Qt can write the following formats:
760
761 \table
762 \header \li Format \li MIME type \li Description
763 \row \li BMP \li image/bmp \li Windows Bitmap
764 \row \li JPG \li image/jpeg \li Joint Photographic Experts Group
765 \row \li PNG \li image/png \li Portable Network Graphics
766 \row \li PBM \li image/x-portable-bitmap \li Portable Bitmap
767 \row \li PGM \li image/x-portable-graymap \li Portable Graymap
768 \row \li PPM \li image/x-portable-pixmap \li Portable Pixmap
769 \row \li XBM \li image/x-xbitmap \li X11 Bitmap
770 \row \li XPM \li image/x-xpixmap \li X11 Pixmap
771 \endtable
772
773 Reading and writing SVG files is supported through the \l{Qt SVG} module.
774 The \l{Qt Image Formats} module provides support for additional image formats.
775
776 Note that the QApplication instance must be created before this function is
777 called.
778
779 \sa setFormat(), QImageReader::supportedImageFormats(), QImageIOPlugin
780*/
781QList<QByteArray> QImageWriter::supportedImageFormats()
782{
783 return QImageReaderWriterHelpers::supportedImageFormats(QImageReaderWriterHelpers::CanWrite);
784}
785
786/*!
787 Returns the list of MIME types supported by QImageWriter.
788
789 Note that the QApplication instance must be created before this function is
790 called.
791
792 \sa supportedImageFormats(), QImageReader::supportedMimeTypes()
793*/
794QList<QByteArray> QImageWriter::supportedMimeTypes()
795{
796 return QImageReaderWriterHelpers::supportedMimeTypes(QImageReaderWriterHelpers::CanWrite);
797}
798
799/*!
800 \since 5.12
801
802 Returns the list of image formats corresponding to \a mimeType.
803
804 Note that the QGuiApplication instance must be created before this function is
805 called.
806
807 \sa supportedImageFormats(), supportedMimeTypes()
808*/
809
810QList<QByteArray> QImageWriter::imageFormatsForMimeType(const QByteArray &mimeType)
811{
812 return QImageReaderWriterHelpers::imageFormatsForMimeType(mimeType,
813 QImageReaderWriterHelpers::CanWrite);
814}
815
816QT_END_NAMESPACE
QImageWriterPrivate(QImageWriter *qq)
QImageIOHandler * handler
Definition qcompare.h:76
Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient)
Definition qimage.cpp:6516
static QImageIOHandler * createWriteHandlerHelper(QIODevice *device, const QByteArray &format)
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)