author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 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; |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
65 |
class QImageReader; |
0 | 66 |
class QColor; |
67 |
class QVariant; |
|
68 |
class QX11Info; |
|
69 |
class QPixmapData; |
|
70 |
||
71 |
class Q_GUI_EXPORT QPixmap : public QPaintDevice |
|
72 |
{ |
|
73 |
public: |
|
74 |
QPixmap(); |
|
75 |
explicit QPixmap(QPixmapData *data); |
|
76 |
QPixmap(int w, int h); |
|
77 |
QPixmap(const QSize &); |
|
78 |
QPixmap(const QString& fileName, const char *format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor); |
|
79 |
#ifndef QT_NO_IMAGEFORMAT_XPM |
|
80 |
QPixmap(const char * const xpm[]); |
|
81 |
#endif |
|
82 |
QPixmap(const QPixmap &); |
|
83 |
~QPixmap(); |
|
84 |
||
85 |
QPixmap &operator=(const QPixmap &); |
|
86 |
operator QVariant() const; |
|
87 |
||
88 |
bool isNull() const; // ### Qt 5: make inline |
|
89 |
int devType() const; |
|
90 |
||
91 |
int width() const; // ### Qt 5: make inline |
|
92 |
int height() const; // ### Qt 5: make inline |
|
93 |
QSize size() const; |
|
94 |
QRect rect() const; |
|
95 |
int depth() const; |
|
96 |
||
97 |
static int defaultDepth(); |
|
98 |
||
99 |
void fill(const QColor &fillColor = Qt::white); |
|
100 |
void fill(const QWidget *widget, const QPoint &ofs); |
|
101 |
inline void fill(const QWidget *widget, int xofs, int yofs) { fill(widget, QPoint(xofs, yofs)); } |
|
102 |
||
103 |
QBitmap mask() const; |
|
104 |
void setMask(const QBitmap &); |
|
105 |
||
106 |
QPixmap alphaChannel() const; |
|
107 |
void setAlphaChannel(const QPixmap &); |
|
108 |
||
109 |
bool hasAlpha() const; |
|
110 |
bool hasAlphaChannel() const; |
|
111 |
||
112 |
#ifndef QT_NO_IMAGE_HEURISTIC_MASK |
|
113 |
QBitmap createHeuristicMask(bool clipTight = true) const; |
|
114 |
#endif |
|
115 |
QBitmap createMaskFromColor(const QColor &maskColor) const; // ### Qt 5: remove |
|
116 |
QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const; |
|
117 |
||
118 |
static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1); |
|
119 |
static QPixmap grabWidget(QWidget *widget, const QRect &rect); |
|
120 |
static inline QPixmap grabWidget(QWidget *widget, int x=0, int y=0, int w=-1, int h=-1) |
|
121 |
{ return grabWidget(widget, QRect(x, y, w, h)); } |
|
122 |
||
123 |
||
124 |
inline QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode = Qt::IgnoreAspectRatio, |
|
125 |
Qt::TransformationMode mode = Qt::FastTransformation) const |
|
126 |
{ return scaled(QSize(w, h), aspectMode, mode); } |
|
127 |
QPixmap scaled(const QSize &s, Qt::AspectRatioMode aspectMode = Qt::IgnoreAspectRatio, |
|
128 |
Qt::TransformationMode mode = Qt::FastTransformation) const; |
|
129 |
QPixmap scaledToWidth(int w, Qt::TransformationMode mode = Qt::FastTransformation) const; |
|
130 |
QPixmap scaledToHeight(int h, Qt::TransformationMode mode = Qt::FastTransformation) const; |
|
131 |
QPixmap transformed(const QMatrix &, Qt::TransformationMode mode = Qt::FastTransformation) const; |
|
132 |
static QMatrix trueMatrix(const QMatrix &m, int w, int h); |
|
133 |
QPixmap transformed(const QTransform &, Qt::TransformationMode mode = Qt::FastTransformation) const; |
|
134 |
static QTransform trueMatrix(const QTransform &m, int w, int h); |
|
135 |
||
136 |
QImage toImage() const; |
|
137 |
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags = Qt::AutoColor); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
138 |
static QPixmap fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags = Qt::AutoColor); |
0 | 139 |
|
140 |
bool load(const QString& fileName, const char *format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor); |
|
141 |
bool loadFromData(const uchar *buf, uint len, const char* format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor); |
|
142 |
inline bool loadFromData(const QByteArray &data, const char* format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor); |
|
143 |
bool save(const QString& fileName, const char* format = 0, int quality = -1) const; |
|
144 |
bool save(QIODevice* device, const char* format = 0, int quality = -1) const; |
|
145 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
146 |
bool convertFromImage(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
147 |
|
0 | 148 |
#if defined(Q_WS_WIN) |
149 |
enum HBitmapFormat { |
|
150 |
NoAlpha, |
|
151 |
PremultipliedAlpha, |
|
152 |
Alpha |
|
153 |
}; |
|
154 |
||
155 |
HBITMAP toWinHBITMAP(HBitmapFormat format = NoAlpha) const; |
|
156 |
HICON toWinHICON() const; |
|
157 |
||
158 |
static QPixmap fromWinHBITMAP(HBITMAP hbitmap, HBitmapFormat format = NoAlpha); |
|
159 |
static QPixmap fromWinHICON(HICON hicon); |
|
160 |
#endif |
|
161 |
||
162 |
#if defined(Q_WS_MAC) |
|
163 |
CGImageRef toMacCGImageRef() const; |
|
164 |
static QPixmap fromMacCGImageRef(CGImageRef image); |
|
165 |
#endif |
|
166 |
||
167 |
#if defined(Q_OS_SYMBIAN) |
|
168 |
CFbsBitmap *toSymbianCFbsBitmap() const; |
|
169 |
static QPixmap fromSymbianCFbsBitmap(CFbsBitmap *bitmap); |
|
170 |
RSgImage* toSymbianRSgImage() const; |
|
171 |
static QPixmap fromSymbianRSgImage(RSgImage *sgImage); |
|
172 |
#endif |
|
173 |
||
174 |
inline QPixmap copy(int x, int y, int width, int height) const; |
|
175 |
QPixmap copy(const QRect &rect = QRect()) const; |
|
176 |
||
177 |
inline void scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed = 0); |
|
178 |
void scroll(int dx, int dy, const QRect &rect, QRegion *exposed = 0); |
|
179 |
||
180 |
int serialNumber() const; |
|
181 |
qint64 cacheKey() const; |
|
182 |
||
183 |
bool isDetached() const; |
|
184 |
void detach(); |
|
185 |
||
186 |
bool isQBitmap() const; |
|
187 |
||
188 |
#if defined(Q_WS_QWS) |
|
189 |
const uchar *qwsBits() const; |
|
190 |
int qwsBytesPerLine() const; |
|
191 |
QRgb *clut() const; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
#ifdef QT_DEPRECATED |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
QT_DEPRECATED int numCols() const; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
int colorCount() const; |
0 | 196 |
#elif defined(Q_WS_MAC) |
197 |
Qt::HANDLE macQDHandle() const; |
|
198 |
Qt::HANDLE macQDAlphaHandle() const; |
|
199 |
Qt::HANDLE macCGHandle() const; |
|
200 |
#elif defined(Q_WS_X11) |
|
201 |
enum ShareMode { ImplicitlyShared, ExplicitlyShared }; |
|
202 |
||
203 |
static QPixmap fromX11Pixmap(Qt::HANDLE pixmap, ShareMode mode = ImplicitlyShared); |
|
204 |
static int x11SetDefaultScreen(int screen); |
|
205 |
void x11SetScreen(int screen); |
|
206 |
const QX11Info &x11Info() const; |
|
207 |
Qt::HANDLE x11PictureHandle() const; |
|
208 |
#endif |
|
209 |
||
210 |
#if defined(Q_WS_X11) || defined(Q_WS_QWS) |
|
211 |
Qt::HANDLE handle() const; |
|
212 |
#endif |
|
213 |
||
214 |
QPaintEngine *paintEngine() const; |
|
215 |
||
216 |
inline bool operator!() const { return isNull(); } |
|
217 |
||
218 |
protected: |
|
219 |
int metric(PaintDeviceMetric) const; |
|
220 |
||
221 |
#ifdef QT3_SUPPORT |
|
222 |
public: |
|
223 |
enum ColorMode { Auto, Color, Mono }; |
|
224 |
QT3_SUPPORT_CONSTRUCTOR QPixmap(const QString& fileName, const char *format, ColorMode mode); |
|
225 |
QT3_SUPPORT bool load(const QString& fileName, const char *format, ColorMode mode); |
|
226 |
QT3_SUPPORT bool loadFromData(const uchar *buf, uint len, const char* format, ColorMode mode); |
|
227 |
QT3_SUPPORT_CONSTRUCTOR QPixmap(const QImage& image); |
|
228 |
QT3_SUPPORT QPixmap &operator=(const QImage &); |
|
229 |
inline QT3_SUPPORT QImage convertToImage() const { return toImage(); } |
|
230 |
QT3_SUPPORT bool convertFromImage(const QImage &, ColorMode mode); |
|
231 |
inline QT3_SUPPORT operator QImage() const { return toImage(); } |
|
232 |
inline QT3_SUPPORT QPixmap xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); } |
|
233 |
inline QT3_SUPPORT bool selfMask() const { return false; } |
|
234 |
private: |
|
235 |
void resize_helper(const QSize &s); |
|
236 |
public: |
|
237 |
inline QT3_SUPPORT void resize(const QSize &s) { resize_helper(s); } |
|
238 |
inline QT3_SUPPORT void resize(int width, int height) { resize_helper(QSize(width, height)); } |
|
239 |
#endif |
|
240 |
||
241 |
private: |
|
242 |
QExplicitlySharedDataPointer<QPixmapData> data; |
|
243 |
||
244 |
bool doImageIO(QImageWriter *io, int quality) const; |
|
245 |
||
246 |
// ### Qt5: remove the following three lines |
|
247 |
enum Type { PixmapType, BitmapType }; // must match QPixmapData::PixelType |
|
248 |
QPixmap(const QSize &s, Type); |
|
249 |
void init(int, int, Type = PixmapType); |
|
250 |
||
251 |
QPixmap(const QSize &s, int type); |
|
252 |
void init(int, int, int); |
|
253 |
void deref(); |
|
254 |
#if defined(Q_WS_WIN) |
|
255 |
void initAlphaPixmap(uchar *bytes, int length, struct tagBITMAPINFO *bmi); |
|
256 |
#endif |
|
257 |
Q_DUMMY_COMPARISON_OPERATOR(QPixmap) |
|
258 |
#ifdef Q_WS_MAC |
|
259 |
friend CGContextRef qt_mac_cg_context(const QPaintDevice*); |
|
260 |
friend CGImageRef qt_mac_create_imagemask(const QPixmap&, const QRectF&); |
|
261 |
friend IconRef qt_mac_create_iconref(const QPixmap&); |
|
262 |
friend quint32 *qt_mac_pixmap_get_base(const QPixmap*); |
|
263 |
friend int qt_mac_pixmap_get_bytes_per_line(const QPixmap*); |
|
264 |
#endif |
|
265 |
friend class QPixmapData; |
|
266 |
friend class QX11PixmapData; |
|
267 |
friend class QMacPixmapData; |
|
268 |
friend class QS60PixmapData; |
|
269 |
friend class QBitmap; |
|
270 |
friend class QPaintDevice; |
|
271 |
friend class QPainter; |
|
272 |
friend class QGLWidget; |
|
273 |
friend class QX11PaintEngine; |
|
274 |
friend class QCoreGraphicsPaintEngine; |
|
275 |
friend class QWidgetPrivate; |
|
276 |
friend class QRasterBuffer; |
|
277 |
#if !defined(QT_NO_DATASTREAM) |
|
278 |
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &); |
|
279 |
#endif |
|
280 |
friend Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap); |
|
281 |
||
282 |
public: |
|
283 |
QPixmapData* pixmapData() const; |
|
284 |
||
285 |
public: |
|
286 |
typedef QExplicitlySharedDataPointer<QPixmapData> DataPtr; |
|
287 |
inline DataPtr &data_ptr() { return data; } |
|
288 |
}; |
|
289 |
||
290 |
Q_DECLARE_SHARED(QPixmap) |
|
291 |
||
292 |
inline QPixmap QPixmap::copy(int ax, int ay, int awidth, int aheight) const |
|
293 |
{ |
|
294 |
return copy(QRect(ax, ay, awidth, aheight)); |
|
295 |
} |
|
296 |
||
297 |
inline void QPixmap::scroll(int dx, int dy, int ax, int ay, int awidth, int aheight, QRegion *exposed) |
|
298 |
{ |
|
299 |
scroll(dx, dy, QRect(ax, ay, awidth, aheight), exposed); |
|
300 |
} |
|
301 |
||
302 |
inline bool QPixmap::loadFromData(const QByteArray &buf, const char *format, |
|
303 |
Qt::ImageConversionFlags flags) |
|
304 |
{ |
|
305 |
return loadFromData(reinterpret_cast<const uchar *>(buf.constData()), buf.size(), format, flags); |
|
306 |
} |
|
307 |
||
308 |
/***************************************************************************** |
|
309 |
QPixmap stream functions |
|
310 |
*****************************************************************************/ |
|
311 |
||
312 |
#if !defined(QT_NO_DATASTREAM) |
|
313 |
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPixmap &); |
|
314 |
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &); |
|
315 |
#endif |
|
316 |
||
317 |
/***************************************************************************** |
|
318 |
QPixmap (and QImage) helper functions |
|
319 |
*****************************************************************************/ |
|
320 |
#ifdef QT3_SUPPORT |
|
321 |
QT3_SUPPORT Q_GUI_EXPORT void copyBlt(QPixmap *dst, int dx, int dy, const QPixmap *src, |
|
322 |
int sx=0, int sy=0, int sw=-1, int sh=-1); |
|
323 |
#endif // QT3_SUPPORT |
|
324 |
||
325 |
QT_END_NAMESPACE |
|
326 |
||
327 |
QT_END_HEADER |
|
328 |
||
329 |
#endif // QPIXMAP_H |