source: trunk/src/kernel/qpixmap.cpp@ 97

Last change on this file since 97 was 59, checked in by dmik, 20 years ago

Implemented alpha blending for pixmaps.
Improved blitting of masked pixmaps.

  • Property svn:keywords set to Id
File size: 43.0 KB
Line 
1/****************************************************************************
2** $Id: qpixmap.cpp 59 2006-01-29 19:56:21Z dmik $
3**
4** Implementation of QPixmap class
5**
6** Created : 950301
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the kernel module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "qpixmap.h"
39
40#include "qbitmap.h"
41#include "qimage.h"
42#include "qwidget.h"
43#include "qpainter.h"
44#include "qdatastream.h"
45#include "qbuffer.h"
46#include "qobjectlist.h"
47#include "qapplication.h"
48#include <private/qinternal_p.h>
49#include "qmime.h"
50#include "qdragobject.h"
51#include "qfile.h"
52
53/*!
54 \class QPixmap qpixmap.h
55 \brief The QPixmap class is an off-screen, pixel-based paint device.
56
57 \ingroup graphics
58 \ingroup images
59 \ingroup shared
60 \mainclass
61
62 QPixmap is one of the two classes Qt provides for dealing with
63 images; the other is QImage. QPixmap is designed and optimized
64 for drawing; QImage is designed and optimized for I/O and for
65 direct pixel access/manipulation. There are (slow) functions to
66 convert between QImage and QPixmap: convertToImage() and
67 convertFromImage().
68
69 One common use of the QPixmap class is to enable smooth updating
70 of widgets. Whenever something complex needs to be drawn, you can
71 use a pixmap to obtain flicker-free drawing, like this:
72
73 \list 1
74 \i Create a pixmap with the same size as the widget.
75 \i Fill the pixmap with the widget background color.
76 \i Paint the pixmap.
77 \i bitBlt() the pixmap contents onto the widget.
78 \endlist
79
80 Pixel data in a pixmap is internal and is managed by the
81 underlying window system. Pixels can be accessed only through
82 QPainter functions, through bitBlt(), and by converting the
83 QPixmap to a QImage.
84
85 You can easily display a QPixmap on the screen using
86 QLabel::setPixmap(). For example, all the QButton subclasses
87 support pixmap use.
88
89 The QPixmap class uses \link shclass.html copy-on-write\endlink,
90 so it is practical to pass QPixmap objects by value.
91
92 You can retrieve the width(), height(), depth() and size() of a
93 pixmap. The enclosing rectangle is given by rect(). Pixmaps can be
94 filled with fill() and resized with resize(). You can create and
95 set a mask with createHeuristicMask() and setMask(). Use
96 selfMask() to see if the pixmap is identical to its mask.
97
98 In addition to loading a pixmap from file using load() you can
99 also loadFromData(). You can control optimization with
100 setOptimization() and obtain a transformed version of the pixmap
101 using xForm()
102
103 Note regarding Windows 95 and 98: on Windows 9x the system crashes
104 if you create more than about 1000 pixmaps, independent of the
105 size of the pixmaps or installed RAM. Windows NT-systems (including
106 2000, XP and following versions) do not have the same limitation,
107 but depending on the graphics equipment the system will fail to
108 allocate pixmap objects at some point (due to system running out of
109 GDI resources).
110
111 Qt tries to work around the resource limitation. If you set the
112 pixmap optimization to \c QPixmap::MemoryOptim and the width of
113 your pixmap is less than or equal to 128 pixels, Qt stores the
114 pixmap in a way that is very memory-efficient when there are many
115 pixmaps.
116
117 If your application uses dozens or hundreds of pixmaps (for
118 example on tool bar buttons and in popup menus), and you plan to
119 run it on Windows 95 or Windows 98, we recommend using code like
120 this:
121
122 \code
123 QPixmap::setDefaultOptimization( QPixmap::MemoryOptim );
124 while ( ... ) {
125 // load tool bar pixmaps etc.
126 QPixmap *pixmap = new QPixmap(fileName);
127 }
128 QPixmap::setDefaultOptimization( QPixmap::NormalOptim );
129 \endcode
130
131 In general it is recommended to make as much use of QPixmap's
132 implicit sharing and the QPixmapCache as possible.
133
134 \sa QBitmap, QImage, QImageIO, \link shclass.html Shared Classes\endlink
135*/
136
137/*!
138 \enum QPixmap::ColorMode
139
140 This enum type defines the color modes that exist for converting
141 QImage objects to QPixmap.
142
143 \value Auto Select \c Color or \c Mono on a case-by-case basis.
144 \value Color Always create colored pixmaps.
145 \value Mono Always create bitmaps.
146*/
147
148/*!
149 \enum QPixmap::Optimization
150
151 QPixmap has the choice of optimizing for speed or memory in a few
152 places; the best choice varies from pixmap to pixmap but can
153 generally be derived heuristically. This enum type defines a
154 number of optimization modes that you can set for any pixmap to
155 tweak the speed/memory tradeoffs:
156
157 \value DefaultOptim Whatever QPixmap::defaultOptimization()
158 returns. A pixmap with this optimization will have whatever
159 the current default optimization is. If the default
160 optimization is changed using setDefaultOptimization(), then
161 this will not effect any pixmaps that have already been
162 created.
163
164 \value NoOptim No optimization (currently the same as \c
165 MemoryOptim).
166
167 \value MemoryOptim Optimize for minimal memory use on Windows
168 9x and X11 systems.
169
170 \value NormalOptim Optimize for typical usage. Often uses more
171 memory than \c MemoryOptim, and is often faster.
172
173 \value BestOptim Optimize for pixmaps that are drawn very often
174 and where performance is critical. Generally uses more memory
175 than \c NormalOptim and may provide a little more speed.
176
177 We recommend using \c DefaultOptim.
178
179*/
180
181
182QPixmap::Optimization QPixmap::defOptim = QPixmap::NormalOptim;
183
184
185/*!
186 \internal
187 Private constructor which takes the bitmap flag, the optimization.and a screen.
188*/
189
190QPixmap::QPixmap( int w, int h, int depth, bool bitmap,
191 Optimization optimization )
192 : QPaintDevice( QInternal::Pixmap )
193{
194 init( w, h, depth, bitmap, optimization );
195}
196
197
198/*!
199 Constructs a null pixmap.
200
201 \sa isNull()
202*/
203
204QPixmap::QPixmap()
205 : QPaintDevice( QInternal::Pixmap )
206{
207 init( 0, 0, 0, FALSE, defOptim );
208}
209
210/*!
211 Constructs a pixmap from the QImage \a image.
212
213 \sa convertFromImage()
214*/
215
216QPixmap::QPixmap( const QImage& image )
217 : QPaintDevice( QInternal::Pixmap )
218{
219 init( 0, 0, 0, FALSE, defOptim );
220 convertFromImage( image );
221}
222
223/*!
224 Constructs a pixmap with \a w width, \a h height and \a depth bits
225 per pixel. The pixmap is optimized in accordance with the \a
226 optimization value.
227
228 The contents of the pixmap is uninitialized.
229
230 The \a depth can be either 1 (monochrome) or the depth of the
231 current video mode. If \a depth is negative, then the hardware
232 depth of the current video mode will be used.
233
234 If either \a w or \a h is zero, a null pixmap is constructed.
235
236 \sa isNull() QPixmap::Optimization
237*/
238
239QPixmap::QPixmap( int w, int h, int depth, Optimization optimization )
240 : QPaintDevice( QInternal::Pixmap )
241{
242 init( w, h, depth, FALSE, optimization );
243}
244
245/*!
246 \overload QPixmap::QPixmap( const QSize &size, int depth, Optimization optimization )
247
248 Constructs a pixmap of size \a size, \a depth bits per pixel,
249 optimized in accordance with the \a optimization value.
250*/
251
252QPixmap::QPixmap( const QSize &size, int depth, Optimization optimization )
253 : QPaintDevice( QInternal::Pixmap )
254{
255 init( size.width(), size.height(), depth, FALSE, optimization );
256}
257
258#ifndef QT_NO_IMAGEIO
259/*!
260 Constructs a pixmap from the file \a fileName. If the file does
261 not exist or is of an unknown format, the pixmap becomes a null
262 pixmap.
263
264 The \a fileName, \a format and \a conversion_flags parameters are
265 passed on to load(). This means that the data in \a fileName is
266 not compiled into the binary. If \a fileName contains a relative
267 path (e.g. the filename only) the relevant file must be found
268 relative to the runtime working directory.
269
270 If the image needs to be modified to fit in a lower-resolution
271 result (e.g. converting from 32-bit to 8-bit), use the \a
272 conversion_flags to specify how you'd prefer this to happen.
273
274 \sa Qt::ImageConversionFlags isNull(), load(), loadFromData(), save(), imageFormat()
275*/
276
277QPixmap::QPixmap( const QString& fileName, const char *format,
278 int conversion_flags )
279 : QPaintDevice( QInternal::Pixmap )
280{
281 init( 0, 0, 0, FALSE, defOptim );
282 load( fileName, format, conversion_flags );
283}
284
285/*!
286 Constructs a pixmap from the file \a fileName. If the file does
287 not exist or is of an unknown format, the pixmap becomes a null
288 pixmap.
289
290 The \a fileName, \a format and \a mode parameters are passed on to
291 load(). This means that the data in \a fileName is not compiled
292 into the binary. If \a fileName contains a relative path (e.g. the
293 filename only) the relevant file must be found relative to the
294 runtime working directory.
295
296 \sa QPixmap::ColorMode isNull(), load(), loadFromData(), save(), imageFormat()
297*/
298
299QPixmap::QPixmap( const QString& fileName, const char *format, ColorMode mode )
300 : QPaintDevice( QInternal::Pixmap )
301{
302 init( 0, 0, 0, FALSE, defOptim );
303 load( fileName, format, mode );
304}
305
306/*!
307 Constructs a pixmap from \a xpm, which must be a valid XPM image.
308
309 Errors are silently ignored.
310
311 Note that it's possible to squeeze the XPM variable a little bit
312 by using an unusual declaration:
313
314 \code
315 static const char * const start_xpm[]={
316 "16 15 8 1",
317 "a c #cec6bd",
318 ....
319 \endcode
320
321 The extra \c const makes the entire definition read-only, which is
322 slightly more efficient (for example, when the code is in a shared
323 library) and ROMable when the application is to be stored in ROM.
324
325 In order to use that sort of declaration you must cast the
326 variable back to \c{const char **} when you create the QPixmap.
327*/
328
329QPixmap::QPixmap( const char *xpm[] )
330 : QPaintDevice( QInternal::Pixmap )
331{
332 init( 0, 0, 0, FALSE, defOptim );
333 QImage image( xpm );
334 if ( !image.isNull() )
335 convertFromImage( image );
336}
337
338/*!
339 Constructs a pixmaps by loading from \a img_data. The data can be
340 in any image format supported by Qt.
341
342 \sa loadFromData()
343*/
344
345QPixmap::QPixmap( const QByteArray & img_data )
346 : QPaintDevice( QInternal::Pixmap )
347{
348 init( 0, 0, 0, FALSE, defOptim );
349 loadFromData( img_data );
350}
351#endif //QT_NO_IMAGEIO
352
353/*!
354 Constructs a pixmap that is a copy of \a pixmap.
355*/
356
357QPixmap::QPixmap( const QPixmap &pixmap )
358 : QPaintDevice( QInternal::Pixmap )
359{
360 if ( pixmap.paintingActive() ) { // make a deep copy
361 data = 0;
362 operator=( pixmap.copy() );
363 } else {
364 data = pixmap.data;
365 data->ref();
366 devFlags = pixmap.devFlags; // copy QPaintDevice flags
367#if defined(Q_WS_WIN)
368 hdc = pixmap.hdc; // copy Windows device context
369#elif defined(Q_WS_PM)
370 hps = pixmap.hps; // copy OS/2 PM presentation space
371#elif defined(Q_WS_X11)
372 hd = pixmap.hd; // copy X11 drawable
373 rendhd = pixmap.rendhd;
374 copyX11Data( &pixmap ); // copy x11Data
375#elif defined(Q_WS_MAC)
376 hd = pixmap.hd;
377#endif
378 }
379}
380
381
382/*!
383 Destroys the pixmap.
384*/
385
386QPixmap::~QPixmap()
387{
388 deref();
389}
390
391/*! Convenience function. Gets the data associated with the absolute
392 name \a abs_name from the default mime source factory and decodes it
393 to a pixmap.
394
395 \sa QMimeSourceFactory, QImage::fromMimeSource(), QImageDrag::decode()
396*/
397
398#ifndef QT_NO_MIME
399QPixmap QPixmap::fromMimeSource( const QString &abs_name )
400{
401 const QMimeSource *m = QMimeSourceFactory::defaultFactory()->data( abs_name );
402 if ( !m ) {
403 if ( QFile::exists( abs_name ) )
404 return QPixmap( abs_name );
405#if defined(QT_CHECK_STATE)
406 if ( !abs_name.isEmpty() )
407 qWarning( "QPixmap::fromMimeSource: Cannot find pixmap \"%s\" in the mime source factory",
408 abs_name.latin1() );
409#endif
410 return QPixmap();
411 }
412 QPixmap pix;
413 QImageDrag::decode( m, pix );
414 return pix;
415}
416#endif
417
418/*!
419 Returns a \link shclass.html deep copy\endlink of the pixmap using
420 the bitBlt() function to copy the pixels.
421
422 \sa operator=()
423*/
424
425QPixmap QPixmap::copy( bool ignoreMask ) const
426{
427#if defined(Q_WS_X11)
428 int old = x11SetDefaultScreen( x11Screen() );
429#endif // Q_WS_X11
430
431 QPixmap pm( data->w, data->h, data->d, data->bitmap, data->optim );
432
433 if ( !pm.isNull() ) { // copy the bitmap
434#if defined(Q_WS_X11)
435 pm.cloneX11Data( this );
436#endif // Q_WS_X11
437
438 if ( ignoreMask )
439 bitBlt( &pm, 0, 0, this, 0, 0, data->w, data->h, Qt::CopyROP, TRUE );
440 else
441 copyBlt( &pm, 0, 0, this, 0, 0, data->w, data->h );
442 }
443
444#if defined(Q_WS_X11)
445 x11SetDefaultScreen( old );
446#endif // Q_WS_X11
447
448 return pm;
449}
450
451
452/*!
453 Assigns the pixmap \a pixmap to this pixmap and returns a
454 reference to this pixmap.
455*/
456
457QPixmap &QPixmap::operator=( const QPixmap &pixmap )
458{
459 if ( paintingActive() ) {
460#if defined(QT_CHECK_STATE)
461 qWarning("QPixmap::operator=: Cannot assign to pixmap during painting");
462#endif
463 return *this;
464 }
465 pixmap.data->ref(); // avoid 'x = x'
466 deref();
467 if ( pixmap.paintingActive() ) { // make a deep copy
468 init( pixmap.width(), pixmap.height(), pixmap.depth(),
469 pixmap.data->bitmap, pixmap.data->optim );
470 data->uninit = FALSE;
471 if ( !isNull() )
472 copyBlt( this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height() );
473 pixmap.data->deref();
474 } else {
475 data = pixmap.data;
476 devFlags = pixmap.devFlags; // copy QPaintDevice flags
477#if defined(Q_WS_WIN)
478 hdc = pixmap.hdc;
479#elif defined(Q_WS_PM)
480 hps = pixmap.hps;
481#elif defined(Q_WS_X11)
482 hd = pixmap.hd; // copy QPaintDevice drawable
483 rendhd = pixmap.rendhd;
484 copyX11Data( &pixmap ); // copy x11Data
485#elif defined(Q_WS_MACX) || defined(Q_OS_MAC9)
486 hd = pixmap.hd;
487#endif
488 }
489 return *this;
490}
491
492
493/*!
494 \overload
495
496 Converts the image \a image to a pixmap that is assigned to this
497 pixmap. Returns a reference to the pixmap.
498
499 \sa convertFromImage().
500*/
501
502QPixmap &QPixmap::operator=( const QImage &image )
503{
504 convertFromImage( image );
505 return *this;
506}
507
508
509/*!
510 \fn bool QPixmap::isQBitmap() const
511
512 Returns TRUE if this is a QBitmap; otherwise returns FALSE.
513*/
514
515/*!
516 \fn bool QPixmap::isNull() const
517
518 Returns TRUE if this is a null pixmap; otherwise returns FALSE.
519
520 A null pixmap has zero width, zero height and no contents. You
521 cannot draw in a null pixmap or bitBlt() anything to it.
522
523 Resizing an existing pixmap to (0, 0) makes a pixmap into a null
524 pixmap.
525
526 \sa resize()
527*/
528
529/*!
530 \fn int QPixmap::width() const
531
532 Returns the width of the pixmap.
533
534 \sa height(), size(), rect()
535*/
536
537/*!
538 \fn int QPixmap::height() const
539
540 Returns the height of the pixmap.
541
542 \sa width(), size(), rect()
543*/
544
545/*!
546 \fn QSize QPixmap::size() const
547
548 Returns the size of the pixmap.
549
550 \sa width(), height(), rect()
551*/
552
553/*!
554 \fn QRect QPixmap::rect() const
555
556 Returns the enclosing rectangle (0,0,width(),height()) of the pixmap.
557
558 \sa width(), height(), size()
559*/
560
561/*!
562 \fn int QPixmap::depth() const
563
564 Returns the depth of the pixmap.
565
566 The pixmap depth is also called bits per pixel (bpp) or bit planes
567 of a pixmap. A null pixmap has depth 0.
568
569 \sa defaultDepth(), isNull(), QImage::convertDepth()
570*/
571
572
573/*!
574 \overload void QPixmap::fill( const QWidget *widget, const QPoint &ofs )
575
576 Fills the pixmap with the \a widget's background color or pixmap.
577 If the background is empty, nothing is done.
578
579 The \a ofs point is an offset in the widget.
580
581 The point \a ofs is a point in the widget's coordinate system. The
582 pixmap's top-left pixel will be mapped to the point \a ofs in the
583 widget. This is significant if the widget has a background pixmap;
584 otherwise the pixmap will simply be filled with the background
585 color of the widget.
586
587 Example:
588 \code
589 void CuteWidget::paintEvent( QPaintEvent *e )
590 {
591 QRect ur = e->rect(); // rectangle to update
592 QPixmap pix( ur.size() ); // Pixmap for double-buffering
593 pix.fill( this, ur.topLeft() ); // fill with widget background
594
595 QPainter p( &pix );
596 p.translate( -ur.x(), -ur.y() ); // use widget coordinate system
597 // when drawing on pixmap
598 // ... draw on pixmap ...
599
600 p.end();
601
602 bitBlt( this, ur.topLeft(), &pix );
603 }
604 \endcode
605*/
606
607/*!
608 \overload void QPixmap::fill( const QWidget *widget, int xofs, int yofs )
609
610 Fills the pixmap with the \a widget's background color or pixmap.
611 If the background is empty, nothing is done. \a xofs, \a yofs is
612 an offset in the widget.
613*/
614
615void QPixmap::fill( const QWidget *widget, int xofs, int yofs )
616{
617 const QPixmap* bgpm = widget->backgroundPixmap();
618 fill( widget->backgroundColor() );
619 if ( bgpm ) {
620 if ( !bgpm->isNull() ) {
621 QPoint ofs = widget->backgroundOffset();
622 xofs += ofs.x();
623 yofs += ofs.y();
624
625 QPainter p;
626 p.begin( this );
627 p.setPen( NoPen );
628 p.drawTiledPixmap( 0, 0, width(), height(), *widget->backgroundPixmap(), xofs, yofs );
629 p.end();
630 }
631 }
632}
633
634
635/*!
636 \overload void QPixmap::resize( const QSize &size )
637
638 Resizes the pixmap to size \a size.
639*/
640
641/*!
642 Resizes the pixmap to \a w width and \a h height. If either \a w
643 or \a h is 0, the pixmap becomes a null pixmap.
644
645 If both \a w and \a h are greater than 0, a valid pixmap is
646 created. New pixels will be uninitialized (random) if the pixmap
647 is expanded.
648*/
649
650void QPixmap::resize( int w, int h )
651{
652 if ( w < 1 || h < 1 ) { // becomes null
653 QPixmap pm( 0, 0, 0, data->bitmap, data->optim );
654 *this = pm;
655 return;
656 }
657 int d;
658 if ( depth() > 0 )
659 d = depth();
660 else
661 d = isQBitmap() ? 1 : -1;
662 // Create new pixmap
663 QPixmap pm( w, h, d, data->bitmap, data->optim );
664#ifdef Q_WS_X11
665 pm.x11SetScreen( x11Screen() );
666#endif // Q_WS_X11
667 if ( !data->uninit && !isNull() ) // has existing pixmap
668 bitBlt( &pm, 0, 0, this, 0, 0, // copy old pixmap
669 QMIN(width(), w),
670 QMIN(height(),h), CopyROP, TRUE );
671#if defined(Q_WS_MAC)
672 if(data->alphapm) {
673 data->alphapm->resize(w, h);
674 } else
675#elif defined(Q_WS_X11) && !defined(QT_NO_XFTFREETYPE)
676 if (data->alphapm)
677 qWarning("QPixmap::resize: TODO: resize alpha data");
678 else
679#endif // Q_WS_X11
680 if ( data->mask ) { // resize mask as well
681 if ( data->selfmask ) { // preserve self-mask
682 pm.setMask( *((QBitmap*)&pm) );
683 } else { // independent mask
684 QBitmap m = *data->mask;
685 m.resize( w, h );
686 pm.setMask( m );
687 }
688 }
689 *this = pm;
690}
691
692
693/*!
694 \fn const QBitmap *QPixmap::mask() const
695
696 Returns the mask bitmap, or 0 if no mask has been set.
697
698 \sa setMask(), QBitmap, hasAlpha()
699*/
700
701/*!
702 Sets a mask bitmap.
703
704 The \a newmask bitmap defines the clip mask for this pixmap. Every
705 pixel in \a newmask corresponds to a pixel in this pixmap. Pixel
706 value 1 means opaque and pixel value 0 means transparent. The mask
707 must have the same size as this pixmap.
708
709 \warning Setting the mask on a pixmap will cause any alpha channel
710 data to be cleared. For example:
711 \code
712 QPixmap alpha( "image-with-alpha.png" );
713 QPixmap alphacopy = alpha;
714 alphacopy.setMask( *alphacopy.mask() );
715 \endcode
716 Now, alpha and alphacopy are visually different.
717
718 Setting a \link isNull() null\endlink mask resets the mask.
719
720 \sa mask(), createHeuristicMask(), QBitmap
721*/
722
723void QPixmap::setMask( const QBitmap &newmask )
724{
725 const QPixmap *tmp = &newmask; // dec cxx bug
726 if ( (data == tmp->data) ||
727 ( newmask.handle() && newmask.handle() == handle() ) ) {
728 QPixmap m = tmp->copy( TRUE );
729 setMask( *((QBitmap*)&m) );
730 data->selfmask = TRUE; // mask == pixmap
731 return;
732 }
733
734 if ( newmask.isNull() ) { // reset the mask
735 if (data->mask) {
736 detach();
737 data->selfmask = FALSE;
738
739 delete data->mask;
740 data->mask = 0;
741#if defined (Q_WS_PM)
742 if ( data->maskedHbm ) {
743 GpiDeleteBitmap( data->maskedHbm );
744 data->maskedHbm = 0;
745 }
746#endif
747 }
748#if defined (Q_WS_PM)
749 if ( data->hasRealAlpha ) {
750 detach();
751 data->hasRealAlpha = FALSE;
752 if ( data->realAlphaBits ) {
753 delete[] data->realAlphaBits;
754 data->realAlphaBits = 0;
755 }
756 }
757#endif
758 return;
759 }
760
761 detach();
762 data->selfmask = FALSE;
763
764 if ( newmask.width() != width() || newmask.height() != height() ) {
765#if defined(QT_CHECK_RANGE)
766 qWarning( "QPixmap::setMask: The pixmap and the mask must have "
767 "the same size" );
768#endif
769 return;
770 }
771#if defined(Q_WS_MAC) || (defined(Q_WS_X11) && !defined(QT_NO_XFTFREETYPE))
772 // when setting the mask, we get rid of the alpha channel completely
773 delete data->alphapm;
774 data->alphapm = 0;
775#endif // Q_WS_X11 && !QT_NO_XFTFREETYPE
776
777#if defined (Q_WS_PM)
778 if ( data->hasRealAlpha ) {
779 data->hasRealAlpha = FALSE;
780 if ( data->realAlphaBits ) {
781 delete[] data->realAlphaBits;
782 data->realAlphaBits = 0;
783 }
784 }
785 if ( data->maskedHbm ) {
786 GpiDeleteBitmap( data->maskedHbm );
787 data->maskedHbm = 0;
788 }
789#endif
790
791 delete data->mask;
792 QBitmap* newmaskcopy;
793 if ( newmask.mask() )
794 newmaskcopy = (QBitmap*)new QPixmap( tmp->copy( TRUE ) );
795 else
796 newmaskcopy = new QBitmap( newmask );
797#ifdef Q_WS_X11
798 newmaskcopy->x11SetScreen( x11Screen() );
799#endif
800 data->mask = newmaskcopy;
801}
802
803
804/*!
805 \fn bool QPixmap::selfMask() const
806
807 Returns TRUE if the pixmap's mask is identical to the pixmap
808 itself; otherwise returns FALSE.
809
810 \sa mask()
811*/
812
813#ifndef QT_NO_IMAGE_HEURISTIC_MASK
814/*!
815 Creates and returns a heuristic mask for this pixmap. It works by
816 selecting a color from one of the corners and then chipping away
817 pixels of that color, starting at all the edges.
818
819 The mask may not be perfect but it should be reasonable, so you
820 can do things such as the following:
821 \code
822 pm->setMask( pm->createHeuristicMask() );
823 \endcode
824
825 This function is slow because it involves transformation to a
826 QImage, non-trivial computations and a transformation back to a
827 QBitmap.
828
829 If \a clipTight is TRUE the mask is just large enough to cover the
830 pixels; otherwise, the mask is larger than the data pixels.
831
832 \sa QImage::createHeuristicMask()
833*/
834
835QBitmap QPixmap::createHeuristicMask( bool clipTight ) const
836{
837 QBitmap m;
838 m.convertFromImage( convertToImage().createHeuristicMask(clipTight) );
839 return m;
840}
841#endif
842#ifndef QT_NO_IMAGEIO
843/*!
844 Returns a string that specifies the image format of the file \a
845 fileName, or 0 if the file cannot be read or if the format cannot
846 be recognized.
847
848 The QImageIO documentation lists the supported image formats.
849
850 \sa load(), save()
851*/
852
853const char* QPixmap::imageFormat( const QString &fileName )
854{
855 return QImageIO::imageFormat(fileName);
856}
857
858/*!
859 Loads a pixmap from the file \a fileName at runtime. Returns TRUE
860 if successful; otherwise returns FALSE.
861
862 If \a format is specified, the loader attempts to read the pixmap
863 using the specified format. If \a format is not specified
864 (default), the loader reads a few bytes from the header to guess
865 the file's format.
866
867 See the convertFromImage() documentation for a description of the
868 \a conversion_flags argument.
869
870 The QImageIO documentation lists the supported image formats and
871 explains how to add extra formats.
872
873 \sa loadFromData(), save(), imageFormat(), QImage::load(),
874 QImageIO
875*/
876
877bool QPixmap::load( const QString &fileName, const char *format,
878 int conversion_flags )
879{
880 QImageIO io( fileName, format );
881 bool result = io.read();
882 if ( result ) {
883 detach(); // ###hanord: Why detach here, convertFromImage does it
884 result = convertFromImage( io.image(), conversion_flags );
885 }
886 return result;
887}
888
889/*!
890 \overload
891
892 Loads a pixmap from the file \a fileName at runtime.
893
894 If \a format is specified, the loader attempts to read the pixmap
895 using the specified format. If \a format is not specified
896 (default), the loader reads a few bytes from the header to guess
897 the file's format.
898
899 The \a mode is used to specify the color mode of the pixmap.
900
901 \sa QPixmap::ColorMode
902*/
903
904bool QPixmap::load( const QString &fileName, const char *format,
905 ColorMode mode )
906{
907 int conversion_flags = 0;
908 switch (mode) {
909 case Color:
910 conversion_flags |= ColorOnly;
911 break;
912 case Mono:
913 conversion_flags |= MonoOnly;
914 break;
915 default:
916 break;// Nothing.
917 }
918 return load( fileName, format, conversion_flags );
919}
920#endif //QT_NO_IMAGEIO
921
922/*!
923 \overload
924
925 Converts \a image and sets this pixmap using color mode \a mode.
926 Returns TRUE if successful; otherwise returns FALSE.
927
928 \sa QPixmap::ColorMode
929*/
930
931bool QPixmap::convertFromImage( const QImage &image, ColorMode mode )
932{
933 if ( image.isNull() ) {
934 // convert null image to null pixmap
935 *this = QPixmap();
936 return TRUE;
937 }
938
939 int conversion_flags = 0;
940 switch (mode) {
941 case Color:
942 conversion_flags |= ColorOnly;
943 break;
944 case Mono:
945 conversion_flags |= MonoOnly;
946 break;
947 default:
948 break;// Nothing.
949 }
950 return convertFromImage( image, conversion_flags );
951}
952
953#ifndef QT_NO_IMAGEIO
954/*!
955 Loads a pixmap from the binary data in \a buf (\a len bytes).
956 Returns TRUE if successful; otherwise returns FALSE.
957
958 If \a format is specified, the loader attempts to read the pixmap
959 using the specified format. If \a format is not specified
960 (default), the loader reads a few bytes from the header to guess
961 the file's format.
962
963 See the convertFromImage() documentation for a description of the
964 \a conversion_flags argument.
965
966 The QImageIO documentation lists the supported image formats and
967 explains how to add extra formats.
968
969 \sa load(), save(), imageFormat(), QImage::loadFromData(),
970 QImageIO
971*/
972
973bool QPixmap::loadFromData( const uchar *buf, uint len, const char *format,
974 int conversion_flags )
975{
976 QByteArray a;
977 a.setRawData( (char *)buf, len );
978 QBuffer b( a );
979 b.open( IO_ReadOnly );
980 QImageIO io( &b, format );
981 bool result = io.read();
982 b.close();
983 a.resetRawData( (char *)buf, len );
984 if ( result ) {
985 detach();
986 result = convertFromImage( io.image(), conversion_flags );
987 }
988 return result;
989}
990
991/*!
992 \overload
993
994 Loads a pixmap from the binary data in \a buf (\a len bytes) using
995 color mode \a mode. Returns TRUE if successful; otherwise returns
996 FALSE.
997
998 If \a format is specified, the loader attempts to read the pixmap
999 using the specified format. If \a format is not specified
1000 (default), the loader reads a few bytes from the header to guess
1001 the file's format.
1002
1003 \sa QPixmap::ColorMode
1004*/
1005
1006bool QPixmap::loadFromData( const uchar *buf, uint len, const char *format,
1007 ColorMode mode )
1008{
1009 int conversion_flags = 0;
1010 switch (mode) {
1011 case Color:
1012 conversion_flags |= ColorOnly;
1013 break;
1014 case Mono:
1015 conversion_flags |= MonoOnly;
1016 break;
1017 default:
1018 break;// Nothing.
1019 }
1020 return loadFromData( buf, len, format, conversion_flags );
1021}
1022
1023/*!
1024 \overload
1025*/
1026
1027bool QPixmap::loadFromData( const QByteArray &buf, const char *format,
1028 int conversion_flags )
1029{
1030 return loadFromData( (const uchar *)(buf.data()), buf.size(),
1031 format, conversion_flags );
1032}
1033
1034
1035/*!
1036 Saves the pixmap to the file \a fileName using the image file
1037 format \a format and a quality factor \a quality. \a quality must
1038 be in the range [0,100] or -1. Specify 0 to obtain small
1039 compressed files, 100 for large uncompressed files, and -1 to use
1040 the default settings. Returns TRUE if successful; otherwise
1041 returns FALSE.
1042
1043 \sa load(), loadFromData(), imageFormat(), QImage::save(),
1044 QImageIO
1045*/
1046
1047bool QPixmap::save( const QString &fileName, const char *format, int quality ) const
1048{
1049 if ( isNull() )
1050 return FALSE; // nothing to save
1051 QImageIO io( fileName, format );
1052 return doImageIO( &io, quality );
1053}
1054
1055/*!
1056 \overload
1057
1058 This function writes a QPixmap to the QIODevice, \a device. This
1059 can be used, for example, to save a pixmap directly into a
1060 QByteArray:
1061 \code
1062 QPixmap pixmap;
1063 QByteArray ba;
1064 QBuffer buffer( ba );
1065 buffer.open( IO_WriteOnly );
1066 pixmap.save( &buffer, "PNG" ); // writes pixmap into ba in PNG format
1067 \endcode
1068*/
1069
1070bool QPixmap::save( QIODevice* device, const char* format, int quality ) const
1071{
1072 if ( isNull() )
1073 return FALSE; // nothing to save
1074 QImageIO io( device, format );
1075 return doImageIO( &io, quality );
1076}
1077
1078/*! \internal
1079*/
1080
1081bool QPixmap::doImageIO( QImageIO* io, int quality ) const
1082{
1083 if ( !io )
1084 return FALSE;
1085 io->setImage( convertToImage() );
1086#if defined(QT_CHECK_RANGE)
1087 if ( quality > 100 || quality < -1 )
1088 qWarning( "QPixmap::save: quality out of range [-1,100]" );
1089#endif
1090 if ( quality >= 0 )
1091 io->setQuality( QMIN(quality,100) );
1092 return io->write();
1093}
1094
1095#endif //QT_NO_IMAGEIO
1096
1097/*!
1098 \fn int QPixmap::serialNumber() const
1099
1100 Returns a number that uniquely identifies the contents of this
1101 QPixmap object. This means that multiple QPixmap objects can have
1102 the same serial number as long as they refer to the same contents.
1103
1104 An example of where this is useful is for caching QPixmaps.
1105
1106 \sa QPixmapCache
1107*/
1108
1109
1110/*!
1111 Returns the default pixmap optimization setting.
1112
1113 \sa setDefaultOptimization(), setOptimization(), optimization()
1114*/
1115
1116QPixmap::Optimization QPixmap::defaultOptimization()
1117{
1118 return defOptim;
1119}
1120
1121/*!
1122 Sets the default pixmap optimization.
1123
1124 All \e new pixmaps that are created will use this default
1125 optimization. You may also set optimization for individual pixmaps
1126 using the setOptimization() function.
1127
1128 The initial default \a optimization setting is \c QPixmap::Normal.
1129
1130 \sa defaultOptimization(), setOptimization(), optimization()
1131*/
1132
1133void QPixmap::setDefaultOptimization( Optimization optimization )
1134{
1135 if ( optimization != DefaultOptim )
1136 defOptim = optimization;
1137}
1138
1139
1140// helper for next function.
1141static QPixmap grabChildWidgets( QWidget * w )
1142{
1143 QPixmap res( w->width(), w->height() );
1144 if ( res.isNull() && w->width() )
1145 return res;
1146 res.fill( w, QPoint( 0, 0 ) );
1147 QPaintDevice *oldRedirect = QPainter::redirect( w );
1148 QPainter::redirect( w, &res );
1149 bool dblbfr = QSharedDoubleBuffer::isDisabled();
1150 QSharedDoubleBuffer::setDisabled( TRUE );
1151 QPaintEvent e( w->rect(), FALSE );
1152 QApplication::sendEvent( w, &e );
1153 QSharedDoubleBuffer::setDisabled( dblbfr );
1154 QPainter::redirect( w, oldRedirect );
1155 if ( w->testWFlags( Qt::WRepaintNoErase ) )
1156 w->repaint( FALSE );
1157
1158 const QObjectList * children = w->children();
1159 if ( children ) {
1160 QPainter p( &res );
1161 QObjectListIt it( *children );
1162 QObject * child;
1163 while( (child=it.current()) != 0 ) {
1164 ++it;
1165 if ( child->isWidgetType() &&
1166 !((QWidget *)child)->isHidden() &&
1167 ((QWidget *)child)->geometry().intersects( w->rect() ) ) {
1168 // those conditions aren't quite right, it's possible
1169 // to have a grandchild completely outside its
1170 // grandparent, but partially inside its parent. no
1171 // point in optimizing for that.
1172
1173 // make sure to evaluate pos() first - who knows what
1174 // the paint event(s) inside grabChildWidgets() will do.
1175 QPoint childpos = ((QWidget *)child)->pos();
1176 QPixmap cpm = grabChildWidgets( (QWidget *)child );
1177 if ( cpm.isNull() ) {
1178 // Some child pixmap failed - abort and reset
1179 res.resize( 0, 0 );
1180 break;
1181 }
1182 p.drawPixmap( childpos, cpm);
1183 }
1184 }
1185 }
1186 return res;
1187}
1188
1189
1190/*!
1191 Creates a pixmap and paints \a widget in it.
1192
1193 If the \a widget has any children, then they are also painted in
1194 the appropriate positions.
1195
1196 If you specify \a x, \a y, \a w or \a h, only the rectangle you
1197 specify is painted. The defaults are 0, 0 (top-left corner) and
1198 -1,-1 (which means the entire widget).
1199
1200 (If \a w is negative, the function copies everything to the right
1201 border of the window. If \a h is negative, the function copies
1202 everything to the bottom of the window.)
1203
1204 If \a widget is 0, or if the rectangle defined by \a x, \a y, the
1205 modified \a w and the modified \a h does not overlap the \a
1206 {widget}->rect(), this function will return a null QPixmap.
1207
1208 This function actually asks \a widget to paint itself (and its
1209 children to paint themselves). QPixmap::grabWindow() grabs pixels
1210 off the screen, which is a bit faster and picks up \e exactly
1211 what's on-screen. This function works by calling paintEvent() with
1212 painter redirection turned on. If there are overlaying windows,
1213 grabWindow() will see them, but not this function.
1214
1215 If there is overlap, it returns a pixmap of the size you want,
1216 containing a rendering of \a widget. If the rectangle you ask for
1217 is a superset of \a widget, the areas outside \a widget are
1218 covered with the widget's background.
1219
1220 If an error occurs when trying to grab the widget, such as the
1221 size of the widget being too large to fit in memory, an isNull()
1222 pixmap is returned.
1223
1224 \sa grabWindow() QPainter::redirect() QWidget::paintEvent()
1225*/
1226
1227QPixmap QPixmap::grabWidget( QWidget * widget, int x, int y, int w, int h )
1228{
1229 QPixmap res;
1230 if ( !widget )
1231 return res;
1232
1233 if ( w < 0 )
1234 w = widget->width() - x;
1235 if ( h < 0 )
1236 h = widget->height() - y;
1237
1238 QRect wr( x, y, w, h );
1239 if ( wr == widget->rect() )
1240 return grabChildWidgets( widget );
1241 if ( !wr.intersects( widget->rect() ) )
1242 return res;
1243
1244 res.resize( w, h );
1245 if( res.isNull() )
1246 return res;
1247 res.fill( widget, QPoint( w,h ) );
1248 QPixmap tmp( grabChildWidgets( widget ) );
1249 if( tmp.isNull() )
1250 return tmp;
1251 ::bitBlt( &res, 0, 0, &tmp, x, y, w, h );
1252 return res;
1253}
1254
1255/*!
1256 Returns the actual matrix used for transforming a pixmap with \a w
1257 width and \a h height and matrix \a matrix.
1258
1259 When transforming a pixmap with xForm(), the transformation matrix
1260 is internally adjusted to compensate for unwanted translation,
1261 i.e. xForm() returns the smallest pixmap containing all
1262 transformed points of the original pixmap.
1263
1264 This function returns the modified matrix, which maps points
1265 correctly from the original pixmap into the new pixmap.
1266
1267 \sa xForm(), QWMatrix
1268*/
1269#ifndef QT_NO_PIXMAP_TRANSFORMATION
1270QWMatrix QPixmap::trueMatrix( const QWMatrix &matrix, int w, int h )
1271{
1272 const double dt = (double)0.;
1273 double x1,y1, x2,y2, x3,y3, x4,y4; // get corners
1274 double xx = (double)w;
1275 double yy = (double)h;
1276
1277 QWMatrix mat( matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), 0., 0. );
1278
1279 mat.map( dt, dt, &x1, &y1 );
1280 mat.map( xx, dt, &x2, &y2 );
1281 mat.map( xx, yy, &x3, &y3 );
1282 mat.map( dt, yy, &x4, &y4 );
1283
1284 double ymin = y1; // lowest y value
1285 if ( y2 < ymin ) ymin = y2;
1286 if ( y3 < ymin ) ymin = y3;
1287 if ( y4 < ymin ) ymin = y4;
1288 double xmin = x1; // lowest x value
1289 if ( x2 < xmin ) xmin = x2;
1290 if ( x3 < xmin ) xmin = x3;
1291 if ( x4 < xmin ) xmin = x4;
1292
1293 double ymax = y1; // lowest y value
1294 if ( y2 > ymax ) ymax = y2;
1295 if ( y3 > ymax ) ymax = y3;
1296 if ( y4 > ymax ) ymax = y4;
1297 double xmax = x1; // lowest x value
1298 if ( x2 > xmax ) xmax = x2;
1299 if ( x3 > xmax ) xmax = x3;
1300 if ( x4 > xmax ) xmax = x4;
1301
1302 if ( xmax-xmin > 1.0 )
1303 xmin -= xmin/(xmax-xmin);
1304 if ( ymax-ymin > 1.0 )
1305 ymin -= ymin/(ymax-ymin);
1306
1307 mat.setMatrix( matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), -xmin, -ymin );
1308 return mat;
1309}
1310#endif // QT_NO_WMATRIX
1311
1312
1313
1314
1315
1316/*****************************************************************************
1317 QPixmap stream functions
1318 *****************************************************************************/
1319#if !defined(QT_NO_DATASTREAM) && !defined(QT_NO_IMAGEIO)
1320/*!
1321 \relates QPixmap
1322
1323 Writes the pixmap \a pixmap to the stream \a s as a PNG image.
1324
1325 Note that writing the stream to a file will not produce a valid image file.
1326
1327 \sa QPixmap::save()
1328 \link datastreamformat.html Format of the QDataStream operators \endlink
1329*/
1330
1331QDataStream &operator<<( QDataStream &s, const QPixmap &pixmap )
1332{
1333 s << pixmap.convertToImage();
1334 return s;
1335}
1336
1337/*!
1338 \relates QPixmap
1339
1340 Reads a pixmap from the stream \a s into the pixmap \a pixmap.
1341
1342 \sa QPixmap::load()
1343 \link datastreamformat.html Format of the QDataStream operators \endlink
1344*/
1345
1346QDataStream &operator>>( QDataStream &s, QPixmap &pixmap )
1347{
1348 QImage img;
1349 s >> img;
1350 pixmap.convertFromImage( img );
1351 return s;
1352}
1353
1354#endif //QT_NO_DATASTREAM
1355
1356
1357
1358
1359/*****************************************************************************
1360 QPixmap (and QImage) helper functions
1361 *****************************************************************************/
1362/*
1363 This internal function contains the common (i.e. platform independent) code
1364 to do a transformation of pixel data. It is used by QPixmap::xForm() and by
1365 QImage::xForm().
1366
1367 \a trueMat is the true transformation matrix (see QPixmap::trueMatrix()) and
1368 \a xoffset is an offset to the matrix.
1369
1370 \a msbfirst specifies for 1bpp images, if the MSB or LSB comes first and \a
1371 depth specifies the colordepth of the data.
1372
1373 \a dptr is a pointer to the destination data, \a dbpl specifies the bits per
1374 line for the destination data, \a p_inc is the offset that we advance for
1375 every scanline and \a dHeight is the height of the destination image.
1376
1377 \a sprt is the pointer to the source data, \a sbpl specifies the bits per
1378 line of the source data, \a sWidth and \a sHeight are the width and height of
1379 the source data.
1380*/
1381#ifndef QT_NO_PIXMAP_TRANSFORMATION
1382#undef IWX_MSB
1383#define IWX_MSB(b) if ( trigx < maxws && trigy < maxhs ) { \
1384 if ( *(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \
1385 (1 << (7-((trigx>>16)&7))) ) \
1386 *dptr |= b; \
1387 } \
1388 trigx += m11; \
1389 trigy += m12;
1390 // END OF MACRO
1391#undef IWX_LSB
1392#define IWX_LSB(b) if ( trigx < maxws && trigy < maxhs ) { \
1393 if ( *(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \
1394 (1 << ((trigx>>16)&7)) ) \
1395 *dptr |= b; \
1396 } \
1397 trigx += m11; \
1398 trigy += m12;
1399 // END OF MACRO
1400#undef IWX_PIX
1401#define IWX_PIX(b) if ( trigx < maxws && trigy < maxhs ) { \
1402 if ( (*(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \
1403 (1 << (7-((trigx>>16)&7)))) == 0 ) \
1404 *dptr &= ~b; \
1405 } \
1406 trigx += m11; \
1407 trigy += m12;
1408 // END OF MACRO
1409bool qt_xForm_helper( const QWMatrix &trueMat, int xoffset,
1410 int type, int depth,
1411 uchar *dptr, int dbpl, int p_inc, int dHeight,
1412 uchar *sptr, int sbpl, int sWidth, int sHeight
1413 )
1414{
1415 int m11 = (int)(trueMat.m11()*65536.0);
1416 int m12 = (int)(trueMat.m12()*65536.0);
1417 int m21 = (int)(trueMat.m21()*65536.0);
1418 int m22 = (int)(trueMat.m22()*65536.0);
1419 int dx = (int)(trueMat.dx() *65536.0);
1420 int dy = (int)(trueMat.dy() *65536.0);
1421
1422 int m21ydx = dx + (xoffset<<16) + QABS(m11)/2;
1423 int m22ydy = dy + QABS(m22)/2;
1424 uint trigx;
1425 uint trigy;
1426 uint maxws = sWidth<<16;
1427 uint maxhs = sHeight<<16;
1428
1429 for ( int y=0; y<dHeight; y++ ) { // for each target scanline
1430 trigx = m21ydx;
1431 trigy = m22ydy;
1432 uchar *maxp = dptr + dbpl;
1433 if ( depth != 1 ) {
1434 switch ( depth ) {
1435 case 8: // 8 bpp transform
1436 while ( dptr < maxp ) {
1437 if ( trigx < maxws && trigy < maxhs )
1438 *dptr = *(sptr+sbpl*(trigy>>16)+(trigx>>16));
1439 trigx += m11;
1440 trigy += m12;
1441 dptr++;
1442 }
1443 break;
1444
1445 case 16: // 16 bpp transform
1446 while ( dptr < maxp ) {
1447 if ( trigx < maxws && trigy < maxhs )
1448 *((ushort*)dptr) = *((ushort *)(sptr+sbpl*(trigy>>16) +
1449 ((trigx>>16)<<1)));
1450 trigx += m11;
1451 trigy += m12;
1452 dptr++;
1453 dptr++;
1454 }
1455 break;
1456
1457 case 24: { // 24 bpp transform
1458 uchar *p2;
1459 while ( dptr < maxp ) {
1460 if ( trigx < maxws && trigy < maxhs ) {
1461 p2 = sptr+sbpl*(trigy>>16) + ((trigx>>16)*3);
1462 dptr[0] = p2[0];
1463 dptr[1] = p2[1];
1464 dptr[2] = p2[2];
1465 }
1466 trigx += m11;
1467 trigy += m12;
1468 dptr += 3;
1469 }
1470 }
1471 break;
1472
1473 case 32: // 32 bpp transform
1474 while ( dptr < maxp ) {
1475 if ( trigx < maxws && trigy < maxhs )
1476 *((uint*)dptr) = *((uint *)(sptr+sbpl*(trigy>>16) +
1477 ((trigx>>16)<<2)));
1478 trigx += m11;
1479 trigy += m12;
1480 dptr += 4;
1481 }
1482 break;
1483
1484 default: {
1485 return FALSE;
1486 }
1487 }
1488 } else {
1489 switch ( type ) {
1490 case QT_XFORM_TYPE_MSBFIRST:
1491 while ( dptr < maxp ) {
1492 IWX_MSB(128);
1493 IWX_MSB(64);
1494 IWX_MSB(32);
1495 IWX_MSB(16);
1496 IWX_MSB(8);
1497 IWX_MSB(4);
1498 IWX_MSB(2);
1499 IWX_MSB(1);
1500 dptr++;
1501 }
1502 break;
1503 case QT_XFORM_TYPE_LSBFIRST:
1504 while ( dptr < maxp ) {
1505 IWX_LSB(1);
1506 IWX_LSB(2);
1507 IWX_LSB(4);
1508 IWX_LSB(8);
1509 IWX_LSB(16);
1510 IWX_LSB(32);
1511 IWX_LSB(64);
1512 IWX_LSB(128);
1513 dptr++;
1514 }
1515 break;
1516# if defined(Q_WS_WIN)
1517 case QT_XFORM_TYPE_WINDOWSPIXMAP:
1518 while ( dptr < maxp ) {
1519 IWX_PIX(128);
1520 IWX_PIX(64);
1521 IWX_PIX(32);
1522 IWX_PIX(16);
1523 IWX_PIX(8);
1524 IWX_PIX(4);
1525 IWX_PIX(2);
1526 IWX_PIX(1);
1527 dptr++;
1528 }
1529 break;
1530# endif
1531 }
1532 }
1533 m21ydx += m21;
1534 m22ydy += m22;
1535 dptr += p_inc;
1536 }
1537 return TRUE;
1538}
1539#undef IWX_MSB
1540#undef IWX_LSB
1541#undef IWX_PIX
1542#endif // QT_NO_PIXMAP_TRANSFORMATION
Note: See TracBrowser for help on using the repository browser.