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

Last change on this file since 10 was 8, checked in by dmik, 20 years ago

Transferred Qt for OS/2 version 3.3.1-rc5 sources from the CVS

  • Property svn:keywords set to Id
File size: 42.5 KB
Line 
1/****************************************************************************
2** $Id: qpixmap.cpp 8 2005-11-16 19:36:46Z 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 return;
749 }
750
751 detach();
752 data->selfmask = FALSE;
753
754 if ( newmask.width() != width() || newmask.height() != height() ) {
755#if defined(QT_CHECK_RANGE)
756 qWarning( "QPixmap::setMask: The pixmap and the mask must have "
757 "the same size" );
758#endif
759 return;
760 }
761#if defined(Q_WS_MAC) || (defined(Q_WS_X11) && !defined(QT_NO_XFTFREETYPE))
762 // when setting the mask, we get rid of the alpha channel completely
763 delete data->alphapm;
764 data->alphapm = 0;
765#endif // Q_WS_X11 && !QT_NO_XFTFREETYPE
766
767#if defined (Q_WS_PM)
768 if ( data->maskedHbm ) {
769 GpiDeleteBitmap( data->maskedHbm );
770 data->maskedHbm = 0;
771 }
772#endif
773
774 delete data->mask;
775 QBitmap* newmaskcopy;
776 if ( newmask.mask() )
777 newmaskcopy = (QBitmap*)new QPixmap( tmp->copy( TRUE ) );
778 else
779 newmaskcopy = new QBitmap( newmask );
780#ifdef Q_WS_X11
781 newmaskcopy->x11SetScreen( x11Screen() );
782#endif
783 data->mask = newmaskcopy;
784}
785
786
787/*!
788 \fn bool QPixmap::selfMask() const
789
790 Returns TRUE if the pixmap's mask is identical to the pixmap
791 itself; otherwise returns FALSE.
792
793 \sa mask()
794*/
795
796#ifndef QT_NO_IMAGE_HEURISTIC_MASK
797/*!
798 Creates and returns a heuristic mask for this pixmap. It works by
799 selecting a color from one of the corners and then chipping away
800 pixels of that color, starting at all the edges.
801
802 The mask may not be perfect but it should be reasonable, so you
803 can do things such as the following:
804 \code
805 pm->setMask( pm->createHeuristicMask() );
806 \endcode
807
808 This function is slow because it involves transformation to a
809 QImage, non-trivial computations and a transformation back to a
810 QBitmap.
811
812 If \a clipTight is TRUE the mask is just large enough to cover the
813 pixels; otherwise, the mask is larger than the data pixels.
814
815 \sa QImage::createHeuristicMask()
816*/
817
818QBitmap QPixmap::createHeuristicMask( bool clipTight ) const
819{
820 QBitmap m;
821 m.convertFromImage( convertToImage().createHeuristicMask(clipTight) );
822 return m;
823}
824#endif
825#ifndef QT_NO_IMAGEIO
826/*!
827 Returns a string that specifies the image format of the file \a
828 fileName, or 0 if the file cannot be read or if the format cannot
829 be recognized.
830
831 The QImageIO documentation lists the supported image formats.
832
833 \sa load(), save()
834*/
835
836const char* QPixmap::imageFormat( const QString &fileName )
837{
838 return QImageIO::imageFormat(fileName);
839}
840
841/*!
842 Loads a pixmap from the file \a fileName at runtime. Returns TRUE
843 if successful; otherwise returns FALSE.
844
845 If \a format is specified, the loader attempts to read the pixmap
846 using the specified format. If \a format is not specified
847 (default), the loader reads a few bytes from the header to guess
848 the file's format.
849
850 See the convertFromImage() documentation for a description of the
851 \a conversion_flags argument.
852
853 The QImageIO documentation lists the supported image formats and
854 explains how to add extra formats.
855
856 \sa loadFromData(), save(), imageFormat(), QImage::load(),
857 QImageIO
858*/
859
860bool QPixmap::load( const QString &fileName, const char *format,
861 int conversion_flags )
862{
863 QImageIO io( fileName, format );
864 bool result = io.read();
865 if ( result ) {
866 detach(); // ###hanord: Why detach here, convertFromImage does it
867 result = convertFromImage( io.image(), conversion_flags );
868 }
869 return result;
870}
871
872/*!
873 \overload
874
875 Loads a pixmap from the file \a fileName at runtime.
876
877 If \a format is specified, the loader attempts to read the pixmap
878 using the specified format. If \a format is not specified
879 (default), the loader reads a few bytes from the header to guess
880 the file's format.
881
882 The \a mode is used to specify the color mode of the pixmap.
883
884 \sa QPixmap::ColorMode
885*/
886
887bool QPixmap::load( const QString &fileName, const char *format,
888 ColorMode mode )
889{
890 int conversion_flags = 0;
891 switch (mode) {
892 case Color:
893 conversion_flags |= ColorOnly;
894 break;
895 case Mono:
896 conversion_flags |= MonoOnly;
897 break;
898 default:
899 break;// Nothing.
900 }
901 return load( fileName, format, conversion_flags );
902}
903#endif //QT_NO_IMAGEIO
904
905/*!
906 \overload
907
908 Converts \a image and sets this pixmap using color mode \a mode.
909 Returns TRUE if successful; otherwise returns FALSE.
910
911 \sa QPixmap::ColorMode
912*/
913
914bool QPixmap::convertFromImage( const QImage &image, ColorMode mode )
915{
916 if ( image.isNull() ) {
917 // convert null image to null pixmap
918 *this = QPixmap();
919 return TRUE;
920 }
921
922 int conversion_flags = 0;
923 switch (mode) {
924 case Color:
925 conversion_flags |= ColorOnly;
926 break;
927 case Mono:
928 conversion_flags |= MonoOnly;
929 break;
930 default:
931 break;// Nothing.
932 }
933 return convertFromImage( image, conversion_flags );
934}
935
936#ifndef QT_NO_IMAGEIO
937/*!
938 Loads a pixmap from the binary data in \a buf (\a len bytes).
939 Returns TRUE if successful; otherwise returns FALSE.
940
941 If \a format is specified, the loader attempts to read the pixmap
942 using the specified format. If \a format is not specified
943 (default), the loader reads a few bytes from the header to guess
944 the file's format.
945
946 See the convertFromImage() documentation for a description of the
947 \a conversion_flags argument.
948
949 The QImageIO documentation lists the supported image formats and
950 explains how to add extra formats.
951
952 \sa load(), save(), imageFormat(), QImage::loadFromData(),
953 QImageIO
954*/
955
956bool QPixmap::loadFromData( const uchar *buf, uint len, const char *format,
957 int conversion_flags )
958{
959 QByteArray a;
960 a.setRawData( (char *)buf, len );
961 QBuffer b( a );
962 b.open( IO_ReadOnly );
963 QImageIO io( &b, format );
964 bool result = io.read();
965 b.close();
966 a.resetRawData( (char *)buf, len );
967 if ( result ) {
968 detach();
969 result = convertFromImage( io.image(), conversion_flags );
970 }
971 return result;
972}
973
974/*!
975 \overload
976
977 Loads a pixmap from the binary data in \a buf (\a len bytes) using
978 color mode \a mode. Returns TRUE if successful; otherwise returns
979 FALSE.
980
981 If \a format is specified, the loader attempts to read the pixmap
982 using the specified format. If \a format is not specified
983 (default), the loader reads a few bytes from the header to guess
984 the file's format.
985
986 \sa QPixmap::ColorMode
987*/
988
989bool QPixmap::loadFromData( const uchar *buf, uint len, const char *format,
990 ColorMode mode )
991{
992 int conversion_flags = 0;
993 switch (mode) {
994 case Color:
995 conversion_flags |= ColorOnly;
996 break;
997 case Mono:
998 conversion_flags |= MonoOnly;
999 break;
1000 default:
1001 break;// Nothing.
1002 }
1003 return loadFromData( buf, len, format, conversion_flags );
1004}
1005
1006/*!
1007 \overload
1008*/
1009
1010bool QPixmap::loadFromData( const QByteArray &buf, const char *format,
1011 int conversion_flags )
1012{
1013 return loadFromData( (const uchar *)(buf.data()), buf.size(),
1014 format, conversion_flags );
1015}
1016
1017
1018/*!
1019 Saves the pixmap to the file \a fileName using the image file
1020 format \a format and a quality factor \a quality. \a quality must
1021 be in the range [0,100] or -1. Specify 0 to obtain small
1022 compressed files, 100 for large uncompressed files, and -1 to use
1023 the default settings. Returns TRUE if successful; otherwise
1024 returns FALSE.
1025
1026 \sa load(), loadFromData(), imageFormat(), QImage::save(),
1027 QImageIO
1028*/
1029
1030bool QPixmap::save( const QString &fileName, const char *format, int quality ) const
1031{
1032 if ( isNull() )
1033 return FALSE; // nothing to save
1034 QImageIO io( fileName, format );
1035 return doImageIO( &io, quality );
1036}
1037
1038/*!
1039 \overload
1040
1041 This function writes a QPixmap to the QIODevice, \a device. This
1042 can be used, for example, to save a pixmap directly into a
1043 QByteArray:
1044 \code
1045 QPixmap pixmap;
1046 QByteArray ba;
1047 QBuffer buffer( ba );
1048 buffer.open( IO_WriteOnly );
1049 pixmap.save( &buffer, "PNG" ); // writes pixmap into ba in PNG format
1050 \endcode
1051*/
1052
1053bool QPixmap::save( QIODevice* device, const char* format, int quality ) const
1054{
1055 if ( isNull() )
1056 return FALSE; // nothing to save
1057 QImageIO io( device, format );
1058 return doImageIO( &io, quality );
1059}
1060
1061/*! \internal
1062*/
1063
1064bool QPixmap::doImageIO( QImageIO* io, int quality ) const
1065{
1066 if ( !io )
1067 return FALSE;
1068 io->setImage( convertToImage() );
1069#if defined(QT_CHECK_RANGE)
1070 if ( quality > 100 || quality < -1 )
1071 qWarning( "QPixmap::save: quality out of range [-1,100]" );
1072#endif
1073 if ( quality >= 0 )
1074 io->setQuality( QMIN(quality,100) );
1075 return io->write();
1076}
1077
1078#endif //QT_NO_IMAGEIO
1079
1080/*!
1081 \fn int QPixmap::serialNumber() const
1082
1083 Returns a number that uniquely identifies the contents of this
1084 QPixmap object. This means that multiple QPixmap objects can have
1085 the same serial number as long as they refer to the same contents.
1086
1087 An example of where this is useful is for caching QPixmaps.
1088
1089 \sa QPixmapCache
1090*/
1091
1092
1093/*!
1094 Returns the default pixmap optimization setting.
1095
1096 \sa setDefaultOptimization(), setOptimization(), optimization()
1097*/
1098
1099QPixmap::Optimization QPixmap::defaultOptimization()
1100{
1101 return defOptim;
1102}
1103
1104/*!
1105 Sets the default pixmap optimization.
1106
1107 All \e new pixmaps that are created will use this default
1108 optimization. You may also set optimization for individual pixmaps
1109 using the setOptimization() function.
1110
1111 The initial default \a optimization setting is \c QPixmap::Normal.
1112
1113 \sa defaultOptimization(), setOptimization(), optimization()
1114*/
1115
1116void QPixmap::setDefaultOptimization( Optimization optimization )
1117{
1118 if ( optimization != DefaultOptim )
1119 defOptim = optimization;
1120}
1121
1122
1123// helper for next function.
1124static QPixmap grabChildWidgets( QWidget * w )
1125{
1126 QPixmap res( w->width(), w->height() );
1127 if ( res.isNull() && w->width() )
1128 return res;
1129 res.fill( w, QPoint( 0, 0 ) );
1130 QPaintDevice *oldRedirect = QPainter::redirect( w );
1131 QPainter::redirect( w, &res );
1132 bool dblbfr = QSharedDoubleBuffer::isDisabled();
1133 QSharedDoubleBuffer::setDisabled( TRUE );
1134 QPaintEvent e( w->rect(), FALSE );
1135 QApplication::sendEvent( w, &e );
1136 QSharedDoubleBuffer::setDisabled( dblbfr );
1137 QPainter::redirect( w, oldRedirect );
1138 if ( w->testWFlags( Qt::WRepaintNoErase ) )
1139 w->repaint( FALSE );
1140
1141 const QObjectList * children = w->children();
1142 if ( children ) {
1143 QPainter p( &res );
1144 QObjectListIt it( *children );
1145 QObject * child;
1146 while( (child=it.current()) != 0 ) {
1147 ++it;
1148 if ( child->isWidgetType() &&
1149 !((QWidget *)child)->isHidden() &&
1150 ((QWidget *)child)->geometry().intersects( w->rect() ) ) {
1151 // those conditions aren't quite right, it's possible
1152 // to have a grandchild completely outside its
1153 // grandparent, but partially inside its parent. no
1154 // point in optimizing for that.
1155
1156 // make sure to evaluate pos() first - who knows what
1157 // the paint event(s) inside grabChildWidgets() will do.
1158 QPoint childpos = ((QWidget *)child)->pos();
1159 QPixmap cpm = grabChildWidgets( (QWidget *)child );
1160 if ( cpm.isNull() ) {
1161 // Some child pixmap failed - abort and reset
1162 res.resize( 0, 0 );
1163 break;
1164 }
1165 p.drawPixmap( childpos, cpm);
1166 }
1167 }
1168 }
1169 return res;
1170}
1171
1172
1173/*!
1174 Creates a pixmap and paints \a widget in it.
1175
1176 If the \a widget has any children, then they are also painted in
1177 the appropriate positions.
1178
1179 If you specify \a x, \a y, \a w or \a h, only the rectangle you
1180 specify is painted. The defaults are 0, 0 (top-left corner) and
1181 -1,-1 (which means the entire widget).
1182
1183 (If \a w is negative, the function copies everything to the right
1184 border of the window. If \a h is negative, the function copies
1185 everything to the bottom of the window.)
1186
1187 If \a widget is 0, or if the rectangle defined by \a x, \a y, the
1188 modified \a w and the modified \a h does not overlap the \a
1189 {widget}->rect(), this function will return a null QPixmap.
1190
1191 This function actually asks \a widget to paint itself (and its
1192 children to paint themselves). QPixmap::grabWindow() grabs pixels
1193 off the screen, which is a bit faster and picks up \e exactly
1194 what's on-screen. This function works by calling paintEvent() with
1195 painter redirection turned on. If there are overlaying windows,
1196 grabWindow() will see them, but not this function.
1197
1198 If there is overlap, it returns a pixmap of the size you want,
1199 containing a rendering of \a widget. If the rectangle you ask for
1200 is a superset of \a widget, the areas outside \a widget are
1201 covered with the widget's background.
1202
1203 If an error occurs when trying to grab the widget, such as the
1204 size of the widget being too large to fit in memory, an isNull()
1205 pixmap is returned.
1206
1207 \sa grabWindow() QPainter::redirect() QWidget::paintEvent()
1208*/
1209
1210QPixmap QPixmap::grabWidget( QWidget * widget, int x, int y, int w, int h )
1211{
1212 QPixmap res;
1213 if ( !widget )
1214 return res;
1215
1216 if ( w < 0 )
1217 w = widget->width() - x;
1218 if ( h < 0 )
1219 h = widget->height() - y;
1220
1221 QRect wr( x, y, w, h );
1222 if ( wr == widget->rect() )
1223 return grabChildWidgets( widget );
1224 if ( !wr.intersects( widget->rect() ) )
1225 return res;
1226
1227 res.resize( w, h );
1228 if( res.isNull() )
1229 return res;
1230 res.fill( widget, QPoint( w,h ) );
1231 QPixmap tmp( grabChildWidgets( widget ) );
1232 if( tmp.isNull() )
1233 return tmp;
1234 ::bitBlt( &res, 0, 0, &tmp, x, y, w, h );
1235 return res;
1236}
1237
1238/*!
1239 Returns the actual matrix used for transforming a pixmap with \a w
1240 width and \a h height and matrix \a matrix.
1241
1242 When transforming a pixmap with xForm(), the transformation matrix
1243 is internally adjusted to compensate for unwanted translation,
1244 i.e. xForm() returns the smallest pixmap containing all
1245 transformed points of the original pixmap.
1246
1247 This function returns the modified matrix, which maps points
1248 correctly from the original pixmap into the new pixmap.
1249
1250 \sa xForm(), QWMatrix
1251*/
1252#ifndef QT_NO_PIXMAP_TRANSFORMATION
1253QWMatrix QPixmap::trueMatrix( const QWMatrix &matrix, int w, int h )
1254{
1255 const double dt = (double)0.;
1256 double x1,y1, x2,y2, x3,y3, x4,y4; // get corners
1257 double xx = (double)w;
1258 double yy = (double)h;
1259
1260 QWMatrix mat( matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), 0., 0. );
1261
1262 mat.map( dt, dt, &x1, &y1 );
1263 mat.map( xx, dt, &x2, &y2 );
1264 mat.map( xx, yy, &x3, &y3 );
1265 mat.map( dt, yy, &x4, &y4 );
1266
1267 double ymin = y1; // lowest y value
1268 if ( y2 < ymin ) ymin = y2;
1269 if ( y3 < ymin ) ymin = y3;
1270 if ( y4 < ymin ) ymin = y4;
1271 double xmin = x1; // lowest x value
1272 if ( x2 < xmin ) xmin = x2;
1273 if ( x3 < xmin ) xmin = x3;
1274 if ( x4 < xmin ) xmin = x4;
1275
1276 double ymax = y1; // lowest y value
1277 if ( y2 > ymax ) ymax = y2;
1278 if ( y3 > ymax ) ymax = y3;
1279 if ( y4 > ymax ) ymax = y4;
1280 double xmax = x1; // lowest x value
1281 if ( x2 > xmax ) xmax = x2;
1282 if ( x3 > xmax ) xmax = x3;
1283 if ( x4 > xmax ) xmax = x4;
1284
1285 if ( xmax-xmin > 1.0 )
1286 xmin -= xmin/(xmax-xmin);
1287 if ( ymax-ymin > 1.0 )
1288 ymin -= ymin/(ymax-ymin);
1289
1290 mat.setMatrix( matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), -xmin, -ymin );
1291 return mat;
1292}
1293#endif // QT_NO_WMATRIX
1294
1295
1296
1297
1298
1299/*****************************************************************************
1300 QPixmap stream functions
1301 *****************************************************************************/
1302#if !defined(QT_NO_DATASTREAM) && !defined(QT_NO_IMAGEIO)
1303/*!
1304 \relates QPixmap
1305
1306 Writes the pixmap \a pixmap to the stream \a s as a PNG image.
1307
1308 Note that writing the stream to a file will not produce a valid image file.
1309
1310 \sa QPixmap::save()
1311 \link datastreamformat.html Format of the QDataStream operators \endlink
1312*/
1313
1314QDataStream &operator<<( QDataStream &s, const QPixmap &pixmap )
1315{
1316 s << pixmap.convertToImage();
1317 return s;
1318}
1319
1320/*!
1321 \relates QPixmap
1322
1323 Reads a pixmap from the stream \a s into the pixmap \a pixmap.
1324
1325 \sa QPixmap::load()
1326 \link datastreamformat.html Format of the QDataStream operators \endlink
1327*/
1328
1329QDataStream &operator>>( QDataStream &s, QPixmap &pixmap )
1330{
1331 QImage img;
1332 s >> img;
1333 pixmap.convertFromImage( img );
1334 return s;
1335}
1336
1337#endif //QT_NO_DATASTREAM
1338
1339
1340
1341
1342/*****************************************************************************
1343 QPixmap (and QImage) helper functions
1344 *****************************************************************************/
1345/*
1346 This internal function contains the common (i.e. platform independent) code
1347 to do a transformation of pixel data. It is used by QPixmap::xForm() and by
1348 QImage::xForm().
1349
1350 \a trueMat is the true transformation matrix (see QPixmap::trueMatrix()) and
1351 \a xoffset is an offset to the matrix.
1352
1353 \a msbfirst specifies for 1bpp images, if the MSB or LSB comes first and \a
1354 depth specifies the colordepth of the data.
1355
1356 \a dptr is a pointer to the destination data, \a dbpl specifies the bits per
1357 line for the destination data, \a p_inc is the offset that we advance for
1358 every scanline and \a dHeight is the height of the destination image.
1359
1360 \a sprt is the pointer to the source data, \a sbpl specifies the bits per
1361 line of the source data, \a sWidth and \a sHeight are the width and height of
1362 the source data.
1363*/
1364#ifndef QT_NO_PIXMAP_TRANSFORMATION
1365#undef IWX_MSB
1366#define IWX_MSB(b) if ( trigx < maxws && trigy < maxhs ) { \
1367 if ( *(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \
1368 (1 << (7-((trigx>>16)&7))) ) \
1369 *dptr |= b; \
1370 } \
1371 trigx += m11; \
1372 trigy += m12;
1373 // END OF MACRO
1374#undef IWX_LSB
1375#define IWX_LSB(b) if ( trigx < maxws && trigy < maxhs ) { \
1376 if ( *(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \
1377 (1 << ((trigx>>16)&7)) ) \
1378 *dptr |= b; \
1379 } \
1380 trigx += m11; \
1381 trigy += m12;
1382 // END OF MACRO
1383#undef IWX_PIX
1384#define IWX_PIX(b) if ( trigx < maxws && trigy < maxhs ) { \
1385 if ( (*(sptr+sbpl*(trigy>>16)+(trigx>>19)) & \
1386 (1 << (7-((trigx>>16)&7)))) == 0 ) \
1387 *dptr &= ~b; \
1388 } \
1389 trigx += m11; \
1390 trigy += m12;
1391 // END OF MACRO
1392bool qt_xForm_helper( const QWMatrix &trueMat, int xoffset,
1393 int type, int depth,
1394 uchar *dptr, int dbpl, int p_inc, int dHeight,
1395 uchar *sptr, int sbpl, int sWidth, int sHeight
1396 )
1397{
1398 int m11 = (int)(trueMat.m11()*65536.0);
1399 int m12 = (int)(trueMat.m12()*65536.0);
1400 int m21 = (int)(trueMat.m21()*65536.0);
1401 int m22 = (int)(trueMat.m22()*65536.0);
1402 int dx = (int)(trueMat.dx() *65536.0);
1403 int dy = (int)(trueMat.dy() *65536.0);
1404
1405 int m21ydx = dx + (xoffset<<16) + QABS(m11)/2;
1406 int m22ydy = dy + QABS(m22)/2;
1407 uint trigx;
1408 uint trigy;
1409 uint maxws = sWidth<<16;
1410 uint maxhs = sHeight<<16;
1411
1412 for ( int y=0; y<dHeight; y++ ) { // for each target scanline
1413 trigx = m21ydx;
1414 trigy = m22ydy;
1415 uchar *maxp = dptr + dbpl;
1416 if ( depth != 1 ) {
1417 switch ( depth ) {
1418 case 8: // 8 bpp transform
1419 while ( dptr < maxp ) {
1420 if ( trigx < maxws && trigy < maxhs )
1421 *dptr = *(sptr+sbpl*(trigy>>16)+(trigx>>16));
1422 trigx += m11;
1423 trigy += m12;
1424 dptr++;
1425 }
1426 break;
1427
1428 case 16: // 16 bpp transform
1429 while ( dptr < maxp ) {
1430 if ( trigx < maxws && trigy < maxhs )
1431 *((ushort*)dptr) = *((ushort *)(sptr+sbpl*(trigy>>16) +
1432 ((trigx>>16)<<1)));
1433 trigx += m11;
1434 trigy += m12;
1435 dptr++;
1436 dptr++;
1437 }
1438 break;
1439
1440 case 24: { // 24 bpp transform
1441 uchar *p2;
1442 while ( dptr < maxp ) {
1443 if ( trigx < maxws && trigy < maxhs ) {
1444 p2 = sptr+sbpl*(trigy>>16) + ((trigx>>16)*3);
1445 dptr[0] = p2[0];
1446 dptr[1] = p2[1];
1447 dptr[2] = p2[2];
1448 }
1449 trigx += m11;
1450 trigy += m12;
1451 dptr += 3;
1452 }
1453 }
1454 break;
1455
1456 case 32: // 32 bpp transform
1457 while ( dptr < maxp ) {
1458 if ( trigx < maxws && trigy < maxhs )
1459 *((uint*)dptr) = *((uint *)(sptr+sbpl*(trigy>>16) +
1460 ((trigx>>16)<<2)));
1461 trigx += m11;
1462 trigy += m12;
1463 dptr += 4;
1464 }
1465 break;
1466
1467 default: {
1468 return FALSE;
1469 }
1470 }
1471 } else {
1472 switch ( type ) {
1473 case QT_XFORM_TYPE_MSBFIRST:
1474 while ( dptr < maxp ) {
1475 IWX_MSB(128);
1476 IWX_MSB(64);
1477 IWX_MSB(32);
1478 IWX_MSB(16);
1479 IWX_MSB(8);
1480 IWX_MSB(4);
1481 IWX_MSB(2);
1482 IWX_MSB(1);
1483 dptr++;
1484 }
1485 break;
1486 case QT_XFORM_TYPE_LSBFIRST:
1487 while ( dptr < maxp ) {
1488 IWX_LSB(1);
1489 IWX_LSB(2);
1490 IWX_LSB(4);
1491 IWX_LSB(8);
1492 IWX_LSB(16);
1493 IWX_LSB(32);
1494 IWX_LSB(64);
1495 IWX_LSB(128);
1496 dptr++;
1497 }
1498 break;
1499# if defined(Q_WS_WIN)
1500 case QT_XFORM_TYPE_WINDOWSPIXMAP:
1501 while ( dptr < maxp ) {
1502 IWX_PIX(128);
1503 IWX_PIX(64);
1504 IWX_PIX(32);
1505 IWX_PIX(16);
1506 IWX_PIX(8);
1507 IWX_PIX(4);
1508 IWX_PIX(2);
1509 IWX_PIX(1);
1510 dptr++;
1511 }
1512 break;
1513# endif
1514 }
1515 }
1516 m21ydx += m21;
1517 m22ydy += m22;
1518 dptr += p_inc;
1519 }
1520 return TRUE;
1521}
1522#undef IWX_MSB
1523#undef IWX_LSB
1524#undef IWX_PIX
1525#endif // QT_NO_PIXMAP_TRANSFORMATION
Note: See TracBrowser for help on using the repository browser.