- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qpicture.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QPICTURE_H
    00043 #define QPICTURE_H
    00044
    00045 #include <QtCore/qstringlist.h>
    00046 #include <QtCore/qsharedpointer.h>
    00047 #include <QtGui/qpaintdevice.h>
    00048
    00049 QT_BEGIN_HEADER
    00050
    00051 QT_BEGIN_NAMESPACE
    00052
    00053 QT_MODULE(Gui)
    00054
    00055 #ifndef QT_NO_PICTURE
    00056
    00057 class QPicturePrivate;
    00058 class Q_GUI_EXPORT QPicture : public QPaintDevice
    00059 {
    00060     Q_DECLARE_PRIVATE(QPicture)
    00061 public:
    00062     explicit QPicture(int formatVersion = -1);
    00063     QPicture(const QPicture &);
    00064     ~QPicture();
    00065
    00066     bool isNull() const;
    00067
    00068     int devType() const;
    00069     uint size() const;
    00070     const char* data() const;
    00071     virtual void setData(const char* data, uint size);
    00072
    00073     bool play(QPainter *p);
    00074
    00075     bool load(QIODevice *dev, const char *format = 0);
    00076     bool load(const QString &fileName, const char *format = 0);
    00077     bool save(QIODevice *dev, const char *format = 0);
    00078     bool save(const QString &fileName, const char *format = 0);
    00079
    00080     QRect boundingRect() const;
    00081     void setBoundingRect(const QRect &r);
    00082
    00083     QPicture& operator=(const QPicture &p);
    00084     void detach();
    00085     bool isDetached() const;
    00086
    00087     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QPicture &p);
    00088     friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QPicture &p);
    00089
    00090     static const char* pictureFormat(const QString &fileName);
    00091     static QList<QByteArray> inputFormats();
    00092     static QList<QByteArray> outputFormats();
    00093     static QStringList inputFormatList();
    00094     static QStringList outputFormatList();
    00095
    00096     QPaintEngine *paintEngine() const;
    00097
    00098 protected:
    00099     QPicture(QPicturePrivate &data);
    00100
    00101     int metric(PaintDeviceMetric m) const;
    00102 #ifdef QT3_SUPPORT
    00103     inline QT3_SUPPORT QPicture copy() const { QPicture p(*this); p.detach(); return p; }
    00104 #endif
    00105
    00106 private:
    00107     bool exec(QPainter *p, QDataStream &ds, int i);
    00108     void detach_helper();
    00109
    00110     QExplicitlySharedDataPointer<QPicturePrivate> d_ptr;
    00111     friend class QPicturePaintEngine;
    00112     friend class Q3Picture;
    00113     friend class QAlphaPaintEngine;
    00114     friend class QPreviewPaintEngine;
    00115
    00116 public:
    00117     typedef QExplicitlySharedDataPointer<QPicturePrivate> DataPtr;
    00118     inline DataPtr &data_ptr() { return d_ptr; }
    00119 };
    00120
    00121 Q_DECLARE_SHARED(QPicture)
    00122
    00123
    00124 #ifndef QT_NO_PICTUREIO
    00125 class QIODevice;
    00126 class QPictureIO;
    00127 typedef void (*picture_io_handler)(QPictureIO *); // picture IO handler
    00128
    00129 struct QPictureIOData;
    00130
    00131 class Q_GUI_EXPORT QPictureIO
    00132 {
    00133 public:
    00134     QPictureIO();
    00135     QPictureIO(QIODevice *ioDevice, const char *format);
    00136     QPictureIO(const QString &fileName, const char *format);
    00137     ~QPictureIO();
    00138
    00139     const QPicture &picture() const;
    00140     int status() const;
    00141     const char *format() const;
    00142     QIODevice *ioDevice() const;
    00143     QString fileName() const;
    00144     int quality() const;
    00145     QString description() const;
    00146     const char *parameters() const;
    00147     float gamma() const;
    00148
    00149     void setPicture(const QPicture &);
    00150     void setStatus(int);
    00151     void setFormat(const char *);
    00152     void setIODevice(QIODevice *);
    00153     void setFileName(const QString &);
    00154     void setQuality(int);
    00155     void setDescription(const QString &);
    00156     void setParameters(const char *);
    00157     void setGamma(float);
    00158
    00159     bool read();
    00160     bool write();
    00161
    00162     static QByteArray pictureFormat(const QString &fileName);
    00163     static QByteArray pictureFormat(QIODevice *);
    00164     static QList<QByteArray> inputFormats();
    00165     static QList<QByteArray> outputFormats();
    00166
    00167     static void defineIOHandler(const char *format,
    00168                                 const char *header,
    00169                                 const char *flags,
    00170                                 picture_io_handler read_picture,
    00171                                 picture_io_handler write_picture);
    00172
    00173 private:
    00174     Q_DISABLE_COPY(QPictureIO)
    00175
    00176     void init();
    00177
    00178     QPictureIOData *d;
    00179 };
    00180
    00181 #endif //QT_NO_PICTUREIO
    00182
    00183
    00184 /*****************************************************************************
    00185   QPicture stream functions
    00186  *****************************************************************************/
    00187
    00188 #ifndef QT_NO_DATASTREAM
    00189 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPicture &);
    00190 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPicture &);
    00191 #endif
    00192
    00193 #endif // QT_NO_PICTURE
    00194
    00195 QT_END_NAMESPACE
    00196
    00197 QT_END_HEADER
    00198
    00199 #endif // QPICTURE_H