src/gui/image/qpicture.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    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 
       
    49 QT_BEGIN_HEADER
       
    50 
       
    51 QT_BEGIN_NAMESPACE
       
    52 
       
    53 QT_MODULE(Gui)
       
    54 
       
    55 #ifndef QT_NO_PICTURE
       
    56 
       
    57 class QPicturePrivate;
       
    58 class Q_GUI_EXPORT QPicture : public QPaintDevice
       
    59 {
       
    60     Q_DECLARE_PRIVATE(QPicture)
       
    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     void detach();
       
    85     bool isDetached() const;
       
    86 
       
    87     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QPicture &p);
       
    88     friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QPicture &p);
       
    89 
       
    90     static const char* pictureFormat(const QString &fileName);
       
    91     static QList<QByteArray> inputFormats();
       
    92     static QList<QByteArray> outputFormats();
       
    93     static QStringList inputFormatList();
       
    94     static QStringList outputFormatList();
       
    95 
       
    96     QPaintEngine *paintEngine() const;
       
    97 
       
    98 protected:
       
    99     QPicture(QPicturePrivate &data);
       
   100 
       
   101     int metric(PaintDeviceMetric m) const;
       
   102 #ifdef QT3_SUPPORT
       
   103     inline QT3_SUPPORT QPicture copy() const { QPicture p(*this); p.detach(); return p; }
       
   104 #endif
       
   105 
       
   106 private:
       
   107     bool exec(QPainter *p, QDataStream &ds, int i);
       
   108     void detach_helper();
       
   109 
       
   110     QExplicitlySharedDataPointer<QPicturePrivate> d_ptr;
       
   111     friend class QPicturePaintEngine;
       
   112     friend class Q3Picture;
       
   113     friend class QAlphaPaintEngine;
       
   114     friend class QPreviewPaintEngine;
       
   115 
       
   116 public:
       
   117     typedef QExplicitlySharedDataPointer<QPicturePrivate> DataPtr;
       
   118     inline DataPtr &data_ptr() { return d_ptr; }
       
   119 };
       
   120 
       
   121 Q_DECLARE_SHARED(QPicture)
       
   122 
       
   123 
       
   124 #ifndef QT_NO_PICTUREIO
       
   125 class QIODevice;
       
   126 class QPictureIO;
       
   127 typedef void (*picture_io_handler)(QPictureIO *); // picture IO handler
       
   128 
       
   129 struct QPictureIOData;
       
   130 
       
   131 class Q_GUI_EXPORT QPictureIO
       
   132 {
       
   133 public:
       
   134     QPictureIO();
       
   135     QPictureIO(QIODevice *ioDevice, const char *format);
       
   136     QPictureIO(const QString &fileName, const char *format);
       
   137     ~QPictureIO();
       
   138 
       
   139     const QPicture &picture() const;
       
   140     int status() const;
       
   141     const char *format() const;
       
   142     QIODevice *ioDevice() const;
       
   143     QString fileName() const;
       
   144     int quality() const;
       
   145     QString description() const;
       
   146     const char *parameters() const;
       
   147     float gamma() const;
       
   148 
       
   149     void setPicture(const QPicture &);
       
   150     void setStatus(int);
       
   151     void setFormat(const char *);
       
   152     void setIODevice(QIODevice *);
       
   153     void setFileName(const QString &);
       
   154     void setQuality(int);
       
   155     void setDescription(const QString &);
       
   156     void setParameters(const char *);
       
   157     void setGamma(float);
       
   158 
       
   159     bool read();
       
   160     bool write();
       
   161 
       
   162     static QByteArray pictureFormat(const QString &fileName);
       
   163     static QByteArray pictureFormat(QIODevice *);
       
   164     static QList<QByteArray> inputFormats();
       
   165     static QList<QByteArray> outputFormats();
       
   166 
       
   167     static void defineIOHandler(const char *format,
       
   168                                 const char *header,
       
   169                                 const char *flags,
       
   170                                 picture_io_handler read_picture,
       
   171                                 picture_io_handler write_picture);
       
   172 
       
   173 private:
       
   174     Q_DISABLE_COPY(QPictureIO)
       
   175 
       
   176     void init();
       
   177 
       
   178     QPictureIOData *d;
       
   179 };
       
   180 
       
   181 #endif //QT_NO_PICTUREIO
       
   182 
       
   183 
       
   184 /*****************************************************************************
       
   185   QPicture stream functions
       
   186  *****************************************************************************/
       
   187 
       
   188 #ifndef QT_NO_DATASTREAM
       
   189 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPicture &);
       
   190 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPicture &);
       
   191 #endif
       
   192 
       
   193 #endif // QT_NO_PICTURE
       
   194 
       
   195 QT_END_NAMESPACE
       
   196 
       
   197 QT_END_HEADER
       
   198 
       
   199 #endif // QPICTURE_H