| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 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 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QPIXMAP_H
|
|---|
| 43 | #define QPIXMAP_H
|
|---|
| 44 |
|
|---|
| 45 | #include <QtGui/qpaintdevice.h>
|
|---|
| 46 | #include <QtGui/qcolor.h>
|
|---|
| 47 | #include <QtCore/qnamespace.h>
|
|---|
| 48 | #include <QtCore/qstring.h> // char*->QString conversion
|
|---|
| 49 | #include <QtCore/qsharedpointer.h>
|
|---|
| 50 | #include <QtGui/qimage.h>
|
|---|
| 51 | #include <QtGui/qtransform.h>
|
|---|
| 52 |
|
|---|
| 53 | QT_BEGIN_HEADER
|
|---|
| 54 |
|
|---|
| 55 | #if defined(Q_OS_SYMBIAN)
|
|---|
| 56 | class CFbsBitmap;
|
|---|
| 57 | class RSgImage;
|
|---|
| 58 | #endif
|
|---|
| 59 |
|
|---|
| 60 | QT_BEGIN_NAMESPACE
|
|---|
| 61 |
|
|---|
| 62 | QT_MODULE(Gui)
|
|---|
| 63 |
|
|---|
| 64 | class QImageWriter;
|
|---|
| 65 | class QImageReader;
|
|---|
| 66 | class QColor;
|
|---|
| 67 | class QVariant;
|
|---|
| 68 | class QX11Info;
|
|---|
| 69 |
|
|---|
| 70 | #if defined(Q_WS_PM)
|
|---|
| 71 | class QIcon;
|
|---|
| 72 | #endif
|
|---|
| 73 |
|
|---|
| 74 | class QPixmapData;
|
|---|
| 75 |
|
|---|
| 76 | class Q_GUI_EXPORT QPixmap : public QPaintDevice
|
|---|
| 77 | {
|
|---|
| 78 | public:
|
|---|
| 79 | QPixmap();
|
|---|
| 80 | explicit QPixmap(QPixmapData *data);
|
|---|
| 81 | QPixmap(int w, int h);
|
|---|
| 82 | QPixmap(const QSize &);
|
|---|
| 83 | QPixmap(const QString& fileName, const char *format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
|---|
| 84 | #ifndef QT_NO_IMAGEFORMAT_XPM
|
|---|
| 85 | QPixmap(const char * const xpm[]);
|
|---|
| 86 | #endif
|
|---|
| 87 | QPixmap(const QPixmap &);
|
|---|
| 88 | ~QPixmap();
|
|---|
| 89 |
|
|---|
| 90 | QPixmap &operator=(const QPixmap &);
|
|---|
| 91 | operator QVariant() const;
|
|---|
| 92 |
|
|---|
| 93 | bool isNull() const; // ### Qt 5: make inline
|
|---|
| 94 | int devType() const;
|
|---|
| 95 |
|
|---|
| 96 | int width() const; // ### Qt 5: make inline
|
|---|
| 97 | int height() const; // ### Qt 5: make inline
|
|---|
| 98 | QSize size() const;
|
|---|
| 99 | QRect rect() const;
|
|---|
| 100 | int depth() const;
|
|---|
| 101 |
|
|---|
| 102 | static int defaultDepth();
|
|---|
| 103 |
|
|---|
| 104 | void fill(const QColor &fillColor = Qt::white);
|
|---|
| 105 | void fill(const QWidget *widget, const QPoint &ofs);
|
|---|
| 106 | inline void fill(const QWidget *widget, int xofs, int yofs) { fill(widget, QPoint(xofs, yofs)); }
|
|---|
| 107 |
|
|---|
| 108 | QBitmap mask() const;
|
|---|
| 109 | void setMask(const QBitmap &);
|
|---|
| 110 |
|
|---|
| 111 | QPixmap alphaChannel() const;
|
|---|
| 112 | void setAlphaChannel(const QPixmap &);
|
|---|
| 113 |
|
|---|
| 114 | bool hasAlpha() const;
|
|---|
| 115 | bool hasAlphaChannel() const;
|
|---|
| 116 |
|
|---|
| 117 | #ifndef QT_NO_IMAGE_HEURISTIC_MASK
|
|---|
| 118 | QBitmap createHeuristicMask(bool clipTight = true) const;
|
|---|
| 119 | #endif
|
|---|
| 120 | QBitmap createMaskFromColor(const QColor &maskColor) const; // ### Qt 5: remove
|
|---|
| 121 | QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const;
|
|---|
| 122 |
|
|---|
| 123 | static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1);
|
|---|
| 124 | static QPixmap grabWidget(QWidget *widget, const QRect &rect);
|
|---|
| 125 | static inline QPixmap grabWidget(QWidget *widget, int x=0, int y=0, int w=-1, int h=-1)
|
|---|
| 126 | { return grabWidget(widget, QRect(x, y, w, h)); }
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | inline QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode = Qt::IgnoreAspectRatio,
|
|---|
| 130 | Qt::TransformationMode mode = Qt::FastTransformation) const
|
|---|
| 131 | { return scaled(QSize(w, h), aspectMode, mode); }
|
|---|
| 132 | QPixmap scaled(const QSize &s, Qt::AspectRatioMode aspectMode = Qt::IgnoreAspectRatio,
|
|---|
| 133 | Qt::TransformationMode mode = Qt::FastTransformation) const;
|
|---|
| 134 | QPixmap scaledToWidth(int w, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
|---|
| 135 | QPixmap scaledToHeight(int h, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
|---|
| 136 | QPixmap transformed(const QMatrix &, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
|---|
| 137 | static QMatrix trueMatrix(const QMatrix &m, int w, int h);
|
|---|
| 138 | QPixmap transformed(const QTransform &, Qt::TransformationMode mode = Qt::FastTransformation) const;
|
|---|
| 139 | static QTransform trueMatrix(const QTransform &m, int w, int h);
|
|---|
| 140 |
|
|---|
| 141 | QImage toImage() const;
|
|---|
| 142 | static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
|---|
| 143 | static QPixmap fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
|---|
| 144 |
|
|---|
| 145 | bool load(const QString& fileName, const char *format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
|---|
| 146 | bool loadFromData(const uchar *buf, uint len, const char* format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
|---|
| 147 | inline bool loadFromData(const QByteArray &data, const char* format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
|---|
| 148 | bool save(const QString& fileName, const char* format = 0, int quality = -1) const;
|
|---|
| 149 | bool save(QIODevice* device, const char* format = 0, int quality = -1) const;
|
|---|
| 150 |
|
|---|
| 151 | bool convertFromImage(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor);
|
|---|
| 152 |
|
|---|
| 153 | #if defined(Q_WS_WIN)
|
|---|
| 154 | enum HBitmapFormat {
|
|---|
| 155 | NoAlpha,
|
|---|
| 156 | PremultipliedAlpha,
|
|---|
| 157 | Alpha
|
|---|
| 158 | };
|
|---|
| 159 |
|
|---|
| 160 | HBITMAP toWinHBITMAP(HBitmapFormat format = NoAlpha) const;
|
|---|
| 161 | HICON toWinHICON() const;
|
|---|
| 162 |
|
|---|
| 163 | static QPixmap fromWinHBITMAP(HBITMAP hbitmap, HBitmapFormat format = NoAlpha);
|
|---|
| 164 | static QPixmap fromWinHICON(HICON hicon);
|
|---|
|
|---|