Qt 4.8
Public Types | Public Functions | Static Public Functions | Protected Functions | Private Functions | Properties | Friends | List of all members
QPicture Class Reference

The QPicture class is a paint device that records and replays QPainter commands. More...

#include <qpicture.h>

Inheritance diagram for QPicture:
QPaintDevice

Public Types

typedef QExplicitlySharedDataPointer< QPicturePrivateDataPtr
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Public Functions

QRect boundingRect () const
 Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data. More...
 
const char * data () const
 Returns a pointer to the picture data. More...
 
DataPtrdata_ptr ()
 
void detach ()
 Detaches from shared picture data and makes sure that this picture is the only one referring to the data. More...
 
int devType () const
 
bool isDetached () const
 
bool isNull () const
 Returns true if the picture contains no data; otherwise returns false. More...
 
bool load (QIODevice *dev, const char *format=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.dev is the device to use for loading. More...
 
bool load (const QString &fileName, const char *format=0)
 Loads a picture from the file specified by fileName and returns true if successful; otherwise returns false. More...
 
QPictureoperator= (const QPicture &p)
 Assigns picture p to this picture and returns a reference to this picture. More...
 
QPaintEnginepaintEngine () const
 
bool play (QPainter *p)
 Replays the picture using painter, and returns true if successful; otherwise returns false. More...
 
 QPicture (int formatVersion=-1)
 Constructs an empty picture. More...
 
 QPicture (const QPicture &)
 Constructs a copy of pic. More...
 
bool save (QIODevice *dev, const char *format=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.dev is the device to use for saving. More...
 
bool save (const QString &fileName, const char *format=0)
 Saves a picture to the file specified by fileName and returns true if successful; otherwise returns false. More...
 
void setBoundingRect (const QRect &r)
 Sets the picture's bounding rectangle to r. More...
 
virtual void setData (const char *data, uint size)
 Sets the picture data directly from data and size. More...
 
uint size () const
 Returns the size of the picture data. More...
 
void swap (QPicture &other)
 Swaps picture other with this picture. More...
 
 ~QPicture ()
 Destroys the picture. More...
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
virtual HDC getDC () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
virtual void releaseDC (HDC hdc) const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Static Public Functions

static QStringList inputFormatList ()
 Returns a list of picture formats that are supported for picture input. More...
 
static QList< QByteArrayinputFormats ()
 Returns a list of picture formats that are supported for picture input. More...
 
static QStringList outputFormatList ()
 Returns a list of picture formats that are supported for picture output. More...
 
static QList< QByteArrayoutputFormats ()
 Returns a list of picture formats that are supported for picture output. More...
 
static const char * pictureFormat (const QString &fileName)
 Returns a string that specifies the picture format of the file fileName, or 0 if the file cannot be read or if the format is not recognized. More...
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 

Protected Functions

int metric (PaintDeviceMetric m) const
 Internal implementation of the virtual QPaintDevice::metric() function. More...
 
 QPicture (QPicturePrivate &data)
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Private Functions

void detach_helper ()
 
bool exec (QPainter *p, QDataStream &ds, int i)
 Iterates over the internal picture data and draws the picture using painter. More...
 

Properties

QExplicitlySharedDataPointer< QPicturePrivated_ptr
 

Friends

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &in, const QPicture &p)
 Writes picture r to the stream s and returns a reference to the stream. More...
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &in, QPicture &p)
 Reads a picture from the stream s into picture r and returns a reference to the stream. More...
 
class Q3Picture
 
class QAlphaPaintEngine
 
class QPicturePaintEngine
 
class QPreviewPaintEngine
 

Additional Inherited Members

- Protected Variables inherited from QPaintDevice
ushort painters
 

Detailed Description

The QPicture class is a paint device that records and replays QPainter commands.

A picture serializes painter commands to an IO device in a platform-independent format. They are sometimes referred to as meta-files.

Qt pictures use a proprietary binary format. Unlike native picture (meta-file) formats on many window systems, Qt pictures have no limitations regarding their contents. Everything that can be painted on a widget or pixmap (e.g., fonts, pixmaps, regions, transformed graphics, etc.) can also be stored in a picture.

QPicture is resolution independent, i.e. a QPicture can be displayed on different devices (for example svg, pdf, ps, printer and screen) looking the same. This is, for instance, needed for WYSIWYG print preview. QPicture runs in the default system dpi, and scales the painter to match differences in resolution depending on the window system.

Example of how to record a picture:

QPicture picture;
QPainter painter;
painter.begin(&picture); // paint in picture
painter.drawEllipse(10,20, 80,70); // draw an ellipse
painter.end(); // painting done
picture.save("drawing.pic"); // save picture

Note that the list of painter commands is reset on each call to the QPainter::begin() function.

Example of how to replay a picture:

QPicture picture;
picture.load("drawing.pic"); // load picture
QPainter painter;
painter.begin(&myImage); // paint in myImage
painter.drawPicture(0, 0, picture); // draw the picture at (0,0)
painter.end(); // painting done

Pictures can also be drawn using play(). Some basic data about a picture is available, for example, size(), isNull() and boundingRect().

See also
QMovie

Definition at line 58 of file qpicture.h.

Typedefs

◆ DataPtr

Warning
This function is not part of the public interface.

Definition at line 122 of file qpicture.h.

Constructors and Destructors

◆ QPicture() [1/3]

QPicture::QPicture ( int  formatVersion = -1)
explicit

Constructs an empty picture.

The formatVersion parameter may be used to create a QPicture that can be read by applications that are compiled with earlier versions of Qt.

Note that the default formatVersion is -1 which signifies the current release, i.e. for Qt 4.0 a formatVersion of 7 is the same as the default formatVersion of -1.

Reading pictures generated by earlier versions of Qt is not supported in Qt 4.0.

Definition at line 131 of file qpicture.cpp.

132  : QPaintDevice(),
134 {
135  Q_D(QPicture);
136 
137  if (formatVersion == 0)
138  qWarning("QPicture: invalid format version 0");
139 
140  // still accept the 0 default from before Qt 3.0.
141  if (formatVersion > 0 && formatVersion != (int)mfhdr_maj) {
142  d->formatMajor = formatVersion;
143  d->formatMinor = 0;
144  d->formatOk = false;
145  } else {
146  d->resetFormat();
147  }
148 }
double d
Definition: qnumeric_p.h:62
static const quint16 mfhdr_maj
Definition: qpicture.cpp:113
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58

◆ QPicture() [2/3]

QPicture::QPicture ( const QPicture pic)

Constructs a copy of pic.

This constructor is fast thanks to implicit sharing.

Definition at line 156 of file qpicture.cpp.

157  : QPaintDevice(), d_ptr(pic.d_ptr)
158 {
159 }
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115

◆ ~QPicture()

QPicture::~QPicture ( )

Destroys the picture.

Definition at line 171 of file qpicture.cpp.

172 {
173 }

◆ QPicture() [3/3]

QPicture::QPicture ( QPicturePrivate dptr)
protected
Warning
This function is not part of the public interface.

Definition at line 162 of file qpicture.cpp.

163  : QPaintDevice(),
164  d_ptr(&dptr)
165 {
166 }
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115

Functions

◆ boundingRect()

QRect QPicture::boundingRect ( ) const

Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.

Definition at line 385 of file qpicture.cpp.

Referenced by QPicturePaintEngine::begin(), metric(), and QLabelPrivate::sizeForWidth().

386 {
387  Q_D(const QPicture);
388  // Use override rect where possible.
389  if (!d->override_rect.isEmpty())
390  return d->override_rect;
391 
392  if (!d->formatOk)
393  d_ptr->checkFormat();
394 
395  return d->brect;
396 }
double d
Definition: qnumeric_p.h:62
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115
#define Q_D(Class)
Definition: qglobal.h:2482
bool checkFormat()
Checks data integrity and format version number.
Definition: qpicture.cpp:1117
if(void) toggleToolbarShown
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58

◆ data()

const char * QPicture::data ( ) const

Returns a pointer to the picture data.

The pointer is only valid until the next non-const function is called on this picture. The returned pointer is 0 if the picture contains no data.

See also
size(), isNull()

Definition at line 225 of file qpicture.cpp.

226 {
227  return d_func()->pictb.buffer();
228 }

◆ data_ptr()

DataPtr & QPicture::data_ptr ( )
inline
Warning
This function is not part of the public interface.

Definition at line 123 of file qpicture.h.

123 { return d_ptr; }
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115

◆ detach()

void QPicture::detach ( )

Detaches from shared picture data and makes sure that this picture is the only one referring to the data.

Warning
This function is not part of the public interface.

If multiple pictures share common data, this picture makes a copy of the data and detaches itself from the sharing mechanism. Nothing is done if there is just a single reference.

Definition at line 230 of file qpicture.cpp.

Referenced by load(), setData(), and swap().

231 {
232  d_ptr.detach();
233 }
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115
void detach()
If the shared data object&#39;s reference count is greater than 1, this function creates a deep copy of t...
Definition: qshareddata.h:148

◆ detach_helper()

void QPicture::detach_helper ( )
private
Warning
This function is not part of the public interface.

Qt 5 - remove me

Definition at line 1031 of file qpicture.cpp.

1032 {
1033  // QExplicitelySharedDataPointer takes care of cloning using
1034  // QPicturePrivate's copy constructor. Do not call detach_helper() anymore
1035  // and remove in Qt 5, please.
1036  Q_ASSERT_X(false, "QPicture::detach_helper()", "Do not call this function");
1037 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837

◆ devType()

int QPicture::devType ( ) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QPaintDevice.

Definition at line 178 of file qpicture.cpp.

179 {
180  return QInternal::Picture;
181 }

◆ exec()

bool QPicture::exec ( QPainter painter,
QDataStream s,
int  nrecords 
)
private

Iterates over the internal picture data and draws the picture using painter.

Warning
This function is not part of the public interface.

Definition at line 490 of file qpicture.cpp.

Referenced by play().

491 {
492  Q_D(QPicture);
493 #if defined(QT_DEBUG)
494  int strm_pos;
495 #endif
496  quint8 c; // command id
497  quint8 tiny_len; // 8-bit length descriptor
498  qint32 len; // 32-bit length descriptor
499  qint16 i_16, i1_16, i2_16; // parameters...
500  qint8 i_8;
501  quint32 ul;
502  double dbl;
503  bool bl;
504  QByteArray str1;
505  QString str;
506  QPointF p, p1, p2;
507  QPoint ip, ip1, ip2;
508  QRect ir;
509  QRectF r;
510  QPolygonF a;
511  QPolygon ia;
512  QColor color;
513  QFont font;
514  QPen pen;
515  QBrush brush;
516  QRegion rgn;
517  QMatrix wmatrix;
518  QTransform matrix;
519 
520  QTransform worldMatrix = painter->transform();
521  worldMatrix.scale(qreal(painter->device()->logicalDpiX()) / qreal(qt_defaultDpiX()),
522  qreal(painter->device()->logicalDpiY()) / qreal(qt_defaultDpiY()));
523  painter->setTransform(worldMatrix);
524 
525  while (nrecords-- && !s.atEnd()) {
526  s >> c; // read cmd
527  s >> tiny_len; // read param length
528  if (tiny_len == 255) // longer than 254 bytes
529  s >> len;
530  else
531  len = tiny_len;
532 #if defined(QT_DEBUG)
533  strm_pos = s.device()->pos();
534 #endif
535  switch (c) { // exec cmd
537  break;
539  if (d->formatMajor <= 5) {
540  s >> ip;
541  painter->drawPoint(ip);
542  } else {
543  s >> p;
544  painter->drawPoint(p);
545  }
546  break;
548 // ## implement me in the picture paint engine
549 // s >> a >> i1_32 >> i2_32;
550 // painter->drawPoints(a.mid(i1_32, i2_32));
551  break;
553  QPainterPath path;
554  s >> path;
555  painter->drawPath(path);
556  break;
557  }
559  if (d->formatMajor <= 5) {
560  s >> ip1 >> ip2;
561  painter->drawLine(ip1, ip2);
562  } else {
563  s >> p1 >> p2;
564  painter->drawLine(p1, p2);
565  }
566  break;
568  if (d->formatMajor <= 5) {
569  s >> ir;
570  painter->drawRect(ir);
571  } else {
572  s >> r;
573  painter->drawRect(r);
574  }
575  break;
577  if (d->formatMajor <= 5) {
578  s >> ir >> i1_16 >> i2_16;
579  painter->drawRoundedRect(ir, i1_16, i2_16, Qt::RelativeSize);
580  } else {
581  s >> r >> i1_16 >> i2_16;
582  painter->drawRoundedRect(r, i1_16, i2_16, Qt::RelativeSize);
583  }
584  break;
586  if (d->formatMajor <= 5) {
587  s >> ir;
588  painter->drawEllipse(ir);
589  } else {
590  s >> r;
591  painter->drawEllipse(r);
592  }
593  break;
595  if (d->formatMajor <= 5) {
596  s >> ir;
597  r = ir;
598  } else {
599  s >> r;
600  }
601  s >> i1_16 >> i2_16;
602  painter->drawArc(r, i1_16, i2_16);
603  break;
605  if (d->formatMajor <= 5) {
606  s >> ir;
607  r = ir;
608  } else {
609  s >> r;
610  }
611  s >> i1_16 >> i2_16;
612  painter->drawPie(r, i1_16, i2_16);
613  break;
615  if (d->formatMajor <= 5) {
616  s >> ir;
617  r = ir;
618  } else {
619  s >> r;
620  }
621  s >> i1_16 >> i2_16;
622  painter->drawChord(r, i1_16, i2_16);
623  break;
625  s >> ia;
626  painter->drawLines(ia);
627  ia.clear();
628  break;
630  if (d->formatMajor <= 5) {
631  s >> ia;
632  painter->drawPolyline(ia);
633  ia.clear();
634  } else {
635  s >> a;
636  painter->drawPolyline(a);
637  a.clear();
638  }
639  break;
641  if (d->formatMajor <= 5) {
642  s >> ia >> i_8;
643  painter->drawPolygon(ia, i_8 ? Qt::WindingFill : Qt::OddEvenFill);
644  a.clear();
645  } else {
646  s >> a >> i_8;
647  painter->drawPolygon(a, i_8 ? Qt::WindingFill : Qt::OddEvenFill);
648  a.clear();
649  }
650  break;
652  s >> ia;
653  QPainterPath path;
654  Q_ASSERT(ia.size() == 4);
655  path.moveTo(ia.at(0));
656  path.cubicTo(ia.at(1), ia.at(2), ia.at(3));
657  painter->strokePath(path, painter->pen());
658  a.clear();
659  }
660  break;
662  s >> ip >> str1;
663  painter->drawText(ip, QString::fromLatin1(str1));
664  break;
666  s >> ir >> i_16 >> str1;
667  painter->drawText(ir, i_16, QString::fromLatin1(str1));
668  break;
670  if (d->formatMajor <= 5) {
671  s >> ip >> str;
672  painter->drawText(ip, str);
673  } else {
674  s >> p >> str;
675  painter->drawText(p, str);
676  }
677  break;
679  s >> ir;
680  s >> i_16;
681  s >> str;
682  painter->drawText(ir, i_16, str);
683  break;
685  s >> p >> str >> font >> ul;
686 
687  // the text layout direction is not used here because it's already
688  // aligned when QPicturePaintEngine::drawTextItem() serializes the
689  // drawText() call, therefore ul is unsed in this context
690 
691  if (d->formatMajor >= 9) {
692  s >> dbl;
693  QFont fnt(font);
694  if (dbl != 1.0) {
695  QFakeDevice fake;
696  fake.setDpiX(qRound(dbl*qt_defaultDpiX()));
697  fake.setDpiY(qRound(dbl*qt_defaultDpiY()));
698  fnt = QFont(font, &fake);
699  }
700 
701  qreal justificationWidth;
702  s >> justificationWidth;
703 
705 
706  QSizeF size(1, 1);
707  if (justificationWidth > 0) {
708  size.setWidth(justificationWidth);
710  flags |= Qt::AlignJustify;
711  }
712 
713  QFontMetrics fm(fnt);
714  QPointF pt(p.x(), p.y() - fm.ascent());
715  qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/0,
716  str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter);
717  } else {
718  qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/0,
719  str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter);
720  }
721 
722  break;
723  }
725  QPixmap pixmap;
726  if (d->formatMajor < 4) {
727  s >> ip >> pixmap;
728  painter->drawPixmap(ip, pixmap);
729  } else if (d->formatMajor <= 5) {
730  s >> ir >> pixmap;
731  painter->drawPixmap(ir, pixmap);
732  } else {
733  QRectF sr;
734  if (d->in_memory_only) {
735  int index;
736  s >> r >> index >> sr;
737  Q_ASSERT(index < d->pixmap_list.size());
738  pixmap = d->pixmap_list.at(index);
739  } else {
740  s >> r >> pixmap >> sr;
741  }
742  painter->drawPixmap(r, pixmap, sr);
743  }
744  }
745  break;
747  QPixmap pixmap;
748  if (d->in_memory_only) {
749  int index;
750  s >> r >> index >> p;
751  Q_ASSERT(index < d->pixmap_list.size());
752  pixmap = d->pixmap_list.at(index);
753  } else {
754  s >> r >> pixmap >> p;
755  }
756  painter->drawTiledPixmap(r, pixmap, p);
757  }
758  break;
760  QImage image;
761  if (d->formatMajor < 4) {
762  s >> p >> image;
763  painter->drawImage(p, image);
764  } else if (d->formatMajor <= 5){
765  s >> ir >> image;
766  painter->drawImage(ir, image, QRect(0, 0, ir.width(), ir.height()));
767  } else {
768  QRectF sr;
769  if (d->in_memory_only) {
770  int index;
771  s >> r >> index >> sr >> ul;
772  Q_ASSERT(index < d->image_list.size());
773  image = d->image_list.at(index);
774  } else {
775  s >> r >> image >> sr >> ul;
776  }
777  painter->drawImage(r, image, sr, Qt::ImageConversionFlags(ul));
778  }
779  }
780  break;
782  s >> ul; // number of records
783  if (!exec(painter, s, ul))
784  return false;
785  break;
787  if (nrecords == 0)
788  return true;
789  break;
791  painter->save();
792  break;
794  painter->restore();
795  break;
797  s >> color;
798  painter->setBackground(color);
799  break;
801  s >> i_8;
802  painter->setBackgroundMode((Qt::BGMode)i_8);
803  break;
804  case QPicturePrivate::PdcSetROP: // NOP
805  s >> i_8;
806  break;
808  if (d->formatMajor <= 5) {
809  s >> ip;
810  painter->setBrushOrigin(ip);
811  } else {
812  s >> p;
813  painter->setBrushOrigin(p);
814  }
815  break;
817  s >> font;
818  painter->setFont(font);
819  break;
821  if (d->in_memory_only) {
822  int index;
823  s >> index;
824  Q_ASSERT(index < d->pen_list.size());
825  pen = d->pen_list.at(index);
826  } else {
827  s >> pen;
828  }
829  painter->setPen(pen);
830  break;
832  if (d->in_memory_only) {
833  int index;
834  s >> index;
835  Q_ASSERT(index < d->brush_list.size());
836  brush = d->brush_list.at(index);
837  } else {
838  s >> brush;
839  }
840  painter->setBrush(brush);
841  break;
842 // #ifdef Q_Q3PAINTER
843 // case QPicturePrivate::PdcSetTabStops:
844 // s >> i_16;
845 // painter->setTabStops(i_16);
846 // break;
847 // case QPicturePrivate::PdcSetTabArray:
848 // s >> i_16;
849 // if (i_16 == 0) {
850 // painter->setTabArray(0);
851 // } else {
852 // int *ta = new int[i_16];
853 // for (int i=0; i<i_16; i++) {
854 // s >> i1_16;
855 // ta[i] = i1_16;
856 // }
857 // painter->setTabArray(ta);
858 // delete [] ta;
859 // }
860 // break;
861 // #endif
863  s >> i_8;
864  painter->setViewTransformEnabled(i_8);
865  break;
867  if (d->formatMajor <= 5) {
868  s >> ir;
869  painter->setWindow(ir);
870  } else {
871  s >> r;
872  painter->setWindow(r.toRect());
873  }
874  break;
876  if (d->formatMajor <= 5) {
877  s >> ir;
878  painter->setViewport(ir);
879  } else {
880  s >> r;
881  painter->setViewport(r.toRect());
882  }
883  break;
885  s >> i_8;
886  painter->setMatrixEnabled(i_8);
887  break;
889  if (d->formatMajor >= 8) {
890  s >> matrix >> i_8;
891  } else {
892  s >> wmatrix >> i_8;
893  matrix = QTransform(wmatrix);
894  }
895  // i_8 is always false due to updateXForm() in qpaintengine_pic.cpp
896  painter->setTransform(matrix * worldMatrix, i_8);
897  break;
898 // #ifdef Q_Q3PAINTER
899 // case QPicturePrivate::PdcSaveWMatrix:
900 // painter->saveWorldMatrix();
901 // break;
902 // case QPicturePrivate::PdcRestoreWMatrix:
903 // painter->restoreWorldMatrix();
904 // break;
905 // #endif
907  s >> i_8;
908  painter->setClipping(i_8);
909  break;
911  s >> rgn >> i_8;
912  if (d->formatMajor >= 9) {
913  painter->setClipRegion(rgn, Qt::ClipOperation(i_8));
914  } else {
915  painter->setClipRegion(rgn);
916  }
917  break;
919  {
920  QPainterPath path;
921  s >> path >> i_8;
922  painter->setClipPath(path, Qt::ClipOperation(i_8));
923  break;
924  }
926  s >> ul;
928  bool(ul & QPainter::Antialiasing));
931  break;
933  s >> ul;
935  break;
937  s >> bl;
938  painter->setClipping(bl);
939  break;
941  s >> dbl;
942  painter->setOpacity(qreal(dbl));
943  break;
944  default:
945  qWarning("QPicture::play: Invalid command %d", c);
946  if (len) // skip unknown command
947  s.device()->seek(s.device()->pos()+len);
948  }
949 #if defined(QT_DEBUG)
950  //qDebug("device->at(): %i, strm_pos: %i len: %i", (int)s.device()->pos(), strm_pos, len);
951  Q_ASSERT(qint32(s.device()->pos() - strm_pos) == len);
952 #endif
953  }
954  return false;
955 }
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
Definition: qpainter.cpp:3998
void drawChord(const QRectF &rect, int a, int alen)
Draws the chord defined by the given rectangle, startAngle and spanAngle.
Definition: qpainter.cpp:4744
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or 0 if the painter is not acti...
Definition: qpainter.cpp:1530
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling...
Definition: qpainter.cpp:3502
void drawPie(const QRectF &rect, int a, int alen)
Draws a pie defined by the given rectangle, startAngle and and spanAngle.
Definition: qpainter.cpp:4670
double qreal
Definition: qglobal.h:1193
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
Definition: qpainter.cpp:4602
unsigned char c[8]
Definition: qnumeric_p.h:62
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
int qint32
Definition: qglobal.h:937
CompositionMode
Defines the modes supported for digital image compositing.
Definition: qpainter.h:138
void setViewport(const QRect &viewport)
Sets the painter&#39;s viewport rectangle to the given rectangle, and enables view transformations.
Definition: qpainter.cpp:7815
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
int logicalDpiY() const
Definition: qpaintdevice.h:96
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
Q_GUI_EXPORT int qt_defaultDpiY()
Definition: qfont.cpp:201
void setDpiY(int dpi)
Definition: qpicture.cpp:460
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Q_GUI_EXPORT int qt_defaultDpiX()
Definition: qfont.cpp:162
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from...
Definition: qiodevice.cpp:624
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
void setMatrixEnabled(bool enabled)
Use setWorldMatrixEnabled() instead.
Definition: qpainter.cpp:3209
long ASN1_INTEGER_get ASN1_INTEGER * a
unsigned char quint8
Definition: qglobal.h:934
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
uint size() const
Returns the size of the picture data.
Definition: qpicture.cpp:220
int logicalDpiX() const
Definition: qpaintdevice.h:95
signed char qint8
Definition: qglobal.h:933
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
short qint16
Definition: qglobal.h:935
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void strokePath(const QPainterPath &path, const QPen &pen)
Draws the outline (strokes) the path path with the pen specified by pen.
Definition: qpainter.cpp:3413
void setWindow(const QRect &window)
Sets the painter&#39;s window to the given rectangle, and enables view transformations.
Definition: qpainter.cpp:7745
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void setViewTransformEnabled(bool enable)
Enables view transformations if enable is true, or disables view transformations if enable is false...
Definition: qpainter.cpp:7906
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
QIODevice * device() const
Returns the I/O device currently set, or 0 if no device is currently set.
Definition: qdatastream.h:206
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
Definition: qpainter.cpp:2422
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
Definition: qpainter.cpp:2517
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
bool exec(QPainter *p, QDataStream &ds, int i)
Iterates over the internal picture data and draws the picture using painter.
Definition: qpicture.cpp:490
unsigned int quint32
Definition: qglobal.h:938
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition: qpainter.cpp:5936
quint16 index
void cubicTo(const QPointF &ctrlPt1, const QPointF &ctrlPt2, const QPointF &endPt)
Adds a cubic Bezier curve between the current position and the given endPoint using the control point...
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qtransform.cpp:485
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation...
Definition: qpainter.cpp:3365
void setOpacity(qreal opacity)
Sets the opacity of the painter to opacity.
Definition: qpainter.cpp:2139
void qt_format_text(const QFont &fnt, const QRectF &_r, int tf, const QTextOption *opt, const QString &str, QRectF *brect, int tabstops, int *, int tabarraylen, QPainter *painter)
Definition: qpainter.cpp:8458
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
Draws the given rectangle rect with rounded corners.
Definition: qpainter.cpp:4348
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Definition: qpainter.cpp:5055
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success...
Definition: qiodevice.cpp:659
BGMode
Definition: qnamespace.h:588
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
Definition: qpainter.cpp:4258
void setDpiX(int dpi)
Definition: qpicture.cpp:459
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
ClipOperation
Definition: qnamespace.h:1495

◆ inputFormatList()

QStringList QPicture::inputFormatList ( )
static

Returns a list of picture formats that are supported for picture input.

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

foreach (const QString &string, list)
myProcessing(string);
See also
outputFormatList() inputFormats() QPictureIO

Definition at line 1314 of file qpicture.cpp.

1315 {
1317 }
static QList< QByteArray > inputFormats()
Returns a sorted list of picture formats that are supported for picture input.
Definition: qpicture.cpp:1876
static QStringList qToStringList(const QList< QByteArray > arr)
Definition: qpicture.cpp:1291

◆ inputFormats()

QList< QByteArray > QPicture::inputFormats ( )
static

Returns a list of picture formats that are supported for picture input.

See also
outputFormats() inputFormatList() QPictureIO

Definition at line 1286 of file qpicture.cpp.

1287 {
1288  return QPictureIO::inputFormats();
1289 }
static QList< QByteArray > inputFormats()
Returns a sorted list of picture formats that are supported for picture input.
Definition: qpicture.cpp:1876

◆ isDetached()

bool QPicture::isDetached ( ) const
Warning
This function is not part of the public interface.

Definition at line 235 of file qpicture.cpp.

236 {
237  return d_func()->ref == 1;
238 }

◆ isNull()

bool QPicture::isNull ( ) const

Returns true if the picture contains no data; otherwise returns false.

Definition at line 215 of file qpicture.cpp.

Referenced by QLabelPrivate::sizeForWidth().

216 {
217  return d_func()->pictb.buffer().isNull();
218 }

◆ load() [1/2]

bool QPicture::load ( QIODevice dev,
const char *  format = 0 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.dev is the device to use for loading.

Definition at line 279 of file qpicture.cpp.

Referenced by load().

280 {
281  if(format) {
282 #ifndef QT_NO_PICTUREIO
283  QPictureIO io(dev, format);
284  bool result = io.read();
285  if (result) {
286  operator=(io.picture());
287 
288  } else if (format)
289 #else
290  bool result = false;
291 #endif
292  {
293  qWarning("QPicture::load: No such picture format: %s", format);
294  }
295  return result;
296  }
297 
298  detach();
299  QByteArray a = dev->readAll();
300 
301  d_func()->pictb.setData(a); // set byte array in buffer
302  return d_func()->checkFormat();
303 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
long ASN1_INTEGER_get ASN1_INTEGER * a
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
Definition: qiodevice.cpp:1025
The QPictureIO class contains parameters for loading and saving pictures.
Definition: qpicture.h:136
QPicture & operator=(const QPicture &p)
Assigns picture p to this picture and returns a reference to this picture.
Definition: qpicture.cpp:1043
void detach()
Detaches from shared picture data and makes sure that this picture is the only one referring to the d...
Definition: qpicture.cpp:230

◆ load() [2/2]

bool QPicture::load ( const QString fileName,
const char *  format = 0 
)

Loads a picture from the file specified by fileName and returns true if successful; otherwise returns false.

Please note that the format parameter has been deprecated and will have no effect.

See also
save()

Definition at line 265 of file qpicture.cpp.

266 {
267  QFile f(fileName);
268  if (!f.open(QIODevice::ReadOnly))
269  return false;
270  return load(&f, format);
271 }
bool load(QIODevice *dev, const char *format=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qpicture.cpp:279
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65

◆ metric()

int QPicture::metric ( PaintDeviceMetric  m) const
protectedvirtual

Internal implementation of the virtual QPaintDevice::metric() function.

Warning
This function is not part of the public interface.

A picture has the following hard-coded values: numcolors=16777216 and depth=24.

m is the metric to get.

Reimplemented from QPaintDevice.

Definition at line 972 of file qpicture.cpp.

973 {
974  int val;
975  QRect brect = boundingRect();
976  switch (m) {
977  case PdmWidth:
978  val = brect.width();
979  break;
980  case PdmHeight:
981  val = brect.height();
982  break;
983  case PdmWidthMM:
984  val = int(25.4/qt_defaultDpiX()*brect.width());
985  break;
986  case PdmHeightMM:
987  val = int(25.4/qt_defaultDpiY()*brect.height());
988  break;
989  case PdmDpiX:
990  case PdmPhysicalDpiX:
991  val = qt_defaultDpiX();
992  break;
993  case PdmDpiY:
994  case PdmPhysicalDpiY:
995  val = qt_defaultDpiY();
996  break;
997  case PdmNumColors:
998  val = 16777216;
999  break;
1000  case PdmDepth:
1001  val = 24;
1002  break;
1003  default:
1004  val = 0;
1005  qWarning("QPicture::metric: Invalid metric command");
1006  }
1007  return val;
1008 }
Q_GUI_EXPORT int qt_defaultDpiY()
Definition: qfont.cpp:201
Q_GUI_EXPORT int qt_defaultDpiX()
Definition: qfont.cpp:162
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QRect boundingRect() const
Returns the picture&#39;s bounding rectangle or an invalid rectangle if the picture contains no data...
Definition: qpicture.cpp:385
Q_CORE_EXPORT void qWarning(const char *,...)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ operator=()

QPicture & QPicture::operator= ( const QPicture p)

Assigns picture p to this picture and returns a reference to this picture.

Definition at line 1043 of file qpicture.cpp.

Referenced by load(), and save().

1044 {
1045  d_ptr = p.d_ptr;
1046  return *this;
1047 }
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115

◆ outputFormatList()

QStringList QPicture::outputFormatList ( )
static

Returns a list of picture formats that are supported for picture output.

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

foreach (const QString &string, list)
myProcessing(string);
See also
inputFormatList() outputFormats() QPictureIO

Definition at line 1335 of file qpicture.cpp.

1336 {
1338 }
static QList< QByteArray > outputFormats()
Returns a sorted list of picture formats that are supported for picture output.
Definition: qpicture.cpp:1899
static QStringList qToStringList(const QList< QByteArray > arr)
Definition: qpicture.cpp:1291

◆ outputFormats()

QList< QByteArray > QPicture::outputFormats ( )
static

Returns a list of picture formats that are supported for picture output.

See also
inputFormats() outputFormatList() QPictureIO

Definition at line 1351 of file qpicture.cpp.

1352 {
1353  return QPictureIO::outputFormats();
1354 }
static QList< QByteArray > outputFormats()
Returns a sorted list of picture formats that are supported for picture output.
Definition: qpicture.cpp:1899

◆ paintEngine()

QPaintEngine * QPicture::paintEngine ( ) const
virtual
Warning
This function is not part of the public interface.

Implements QPaintDevice.

Definition at line 1183 of file qpicture.cpp.

Referenced by paintEngine().

1184 {
1185  if (!d_func()->paintEngine)
1186  const_cast<QPicture*>(this)->d_func()->paintEngine.reset(new QPicturePaintEngine);
1187  return d_func()->paintEngine.data();
1188 }
QPaintEngine * paintEngine() const
Definition: qpicture.cpp:1183
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58

◆ pictureFormat()

const char * QPicture::pictureFormat ( const QString fileName)
static

Returns a string that specifies the picture format of the file fileName, or 0 if the file cannot be read or if the format is not recognized.

See also
load() save()

Definition at line 1270 of file qpicture.cpp.

1271 {
1272  return QPictureIO::pictureFormat(fileName);
1273 }
static QByteArray pictureFormat(const QString &fileName)
Returns a string that specifies the picture format of the file fileName, or null if the file cannot b...
Definition: qpicture.cpp:1808

◆ play()

bool QPicture::play ( QPainter painter)

Replays the picture using painter, and returns true if successful; otherwise returns false.

This function does exactly the same as QPainter::drawPicture() with (x, y) = (0, 0).

Definition at line 416 of file qpicture.cpp.

417 {
418  Q_D(QPicture);
419 
420  if (d->pictb.size() == 0) // nothing recorded
421  return true;
422 
423  if (!d->formatOk && !d->checkFormat())
424  return false;
425 
426  d->pictb.open(QIODevice::ReadOnly); // open buffer device
427  QDataStream s;
428  s.setDevice(&d->pictb); // attach data stream to buffer
429  s.device()->seek(10); // go directly to the data
430  s.setVersion(d->formatMajor == 4 ? 3 : d->formatMajor);
431 
432  quint8 c, clen;
433  quint32 nrecords;
434  s >> c >> clen;
436  // bounding rect was introduced in ver 4. Read in checkFormat().
437  if (d->formatMajor >= 4) {
438  qint32 dummy;
439  s >> dummy >> dummy >> dummy >> dummy;
440  }
441  s >> nrecords;
442  if (!exec(painter, s, nrecords)) {
443  qWarning("QPicture::play: Format error");
444  d->pictb.close();
445  return false;
446  }
447  d->pictb.close();
448  return true; // no end-command
449 }
double d
Definition: qnumeric_p.h:62
unsigned char c[8]
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
unsigned char quint8
Definition: qglobal.h:934
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void setVersion(int)
Sets the version number of the data serialization format to v.
Definition: qdatastream.h:215
Q_CORE_EXPORT void qWarning(const char *,...)
QIODevice * device() const
Returns the I/O device currently set, or 0 if no device is currently set.
Definition: qdatastream.h:206
bool exec(QPainter *p, QDataStream &ds, int i)
Iterates over the internal picture data and draws the picture using painter.
Definition: qpicture.cpp:490
unsigned int quint32
Definition: qglobal.h:938
void setDevice(QIODevice *)
void QDataStream::setDevice(QIODevice *d)
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success...
Definition: qiodevice.cpp:659

◆ save() [1/2]

bool QPicture::save ( QIODevice dev,
const char *  format = 0 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.dev is the device to use for saving.

Definition at line 352 of file qpicture.cpp.

Referenced by save().

353 {
354  if (paintingActive()) {
355  qWarning("QPicture::save: still being painted on. "
356  "Call QPainter::end() first");
357  return false;
358  }
359 
360  if(format) {
361 #ifndef QT_NO_PICTUREIO
362  QPictureIO io(dev, format);
363  bool result = io.write();
364  if (result) {
365  operator=(io.picture());
366  } else if (format)
367 #else
368  bool result = false;
369 #endif
370  {
371  qWarning("QPicture::save: No such picture format: %s", format);
372  }
373  return result;
374  }
375 
376  dev->write(d_func()->pictb.buffer(), d_func()->pictb.buffer().size());
377  return true;
378 }
bool paintingActive() const
Definition: qpaintdevice.h:170
Q_CORE_EXPORT void qWarning(const char *,...)
The QPictureIO class contains parameters for loading and saving pictures.
Definition: qpicture.h:136
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
QPicture & operator=(const QPicture &p)
Assigns picture p to this picture and returns a reference to this picture.
Definition: qpicture.cpp:1043

◆ save() [2/2]

bool QPicture::save ( const QString fileName,
const char *  format = 0 
)

Saves a picture to the file specified by fileName and returns true if successful; otherwise returns false.

Please note that the format parameter has been deprecated and will have no effect.

See also
load()

Definition at line 315 of file qpicture.cpp.

316 {
317  if (paintingActive()) {
318  qWarning("QPicture::save: still being painted on. "
319  "Call QPainter::end() first");
320  return false;
321  }
322 
323 
324  if(format) {
325 #ifndef QT_NO_PICTUREIO
326  QPictureIO io(fileName, format);
327  bool result = io.write();
328  if (result) {
329  operator=(io.picture());
330  } else if (format)
331 #else
332  bool result = false;
333 #endif
334  {
335  qWarning("QPicture::save: No such picture format: %s", format);
336  }
337  return result;
338  }
339 
340  QFile f(fileName);
341  if (!f.open(QIODevice::WriteOnly))
342  return false;
343  return save(&f, format);
344 }
bool save(QIODevice *dev, const char *format=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qpicture.cpp:352
bool paintingActive() const
Definition: qpaintdevice.h:170
Q_CORE_EXPORT void qWarning(const char *,...)
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
The QPictureIO class contains parameters for loading and saving pictures.
Definition: qpicture.h:136
QPicture & operator=(const QPicture &p)
Assigns picture p to this picture and returns a reference to this picture.
Definition: qpicture.cpp:1043

◆ setBoundingRect()

void QPicture::setBoundingRect ( const QRect r)

Sets the picture's bounding rectangle to r.

The automatically calculated value is overridden.

Definition at line 403 of file qpicture.cpp.

404 {
405  d_func()->override_rect = r;
406 }

◆ setData()

void QPicture::setData ( const char *  data,
uint  size 
)
virtual

Sets the picture data directly from data and size.

This function copies the input data.

See also
data(), size()

Definition at line 247 of file qpicture.cpp.

248 {
249  detach();
250  d_func()->pictb.setData(data, size);
251  d_func()->resetFormat(); // we'll have to check
252 }
uint size() const
Returns the size of the picture data.
Definition: qpicture.cpp:220
const char * data() const
Returns a pointer to the picture data.
Definition: qpicture.cpp:225
void detach()
Detaches from shared picture data and makes sure that this picture is the only one referring to the d...
Definition: qpicture.cpp:230

◆ size()

uint QPicture::size ( ) const

Returns the size of the picture data.

See also
data()

Definition at line 220 of file qpicture.cpp.

Referenced by exec().

221 {
222  return d_func()->pictb.buffer().size();
223 }

◆ swap()

void QPicture::swap ( QPicture other)
inline

Swaps picture other with this picture.

Since
4.8

This operation is very fast and never fails.

Definition at line 88 of file qpicture.h.

88 { d_ptr.swap(other.d_ptr); }
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115
void swap(QExplicitlySharedDataPointer &other)
Swap this instance&#39;s explicitly shared data pointer with the explicitly shared data pointer in other...
Definition: qshareddata.h:208

Friends and Related Functions

◆ operator<<

QDataStream & operator<< ( QDataStream in,
const QPicture p 
)
friend

Writes picture r to the stream s and returns a reference to the stream.

Definition at line 1205 of file qpicture.cpp.

1206 {
1207  quint32 size = r.d_func()->pictb.buffer().size();
1208  s << size;
1209  // null picture ?
1210  if (size == 0)
1211  return s;
1212  // just write the whole buffer to the stream
1213  s.writeRawData (r.d_func()->pictb.buffer(), r.d_func()->pictb.buffer().size());
1214  return s;
1215 }
uint size() const
Returns the size of the picture data.
Definition: qpicture.cpp:220
unsigned int quint32
Definition: qglobal.h:938

◆ operator>>

QDataStream & operator>> ( QDataStream in,
QPicture p 
)
friend

Reads a picture from the stream s into picture r and returns a reference to the stream.

Definition at line 1227 of file qpicture.cpp.

1228 {
1229  QDataStream sr;
1230 
1231  // "init"; this code is similar to the beginning of QPicture::cmd()
1232  sr.setDevice(&r.d_func()->pictb);
1233  sr.setVersion(r.d_func()->formatMajor);
1234  quint32 len;
1235  s >> len;
1236  QByteArray data;
1237  if (len > 0) {
1238  data.resize(len);
1239  s.readRawData(data.data(), len);
1240  }
1241 
1242  r.d_func()->pictb.setData(data);
1243  r.d_func()->resetFormat();
1244  return s;
1245 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void setVersion(int)
Sets the version number of the data serialization format to v.
Definition: qdatastream.h:215
void resize(int size)
Sets the size of the byte array to size bytes.
unsigned int quint32
Definition: qglobal.h:938
const char * data() const
Returns a pointer to the picture data.
Definition: qpicture.cpp:225
void setDevice(QIODevice *)
void QDataStream::setDevice(QIODevice *d)
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71

◆ Q3Picture

friend class Q3Picture
friend

Definition at line 117 of file qpicture.h.

◆ QAlphaPaintEngine

friend class QAlphaPaintEngine
friend

Definition at line 118 of file qpicture.h.

◆ QPicturePaintEngine

friend class QPicturePaintEngine
friend

Definition at line 116 of file qpicture.h.

◆ QPreviewPaintEngine

friend class QPreviewPaintEngine
friend

Definition at line 119 of file qpicture.h.

Properties

◆ d_ptr

Definition at line 115 of file qpicture.h.

Referenced by boundingRect(), detach(), operator=(), and swap().


The documentation for this class was generated from the following files: