Qt 4.8
qpicture.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QPICTURE_H
43 #define QPICTURE_H
44 
45 #include <QtCore/qstringlist.h>
46 #include <QtCore/qsharedpointer.h>
47 #include <QtGui/qpaintdevice.h>
48 
50 
52 
53 QT_MODULE(Gui)
54 
55 #ifndef QT_NO_PICTURE
56 
57 class QPicturePrivate;
59 {
61 public:
62  explicit QPicture(int formatVersion = -1);
63  QPicture(const QPicture &);
64  ~QPicture();
65 
66  bool isNull() const;
67 
68  int devType() const;
69  uint size() const;
70  const char* data() const;
71  virtual void setData(const char* data, uint size);
72 
73  bool play(QPainter *p);
74 
75  bool load(QIODevice *dev, const char *format = 0);
76  bool load(const QString &fileName, const char *format = 0);
77  bool save(QIODevice *dev, const char *format = 0);
78  bool save(const QString &fileName, const char *format = 0);
79 
80  QRect boundingRect() const;
81  void setBoundingRect(const QRect &r);
82 
83  QPicture& operator=(const QPicture &p);
84 #ifdef Q_COMPILER_RVALUE_REFS
85  inline QPicture &operator=(QPicture &&other)
86  { qSwap(d_ptr, other.d_ptr); return *this; }
87 #endif
88  inline void swap(QPicture &other) { d_ptr.swap(other.d_ptr); }
89  void detach();
90  bool isDetached() const;
91 
94 
95  static const char* pictureFormat(const QString &fileName);
96  static QList<QByteArray> inputFormats();
97  static QList<QByteArray> outputFormats();
98  static QStringList inputFormatList();
99  static QStringList outputFormatList();
100 
101  QPaintEngine *paintEngine() const;
102 
103 protected:
104  QPicture(QPicturePrivate &data);
105 
106  int metric(PaintDeviceMetric m) const;
107 #ifdef QT3_SUPPORT
108  inline QT3_SUPPORT QPicture copy() const { QPicture p(*this); p.detach(); return p; }
109 #endif
110 
111 private:
112  bool exec(QPainter *p, QDataStream &ds, int i);
113  void detach_helper();
114 
116  friend class QPicturePaintEngine;
117  friend class Q3Picture;
118  friend class QAlphaPaintEngine;
119  friend class QPreviewPaintEngine;
120 
121 public:
123  inline DataPtr &data_ptr() { return d_ptr; }
124 };
125 
127 
128 
129 #ifndef QT_NO_PICTUREIO
130 class QIODevice;
131 class QPictureIO;
132 typedef void (*picture_io_handler)(QPictureIO *); // picture IO handler
133 
134 struct QPictureIOData;
135 
137 {
138 public:
139  QPictureIO();
140  QPictureIO(QIODevice *ioDevice, const char *format);
141  QPictureIO(const QString &fileName, const char *format);
142  ~QPictureIO();
143 
144  const QPicture &picture() const;
145  int status() const;
146  const char *format() const;
147  QIODevice *ioDevice() const;
148  QString fileName() const;
149  int quality() const;
150  QString description() const;
151  const char *parameters() const;
152  float gamma() const;
153 
154  void setPicture(const QPicture &);
155  void setStatus(int);
156  void setFormat(const char *);
157  void setIODevice(QIODevice *);
158  void setFileName(const QString &);
159  void setQuality(int);
160  void setDescription(const QString &);
161  void setParameters(const char *);
162  void setGamma(float);
163 
164  bool read();
165  bool write();
166 
167  static QByteArray pictureFormat(const QString &fileName);
168  static QByteArray pictureFormat(QIODevice *);
169  static QList<QByteArray> inputFormats();
170  static QList<QByteArray> outputFormats();
171 
172  static void defineIOHandler(const char *format,
173  const char *header,
174  const char *flags,
175  picture_io_handler read_picture,
176  picture_io_handler write_picture);
177 
178 private:
180 
181  void init();
182 
184 };
185 
186 #endif //QT_NO_PICTUREIO
187 
188 
189 /*****************************************************************************
190  QPicture stream functions
191  *****************************************************************************/
192 
193 #ifndef QT_NO_DATASTREAM
196 #endif
197 
198 #endif // QT_NO_PICTURE
199 
201 
203 
204 #endif // QPICTURE_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
void(* picture_io_handler)(QPictureIO *)
Definition: qpicture.h:132
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
void swap(QPicture &other)
Swaps picture other with this picture.
Definition: qpicture.h:88
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
QExplicitlySharedDataPointer< QPicturePrivate > d_ptr
Definition: qpicture.h:115
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QPicture &)
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual int devType() const
Definition: qpaintdevice.h:167
#define Q_DECLARE_SHARED(TYPE)
Definition: qglobal.h:2214
static const QRectF boundingRect(const QPointF *points, int pointCount)
QExplicitlySharedDataPointer< QPicturePrivate > DataPtr
Definition: qpicture.h:122
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool init
static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
Definition: qmime_win.cpp:141
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
QPictureIOData * d
Definition: qpicture.h:183
DataPtr & data_ptr()
Definition: qpicture.h:123
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
virtual QPaintEngine * paintEngine() const =0
QScopedPointer< QPaintEnginePrivate > d_ptr
Definition: qpaintengine.h:246
#define load(x)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual int metric(PaintDeviceMetric metric) const
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QPicture &)
The QPictureIO class contains parameters for loading and saving pictures.
Definition: qpicture.h:136
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
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
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58
#define QT_END_HEADER
Definition: qglobal.h:137
static QString fileName(const QString &fileUrl)
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300