1QPixmap(3qt)                                                      QPixmap(3qt)
2
3
4

NAME

6       QPixmap - Off-screen, pixel-based paint device
7

SYNOPSIS

9       #include <qpixmap.h>
10
11       Inherits QPaintDevice and Qt.
12
13       Inherited by QBitmap and QCanvasPixmap.
14
15   Public Members
16       enum ColorMode { Auto, Color, Mono }
17       enum Optimization { DefaultOptim, NoOptim, MemoryOptim = NoOptim,
18           NormalOptim, BestOptim }
19       QPixmap ()
20       QPixmap ( const QImage & image )
21       QPixmap ( int w, int h, int depth = -1, Optimization optimization =
22           DefaultOptim )
23       QPixmap ( const QSize & size, int depth = -1, Optimization optimization
24           = DefaultOptim )
25       QPixmap ( const QString & fileName, const char * format = 0, ColorMode
26           mode = Auto )
27       QPixmap ( const QString & fileName, const char * format, int
28           conversion_flags )
29       QPixmap ( const char * xpm[] )
30       QPixmap ( const QByteArray & img_data )
31       QPixmap ( const QPixmap & pixmap )
32       ~QPixmap ()
33       QPixmap & operator= ( const QPixmap & pixmap )
34       QPixmap & operator= ( const QImage & image )
35       bool isNull () const
36       int width () const
37       int height () const
38       QSize size () const
39       QRect rect () const
40       int depth () const
41       void fill ( const QColor & fillColor = Qt::white )
42       void fill ( const QWidget * widget, int xofs, int yofs )
43       void fill ( const QWidget * widget, const QPoint & ofs )
44       void resize ( int w, int h )
45       void resize ( const QSize & size )
46       const QBitmap * mask () const
47       void setMask ( const QBitmap & newmask )
48       bool selfMask () const
49       bool hasAlpha () const
50       bool hasAlphaChannel () const
51       QBitmap createHeuristicMask ( bool clipTight = TRUE ) const
52       QPixmap xForm ( const QWMatrix & matrix ) const
53       QImage convertToImage () const
54       bool convertFromImage ( const QImage & image, ColorMode mode = Auto )
55       bool convertFromImage ( const QImage & img, int conversion_flags )
56       bool load ( const QString & fileName, const char * format = 0,
57           ColorMode mode = Auto )
58       bool load ( const QString & fileName, const char * format, int
59           conversion_flags )
60       bool loadFromData ( const uchar * buf, uint len, const char * format =
61           0, ColorMode mode = Auto )
62       bool loadFromData ( const uchar * buf, uint len, const char * format,
63           int conversion_flags )
64       bool loadFromData ( const QByteArray & buf, const char * format = 0,
65           int conversion_flags = 0 )
66       bool save ( const QString & fileName, const char * format, int quality
67           = -1 ) const
68       bool save ( QIODevice * device, const char * format, int quality = -1 )
69           const
70       int serialNumber () const
71       Optimization optimization () const
72       void setOptimization ( Optimization optimization )
73       virtual void detach ()
74       bool isQBitmap () const
75
76   Static Public Members
77       int defaultDepth ()
78       QPixmap fromMimeSource ( const QString & abs_name )
79       QPixmap grabWindow ( WId window, int x = 0, int y = 0, int w = -1, int
80           h = -1 )
81       QPixmap grabWidget ( QWidget * widget, int x = 0, int y = 0, int w =
82           -1, int h = -1 )
83       QWMatrix trueMatrix ( const QWMatrix & matrix, int w, int h )
84       const char * imageFormat ( const QString & fileName )
85       Optimization defaultOptimization ()
86       void setDefaultOptimization ( Optimization optimization )
87
88   Protected Members
89       QPixmap ( int w, int h, const uchar * bits, bool isXbitmap )
90       virtual int metric ( int m ) const
91
93       QDataStream & operator<< ( QDataStream & s, const QPixmap & pixmap )
94       QDataStream & operator>> ( QDataStream & s, QPixmap & pixmap )
95       void copyBlt ( QPixmap * dst, int dx, int dy, const QPixmap * src, int
96           sx, int sy, int sw, int sh )
97

DESCRIPTION

99       The QPixmap class is an off-screen, pixel-based paint device.
100
101       QPixmap is one of the two classes Qt provides for dealing with images;
102       the other is QImage. QPixmap is designed and optimized for drawing;
103       QImage is designed and optimized for I/O and for direct pixel
104       access/manipulation. There are (slow) functions to convert between
105       QImage and QPixmap: convertToImage() and convertFromImage().
106
107       One common use of the QPixmap class is to enable smooth updating of
108       widgets. Whenever something complex needs to be drawn, you can use a
109       pixmap to obtain flicker-free drawing, like this:
110
111       <ol type=1>
112
113       1      Create a pixmap with the same size as the widget.
114
115       2      Fill the pixmap with the widget background color.
116
117       3      Paint the pixmap.
118
119       4      bitBlt() the pixmap contents onto the widget.
120
121       Pixel data in a pixmap is internal and is managed by the underlying
122       window system. Pixels can be accessed only through QPainter functions,
123       through bitBlt(), and by converting the QPixmap to a QImage.
124
125       You can easily display a QPixmap on the screen using
126       QLabel::setPixmap(). For example, all the QButton subclasses support
127       pixmap use.
128
129       The QPixmap class uses copy-on-write, so it is practical to pass
130       QPixmap objects by value.
131
132       You can retrieve the width(), height(), depth() and size() of a pixmap.
133       The enclosing rectangle is given by rect(). Pixmaps can be filled with
134       fill() and resized with resize(). You can create and set a mask with
135       createHeuristicMask() and setMask(). Use selfMask() to see if the
136       pixmap is identical to its mask.
137
138       In addition to loading a pixmap from file using load() you can also
139       loadFromData(). You can control optimization with setOptimization() and
140       obtain a transformed version of the pixmap using xForm()
141
142       Note regarding Windows 95 and 98: on Windows 9x the system crashes if
143       you create more than about 1000 pixmaps, independent of the size of the
144       pixmaps or installed RAM. Windows NT-systems (including 2000, XP and
145       following versions) do not have the same limitation, but depending on
146       the graphics equipment the system will fail to allocate pixmap objects
147       at some point (due to system running out of GDI resources).
148
149       Qt tries to work around the resource limitation. If you set the pixmap
150       optimization to QPixmap::MemoryOptim and the width of your pixmap is
151       less than or equal to 128 pixels, Qt stores the pixmap in a way that is
152       very memory-efficient when there are many pixmaps.
153
154       If your application uses dozens or hundreds of pixmaps (for example on
155       tool bar buttons and in popup menus), and you plan to run it on Windows
156       95 or Windows 98, we recommend using code like this:
157
158               QPixmap::setDefaultOptimization( QPixmap::MemoryOptim );
159               while ( ... ) {
160                   // load tool bar pixmaps etc.
161                   QPixmap *pixmap = new QPixmap(fileName);
162               }
163               QPixmap::setDefaultOptimization( QPixmap::NormalOptim );
164
165       In general it is recommended to make as much use of QPixmap's implicit
166       sharing and the QPixmapCache as possible.
167
168       See also QBitmap, QImage, QImageIO, Shared Classes, Graphics Classes,
169       Image Processing Classes, and Implicitly and Explicitly Shared Classes.
170
171   Member Type Documentation

QPixmap::ColorMode

173       This enum type defines the color modes that exist for converting QImage
174       objects to QPixmap.
175
176       QPixmap::Auto - Select Color or Mono on a case-by-case basis.
177
178       QPixmap::Color - Always create colored pixmaps.
179
180       QPixmap::Mono - Always create bitmaps.
181

QPixmap::Optimization

183       QPixmap has the choice of optimizing for speed or memory in a few
184       places; the best choice varies from pixmap to pixmap but can generally
185       be derived heuristically. This enum type defines a number of
186       optimization modes that you can set for any pixmap to tweak the
187       speed/memory tradeoffs:
188
189       QPixmap::DefaultOptim - Whatever QPixmap::defaultOptimization()
190       returns. A pixmap with this optimization will have whatever the current
191       default optimization is. If the default optimization is changed using
192       setDefaultOptimization(), then this will not effect any pixmaps that
193       have already been created.
194
195       QPixmap::NoOptim - No optimization (currently the same as MemoryOptim).
196
197       QPixmap::MemoryOptim - Optimize for minimal memory use on Windows 9x
198       and X11 systems.
199
200       QPixmap::NormalOptim - Optimize for typical usage. Often uses more
201       memory than MemoryOptim, and is often faster.
202
203       QPixmap::BestOptim - Optimize for pixmaps that are drawn very often and
204       where performance is critical. Generally uses more memory than
205       NormalOptim and may provide a little more speed.
206
207       We recommend using DefaultOptim.
208

MEMBER FUNCTION DOCUMENTATION

QPixmap::QPixmap ()

211       Constructs a null pixmap.
212
213       See also isNull().
214

QPixmap::QPixmap ( const QImage & image )

216       Constructs a pixmap from the QImage image.
217
218       See also convertFromImage().
219

QPixmap::QPixmap ( int w, int h, int depth = -1, Optimization optimization =

221       DefaultOptim )
222       Constructs a pixmap with w width, h height and depth bits per pixel.
223       The pixmap is optimized in accordance with the optimization value.
224
225       The contents of the pixmap is uninitialized.
226
227       The depth can be either 1 (monochrome) or the depth of the current
228       video mode. If depth is negative, then the hardware depth of the
229       current video mode will be used.
230
231       If either w or h is zero, a null pixmap is constructed.
232
233       See also isNull() and QPixmap::Optimization.
234

QPixmap::QPixmap ( const QSize & size, int depth = -1, Optimization

236       optimization = DefaultOptim )
237       This is an overloaded member function, provided for convenience. It
238       behaves essentially like the above function.
239
240       Constructs a pixmap of size size, depth bits per pixel, optimized in
241       accordance with the optimization value.
242

QPixmap::QPixmap ( const QString & fileName, const char * format = 0,

244       ColorMode mode = Auto )
245       Constructs a pixmap from the file fileName. If the file does not exist
246       or is of an unknown format, the pixmap becomes a null pixmap.
247
248       The fileName, format and mode parameters are passed on to load(). This
249       means that the data in fileName is not compiled into the binary. If
250       fileName contains a relative path (e.g. the filename only) the relevant
251       file must be found relative to the runtime working directory.
252
253       See also QPixmap::ColorMode, isNull(), load(), loadFromData(), save(),
254       and imageFormat().
255

QPixmap::QPixmap ( const QString & fileName, const char * format, int

257       conversion_flags )
258       Constructs a pixmap from the file fileName. If the file does not exist
259       or is of an unknown format, the pixmap becomes a null pixmap.
260
261       The fileName, format and conversion_flags parameters are passed on to
262       load(). This means that the data in fileName is not compiled into the
263       binary. If fileName contains a relative path (e.g. the filename only)
264       the relevant file must be found relative to the runtime working
265       directory.
266
267       If the image needs to be modified to fit in a lower-resolution result
268       (e.g. converting from 32-bit to 8-bit), use the conversion_flags to
269       specify how you'd prefer this to happen.
270
271       See also Qt::ImageConversionFlags, isNull(), load(), loadFromData(),
272       save(), and imageFormat().
273

QPixmap::QPixmap ( const char * xpm[] )

275       Constructs a pixmap from xpm, which must be a valid XPM image.
276
277       Errors are silently ignored.
278
279       Note that it's possible to squeeze the XPM variable a little bit by
280       using an unusual declaration:
281
282               static const char * const start_xpm[]={
283                   "16 15 8 1",
284                   "a c #cec6bd",
285               ....
286
287       The extra const makes the entire definition read-only, which is
288       slightly more efficient (for example, when the code is in a shared
289       library) and ROMable when the application is to be stored in ROM.
290
291       In order to use that sort of declaration you must cast the variable
292       back to const char ** when you create the QPixmap.
293

QPixmap::QPixmap ( const QByteArray & img_data )

295       Constructs a pixmaps by loading from img_data. The data can be in any
296       image format supported by Qt.
297
298       See also loadFromData().
299

QPixmap::QPixmap ( const QPixmap & pixmap )

301       Constructs a pixmap that is a copy of pixmap.
302

QPixmap::QPixmap ( int w, int h, const uchar * bits, bool isXbitmap )

304       [protected]
305       Constructs a monochrome pixmap, with width w and height h, that is
306       initialized with the data in bits. The isXbitmap indicates whether the
307       data is an X bitmap and defaults to FALSE. This constructor is
308       protected and used by the QBitmap class.
309

QPixmap::~QPixmap ()

311       Destroys the pixmap.
312

bool QPixmap::convertFromImage ( const QImage & img, int conversion_flags )

314       Converts image img and sets this pixmap. Returns TRUE if successful;
315       otherwise returns FALSE.
316
317       The conversion_flags argument is a bitwise-OR of the
318       Qt::ImageConversionFlags. Passing 0 for conversion_flags sets all the
319       default options.
320
321       Note that even though a QPixmap with depth 1 behaves much like a
322       QBitmap, isQBitmap() returns FALSE.
323
324       If a pixmap with depth 1 is painted with color0 and color1 and
325       converted to an image, the pixels painted with color0 will produce
326       pixel index 0 in the image and those painted with color1 will produce
327       pixel index 1.
328
329       See also convertToImage(), isQBitmap(), QImage::convertDepth(),
330       defaultDepth(), and QImage::hasAlphaBuffer().
331
332       Examples:
333

bool QPixmap::convertFromImage ( const QImage & image, ColorMode mode = Auto )

335
336       This is an overloaded member function, provided for convenience. It
337       behaves essentially like the above function.
338
339       Converts image and sets this pixmap using color mode mode. Returns TRUE
340       if successful; otherwise returns FALSE.
341
342       See also QPixmap::ColorMode.
343

QImage QPixmap::convertToImage () const

345       Converts the pixmap to a QImage. Returns a null image if it fails.
346
347       If the pixmap has 1-bit depth, the returned image will also be 1 bit
348       deep. If the pixmap has 2- to 8-bit depth, the returned image has 8-bit
349       depth. If the pixmap has greater than 8-bit depth, the returned image
350       has 32-bit depth.
351
352       Note that for the moment, alpha masks on monochrome images are ignored.
353
354       See also convertFromImage().
355
356       Example: qmag/qmag.cpp.
357

QBitmap QPixmap::createHeuristicMask ( bool clipTight = TRUE ) const

359       Creates and returns a heuristic mask for this pixmap. It works by
360       selecting a color from one of the corners and then chipping away pixels
361       of that color, starting at all the edges.
362
363       The mask may not be perfect but it should be reasonable, so you can do
364       things such as the following:
365
366           pm->setMask( pm->createHeuristicMask() );
367
368       This function is slow because it involves transformation to a QImage,
369       non-trivial computations and a transformation back to a QBitmap.
370
371       If clipTight is TRUE the mask is just large enough to cover the pixels;
372       otherwise, the mask is larger than the data pixels.
373
374       See also QImage::createHeuristicMask().
375

int QPixmap::defaultDepth () [static]

377       Returns the default pixmap depth, i.e. the depth a pixmap gets if -1 is
378       specified.
379
380       See also depth().
381

Optimization QPixmap::defaultOptimization () [static]

383       Returns the default pixmap optimization setting.
384
385       See also setDefaultOptimization(), setOptimization(), and
386       optimization().
387

int QPixmap::depth () const

389       Returns the depth of the pixmap.
390
391       The pixmap depth is also called bits per pixel (bpp) or bit planes of a
392       pixmap. A null pixmap has depth 0.
393
394       See also defaultDepth(), isNull(), and QImage::convertDepth().
395

void QPixmap::detach () [virtual]

397       This is a special-purpose function that detaches the pixmap from shared
398       pixmap data.
399
400       A pixmap is automatically detached by Qt whenever its contents is about
401       to change. This is done in all QPixmap member functions that modify the
402       pixmap (fill(), resize(), convertFromImage(), load(), etc.), in
403       bitBlt() for the destination pixmap and in QPainter::begin() on a
404       pixmap.
405
406       It is possible to modify a pixmap without letting Qt know. You can
407       first obtain the system-dependent handle() and then call system-
408       specific functions (for instance, BitBlt under Windows) that modify the
409       pixmap contents. In such cases, you can call detach() to cut the pixmap
410       loose from other pixmaps that share data with this one.
411
412       detach() returns immediately if there is just a single reference or if
413       the pixmap has not been initialized yet.
414

void QPixmap::fill ( const QColor & fillColor = Qt::white )

416       Fills the pixmap with the color fillColor.
417
418       Examples:
419

void QPixmap::fill ( const QWidget * widget, int xofs, int yofs )

421       This is an overloaded member function, provided for convenience. It
422       behaves essentially like the above function.
423
424       Fills the pixmap with the widget's background color or pixmap. If the
425       background is empty, nothing is done. xofs, yofs is an offset in the
426       widget.
427

void QPixmap::fill ( const QWidget * widget, const QPoint & ofs )

429       This is an overloaded member function, provided for convenience. It
430       behaves essentially like the above function.
431
432       Fills the pixmap with the widget's background color or pixmap. If the
433       background is empty, nothing is done.
434
435       The ofs point is an offset in the widget.
436
437       The point ofs is a point in the widget's coordinate system. The
438       pixmap's top-left pixel will be mapped to the point ofs in the widget.
439       This is significant if the widget has a background pixmap; otherwise
440       the pixmap will simply be filled with the background color of the
441       widget.
442
443       Example:
444
445           void CuteWidget::paintEvent( QPaintEvent *e )
446           {
447               QRect ur = e->rect();            // rectangle to update
448               QPixmap pix( ur.size() );        // Pixmap for double-buffering
449               pix.fill( this, ur.topLeft() );  // fill with widget background
450               QPainter p( &pix );
451               p.translate( -ur.x(), -ur.y() ); // use widget coordinate system
452                                                // when drawing on pixmap
453               //    ... draw on pixmap ...
454               p.end();
455               bitBlt( this, ur.topLeft(), &pix );
456           }
457

QPixmap QPixmap::fromMimeSource ( const QString & abs_name ) [static]

459       Convenience function. Gets the data associated with the absolute name
460       abs_name from the default mime source factory and decodes it to a
461       pixmap.
462
463       See also QMimeSourceFactory, QImage::fromMimeSource(), and
464       QImageDrag::decode().
465
466       Example: textedit/textedit.cpp.
467

QPixmap QPixmap::grabWidget ( QWidget * widget, int x = 0, int y = 0, int w =

469       -1, int h = -1 ) [static]
470       Creates a pixmap and paints widget in it.
471
472       If the widget has any children, then they are also painted in the
473       appropriate positions.
474
475       If you specify x, y, w or h, only the rectangle you specify is painted.
476       The defaults are 0, 0 (top-left corner) and -1,-1 (which means the
477       entire widget).
478
479       (If w is negative, the function copies everything to the right border
480       of the window. If h is negative, the function copies everything to the
481       bottom of the window.)
482
483       If widget is 0, or if the rectangle defined by x, y, the modified w and
484       the modified h does not overlap the widget->rect(), this function will
485       return a null QPixmap.
486
487       This function actually asks widget to paint itself (and its children to
488       paint themselves). QPixmap::grabWindow() grabs pixels off the screen,
489       which is a bit faster and picks up exactly what's on-screen. This
490       function works by calling paintEvent() with painter redirection turned
491       on. If there are overlaying windows, grabWindow() will see them, but
492       not this function.
493
494       If there is overlap, it returns a pixmap of the size you want,
495       containing a rendering of widget. If the rectangle you ask for is a
496       superset of widget, the areas outside widget are covered with the
497       widget's background.
498
499       If an error occurs when trying to grab the widget, such as the size of
500       the widget being too large to fit in memory, an isNull() pixmap is
501       returned.
502
503       See also grabWindow(), QPainter::redirect(), and QWidget::paintEvent().
504

QPixmap QPixmap::grabWindow ( WId window, int x = 0, int y = 0, int w = -1,

506       int h = -1 ) [static]
507       Grabs the contents of the window window and makes a pixmap out of it.
508       Returns the pixmap.
509
510       The arguments (x, y) specify the offset in the window, whereas (w, h)
511       specify the width and height of the area to be copied.
512
513       If w is negative, the function copies everything to the right border of
514       the window. If h is negative, the function copies everything to the
515       bottom of the window.
516
517       Note that grabWindow() grabs pixels from the screen, not from the
518       window. If there is another window partially or entirely over the one
519       you grab, you get pixels from the overlying window, too.
520
521       Note also that the mouse cursor is generally not grabbed.
522
523       The reason we use a window identifier and not a QWidget is to enable
524       grabbing of windows that are not part of the application, window system
525       frames, and so on.
526
527       Warning: Grabbing an area outside the screen is not safe in general.
528       This depends on the underlying window system.
529
530       Warning: X11 only: If window is not the same depth as the root window
531       and another window partially or entirely obscures the one you grab, you
532       will not get pixels from the overlying window. The contests of the
533       obscured areas in the pixmap are undefined and uninitialized.
534
535       See also grabWidget().
536
537       Example: qmag/qmag.cpp.
538

bool QPixmap::hasAlpha () const

540       Returns TRUE this pixmap has an alpha channel or a mask.
541
542       See also hasAlphaChannel() and mask().
543

bool QPixmap::hasAlphaChannel () const

545       Returns TRUE if the pixmap has an alpha channel; otherwise it returns
546       FALSE.
547
548       NOTE: If the pixmap has a mask but not alpha channel, this function
549       returns FALSE.
550
551       See also hasAlpha() and mask().
552

int QPixmap::height () const

554       Returns the height of the pixmap.
555
556       See also width(), size(), and rect().
557
558       Examples:
559

const char * QPixmap::imageFormat ( const QString & fileName ) [static]

561       Returns a string that specifies the image format of the file fileName,
562       or 0 if the file cannot be read or if the format cannot be recognized.
563
564       The QImageIO documentation lists the supported image formats.
565
566       See also load() and save().
567

bool QPixmap::isNull () const

569       Returns TRUE if this is a null pixmap; otherwise returns FALSE.
570
571       A null pixmap has zero width, zero height and no contents. You cannot
572       draw in a null pixmap or bitBlt() anything to it.
573
574       Resizing an existing pixmap to (0, 0) makes a pixmap into a null
575       pixmap.
576
577       See also resize().
578
579       Examples:
580

bool QPixmap::isQBitmap () const

582       Returns TRUE if this is a QBitmap; otherwise returns FALSE.
583

bool QPixmap::load ( const QString & fileName, const char * format, int

585       conversion_flags )
586       Loads a pixmap from the file fileName at runtime. Returns TRUE if
587       successful; otherwise returns FALSE.
588
589       If format is specified, the loader attempts to read the pixmap using
590       the specified format. If format is not specified (default), the loader
591       reads a few bytes from the header to guess the file's format.
592
593       See the convertFromImage() documentation for a description of the
594       conversion_flags argument.
595
596       The QImageIO documentation lists the supported image formats and
597       explains how to add extra formats.
598
599       See also loadFromData(), save(), imageFormat(), QImage::load(), and
600       QImageIO.
601
602       Examples:
603

bool QPixmap::load ( const QString & fileName, const char * format = 0,

605       ColorMode mode = Auto )
606       This is an overloaded member function, provided for convenience. It
607       behaves essentially like the above function.
608
609       Loads a pixmap from the file fileName at runtime.
610
611       If format is specified, the loader attempts to read the pixmap using
612       the specified format. If format is not specified (default), the loader
613       reads a few bytes from the header to guess the file's format.
614
615       The mode is used to specify the color mode of the pixmap.
616
617       See also QPixmap::ColorMode.
618

bool QPixmap::loadFromData ( const uchar * buf, uint len, const char * format,

620       int conversion_flags )
621       Loads a pixmap from the binary data in buf (len bytes). Returns TRUE if
622       successful; otherwise returns FALSE.
623
624       If format is specified, the loader attempts to read the pixmap using
625       the specified format. If format is not specified (default), the loader
626       reads a few bytes from the header to guess the file's format.
627
628       See the convertFromImage() documentation for a description of the
629       conversion_flags argument.
630
631       The QImageIO documentation lists the supported image formats and
632       explains how to add extra formats.
633
634       See also load(), save(), imageFormat(), QImage::loadFromData(), and
635       QImageIO.
636

bool QPixmap::loadFromData ( const uchar * buf, uint len, const char * format

638       = 0, ColorMode mode = Auto )
639       This is an overloaded member function, provided for convenience. It
640       behaves essentially like the above function.
641
642       Loads a pixmap from the binary data in buf (len bytes) using color mode
643       mode. Returns TRUE if successful; otherwise returns FALSE.
644
645       If format is specified, the loader attempts to read the pixmap using
646       the specified format. If format is not specified (default), the loader
647       reads a few bytes from the header to guess the file's format.
648
649       See also QPixmap::ColorMode.
650

bool QPixmap::loadFromData ( const QByteArray & buf, const char * format = 0,

652       int conversion_flags = 0 )
653       This is an overloaded member function, provided for convenience. It
654       behaves essentially like the above function.
655

const QBitmap * QPixmap::mask () const

657       Returns the mask bitmap, or 0 if no mask has been set.
658
659       See also setMask(), QBitmap, and hasAlpha().
660

int QPixmap::metric ( int m ) const [virtual protected]

662       Internal implementation of the virtual QPaintDevice::metric() function.
663
664       Use the QPaintDeviceMetrics class instead.
665
666       m is the metric to get.
667

QPixmap & QPixmap::operator= ( const QPixmap & pixmap )

669       Assigns the pixmap pixmap to this pixmap and returns a reference to
670       this pixmap.
671

QPixmap & QPixmap::operator= ( const QImage & image )

673       This is an overloaded member function, provided for convenience. It
674       behaves essentially like the above function.
675
676       Converts the image image to a pixmap that is assigned to this pixmap.
677       Returns a reference to the pixmap.
678
679       See also convertFromImage().
680

Optimization QPixmap::optimization () const

682       Returns the optimization setting for this pixmap.
683
684       The default optimization setting is QPixmap::NormalOptim. You can
685       change this setting in two ways:
686
687       Call setDefaultOptimization() to set the default optimization for all
688       new pixmaps.
689
690       Call setOptimization() to set the optimization for individual pixmaps.
691
692       See also setOptimization(), setDefaultOptimization(), and
693       defaultOptimization().
694

QRect QPixmap::rect () const

696       Returns the enclosing rectangle (0,0,width(),height()) of the pixmap.
697
698       See also width(), height(), and size().
699

void QPixmap::resize ( int w, int h )

701       Resizes the pixmap to w width and h height. If either w or h is 0, the
702       pixmap becomes a null pixmap.
703
704       If both w and h are greater than 0, a valid pixmap is created. New
705       pixels will be uninitialized (random) if the pixmap is expanded.
706
707       Examples:
708

void QPixmap::resize ( const QSize & size )

710       This is an overloaded member function, provided for convenience. It
711       behaves essentially like the above function.
712
713       Resizes the pixmap to size size.
714

bool QPixmap::save ( const QString & fileName, const char * format, int

716       quality = -1 ) const
717       Saves the pixmap to the file fileName using the image file format
718       format and a quality factor quality. quality must be in the range
719       [0,100] or -1. Specify 0 to obtain small compressed files, 100 for
720       large uncompressed files, and -1 to use the default settings. Returns
721       TRUE if successful; otherwise returns FALSE.
722
723       See also load(), loadFromData(), imageFormat(), QImage::save(), and
724       QImageIO.
725
726       Example: qmag/qmag.cpp.
727

bool QPixmap::save ( QIODevice * device, const char * format, int quality = -1

729       ) const
730       This is an overloaded member function, provided for convenience. It
731       behaves essentially like the above function.
732
733       This function writes a QPixmap to the QIODevice, device. This can be
734       used, for example, to save a pixmap directly into a QByteArray:
735
736           QPixmap pixmap;
737           QByteArray ba;
738           QBuffer buffer( ba );
739           buffer.open( IO_WriteOnly );
740           pixmap.save( &buffer, "PNG" ); // writes pixmap into ba in PNG format
741

bool QPixmap::selfMask () const

743       Returns TRUE if the pixmap's mask is identical to the pixmap itself;
744       otherwise returns FALSE.
745
746       See also mask().
747

int QPixmap::serialNumber () const

749       Returns a number that uniquely identifies the contents of this QPixmap
750       object. This means that multiple QPixmap objects can have the same
751       serial number as long as they refer to the same contents.
752
753       An example of where this is useful is for caching QPixmaps.
754
755       See also QPixmapCache.
756

void QPixmap::setDefaultOptimization ( Optimization optimization ) [static]

758       Sets the default pixmap optimization.
759
760       All new pixmaps that are created will use this default optimization.
761       You may also set optimization for individual pixmaps using the
762       setOptimization() function.
763
764       The initial default optimization setting is QPixmap::Normal.
765
766       See also defaultOptimization(), setOptimization(), and optimization().
767

void QPixmap::setMask ( const QBitmap & newmask )

769       Sets a mask bitmap.
770
771       The newmask bitmap defines the clip mask for this pixmap. Every pixel
772       in newmask corresponds to a pixel in this pixmap. Pixel value 1 means
773       opaque and pixel value 0 means transparent. The mask must have the same
774       size as this pixmap.
775
776       Warning: Setting the mask on a pixmap will cause any alpha channel data
777       to be cleared. For example:
778
779               QPixmap alpha( "image-with-alpha.png" );
780               QPixmap alphacopy = alpha;
781               alphacopy.setMask( *alphacopy.mask() );
782       Now, alpha and alphacopy are visually different.
783
784       Setting a null mask resets the mask.
785
786       See also mask(), createHeuristicMask(), and QBitmap.
787

void QPixmap::setOptimization ( Optimization optimization )

789       Sets pixmap drawing optimization for this pixmap.
790
791       The optimization setting affects pixmap operations, in particular
792       drawing of transparent pixmaps (bitBlt() a pixmap with a mask set) and
793       pixmap transformations (the xForm() function).
794
795       Pixmap optimization involves keeping intermediate results in a cache
796       buffer and using the cache to speed up bitBlt() and xForm(). The cost
797       is more memory consumption, up to twice as much as an unoptimized
798       pixmap.
799
800       Use the setDefaultOptimization() to change the default optimization for
801       all new pixmaps.
802
803       See also optimization(), setDefaultOptimization(), and
804       defaultOptimization().
805
806       Example: desktop/desktop.cpp.
807

QSize QPixmap::size () const

809       Returns the size of the pixmap.
810
811       See also width(), height(), and rect().
812
813       Example: movies/main.cpp.
814

QWMatrix QPixmap::trueMatrix ( const QWMatrix & matrix, int w, int h )

816       [static]
817       Returns the actual matrix used for transforming a pixmap with w width
818       and h height and matrix matrix.
819
820       When transforming a pixmap with xForm(), the transformation matrix is
821       internally adjusted to compensate for unwanted translation, i.e.
822       xForm() returns the smallest pixmap containing all transformed points
823       of the original pixmap.
824
825       This function returns the modified matrix, which maps points correctly
826       from the original pixmap into the new pixmap.
827
828       See also xForm() and QWMatrix.
829

int QPixmap::width () const

831       Returns the width of the pixmap.
832
833       See also height(), size(), and rect().
834
835       Examples:
836

QPixmap QPixmap::xForm ( const QWMatrix & matrix ) const

838       Returns a copy of the pixmap that is transformed using matrix. The
839       original pixmap is not changed.
840
841       The transformation matrix is internally adjusted to compensate for
842       unwanted translation, i.e. xForm() returns the smallest image that
843       contains all the transformed points of the original image.
844
845       This function is slow because it involves transformation to a QImage,
846       non-trivial computations and a transformation back to a QPixmap.
847
848       See also trueMatrix(), QWMatrix, QPainter::setWorldMatrix(), and
849       QImage::xForm().
850
851       Examples:
852

void copyBlt ( QPixmap * dst, int dx, int dy, const QPixmap * src, int sx, int

855       sy, int sw, int sh )
856       Copies a block of pixels from src to dst. The alpha channel and mask
857       data (if any) is also copied from src. NOTE: src is not alpha blended
858       or masked when copied to dst. Use bitBlt() or QPainter::drawPixmap() to
859       perform alpha blending or masked drawing.
860
861       sx, sy is the top-left pixel in src (0, 0 by default), dx, dy is the
862       top-left position in dst and sw, \sh is the size of the copied block
863       (all of src by default).
864
865       If src, dst, sw or sh is 0 (zero), copyBlt() does nothing. If sw or sh
866       is negative, copyBlt() copies starting at sx (and respectively, sy) and
867       ending at the right edge (and respectively, the bottom edge) of src.
868
869       copyBlt() does nothing if src and dst have different depths.
870

QDataStream & operator<< ( QDataStream & s, const QPixmap & pixmap )

872       Writes the pixmap pixmap to the stream s as a PNG image.
873
874       Note that writing the stream to a file will not produce a valid image
875       file.
876
877       See also QPixmap::save() and Format of the QDataStream operators.
878

QDataStream & operator>> ( QDataStream & s, QPixmap & pixmap )

880       Reads a pixmap from the stream s into the pixmap pixmap.
881
882       See also QPixmap::load() and Format of the QDataStream operators.
883
884

SEE ALSO

886       http://doc.trolltech.com/qpixmap.html
887       http://www.trolltech.com/faq/tech.html
888
890       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
891       license file included in the distribution for a complete license
892       statement.
893

AUTHOR

895       Generated automatically from the source code.
896

BUGS

898       If you find a bug in Qt, please report it as described in
899       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
900       help you. Thank you.
901
902       The definitive Qt documentation is provided in HTML format; it is
903       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
904       web browser. This man page is provided as a convenience for those users
905       who prefer man pages, although this format is not officially supported
906       by Trolltech.
907
908       If you find errors in this manual page, please report them to qt-
909       bugs@trolltech.com.  Please include the name of the manual page
910       (qpixmap.3qt) and the Qt version (3.3.8).
911
912
913
914Trolltech AS                    2 February 2007                   QPixmap(3qt)
Impressum