Qt 4.8
Public Types | Public Functions | Public Variables | Friends | List of all members
QPicturePrivate Class Reference

#include <qpicture_p.h>

Public Types

enum  PaintCommand {
  PdcNOP = 0, PdcDrawPoint = 1, PdcDrawFirst = PdcDrawPoint, PdcMoveTo = 2,
  PdcLineTo = 3, PdcDrawLine = 4, PdcDrawRect = 5, PdcDrawRoundRect = 6,
  PdcDrawEllipse = 7, PdcDrawArc = 8, PdcDrawPie = 9, PdcDrawChord = 10,
  PdcDrawLineSegments = 11, PdcDrawPolyline = 12, PdcDrawPolygon = 13, PdcDrawCubicBezier = 14,
  PdcDrawText = 15, PdcDrawTextFormatted = 16, PdcDrawPixmap = 17, PdcDrawImage = 18,
  PdcDrawText2 = 19, PdcDrawText2Formatted = 20, PdcDrawTextItem = 21, PdcDrawLast = PdcDrawTextItem,
  PdcDrawPoints = 22, PdcDrawWinFocusRect = 23, PdcDrawTiledPixmap = 24, PdcDrawPath = 25,
  PdcBegin = 30, PdcEnd = 31, PdcSave = 32, PdcRestore = 33,
  PdcSetdev = 34, PdcSetBkColor = 40, PdcSetBkMode = 41, PdcSetROP = 42,
  PdcSetBrushOrigin = 43, PdcSetFont = 45, PdcSetPen = 46, PdcSetBrush = 47,
  PdcSetTabStops = 48, PdcSetTabArray = 49, PdcSetUnit = 50, PdcSetVXform = 51,
  PdcSetWindow = 52, PdcSetViewport = 53, PdcSetWXform = 54, PdcSetWMatrix = 55,
  PdcSaveWMatrix = 56, PdcRestoreWMatrix = 57, PdcSetClip = 60, PdcSetClipRegion = 61,
  PdcSetClipPath = 62, PdcSetRenderHint = 63, PdcSetCompositionMode = 64, PdcSetClipEnabled = 65,
  PdcSetOpacity = 66, PdcReservedStart = 0, PdcReservedStop = 199
}
 

Public Functions

bool checkFormat ()
 Checks data integrity and format version number. More...
 
 QPicturePrivate ()
 
 QPicturePrivate (const QPicturePrivate &other)
 Copy-Constructs a QPicturePrivate. More...
 
void resetFormat ()
 

Public Variables

QRect brect
 
QList< QBrushbrush_list
 
int formatMajor
 
int formatMinor
 
bool formatOk
 
QList< QImageimage_list
 
bool in_memory_only
 
QRect override_rect
 
QScopedPointer< QPaintEnginepaintEngine
 
QList< QPenpen_list
 
QBuffer pictb
 
QList< QPixmappixmap_list
 
QAtomicInt ref
 
int trecs
 

Friends

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &s, const QPicture &r)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &s, QPicture &r)
 
class QPicturePaintEngine
 

Detailed Description

Definition at line 72 of file qpicture_p.h.

Enumerations

◆ PaintCommand

Enumerator
PdcNOP 
PdcDrawPoint 
PdcDrawFirst 
PdcMoveTo 
PdcLineTo 
PdcDrawLine 
PdcDrawRect 
PdcDrawRoundRect 
PdcDrawEllipse 
PdcDrawArc 
PdcDrawPie 
PdcDrawChord 
PdcDrawLineSegments 
PdcDrawPolyline 
PdcDrawPolygon 
PdcDrawCubicBezier 
PdcDrawText 
PdcDrawTextFormatted 
PdcDrawPixmap 
PdcDrawImage 
PdcDrawText2 
PdcDrawText2Formatted 
PdcDrawTextItem 
PdcDrawLast 
PdcDrawPoints 
PdcDrawWinFocusRect 
PdcDrawTiledPixmap 
PdcDrawPath 
PdcBegin 
PdcEnd 
PdcSave 
PdcRestore 
PdcSetdev 
PdcSetBkColor 
PdcSetBkMode 
PdcSetROP 
PdcSetBrushOrigin 
PdcSetFont 
PdcSetPen 
PdcSetBrush 
PdcSetTabStops 
PdcSetTabArray 
PdcSetUnit 
PdcSetVXform 
PdcSetWindow 
PdcSetViewport 
PdcSetWXform 
PdcSetWMatrix 
PdcSaveWMatrix 
PdcRestoreWMatrix 
PdcSetClip 
PdcSetClipRegion 
PdcSetClipPath 
PdcSetRenderHint 
PdcSetCompositionMode 
PdcSetClipEnabled 
PdcSetOpacity 
PdcReservedStart 
PdcReservedStop 

Definition at line 79 of file qpicture_p.h.

79  {
80  PdcNOP = 0, // <void>
81  PdcDrawPoint = 1, // point
83  PdcMoveTo = 2, // point
84  PdcLineTo = 3, // point
85  PdcDrawLine = 4, // point,point
86  PdcDrawRect = 5, // rect
87  PdcDrawRoundRect = 6, // rect,ival,ival
88  PdcDrawEllipse = 7, // rect
89  PdcDrawArc = 8, // rect,ival,ival
90  PdcDrawPie = 9, // rect,ival,ival
91  PdcDrawChord = 10, // rect,ival,ival
92  PdcDrawLineSegments = 11, // ptarr
93  PdcDrawPolyline = 12, // ptarr
94  PdcDrawPolygon = 13, // ptarr,ival
95  PdcDrawCubicBezier = 14, // ptarr
96  PdcDrawText = 15, // point,str
97  PdcDrawTextFormatted = 16, // rect,ival,str
98  PdcDrawPixmap = 17, // rect,pixmap
99  PdcDrawImage = 18, // rect,image
100  PdcDrawText2 = 19, // point,str
101  PdcDrawText2Formatted = 20, // rect,ival,str
102  PdcDrawTextItem = 21, // pos,text,font,flags
104  PdcDrawPoints = 22, // ptarr,ival,ival
105  PdcDrawWinFocusRect = 23, // rect,color
106  PdcDrawTiledPixmap = 24, // rect,pixmap,point
107  PdcDrawPath = 25, // path
108 
109  // no painting commands below PdcDrawLast.
110 
111  PdcBegin = 30, // <void>
112  PdcEnd = 31, // <void>
113  PdcSave = 32, // <void>
114  PdcRestore = 33, // <void>
115  PdcSetdev = 34, // device - PRIVATE
116  PdcSetBkColor = 40, // color
117  PdcSetBkMode = 41, // ival
118  PdcSetROP = 42, // ival
119  PdcSetBrushOrigin = 43, // point
120  PdcSetFont = 45, // font
121  PdcSetPen = 46, // pen
122  PdcSetBrush = 47, // brush
123  PdcSetTabStops = 48, // ival
124  PdcSetTabArray = 49, // ival,ivec
125  PdcSetUnit = 50, // ival
126  PdcSetVXform = 51, // ival
127  PdcSetWindow = 52, // rect
128  PdcSetViewport = 53, // rect
129  PdcSetWXform = 54, // ival
130  PdcSetWMatrix = 55, // matrix,ival
131  PdcSaveWMatrix = 56,
132  PdcRestoreWMatrix = 57,
133  PdcSetClip = 60, // ival
134  PdcSetClipRegion = 61, // rgn
135  PdcSetClipPath = 62, // path
136  PdcSetRenderHint = 63, // ival
137  PdcSetCompositionMode = 64, // ival
138  PdcSetClipEnabled = 65, // bool
139  PdcSetOpacity = 66, // qreal
140 
141  PdcReservedStart = 0, // codes 0-199 are reserved
142  PdcReservedStop = 199 // for Qt
143  };

Constructors and Destructors

◆ QPicturePrivate() [1/2]

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

Constructs a QPicturePrivate

Definition at line 1065 of file qpicture.cpp.

1066  : in_memory_only(false)
1067 {
1068 }

◆ QPicturePrivate() [2/2]

QPicturePrivate::QPicturePrivate ( const QPicturePrivate other)

Copy-Constructs a QPicturePrivate.

Warning
This function is not part of the public interface.

Needed when detaching.

Definition at line 1078 of file qpicture.cpp.

1079  : trecs(other.trecs),
1080  formatOk(other.formatOk),
1081  formatMinor(other.formatMinor),
1082  brect(other.brect),
1084  in_memory_only(false)
1085 {
1086  pictb.setData(other.pictb.data(), other.pictb.size());
1087  if (other.pictb.isOpen()) {
1088  pictb.open(other.pictb.openMode());
1089  pictb.seek(other.pictb.pos());
1090  }
1091 }
const QByteArray & data() const
Returns the data contained in the buffer.
Definition: qbuffer.cpp:301
void setData(const QByteArray &data)
Sets the contents of the internal buffer to be data.
Definition: qbuffer.cpp:315
bool open(OpenMode openMode)
Reimplemented Function
Definition: qbuffer.cpp:338
qint64 pos() const
Reimplemented Function
Definition: qbuffer.cpp:367
qint64 size() const
Reimplemented Function
Definition: qbuffer.cpp:375
bool seek(qint64 off)
Reimplemented Function
Definition: qbuffer.cpp:384
bool isOpen() const
Returns true if the device is open; otherwise returns false.
Definition: qiodevice.cpp:530
QRect override_rect
Definition: qpicture_p.h:158
OpenMode openMode() const
Returns the mode in which the device has been opened; i.e.
Definition: qiodevice.cpp:465

Functions

◆ checkFormat()

bool QPicturePrivate::checkFormat ( )

Checks data integrity and format version number.

Warning
This function is not part of the public interface.

Set formatOk to true on success, to false otherwise. Returns the resulting formatOk value.

Definition at line 1117 of file qpicture.cpp.

Referenced by QPicture::boundingRect().

1118 {
1119  resetFormat();
1120 
1121  // can't check anything in an empty buffer
1122  if (pictb.size() == 0 || pictb.isOpen())
1123  return false;
1124 
1125  pictb.open(QIODevice::ReadOnly); // open buffer device
1126  QDataStream s;
1127  s.setDevice(&pictb); // attach data stream to buffer
1128 
1129  char mf_id[4]; // picture header tag
1130  s.readRawData(mf_id, 4); // read actual tag
1131  if (memcmp(mf_id, qt_mfhdr_tag, 4) != 0) { // wrong header id
1132  qWarning("QPicturePaintEngine::checkFormat: Incorrect header");
1133  pictb.close();
1134  return false;
1135  }
1136 
1137  int cs_start = sizeof(quint32); // pos of checksum word
1138  int data_start = cs_start + sizeof(quint16);
1139  quint16 cs,ccs;
1140  QByteArray buf = pictb.buffer(); // pointer to data
1141 
1142  s >> cs; // read checksum
1143  ccs = (quint16) qChecksum(buf.constData() + data_start, buf.size() - data_start);
1144  if (ccs != cs) {
1145  qWarning("QPicturePaintEngine::checkFormat: Invalid checksum %x, %x expected",
1146  ccs, cs);
1147  pictb.close();
1148  return false;
1149  }
1150 
1151  quint16 major, minor;
1152  s >> major >> minor; // read version number
1153  if (major > mfhdr_maj) { // new, incompatible version
1154  qWarning("QPicturePaintEngine::checkFormat: Incompatible version %d.%d",
1155  major, minor);
1156  pictb.close();
1157  return false;
1158  }
1159  s.setVersion(major != 4 ? major : 3);
1160 
1161  quint8 c, clen;
1162  s >> c >> clen;
1163  if (c == QPicturePrivate::PdcBegin) {
1164  if (!(major >= 1 && major <= 3)) {
1165  qint32 l, t, w, h;
1166  s >> l >> t >> w >> h;
1167  brect = QRect(l, t, w, h);
1168  }
1169  } else {
1170  qWarning("QPicturePaintEngine::checkFormat: Format error");
1171  pictb.close();
1172  return false;
1173  }
1174  pictb.close();
1175 
1176  formatOk = true; // picture seems to be ok
1177  formatMajor = major;
1178  formatMinor = minor;
1179  return true;
1180 }
unsigned char c[8]
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
bool open(OpenMode openMode)
Reimplemented Function
Definition: qbuffer.cpp:338
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void close()
Reimplemented Function
Definition: qbuffer.cpp:359
qint64 size() const
Reimplemented Function
Definition: qbuffer.cpp:375
static const quint16 mfhdr_maj
Definition: qpicture.cpp:113
unsigned char quint8
Definition: qglobal.h:934
void setVersion(int)
Sets the version number of the data serialization format to v.
Definition: qdatastream.h:215
Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len)
bool isOpen() const
Returns true if the device is open; otherwise returns false.
Definition: qiodevice.cpp:530
int readRawData(char *, int len)
Reads at most len bytes from the stream into s and returns the number of bytes read.
QByteArray & buffer()
Returns a reference to the QBuffer&#39;s internal buffer.
Definition: qbuffer.cpp:271
unsigned short quint16
Definition: qglobal.h:936
Q_CORE_EXPORT void qWarning(const char *,...)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QFactoryLoader * l
const char * qt_mfhdr_tag
Definition: qpicture.cpp:112
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
void setDevice(QIODevice *)
void QDataStream::setDevice(QIODevice *d)
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
void resetFormat()
Definition: qpicture.cpp:1099

◆ resetFormat()

void QPicturePrivate::resetFormat ( )
Warning
This function is not part of the public interface.

Sets formatOk to false and resets the format version numbers to default

Definition at line 1099 of file qpicture.cpp.

Referenced by checkFormat().

1100 {
1101  formatOk = false;
1104 }
static const quint16 mfhdr_maj
Definition: qpicture.cpp:113
static const quint16 mfhdr_min
Definition: qpicture.cpp:114

Friends and Related Functions

◆ operator<<

Q_GUI_EXPORT QDataStream& operator<< ( QDataStream s,
const QPicture r 
)
friend

◆ operator>>

Q_GUI_EXPORT QDataStream& operator>> ( QDataStream s,
QPicture r 
)
friend

◆ QPicturePaintEngine

friend class QPicturePaintEngine
friend

Definition at line 74 of file qpicture_p.h.

Properties

◆ brect

QRect QPicturePrivate::brect

Definition at line 157 of file qpicture_p.h.

Referenced by checkFormat().

◆ brush_list

QList<QBrush> QPicturePrivate::brush_list

Definition at line 163 of file qpicture_p.h.

◆ formatMajor

int QPicturePrivate::formatMajor

Definition at line 155 of file qpicture_p.h.

Referenced by checkFormat(), and resetFormat().

◆ formatMinor

int QPicturePrivate::formatMinor

Definition at line 156 of file qpicture_p.h.

Referenced by checkFormat(), and resetFormat().

◆ formatOk

bool QPicturePrivate::formatOk

Definition at line 154 of file qpicture_p.h.

Referenced by checkFormat(), and resetFormat().

◆ image_list

QList<QImage> QPicturePrivate::image_list

Definition at line 161 of file qpicture_p.h.

◆ in_memory_only

bool QPicturePrivate::in_memory_only

Definition at line 160 of file qpicture_p.h.

◆ override_rect

QRect QPicturePrivate::override_rect

Definition at line 158 of file qpicture_p.h.

◆ paintEngine

QScopedPointer<QPaintEngine> QPicturePrivate::paintEngine

Definition at line 159 of file qpicture_p.h.

Referenced by QPicture::paintEngine().

◆ pen_list

QList<QPen> QPicturePrivate::pen_list

Definition at line 164 of file qpicture_p.h.

◆ pictb

QBuffer QPicturePrivate::pictb

Definition at line 152 of file qpicture_p.h.

Referenced by checkFormat(), and QPicturePrivate().

◆ pixmap_list

QList<QPixmap> QPicturePrivate::pixmap_list

Definition at line 162 of file qpicture_p.h.

◆ ref

QAtomicInt QPicturePrivate::ref

Definition at line 147 of file qpicture_p.h.

◆ trecs

int QPicturePrivate::trecs

Definition at line 153 of file qpicture_p.h.


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