image/qpicture.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8void qt_format_text(const QFont &fnt, const QRectF &_r, -
9 int tf, const QTextOption *opt, const QString& str, QRectF *brect, -
10 int tabstops, int *, int tabarraylen, -
11 QPainter *painter); -
12const char *qt_mfhdr_tag = "QPIC"; -
13static const quint16 mfhdr_maj = 11; -
14static const quint16 mfhdr_min = 0; -
15QPicture::QPicture(int formatVersion) -
16 : QPaintDevice(), -
17 d_ptr(new QPicturePrivate) -
18{ -
19 QPicturePrivate * const d = d_func(); -
20 -
21 if (formatVersion == 0)
partially evaluated: formatVersion == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
22 QMessageLogger("image/qpicture.cpp", 136, __PRETTY_FUNCTION__).warning("QPicture: invalid format version 0");
never executed: QMessageLogger("image/qpicture.cpp", 136, __PRETTY_FUNCTION__).warning("QPicture: invalid format version 0");
0
23 -
24 -
25 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
26 d->formatMajor = formatVersion; -
27 d->formatMinor = 0; -
28 d->formatOk = false; -
29 } else {
never executed: }
0
30 d->resetFormat(); -
31 }
executed: }
Execution Count:25
25
32} -
33 -
34 -
35 -
36 -
37 -
38 -
39 -
40QPicture::QPicture(const QPicture &pic) -
41 : QPaintDevice(), d_ptr(pic.d_ptr) -
42{ -
43}
executed: }
Execution Count:2
2
44 -
45 -
46QPicture::QPicture(QPicturePrivate &dptr) -
47 : QPaintDevice(), -
48 d_ptr(&dptr) -
49{ -
50}
never executed: }
0
51 -
52 -
53 -
54 -
55QPicture::~QPicture() -
56{ -
57} -
58 -
59 -
60 -
61 -
62int QPicture::devType() const -
63{ -
64 return QInternal::Picture;
executed: return QInternal::Picture;
Execution Count:65
65
65} -
66bool QPicture::isNull() const -
67{ -
68 return d_func()->pictb.buffer().isNull();
executed: return d_func()->pictb.buffer().isNull();
Execution Count:2
2
69} -
70 -
71uint QPicture::size() const -
72{ -
73 return d_func()->pictb.buffer().size();
executed: return d_func()->pictb.buffer().size();
Execution Count:4
4
74} -
75 -
76const char* QPicture::data() const -
77{ -
78 return d_func()->pictb.buffer();
executed: return d_func()->pictb.buffer();
Execution Count:2
2
79} -
80 -
81void QPicture::detach() -
82{ -
83 d_ptr.detach(); -
84}
never executed: }
0
85 -
86bool QPicture::isDetached() const -
87{ -
88 return d_func()->ref.load() == 1;
never executed: return d_func()->ref.load() == 1;
0
89} -
90void QPicture::setData(const char* data, uint size) -
91{ -
92 detach(); -
93 d_func()->pictb.setData(data, size); -
94 d_func()->resetFormat(); -
95}
never executed: }
0
96bool QPicture::load(const QString &fileName, const char *format) -
97{ -
98 QFile f(fileName); -
99 if (!f.open(QIODevice::ReadOnly)) {
never evaluated: !f.open(QIODevice::ReadOnly)
0
100 operator=(QPicture()); -
101 return false;
never executed: return false;
0
102 } -
103 return load(&f, format);
never executed: return load(&f, format);
0
104} -
105 -
106 -
107 -
108 -
109 -
110 -
111 -
112bool QPicture::load(QIODevice *dev, const char *format) -
113{ -
114 if(format) {
never evaluated: format
0
115 -
116 QPictureIO io(dev, format); -
117 if (io.read()) {
never evaluated: io.read()
0
118 operator=(io.picture()); -
119 return true;
never executed: return true;
0
120 } -
121 -
122 QMessageLogger("image/qpicture.cpp", 283, __PRETTY_FUNCTION__).warning("QPicture::load: No such picture format: %s", format); -
123 operator=(QPicture()); -
124 return false;
never executed: return false;
0
125 } -
126 -
127 detach(); -
128 QByteArray a = dev->readAll(); -
129 -
130 d_func()->pictb.setData(a); -
131 return d_func()->checkFormat();
never executed: return d_func()->checkFormat();
0
132} -
133bool QPicture::save(const QString &fileName, const char *format) -
134{ -
135 if (paintingActive()) {
never evaluated: paintingActive()
0
136 QMessageLogger("image/qpicture.cpp", 308, __PRETTY_FUNCTION__).warning("QPicture::save: still being painted on. " -
137 "Call QPainter::end() first"); -
138 return false;
never executed: return false;
0
139 } -
140 -
141 -
142 if(format) {
never evaluated: format
0
143 -
144 QPictureIO io(fileName, format); -
145 bool result = io.write(); -
146 if (result) {
never evaluated: result
0
147 operator=(io.picture()); -
148 } else if (format)
never executed: }
never evaluated: format
0
149 -
150 -
151 -
152 { -
153 QMessageLogger("image/qpicture.cpp", 325, __PRETTY_FUNCTION__).warning("QPicture::save: No such picture format: %s", format); -
154 }
never executed: }
0
155 return result;
never executed: return result;
0
156 } -
157 -
158 QFile f(fileName); -
159 if (!f.open(QIODevice::WriteOnly))
never evaluated: !f.open(QIODevice::WriteOnly)
0
160 return false;
never executed: return false;
0
161 return save(&f, format);
never executed: return save(&f, format);
0
162} -
163 -
164 -
165 -
166 -
167 -
168 -
169 -
170bool QPicture::save(QIODevice *dev, const char *format) -
171{ -
172 if (paintingActive()) {
partially evaluated: paintingActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
173 QMessageLogger("image/qpicture.cpp", 345, __PRETTY_FUNCTION__).warning("QPicture::save: still being painted on. " -
174 "Call QPainter::end() first"); -
175 return false;
never executed: return false;
0
176 } -
177 -
178 if(format) {
partially evaluated: format
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
179 -
180 QPictureIO io(dev, format); -
181 bool result = io.write(); -
182 if (result) {
never evaluated: result
0
183 operator=(io.picture()); -
184 } else if (format)
never executed: }
never evaluated: format
0
185 -
186 -
187 -
188 { -
189 QMessageLogger("image/qpicture.cpp", 361, __PRETTY_FUNCTION__).warning("QPicture::save: No such picture format: %s", format); -
190 }
never executed: }
0
191 return result;
never executed: return result;
0
192 } -
193 -
194 dev->write(d_func()->pictb.buffer(), d_func()->pictb.buffer().size()); -
195 return true;
executed: return true;
Execution Count:2
2
196} -
197 -
198 -
199 -
200 -
201 -
202 -
203QRect QPicture::boundingRect() const -
204{ -
205 const QPicturePrivate * const d = d_func(); -
206 -
207 if (!d->override_rect.isEmpty())
evaluated: !d->override_rect.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:94
6-94
208 return d->override_rect;
executed: return d->override_rect;
Execution Count:6
6
209 -
210 if (!d->formatOk)
evaluated: !d->formatOk
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:4
4-90
211 d_ptr->checkFormat();
executed: d_ptr->checkFormat();
Execution Count:90
90
212 -
213 return d->brect;
executed: return d->brect;
Execution Count:94
94
214} -
215 -
216 -
217 -
218 -
219 -
220 -
221void QPicture::setBoundingRect(const QRect &r) -
222{ -
223 d_func()->override_rect = r; -
224}
executed: }
Execution Count:3
3
225bool QPicture::play(QPainter *painter) -
226{ -
227 QPicturePrivate * const d = d_func(); -
228 -
229 if (d->pictb.size() == 0)
partially evaluated: d->pictb.size() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
230 return true;
never executed: return true;
0
231 -
232 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
233 return false;
never executed: return false;
0
234 -
235 d->pictb.open(QIODevice::ReadOnly); -
236 QDataStream s; -
237 s.setDevice(&d->pictb); -
238 s.device()->seek(10); -
239 s.setVersion(d->formatMajor == 4 ? 3 : d->formatMajor); -
240 -
241 quint8 c, clen; -
242 quint32 nrecords; -
243 s >> c >> clen; -
244 qt_noop(); -
245 -
246 if (d->formatMajor >= 4) {
partially evaluated: d->formatMajor >= 4
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
247 qint32 dummy; -
248 s >> dummy >> dummy >> dummy >> dummy; -
249 }
executed: }
Execution Count:1
1
250 s >> nrecords; -
251 if (!exec(painter, s, nrecords)) {
partially evaluated: !exec(painter, s, nrecords)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
252 QMessageLogger("image/qpicture.cpp", 433, __PRETTY_FUNCTION__).warning("QPicture::play: Format error"); -
253 d->pictb.close(); -
254 return false;
never executed: return false;
0
255 } -
256 d->pictb.close(); -
257 return true;
executed: return true;
Execution Count:1
1
258} -
259 -
260 -
261 -
262 -
263 -
264class QFakeDevice : public QPaintDevice -
265{ -
266public: -
267 QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); }
never executed: }
0
268 void setDpiX(int dpi) { dpi_x = dpi; }
never executed: }
0
269 void setDpiY(int dpi) { dpi_y = dpi; }
never executed: }
0
270 QPaintEngine *paintEngine() const { return 0; }
never executed: return 0;
0
271 int metric(PaintDeviceMetric m) const -
272 { -
273 switch(m) { -
274 case PdmPhysicalDpiX: -
275 case PdmDpiX: -
276 return dpi_x;
never executed: return dpi_x;
0
277 case PdmPhysicalDpiY: -
278 case PdmDpiY: -
279 return dpi_y;
never executed: return dpi_y;
0
280 default: -
281 return QPaintDevice::metric(m);
never executed: return QPaintDevice::metric(m);
0
282 } -
283 }
never executed: }
0
284 -
285private: -
286 int dpi_x; -
287 int dpi_y; -
288}; -
289 -
290 -
291 -
292 -
293 -
294 -
295 -
296bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords) -
297{ -
298 QPicturePrivate * const d = d_func(); -
299 -
300 -
301 -
302 quint8 c; -
303 quint8 tiny_len; -
304 qint32 len; -
305 qint16 i_16, i1_16, i2_16; -
306 qint8 i_8; -
307 quint32 ul; -
308 double dbl; -
309 bool bl; -
310 QByteArray str1; -
311 QString str; -
312 QPointF p, p1, p2; -
313 QPoint ip, ip1, ip2; -
314 QRect ir; -
315 QRectF r; -
316 QPolygonF a; -
317 QPolygon ia; -
318 QColor color; -
319 QFont font; -
320 QPen pen; -
321 QBrush brush; -
322 QRegion rgn; -
323 QMatrix wmatrix; -
324 QTransform matrix; -
325 -
326 QTransform worldMatrix = painter->transform(); -
327 worldMatrix.scale(qreal(painter->device()->logicalDpiX()) / qreal(qt_defaultDpiX()), -
328 qreal(painter->device()->logicalDpiY()) / qreal(qt_defaultDpiY())); -
329 painter->setTransform(worldMatrix); -
330 -
331 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
332 s >> c; -
333 s >> tiny_len; -
334 if (tiny_len == 255)
partially evaluated: tiny_len == 255
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
335 s >> len;
never executed: s >> len;
0
336 else -
337 len = tiny_len;
executed: len = tiny_len;
Execution Count:3
3
338 -
339 -
340 -
341 switch (c) { -
342 case QPicturePrivate::PdcNOP: -
343 break;
never executed: break;
0
344 case QPicturePrivate::PdcDrawPoint: -
345 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
346 s >> ip; -
347 painter->drawPoint(ip); -
348 } else {
never executed: }
0
349 s >> p; -
350 painter->drawPoint(p); -
351 }
never executed: }
0
352 break;
never executed: break;
0
353 case QPicturePrivate::PdcDrawPoints: -
354 -
355 -
356 -
357 break;
never executed: break;
0
358 case QPicturePrivate::PdcDrawPath: { -
359 QPainterPath path; -
360 s >> path; -
361 painter->drawPath(path); -
362 break;
executed: break;
Execution Count:2
2
363 } -
364 case QPicturePrivate::PdcDrawLine: -
365 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
366 s >> ip1 >> ip2; -
367 painter->drawLine(ip1, ip2); -
368 } else {
never executed: }
0
369 s >> p1 >> p2; -
370 painter->drawLine(p1, p2); -
371 }
never executed: }
0
372 break;
never executed: break;
0
373 case QPicturePrivate::PdcDrawRect: -
374 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
375 s >> ir; -
376 painter->drawRect(ir); -
377 } else {
never executed: }
0
378 s >> r; -
379 painter->drawRect(r); -
380 }
never executed: }
0
381 break;
never executed: break;
0
382 case QPicturePrivate::PdcDrawRoundRect: -
383 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
384 s >> ir >> i1_16 >> i2_16; -
385 painter->drawRoundedRect(ir, i1_16, i2_16, Qt::RelativeSize); -
386 } else {
never executed: }
0
387 s >> r >> i1_16 >> i2_16; -
388 painter->drawRoundedRect(r, i1_16, i2_16, Qt::RelativeSize); -
389 }
never executed: }
0
390 break;
never executed: break;
0
391 case QPicturePrivate::PdcDrawEllipse: -
392 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
393 s >> ir; -
394 painter->drawEllipse(ir); -
395 } else {
never executed: }
0
396 s >> r; -
397 painter->drawEllipse(r); -
398 }
never executed: }
0
399 break;
never executed: break;
0
400 case QPicturePrivate::PdcDrawArc: -
401 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
402 s >> ir; -
403 r = ir; -
404 } else {
never executed: }
0
405 s >> r; -
406 }
never executed: }
0
407 s >> i1_16 >> i2_16; -
408 painter->drawArc(r, i1_16, i2_16); -
409 break;
never executed: break;
0
410 case QPicturePrivate::PdcDrawPie: -
411 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
412 s >> ir; -
413 r = ir; -
414 } else {
never executed: }
0
415 s >> r; -
416 }
never executed: }
0
417 s >> i1_16 >> i2_16; -
418 painter->drawPie(r, i1_16, i2_16); -
419 break;
never executed: break;
0
420 case QPicturePrivate::PdcDrawChord: -
421 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
422 s >> ir; -
423 r = ir; -
424 } else {
never executed: }
0
425 s >> r; -
426 }
never executed: }
0
427 s >> i1_16 >> i2_16; -
428 painter->drawChord(r, i1_16, i2_16); -
429 break;
never executed: break;
0
430 case QPicturePrivate::PdcDrawLineSegments: -
431 s >> ia; -
432 painter->drawLines(ia); -
433 ia.clear(); -
434 break;
never executed: break;
0
435 case QPicturePrivate::PdcDrawPolyline: -
436 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
437 s >> ia; -
438 painter->drawPolyline(ia); -
439 ia.clear(); -
440 } else {
never executed: }
0
441 s >> a; -
442 painter->drawPolyline(a); -
443 a.clear(); -
444 }
never executed: }
0
445 break;
never executed: break;
0
446 case QPicturePrivate::PdcDrawPolygon: -
447 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
448 s >> ia >> i_8; -
449 painter->drawPolygon(ia, i_8 ? Qt::WindingFill : Qt::OddEvenFill); -
450 a.clear(); -
451 } else {
never executed: }
0
452 s >> a >> i_8; -
453 painter->drawPolygon(a, i_8 ? Qt::WindingFill : Qt::OddEvenFill); -
454 a.clear(); -
455 }
never executed: }
0
456 break;
never executed: break;
0
457 case QPicturePrivate::PdcDrawCubicBezier: { -
458 s >> ia; -
459 QPainterPath path; -
460 qt_noop(); -
461 path.moveTo(ia.at(0)); -
462 path.cubicTo(ia.at(1), ia.at(2), ia.at(3)); -
463 painter->strokePath(path, painter->pen()); -
464 a.clear(); -
465 } -
466 break;
never executed: break;
0
467 case QPicturePrivate::PdcDrawText: -
468 s >> ip >> str1; -
469 painter->drawText(ip, QString::fromLatin1(str1)); -
470 break;
never executed: break;
0
471 case QPicturePrivate::PdcDrawTextFormatted: -
472 s >> ir >> i_16 >> str1; -
473 painter->drawText(ir, i_16, QString::fromLatin1(str1)); -
474 break;
never executed: break;
0
475 case QPicturePrivate::PdcDrawText2: -
476 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
477 s >> ip >> str; -
478 painter->drawText(ip, str); -
479 } else {
never executed: }
0
480 s >> p >> str; -
481 painter->drawText(p, str); -
482 }
never executed: }
0
483 break;
never executed: break;
0
484 case QPicturePrivate::PdcDrawText2Formatted: -
485 s >> ir; -
486 s >> i_16; -
487 s >> str; -
488 painter->drawText(ir, i_16, str); -
489 break;
never executed: break;
0
490 case QPicturePrivate::PdcDrawTextItem: { -
491 s >> p >> str >> font >> ul; -
492 -
493 -
494 -
495 -
496 -
497 if (d->formatMajor >= 9) {
never evaluated: d->formatMajor >= 9
0
498 s >> dbl; -
499 QFont fnt(font); -
500 if (dbl != 1.0) {
never evaluated: dbl != 1.0
0
501 QFakeDevice fake; -
502 fake.setDpiX(qRound(dbl*qt_defaultDpiX())); -
503 fake.setDpiY(qRound(dbl*qt_defaultDpiY())); -
504 fnt = QFont(font, &fake); -
505 }
never executed: }
0
506 -
507 qreal justificationWidth; -
508 s >> justificationWidth; -
509 -
510 int flags = Qt::TextSingleLine | Qt::TextDontClip | Qt::TextForceLeftToRight; -
511 -
512 QSizeF size(1, 1); -
513 if (justificationWidth > 0) {
never evaluated: justificationWidth > 0
0
514 size.setWidth(justificationWidth); -
515 flags |= Qt::TextJustificationForced; -
516 flags |= Qt::AlignJustify; -
517 }
never executed: }
0
518 -
519 QFontMetrics fm(fnt); -
520 QPointF pt(p.x(), p.y() - fm.ascent()); -
521 qt_format_text(fnt, QRectF(pt, size), flags, 0, -
522 str, 0, 0, 0, 0, painter); -
523 } else {
never executed: }
0
524 qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, 0, -
525 str, 0, 0, 0, 0, painter); -
526 }
never executed: }
0
527 -
528 break;
never executed: break;
0
529 } -
530 case QPicturePrivate::PdcDrawPixmap: { -
531 QPixmap pixmap; -
532 if (d->formatMajor < 4) {
never evaluated: d->formatMajor < 4
0
533 s >> ip >> pixmap; -
534 painter->drawPixmap(ip, pixmap); -
535 } else if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
never executed: }
0
536 s >> ir >> pixmap; -
537 painter->drawPixmap(ir, pixmap); -
538 } else {
never executed: }
0
539 QRectF sr; -
540 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
541 int index; -
542 s >> r >> index >> sr; -
543 qt_noop(); -
544 pixmap = d->pixmap_list.at(index); -
545 } else {
never executed: }
0
546 s >> r >> pixmap >> sr; -
547 }
never executed: }
0
548 painter->drawPixmap(r, pixmap, sr); -
549 }
never executed: }
0
550 } -
551 break;
never executed: break;
0
552 case QPicturePrivate::PdcDrawTiledPixmap: { -
553 QPixmap pixmap; -
554 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
555 int index; -
556 s >> r >> index >> p; -
557 qt_noop(); -
558 pixmap = d->pixmap_list.at(index); -
559 } else {
never executed: }
0
560 s >> r >> pixmap >> p; -
561 }
never executed: }
0
562 painter->drawTiledPixmap(r, pixmap, p); -
563 } -
564 break;
never executed: break;
0
565 case QPicturePrivate::PdcDrawImage: { -
566 QImage image; -
567 if (d->formatMajor < 4) {
never evaluated: d->formatMajor < 4
0
568 s >> p >> image; -
569 painter->drawImage(p, image); -
570 } else if (d->formatMajor <= 5){
never executed: }
never evaluated: d->formatMajor <= 5
0
571 s >> ir >> image; -
572 painter->drawImage(ir, image, QRect(0, 0, ir.width(), ir.height())); -
573 } else {
never executed: }
0
574 QRectF sr; -
575 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
576 int index; -
577 s >> r >> index >> sr >> ul; -
578 qt_noop(); -
579 image = d->image_list.at(index); -
580 } else {
never executed: }
0
581 s >> r >> image >> sr >> ul; -
582 }
never executed: }
0
583 painter->drawImage(r, image, sr, Qt::ImageConversionFlags(ul)); -
584 }
never executed: }
0
585 } -
586 break;
never executed: break;
0
587 case QPicturePrivate::PdcBegin: -
588 s >> ul; -
589 if (!exec(painter, s, ul))
never evaluated: !exec(painter, s, ul)
0
590 return false;
never executed: return false;
0
591 break;
never executed: break;
0
592 case QPicturePrivate::PdcEnd: -
593 if (nrecords == 0)
partially evaluated: nrecords == 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
594 return true;
executed: return true;
Execution Count:1
1
595 break;
never executed: break;
0
596 case QPicturePrivate::PdcSave: -
597 painter->save(); -
598 break;
never executed: break;
0
599 case QPicturePrivate::PdcRestore: -
600 painter->restore(); -
601 break;
never executed: break;
0
602 case QPicturePrivate::PdcSetBkColor: -
603 s >> color; -
604 painter->setBackground(color); -
605 break;
never executed: break;
0
606 case QPicturePrivate::PdcSetBkMode: -
607 s >> i_8; -
608 painter->setBackgroundMode((Qt::BGMode)i_8); -
609 break;
never executed: break;
0
610 case QPicturePrivate::PdcSetROP: -
611 s >> i_8; -
612 break;
never executed: break;
0
613 case QPicturePrivate::PdcSetBrushOrigin: -
614 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
615 s >> ip; -
616 painter->setBrushOrigin(ip); -
617 } else {
never executed: }
0
618 s >> p; -
619 painter->setBrushOrigin(p); -
620 }
never executed: }
0
621 break;
never executed: break;
0
622 case QPicturePrivate::PdcSetFont: -
623 s >> font; -
624 painter->setFont(font); -
625 break;
never executed: break;
0
626 case QPicturePrivate::PdcSetPen: -
627 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
628 int index; -
629 s >> index; -
630 qt_noop(); -
631 pen = d->pen_list.at(index); -
632 } else {
never executed: }
0
633 s >> pen; -
634 }
never executed: }
0
635 painter->setPen(pen); -
636 break;
never executed: break;
0
637 case QPicturePrivate::PdcSetBrush: -
638 if (d->in_memory_only) {
never evaluated: d->in_memory_only
0
639 int index; -
640 s >> index; -
641 qt_noop(); -
642 brush = d->brush_list.at(index); -
643 } else {
never executed: }
0
644 s >> brush; -
645 }
never executed: }
0
646 painter->setBrush(brush); -
647 break;
never executed: break;
0
648 case QPicturePrivate::PdcSetVXform: -
649 s >> i_8; -
650 painter->setViewTransformEnabled(i_8); -
651 break;
never executed: break;
0
652 case QPicturePrivate::PdcSetWindow: -
653 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
654 s >> ir; -
655 painter->setWindow(ir); -
656 } else {
never executed: }
0
657 s >> r; -
658 painter->setWindow(r.toRect()); -
659 }
never executed: }
0
660 break;
never executed: break;
0
661 case QPicturePrivate::PdcSetViewport: -
662 if (d->formatMajor <= 5) {
never evaluated: d->formatMajor <= 5
0
663 s >> ir; -
664 painter->setViewport(ir); -
665 } else {
never executed: }
0
666 s >> r; -
667 painter->setViewport(r.toRect()); -
668 }
never executed: }
0
669 break;
never executed: break;
0
670 case QPicturePrivate::PdcSetWXform: -
671 s >> i_8; -
672 painter->setMatrixEnabled(i_8); -
673 break;
never executed: break;
0
674 case QPicturePrivate::PdcSetWMatrix: -
675 if (d->formatMajor >= 8) {
never evaluated: d->formatMajor >= 8
0
676 s >> matrix >> i_8; -
677 } else {
never executed: }
0
678 s >> wmatrix >> i_8; -
679 matrix = QTransform(wmatrix); -
680 }
never executed: }
0
681 -
682 painter->setTransform(matrix * worldMatrix, i_8); -
683 break;
never executed: break;
0
684 case QPicturePrivate::PdcSetClip: -
685 s >> i_8; -
686 painter->setClipping(i_8); -
687 break;
never executed: break;
0
688 case QPicturePrivate::PdcSetClipRegion: -
689 s >> rgn >> i_8; -
690 if (d->formatMajor >= 9) {
never evaluated: d->formatMajor >= 9
0
691 painter->setClipRegion(rgn, Qt::ClipOperation(i_8)); -
692 } else {
never executed: }
0
693 painter->setClipRegion(rgn); -
694 }
never executed: }
0
695 break;
never executed: break;
0
696 case QPicturePrivate::PdcSetClipPath: -
697 { -
698 QPainterPath path; -
699 s >> path >> i_8; -
700 painter->setClipPath(path, Qt::ClipOperation(i_8)); -
701 break;
never executed: break;
0
702 } -
703 case QPicturePrivate::PdcSetRenderHint: -
704 s >> ul; -
705 painter->setRenderHint(QPainter::Antialiasing, -
706 bool(ul & QPainter::Antialiasing)); -
707 painter->setRenderHint(QPainter::SmoothPixmapTransform, -
708 bool(ul & QPainter::SmoothPixmapTransform)); -
709 break;
never executed: break;
0
710 case QPicturePrivate::PdcSetCompositionMode: -
711 s >> ul; -
712 painter->setCompositionMode((QPainter::CompositionMode)ul); -
713 break;
never executed: break;
0
714 case QPicturePrivate::PdcSetClipEnabled: -
715 s >> bl; -
716 painter->setClipping(bl); -
717 break;
never executed: break;
0
718 case QPicturePrivate::PdcSetOpacity: -
719 s >> dbl; -
720 painter->setOpacity(qreal(dbl)); -
721 break;
never executed: break;
0
722 default: -
723 QMessageLogger("image/qpicture.cpp", 904, __PRETTY_FUNCTION__).warning("QPicture::play: Invalid command %d", c); -
724 if (len)
never evaluated: len
0
725 s.device()->seek(s.device()->pos()+len);
never executed: s.device()->seek(s.device()->pos()+len);
0
726 }
never executed: }
0
727 -
728 -
729 -
730 -
731 }
executed: }
Execution Count:2
2
732 return false;
never executed: return false;
0
733} -
734int QPicture::metric(PaintDeviceMetric m) const -
735{ -
736 int val; -
737 QRect brect = boundingRect(); -
738 switch (m) { -
739 case PdmWidth: -
740 val = brect.width(); -
741 break;
executed: break;
Execution Count:16
16
742 case PdmHeight: -
743 val = brect.height(); -
744 break;
executed: break;
Execution Count:16
16
745 case PdmWidthMM: -
746 val = int(25.4/qt_defaultDpiX()*brect.width()); -
747 break;
never executed: break;
0
748 case PdmHeightMM: -
749 val = int(25.4/qt_defaultDpiY()*brect.height()); -
750 break;
never executed: break;
0
751 case PdmDpiX: -
752 case PdmPhysicalDpiX: -
753 val = qt_defaultDpiX(); -
754 break;
executed: break;
Execution Count:5
5
755 case PdmDpiY: -
756 case PdmPhysicalDpiY: -
757 val = qt_defaultDpiY(); -
758 break;
executed: break;
Execution Count:21
21
759 case PdmNumColors: -
760 val = 16777216; -
761 break;
never executed: break;
0
762 case PdmDepth: -
763 val = 24; -
764 break;
never executed: break;
0
765 default: -
766 val = 0; -
767 QMessageLogger("image/qpicture.cpp", 961, __PRETTY_FUNCTION__).warning("QPicture::metric: Invalid metric command"); -
768 }
never executed: }
0
769 return val;
executed: return val;
Execution Count:58
58
770} -
771QPicture& QPicture::operator=(const QPicture &p) -
772{ -
773 d_ptr = p.d_ptr; -
774 return *this;
executed: return *this;
Execution Count:1
1
775} -
776QPicturePrivate::QPicturePrivate() -
777 : in_memory_only(false) -
778{ -
779}
executed: }
Execution Count:25
25
780 -
781 -
782 -
783 -
784 -
785 -
786QPicturePrivate::QPicturePrivate(const QPicturePrivate &other) -
787 : trecs(other.trecs), -
788 formatOk(other.formatOk), -
789 formatMinor(other.formatMinor), -
790 brect(other.brect), -
791 override_rect(other.override_rect), -
792 in_memory_only(false) -
793{ -
794 pictb.setData(other.pictb.data(), other.pictb.size()); -
795 if (other.pictb.isOpen()) {
never evaluated: other.pictb.isOpen()
0
796 pictb.open(other.pictb.openMode()); -
797 pictb.seek(other.pictb.pos()); -
798 }
never executed: }
0
799}
never executed: }
0
800 -
801 -
802 -
803 -
804 -
805 -
806 -
807void QPicturePrivate::resetFormat() -
808{ -
809 formatOk = false; -
810 formatMajor = mfhdr_maj; -
811 formatMinor = mfhdr_min; -
812}
executed: }
Execution Count:119
119
813bool QPicturePrivate::checkFormat() -
814{ -
815 resetFormat(); -
816 -
817 -
818 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
819 return false;
executed: return false;
Execution Count:86
86
820 -
821 pictb.open(QIODevice::ReadOnly); -
822 QDataStream s; -
823 s.setDevice(&pictb); -
824 -
825 char mf_id[4]; -
826 s.readRawData(mf_id, 4); -
827 if (memcmp(mf_id, qt_mfhdr_tag, 4) != 0) {
partially evaluated: memcmp(mf_id, qt_mfhdr_tag, 4) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
828 QMessageLogger("image/qpicture.cpp", 1065, __PRETTY_FUNCTION__).warning("QPicturePaintEngine::checkFormat: Incorrect header"); -
829 pictb.close(); -
830 return false;
never executed: return false;
0
831 } -
832 -
833 int cs_start = sizeof(quint32); -
834 int data_start = cs_start + sizeof(quint16); -
835 quint16 cs,ccs; -
836 QByteArray buf = pictb.buffer(); -
837 -
838 s >> cs; -
839 ccs = (quint16) qChecksum(buf.constData() + data_start, buf.size() - data_start); -
840 if (ccs != cs) {
partially evaluated: ccs != cs
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
841 QMessageLogger("image/qpicture.cpp", 1078, __PRETTY_FUNCTION__).warning("QPicturePaintEngine::checkFormat: Invalid checksum %x, %x expected", -
842 ccs, cs); -
843 pictb.close(); -
844 return false;
never executed: return false;
0
845 } -
846 -
847 quint16 major, minor; -
848 s >> major >> minor; -
849 if (major > mfhdr_maj) {
partially evaluated: major > mfhdr_maj
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
850 QMessageLogger("image/qpicture.cpp", 1087, __PRETTY_FUNCTION__).warning("QPicturePaintEngine::checkFormat: Incompatible version %d.%d", -
851 major, minor); -
852 pictb.close(); -
853 return false;
never executed: return false;
0
854 } -
855 s.setVersion(major != 4 ? major : 3); -
856 -
857 quint8 c, clen; -
858 s >> c >> clen; -
859 if (c == QPicturePrivate::PdcBegin) {
partially evaluated: c == QPicturePrivate::PdcBegin
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
860 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
861 qint32 l, t, w, h; -
862 s >> l >> t >> w >> h; -
863 brect = QRect(l, t, w, h); -
864 }
executed: }
Execution Count:5
5
865 } else {
executed: }
Execution Count:5
5
866 QMessageLogger("image/qpicture.cpp", 1103, __PRETTY_FUNCTION__).warning("QPicturePaintEngine::checkFormat: Format error"); -
867 pictb.close(); -
868 return false;
never executed: return false;
0
869 } -
870 pictb.close(); -
871 -
872 formatOk = true; -
873 formatMajor = major; -
874 formatMinor = minor; -
875 return true;
executed: return true;
Execution Count:5
5
876} -
877 -
878 -
879QPaintEngine *QPicture::paintEngine() const -
880{ -
881 if (!d_func()->paintEngine)
partially evaluated: !d_func()->paintEngine
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
882 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
883 return d_func()->paintEngine.data();
executed: return d_func()->paintEngine.data();
Execution Count:16
16
884} -
885QDataStream &operator<<(QDataStream &s, const QPicture &r) -
886{ -
887 quint32 size = r.d_func()->pictb.buffer().size(); -
888 s << size; -
889 -
890 if (size == 0)
evaluated: size == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
891 return s;
executed: return s;
Execution Count:1
1
892 -
893 s.writeRawData (r.d_func()->pictb.buffer(), r.d_func()->pictb.buffer().size()); -
894 return s;
executed: return s;
Execution Count:2
2
895} -
896QDataStream &operator>>(QDataStream &s, QPicture &r) -
897{ -
898 QDataStream sr; -
899 -
900 -
901 sr.setDevice(&r.d_func()->pictb); -
902 sr.setVersion(r.d_func()->formatMajor); -
903 quint32 len; -
904 s >> len; -
905 QByteArray data; -
906 if (len > 0) {
evaluated: len > 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
907 data.resize(len); -
908 s.readRawData(data.data(), len); -
909 }
executed: }
Execution Count:2
2
910 -
911 r.d_func()->pictb.setData(data); -
912 r.d_func()->resetFormat(); -
913 return s;
executed: return s;
Execution Count:3
3
914} -
915 -
916 -
917 -
918 -
919 -
920 -
921 -
922const char* QPicture::pictureFormat(const QString &fileName) -
923{ -
924 return QPictureIO::pictureFormat(fileName);
never executed: return QPictureIO::pictureFormat(fileName);
0
925} -
926QList<QByteArray> QPicture::inputFormats() -
927{ -
928 return QPictureIO::inputFormats();
never executed: return QPictureIO::inputFormats();
0
929} -
930 -
931static QStringList qToStringList(const QList<QByteArray> arr) -
932{ -
933 QStringList list; -
934 for (int i = 0; i < arr.count(); ++i)
never evaluated: i < arr.count()
0
935 list.append(QString::fromLatin1(arr.at(i)));
never executed: list.append(QString::fromLatin1(arr.at(i)));
0
936 return list;
never executed: return list;
0
937} -
938QStringList QPicture::inputFormatList() -
939{ -
940 return qToStringList(QPictureIO::inputFormats());
never executed: return qToStringList(QPictureIO::inputFormats());
0
941} -
942QStringList QPicture::outputFormatList() -
943{ -
944 return qToStringList(QPictureIO::outputFormats());
never executed: return qToStringList(QPictureIO::outputFormats());
0
945} -
946QList<QByteArray> QPicture::outputFormats() -
947{ -
948 return QPictureIO::outputFormats();
never executed: return QPictureIO::outputFormats();
0
949} -
950struct QPictureIOData -
951{ -
952 QPicture pi; -
953 int iostat; -
954 QByteArray frmt; -
955 QIODevice *iodev; -
956 QString fname; -
957 QString descr; -
958 const char *parameters; -
959 int quality; -
960 float gamma; -
961}; -
962 -
963 -
964 -
965 -
966 -
967QPictureIO::QPictureIO() -
968{ -
969 init(); -
970}
executed: }
Execution Count:1
1
971 -
972 -
973 -
974 -
975 -
976 -
977QPictureIO::QPictureIO(QIODevice *ioDevice, const char *format) -
978{ -
979 init(); -
980 d->iodev = ioDevice; -
981 d->frmt = format; -
982}
never executed: }
0
983 -
984 -
985 -
986 -
987 -
988 -
989QPictureIO::QPictureIO(const QString &fileName, const char* format) -
990{ -
991 init(); -
992 d->frmt = format; -
993 d->fname = fileName; -
994}
never executed: }
0
995 -
996 -
997 -
998 -
999 -
1000void QPictureIO::init() -
1001{ -
1002 d = new QPictureIOData(); -
1003 d->parameters = 0; -
1004 d->quality = -1; -
1005 d->gamma=0.0f; -
1006 d->iostat = 0; -
1007 d->iodev = 0; -
1008}
executed: }
Execution Count:1
1
1009 -
1010 -
1011 -
1012 -
1013 -
1014QPictureIO::~QPictureIO() -
1015{ -
1016 if (d->parameters)
partially evaluated: d->parameters
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1017 delete [] (char*)d->parameters;
never executed: delete [] (char*)d->parameters;
0
1018 delete d; -
1019}
executed: }
Execution Count:1
1
1020 -
1021 -
1022 -
1023 -
1024 -
1025 -
1026class QPictureHandler -
1027{ -
1028public: -
1029 QPictureHandler(const char *f, const char *h, const QByteArray& fl, -
1030 picture_io_handler r, picture_io_handler w); -
1031 QByteArray format; -
1032 QRegExp header; -
1033 enum TMode { Untranslated=0, TranslateIn, TranslateInOut } text_mode; -
1034 picture_io_handler read_picture; -
1035 picture_io_handler write_picture; -
1036 bool obsolete; -
1037}; -
1038 -
1039QPictureHandler::QPictureHandler(const char *f, const char *h, const QByteArray& fl, -
1040 picture_io_handler r, picture_io_handler w) -
1041 : format(f), header(QString::fromLatin1(h)) -
1042{ -
1043 text_mode = Untranslated; -
1044 if (fl.contains('t'))
never evaluated: fl.contains('t')
0
1045 text_mode = TranslateIn;
never executed: text_mode = TranslateIn;
0
1046 else if (fl.contains('T'))
never evaluated: fl.contains('T')
0
1047 text_mode = TranslateInOut;
never executed: text_mode = TranslateInOut;
0
1048 obsolete = fl.contains('O'); -
1049 read_picture = r; -
1050 write_picture = w; -
1051}
never executed: }
0
1052 -
1053typedef QList<QPictureHandler *> QPHList; -
1054static QPHList *pictureHandlers() { static QGlobalStatic<QPHList > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QPHList *x = new QPHList; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QPHList > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
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
1055 -
1056void qt_init_picture_plugins() -
1057{ -
1058 -
1059 typedef QMultiMap<int, QString> PluginKeyMap; -
1060 typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; -
1061 -
1062 static QBasicMutex mutex; -
1063 QMutexLocker locker(&mutex); -
1064 static QFactoryLoader loader("org.qt-project.Qt.QPictureFormatInterface", -
1065 QString::fromUtf8("" "/pictureformats" "", sizeof("/pictureformats") - 1)); -
1066 -
1067 const PluginKeyMap keyMap = loader.keyMap(); -
1068 const PluginKeyMapConstIterator cend = keyMap.constEnd(); -
1069 for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
never evaluated: it != cend
0
1070 if (QPictureFormatPlugin *format = qobject_cast<QPictureFormatPlugin*>(loader.instance(it.key())))
never evaluated: QPictureFormatPlugin *format = qobject_cast<QPictureFormatPlugin*>(loader.instance(it.key()))
0
1071 format->installIOHandler(it.value());
never executed: format->installIOHandler(it.value());
0
1072 }
never executed: }
0
1073 -
1074}
never executed: }
0
1075 -
1076static void cleanup() -
1077{ -
1078 -
1079 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1080 qDeleteAll(*list); -
1081 list->clear(); -
1082 }
never executed: }
0
1083}
never executed: }
0
1084 -
1085void qt_init_picture_handlers() -
1086{ -
1087 static QBasicAtomicInt done = { (0) }; -
1088 if (done.testAndSetRelaxed(0, 1)) {
never evaluated: done.testAndSetRelaxed(0, 1)
0
1089 qAddPostRoutine(cleanup); -
1090 }
never executed: }
0
1091}
never executed: }
0
1092 -
1093static QPictureHandler *get_picture_handler(const char *format) -
1094{ -
1095 qt_init_picture_handlers(); -
1096 qt_init_picture_plugins(); -
1097 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1098 for (int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1099 if (list->at(i)->format == format)
never evaluated: list->at(i)->format == format
0
1100 return list->at(i);
never executed: return list->at(i);
0
1101 }
never executed: }
0
1102 }
never executed: }
0
1103 return 0;
never executed: return 0;
0
1104} -
1105void QPictureIO::defineIOHandler(const char *format, -
1106 const char *header, -
1107 const char *flags, -
1108 picture_io_handler readPicture, -
1109 picture_io_handler writePicture) -
1110{ -
1111 qt_init_picture_handlers(); -
1112 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1113 QPictureHandler *p; -
1114 p = new QPictureHandler(format, header, QByteArray(flags), readPicture, writePicture); -
1115 list->prepend(p); -
1116 }
never executed: }
0
1117}
never executed: }
0
1118const QPicture &QPictureIO::picture() const { return d->pi; }
never executed: return d->pi;
0
1119 -
1120 -
1121 -
1122 -
1123 -
1124 -
1125 -
1126int QPictureIO::status() const { return d->iostat; }
never executed: return d->iostat;
0
1127 -
1128 -
1129 -
1130 -
1131 -
1132const char *QPictureIO::format() const { return d->frmt; }
executed: return d->frmt;
Execution Count:2
2
1133 -
1134 -
1135 -
1136 -
1137 -
1138 -
1139QIODevice *QPictureIO::ioDevice() const { return d->iodev; }
never executed: return d->iodev;
0
1140 -
1141 -
1142 -
1143 -
1144 -
1145 -
1146QString QPictureIO::fileName() const { return d->fname; }
never executed: return d->fname;
0
1147 -
1148 -
1149 -
1150 -
1151 -
1152 -
1153 -
1154QString QPictureIO::description() const { return d->descr; }
never executed: return d->descr;
0
1155 -
1156 -
1157 -
1158 -
1159 -
1160 -
1161void QPictureIO::setPicture(const QPicture &picture) -
1162{ -
1163 d->pi = picture; -
1164}
never executed: }
0
1165 -
1166 -
1167 -
1168 -
1169 -
1170 -
1171 -
1172void QPictureIO::setStatus(int status) -
1173{ -
1174 d->iostat = status; -
1175}
never executed: }
0
1176void QPictureIO::setFormat(const char *format) -
1177{ -
1178 d->frmt = format; -
1179}
executed: }
Execution Count:2
2
1180void QPictureIO::setIODevice(QIODevice *ioDevice) -
1181{ -
1182 d->iodev = ioDevice; -
1183}
never executed: }
0
1184 -
1185 -
1186 -
1187 -
1188 -
1189 -
1190 -
1191void QPictureIO::setFileName(const QString &fileName) -
1192{ -
1193 d->fname = fileName; -
1194}
never executed: }
0
1195 -
1196 -
1197 -
1198 -
1199 -
1200 -
1201 -
1202int QPictureIO::quality() const -
1203{ -
1204 return d->quality;
never executed: return d->quality;
0
1205} -
1206void QPictureIO::setQuality(int q) -
1207{ -
1208 d->quality = q; -
1209}
never executed: }
0
1210 -
1211 -
1212 -
1213 -
1214 -
1215 -
1216 -
1217const char *QPictureIO::parameters() const -
1218{ -
1219 return d->parameters;
executed: return d->parameters;
Execution Count:2
2
1220} -
1221void QPictureIO::setParameters(const char *parameters) -
1222{ -
1223 if (d->parameters)
evaluated: d->parameters
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1224 delete [] (char*)d->parameters;
executed: delete [] (char*)d->parameters;
Execution Count:1
1
1225 d->parameters = qstrdup(parameters); -
1226}
executed: }
Execution Count:2
2
1227void QPictureIO::setGamma(float gamma) -
1228{ -
1229 d->gamma=gamma; -
1230}
never executed: }
0
1231 -
1232 -
1233 -
1234 -
1235 -
1236 -
1237float QPictureIO::gamma() const -
1238{ -
1239 return d->gamma;
never executed: return d->gamma;
0
1240} -
1241void QPictureIO::setDescription(const QString &description) -
1242{ -
1243 d->descr = description; -
1244}
never executed: }
0
1245QByteArray QPictureIO::pictureFormat(const QString &fileName) -
1246{ -
1247 QFile file(fileName); -
1248 QByteArray format; -
1249 if (!file.open(QIODevice::ReadOnly))
never evaluated: !file.open(QIODevice::ReadOnly)
0
1250 return format;
never executed: return format;
0
1251 format = pictureFormat(&file); -
1252 file.close(); -
1253 return format;
never executed: return format;
0
1254} -
1255QByteArray QPictureIO::pictureFormat(QIODevice *d) -
1256{ -
1257 -
1258 const int buflen = 14; -
1259 -
1260 char buf[buflen]; -
1261 char buf2[buflen]; -
1262 qt_init_picture_handlers(); -
1263 qt_init_picture_plugins(); -
1264 int pos = d->pos(); -
1265 int rdlen = d->read(buf, buflen); -
1266 -
1267 QByteArray format; -
1268 if (rdlen != buflen)
never evaluated: rdlen != buflen
0
1269 return format;
never executed: return format;
0
1270 -
1271 memcpy(buf2, buf, buflen); -
1272 -
1273 for (int n = 0; n < rdlen; n++)
never evaluated: n < rdlen
0
1274 if (buf[n] == '\0')
never evaluated: buf[n] == '\0'
0
1275 buf[n] = '\001';
never executed: buf[n] = '\001';
0
1276 if (rdlen > 0) {
never evaluated: rdlen > 0
0
1277 buf[rdlen - 1] = '\0'; -
1278 QString bufStr = QString::fromLatin1(buf); -
1279 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1280 for (int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1281 if (list->at(i)->header.indexIn(bufStr) != -1) {
never evaluated: list->at(i)->header.indexIn(bufStr) != -1
0
1282 format = list->at(i)->format; -
1283 break;
never executed: break;
0
1284 } -
1285 }
never executed: }
0
1286 }
never executed: }
0
1287 }
never executed: }
0
1288 d->seek(pos); -
1289 return format;
never executed: return format;
0
1290} -
1291 -
1292 -
1293 -
1294 -
1295 -
1296QList<QByteArray> QPictureIO::inputFormats() -
1297{ -
1298 QList<QByteArray> result; -
1299 -
1300 qt_init_picture_handlers(); -
1301 qt_init_picture_plugins(); -
1302 -
1303 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1304 for (int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1305 QPictureHandler *p = list->at(i); -
1306 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
1307 result.append(p->format);
never executed: result.append(p->format);
0
1308 }
never executed: }
0
1309 }
never executed: }
0
1310 qSort(result); -
1311 -
1312 return result;
never executed: return result;
0
1313} -
1314 -
1315 -
1316 -
1317 -
1318 -
1319QList<QByteArray> QPictureIO::outputFormats() -
1320{ -
1321 qt_init_picture_handlers(); -
1322 qt_init_picture_plugins(); -
1323 -
1324 QList<QByteArray> result; -
1325 if (QPHList *list = pictureHandlers()) {
never evaluated: QPHList *list = pictureHandlers()
0
1326 for (int i = 0; i < list->size(); ++i) {
never evaluated: i < list->size()
0
1327 QPictureHandler *p = list->at(i); -
1328 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
1329 result.append(p->format);
never executed: result.append(p->format);
0
1330 }
never executed: }
0
1331 }
never executed: }
0
1332 return result;
never executed: return result;
0
1333} -
1334bool QPictureIO::read() -
1335{ -
1336 QFile file; -
1337 const char *picture_format; -
1338 QPictureHandler *h; -
1339 -
1340 if (d->iodev) {
never evaluated: d->iodev
0
1341 -
1342 } else if (!d->fname.isEmpty()) {
never executed: }
never evaluated: !d->fname.isEmpty()
0
1343 file.setFileName(d->fname); -
1344 if (!file.open(QIODevice::ReadOnly))
never evaluated: !file.open(QIODevice::ReadOnly)
0
1345 return false;
never executed: return false;
0
1346 d->iodev = &file; -
1347 } else {
never executed: }
0
1348 return false;
never executed: return false;
0
1349 } -
1350 if (d->frmt.isEmpty()) {
never evaluated: d->frmt.isEmpty()
0
1351 -
1352 picture_format = pictureFormat(d->iodev); -
1353 if (!picture_format) {
never evaluated: !picture_format
0
1354 if (file.isOpen()) {
never evaluated: file.isOpen()
0
1355 file.close(); -
1356 d->iodev = 0; -
1357 }
never executed: }
0
1358 return false;
never executed: return false;
0
1359 } -
1360 } else {
never executed: }
0
1361 picture_format = d->frmt; -
1362 }
never executed: }
0
1363 -
1364 h = get_picture_handler(picture_format); -
1365 if (file.isOpen()) {
never evaluated: file.isOpen()
0
1366 -
1367 -
1368 -
1369 -
1370 -
1371 -
1372 -
1373 file.seek(0); -
1374 }
never executed: }
0
1375 d->iostat = 1; -
1376 -
1377 if (h && h->read_picture)
never evaluated: h
never evaluated: h->read_picture
0
1378 (*h->read_picture)(this);
never executed: (*h->read_picture)(this);
0
1379 -
1380 if (file.isOpen()) {
never evaluated: file.isOpen()
0
1381 file.close(); -
1382 d->iodev = 0; -
1383 }
never executed: }
0
1384 return d->iostat == 0;
never executed: return d->iostat == 0;
0
1385} -
1386bool QPictureIO::write() -
1387{ -
1388 if (d->frmt.isEmpty())
never evaluated: d->frmt.isEmpty()
0
1389 return false;
never executed: return false;
0
1390 QPictureHandler *h = get_picture_handler(d->frmt); -
1391 if (!h || !h->write_picture) {
never evaluated: !h
never evaluated: !h->write_picture
0
1392 QMessageLogger("image/qpicture.cpp", 1919, __PRETTY_FUNCTION__).warning("QPictureIO::write: No such picture format handler: %s", -
1393 format()); -
1394 return false;
never executed: return false;
0
1395 } -
1396 QFile file; -
1397 if (!d->iodev && !d->fname.isEmpty()) {
never evaluated: !d->iodev
never evaluated: !d->fname.isEmpty()
0
1398 file.setFileName(d->fname); -
1399 bool translate = h->text_mode==QPictureHandler::TranslateInOut; -
1400 QIODevice::OpenMode fmode = translate ? QIODevice::WriteOnly | QIODevice::Text : QIODevice::OpenMode(QIODevice::WriteOnly);
never evaluated: translate
0
1401 if (!file.open(fmode))
never evaluated: !file.open(fmode)
0
1402 return false;
never executed: return false;
0
1403 d->iodev = &file; -
1404 }
never executed: }
0
1405 d->iostat = 1; -
1406 (*h->write_picture)(this); -
1407 if (file.isOpen()) {
never evaluated: file.isOpen()
0
1408 file.close(); -
1409 d->iodev = 0; -
1410 }
never executed: }
0
1411 return d->iostat == 0;
never executed: return d->iostat == 0;
0
1412} -
1413 -
1414 -
1415 -
1416 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial