image/qpicture.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qpicture.h" -
43#include <private/qpicture_p.h> -
44 -
45#ifndef QT_NO_PICTURE -
46 -
47#include <private/qfactoryloader_p.h> -
48#include <private/qpaintengine_pic_p.h> -
49#include <private/qfont_p.h> -
50#include <qguiapplication.h> -
51 -
52#include "qdatastream.h" -
53#include "qfile.h" -
54#include "qimage.h" -
55#include "qmutex.h" -
56#include "qpainter.h" -
57#include "qpainterpath.h" -
58#include "qpixmap.h" -
59#include "qregion.h" -
60#include "qdebug.h" -
61 -
62QT_BEGIN_NAMESPACE -
63 -
64void qt_format_text(const QFont &fnt, const QRectF &_r, -
65 int tf, const QTextOption *opt, const QString& str, QRectF *brect, -
66 int tabstops, int *, int tabarraylen, -
67 QPainter *painter); -
68 -
69/*! -
70 \class QPicture -
71 \brief The QPicture class is a paint device that records and -
72 replays QPainter commands. -
73 -
74 \inmodule QtGui -
75 \ingroup shared -
76 -
77 -
78 A picture serializes painter commands to an IO device in a -
79 platform-independent format. They are sometimes referred to as meta-files. -
80 -
81 Qt pictures use a proprietary binary format. Unlike native picture -
82 (meta-file) formats on many window systems, Qt pictures have no -
83 limitations regarding their contents. Everything that can be -
84 painted on a widget or pixmap (e.g., fonts, pixmaps, regions, -
85 transformed graphics, etc.) can also be stored in a picture. -
86 -
87 QPicture is resolution independent, i.e. a QPicture can be -
88 displayed on different devices (for example svg, pdf, ps, printer -
89 and screen) looking the same. This is, for instance, needed for -
90 WYSIWYG print preview. QPicture runs in the default system dpi, -
91 and scales the painter to match differences in resolution -
92 depending on the window system. -
93 -
94 Example of how to record a picture: -
95 \snippet picture/picture.cpp 0 -
96 -
97 Note that the list of painter commands is reset on each call to -
98 the QPainter::begin() function. -
99 -
100 Example of how to replay a picture: -
101 \snippet picture/picture.cpp 1 -
102 -
103 Pictures can also be drawn using play(). Some basic data about a -
104 picture is available, for example, size(), isNull() and -
105 boundingRect(). -
106 -
107 \sa QMovie -
108*/ -
109 -
110const char *qt_mfhdr_tag = "QPIC"; // header tag -
111static const quint16 mfhdr_maj = 11; // major version # -
112static const quint16 mfhdr_min = 0; // minor version # -
113 -
114/*! -
115 Constructs an empty picture. -
116 -
117 The \a formatVersion parameter may be used to \e create a QPicture -
118 that can be read by applications that are compiled with earlier -
119 versions of Qt. -
120 -
121 Note that the default formatVersion is -1 which signifies the -
122 current release, i.e. for Qt 4.0 a formatVersion of 7 is the same -
123 as the default formatVersion of -1. -
124 -
125 Reading pictures generated by earlier versions of Qt is not -
126 supported in Qt 4.0. -
127*/ -
128 -
129QPicture::QPicture(int formatVersion) -
130 : QPaintDevice(), -
131 d_ptr(new QPicturePrivate) -
132{ -
133 Q_D(QPicture);
executed (the execution status of this line is deduced): QPicturePrivate * const d = d_func();
-
134 -
135 if (formatVersion == 0)
partially evaluated: formatVersion == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
136 qWarning("QPicture: invalid format version 0");
never executed: QMessageLogger("image/qpicture.cpp", 136, __PRETTY_FUNCTION__).warning("QPicture: invalid format version 0");
0
137 -
138 // still accept the 0 default from before Qt 3.0. -
139 if (formatVersion > 0 && formatVersion != (int)mfhdr_maj) {
partially evaluated: formatVersion > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
never evaluated: formatVersion != (int)mfhdr_maj
0-25
140 d->formatMajor = formatVersion;
never executed (the execution status of this line is deduced): d->formatMajor = formatVersion;
-
141 d->formatMinor = 0;
never executed (the execution status of this line is deduced): d->formatMinor = 0;
-
142 d->formatOk = false;
never executed (the execution status of this line is deduced): d->formatOk = false;
-
143 } else {
never executed: }
0
144 d->resetFormat();
executed (the execution status of this line is deduced): d->resetFormat();
-
145 }
executed: }
Execution Count:25
25
146} -
147 -
148/*! -
149 Constructs a copy of \a pic. -
150 -
151 This constructor is fast thanks to \l{implicit sharing}. -
152*/ -
153 -
154QPicture::QPicture(const QPicture &pic) -
155 : QPaintDevice(), d_ptr(pic.d_ptr) -
156{ -
157}
executed: }
Execution Count:2
2
158 -
159/*! \internal */ -
160QPicture::QPicture(QPicturePrivate &dptr) -
161 : QPaintDevice(), -
162 d_ptr(&dptr) -
163{ -
164}
never executed: }
0
165 -
166/*! -
167 Destroys the picture. -
168*/ -
169QPicture::~QPicture() -
170{ -
171} -
172 -
173/*! -
174 \internal -
175*/ -
176int QPicture::devType() const -
177{ -
178 return QInternal::Picture;
executed: return QInternal::Picture;
Execution Count:65
65
179} -
180 -
181/*! -
182 \fn bool QPicture::isNull() const -
183 -
184 Returns true if the picture contains no data; otherwise returns -
185 false. -
186*/ -
187 -
188/*! -
189 \fn uint QPicture::size() const -
190 -
191 Returns the size of the picture data. -
192 -
193 \sa data() -
194*/ -
195 -
196/*! -
197 \fn const char* QPicture::data() const -
198 -
199 Returns a pointer to the picture data. The pointer is only valid -
200 until the next non-const function is called on this picture. The -
201 returned pointer is 0 if the picture contains no data. -
202 -
203 \sa size(), isNull() -
204*/ -
205 -
206 -
207bool QPicture::isNull() const -
208{ -
209 return d_func()->pictb.buffer().isNull();
executed: return d_func()->pictb.buffer().isNull();
Execution Count:2
2
210} -
211 -
212uint QPicture::size() const -
213{ -
214 return d_func()->pictb.buffer().size();
executed: return d_func()->pictb.buffer().size();
Execution Count:4
4
215} -
216 -
217const char* QPicture::data() const -
218{ -
219 return d_func()->pictb.buffer();
executed: return d_func()->pictb.buffer();
Execution Count:2
2
220} -
221 -
222void QPicture::detach() -
223{ -
224 d_ptr.detach();
never executed (the execution status of this line is deduced): d_ptr.detach();
-
225}
never executed: }
0
226 -
227bool QPicture::isDetached() const -
228{ -
229 return d_func()->ref.load() == 1;
never executed: return d_func()->ref.load() == 1;
0
230} -
231 -
232/*! -
233 Sets the picture data directly from \a data and \a size. This -
234 function copies the input data. -
235 -
236 \sa data(), size() -
237*/ -
238 -
239void QPicture::setData(const char* data, uint size) -
240{ -
241 detach();
never executed (the execution status of this line is deduced): detach();
-
242 d_func()->pictb.setData(data, size);
never executed (the execution status of this line is deduced): d_func()->pictb.setData(data, size);
-
243 d_func()->resetFormat(); // we'll have to check
never executed (the execution status of this line is deduced): d_func()->resetFormat();
-
244}
never executed: }
0
245 -
246 -
247/*! -
248 Loads a picture from the file specified by \a fileName and returns -
249 true if successful; otherwise invalidates the picture and returns false. -
250 -
251 Please note that the \a format parameter has been deprecated and -
252 will have no effect. -
253 -
254 \sa save() -
255*/ -
256 -
257bool QPicture::load(const QString &fileName, const char *format) -
258{ -
259 QFile f(fileName);
never executed (the execution status of this line is deduced): QFile f(fileName);
-
260 if (!f.open(QIODevice::ReadOnly)) {
never evaluated: !f.open(QIODevice::ReadOnly)
0
261 operator=(QPicture());
never executed (the execution status of this line is deduced): operator=(QPicture());
-
262 return false;
never executed: return false;
0
263 } -
264 return load(&f, format);
never executed: return load(&f, format);
0
265} -
266 -
267/*! -
268 \overload -
269 -
270 \a dev is the device to use for loading. -
271*/ -
272 -
273bool QPicture::load(QIODevice *dev, const char *format) -
274{ -
275 if(format) {
never evaluated: format
0
276#ifndef QT_NO_PICTUREIO -
277 QPictureIO io(dev, format);
never executed (the execution status of this line is deduced): QPictureIO io(dev, format);
-
278 if (io.read()) {
never evaluated: io.read()
0
279 operator=(io.picture());
never executed (the execution status of this line is deduced): operator=(io.picture());
-
280 return true;
never executed: return true;
0
281 } -
282#endif -
283 qWarning("QPicture::load: No such picture format: %s", format);
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 283, __PRETTY_FUNCTION__).warning("QPicture::load: No such picture format: %s", format);
-
284 operator=(QPicture());
never executed (the execution status of this line is deduced): operator=(QPicture());
-
285 return false;
never executed: return false;
0
286 } -
287 -
288 detach();
never executed (the execution status of this line is deduced): detach();
-
289 QByteArray a = dev->readAll();
never executed (the execution status of this line is deduced): QByteArray a = dev->readAll();
-
290 -
291 d_func()->pictb.setData(a); // set byte array in buffer
never executed (the execution status of this line is deduced): d_func()->pictb.setData(a);
-
292 return d_func()->checkFormat();
never executed: return d_func()->checkFormat();
0
293} -
294 -
295/*! -
296 Saves a picture to the file specified by \a fileName and returns -
297 true if successful; otherwise returns false. -
298 -
299 Please note that the \a format parameter has been deprecated and -
300 will have no effect. -
301 -
302 \sa load() -
303*/ -
304 -
305bool QPicture::save(const QString &fileName, const char *format) -
306{ -
307 if (paintingActive()) {
never evaluated: paintingActive()
0
308 qWarning("QPicture::save: still being painted on. "
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 308, __PRETTY_FUNCTION__).warning("QPicture::save: still being painted on. "
-
309 "Call QPainter::end() first");
never executed (the execution status of this line is deduced): "Call QPainter::end() first");
-
310 return false;
never executed: return false;
0
311 } -
312 -
313 -
314 if(format) {
never evaluated: format
0
315#ifndef QT_NO_PICTUREIO -
316 QPictureIO io(fileName, format);
never executed (the execution status of this line is deduced): QPictureIO io(fileName, format);
-
317 bool result = io.write();
never executed (the execution status of this line is deduced): bool result = io.write();
-
318 if (result) {
never evaluated: result
0
319 operator=(io.picture());
never executed (the execution status of this line is deduced): operator=(io.picture());
-
320 } else if (format)
never executed: }
never evaluated: format
0
321#else -
322 bool result = false; -
323#endif -
324 { -
325 qWarning("QPicture::save: No such picture format: %s", format);
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 325, __PRETTY_FUNCTION__).warning("QPicture::save: No such picture format: %s", format);
-
326 }
never executed: }
0
327 return result;
never executed: return result;
0
328 } -
329 -
330 QFile f(fileName);
never executed (the execution status of this line is deduced): QFile f(fileName);
-
331 if (!f.open(QIODevice::WriteOnly))
never evaluated: !f.open(QIODevice::WriteOnly)
0
332 return false;
never executed: return false;
0
333 return save(&f, format);
never executed: return save(&f, format);
0
334} -
335 -
336/*! -
337 \overload -
338 -
339 \a dev is the device to use for saving. -
340*/ -
341 -
342bool QPicture::save(QIODevice *dev, const char *format) -
343{ -
344 if (paintingActive()) {
partially evaluated: paintingActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
345 qWarning("QPicture::save: still being painted on. "
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 345, __PRETTY_FUNCTION__).warning("QPicture::save: still being painted on. "
-
346 "Call QPainter::end() first");
never executed (the execution status of this line is deduced): "Call QPainter::end() first");
-
347 return false;
never executed: return false;
0
348 } -
349 -
350 if(format) {
partially evaluated: format
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
351#ifndef QT_NO_PICTUREIO -
352 QPictureIO io(dev, format);
never executed (the execution status of this line is deduced): QPictureIO io(dev, format);
-
353 bool result = io.write();
never executed (the execution status of this line is deduced): bool result = io.write();
-
354 if (result) {
never evaluated: result
0
355 operator=(io.picture());
never executed (the execution status of this line is deduced): operator=(io.picture());
-
356 } else if (format)
never executed: }
never evaluated: format
0
357#else -
358 bool result = false; -
359#endif -
360 { -
361 qWarning("QPicture::save: No such picture format: %s", format);
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 361, __PRETTY_FUNCTION__).warning("QPicture::save: No such picture format: %s", format);
-
362 }
never executed: }
0
363 return result;
never executed: return result;
0
364 } -
365 -
366 dev->write(d_func()->pictb.buffer(), d_func()->pictb.buffer().size());
executed (the execution status of this line is deduced): dev->write(d_func()->pictb.buffer(), d_func()->pictb.buffer().size());
-
367 return true;
executed: return true;
Execution Count:2
2
368} -
369 -
370/*! -
371 Returns the picture's bounding rectangle or an invalid rectangle -
372 if the picture contains no data. -
373*/ -
374 -
375QRect QPicture::boundingRect() const -
376{ -
377 Q_D(const QPicture);
executed (the execution status of this line is deduced): const QPicturePrivate * const d = d_func();
-
378 // Use override rect where possible. -
379 if (!d->override_rect.isEmpty())
evaluated: !d->override_rect.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:94
6-94
380 return d->override_rect;
executed: return d->override_rect;
Execution Count:6
6
381 -
382 if (!d->formatOk)
evaluated: !d->formatOk
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:4
4-90
383 d_ptr->checkFormat();
executed: d_ptr->checkFormat();
Execution Count:90
90
384 -
385 return d->brect;
executed: return d->brect;
Execution Count:94
94
386} -
387 -
388/*! -
389 Sets the picture's bounding rectangle to \a r. The automatically -
390 calculated value is overridden. -
391*/ -
392 -
393void QPicture::setBoundingRect(const QRect &r) -
394{ -
395 d_func()->override_rect = r;
executed (the execution status of this line is deduced): d_func()->override_rect = r;
-
396}
executed: }
Execution Count:3
3
397 -
398/*! -
399 Replays the picture using \a painter, and returns true if -
400 successful; otherwise returns false. -
401 -
402 This function does exactly the same as QPainter::drawPicture() -
403 with (x, y) = (0, 0). -
404*/ -
405 -
406bool QPicture::play(QPainter *painter) -
407{ -
408 Q_D(QPicture);
executed (the execution status of this line is deduced): QPicturePrivate * const d = d_func();
-
409 -
410 if (d->pictb.size() == 0) // nothing recorded
partially evaluated: d->pictb.size() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
411 return true;
never executed: return true;
0
412 -
413 if (!d->formatOk && !d->checkFormat())
partially evaluated: !d->formatOk
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !d->checkFormat()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
414 return false;
never executed: return false;
0
415 -
416 d->pictb.open(QIODevice::ReadOnly); // open buffer device
executed (the execution status of this line is deduced): d->pictb.open(QIODevice::ReadOnly);
-
417 QDataStream s;
executed (the execution status of this line is deduced): QDataStream s;
-
418 s.setDevice(&d->pictb); // attach data stream to buffer
executed (the execution status of this line is deduced): s.setDevice(&d->pictb);
-
419 s.device()->seek(10); // go directly to the data
executed (the execution status of this line is deduced): s.device()->seek(10);
-
420 s.setVersion(d->formatMajor == 4 ? 3 : d->formatMajor);
executed (the execution status of this line is deduced): s.setVersion(d->formatMajor == 4 ? 3 : d->formatMajor);
-
421 -
422 quint8 c, clen;
executed (the execution status of this line is deduced): quint8 c, clen;
-
423 quint32 nrecords;
executed (the execution status of this line is deduced): quint32 nrecords;
-
424 s >> c >> clen;
executed (the execution status of this line is deduced): s >> c >> clen;
-
425 Q_ASSERT(c == QPicturePrivate::PdcBegin);
executed (the execution status of this line is deduced): qt_noop();
-
426 // bounding rect was introduced in ver 4. Read in checkFormat(). -
427 if (d->formatMajor >= 4) {
partially evaluated: d->formatMajor >= 4
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
428 qint32 dummy;
executed (the execution status of this line is deduced): qint32 dummy;
-
429 s >> dummy >> dummy >> dummy >> dummy;
executed (the execution status of this line is deduced): s >> dummy >> dummy >> dummy >> dummy;
-
430 }
executed: }
Execution Count:1
1
431 s >> nrecords;
executed (the execution status of this line is deduced): s >> nrecords;
-
432 if (!exec(painter, s, nrecords)) {
partially evaluated: !exec(painter, s, nrecords)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
433 qWarning("QPicture::play: Format error");
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 433, __PRETTY_FUNCTION__).warning("QPicture::play: Format error");
-
434 d->pictb.close();
never executed (the execution status of this line is deduced): d->pictb.close();
-
435 return false;
never executed: return false;
0
436 } -
437 d->pictb.close();
executed (the execution status of this line is deduced): d->pictb.close();
-
438 return true; // no end-command
executed: return true;
Execution Count:1
1
439} -
440 -
441 -
442// -
443// QFakeDevice is used to create fonts with a custom DPI -
444// -
445class QFakeDevice : public QPaintDevice -
446{ -
447public: -
448 QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); }
never executed: }
0
449 void setDpiX(int dpi) { dpi_x = dpi; }
never executed: }
0
450 void setDpiY(int dpi) { dpi_y = dpi; }
never executed: }
0
451 QPaintEngine *paintEngine() const { return 0; }
never executed: return 0;
0
452 int metric(PaintDeviceMetric m) const -
453 { -
454 switch(m) { -
455 case PdmPhysicalDpiX: -
456 case PdmDpiX: -
457 return dpi_x;
never executed: return dpi_x;
0
458 case PdmPhysicalDpiY: -
459 case PdmDpiY: -
460 return dpi_y;
never executed: return dpi_y;
0
461 default: -
462 return QPaintDevice::metric(m);
never executed: return QPaintDevice::metric(m);
0
463 } -
464 }
never executed: }
0
465 -
466private: -
467 int dpi_x; -
468 int dpi_y; -
469}; -
470 -
471/*! -
472 \internal -
473 Iterates over the internal picture data and draws the picture using -
474 \a painter. -
475*/ -
476 -
477bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords) -
478{ -
479 Q_D(QPicture);
executed (the execution status of this line is deduced): QPicturePrivate * const d = d_func();
-
480#if defined(QT_DEBUG) -
481 int strm_pos; -
482#endif -
483 quint8 c; // command id
executed (the execution status of this line is deduced): quint8 c;
-
484 quint8 tiny_len; // 8-bit length descriptor
executed (the execution status of this line is deduced): quint8 tiny_len;
-
485 qint32 len; // 32-bit length descriptor
executed (the execution status of this line is deduced): qint32 len;
-
486 qint16 i_16, i1_16, i2_16; // parameters...
executed (the execution status of this line is deduced): qint16 i_16, i1_16, i2_16;
-
487 qint8 i_8;
executed (the execution status of this line is deduced): qint8 i_8;
-
488 quint32 ul;
executed (the execution status of this line is deduced): quint32 ul;
-
489 double dbl;
executed (the execution status of this line is deduced): double dbl;
-
490 bool bl;
executed (the execution status of this line is deduced): bool bl;
-
491 QByteArray str1;
executed (the execution status of this line is deduced): QByteArray str1;
-
492 QString str;
executed (the execution status of this line is deduced): QString str;
-
493 QPointF p, p1, p2;
executed (the execution status of this line is deduced): QPointF p, p1, p2;
-
494 QPoint ip, ip1, ip2;
executed (the execution status of this line is deduced): QPoint ip, ip1, ip2;
-
495 QRect ir;
executed (the execution status of this line is deduced): QRect ir;
-
496 QRectF r;
executed (the execution status of this line is deduced): QRectF r;
-
497 QPolygonF a;
executed (the execution status of this line is deduced): QPolygonF a;
-
498 QPolygon ia;
executed (the execution status of this line is deduced): QPolygon ia;
-
499 QColor color;
executed (the execution status of this line is deduced): QColor color;
-
500 QFont font;
executed (the execution status of this line is deduced): QFont font;
-
501 QPen pen;
executed (the execution status of this line is deduced): QPen pen;
-
502 QBrush brush;
executed (the execution status of this line is deduced): QBrush brush;
-
503 QRegion rgn;
executed (the execution status of this line is deduced): QRegion rgn;
-
504 QMatrix wmatrix;
executed (the execution status of this line is deduced): QMatrix wmatrix;
-
505 QTransform matrix;
executed (the execution status of this line is deduced): QTransform matrix;
-
506 -
507 QTransform worldMatrix = painter->transform();
executed (the execution status of this line is deduced): QTransform worldMatrix = painter->transform();
-
508 worldMatrix.scale(qreal(painter->device()->logicalDpiX()) / qreal(qt_defaultDpiX()),
executed (the execution status of this line is deduced): worldMatrix.scale(qreal(painter->device()->logicalDpiX()) / qreal(qt_defaultDpiX()),
-
509 qreal(painter->device()->logicalDpiY()) / qreal(qt_defaultDpiY()));
executed (the execution status of this line is deduced): qreal(painter->device()->logicalDpiY()) / qreal(qt_defaultDpiY()));
-
510 painter->setTransform(worldMatrix);
executed (the execution status of this line is deduced): painter->setTransform(worldMatrix);
-
511 -
512 while (nrecords-- && !s.atEnd()) {
partially evaluated: nrecords--
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
partially evaluated: !s.atEnd()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
513 s >> c; // read cmd
executed (the execution status of this line is deduced): s >> c;
-
514 s >> tiny_len; // read param length
executed (the execution status of this line is deduced): s >> tiny_len;
-
515 if (tiny_len == 255) // longer than 254 bytes
partially evaluated: tiny_len == 255
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
516 s >> len;
never executed: s >> len;
0
517 else -
518 len = tiny_len;
executed: len = tiny_len;
Execution Count:3
3
519#if defined(QT_DEBUG) -
520 strm_pos = s.device()->pos(); -
521#endif -
522 switch (c) { // exec cmd -
523 case QPicturePrivate::PdcNOP: -
524 break;
never executed: break;
0
525 case QPicturePrivate::PdcDrawPoint: -
526 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
527 s >> ip;
never executed (the execution status of this line is deduced): s >> ip;
-
528 painter->drawPoint(ip);
never executed (the execution status of this line is deduced): painter->drawPoint(ip);
-
529 } else {
never executed: }
0
530 s >> p;
never executed (the execution status of this line is deduced): s >> p;
-
531 painter->drawPoint(p);
never executed (the execution status of this line is deduced): painter->drawPoint(p);
-
532 }
never executed: }
0
533 break;
never executed: break;
0
534 case QPicturePrivate::PdcDrawPoints: -
535// ## implement me in the picture paint engine -
536// s >> a >> i1_32 >> i2_32; -
537// painter->drawPoints(a.mid(i1_32, i2_32)); -
538 break;
never executed: break;
0
539 case QPicturePrivate::PdcDrawPath: { -
540 QPainterPath path;
executed (the execution status of this line is deduced): QPainterPath path;
-
541 s >> path;
executed (the execution status of this line is deduced): s >> path;
-
542 painter->drawPath(path);
executed (the execution status of this line is deduced): painter->drawPath(path);
-
543 break;
executed: break;
Execution Count:2
2
544 } -
545 case QPicturePrivate::PdcDrawLine: -
546 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
547 s >> ip1 >> ip2;
never executed (the execution status of this line is deduced): s >> ip1 >> ip2;
-
548 painter->drawLine(ip1, ip2);
never executed (the execution status of this line is deduced): painter->drawLine(ip1, ip2);
-
549 } else {
never executed: }
0
550 s >> p1 >> p2;
never executed (the execution status of this line is deduced): s >> p1 >> p2;
-
551 painter->drawLine(p1, p2);
never executed (the execution status of this line is deduced): painter->drawLine(p1, p2);
-
552 }
never executed: }
0
553 break;
never executed: break;
0
554 case QPicturePrivate::PdcDrawRect: -
555 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
556 s >> ir;
never executed (the execution status of this line is deduced): s >> ir;
-
557 painter->drawRect(ir);
never executed (the execution status of this line is deduced): painter->drawRect(ir);
-
558 } else {
never executed: }
0
559 s >> r;
never executed (the execution status of this line is deduced): s >> r;
-
560 painter->drawRect(r);
never executed (the execution status of this line is deduced): painter->drawRect(r);
-
561 }
never executed: }
0
562 break;
never executed: break;
0
563 case QPicturePrivate::PdcDrawRoundRect: -
564 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
565 s >> ir >> i1_16 >> i2_16;
never executed (the execution status of this line is deduced): s >> ir >> i1_16 >> i2_16;
-
566 painter->drawRoundedRect(ir, i1_16, i2_16, Qt::RelativeSize);
never executed (the execution status of this line is deduced): painter->drawRoundedRect(ir, i1_16, i2_16, Qt::RelativeSize);
-
567 } else {
never executed: }
0
568 s >> r >> i1_16 >> i2_16;
never executed (the execution status of this line is deduced): s >> r >> i1_16 >> i2_16;
-
569 painter->drawRoundedRect(r, i1_16, i2_16, Qt::RelativeSize);
never executed (the execution status of this line is deduced): painter->drawRoundedRect(r, i1_16, i2_16, Qt::RelativeSize);
-
570 }
never executed: }
0
571 break;
never executed: break;
0
572 case QPicturePrivate::PdcDrawEllipse: -
573 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
574 s >> ir;
never executed (the execution status of this line is deduced): s >> ir;
-
575 painter->drawEllipse(ir);
never executed (the execution status of this line is deduced): painter->drawEllipse(ir);
-
576 } else {
never executed: }
0
577 s >> r;
never executed (the execution status of this line is deduced): s >> r;
-
578 painter->drawEllipse(r);
never executed (the execution status of this line is deduced): painter->drawEllipse(r);
-
579 }
never executed: }
0
580 break;
never executed: break;
0
581 case QPicturePrivate::PdcDrawArc: -
582 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
583 s >> ir;
never executed (the execution status of this line is deduced): s >> ir;
-
584 r = ir;
never executed (the execution status of this line is deduced): r = ir;
-
585 } else {
never executed: }
0
586 s >> r;
never executed (the execution status of this line is deduced): s >> r;
-
587 }
never executed: }
0
588 s >> i1_16 >> i2_16;
never executed (the execution status of this line is deduced): s >> i1_16 >> i2_16;
-
589 painter->drawArc(r, i1_16, i2_16);
never executed (the execution status of this line is deduced): painter->drawArc(r, i1_16, i2_16);
-
590 break;
never executed: break;
0
591 case QPicturePrivate::PdcDrawPie: -
592 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
593 s >> ir;
never executed (the execution status of this line is deduced): s >> ir;
-
594 r = ir;
never executed (the execution status of this line is deduced): r = ir;
-
595 } else {
never executed: }
0
596 s >> r;
never executed (the execution status of this line is deduced): s >> r;
-
597 }
never executed: }
0
598 s >> i1_16 >> i2_16;
never executed (the execution status of this line is deduced): s >> i1_16 >> i2_16;
-
599 painter->drawPie(r, i1_16, i2_16);
never executed (the execution status of this line is deduced): painter->drawPie(r, i1_16, i2_16);
-
600 break;
never executed: break;
0
601 case QPicturePrivate::PdcDrawChord: -
602 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
603 s >> ir;
never executed (the execution status of this line is deduced): s >> ir;
-
604 r = ir;
never executed (the execution status of this line is deduced): r = ir;
-
605 } else {
never executed: }
0
606 s >> r;
never executed (the execution status of this line is deduced): s >> r;
-
607 }
never executed: }
0
608 s >> i1_16 >> i2_16;
never executed (the execution status of this line is deduced): s >> i1_16 >> i2_16;
-
609 painter->drawChord(r, i1_16, i2_16);
never executed (the execution status of this line is deduced): painter->drawChord(r, i1_16, i2_16);
-
610 break;
never executed: break;
0
611 case QPicturePrivate::PdcDrawLineSegments: -
612 s >> ia;
never executed (the execution status of this line is deduced): s >> ia;
-
613 painter->drawLines(ia);
never executed (the execution status of this line is deduced): painter->drawLines(ia);
-
614 ia.clear();
never executed (the execution status of this line is deduced): ia.clear();
-
615 break;
never executed: break;
0
616 case QPicturePrivate::PdcDrawPolyline: -
617 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
618 s >> ia;
never executed (the execution status of this line is deduced): s >> ia;
-
619 painter->drawPolyline(ia);
never executed (the execution status of this line is deduced): painter->drawPolyline(ia);
-
620 ia.clear();
never executed (the execution status of this line is deduced): ia.clear();
-
621 } else {
never executed: }
0
622 s >> a;
never executed (the execution status of this line is deduced): s >> a;
-
623 painter->drawPolyline(a);
never executed (the execution status of this line is deduced): painter->drawPolyline(a);
-
624 a.clear();
never executed (the execution status of this line is deduced): a.clear();
-
625 }
never executed: }
0
626 break;
never executed: break;
0
627 case QPicturePrivate::PdcDrawPolygon: -
628 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
629 s >> ia >> i_8;
never executed (the execution status of this line is deduced): s >> ia >> i_8;
-
630 painter->drawPolygon(ia, i_8 ? Qt::WindingFill : Qt::OddEvenFill);
never executed (the execution status of this line is deduced): painter->drawPolygon(ia, i_8 ? Qt::WindingFill : Qt::OddEvenFill);
-
631 a.clear();
never executed (the execution status of this line is deduced): a.clear();
-
632 } else {
never executed: }
0
633 s >> a >> i_8;
never executed (the execution status of this line is deduced): s >> a >> i_8;
-
634 painter->drawPolygon(a, i_8 ? Qt::WindingFill : Qt::OddEvenFill);
never executed (the execution status of this line is deduced): painter->drawPolygon(a, i_8 ? Qt::WindingFill : Qt::OddEvenFill);
-
635 a.clear();
never executed (the execution status of this line is deduced): a.clear();
-
636 }
never executed: }
0
637 break;
never executed: break;
0
638 case QPicturePrivate::PdcDrawCubicBezier: { -
639 s >> ia;
never executed (the execution status of this line is deduced): s >> ia;
-
640 QPainterPath path;
never executed (the execution status of this line is deduced): QPainterPath path;
-
641 Q_ASSERT(ia.size() == 4);
never executed (the execution status of this line is deduced): qt_noop();
-
642 path.moveTo(ia.at(0));
never executed (the execution status of this line is deduced): path.moveTo(ia.at(0));
-
643 path.cubicTo(ia.at(1), ia.at(2), ia.at(3));
never executed (the execution status of this line is deduced): path.cubicTo(ia.at(1), ia.at(2), ia.at(3));
-
644 painter->strokePath(path, painter->pen());
never executed (the execution status of this line is deduced): painter->strokePath(path, painter->pen());
-
645 a.clear();
never executed (the execution status of this line is deduced): a.clear();
-
646 } -
647 break;
never executed: break;
0
648 case QPicturePrivate::PdcDrawText: -
649 s >> ip >> str1;
never executed (the execution status of this line is deduced): s >> ip >> str1;
-
650 painter->drawText(ip, QString::fromLatin1(str1));
never executed (the execution status of this line is deduced): painter->drawText(ip, QString::fromLatin1(str1));
-
651 break;
never executed: break;
0
652 case QPicturePrivate::PdcDrawTextFormatted: -
653 s >> ir >> i_16 >> str1;
never executed (the execution status of this line is deduced): s >> ir >> i_16 >> str1;
-
654 painter->drawText(ir, i_16, QString::fromLatin1(str1));
never executed (the execution status of this line is deduced): painter->drawText(ir, i_16, QString::fromLatin1(str1));
-
655 break;
never executed: break;
0
656 case QPicturePrivate::PdcDrawText2: -
657 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
658 s >> ip >> str;
never executed (the execution status of this line is deduced): s >> ip >> str;
-
659 painter->drawText(ip, str);
never executed (the execution status of this line is deduced): painter->drawText(ip, str);
-
660 } else {
never executed: }
0
661 s >> p >> str;
never executed (the execution status of this line is deduced): s >> p >> str;
-
662 painter->drawText(p, str);
never executed (the execution status of this line is deduced): painter->drawText(p, str);
-
663 }
never executed: }
0
664 break;
never executed: break;
0
665 case QPicturePrivate::PdcDrawText2Formatted: -
666 s >> ir;
never executed (the execution status of this line is deduced): s >> ir;
-
667 s >> i_16;
never executed (the execution status of this line is deduced): s >> i_16;
-
668 s >> str;
never executed (the execution status of this line is deduced): s >> str;
-
669 painter->drawText(ir, i_16, str);
never executed (the execution status of this line is deduced): painter->drawText(ir, i_16, str);
-
670 break;
never executed: break;
0
671 case QPicturePrivate::PdcDrawTextItem: { -
672 s >> p >> str >> font >> ul;
never executed (the execution status of this line is deduced): s >> p >> str >> font >> ul;
-
673 -
674 // the text layout direction is not used here because it's already -
675 // aligned when QPicturePaintEngine::drawTextItem() serializes the -
676 // drawText() call, therefore ul is unsed in this context -
677 -
678 if (d->formatMajor >= 9) {
never evaluated: d->formatMajor >= 9
0
679 s >> dbl;
never executed (the execution status of this line is deduced): s >> dbl;
-
680 QFont fnt(font);
never executed (the execution status of this line is deduced): QFont fnt(font);
-
681 if (dbl != 1.0) {
never evaluated: dbl != 1.0
0
682 QFakeDevice fake;
never executed (the execution status of this line is deduced): QFakeDevice fake;
-
683 fake.setDpiX(qRound(dbl*qt_defaultDpiX()));
never executed (the execution status of this line is deduced): fake.setDpiX(qRound(dbl*qt_defaultDpiX()));
-
684 fake.setDpiY(qRound(dbl*qt_defaultDpiY()));
never executed (the execution status of this line is deduced): fake.setDpiY(qRound(dbl*qt_defaultDpiY()));
-
685 fnt = QFont(font, &fake);
never executed (the execution status of this line is deduced): fnt = QFont(font, &fake);
-
686 }
never executed: }
0
687 -
688 qreal justificationWidth;
never executed (the execution status of this line is deduced): qreal justificationWidth;
-
689 s >> justificationWidth;
never executed (the execution status of this line is deduced): s >> justificationWidth;
-
690 -
691 int flags = Qt::TextSingleLine | Qt::TextDontClip | Qt::TextForceLeftToRight;
never executed (the execution status of this line is deduced): int flags = Qt::TextSingleLine | Qt::TextDontClip | Qt::TextForceLeftToRight;
-
692 -
693 QSizeF size(1, 1);
never executed (the execution status of this line is deduced): QSizeF size(1, 1);
-
694 if (justificationWidth > 0) {
never evaluated: justificationWidth > 0
0
695 size.setWidth(justificationWidth);
never executed (the execution status of this line is deduced): size.setWidth(justificationWidth);
-
696 flags |= Qt::TextJustificationForced;
never executed (the execution status of this line is deduced): flags |= Qt::TextJustificationForced;
-
697 flags |= Qt::AlignJustify;
never executed (the execution status of this line is deduced): flags |= Qt::AlignJustify;
-
698 }
never executed: }
0
699 -
700 QFontMetrics fm(fnt);
never executed (the execution status of this line is deduced): QFontMetrics fm(fnt);
-
701 QPointF pt(p.x(), p.y() - fm.ascent());
never executed (the execution status of this line is deduced): QPointF pt(p.x(), p.y() - fm.ascent());
-
702 qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/0,
never executed (the execution status of this line is deduced): qt_format_text(fnt, QRectF(pt, size), flags, 0,
-
703 str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter);
never executed (the execution status of this line is deduced): str, 0, 0, 0, 0, painter);
-
704 } else {
never executed: }
0
705 qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/0,
never executed (the execution status of this line is deduced): qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, 0,
-
706 str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter);
never executed (the execution status of this line is deduced): str, 0, 0, 0, 0, painter);
-
707 }
never executed: }
0
708 -
709 break;
never executed: break;
0
710 } -
711 case QPicturePrivate::PdcDrawPixmap: { -
712 QPixmap pixmap;
never executed (the execution status of this line is deduced): QPixmap pixmap;
-
713 if (d->formatMajor < 4) {
never evaluated: d->formatMajor < 4
0
714 s >> ip >> pixmap;
never executed (the execution status of this line is deduced): s >> ip >> pixmap;
-
715 painter->drawPixmap(ip, pixmap);
never executed (the execution status of this line is deduced): painter->drawPixmap(ip, pixmap);
-
716 } else if (d->formatMajor <= 5) {
never executed: }
never evaluated: d->formatMajor <= 5
0
717 s >> ir >> pixmap;
never executed (the execution status of this line is deduced): s >> ir >> pixmap;
-
718 painter->drawPixmap(ir, pixmap);
never executed (the execution status of this line is deduced): painter->drawPixmap(ir, pixmap);
-
719 } else {
never executed: }
0
720 QRectF sr;
never executed (the execution status of this line is deduced): QRectF sr;
-
721 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
722 int index;
never executed (the execution status of this line is deduced): int index;
-
723 s >> r >> index >> sr;
never executed (the execution status of this line is deduced): s >> r >> index >> sr;
-
724 Q_ASSERT(index < d->pixmap_list.size());
never executed (the execution status of this line is deduced): qt_noop();
-
725 pixmap = d->pixmap_list.at(index);
never executed (the execution status of this line is deduced): pixmap = d->pixmap_list.at(index);
-
726 } else {
never executed: }
0
727 s >> r >> pixmap >> sr;
never executed (the execution status of this line is deduced): s >> r >> pixmap >> sr;
-
728 }
never executed: }
0
729 painter->drawPixmap(r, pixmap, sr);
never executed (the execution status of this line is deduced): painter->drawPixmap(r, pixmap, sr);
-
730 }
never executed: }
0
731 } -
732 break;
never executed: break;
0
733 case QPicturePrivate::PdcDrawTiledPixmap: { -
734 QPixmap pixmap;
never executed (the execution status of this line is deduced): QPixmap pixmap;
-
735 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
736 int index;
never executed (the execution status of this line is deduced): int index;
-
737 s >> r >> index >> p;
never executed (the execution status of this line is deduced): s >> r >> index >> p;
-
738 Q_ASSERT(index < d->pixmap_list.size());
never executed (the execution status of this line is deduced): qt_noop();
-
739 pixmap = d->pixmap_list.at(index);
never executed (the execution status of this line is deduced): pixmap = d->pixmap_list.at(index);
-
740 } else {
never executed: }
0
741 s >> r >> pixmap >> p;
never executed (the execution status of this line is deduced): s >> r >> pixmap >> p;
-
742 }
never executed: }
0
743 painter->drawTiledPixmap(r, pixmap, p);
never executed (the execution status of this line is deduced): painter->drawTiledPixmap(r, pixmap, p);
-
744 } -
745 break;
never executed: break;
0
746 case QPicturePrivate::PdcDrawImage: { -
747 QImage image;
never executed (the execution status of this line is deduced): QImage image;
-
748 if (d->formatMajor < 4) {
never evaluated: d->formatMajor < 4
0
749 s >> p >> image;
never executed (the execution status of this line is deduced): s >> p >> image;
-
750 painter->drawImage(p, image);
never executed (the execution status of this line is deduced): painter->drawImage(p, image);
-
751 } else if (d->formatMajor <= 5){
never executed: }
never evaluated: d->formatMajor <= 5
0
752 s >> ir >> image;
never executed (the execution status of this line is deduced): s >> ir >> image;
-
753 painter->drawImage(ir, image, QRect(0, 0, ir.width(), ir.height()));
never executed (the execution status of this line is deduced): painter->drawImage(ir, image, QRect(0, 0, ir.width(), ir.height()));
-
754 } else {
never executed: }
0
755 QRectF sr;
never executed (the execution status of this line is deduced): QRectF sr;
-
756 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
757 int index;
never executed (the execution status of this line is deduced): int index;
-
758 s >> r >> index >> sr >> ul;
never executed (the execution status of this line is deduced): s >> r >> index >> sr >> ul;
-
759 Q_ASSERT(index < d->image_list.size());
never executed (the execution status of this line is deduced): qt_noop();
-
760 image = d->image_list.at(index);
never executed (the execution status of this line is deduced): image = d->image_list.at(index);
-
761 } else {
never executed: }
0
762 s >> r >> image >> sr >> ul;
never executed (the execution status of this line is deduced): s >> r >> image >> sr >> ul;
-
763 }
never executed: }
0
764 painter->drawImage(r, image, sr, Qt::ImageConversionFlags(ul));
never executed (the execution status of this line is deduced): painter->drawImage(r, image, sr, Qt::ImageConversionFlags(ul));
-
765 }
never executed: }
0
766 } -
767 break;
never executed: break;
0
768 case QPicturePrivate::PdcBegin: -
769 s >> ul; // number of records
never executed (the execution status of this line is deduced): s >> ul;
-
770 if (!exec(painter, s, ul))
never evaluated: !exec(painter, s, ul)
0
771 return false;
never executed: return false;
0
772 break;
never executed: break;
0
773 case QPicturePrivate::PdcEnd: -
774 if (nrecords == 0)
partially evaluated: nrecords == 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
775 return true;
executed: return true;
Execution Count:1
1
776 break;
never executed: break;
0
777 case QPicturePrivate::PdcSave: -
778 painter->save();
never executed (the execution status of this line is deduced): painter->save();
-
779 break;
never executed: break;
0
780 case QPicturePrivate::PdcRestore: -
781 painter->restore();
never executed (the execution status of this line is deduced): painter->restore();
-
782 break;
never executed: break;
0
783 case QPicturePrivate::PdcSetBkColor: -
784 s >> color;
never executed (the execution status of this line is deduced): s >> color;
-
785 painter->setBackground(color);
never executed (the execution status of this line is deduced): painter->setBackground(color);
-
786 break;
never executed: break;
0
787 case QPicturePrivate::PdcSetBkMode: -
788 s >> i_8;
never executed (the execution status of this line is deduced): s >> i_8;
-
789 painter->setBackgroundMode((Qt::BGMode)i_8);
never executed (the execution status of this line is deduced): painter->setBackgroundMode((Qt::BGMode)i_8);
-
790 break;
never executed: break;
0
791 case QPicturePrivate::PdcSetROP: // NOP -
792 s >> i_8;
never executed (the execution status of this line is deduced): s >> i_8;
-
793 break;
never executed: break;
0
794 case QPicturePrivate::PdcSetBrushOrigin: -
795 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
796 s >> ip;
never executed (the execution status of this line is deduced): s >> ip;
-
797 painter->setBrushOrigin(ip);
never executed (the execution status of this line is deduced): painter->setBrushOrigin(ip);
-
798 } else {
never executed: }
0
799 s >> p;
never executed (the execution status of this line is deduced): s >> p;
-
800 painter->setBrushOrigin(p);
never executed (the execution status of this line is deduced): painter->setBrushOrigin(p);
-
801 }
never executed: }
0
802 break;
never executed: break;
0
803 case QPicturePrivate::PdcSetFont: -
804 s >> font;
never executed (the execution status of this line is deduced): s >> font;
-
805 painter->setFont(font);
never executed (the execution status of this line is deduced): painter->setFont(font);
-
806 break;
never executed: break;
0
807 case QPicturePrivate::PdcSetPen: -
808 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
809 int index;
never executed (the execution status of this line is deduced): int index;
-
810 s >> index;
never executed (the execution status of this line is deduced): s >> index;
-
811 Q_ASSERT(index < d->pen_list.size());
never executed (the execution status of this line is deduced): qt_noop();
-
812 pen = d->pen_list.at(index);
never executed (the execution status of this line is deduced): pen = d->pen_list.at(index);
-
813 } else {
never executed: }
0
814 s >> pen;
never executed (the execution status of this line is deduced): s >> pen;
-
815 }
never executed: }
0
816 painter->setPen(pen);
never executed (the execution status of this line is deduced): painter->setPen(pen);
-
817 break;
never executed: break;
0
818 case QPicturePrivate::PdcSetBrush: -
819 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
820 int index;
never executed (the execution status of this line is deduced): int index;
-
821 s >> index;
never executed (the execution status of this line is deduced): s >> index;
-
822 Q_ASSERT(index < d->brush_list.size());
never executed (the execution status of this line is deduced): qt_noop();
-
823 brush = d->brush_list.at(index);
never executed (the execution status of this line is deduced): brush = d->brush_list.at(index);
-
824 } else {
never executed: }
0
825 s >> brush;
never executed (the execution status of this line is deduced): s >> brush;
-
826 }
never executed: }
0
827 painter->setBrush(brush);
never executed (the execution status of this line is deduced): painter->setBrush(brush);
-
828 break;
never executed: break;
0
829 case QPicturePrivate::PdcSetVXform: -
830 s >> i_8;
never executed (the execution status of this line is deduced): s >> i_8;
-
831 painter->setViewTransformEnabled(i_8);
never executed (the execution status of this line is deduced): painter->setViewTransformEnabled(i_8);
-
832 break;
never executed: break;
0
833 case QPicturePrivate::PdcSetWindow: -
834 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
835 s >> ir;
never executed (the execution status of this line is deduced): s >> ir;
-
836 painter->setWindow(ir);
never executed (the execution status of this line is deduced): painter->setWindow(ir);
-
837 } else {
never executed: }
0
838 s >> r;
never executed (the execution status of this line is deduced): s >> r;
-
839 painter->setWindow(r.toRect());
never executed (the execution status of this line is deduced): painter->setWindow(r.toRect());
-
840 }
never executed: }
0
841 break;
never executed: break;
0
842 case QPicturePrivate::PdcSetViewport: -
843 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
844 s >> ir;
never executed (the execution status of this line is deduced): s >> ir;
-
845 painter->setViewport(ir);
never executed (the execution status of this line is deduced): painter->setViewport(ir);
-
846 } else {
never executed: }
0
847 s >> r;
never executed (the execution status of this line is deduced): s >> r;
-
848 painter->setViewport(r.toRect());
never executed (the execution status of this line is deduced): painter->setViewport(r.toRect());
-
849 }
never executed: }
0
850 break;
never executed: break;
0
851 case QPicturePrivate::PdcSetWXform: -
852 s >> i_8;
never executed (the execution status of this line is deduced): s >> i_8;
-
853 painter->setMatrixEnabled(i_8);
never executed (the execution status of this line is deduced): painter->setMatrixEnabled(i_8);
-
854 break;
never executed: break;
0
855 case QPicturePrivate::PdcSetWMatrix: -
856 if (d->formatMajor >= 8) {
never evaluated: d->formatMajor >= 8
0
857 s >> matrix >> i_8;
never executed (the execution status of this line is deduced): s >> matrix >> i_8;
-
858 } else {
never executed: }
0
859 s >> wmatrix >> i_8;
never executed (the execution status of this line is deduced): s >> wmatrix >> i_8;
-
860 matrix = QTransform(wmatrix);
never executed (the execution status of this line is deduced): matrix = QTransform(wmatrix);
-
861 }
never executed: }
0
862 // i_8 is always false due to updateXForm() in qpaintengine_pic.cpp -
863 painter->setTransform(matrix * worldMatrix, i_8);
never executed (the execution status of this line is deduced): painter->setTransform(matrix * worldMatrix, i_8);
-
864 break;
never executed: break;
0
865 case QPicturePrivate::PdcSetClip: -
866 s >> i_8;
never executed (the execution status of this line is deduced): s >> i_8;
-
867 painter->setClipping(i_8);
never executed (the execution status of this line is deduced): painter->setClipping(i_8);
-
868 break;
never executed: break;
0
869 case QPicturePrivate::PdcSetClipRegion: -
870 s >> rgn >> i_8;
never executed (the execution status of this line is deduced): s >> rgn >> i_8;
-
871 if (d->formatMajor >= 9) {
never evaluated: d->formatMajor >= 9
0
872 painter->setClipRegion(rgn, Qt::ClipOperation(i_8));
never executed (the execution status of this line is deduced): painter->setClipRegion(rgn, Qt::ClipOperation(i_8));
-
873 } else {
never executed: }
0
874 painter->setClipRegion(rgn);
never executed (the execution status of this line is deduced): painter->setClipRegion(rgn);
-
875 }
never executed: }
0
876 break;
never executed: break;
0
877 case QPicturePrivate::PdcSetClipPath: -
878 { -
879 QPainterPath path;
never executed (the execution status of this line is deduced): QPainterPath path;
-
880 s >> path >> i_8;
never executed (the execution status of this line is deduced): s >> path >> i_8;
-
881 painter->setClipPath(path, Qt::ClipOperation(i_8));
never executed (the execution status of this line is deduced): painter->setClipPath(path, Qt::ClipOperation(i_8));
-
882 break;
never executed: break;
0
883 } -
884 case QPicturePrivate::PdcSetRenderHint: -
885 s >> ul;
never executed (the execution status of this line is deduced): s >> ul;
-
886 painter->setRenderHint(QPainter::Antialiasing,
never executed (the execution status of this line is deduced): painter->setRenderHint(QPainter::Antialiasing,
-
887 bool(ul & QPainter::Antialiasing));
never executed (the execution status of this line is deduced): bool(ul & QPainter::Antialiasing));
-
888 painter->setRenderHint(QPainter::SmoothPixmapTransform,
never executed (the execution status of this line is deduced): painter->setRenderHint(QPainter::SmoothPixmapTransform,
-
889 bool(ul & QPainter::SmoothPixmapTransform));
never executed (the execution status of this line is deduced): bool(ul & QPainter::SmoothPixmapTransform));
-
890 break;
never executed: break;
0
891 case QPicturePrivate::PdcSetCompositionMode: -
892 s >> ul;
never executed (the execution status of this line is deduced): s >> ul;
-
893 painter->setCompositionMode((QPainter::CompositionMode)ul);
never executed (the execution status of this line is deduced): painter->setCompositionMode((QPainter::CompositionMode)ul);
-
894 break;
never executed: break;
0
895 case QPicturePrivate::PdcSetClipEnabled: -
896 s >> bl;
never executed (the execution status of this line is deduced): s >> bl;
-
897 painter->setClipping(bl);
never executed (the execution status of this line is deduced): painter->setClipping(bl);
-
898 break;
never executed: break;
0
899 case QPicturePrivate::PdcSetOpacity: -
900 s >> dbl;
never executed (the execution status of this line is deduced): s >> dbl;
-
901 painter->setOpacity(qreal(dbl));
never executed (the execution status of this line is deduced): painter->setOpacity(qreal(dbl));
-
902 break;
never executed: break;
0
903 default: -
904 qWarning("QPicture::play: Invalid command %d", c);
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 904, __PRETTY_FUNCTION__).warning("QPicture::play: Invalid command %d", c);
-
905 if (len) // skip unknown command
never evaluated: len
0
906 s.device()->seek(s.device()->pos()+len);
never executed: s.device()->seek(s.device()->pos()+len);
0
907 }
never executed: }
0
908#if defined(QT_DEBUG) -
909 //qDebug("device->at(): %i, strm_pos: %i len: %i", (int)s.device()->pos(), strm_pos, len); -
910 Q_ASSERT(qint32(s.device()->pos() - strm_pos) == len); -
911#endif -
912 }
executed: }
Execution Count:2
2
913 return false;
never executed: return false;
0
914} -
915 -
916/*! -
917 \internal -
918 -
919 Internal implementation of the virtual QPaintDevice::metric() -
920 function. -
921 -
922 A picture has the following hard-coded values: numcolors=16777216 -
923 and depth=24. -
924 -
925 \a m is the metric to get. -
926*/ -
927 -
928int QPicture::metric(PaintDeviceMetric m) const -
929{ -
930 int val;
executed (the execution status of this line is deduced): int val;
-
931 QRect brect = boundingRect();
executed (the execution status of this line is deduced): QRect brect = boundingRect();
-
932 switch (m) { -
933 case PdmWidth: -
934 val = brect.width();
executed (the execution status of this line is deduced): val = brect.width();
-
935 break;
executed: break;
Execution Count:16
16
936 case PdmHeight: -
937 val = brect.height();
executed (the execution status of this line is deduced): val = brect.height();
-
938 break;
executed: break;
Execution Count:16
16
939 case PdmWidthMM: -
940 val = int(25.4/qt_defaultDpiX()*brect.width());
never executed (the execution status of this line is deduced): val = int(25.4/qt_defaultDpiX()*brect.width());
-
941 break;
never executed: break;
0
942 case PdmHeightMM: -
943 val = int(25.4/qt_defaultDpiY()*brect.height());
never executed (the execution status of this line is deduced): val = int(25.4/qt_defaultDpiY()*brect.height());
-
944 break;
never executed: break;
0
945 case PdmDpiX: -
946 case PdmPhysicalDpiX: -
947 val = qt_defaultDpiX();
executed (the execution status of this line is deduced): val = qt_defaultDpiX();
-
948 break;
executed: break;
Execution Count:5
5
949 case PdmDpiY: -
950 case PdmPhysicalDpiY: -
951 val = qt_defaultDpiY();
executed (the execution status of this line is deduced): val = qt_defaultDpiY();
-
952 break;
executed: break;
Execution Count:21
21
953 case PdmNumColors: -
954 val = 16777216;
never executed (the execution status of this line is deduced): val = 16777216;
-
955 break;
never executed: break;
0
956 case PdmDepth: -
957 val = 24;
never executed (the execution status of this line is deduced): val = 24;
-
958 break;
never executed: break;
0
959 default: -
960 val = 0;
never executed (the execution status of this line is deduced): val = 0;
-
961 qWarning("QPicture::metric: Invalid metric command");
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 961, __PRETTY_FUNCTION__).warning("QPicture::metric: Invalid metric command");
-
962 }
never executed: }
0
963 return val;
executed: return val;
Execution Count:58
58
964} -
965 -
966/*! -
967 \fn void QPicture::detach() -
968 \internal -
969 Detaches from shared picture data and makes sure that this picture -
970 is the only one referring to the data. -
971 -
972 If multiple pictures share common data, this picture makes a copy -
973 of the data and detaches itself from the sharing mechanism. -
974 Nothing is done if there is just a single reference. -
975*/ -
976 -
977/*! \fn bool QPicture::isDetached() const -
978\internal -
979*/ -
980 -
981/*! -
982 Assigns picture \a p to this picture and returns a reference to -
983 this picture. -
984*/ -
985QPicture& QPicture::operator=(const QPicture &p) -
986{ -
987 d_ptr = p.d_ptr;
executed (the execution status of this line is deduced): d_ptr = p.d_ptr;
-
988 return *this;
executed: return *this;
Execution Count:1
1
989} -
990 -
991/*! -
992 \fn void QPicture::swap(QPicture &other) -
993 \since 4.8 -
994 -
995 Swaps picture \a other with this picture. This operation is very -
996 fast and never fails. -
997*/ -
998 -
999/*! -
1000 \internal -
1001 -
1002 Constructs a QPicturePrivate -
1003*/ -
1004QPicturePrivate::QPicturePrivate() -
1005 : in_memory_only(false) -
1006{ -
1007}
executed: }
Execution Count:25
25
1008 -
1009/*! -
1010 \internal -
1011 -
1012 Copy-Constructs a QPicturePrivate. Needed when detaching. -
1013*/ -
1014QPicturePrivate::QPicturePrivate(const QPicturePrivate &other) -
1015 : trecs(other.trecs), -
1016 formatOk(other.formatOk), -
1017 formatMinor(other.formatMinor), -
1018 brect(other.brect), -
1019 override_rect(other.override_rect), -
1020 in_memory_only(false) -
1021{ -
1022 pictb.setData(other.pictb.data(), other.pictb.size());
never executed (the execution status of this line is deduced): pictb.setData(other.pictb.data(), other.pictb.size());
-
1023 if (other.pictb.isOpen()) {
never evaluated: other.pictb.isOpen()
0
1024 pictb.open(other.pictb.openMode());
never executed (the execution status of this line is deduced): pictb.open(other.pictb.openMode());
-
1025 pictb.seek(other.pictb.pos());
never executed (the execution status of this line is deduced): pictb.seek(other.pictb.pos());
-
1026 }
never executed: }
0
1027}
never executed: }
0
1028 -
1029/*! -
1030 \internal -
1031 -
1032 Sets formatOk to false and resets the format version numbers to default -
1033*/ -
1034 -
1035void QPicturePrivate::resetFormat() -
1036{ -
1037 formatOk = false;
executed (the execution status of this line is deduced): formatOk = false;
-
1038 formatMajor = mfhdr_maj;
executed (the execution status of this line is deduced): formatMajor = mfhdr_maj;
-
1039 formatMinor = mfhdr_min;
executed (the execution status of this line is deduced): formatMinor = mfhdr_min;
-
1040}
executed: }
Execution Count:119
119
1041 -
1042 -
1043/*! -
1044 \internal -
1045 -
1046 Checks data integrity and format version number. Set formatOk to -
1047 true on success, to false otherwise. Returns the resulting formatOk -
1048 value. -
1049*/ -
1050bool QPicturePrivate::checkFormat() -
1051{ -
1052 resetFormat();
executed (the execution status of this line is deduced): resetFormat();
-
1053 -
1054 // can't check anything in an empty buffer -
1055 if (pictb.size() == 0 || pictb.isOpen())
evaluated: pictb.size() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:90
evaluated: pictb.isOpen()
TRUEFALSE
yes
Evaluation Count:85
yes
Evaluation Count:5
1-90
1056 return false;
executed: return false;
Execution Count:86
86
1057 -
1058 pictb.open(QIODevice::ReadOnly); // open buffer device
executed (the execution status of this line is deduced): pictb.open(QIODevice::ReadOnly);
-
1059 QDataStream s;
executed (the execution status of this line is deduced): QDataStream s;
-
1060 s.setDevice(&pictb); // attach data stream to buffer
executed (the execution status of this line is deduced): s.setDevice(&pictb);
-
1061 -
1062 char mf_id[4]; // picture header tag
executed (the execution status of this line is deduced): char mf_id[4];
-
1063 s.readRawData(mf_id, 4); // read actual tag
executed (the execution status of this line is deduced): s.readRawData(mf_id, 4);
-
1064 if (memcmp(mf_id, qt_mfhdr_tag, 4) != 0) { // wrong header id
partially evaluated: memcmp(mf_id, qt_mfhdr_tag, 4) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1065 qWarning("QPicturePaintEngine::checkFormat: Incorrect header");
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 1065, __PRETTY_FUNCTION__).warning("QPicturePaintEngine::checkFormat: Incorrect header");
-
1066 pictb.close();
never executed (the execution status of this line is deduced): pictb.close();
-
1067 return false;
never executed: return false;
0
1068 } -
1069 -
1070 int cs_start = sizeof(quint32); // pos of checksum word
executed (the execution status of this line is deduced): int cs_start = sizeof(quint32);
-
1071 int data_start = cs_start + sizeof(quint16);
executed (the execution status of this line is deduced): int data_start = cs_start + sizeof(quint16);
-
1072 quint16 cs,ccs;
executed (the execution status of this line is deduced): quint16 cs,ccs;
-
1073 QByteArray buf = pictb.buffer(); // pointer to data
executed (the execution status of this line is deduced): QByteArray buf = pictb.buffer();
-
1074 -
1075 s >> cs; // read checksum
executed (the execution status of this line is deduced): s >> cs;
-
1076 ccs = (quint16) qChecksum(buf.constData() + data_start, buf.size() - data_start);
executed (the execution status of this line is deduced): ccs = (quint16) qChecksum(buf.constData() + data_start, buf.size() - data_start);
-
1077 if (ccs != cs) {
partially evaluated: ccs != cs
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1078 qWarning("QPicturePaintEngine::checkFormat: Invalid checksum %x, %x expected",
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 1078, __PRETTY_FUNCTION__).warning("QPicturePaintEngine::checkFormat: Invalid checksum %x, %x expected",
-
1079 ccs, cs);
never executed (the execution status of this line is deduced): ccs, cs);
-
1080 pictb.close();
never executed (the execution status of this line is deduced): pictb.close();
-
1081 return false;
never executed: return false;
0
1082 } -
1083 -
1084 quint16 major, minor;
executed (the execution status of this line is deduced): quint16 major, minor;
-
1085 s >> major >> minor; // read version number
executed (the execution status of this line is deduced): s >> major >> minor;
-
1086 if (major > mfhdr_maj) { // new, incompatible version
partially evaluated: major > mfhdr_maj
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1087 qWarning("QPicturePaintEngine::checkFormat: Incompatible version %d.%d",
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 1087, __PRETTY_FUNCTION__).warning("QPicturePaintEngine::checkFormat: Incompatible version %d.%d",
-
1088 major, minor);
never executed (the execution status of this line is deduced): major, minor);
-
1089 pictb.close();
never executed (the execution status of this line is deduced): pictb.close();
-
1090 return false;
never executed: return false;
0
1091 } -
1092 s.setVersion(major != 4 ? major : 3);
executed (the execution status of this line is deduced): s.setVersion(major != 4 ? major : 3);
-
1093 -
1094 quint8 c, clen;
executed (the execution status of this line is deduced): quint8 c, clen;
-
1095 s >> c >> clen;
executed (the execution status of this line is deduced): s >> c >> clen;
-
1096 if (c == QPicturePrivate::PdcBegin) {
partially evaluated: c == QPicturePrivate::PdcBegin
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1097 if (!(major >= 1 && major <= 3)) {
partially evaluated: major >= 1
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
partially evaluated: major <= 3
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1098 qint32 l, t, w, h;
executed (the execution status of this line is deduced): qint32 l, t, w, h;
-
1099 s >> l >> t >> w >> h;
executed (the execution status of this line is deduced): s >> l >> t >> w >> h;
-
1100 brect = QRect(l, t, w, h);
executed (the execution status of this line is deduced): brect = QRect(l, t, w, h);
-
1101 }
executed: }
Execution Count:5
5
1102 } else {
executed: }
Execution Count:5
5
1103 qWarning("QPicturePaintEngine::checkFormat: Format error");
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 1103, __PRETTY_FUNCTION__).warning("QPicturePaintEngine::checkFormat: Format error");
-
1104 pictb.close();
never executed (the execution status of this line is deduced): pictb.close();
-
1105 return false;
never executed: return false;
0
1106 } -
1107 pictb.close();
executed (the execution status of this line is deduced): pictb.close();
-
1108 -
1109 formatOk = true; // picture seems to be ok
executed (the execution status of this line is deduced): formatOk = true;
-
1110 formatMajor = major;
executed (the execution status of this line is deduced): formatMajor = major;
-
1111 formatMinor = minor;
executed (the execution status of this line is deduced): formatMinor = minor;
-
1112 return true;
executed: return true;
Execution Count:5
5
1113} -
1114 -
1115/*! \internal */ -
1116QPaintEngine *QPicture::paintEngine() const -
1117{ -
1118 if (!d_func()->paintEngine)
partially evaluated: !d_func()->paintEngine
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
1119 const_cast<QPicture*>(this)->d_func()->paintEngine.reset(new QPicturePaintEngine);
executed: const_cast<QPicture*>(this)->d_func()->paintEngine.reset(new QPicturePaintEngine);
Execution Count:16
16
1120 return d_func()->paintEngine.data();
executed: return d_func()->paintEngine.data();
Execution Count:16
16
1121} -
1122 -
1123/***************************************************************************** -
1124 QPicture stream functions -
1125 *****************************************************************************/ -
1126 -
1127#ifndef QT_NO_DATASTREAM -
1128/*! -
1129 \relates QPicture -
1130 -
1131 Writes picture \a r to the stream \a s and returns a reference to -
1132 the stream. -
1133*/ -
1134 -
1135QDataStream &operator<<(QDataStream &s, const QPicture &r) -
1136{ -
1137 quint32 size = r.d_func()->pictb.buffer().size();
executed (the execution status of this line is deduced): quint32 size = r.d_func()->pictb.buffer().size();
-
1138 s << size;
executed (the execution status of this line is deduced): s << size;
-
1139 // null picture ? -
1140 if (size == 0)
evaluated: size == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1141 return s;
executed: return s;
Execution Count:1
1
1142 // just write the whole buffer to the stream -
1143 s.writeRawData (r.d_func()->pictb.buffer(), r.d_func()->pictb.buffer().size());
executed (the execution status of this line is deduced): s.writeRawData (r.d_func()->pictb.buffer(), r.d_func()->pictb.buffer().size());
-
1144 return s;
executed: return s;
Execution Count:2
2
1145} -
1146 -
1147/*! -
1148 \relates QPicture -
1149 -
1150 Reads a picture from the stream \a s into picture \a r and returns -
1151 a reference to the stream. -
1152*/ -
1153 -
1154QDataStream &operator>>(QDataStream &s, QPicture &r) -
1155{ -
1156 QDataStream sr;
executed (the execution status of this line is deduced): QDataStream sr;
-
1157 -
1158 // "init"; this code is similar to the beginning of QPicture::cmd() -
1159 sr.setDevice(&r.d_func()->pictb);
executed (the execution status of this line is deduced): sr.setDevice(&r.d_func()->pictb);
-
1160 sr.setVersion(r.d_func()->formatMajor);
executed (the execution status of this line is deduced): sr.setVersion(r.d_func()->formatMajor);
-
1161 quint32 len;
executed (the execution status of this line is deduced): quint32 len;
-
1162 s >> len;
executed (the execution status of this line is deduced): s >> len;
-
1163 QByteArray data;
executed (the execution status of this line is deduced): QByteArray data;
-
1164 if (len > 0) {
evaluated: len > 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
1165 data.resize(len);
executed (the execution status of this line is deduced): data.resize(len);
-
1166 s.readRawData(data.data(), len);
executed (the execution status of this line is deduced): s.readRawData(data.data(), len);
-
1167 }
executed: }
Execution Count:2
2
1168 -
1169 r.d_func()->pictb.setData(data);
executed (the execution status of this line is deduced): r.d_func()->pictb.setData(data);
-
1170 r.d_func()->resetFormat();
executed (the execution status of this line is deduced): r.d_func()->resetFormat();
-
1171 return s;
executed: return s;
Execution Count:3
3
1172} -
1173#endif // QT_NO_DATASTREAM -
1174 -
1175 -
1176#ifndef QT_NO_PICTUREIO -
1177 -
1178QT_BEGIN_INCLUDE_NAMESPACE -
1179#include "qregexp.h" -
1180#include "qpictureformatplugin.h" -
1181QT_END_INCLUDE_NAMESPACE -
1182 -
1183/*! -
1184 \obsolete -
1185 -
1186 Returns a string that specifies the picture format of the file \a -
1187 fileName, or 0 if the file cannot be read or if the format is not -
1188 recognized. -
1189 -
1190 \sa load(), save() -
1191*/ -
1192 -
1193const char* QPicture::pictureFormat(const QString &fileName) -
1194{ -
1195 return QPictureIO::pictureFormat(fileName);
never executed: return QPictureIO::pictureFormat(fileName);
0
1196} -
1197 -
1198/*! -
1199 \obsolete -
1200 -
1201 Returns a list of picture formats that are supported for picture -
1202 input. -
1203 -
1204 \sa outputFormats(), inputFormatList(), QPictureIO -
1205*/ -
1206QList<QByteArray> QPicture::inputFormats() -
1207{ -
1208 return QPictureIO::inputFormats();
never executed: return QPictureIO::inputFormats();
0
1209} -
1210 -
1211static QStringList qToStringList(const QList<QByteArray> arr) -
1212{ -
1213 QStringList list;
never executed (the execution status of this line is deduced): QStringList list;
-
1214 for (int i = 0; i < arr.count(); ++i)
never evaluated: i < arr.count()
0
1215 list.append(QString::fromLatin1(arr.at(i)));
never executed: list.append(QString::fromLatin1(arr.at(i)));
0
1216 return list;
never executed: return list;
0
1217} -
1218 -
1219/*! -
1220 \obsolete -
1221 -
1222 Returns a list of picture formats that are supported for picture -
1223 input. -
1224 -
1225 Note that if you want to iterate over the list, you should iterate -
1226 over a copy, e.g. -
1227 \snippet picture/picture.cpp 2 -
1228 -
1229 \sa outputFormatList(), inputFormats(), QPictureIO -
1230*/ -
1231QStringList QPicture::inputFormatList() -
1232{ -
1233 return qToStringList(QPictureIO::inputFormats());
never executed: return qToStringList(QPictureIO::inputFormats());
0
1234} -
1235 -
1236 -
1237/*! -
1238 \obsolete -
1239 -
1240 Returns a list of picture formats that are supported for picture -
1241 output. -
1242 -
1243 Note that if you want to iterate over the list, you should iterate -
1244 over a copy, e.g. -
1245 \snippet picture/picture.cpp 3 -
1246 -
1247 \sa inputFormatList(), outputFormats(), QPictureIO -
1248*/ -
1249QStringList QPicture::outputFormatList() -
1250{ -
1251 return qToStringList(QPictureIO::outputFormats());
never executed: return qToStringList(QPictureIO::outputFormats());
0
1252} -
1253 -
1254/*! -
1255 \obsolete -
1256 -
1257 Returns a list of picture formats that are supported for picture -
1258 output. -
1259 -
1260 \sa inputFormats(), outputFormatList(), QPictureIO -
1261*/ -
1262QList<QByteArray> QPicture::outputFormats() -
1263{ -
1264 return QPictureIO::outputFormats();
never executed: return QPictureIO::outputFormats();
0
1265} -
1266 -
1267/***************************************************************************** -
1268 QPictureIO member functions -
1269 *****************************************************************************/ -
1270 -
1271/*! -
1272 \obsolete -
1273 -
1274 \class QPictureIO -
1275 -
1276 \brief The QPictureIO class contains parameters for loading and -
1277 saving pictures. -
1278 -
1279 \ingroup painting -
1280 \ingroup io -
1281 \inmodule QtGui -
1282 -
1283 QPictureIO contains a QIODevice object that is used for picture data -
1284 I/O. The programmer can install new picture file formats in addition -
1285 to those that Qt provides. -
1286 -
1287 You don't normally need to use this class; QPicture::load(), -
1288 QPicture::save(). -
1289 -
1290 \sa QPicture, QPixmap, QFile -
1291*/ -
1292 -
1293struct QPictureIOData -
1294{ -
1295 QPicture pi; // picture -
1296 int iostat; // IO status -
1297 QByteArray frmt; // picture format -
1298 QIODevice *iodev; // IO device -
1299 QString fname; // file name -
1300 QString descr; // picture description -
1301 const char *parameters; -
1302 int quality; -
1303 float gamma; -
1304}; -
1305 -
1306/*! -
1307 Constructs a QPictureIO object with all parameters set to zero. -
1308*/ -
1309 -
1310QPictureIO::QPictureIO() -
1311{ -
1312 init();
executed (the execution status of this line is deduced): init();
-
1313}
executed: }
Execution Count:1
1
1314 -
1315/*! -
1316 Constructs a QPictureIO object with the I/O device \a ioDevice and a -
1317 \a format tag. -
1318*/ -
1319 -
1320QPictureIO::QPictureIO(QIODevice *ioDevice, const char *format) -
1321{ -
1322 init();
never executed (the execution status of this line is deduced): init();
-
1323 d->iodev = ioDevice;
never executed (the execution status of this line is deduced): d->iodev = ioDevice;
-
1324 d->frmt = format;
never executed (the execution status of this line is deduced): d->frmt = format;
-
1325}
never executed: }
0
1326 -
1327/*! -
1328 Constructs a QPictureIO object with the file name \a fileName and a -
1329 \a format tag. -
1330*/ -
1331 -
1332QPictureIO::QPictureIO(const QString &fileName, const char* format) -
1333{ -
1334 init();
never executed (the execution status of this line is deduced): init();
-
1335 d->frmt = format;
never executed (the execution status of this line is deduced): d->frmt = format;
-
1336 d->fname = fileName;
never executed (the execution status of this line is deduced): d->fname = fileName;
-
1337}
never executed: }
0
1338 -
1339/*! -
1340 Contains initialization common to all QPictureIO constructors. -
1341*/ -
1342 -
1343void QPictureIO::init() -
1344{ -
1345 d = new QPictureIOData();
executed (the execution status of this line is deduced): d = new QPictureIOData();
-
1346 d->parameters = 0;
executed (the execution status of this line is deduced): d->parameters = 0;
-
1347 d->quality = -1; // default quality of the current format
executed (the execution status of this line is deduced): d->quality = -1;
-
1348 d->gamma=0.0f;
executed (the execution status of this line is deduced): d->gamma=0.0f;
-
1349 d->iostat = 0;
executed (the execution status of this line is deduced): d->iostat = 0;
-
1350 d->iodev = 0;
executed (the execution status of this line is deduced): d->iodev = 0;
-
1351}
executed: }
Execution Count:1
1
1352 -
1353/*! -
1354 Destroys the object and all related data. -
1355*/ -
1356 -
1357QPictureIO::~QPictureIO() -
1358{ -
1359 if (d->parameters)
partially evaluated: d->parameters
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1360 delete [] (char*)d->parameters;
never executed: delete [] (char*)d->parameters;
0
1361 delete d;
executed (the execution status of this line is deduced): delete d;
-
1362}
executed: }
Execution Count:1
1
1363 -
1364 -
1365/***************************************************************************** -
1366 QPictureIO picture handler functions -
1367 *****************************************************************************/ -
1368 -
1369class QPictureHandler -
1370{ -
1371public: -
1372 QPictureHandler(const char *f, const char *h, const QByteArray& fl, -
1373 picture_io_handler r, picture_io_handler w); -
1374 QByteArray format; // picture format -
1375 QRegExp header; // picture header pattern -
1376 enum TMode { Untranslated=0, TranslateIn, TranslateInOut } text_mode; -
1377 picture_io_handler read_picture; // picture read function -
1378 picture_io_handler write_picture; // picture write function -
1379 bool obsolete; // support not "published" -
1380}; -
1381 -
1382QPictureHandler::QPictureHandler(const char *f, const char *h, const QByteArray& fl, -
1383 picture_io_handler r, picture_io_handler w) -
1384 : format(f), header(QString::fromLatin1(h)) -
1385{ -
1386 text_mode = Untranslated;
never executed (the execution status of this line is deduced): text_mode = Untranslated;
-
1387 if (fl.contains('t'))
never evaluated: fl.contains('t')
0
1388 text_mode = TranslateIn;
never executed: text_mode = TranslateIn;
0
1389 else if (fl.contains('T'))
never evaluated: fl.contains('T')
0
1390 text_mode = TranslateInOut;
never executed: text_mode = TranslateInOut;
0
1391 obsolete = fl.contains('O');
never executed (the execution status of this line is deduced): obsolete = fl.contains('O');
-
1392 read_picture = r;
never executed (the execution status of this line is deduced): read_picture = r;
-
1393 write_picture = w;
never executed (the execution status of this line is deduced): write_picture = w;
-
1394}
never executed: }
0
1395 -
1396typedef QList<QPictureHandler *> QPHList; -
1397Q_GLOBAL_STATIC(QPHList, pictureHandlers)
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
1398 -
1399void qt_init_picture_plugins() -
1400{ -
1401#ifndef QT_NO_LIBRARY -
1402 typedef QMultiMap<int, QString> PluginKeyMap;
never executed (the execution status of this line is deduced): typedef QMultiMap<int, QString> PluginKeyMap;
-
1403 typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
never executed (the execution status of this line is deduced): typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
-
1404 -
1405 static QBasicMutex mutex; -
1406 QMutexLocker locker(&mutex);
never executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
1407 static QFactoryLoader loader(QPictureFormatInterface_iid, -
1408 QStringLiteral("/pictureformats")); -
1409 -
1410 const PluginKeyMap keyMap = loader.keyMap();
never executed (the execution status of this line is deduced): const PluginKeyMap keyMap = loader.keyMap();
-
1411 const PluginKeyMapConstIterator cend = keyMap.constEnd();
never executed (the execution status of this line is deduced): const PluginKeyMapConstIterator cend = keyMap.constEnd();
-
1412 for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
never evaluated: it != cend
0
1413 if (QPictureFormatPlugin *format = qobject_cast<QPictureFormatPlugin*>(loader.instance(it.key())))
never evaluated: QPictureFormatPlugin *format = qobject_cast<QPictureFormatPlugin*>(loader.instance(it.key()))
0
1414 format->installIOHandler(it.value());
never executed: format->installIOHandler(it.value());
0
1415 }
never executed: }
0
1416#endif -
1417}
never executed: }
0
1418 -
1419static void cleanup() -
1420{ -
1421 // make sure that picture handlers are delete before plugin manager -
1422 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1423 qDeleteAll(*list);
never executed (the execution status of this line is deduced): qDeleteAll(*list);
-
1424 list->clear();
never executed (the execution status of this line is deduced): list->clear();
-
1425 }
never executed: }
0
1426}
never executed: }
0
1427 -
1428void qt_init_picture_handlers() // initialize picture handlers -
1429{ -
1430 static QBasicAtomicInt done = Q_BASIC_ATOMIC_INITIALIZER(0); -
1431 if (done.testAndSetRelaxed(0, 1)) {
never evaluated: done.testAndSetRelaxed(0, 1)
0
1432 qAddPostRoutine(cleanup);
never executed (the execution status of this line is deduced): qAddPostRoutine(cleanup);
-
1433 }
never executed: }
0
1434}
never executed: }
0
1435 -
1436static QPictureHandler *get_picture_handler(const char *format) -
1437{ // get pointer to handler -
1438 qt_init_picture_handlers();
never executed (the execution status of this line is deduced): qt_init_picture_handlers();
-
1439 qt_init_picture_plugins();
never executed (the execution status of this line is deduced): qt_init_picture_plugins();
-
1440 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1441 for (int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1442 if (list->at(i)->format == format)
never evaluated: list->at(i)->format == format
0
1443 return list->at(i);
never executed: return list->at(i);
0
1444 }
never executed: }
0
1445 }
never executed: }
0
1446 return 0; // no such handler
never executed: return 0;
0
1447} -
1448 -
1449 -
1450/*! -
1451 Defines a picture I/O handler for the picture format called \a -
1452 format, which is recognized using the regular -
1453 expression defined in \a header, read using \a readPicture and -
1454 written using \a writePicture. -
1455 -
1456 \a flags is a string of single-character flags for this format. -
1457 The only flag defined currently is T (upper case), so the only -
1458 legal value for \a flags are "T" and the empty string. The "T" -
1459 flag means that the picture file is a text file, and Qt should treat -
1460 all newline conventions as equivalent. (XPM files and some PPM -
1461 files are text files for example.) -
1462 -
1463 \a format is used to select a handler to write a QPicture; \a header -
1464 is used to select a handler to read an picture file. -
1465 -
1466 If \a readPicture is a null pointer, the QPictureIO will not be able -
1467 to read pictures in \a format. If \a writePicture is a null pointer, -
1468 the QPictureIO will not be able to write pictures in \a format. If -
1469 both are null, the QPictureIO object is valid but useless. -
1470 -
1471 Example: -
1472 \snippet picture/picture.cpp 6 -
1473 \codeline -
1474 \snippet picture/picture.cpp 7 -
1475 \codeline -
1476 \snippet picture/picture.cpp 8 -
1477 -
1478 Before the regular expression test, all the 0 bytes in the file header are -
1479 converted to 1 bytes. This is done because when Qt was ASCII-based, QRegExp -
1480 could not handle 0 bytes in strings. -
1481 -
1482 The regexp is only applied on the first 14 bytes of the file. -
1483 -
1484 (Note that if one handlerIO supports writing a format and another -
1485 supports reading it, Qt supports both reading and writing. If two -
1486 handlers support the same operation, Qt chooses one arbitrarily.) -
1487*/ -
1488 -
1489void QPictureIO::defineIOHandler(const char *format, -
1490 const char *header, -
1491 const char *flags, -
1492 picture_io_handler readPicture, -
1493 picture_io_handler writePicture) -
1494{ -
1495 qt_init_picture_handlers();
never executed (the execution status of this line is deduced): qt_init_picture_handlers();
-
1496 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1497 QPictureHandler *p;
never executed (the execution status of this line is deduced): QPictureHandler *p;
-
1498 p = new QPictureHandler(format, header, QByteArray(flags), readPicture, writePicture);
never executed (the execution status of this line is deduced): p = new QPictureHandler(format, header, QByteArray(flags), readPicture, writePicture);
-
1499 list->prepend(p);
never executed (the execution status of this line is deduced): list->prepend(p);
-
1500 }
never executed: }
0
1501}
never executed: }
0
1502 -
1503 -
1504/***************************************************************************** -
1505 QPictureIO normal member functions -
1506 *****************************************************************************/ -
1507 -
1508/*! -
1509 Returns the picture currently set. -
1510 -
1511 \sa setPicture() -
1512*/ -
1513const QPicture &QPictureIO::picture() const { return d->pi; }
never executed: return d->pi;
0
1514 -
1515/*! -
1516 Returns the picture's IO status. A non-zero value indicates an -
1517 error, whereas 0 means that the IO operation was successful. -
1518 -
1519 \sa setStatus() -
1520*/ -
1521int QPictureIO::status() const { return d->iostat; }
never executed: return d->iostat;
0
1522 -
1523/*! -
1524 Returns the picture format string or 0 if no format has been -
1525 explicitly set. -
1526*/ -
1527const char *QPictureIO::format() const { return d->frmt; }
executed: return d->frmt;
Execution Count:2
2
1528 -
1529/*! -
1530 Returns the IO device currently set. -
1531 -
1532 \sa setIODevice() -
1533*/ -
1534QIODevice *QPictureIO::ioDevice() const { return d->iodev; }
never executed: return d->iodev;
0
1535 -
1536/*! -
1537 Returns the file name currently set. -
1538 -
1539 \sa setFileName() -
1540*/ -
1541QString QPictureIO::fileName() const { return d->fname; }
never executed: return d->fname;
0
1542 -
1543 -
1544/*! -
1545 Returns the picture description string. -
1546 -
1547 \sa setDescription() -
1548*/ -
1549QString QPictureIO::description() const { return d->descr; }
never executed: return d->descr;
0
1550 -
1551/*! -
1552 Sets the picture to \a picture. -
1553 -
1554 \sa picture() -
1555*/ -
1556void QPictureIO::setPicture(const QPicture &picture) -
1557{ -
1558 d->pi = picture;
never executed (the execution status of this line is deduced): d->pi = picture;
-
1559}
never executed: }
0
1560 -
1561/*! -
1562 Sets the picture IO status to \a status. A non-zero value indicates -
1563 an error, whereas 0 means that the IO operation was successful. -
1564 -
1565 \sa status() -
1566*/ -
1567void QPictureIO::setStatus(int status) -
1568{ -
1569 d->iostat = status;
never executed (the execution status of this line is deduced): d->iostat = status;
-
1570}
never executed: }
0
1571 -
1572/*! -
1573 Sets the picture format to \a format for the picture to be read or -
1574 written. -
1575 -
1576 It is necessary to specify a format before writing an picture, but -
1577 it is not necessary to specify a format before reading an picture. -
1578 -
1579 If no format has been set, Qt guesses the picture format before -
1580 reading it. If a format is set the picture will only be read if it -
1581 has that format. -
1582 -
1583 \sa read(), write(), format() -
1584*/ -
1585void QPictureIO::setFormat(const char *format) -
1586{ -
1587 d->frmt = format;
executed (the execution status of this line is deduced): d->frmt = format;
-
1588}
executed: }
Execution Count:2
2
1589 -
1590/*! -
1591 Sets the IO device to be used for reading or writing an picture. -
1592 -
1593 Setting the IO device allows pictures to be read/written to any -
1594 block-oriented QIODevice. -
1595 -
1596 If \a ioDevice is not null, this IO device will override file name -
1597 settings. -
1598 -
1599 \sa setFileName() -
1600*/ -
1601void QPictureIO::setIODevice(QIODevice *ioDevice) -
1602{ -
1603 d->iodev = ioDevice;
never executed (the execution status of this line is deduced): d->iodev = ioDevice;
-
1604}
never executed: }
0
1605 -
1606/*! -
1607 Sets the name of the file to read or write an picture from to \a -
1608 fileName. -
1609 -
1610 \sa setIODevice() -
1611*/ -
1612void QPictureIO::setFileName(const QString &fileName) -
1613{ -
1614 d->fname = fileName;
never executed (the execution status of this line is deduced): d->fname = fileName;
-
1615}
never executed: }
0
1616 -
1617/*! -
1618 Returns the quality of the written picture, related to the -
1619 compression ratio. -
1620 -
1621 \sa setQuality(), QPicture::save() -
1622*/ -
1623int QPictureIO::quality() const -
1624{ -
1625 return d->quality;
never executed: return d->quality;
0
1626} -
1627 -
1628/*! -
1629 Sets the quality of the written picture to \a q, related to the -
1630 compression ratio. -
1631 -
1632 \a q must be in the range -1..100. Specify 0 to obtain small -
1633 compressed files, 100 for large uncompressed files. (-1 signifies -
1634 the default compression.) -
1635 -
1636 \sa quality(), QPicture::save() -
1637*/ -
1638 -
1639void QPictureIO::setQuality(int q) -
1640{ -
1641 d->quality = q;
never executed (the execution status of this line is deduced): d->quality = q;
-
1642}
never executed: }
0
1643 -
1644/*! -
1645 Returns the picture's parameters string. -
1646 -
1647 \sa setParameters() -
1648*/ -
1649 -
1650const char *QPictureIO::parameters() const -
1651{ -
1652 return d->parameters;
executed: return d->parameters;
Execution Count:2
2
1653} -
1654 -
1655/*! -
1656 Sets the picture's parameter string to \a parameters. This is for -
1657 picture handlers that require special parameters. -
1658 -
1659 Although the current picture formats supported by Qt ignore the -
1660 parameters string, it may be used in future extensions or by -
1661 contributions (for example, JPEG). -
1662 -
1663 \sa parameters() -
1664*/ -
1665 -
1666void QPictureIO::setParameters(const char *parameters) -
1667{ -
1668 if (d->parameters)
evaluated: d->parameters
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1669 delete [] (char*)d->parameters;
executed: delete [] (char*)d->parameters;
Execution Count:1
1
1670 d->parameters = qstrdup(parameters);
executed (the execution status of this line is deduced): d->parameters = qstrdup(parameters);
-
1671}
executed: }
Execution Count:2
2
1672 -
1673/*! -
1674 Sets the gamma value at which the picture will be viewed to \a -
1675 gamma. If the picture format stores a gamma value for which the -
1676 picture is intended to be used, then this setting will be used to -
1677 modify the picture. Setting to 0.0 will disable gamma correction -
1678 (i.e. any specification in the file will be ignored). -
1679 -
1680 The default value is 0.0. -
1681 -
1682 \sa gamma() -
1683*/ -
1684void QPictureIO::setGamma(float gamma) -
1685{ -
1686 d->gamma=gamma;
never executed (the execution status of this line is deduced): d->gamma=gamma;
-
1687}
never executed: }
0
1688 -
1689/*! -
1690 Returns the gamma value at which the picture will be viewed. -
1691 -
1692 \sa setGamma() -
1693*/ -
1694float QPictureIO::gamma() const -
1695{ -
1696 return d->gamma;
never executed: return d->gamma;
0
1697} -
1698 -
1699/*! -
1700 Sets the picture description string for picture handlers that support -
1701 picture descriptions to \a description. -
1702 -
1703 Currently, no picture format supported by Qt uses the description -
1704 string. -
1705*/ -
1706 -
1707void QPictureIO::setDescription(const QString &description) -
1708{ -
1709 d->descr = description;
never executed (the execution status of this line is deduced): d->descr = description;
-
1710}
never executed: }
0
1711 -
1712 -
1713/*! -
1714 Returns a string that specifies the picture format of the file \a -
1715 fileName, or null if the file cannot be read or if the format is -
1716 not recognized. -
1717*/ -
1718 -
1719QByteArray QPictureIO::pictureFormat(const QString &fileName) -
1720{ -
1721 QFile file(fileName);
never executed (the execution status of this line is deduced): QFile file(fileName);
-
1722 QByteArray format;
never executed (the execution status of this line is deduced): QByteArray format;
-
1723 if (!file.open(QIODevice::ReadOnly))
never evaluated: !file.open(QIODevice::ReadOnly)
0
1724 return format;
never executed: return format;
0
1725 format = pictureFormat(&file);
never executed (the execution status of this line is deduced): format = pictureFormat(&file);
-
1726 file.close();
never executed (the execution status of this line is deduced): file.close();
-
1727 return format;
never executed: return format;
0
1728} -
1729 -
1730/*! -
1731 \overload -
1732 -
1733 Returns a string that specifies the picture format of the picture read -
1734 from IO device \a d, or 0 if the device cannot be read or if the -
1735 format is not recognized. -
1736 -
1737 Make sure that \a d is at the right position in the device (for -
1738 example, at the beginning of the file). -
1739 -
1740 \sa QIODevice::at() -
1741*/ -
1742 -
1743QByteArray QPictureIO::pictureFormat(QIODevice *d) -
1744{ -
1745 // if you change this change the documentation for defineIOHandler() -
1746 const int buflen = 14;
never executed (the execution status of this line is deduced): const int buflen = 14;
-
1747 -
1748 char buf[buflen];
never executed (the execution status of this line is deduced): char buf[buflen];
-
1749 char buf2[buflen];
never executed (the execution status of this line is deduced): char buf2[buflen];
-
1750 qt_init_picture_handlers();
never executed (the execution status of this line is deduced): qt_init_picture_handlers();
-
1751 qt_init_picture_plugins();
never executed (the execution status of this line is deduced): qt_init_picture_plugins();
-
1752 int pos = d->pos(); // save position
never executed (the execution status of this line is deduced): int pos = d->pos();
-
1753 int rdlen = d->read(buf, buflen); // read a few bytes
never executed (the execution status of this line is deduced): int rdlen = d->read(buf, buflen);
-
1754 -
1755 QByteArray format;
never executed (the execution status of this line is deduced): QByteArray format;
-
1756 if (rdlen != buflen)
never evaluated: rdlen != buflen
0
1757 return format;
never executed: return format;
0
1758 -
1759 memcpy(buf2, buf, buflen);
never executed (the execution status of this line is deduced): memcpy(buf2, buf, buflen);
-
1760 -
1761 for (int n = 0; n < rdlen; n++)
never evaluated: n < rdlen
0
1762 if (buf[n] == '\0')
never evaluated: buf[n] == '\0'
0
1763 buf[n] = '\001';
never executed: buf[n] = '\001';
0
1764 if (rdlen > 0) {
never evaluated: rdlen > 0
0
1765 buf[rdlen - 1] = '\0';
never executed (the execution status of this line is deduced): buf[rdlen - 1] = '\0';
-
1766 QString bufStr = QString::fromLatin1(buf);
never executed (the execution status of this line is deduced): QString bufStr = QString::fromLatin1(buf);
-
1767 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1768 for (int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1769 if (list->at(i)->header.indexIn(bufStr) != -1) { // try match with headers
never evaluated: list->at(i)->header.indexIn(bufStr) != -1
0
1770 format = list->at(i)->format;
never executed (the execution status of this line is deduced): format = list->at(i)->format;
-
1771 break;
never executed: break;
0
1772 } -
1773 }
never executed: }
0
1774 }
never executed: }
0
1775 }
never executed: }
0
1776 d->seek(pos); // restore position
never executed (the execution status of this line is deduced): d->seek(pos);
-
1777 return format;
never executed: return format;
0
1778} -
1779 -
1780/*! -
1781 Returns a sorted list of picture formats that are supported for -
1782 picture input. -
1783*/ -
1784QList<QByteArray> QPictureIO::inputFormats() -
1785{ -
1786 QList<QByteArray> result;
never executed (the execution status of this line is deduced): QList<QByteArray> result;
-
1787 -
1788 qt_init_picture_handlers();
never executed (the execution status of this line is deduced): qt_init_picture_handlers();
-
1789 qt_init_picture_plugins();
never executed (the execution status of this line is deduced): qt_init_picture_plugins();
-
1790 -
1791 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1792 for (int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1793 QPictureHandler *p = list->at(i);
never executed (the execution status of this line is deduced): QPictureHandler *p = list->at(i);
-
1794 if (p->read_picture && !p->obsolete && !result.contains(p->format))
never evaluated: p->read_picture
never evaluated: !p->obsolete
never evaluated: !result.contains(p->format)
0
1795 result.append(p->format);
never executed: result.append(p->format);
0
1796 }
never executed: }
0
1797 }
never executed: }
0
1798 qSort(result);
never executed (the execution status of this line is deduced): qSort(result);
-
1799 -
1800 return result;
never executed: return result;
0
1801} -
1802 -
1803/*! -
1804 Returns a sorted list of picture formats that are supported for -
1805 picture output. -
1806*/ -
1807QList<QByteArray> QPictureIO::outputFormats() -
1808{ -
1809 qt_init_picture_handlers();
never executed (the execution status of this line is deduced): qt_init_picture_handlers();
-
1810 qt_init_picture_plugins();
never executed (the execution status of this line is deduced): qt_init_picture_plugins();
-
1811 -
1812 QList<QByteArray> result;
never executed (the execution status of this line is deduced): QList<QByteArray> result;
-
1813 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1814 for (int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1815 QPictureHandler *p = list->at(i);
never executed (the execution status of this line is deduced): QPictureHandler *p = list->at(i);
-
1816 if (p->write_picture && !p->obsolete && !result.contains(p->format))
never evaluated: p->write_picture
never evaluated: !p->obsolete
never evaluated: !result.contains(p->format)
0
1817 result.append(p->format);
never executed: result.append(p->format);
0
1818 }
never executed: }
0
1819 }
never executed: }
0
1820 return result;
never executed: return result;
0
1821} -
1822 -
1823 -
1824 -
1825/*! -
1826 Reads an picture into memory and returns true if the picture was -
1827 successfully read; otherwise returns false. -
1828 -
1829 Before reading an picture you must set an IO device or a file name. -
1830 If both an IO device and a file name have been set, the IO device -
1831 will be used. -
1832 -
1833 Setting the picture file format string is optional. -
1834 -
1835 Note that this function does \e not set the \l{format()}{format} used to read the picture. If you need that -
1836 information, use the pictureFormat() static functions. -
1837 -
1838 Example: -
1839 -
1840 \snippet picture/picture.cpp 4 -
1841 -
1842 \sa setIODevice(), setFileName(), setFormat(), write(), QPixmap::load() -
1843*/ -
1844bool QPictureIO::read() -
1845{ -
1846 QFile file;
never executed (the execution status of this line is deduced): QFile file;
-
1847 const char *picture_format;
never executed (the execution status of this line is deduced): const char *picture_format;
-
1848 QPictureHandler *h;
never executed (the execution status of this line is deduced): QPictureHandler *h;
-
1849 -
1850 if (d->iodev) { // read from io device
never evaluated: d->iodev
0
1851 // ok, already open -
1852 } else if (!d->fname.isEmpty()) { // read from file
never executed: }
never evaluated: !d->fname.isEmpty()
0
1853 file.setFileName(d->fname);
never executed (the execution status of this line is deduced): file.setFileName(d->fname);
-
1854 if (!file.open(QIODevice::ReadOnly))
never evaluated: !file.open(QIODevice::ReadOnly)
0
1855 return false; // cannot open file
never executed: return false;
0
1856 d->iodev = &file;
never executed (the execution status of this line is deduced): d->iodev = &file;
-
1857 } else { // no file name or io device
never executed: }
0
1858 return false;
never executed: return false;
0
1859 } -
1860 if (d->frmt.isEmpty()) {
never evaluated: d->frmt.isEmpty()
0
1861 // Try to guess format -
1862 picture_format = pictureFormat(d->iodev); // get picture format
never executed (the execution status of this line is deduced): picture_format = pictureFormat(d->iodev);
-
1863 if (!picture_format) {
never evaluated: !picture_format
0
1864 if (file.isOpen()) { // unknown format
never evaluated: file.isOpen()
0
1865 file.close();
never executed (the execution status of this line is deduced): file.close();
-
1866 d->iodev = 0;
never executed (the execution status of this line is deduced): d->iodev = 0;
-
1867 }
never executed: }
0
1868 return false;
never executed: return false;
0
1869 } -
1870 } else {
never executed: }
0
1871 picture_format = d->frmt;
never executed (the execution status of this line is deduced): picture_format = d->frmt;
-
1872 }
never executed: }
0
1873 -
1874 h = get_picture_handler(picture_format);
never executed (the execution status of this line is deduced): h = get_picture_handler(picture_format);
-
1875 if (file.isOpen()) {
never evaluated: file.isOpen()
0
1876#if !defined(Q_OS_UNIX) -
1877 if (h && h->text_mode) { // reopen in translated mode -
1878 file.close(); -
1879 file.open(QIODevice::ReadOnly | QIODevice::Text); -
1880 } -
1881 else -
1882#endif -
1883 file.seek(0); // position to start
never executed (the execution status of this line is deduced): file.seek(0);
-
1884 }
never executed: }
0
1885 d->iostat = 1; // assume error
never executed (the execution status of this line is deduced): d->iostat = 1;
-
1886 -
1887 if (h && h->read_picture)
never evaluated: h
never evaluated: h->read_picture
0
1888 (*h->read_picture)(this);
never executed: (*h->read_picture)(this);
0
1889 -
1890 if (file.isOpen()) { // picture was read using file
never evaluated: file.isOpen()
0
1891 file.close();
never executed (the execution status of this line is deduced): file.close();
-
1892 d->iodev = 0;
never executed (the execution status of this line is deduced): d->iodev = 0;
-
1893 }
never executed: }
0
1894 return d->iostat == 0; // picture successfully read?
never executed: return d->iostat == 0;
0
1895} -
1896 -
1897 -
1898/*! -
1899 Writes an picture to an IO device and returns true if the picture was -
1900 successfully written; otherwise returns false. -
1901 -
1902 Before writing an picture you must set an IO device or a file name. -
1903 If both an IO device and a file name have been set, the IO device -
1904 will be used. -
1905 -
1906 The picture will be written using the specified picture format. -
1907 -
1908 Example: -
1909 \snippet picture/picture.cpp 5 -
1910 -
1911 \sa setIODevice(), setFileName(), setFormat(), read(), QPixmap::save() -
1912*/ -
1913bool QPictureIO::write() -
1914{ -
1915 if (d->frmt.isEmpty())
never evaluated: d->frmt.isEmpty()
0
1916 return false;
never executed: return false;
0
1917 QPictureHandler *h = get_picture_handler(d->frmt);
never executed (the execution status of this line is deduced): QPictureHandler *h = get_picture_handler(d->frmt);
-
1918 if (!h || !h->write_picture) {
never evaluated: !h
never evaluated: !h->write_picture
0
1919 qWarning("QPictureIO::write: No such picture format handler: %s",
never executed (the execution status of this line is deduced): QMessageLogger("image/qpicture.cpp", 1919, __PRETTY_FUNCTION__).warning("QPictureIO::write: No such picture format handler: %s",
-
1920 format());
never executed (the execution status of this line is deduced): format());
-
1921 return false;
never executed: return false;
0
1922 } -
1923 QFile file;
never executed (the execution status of this line is deduced): QFile file;
-
1924 if (!d->iodev && !d->fname.isEmpty()) {
never evaluated: !d->iodev
never evaluated: !d->fname.isEmpty()
0
1925 file.setFileName(d->fname);
never executed (the execution status of this line is deduced): file.setFileName(d->fname);
-
1926 bool translate = h->text_mode==QPictureHandler::TranslateInOut;
never executed (the execution status of this line is deduced): bool translate = h->text_mode==QPictureHandler::TranslateInOut;
-
1927 QIODevice::OpenMode fmode = translate ? QIODevice::WriteOnly | QIODevice::Text : QIODevice::OpenMode(QIODevice::WriteOnly);
never evaluated: translate
0
1928 if (!file.open(fmode)) // couldn't create file
never evaluated: !file.open(fmode)
0
1929 return false;
never executed: return false;
0
1930 d->iodev = &file;
never executed (the execution status of this line is deduced): d->iodev = &file;
-
1931 }
never executed: }
0
1932 d->iostat = 1;
never executed (the execution status of this line is deduced): d->iostat = 1;
-
1933 (*h->write_picture)(this);
never executed (the execution status of this line is deduced): (*h->write_picture)(this);
-
1934 if (file.isOpen()) { // picture was written using file
never evaluated: file.isOpen()
0
1935 file.close();
never executed (the execution status of this line is deduced): file.close();
-
1936 d->iodev = 0;
never executed (the execution status of this line is deduced): d->iodev = 0;
-
1937 }
never executed: }
0
1938 return d->iostat == 0; // picture successfully written?
never executed: return d->iostat == 0;
0
1939} -
1940#endif //QT_NO_PICTUREIO -
1941 -
1942QT_END_NAMESPACE -
1943 -
1944#endif // QT_NO_PICTURE -
1945 -
1946/*! -
1947 \typedef QPicture::DataPtr -
1948 \internal -
1949*/ -
1950 -
1951/*! -
1952 \fn DataPtr &QPicture::data_ptr() -
1953 \internal -
1954*/ -
1955 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial