src/gui/image/qpicture.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the QtGui module of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 
00024 #ifndef QPICTURE_H
00025 #define QPICTURE_H
00026 
00027 #include <QtGui/qpaintdevice.h>
00028 #include <QtCore/qstringlist.h>
00029 
00030 QT_BEGIN_HEADER
00031 
00032 QT_MODULE(Gui)
00033 
00034 #ifndef QT_NO_PICTURE
00035 
00036 class QPicturePrivate;
00037 class Q_GUI_EXPORT QPicture : public QPaintDevice
00038 {
00039     Q_DECLARE_PRIVATE(QPicture)
00040 public:
00041     explicit QPicture(int formatVersion = -1);
00042     QPicture(const QPicture &);
00043     ~QPicture();
00044 
00045     bool isNull() const;
00046 
00047     int devType() const;
00048     uint size() const;
00049     const char* data() const;
00050     virtual void setData(const char* data, uint size);
00051 
00052     bool play(QPainter *p);
00053 
00054     bool load(QIODevice *dev, const char *format = 0);
00055     bool load(const QString &fileName, const char *format = 0);
00056     bool save(QIODevice *dev, const char *format = 0);
00057     bool save(const QString &fileName, const char *format = 0);
00058 
00059     QRect boundingRect() const;
00060     void setBoundingRect(const QRect &r);
00061 
00062     QPicture& operator=(const QPicture &p);
00063     void detach();
00064     bool isDetached() const;
00065 
00066     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QPicture &p);
00067     friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QPicture &p);
00068 
00069     static const char* pictureFormat(const QString &fileName);
00070     static QList<QByteArray> inputFormats();
00071     static QList<QByteArray> outputFormats();
00072     static QStringList inputFormatList();
00073     static QStringList outputFormatList();
00074 
00075     QPaintEngine *paintEngine() const;
00076 
00077 protected:
00078     QPicture(QPicturePrivate &data);
00079 
00080     int metric(PaintDeviceMetric m) const;
00081 #ifdef QT3_SUPPORT
00082     inline QT3_SUPPORT QPicture copy() const { QPicture p(*this); p.detach(); return p; }
00083 #endif
00084 
00085 private:
00086     bool exec(QPainter *p, QDataStream &ds, int i);
00087     void detach_helper();
00088 
00089     QPicturePrivate *d_ptr;
00090     friend class QPicturePaintEngine;
00091     friend class Q3Picture;
00092 };
00093 
00094 Q_DECLARE_SHARED(QPicture)
00095 
00096 
00097 #ifndef QT_NO_PICTUREIO
00098 class QIODevice;
00099 class QPictureIO;
00100 typedef void (*picture_io_handler)(QPictureIO *); // picture IO handler
00101 
00102 struct QPictureIOData;
00103 
00104 class Q_GUI_EXPORT QPictureIO
00105 {
00106 public:
00107     QPictureIO();
00108     QPictureIO(QIODevice *ioDevice, const char *format);
00109     QPictureIO(const QString &fileName, const char *format);
00110     ~QPictureIO();
00111 
00112     const QPicture &picture() const;
00113     int status() const;
00114     const char *format() const;
00115     QIODevice *ioDevice() const;
00116     QString fileName() const;
00117     int quality() const;
00118     QString description() const;
00119     const char *parameters() const;
00120     float gamma() const;
00121 
00122     void setPicture(const QPicture &);
00123     void setStatus(int);
00124     void setFormat(const char *);
00125     void setIODevice(QIODevice *);
00126     void setFileName(const QString &);
00127     void setQuality(int);
00128     void setDescription(const QString &);
00129     void setParameters(const char *);
00130     void setGamma(float);
00131 
00132     bool read();
00133     bool write();
00134 
00135     static QByteArray pictureFormat(const QString &fileName);
00136     static QByteArray pictureFormat(QIODevice *);
00137     static QList<QByteArray> inputFormats();
00138     static QList<QByteArray> outputFormats();
00139 
00140     static void defineIOHandler(const char *format,
00141                                 const char *header,
00142                                 const char *flags,
00143                                 picture_io_handler read_picture,
00144                                 picture_io_handler write_picture);
00145 
00146 private:
00147     Q_DISABLE_COPY(QPictureIO)
00148 
00149     void init();
00150 
00151     QPictureIOData *d;
00152 };
00153 
00154 #endif //QT_NO_PICTUREIO
00155 
00156 
00157 /*****************************************************************************
00158   QPicture stream functions
00159  *****************************************************************************/
00160 
00161 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPicture &);
00162 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPicture &);
00163 
00164 #endif // QT_NO_PICTURE
00165 
00166 QT_END_HEADER
00167 
00168 #endif // QPICTURE_H

Generated on Thu Mar 15 11:54:40 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1