qimagewriter.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/image/qimagewriter.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10namespace { namespace Q_QGS_loader { typedef QFactoryLoader Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
never executed: guard.store(QtGlobalStatic::Destroyed);
}
never executed: end of block
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ("org.qt-project.Qt.QImageIOHandlerFactoryInterface", QLatin1String("/imageformats")))) : value ("org.qt-project.Qt.QImageIOHandlerFactoryInterface", QLatin1String("/imageformats")) { guard.store(QtGlobalStatic::Initialized); } } holder; return
never executed: return &holder.value;
&holder.value;
never executed: return &holder.value;
} } } static QGlobalStatic<QFactoryLoader, Q_QGS_loader::innerFunction, Q_QGS_loader::guard> loader;
0
11-
12-
13-
14static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,-
15 const QByteArray &format)-
16{-
17 QByteArray form = format.toLower();-
18 QByteArray suffix;-
19 QImageIOHandler *handler = 0;-
20-
21-
22 typedef QMultiMap<int, QString> PluginKeyMap;-
23-
24-
25 QFactoryLoader *l = loader();-
26 const PluginKeyMap keyMap = l->keyMap();-
27 int suffixPluginIndex = -1;-
28-
29-
30 if (device
deviceDescription
TRUEnever evaluated
FALSEnever evaluated
&& format.isEmpty()
format.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
31-
32-
33-
34 if (QFile *file = qobject_cast<QFile *>(device)
QFile *file = ...ile *>(device)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
35 if (!(suffix = QFileInfo(file->fileName()).suffix().toLower().toLatin1()).isEmpty()
!(suffix = QFi...1()).isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
36-
37 const int index = keyMap.key(QString::fromLatin1(suffix), -1);-
38 if (index != -1
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
39 suffixPluginIndex = index;
never executed: suffixPluginIndex = index;
0
40-
41 }
never executed: end of block
0
42 }
never executed: end of block
0
43 }
never executed: end of block
0
44-
45 QByteArray testFormat = !form.isEmpty()
!form.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
? form : suffix;
0
46-
47-
48 if (suffixPluginIndex != -1
suffixPluginIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
49-
50-
51 const int index = keyMap.key(QString::fromLatin1(suffix), -1);-
52 if (index != -1
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
53 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(index));-
54 if (plugin
pluginDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(plugin->capab...gin::CanWrite)Description
TRUEnever evaluated
FALSEnever evaluated
plugin->capabilities(device, suffix) & QImageIOPlugin::CanWrite)
(plugin->capab...gin::CanWrite)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
55 handler = plugin->create(device, suffix);
never executed: handler = plugin->create(device, suffix);
0
56 }
never executed: end of block
0
57 }
never executed: end of block
0
58-
59-
60-
61 if (!handler
!handlerDescription
TRUEnever evaluated
FALSEnever evaluated
&& !testFormat.isEmpty()
!testFormat.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
62 if (false) {
dead code: { }
-
63-
64 }
dead code: { }
else if (testFormat == "png"
testFormat == "png"Description
TRUEnever evaluated
FALSEnever evaluated
) {
-
65 handler = new QPngHandler;-
66 }
never executed: end of block
else if (testFormat == "bmp"
testFormat == "bmp"Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
67 handler = new QBmpHandler;-
68 }
never executed: end of block
else if (testFormat == "dib"
testFormat == "dib"Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
69 handler = new QBmpHandler(QBmpHandler::DibFormat);-
70-
71-
72 }
never executed: end of block
else if (testFormat == "xpm"
testFormat == "xpm"Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
73 handler = new QXpmHandler;-
74-
75-
76 }
never executed: end of block
else if (testFormat == "xbm"
testFormat == "xbm"Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
77 handler = new QXbmHandler;-
78 handler->setOption(QImageIOHandler::SubType, testFormat);-
79-
80-
81 }
never executed: end of block
else if (testFormat == "pbm"
testFormat == "pbm"Description
TRUEnever evaluated
FALSEnever evaluated
|| testFormat == "pbmraw"
testFormat == "pbmraw"Description
TRUEnever evaluated
FALSEnever evaluated
|| testFormat == "pgm"
testFormat == "pgm"Description
TRUEnever evaluated
FALSEnever evaluated
0
82 || testFormat == "pgmraw"
testFormat == "pgmraw"Description
TRUEnever evaluated
FALSEnever evaluated
|| testFormat == "ppm"
testFormat == "ppm"Description
TRUEnever evaluated
FALSEnever evaluated
|| testFormat == "ppmraw"
testFormat == "ppmraw"Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
83 handler = new QPpmHandler;-
84 handler->setOption(QImageIOHandler::SubType, testFormat);-
85-
86 }
never executed: end of block
0
87 }
never executed: end of block
0
88-
89-
90 if (!testFormat.isEmpty()
!testFormat.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
91 const int keyCount = keyMap.size();-
92 for (int i = 0; i < keyCount
i < keyCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
93 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i));-
94 if (plugin
pluginDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(plugin->capab...gin::CanWrite)Description
TRUEnever evaluated
FALSEnever evaluated
plugin->capabilities(device, testFormat) & QImageIOPlugin::CanWrite)
(plugin->capab...gin::CanWrite)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
95 delete handler;-
96 handler = plugin->create(device, testFormat);-
97 break;
never executed: break;
0
98 }-
99 }
never executed: end of block
0
100 }
never executed: end of block
0
101-
102-
103 if (!handler
!handlerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
104 return
never executed: return 0;
0;
never executed: return 0;
0
105-
106 handler->setDevice(device);-
107 if (!testFormat.isEmpty()
!testFormat.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
108 handler->setFormat(testFormat);
never executed: handler->setFormat(testFormat);
0
109 return
never executed: return handler;
handler;
never executed: return handler;
0
110}-
111-
112class QImageWriterPrivate-
113{-
114public:-
115 QImageWriterPrivate(QImageWriter *qq);-
116-
117 bool canWriteHelper();-
118-
119-
120 QByteArray format;-
121 QIODevice *device;-
122 bool deleteDevice;-
123 QImageIOHandler *handler;-
124-
125-
126 int quality;-
127 int compression;-
128 float gamma;-
129 QString description;-
130 QString text;-
131 QByteArray subType;-
132 bool optimizedWrite;-
133 bool progressiveScanWrite;-
134 QImageIOHandler::Transformations transformation;-
135-
136-
137 QImageWriter::ImageWriterError imageWriterError;-
138 QString errorString;-
139-
140 QImageWriter *q;-
141};-
142-
143-
144-
145-
146QImageWriterPrivate::QImageWriterPrivate(QImageWriter *qq)-
147{-
148 device = 0;-
149 deleteDevice = false;-
150 handler = 0;-
151 quality = -1;-
152 compression = 0;-
153 gamma = 0.0;-
154 optimizedWrite = false;-
155 progressiveScanWrite = false;-
156 imageWriterError = QImageWriter::UnknownError;-
157 errorString = QImageWriter::tr("Unknown error");-
158 transformation = QImageIOHandler::TransformationNone;-
159-
160 q = qq;-
161}
never executed: end of block
0
162-
163bool QImageWriterPrivate::canWriteHelper()-
164{-
165 if (!device
!deviceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
166 imageWriterError = QImageWriter::DeviceError;-
167 errorString = QImageWriter::tr("Device is not set");-
168 return
never executed: return false;
false;
never executed: return false;
0
169 }-
170 if (!device->isOpen()
!device->isOpen()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
171 device->open(QIODevice::WriteOnly);
never executed: device->open(QIODevice::WriteOnly);
0
172 if (!device->isWritable()
!device->isWritable()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
173 imageWriterError = QImageWriter::DeviceError;-
174 errorString = QImageWriter::tr("Device not writable");-
175 return
never executed: return false;
false;
never executed: return false;
0
176 }-
177 if (!handler
!handlerDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(handler = cre... format)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
handler = createWriteHandlerHelper(device, format)) == 0
(handler = cre... format)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
178 imageWriterError = QImageWriter::UnsupportedFormatError;-
179 errorString = QImageWriter::tr("Unsupported image format");-
180 return
never executed: return false;
false;
never executed: return false;
0
181 }-
182 return
never executed: return true;
true;
never executed: return true;
0
183}-
184-
185-
186-
187-
188-
189-
190QImageWriter::QImageWriter()-
191 : d(new QImageWriterPrivate(this))-
192{-
193}
never executed: end of block
0
194-
195-
196-
197-
198-
199QImageWriter::QImageWriter(QIODevice *device, const QByteArray &format)-
200 : d(new QImageWriterPrivate(this))-
201{-
202 d->device = device;-
203 d->format = format;-
204}
never executed: end of block
0
205-
206-
207-
208-
209-
210-
211-
212QImageWriter::QImageWriter(const QString &fileName, const QByteArray &format)-
213 : d(new QImageWriterPrivate(this))-
214{-
215 QFile *file = new QFile(fileName);-
216 d->device = file;-
217 d->deleteDevice = true;-
218 d->format = format;-
219}
never executed: end of block
0
220-
221-
222-
223-
224QImageWriter::~QImageWriter()-
225{-
226 if (d->deleteDevice
d->deleteDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
227 delete d->device;
never executed: delete d->device;
0
228 delete d->handler;-
229 delete d;-
230}
never executed: end of block
0
231void QImageWriter::setFormat(const QByteArray &format)-
232{-
233 d->format = format;-
234}
never executed: end of block
0
235-
236-
237-
238-
239-
240-
241QByteArray QImageWriter::format() const-
242{-
243 return
never executed: return d->format;
d->format;
never executed: return d->format;
0
244}-
245void QImageWriter::setDevice(QIODevice *device)-
246{-
247 if (d->device
d->deviceDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->deleteDevice
d->deleteDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
248 delete d->device;
never executed: delete d->device;
0
249-
250 d->device = device;-
251 d->deleteDevice = false;-
252 delete d->handler;-
253 d->handler = 0;-
254}
never executed: end of block
0
255-
256-
257-
258-
259-
260QIODevice *QImageWriter::device() const-
261{-
262 return
never executed: return d->device;
d->device;
never executed: return d->device;
0
263}-
264void QImageWriter::setFileName(const QString &fileName)-
265{-
266 setDevice(new QFile(fileName));-
267 d->deleteDevice = true;-
268}
never executed: end of block
0
269QString QImageWriter::fileName() const-
270{-
271 QFile *file = qobject_cast<QFile *>(d->device);-
272 return
never executed: return file ? file->fileName() : QString();
file ? file->fileName() : QString();
never executed: return file ? file->fileName() : QString();
0
273}-
274void QImageWriter::setQuality(int quality)-
275{-
276 d->quality = quality;-
277}
never executed: end of block
0
278-
279-
280-
281-
282-
283-
284int QImageWriter::quality() const-
285{-
286 return
never executed: return d->quality;
d->quality;
never executed: return d->quality;
0
287}-
288void QImageWriter::setCompression(int compression)-
289{-
290 d->compression = compression;-
291}
never executed: end of block
0
292-
293-
294-
295-
296-
297-
298int QImageWriter::compression() const-
299{-
300 return
never executed: return d->compression;
d->compression;
never executed: return d->compression;
0
301}-
302void QImageWriter::setGamma(float gamma)-
303{-
304 d->gamma = gamma;-
305}
never executed: end of block
0
306-
307-
308-
309-
310-
311-
312float QImageWriter::gamma() const-
313{-
314 return
never executed: return d->gamma;
d->gamma;
never executed: return d->gamma;
0
315}-
316void QImageWriter::setSubType(const QByteArray &type)-
317{-
318 d->subType = type;-
319}
never executed: end of block
0
320QByteArray QImageWriter::subType() const-
321{-
322 return
never executed: return d->subType;
d->subType;
never executed: return d->subType;
0
323}-
324-
325-
326-
327-
328-
329-
330QList<QByteArray> QImageWriter::supportedSubTypes() const-
331{-
332 if (!supportsOption(QImageIOHandler::SupportedSubTypes)
!supportsOptio...ortedSubTypes)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
333 return
never executed: return QList<QByteArray>();
QList<QByteArray>();
never executed: return QList<QByteArray>();
0
334 return
never executed: return d->handler->option(QImageIOHandler::SupportedSubTypes).value< QList<QByteArray> >();
d->handler->option(QImageIOHandler::SupportedSubTypes).value< QList<QByteArray> >();
never executed: return d->handler->option(QImageIOHandler::SupportedSubTypes).value< QList<QByteArray> >();
0
335}-
336void QImageWriter::setOptimizedWrite(bool optimize)-
337{-
338 d->optimizedWrite = optimize;-
339}
never executed: end of block
0
340bool QImageWriter::optimizedWrite() const-
341{-
342 return
never executed: return d->optimizedWrite;
d->optimizedWrite;
never executed: return d->optimizedWrite;
0
343}-
344void QImageWriter::setProgressiveScanWrite(bool progressive)-
345{-
346 d->progressiveScanWrite = progressive;-
347}
never executed: end of block
0
348bool QImageWriter::progressiveScanWrite() const-
349{-
350 return
never executed: return d->progressiveScanWrite;
d->progressiveScanWrite;
never executed: return d->progressiveScanWrite;
0
351}-
352void QImageWriter::setTransformation(QImageIOHandler::Transformations transform)-
353{-
354 d->transformation = transform;-
355}
never executed: end of block
0
356QImageIOHandler::Transformations QImageWriter::transformation() const-
357{-
358 return
never executed: return d->transformation;
d->transformation;
never executed: return d->transformation;
0
359}-
360void QImageWriter::setDescription(const QString &description)-
361{-
362 d->description = description;-
363}
never executed: end of block
0
364QString QImageWriter::description() const-
365{-
366 return
never executed: return d->description;
d->description;
never executed: return d->description;
0
367}-
368void QImageWriter::setText(const QString &key, const QString &text)-
369{-
370 if (!d->description.isEmpty()
!d->description.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
371 d->description += QLatin1String("\n\n");
never executed: d->description += QLatin1String("\n\n");
0
372 d->description += key.simplified() + QLatin1String(": ") + text.simplified();-
373}
never executed: end of block
0
374-
375-
376-
377-
378-
379-
380-
381bool QImageWriter::canWrite() const-
382{-
383 if (QFile *file = qobject_cast<QFile *>(d->device)
QFile *file = ... *>(d->device)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
384 const bool remove = !file->isOpen()
!file->isOpen()Description
TRUEnever evaluated
FALSEnever evaluated
&& !file->exists()
!file->exists()Description
TRUEnever evaluated
FALSEnever evaluated
;
0
385 const bool result = d->canWriteHelper();-
386 if (!result
!resultDescription
TRUEnever evaluated
FALSEnever evaluated
&& remove
removeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
387 file->remove();
never executed: file->remove();
0
388 return
never executed: return result;
result;
never executed: return result;
0
389 }-
390-
391 return
never executed: return d->canWriteHelper();
d->canWriteHelper();
never executed: return d->canWriteHelper();
0
392}-
393-
394extern void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient);-
395bool QImageWriter::write(const QImage &image)-
396{-
397 if (!canWrite()
!canWrite()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
398 return
never executed: return false;
false;
never executed: return false;
0
399-
400 QImage img = image;-
401 if (d->handler->supportsOption(QImageIOHandler::Quality)
d->handler->su...dler::Quality)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
402 d->handler->setOption(QImageIOHandler::Quality, d->quality);
never executed: d->handler->setOption(QImageIOHandler::Quality, d->quality);
0
403 if (d->handler->supportsOption(QImageIOHandler::CompressionRatio)
d->handler->su...pressionRatio)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
404 d->handler->setOption(QImageIOHandler::CompressionRatio, d->compression);
never executed: d->handler->setOption(QImageIOHandler::CompressionRatio, d->compression);
0
405 if (d->handler->supportsOption(QImageIOHandler::Gamma)
d->handler->su...andler::Gamma)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
406 d->handler->setOption(QImageIOHandler::Gamma, d->gamma);
never executed: d->handler->setOption(QImageIOHandler::Gamma, d->gamma);
0
407 if (!d->description.isEmpty()
!d->description.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->handler->supportsOption(QImageIOHandler::Description)
d->handler->su...::Description)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
408 d->handler->setOption(QImageIOHandler::Description, d->description);
never executed: d->handler->setOption(QImageIOHandler::Description, d->description);
0
409 if (!d->subType.isEmpty()
!d->subType.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->handler->supportsOption(QImageIOHandler::SubType)
d->handler->su...dler::SubType)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
410 d->handler->setOption(QImageIOHandler::SubType, d->subType);
never executed: d->handler->setOption(QImageIOHandler::SubType, d->subType);
0
411 if (d->handler->supportsOption(QImageIOHandler::OptimizedWrite)
d->handler->su...ptimizedWrite)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
412 d->handler->setOption(QImageIOHandler::OptimizedWrite, d->optimizedWrite);
never executed: d->handler->setOption(QImageIOHandler::OptimizedWrite, d->optimizedWrite);
0
413 if (d->handler->supportsOption(QImageIOHandler::ProgressiveScanWrite)
d->handler->su...siveScanWrite)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
414 d->handler->setOption(QImageIOHandler::ProgressiveScanWrite, d->progressiveScanWrite);
never executed: d->handler->setOption(QImageIOHandler::ProgressiveScanWrite, d->progressiveScanWrite);
0
415 if (d->handler->supportsOption(QImageIOHandler::ImageTransformation)
d->handler->su...ransformation)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
416 d->handler->setOption(QImageIOHandler::ImageTransformation, int(d->transformation));
never executed: d->handler->setOption(QImageIOHandler::ImageTransformation, int(d->transformation));
0
417 else-
418 qt_imageTransform(img, d->transformation);
never executed: qt_imageTransform(img, d->transformation);
0
419-
420 if (!d->handler->write(img)
!d->handler->write(img)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
421 return
never executed: return false;
false;
never executed: return false;
0
422 if (QFile *file = qobject_cast<QFile *>(d->device)
QFile *file = ... *>(d->device)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
423 file->flush();
never executed: file->flush();
0
424 return
never executed: return true;
true;
never executed: return true;
0
425}-
426-
427-
428-
429-
430-
431-
432QImageWriter::ImageWriterError QImageWriter::error() const-
433{-
434 return
never executed: return d->imageWriterError;
d->imageWriterError;
never executed: return d->imageWriterError;
0
435}-
436-
437-
438-
439-
440-
441-
442QString QImageWriter::errorString() const-
443{-
444 return
never executed: return d->errorString;
d->errorString;
never executed: return d->errorString;
0
445}-
446bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const-
447{-
448 if (!d->handler
!d->handlerDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(d->handler = ...>format)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
d->handler = createWriteHandlerHelper(d->device, d->format)) == 0
(d->handler = ...>format)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
449 d->imageWriterError = QImageWriter::UnsupportedFormatError;-
450 d->errorString = QImageWriter::tr("Unsupported image format");-
451 return
never executed: return false;
false;
never executed: return false;
0
452 }-
453-
454 return
never executed: return d->handler->supportsOption(option);
d->handler->supportsOption(option);
never executed: return d->handler->supportsOption(option);
0
455}-
456-
457-
458-
459void supportedImageHandlerFormats(QFactoryLoader *loader,-
460 QImageIOPlugin::Capability cap,-
461 QList<QByteArray> *result)-
462{-
463 typedef QMultiMap<int, QString> PluginKeyMap;-
464 typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;-
465-
466 const PluginKeyMap keyMap = loader->keyMap();-
467 const PluginKeyMapConstIterator cend = keyMap.constEnd();-
468 int i = -1;-
469 QImageIOPlugin *plugin = 0;-
470 result->reserve(result->size() + keyMap.size());-
471 for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend
it != cendDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
472 if (it.key() != i
it.key() != iDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
473 i = it.key();-
474 plugin = qobject_cast<QImageIOPlugin *>(loader->instance(i));-
475 }
never executed: end of block
0
476 const QByteArray key = it.value().toLatin1();-
477 if (plugin
pluginDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(plugin->capab...y) & cap) != 0Description
TRUEnever evaluated
FALSEnever evaluated
plugin->capabilities(0, key) & cap) != 0
(plugin->capab...y) & cap) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
478 result->append(key);
never executed: result->append(key);
0
479 }
never executed: end of block
0
480}
never executed: end of block
0
481-
482void supportedImageHandlerMimeTypes(QFactoryLoader *loader,-
483 QImageIOPlugin::Capability cap,-
484 QList<QByteArray> *result)-
485{-
486 QList<QJsonObject> metaDataList = loader->metaData();-
487-
488 const int pluginCount = metaDataList.size();-
489 for (int i = 0; i < pluginCount
i < pluginCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
490 const QJsonObject metaData = metaDataList.at(i).value(QLatin1String("MetaData")).toObject();-
491 const QJsonArray keys = metaData.value(QLatin1String("Keys")).toArray();-
492 const QJsonArray mimeTypes = metaData.value(QLatin1String("MimeTypes")).toArray();-
493 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(loader->instance(i));-
494 const int keyCount = keys.size();-
495 for (int k = 0; k < keyCount
k < keyCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++k) {
0
496 if (plugin
pluginDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(plugin->capab...)) & cap) != 0Description
TRUEnever evaluated
FALSEnever evaluated
plugin->capabilities(0, keys.at(k).toString().toLatin1()) & cap) != 0
(plugin->capab...)) & cap) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
497 result->append(mimeTypes.at(k).toString().toLatin1());
never executed: result->append(mimeTypes.at(k).toString().toLatin1());
0
498 }
never executed: end of block
0
499 }
never executed: end of block
0
500}
never executed: end of block
0
501QList<QByteArray> QImageWriter::supportedImageFormats()-
502{-
503 QList<QByteArray> formats;-
504-
505 formats << "bmp";-
506-
507-
508 formats << "pbm" << "pgm" << "ppm";-
509-
510-
511 formats << "xbm";-
512-
513-
514 formats << "xpm";-
515-
516-
517 formats << "png";-
518-
519-
520-
521-
522-
523-
524 supportedImageHandlerFormats(loader(), QImageIOPlugin::CanWrite, &formats);-
525-
526-
527 std::sort(formats.begin(), formats.end());-
528 formats.erase(std::unique(formats.begin(), formats.end()), formats.end());-
529 return
never executed: return formats;
formats;
never executed: return formats;
0
530}-
531QList<QByteArray> QImageWriter::supportedMimeTypes()-
532{-
533 QList<QByteArray> mimeTypes;-
534-
535 mimeTypes << "image/bmp";-
536-
537-
538 mimeTypes << "image/x-portable-bitmap";-
539 mimeTypes << "image/x-portable-graymap";-
540 mimeTypes << "image/x-portable-pixmap";-
541-
542-
543 mimeTypes << "image/x-xbitmap";-
544-
545-
546 mimeTypes << "image/x-xpixmap";-
547-
548-
549 mimeTypes << "image/png";-
550-
551-
552-
553-
554-
555-
556 supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanWrite, &mimeTypes);-
557-
558-
559 std::sort(mimeTypes.begin(), mimeTypes.end());-
560 mimeTypes.erase(std::unique(mimeTypes.begin(), mimeTypes.end()), mimeTypes.end());-
561 return
never executed: return mimeTypes;
mimeTypes;
never executed: return mimeTypes;
0
562}-
563-
564-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9