/usr/share/qt3/doc/html/qpixmap.html is in qt3-doc 3:3.3.8-b-8ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qpixmap.cpp:53 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QPixmap Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPixmap Class Reference</h1>
<p>The QPixmap class is an off-screen, pixel-based paint device.
<a href="#details">More...</a>
<p><tt>#include <<a href="qpixmap-h.html">qpixmap.h</a>></tt>
<p>Inherits <a href="qpaintdevice.html">QPaintDevice</a> and <a href="qt.html">Qt</a>.
<p>Inherited by <a href="qbitmap.html">QBitmap</a> and <a href="qcanvaspixmap.html">QCanvasPixmap</a>.
<p><a href="qpixmap-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn>enum <a href="#ColorMode-enum"><b>ColorMode</b></a> { Auto, Color, Mono }</li>
<li class=fn>enum <a href="#Optimization-enum"><b>Optimization</b></a> { DefaultOptim, NoOptim, MemoryOptim = NoOptim, NormalOptim, BestOptim }</li>
<li class=fn><a href="#QPixmap"><b>QPixmap</b></a> ()</li>
<li class=fn><a href="#QPixmap-2"><b>QPixmap</b></a> ( const QImage & image )</li>
<li class=fn><a href="#QPixmap-3"><b>QPixmap</b></a> ( int w, int h, int depth = -1, Optimization optimization = DefaultOptim )</li>
<li class=fn><a href="#QPixmap-4"><b>QPixmap</b></a> ( const QSize & size, int depth = -1, Optimization optimization = DefaultOptim )</li>
<li class=fn><a href="#QPixmap-5"><b>QPixmap</b></a> ( const QString & fileName, const char * format = 0, ColorMode mode = Auto )</li>
<li class=fn><a href="#QPixmap-6"><b>QPixmap</b></a> ( const QString & fileName, const char * format, int conversion_flags )</li>
<li class=fn><a href="#QPixmap-7"><b>QPixmap</b></a> ( const char * xpm[] )</li>
<li class=fn><a href="#QPixmap-8"><b>QPixmap</b></a> ( const QByteArray & img_data )</li>
<li class=fn><a href="#QPixmap-9"><b>QPixmap</b></a> ( const QPixmap & pixmap )</li>
<li class=fn><a href="#~QPixmap"><b>~QPixmap</b></a> ()</li>
<li class=fn>QPixmap & <a href="#operator-eq"><b>operator=</b></a> ( const QPixmap & pixmap )</li>
<li class=fn>QPixmap & <a href="#operator-eq-2"><b>operator=</b></a> ( const QImage & image )</li>
<li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
<li class=fn>int <a href="#width"><b>width</b></a> () const</li>
<li class=fn>int <a href="#height"><b>height</b></a> () const</li>
<li class=fn>QSize <a href="#size"><b>size</b></a> () const</li>
<li class=fn>QRect <a href="#rect"><b>rect</b></a> () const</li>
<li class=fn>int <a href="#depth"><b>depth</b></a> () const</li>
<li class=fn>void <a href="#fill"><b>fill</b></a> ( const QColor & fillColor = Qt::white )</li>
<li class=fn>void <a href="#fill-2"><b>fill</b></a> ( const QWidget * widget, int xofs, int yofs )</li>
<li class=fn>void <a href="#fill-3"><b>fill</b></a> ( const QWidget * widget, const QPoint & ofs )</li>
<li class=fn>void <a href="#resize"><b>resize</b></a> ( int w, int h )</li>
<li class=fn>void <a href="#resize-2"><b>resize</b></a> ( const QSize & size )</li>
<li class=fn>const QBitmap * <a href="#mask"><b>mask</b></a> () const</li>
<li class=fn>void <a href="#setMask"><b>setMask</b></a> ( const QBitmap & newmask )</li>
<li class=fn>bool <a href="#selfMask"><b>selfMask</b></a> () const</li>
<li class=fn>bool <a href="#hasAlpha"><b>hasAlpha</b></a> () const</li>
<li class=fn>bool <a href="#hasAlphaChannel"><b>hasAlphaChannel</b></a> () const</li>
<li class=fn>QBitmap <a href="#createHeuristicMask"><b>createHeuristicMask</b></a> ( bool clipTight = TRUE ) const</li>
<li class=fn>QPixmap <a href="#xForm"><b>xForm</b></a> ( const QWMatrix & matrix ) const</li>
<li class=fn>QImage <a href="#convertToImage"><b>convertToImage</b></a> () const</li>
<li class=fn>bool <a href="#convertFromImage-2"><b>convertFromImage</b></a> ( const QImage & image, ColorMode mode = Auto )</li>
<li class=fn>bool <a href="#convertFromImage"><b>convertFromImage</b></a> ( const QImage & img, int conversion_flags )</li>
<li class=fn>bool <a href="#load-2"><b>load</b></a> ( const QString & fileName, const char * format = 0, ColorMode mode = Auto )</li>
<li class=fn>bool <a href="#load"><b>load</b></a> ( const QString & fileName, const char * format, int conversion_flags )</li>
<li class=fn>bool <a href="#loadFromData-2"><b>loadFromData</b></a> ( const uchar * buf, uint len, const char * format = 0, ColorMode mode = Auto )</li>
<li class=fn>bool <a href="#loadFromData"><b>loadFromData</b></a> ( const uchar * buf, uint len, const char * format, int conversion_flags )</li>
<li class=fn>bool <a href="#loadFromData-3"><b>loadFromData</b></a> ( const QByteArray & buf, const char * format = 0, int conversion_flags = 0 )</li>
<li class=fn>bool <a href="#save"><b>save</b></a> ( const QString & fileName, const char * format, int quality = -1 ) const</li>
<li class=fn>bool <a href="#save-2"><b>save</b></a> ( QIODevice * device, const char * format, int quality = -1 ) const</li>
<li class=fn>int <a href="#serialNumber"><b>serialNumber</b></a> () const</li>
<li class=fn>Optimization <a href="#optimization"><b>optimization</b></a> () const</li>
<li class=fn>void <a href="#setOptimization"><b>setOptimization</b></a> ( Optimization optimization )</li>
<li class=fn>virtual void <a href="#detach"><b>detach</b></a> ()</li>
<li class=fn>bool <a href="#isQBitmap"><b>isQBitmap</b></a> () const</li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>int <a href="#defaultDepth"><b>defaultDepth</b></a> ()</li>
<li class=fn>QPixmap <a href="#fromMimeSource"><b>fromMimeSource</b></a> ( const QString & abs_name )</li>
<li class=fn>QPixmap <a href="#grabWindow"><b>grabWindow</b></a> ( WId window, int x = 0, int y = 0, int w = -1, int h = -1 )</li>
<li class=fn>QPixmap <a href="#grabWidget"><b>grabWidget</b></a> ( QWidget * widget, int x = 0, int y = 0, int w = -1, int h = -1 )</li>
<li class=fn>QWMatrix <a href="#trueMatrix"><b>trueMatrix</b></a> ( const QWMatrix & matrix, int w, int h )</li>
<li class=fn>const char * <a href="#imageFormat"><b>imageFormat</b></a> ( const QString & fileName )</li>
<li class=fn>Optimization <a href="#defaultOptimization"><b>defaultOptimization</b></a> ()</li>
<li class=fn>void <a href="#setDefaultOptimization"><b>setDefaultOptimization</b></a> ( Optimization optimization )</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn><a href="#QPixmap-a"><b>QPixmap</b></a> ( int w, int h, const uchar * bits, bool isXbitmap )</li>
<li class=fn>virtual int <a href="#metric"><b>metric</b></a> ( int m ) const</li>
</ul>
<h2>Related Functions</h2>
<ul>
<li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QPixmap & pixmap )</li>
<li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QPixmap & pixmap )</li>
<li class=fn>void <a href="#copyBlt"><b>copyBlt</b></a> ( QPixmap * dst, int dx, int dy, const QPixmap * src, int sx, int sy, int sw, int sh )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The QPixmap class is an off-screen, pixel-based paint device.
<p>
<p> QPixmap is one of the two classes Qt provides for dealing with
images; the other is <a href="qimage.html">QImage</a>. QPixmap is designed and optimized
for drawing; QImage is designed and optimized for I/O and for
direct pixel access/manipulation. There are (slow) functions to
convert between QImage and QPixmap: <a href="#convertToImage">convertToImage</a>() and
<a href="#convertFromImage">convertFromImage</a>().
<p> One common use of the QPixmap class is to enable smooth updating
of widgets. Whenever something complex needs to be drawn, you can
use a pixmap to obtain flicker-free drawing, like this:
<p> <ol type=1>
<li> Create a pixmap with the same size as the widget.
<li> Fill the pixmap with the widget background color.
<li> Paint the pixmap.
<li> <a href="qpaintdevice.html#bitBlt">bitBlt</a>() the pixmap contents onto the widget.
</ol>
<p> Pixel data in a pixmap is internal and is managed by the
underlying window system. Pixels can be accessed only through
<a href="qpainter.html">QPainter</a> functions, through bitBlt(), and by converting the
QPixmap to a QImage.
<p> You can easily display a QPixmap on the screen using
<a href="qlabel.html#setPixmap">QLabel::setPixmap</a>(). For example, all the <a href="qbutton.html">QButton</a> subclasses
support pixmap use.
<p> The QPixmap class uses <a href="shclass.html">copy-on-write</a>,
so it is practical to pass QPixmap objects by value.
<p> You can retrieve the <a href="#width">width</a>(), <a href="#height">height</a>(), <a href="#depth">depth</a>() and <a href="#size">size</a>() of a
pixmap. The enclosing rectangle is given by <a href="#rect">rect</a>(). Pixmaps can be
filled with <a href="#fill">fill</a>() and resized with <a href="#resize">resize</a>(). You can create and
set a mask with <a href="#createHeuristicMask">createHeuristicMask</a>() and <a href="#setMask">setMask</a>(). Use
<a href="#selfMask">selfMask</a>() to see if the pixmap is identical to its mask.
<p> In addition to loading a pixmap from file using <a href="#load">load</a>() you can
also <a href="#loadFromData">loadFromData</a>(). You can control optimization with
<a href="#setOptimization">setOptimization</a>() and obtain a transformed version of the pixmap
using <a href="#xForm">xForm</a>()
<p> Note regarding Windows 95 and 98: on Windows 9x the system crashes
if you create more than about 1000 pixmaps, independent of the
size of the pixmaps or installed RAM. Windows NT-systems (including
2000, XP and following versions) do not have the same limitation,
but depending on the graphics equipment the system will fail to
allocate pixmap objects at some point (due to system running out of
GDI resources).
<p> Qt tries to work around the resource limitation. If you set the
pixmap optimization to <a href="#Optimization-enum">QPixmap::MemoryOptim</a> and the width of
your pixmap is less than or equal to 128 pixels, Qt stores the
pixmap in a way that is very memory-efficient when there are many
pixmaps.
<p> If your application uses dozens or hundreds of pixmaps (for
example on tool bar buttons and in popup menus), and you plan to
run it on Windows 95 or Windows 98, we recommend using code like
this:
<p> <pre>
QPixmap::<a href="#setDefaultOptimization">setDefaultOptimization</a>( QPixmap::<a href="#Optimization-enum">MemoryOptim</a> );
while ( ... ) {
// load tool bar pixmaps etc.
QPixmap *pixmap = new QPixmap(fileName);
}
QPixmap::<a href="#setDefaultOptimization">setDefaultOptimization</a>( QPixmap::<a href="#Optimization-enum">NormalOptim</a> );
</pre>
<p> In general it is recommended to make as much use of QPixmap's
<a href="shclass.html#implicit-sharing">implicit sharing</a> and the <a href="qpixmapcache.html">QPixmapCache</a> as possible.
<p> <p>See also <a href="qbitmap.html">QBitmap</a>, <a href="qimage.html">QImage</a>, <a href="qimageio.html">QImageIO</a>, <a href="shclass.html">Shared Classes</a>, <a href="graphics.html">Graphics Classes</a>, <a href="images.html">Image Processing Classes</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="ColorMode-enum"></a>QPixmap::ColorMode</h3>
<p> This enum type defines the color modes that exist for converting
<a href="qimage.html">QImage</a> objects to QPixmap.
<ul>
<li><tt>QPixmap::Auto</tt> - Select <a href="#ColorMode-enum">Color</a> or <a href="#ColorMode-enum">Mono</a> on a case-by-case basis.
<li><tt>QPixmap::Color</tt> - Always create colored pixmaps.
<li><tt>QPixmap::Mono</tt> - Always create bitmaps.
</ul>
<h3 class=fn><a name="Optimization-enum"></a>QPixmap::Optimization</h3>
<p> QPixmap has the choice of optimizing for speed or memory in a few
places; the best choice varies from pixmap to pixmap but can
generally be derived heuristically. This enum type defines a
number of optimization modes that you can set for any pixmap to
tweak the speed/memory tradeoffs:
<ul>
<li><tt>QPixmap::DefaultOptim</tt> - Whatever <a href="#defaultOptimization">QPixmap::defaultOptimization</a>()
returns. A pixmap with this optimization will have whatever
the current default optimization is. If the default
optimization is changed using <a href="#setDefaultOptimization">setDefaultOptimization</a>(), then
this will not effect any pixmaps that have already been
created.
<li><tt>QPixmap::NoOptim</tt> - No optimization (currently the same as <a href="#Optimization-enum">MemoryOptim</a>).
<li><tt>QPixmap::MemoryOptim</tt> - Optimize for minimal memory use on Windows
9x and X11 systems.
<li><tt>QPixmap::NormalOptim</tt> - Optimize for typical usage. Often uses more
memory than <a href="#Optimization-enum">MemoryOptim</a>, and is often faster.
<li><tt>QPixmap::BestOptim</tt> - Optimize for pixmaps that are drawn very often
and where performance is critical. Generally uses more memory
than <a href="#Optimization-enum">NormalOptim</a> and may provide a little more speed.
</ul><p> We recommend using <a href="#Optimization-enum">DefaultOptim</a>.
<p>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QPixmap"></a>QPixmap::QPixmap ()
</h3>
Constructs a null pixmap.
<p> <p>See also <a href="#isNull">isNull</a>().
<h3 class=fn><a name="QPixmap-2"></a>QPixmap::QPixmap ( const <a href="qimage.html">QImage</a> & image )
</h3>
Constructs a pixmap from the <a href="qimage.html">QImage</a> <em>image</em>.
<p> <p>See also <a href="#convertFromImage">convertFromImage</a>().
<h3 class=fn><a name="QPixmap-3"></a>QPixmap::QPixmap ( int w, int h, int depth = -1, <a href="qpixmap.html#Optimization-enum">Optimization</a> optimization = DefaultOptim )
</h3>
Constructs a pixmap with <em>w</em> width, <em>h</em> height and <em>depth</em> bits
per pixel. The pixmap is optimized in accordance with the <em>optimization</em> value.
<p> The contents of the pixmap is uninitialized.
<p> The <em>depth</em> can be either 1 (monochrome) or the depth of the
current video mode. If <em>depth</em> is negative, then the hardware
depth of the current video mode will be used.
<p> If either <em>w</em> or <em>h</em> is zero, a null pixmap is constructed.
<p> <p>See also <a href="#isNull">isNull</a>() and <a href="#Optimization-enum">QPixmap::Optimization</a>.
<h3 class=fn><a name="QPixmap-4"></a>QPixmap::QPixmap ( const <a href="qsize.html">QSize</a> & size, int depth = -1, <a href="qpixmap.html#Optimization-enum">Optimization</a> optimization = DefaultOptim )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Constructs a pixmap of size <em>size</em>, <em>depth</em> bits per pixel,
optimized in accordance with the <em>optimization</em> value.
<h3 class=fn><a name="QPixmap-5"></a>QPixmap::QPixmap ( const <a href="qstring.html">QString</a> & fileName, const char * format = 0, <a href="qpixmap.html#ColorMode-enum">ColorMode</a> mode = Auto )
</h3>
Constructs a pixmap from the file <em>fileName</em>. If the file does
not exist or is of an unknown format, the pixmap becomes a null
pixmap.
<p> The <em>fileName</em>, <em>format</em> and <em>mode</em> parameters are passed on to
<a href="#load">load</a>(). This means that the data in <em>fileName</em> is not compiled
into the binary. If <em>fileName</em> contains a relative path (e.g. the
filename only) the relevant file must be found relative to the
runtime working directory.
<p> <p>See also <a href="#ColorMode-enum">QPixmap::ColorMode</a>, <a href="#isNull">isNull</a>(), <a href="#load">load</a>(), <a href="#loadFromData">loadFromData</a>(), <a href="#save">save</a>(), and <a href="#imageFormat">imageFormat</a>().
<h3 class=fn><a name="QPixmap-6"></a>QPixmap::QPixmap ( const <a href="qstring.html">QString</a> & fileName, const char * format, int conversion_flags )
</h3>
Constructs a pixmap from the file <em>fileName</em>. If the file does
not exist or is of an unknown format, the pixmap becomes a null
pixmap.
<p> The <em>fileName</em>, <em>format</em> and <em>conversion_flags</em> parameters are
passed on to <a href="#load">load</a>(). This means that the data in <em>fileName</em> is
not compiled into the binary. If <em>fileName</em> contains a relative
path (e.g. the filename only) the relevant file must be found
relative to the runtime working directory.
<p> If the image needs to be modified to fit in a lower-resolution
result (e.g. converting from 32-bit to 8-bit), use the <em>conversion_flags</em> to specify how you'd prefer this to happen.
<p> <p>See also <a href="qt.html#ImageConversionFlags-enum">Qt::ImageConversionFlags</a>, <a href="#isNull">isNull</a>(), <a href="#load">load</a>(), <a href="#loadFromData">loadFromData</a>(), <a href="#save">save</a>(), and <a href="#imageFormat">imageFormat</a>().
<h3 class=fn><a name="QPixmap-7"></a>QPixmap::QPixmap ( const char * xpm[] )
</h3>
Constructs a pixmap from <em>xpm</em>, which must be a valid XPM image.
<p> Errors are silently ignored.
<p> Note that it's possible to squeeze the XPM variable a little bit
by using an unusual declaration:
<p> <pre>
static const char * const start_xpm[]={
"16 15 8 1",
"a c #cec6bd",
....
</pre>
<p> The extra <tt>const</tt> makes the entire definition read-only, which is
slightly more efficient (for example, when the code is in a shared
library) and ROMable when the application is to be stored in ROM.
<p> In order to use that sort of declaration you must cast the
variable back to <tt>const char **</tt> when you create the QPixmap.
<h3 class=fn><a name="QPixmap-8"></a>QPixmap::QPixmap ( const <a href="qbytearray.html">QByteArray</a> & img_data )
</h3>
Constructs a pixmaps by loading from <em>img_data</em>. The data can be
in any image format supported by Qt.
<p> <p>See also <a href="#loadFromData">loadFromData</a>().
<h3 class=fn><a name="QPixmap-9"></a>QPixmap::QPixmap ( const <a href="qpixmap.html">QPixmap</a> & pixmap )
</h3>
Constructs a pixmap that is a copy of <em>pixmap</em>.
<h3 class=fn><a name="QPixmap-a"></a>QPixmap::QPixmap ( int w, int h, const uchar * bits, bool isXbitmap )<tt> [protected]</tt>
</h3>
Constructs a monochrome pixmap, with width <em>w</em> and height <em>h</em>,
that is initialized with the data in <em>bits</em>. The <em>isXbitmap</em>
indicates whether the data is an X bitmap and defaults to FALSE.
This constructor is protected and used by the <a href="qbitmap.html">QBitmap</a> class.
<h3 class=fn><a name="~QPixmap"></a>QPixmap::~QPixmap ()
</h3>
Destroys the pixmap.
<h3 class=fn>bool <a name="convertFromImage"></a>QPixmap::convertFromImage ( const <a href="qimage.html">QImage</a> & img, int conversion_flags )
</h3>
Converts image <em>img</em> and sets this pixmap. Returns TRUE if
successful; otherwise returns FALSE.
<p> The <em>conversion_flags</em> argument is a bitwise-OR of the
<a href="qt.html#ImageConversionFlags-enum">Qt::ImageConversionFlags</a>. Passing 0 for <em>conversion_flags</em>
sets all the default options.
<p> Note that even though a QPixmap with depth 1 behaves much like a
<a href="qbitmap.html">QBitmap</a>, <a href="#isQBitmap">isQBitmap</a>() returns FALSE.
<p> If a pixmap with depth 1 is painted with color0 and color1 and
converted to an image, the pixels painted with color0 will produce
pixel index 0 in the image and those painted with color1 will
produce pixel index 1.
<p> <p>See also <a href="#convertToImage">convertToImage</a>(), <a href="#isQBitmap">isQBitmap</a>(), <a href="qimage.html#convertDepth">QImage::convertDepth</a>(), <a href="#defaultDepth">defaultDepth</a>(), and <a href="qimage.html#hasAlphaBuffer">QImage::hasAlphaBuffer</a>().
<p>Examples: <a href="canvas-example.html#x2943">canvas/canvas.cpp</a> and <a href="themes-example.html#x228">themes/wood.cpp</a>.
<h3 class=fn>bool <a name="convertFromImage-2"></a>QPixmap::convertFromImage ( const <a href="qimage.html">QImage</a> & image, <a href="qpixmap.html#ColorMode-enum">ColorMode</a> mode = Auto )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Converts <em>image</em> and sets this pixmap using color mode <em>mode</em>.
Returns TRUE if successful; otherwise returns FALSE.
<p> <p>See also <a href="#ColorMode-enum">QPixmap::ColorMode</a>.
<h3 class=fn><a href="qimage.html">QImage</a> <a name="convertToImage"></a>QPixmap::convertToImage () const
</h3>
Converts the pixmap to a <a href="qimage.html">QImage</a>. Returns a null image if it fails.
<p> If the pixmap has 1-bit depth, the returned image will also be 1
bit deep. If the pixmap has 2- to 8-bit depth, the returned image
has 8-bit depth. If the pixmap has greater than 8-bit depth, the
returned image has 32-bit depth.
<p> Note that for the moment, alpha masks on monochrome images are
ignored.
<p> <p>See also <a href="#convertFromImage">convertFromImage</a>().
<p>Example: <a href="qmag-example.html#x1783">qmag/qmag.cpp</a>.
<h3 class=fn><a href="qbitmap.html">QBitmap</a> <a name="createHeuristicMask"></a>QPixmap::createHeuristicMask ( bool clipTight = TRUE ) const
</h3>
Creates and returns a heuristic mask for this pixmap. It works by
selecting a color from one of the corners and then chipping away
pixels of that color, starting at all the edges.
<p> The mask may not be perfect but it should be reasonable, so you
can do things such as the following:
<pre>
pm->setMask( pm->createHeuristicMask() );
</pre>
<p> This function is slow because it involves transformation to a
<a href="qimage.html">QImage</a>, non-trivial computations and a transformation back to a
<a href="qbitmap.html">QBitmap</a>.
<p> If <em>clipTight</em> is TRUE the mask is just large enough to cover the
pixels; otherwise, the mask is larger than the data pixels.
<p> <p>See also <a href="qimage.html#createHeuristicMask">QImage::createHeuristicMask</a>().
<h3 class=fn>int <a name="defaultDepth"></a>QPixmap::defaultDepth ()<tt> [static]</tt>
</h3>
Returns the default pixmap depth, i.e. the depth a pixmap gets if
-1 is specified.
<p> <p>See also <a href="#depth">depth</a>().
<h3 class=fn><a href="qpixmap.html#Optimization-enum">Optimization</a> <a name="defaultOptimization"></a>QPixmap::defaultOptimization ()<tt> [static]</tt>
</h3>
Returns the default pixmap optimization setting.
<p> <p>See also <a href="#setDefaultOptimization">setDefaultOptimization</a>(), <a href="#setOptimization">setOptimization</a>(), and <a href="#optimization">optimization</a>().
<h3 class=fn>int <a name="depth"></a>QPixmap::depth () const
</h3>
<p> Returns the depth of the pixmap.
<p> The pixmap depth is also called bits per pixel (bpp) or bit planes
of a pixmap. A null pixmap has depth 0.
<p> <p>See also <a href="#defaultDepth">defaultDepth</a>(), <a href="#isNull">isNull</a>(), and <a href="qimage.html#convertDepth">QImage::convertDepth</a>().
<h3 class=fn>void <a name="detach"></a>QPixmap::detach ()<tt> [virtual]</tt>
</h3>
This is a special-purpose function that detaches the pixmap from
shared pixmap data.
<p> A pixmap is automatically detached by Qt whenever its contents is
about to change. This is done in all QPixmap member functions
that modify the pixmap (<a href="#fill">fill</a>(), <a href="#resize">resize</a>(), <a href="#convertFromImage">convertFromImage</a>(),
<a href="#load">load</a>(), etc.), in <a href="qpaintdevice.html#bitBlt">bitBlt</a>() for the destination pixmap and in
<a href="qpainter.html#begin">QPainter::begin</a>() on a pixmap.
<p> It is possible to modify a pixmap without letting Qt know. You can
first obtain the system-dependent <a href="qpaintdevice.html#handle">handle</a>() and then call
system-specific functions (for instance, BitBlt under Windows)
that modify the pixmap contents. In such cases, you can call
<a href="#detach">detach</a>() to cut the pixmap loose from other pixmaps that share
data with this one.
<p> detach() returns immediately if there is just a single reference
or if the pixmap has not been initialized yet.
<h3 class=fn>void <a name="fill"></a>QPixmap::fill ( const <a href="qcolor.html">QColor</a> & fillColor = Qt::white )
</h3>
Fills the pixmap with the color <em>fillColor</em>.
<p>Examples: <a href="tutorial2-08.html#x2606">chart/setdataform.cpp</a>, <a href="desktop-example.html#x1742">desktop/desktop.cpp</a>, <a href="grapher-nsplugin-example.html#x2765">grapher/grapher.cpp</a>, <a href="hello-example.html#x1638">hello/hello.cpp</a>, <a href="tutorial1-10.html#x2358">t10/cannon.cpp</a>, <a href="themes-example.html#x292">themes/metal.cpp</a>, and <a href="xform-example.html#x1245">xform/xform.cpp</a>.
<h3 class=fn>void <a name="fill-2"></a>QPixmap::fill ( const <a href="qwidget.html">QWidget</a> * widget, int xofs, int yofs )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Fills the pixmap with the <em>widget</em>'s background color or pixmap.
If the background is empty, nothing is done. <em>xofs</em>, <em>yofs</em> is
an offset in the widget.
<h3 class=fn>void <a name="fill-3"></a>QPixmap::fill ( const <a href="qwidget.html">QWidget</a> * widget, const <a href="qpoint.html">QPoint</a> & ofs )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Fills the pixmap with the <em>widget</em>'s background color or pixmap.
If the background is empty, nothing is done.
<p> The <em>ofs</em> point is an offset in the widget.
<p> The point <em>ofs</em> is a point in the widget's coordinate system. The
pixmap's top-left pixel will be mapped to the point <em>ofs</em> in the
widget. This is significant if the widget has a background pixmap;
otherwise the pixmap will simply be filled with the background
color of the widget.
<p> Example:
<pre>
void CuteWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> *e )
{
<a href="qrect.html">QRect</a> ur = e-><a href="qpaintevent.html#rect">rect</a>(); // rectangle to update
QPixmap pix( ur.<a href="qrect.html#size">size</a>() ); // Pixmap for double-buffering
pix.<a href="#fill">fill</a>( this, ur.<a href="qrect.html#topLeft">topLeft</a>() ); // fill with widget background
<a href="qpainter.html">QPainter</a> p( &pix );
p.<a href="qpainter.html#translate">translate</a>( -ur.<a href="qrect.html#x">x</a>(), -ur.<a href="qrect.html#y">y</a>() ); // use widget coordinate system
// when drawing on pixmap
// ... draw on pixmap ...
p.<a href="qpainter.html#end">end</a>();
<a href="qpaintdevice.html#bitBlt">bitBlt</a>( this, ur.<a href="qrect.html#topLeft">topLeft</a>(), &pix );
}
</pre>
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="fromMimeSource"></a>QPixmap::fromMimeSource ( const <a href="qstring.html">QString</a> & abs_name )<tt> [static]</tt>
</h3> Convenience function. Gets the data associated with the absolute
name <em>abs_name</em> from the default mime source factory and decodes it
to a pixmap.
<p> <p>See also <a href="qmimesourcefactory.html">QMimeSourceFactory</a>, <a href="qimage.html#fromMimeSource">QImage::fromMimeSource</a>(), and <a href="qimagedrag.html#decode">QImageDrag::decode</a>().
<p>Example: <a href="qactiongroup.html#x2113">textedit/textedit.cpp</a>.
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="grabWidget"></a>QPixmap::grabWidget ( <a href="qwidget.html">QWidget</a> * widget, int x = 0, int y = 0, int w = -1, int h = -1 )<tt> [static]</tt>
</h3>
Creates a pixmap and paints <em>widget</em> in it.
<p> If the <em>widget</em> has any children, then they are also painted in
the appropriate positions.
<p> If you specify <em>x</em>, <em>y</em>, <em>w</em> or <em>h</em>, only the rectangle you
specify is painted. The defaults are 0, 0 (top-left corner) and
-1,-1 (which means the entire widget).
<p> (If <em>w</em> is negative, the function copies everything to the right
border of the window. If <em>h</em> is negative, the function copies
everything to the bottom of the window.)
<p> If <em>widget</em> is 0, or if the rectangle defined by <em>x</em>, <em>y</em>, the
modified <em>w</em> and the modified <em>h</em> does not overlap the <em>widget</em>->rect(), this function will return a null QPixmap.
<p> This function actually asks <em>widget</em> to paint itself (and its
children to paint themselves). <a href="#grabWindow">QPixmap::grabWindow</a>() grabs pixels
off the screen, which is a bit faster and picks up <em>exactly</em>
what's on-screen. This function works by calling paintEvent() with
painter redirection turned on. If there are overlaying windows,
<a href="#grabWindow">grabWindow</a>() will see them, but not this function.
<p> If there is overlap, it returns a pixmap of the size you want,
containing a rendering of <em>widget</em>. If the rectangle you ask for
is a superset of <em>widget</em>, the areas outside <em>widget</em> are
covered with the widget's background.
<p> If an error occurs when trying to grab the widget, such as the
size of the widget being too large to fit in memory, an <a href="#isNull">isNull</a>()
pixmap is returned.
<p> <p>See also <a href="#grabWindow">grabWindow</a>(), <a href="qpainter.html#redirect">QPainter::redirect</a>(), and <a href="qwidget.html#paintEvent">QWidget::paintEvent</a>().
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="grabWindow"></a>QPixmap::grabWindow ( WId window, int x = 0, int y = 0, int w = -1, int h = -1 )<tt> [static]</tt>
</h3>
Grabs the contents of the window <em>window</em> and makes a pixmap out
of it. Returns the pixmap.
<p> The arguments <em>(x, y)</em> specify the offset in the window, whereas
<em>(w, h)</em> specify the width and height of the area to be copied.
<p> If <em>w</em> is negative, the function copies everything to the right
border of the window. If <em>h</em> is negative, the function copies
everything to the bottom of the window.
<p> Note that <a href="#grabWindow">grabWindow</a>() grabs pixels from the screen, not from the
window. If there is another window partially or entirely over the
one you grab, you get pixels from the overlying window, too.
<p> Note also that the mouse cursor is generally not grabbed.
<p> The reason we use a window identifier and not a <a href="qwidget.html">QWidget</a> is to
enable grabbing of windows that are not part of the application,
window system frames, and so on.
<p> <b>Warning:</b> Grabbing an area outside the screen is not safe in
general. This depends on the underlying window system.
<p> <b>Warning:</b> X11 only: If <em>window</em> is not the same depth as the root
window and another window partially or entirely obscures the one
you grab, you will <em>not</em> get pixels from the overlying window.
The contests of the obscured areas in the pixmap are undefined and
uninitialized.
<p> <p>See also <a href="#grabWidget">grabWidget</a>().
<p>Example: <a href="qmag-example.html#x1784">qmag/qmag.cpp</a>.
<h3 class=fn>bool <a name="hasAlpha"></a>QPixmap::hasAlpha () const
</h3>
Returns TRUE this pixmap has an alpha channel or a mask.
<p> <p>See also <a href="#hasAlphaChannel">hasAlphaChannel</a>() and <a href="#mask">mask</a>().
<h3 class=fn>bool <a name="hasAlphaChannel"></a>QPixmap::hasAlphaChannel () const
</h3>
Returns TRUE if the pixmap has an alpha channel; otherwise it
returns FALSE.
<p> NOTE: If the pixmap has a mask but not alpha channel, this
function returns FALSE.
<p> <p>See also <a href="#hasAlpha">hasAlpha</a>() and <a href="#mask">mask</a>().
<h3 class=fn>int <a name="height"></a>QPixmap::height () const
</h3>
<p> Returns the height of the pixmap.
<p> <p>See also <a href="#width">width</a>(), <a href="#size">size</a>(), and <a href="#rect">rect</a>().
<p>Examples: <a href="desktop-example.html#x1743">desktop/desktop.cpp</a>, <a href="movies-example.html#x510">movies/main.cpp</a>, <a href="scribble-example.html#x921">scribble/scribble.cpp</a>, <a href="scrollview-example.html#x638">scrollview/scrollview.cpp</a>, <a href="tutorial1-10.html#x2359">t10/cannon.cpp</a>, and <a href="xform-example.html#x1246">xform/xform.cpp</a>.
<h3 class=fn>const char * <a name="imageFormat"></a>QPixmap::imageFormat ( const <a href="qstring.html">QString</a> & fileName )<tt> [static]</tt>
</h3>
Returns a string that specifies the image format of the file <em>fileName</em>, or 0 if the file cannot be read or if the format cannot
be recognized.
<p> The <a href="qimageio.html">QImageIO</a> documentation lists the supported image formats.
<p> <p>See also <a href="#load">load</a>() and <a href="#save">save</a>().
<h3 class=fn>bool <a name="isNull"></a>QPixmap::isNull () const
</h3>
<p> Returns TRUE if this is a null pixmap; otherwise returns FALSE.
<p> A null pixmap has zero width, zero height and no contents. You
cannot draw in a null pixmap or <a href="qpaintdevice.html#bitBlt">bitBlt</a>() anything to it.
<p> Resizing an existing pixmap to (0, 0) makes a pixmap into a null
pixmap.
<p> <p>See also <a href="#resize">resize</a>().
<p>Examples: <a href="movies-example.html#x511">movies/main.cpp</a>, <a href="qdir-example.html#x1834">qdir/qdir.cpp</a>, <a href="qmag-example.html#x1785">qmag/qmag.cpp</a>, and <a href="scrollview-example.html#x639">scrollview/scrollview.cpp</a>.
<h3 class=fn>bool <a name="isQBitmap"></a>QPixmap::isQBitmap () const
</h3>
<p> Returns TRUE if this is a <a href="qbitmap.html">QBitmap</a>; otherwise returns FALSE.
<h3 class=fn>bool <a name="load"></a>QPixmap::load ( const <a href="qstring.html">QString</a> & fileName, const char * format, int conversion_flags )
</h3>
Loads a pixmap from the file <em>fileName</em> at runtime. Returns TRUE
if successful; otherwise returns FALSE.
<p> If <em>format</em> is specified, the loader attempts to read the pixmap
using the specified format. If <em>format</em> is not specified
(default), the loader reads a few bytes from the header to guess
the file's format.
<p> See the <a href="#convertFromImage">convertFromImage</a>() documentation for a description of the
<em>conversion_flags</em> argument.
<p> The <a href="qimageio.html">QImageIO</a> documentation lists the supported image formats and
explains how to add extra formats.
<p> <p>See also <a href="#loadFromData">loadFromData</a>(), <a href="#save">save</a>(), <a href="#imageFormat">imageFormat</a>(), <a href="qimage.html#load">QImage::load</a>(), and <a href="qimageio.html">QImageIO</a>.
<p>Examples: <a href="picture-example.html#x124">picture/picture.cpp</a>, <a href="scrollview-example.html#x640">scrollview/scrollview.cpp</a>, and <a href="xform-example.html#x1247">xform/xform.cpp</a>.
<h3 class=fn>bool <a name="load-2"></a>QPixmap::load ( const <a href="qstring.html">QString</a> & fileName, const char * format = 0, <a href="qpixmap.html#ColorMode-enum">ColorMode</a> mode = Auto )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Loads a pixmap from the file <em>fileName</em> at runtime.
<p> If <em>format</em> is specified, the loader attempts to read the pixmap
using the specified format. If <em>format</em> is not specified
(default), the loader reads a few bytes from the header to guess
the file's format.
<p> The <em>mode</em> is used to specify the color mode of the pixmap.
<p> <p>See also <a href="#ColorMode-enum">QPixmap::ColorMode</a>.
<h3 class=fn>bool <a name="loadFromData"></a>QPixmap::loadFromData ( const uchar * buf, uint len, const char * format, int conversion_flags )
</h3>
Loads a pixmap from the binary data in <em>buf</em> (<em>len</em> bytes).
Returns TRUE if successful; otherwise returns FALSE.
<p> If <em>format</em> is specified, the loader attempts to read the pixmap
using the specified format. If <em>format</em> is not specified
(default), the loader reads a few bytes from the header to guess
the file's format.
<p> See the <a href="#convertFromImage">convertFromImage</a>() documentation for a description of the
<em>conversion_flags</em> argument.
<p> The <a href="qimageio.html">QImageIO</a> documentation lists the supported image formats and
explains how to add extra formats.
<p> <p>See also <a href="#load">load</a>(), <a href="#save">save</a>(), <a href="#imageFormat">imageFormat</a>(), <a href="qimage.html#loadFromData">QImage::loadFromData</a>(), and <a href="qimageio.html">QImageIO</a>.
<h3 class=fn>bool <a name="loadFromData-2"></a>QPixmap::loadFromData ( const uchar * buf, uint len, const char * format = 0, <a href="qpixmap.html#ColorMode-enum">ColorMode</a> mode = Auto )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Loads a pixmap from the binary data in <em>buf</em> (<em>len</em> bytes) using
color mode <em>mode</em>. Returns TRUE if successful; otherwise returns
FALSE.
<p> If <em>format</em> is specified, the loader attempts to read the pixmap
using the specified format. If <em>format</em> is not specified
(default), the loader reads a few bytes from the header to guess
the file's format.
<p> <p>See also <a href="#ColorMode-enum">QPixmap::ColorMode</a>.
<h3 class=fn>bool <a name="loadFromData-3"></a>QPixmap::loadFromData ( const <a href="qbytearray.html">QByteArray</a> & buf, const char * format = 0, int conversion_flags = 0 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<h3 class=fn>const <a href="qbitmap.html">QBitmap</a> * <a name="mask"></a>QPixmap::mask () const
</h3>
<p> Returns the mask bitmap, or 0 if no mask has been set.
<p> <p>See also <a href="#setMask">setMask</a>(), <a href="qbitmap.html">QBitmap</a>, and <a href="#hasAlpha">hasAlpha</a>().
<h3 class=fn>int <a name="metric"></a>QPixmap::metric ( int m ) const<tt> [virtual protected]</tt>
</h3>
Internal implementation of the virtual QPaintDevice::metric() function.
<p> Use the <a href="qpaintdevicemetrics.html">QPaintDeviceMetrics</a> class instead.
<p> <em>m</em> is the metric to get.
<h3 class=fn><a href="qpixmap.html">QPixmap</a> & <a name="operator-eq"></a>QPixmap::operator= ( const <a href="qpixmap.html">QPixmap</a> & pixmap )
</h3>
Assigns the pixmap <em>pixmap</em> to this pixmap and returns a
reference to this pixmap.
<h3 class=fn><a href="qpixmap.html">QPixmap</a> & <a name="operator-eq-2"></a>QPixmap::operator= ( const <a href="qimage.html">QImage</a> & image )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Converts the image <em>image</em> to a pixmap that is assigned to this
pixmap. Returns a reference to the pixmap.
<p> <p>See also <a href="#convertFromImage">convertFromImage</a>().
<h3 class=fn><a href="qpixmap.html#Optimization-enum">Optimization</a> <a name="optimization"></a>QPixmap::optimization () const
</h3>
<p> Returns the optimization setting for this pixmap.
<p> The default optimization setting is <a href="#Optimization-enum">QPixmap::NormalOptim</a>. You
can change this setting in two ways:
<ul>
<li> Call <a href="#setDefaultOptimization">setDefaultOptimization</a>() to set the default optimization
for all new pixmaps.
<li> Call <a href="#setOptimization">setOptimization</a>() to set the optimization for individual
pixmaps.
</ul>
<p> <p>See also <a href="#setOptimization">setOptimization</a>(), <a href="#setDefaultOptimization">setDefaultOptimization</a>(), and <a href="#defaultOptimization">defaultOptimization</a>().
<h3 class=fn><a href="qrect.html">QRect</a> <a name="rect"></a>QPixmap::rect () const
</h3>
<p> Returns the enclosing rectangle (0,0,width(),height()) of the pixmap.
<p> <p>See also <a href="#width">width</a>(), <a href="#height">height</a>(), and <a href="#size">size</a>().
<h3 class=fn>void <a name="resize"></a>QPixmap::resize ( int w, int h )
</h3>
Resizes the pixmap to <em>w</em> width and <em>h</em> height. If either <em>w</em>
or <em>h</em> is 0, the pixmap becomes a null pixmap.
<p> If both <em>w</em> and <em>h</em> are greater than 0, a valid pixmap is
created. New pixels will be uninitialized (random) if the pixmap
is expanded.
<p>Examples: <a href="desktop-example.html#x1744">desktop/desktop.cpp</a> and <a href="grapher-nsplugin-example.html#x2766">grapher/grapher.cpp</a>.
<h3 class=fn>void <a name="resize-2"></a>QPixmap::resize ( const <a href="qsize.html">QSize</a> & size )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Resizes the pixmap to size <em>size</em>.
<h3 class=fn>bool <a name="save"></a>QPixmap::save ( const <a href="qstring.html">QString</a> & fileName, const char * format, int quality = -1 ) const
</h3>
Saves the pixmap to the file <em>fileName</em> using the image file
format <em>format</em> and a quality factor <em>quality</em>. <em>quality</em> must
be in the range [0,100] or -1. Specify 0 to obtain small
compressed files, 100 for large uncompressed files, and -1 to use
the default settings. Returns TRUE if successful; otherwise
returns FALSE.
<p> <p>See also <a href="#load">load</a>(), <a href="#loadFromData">loadFromData</a>(), <a href="#imageFormat">imageFormat</a>(), <a href="qimage.html#save">QImage::save</a>(), and <a href="qimageio.html">QImageIO</a>.
<p>Example: <a href="qmag-example.html#x1786">qmag/qmag.cpp</a>.
<h3 class=fn>bool <a name="save-2"></a>QPixmap::save ( <a href="qiodevice.html">QIODevice</a> * device, const char * format, int quality = -1 ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> This function writes a QPixmap to the <a href="qiodevice.html">QIODevice</a>, <em>device</em>. This
can be used, for example, to save a pixmap directly into a
QByteArray:
<pre>
QPixmap pixmap;
<a href="qbytearray.html">QByteArray</a> ba;
<a href="qbuffer.html">QBuffer</a> buffer( ba );
buffer.<a href="qiodevice.html#open">open</a>( <a href="qfile.html#open">IO_WriteOnly</a> );
pixmap.<a href="#save">save</a>( &buffer, "PNG" ); // writes pixmap into ba in PNG format
</pre>
<h3 class=fn>bool <a name="selfMask"></a>QPixmap::selfMask () const
</h3>
<p> Returns TRUE if the pixmap's mask is identical to the pixmap
itself; otherwise returns FALSE.
<p> <p>See also <a href="#mask">mask</a>().
<h3 class=fn>int <a name="serialNumber"></a>QPixmap::serialNumber () const
</h3>
<p> Returns a number that uniquely identifies the contents of this
QPixmap object. This means that multiple QPixmap objects can have
the same serial number as long as they refer to the same contents.
<p> An example of where this is useful is for caching QPixmaps.
<p> <p>See also <a href="qpixmapcache.html">QPixmapCache</a>.
<h3 class=fn>void <a name="setDefaultOptimization"></a>QPixmap::setDefaultOptimization ( <a href="qpixmap.html#Optimization-enum">Optimization</a> optimization )<tt> [static]</tt>
</h3>
Sets the default pixmap optimization.
<p> All <em>new</em> pixmaps that are created will use this default
optimization. You may also set optimization for individual pixmaps
using the <a href="#setOptimization">setOptimization</a>() function.
<p> The initial default <em>optimization</em> setting is <tt>QPixmap::Normal</tt>.
<p> <p>See also <a href="#defaultOptimization">defaultOptimization</a>(), <a href="#setOptimization">setOptimization</a>(), and <a href="#optimization">optimization</a>().
<h3 class=fn>void <a name="setMask"></a>QPixmap::setMask ( const <a href="qbitmap.html">QBitmap</a> & newmask )
</h3>
Sets a mask bitmap.
<p> The <em>newmask</em> bitmap defines the clip mask for this pixmap. Every
pixel in <em>newmask</em> corresponds to a pixel in this pixmap. Pixel
value 1 means opaque and pixel value 0 means transparent. The mask
must have the same size as this pixmap.
<p> <b>Warning:</b> Setting the mask on a pixmap will cause any alpha channel
data to be cleared. For example:
<pre>
QPixmap alpha( "image-with-alpha.png" );
QPixmap alphacopy = alpha;
alphacopy.<a href="#setMask">setMask</a>( *alphacopy.<a href="#mask">mask</a>() );
</pre>
Now, alpha and alphacopy are visually different.
<p> Setting a <a href="#isNull">null</a> mask resets the mask.
<p> <p>See also <a href="#mask">mask</a>(), <a href="#createHeuristicMask">createHeuristicMask</a>(), and <a href="qbitmap.html">QBitmap</a>.
<h3 class=fn>void <a name="setOptimization"></a>QPixmap::setOptimization ( <a href="qpixmap.html#Optimization-enum">Optimization</a> optimization )
</h3>
Sets pixmap drawing optimization for this pixmap.
<p> The <em>optimization</em> setting affects pixmap operations, in
particular drawing of transparent pixmaps (<a href="qpaintdevice.html#bitBlt">bitBlt</a>() a pixmap with
a mask set) and pixmap transformations (the <a href="#xForm">xForm</a>() function).
<p> Pixmap optimization involves keeping intermediate results in a
cache buffer and using the cache to speed up bitBlt() and xForm().
The cost is more memory consumption, up to twice as much as an
unoptimized pixmap.
<p> Use the <a href="#setDefaultOptimization">setDefaultOptimization</a>() to change the default
optimization for all new pixmaps.
<p> <p>See also <a href="#optimization">optimization</a>(), <a href="#setDefaultOptimization">setDefaultOptimization</a>(), and <a href="#defaultOptimization">defaultOptimization</a>().
<p>Example: <a href="desktop-example.html#x1745">desktop/desktop.cpp</a>.
<h3 class=fn><a href="qsize.html">QSize</a> <a name="size"></a>QPixmap::size () const
</h3>
<p> Returns the size of the pixmap.
<p> <p>See also <a href="#width">width</a>(), <a href="#height">height</a>(), and <a href="#rect">rect</a>().
<p>Example: <a href="movies-example.html#x512">movies/main.cpp</a>.
<h3 class=fn><a href="qwmatrix.html">QWMatrix</a> <a name="trueMatrix"></a>QPixmap::trueMatrix ( const <a href="qwmatrix.html">QWMatrix</a> & matrix, int w, int h )<tt> [static]</tt>
</h3>
Returns the actual matrix used for transforming a pixmap with <em>w</em>
width and <em>h</em> height and matrix <em>matrix</em>.
<p> When transforming a pixmap with <a href="#xForm">xForm</a>(), the <a href="qwmatrix.html#TransformationMode">transformation matrix</a>
is internally adjusted to compensate for unwanted translation,
i.e. xForm() returns the smallest pixmap containing all
transformed points of the original pixmap.
<p> This function returns the modified matrix, which maps points
correctly from the original pixmap into the new pixmap.
<p> <p>See also <a href="#xForm">xForm</a>() and <a href="qwmatrix.html">QWMatrix</a>.
<h3 class=fn>int <a name="width"></a>QPixmap::width () const
</h3>
<p> Returns the width of the pixmap.
<p> <p>See also <a href="#height">height</a>(), <a href="#size">size</a>(), and <a href="#rect">rect</a>().
<p>Examples: <a href="desktop-example.html#x1746">desktop/desktop.cpp</a>, <a href="movies-example.html#x513">movies/main.cpp</a>, <a href="scribble-example.html#x922">scribble/scribble.cpp</a>, <a href="scrollview-example.html#x641">scrollview/scrollview.cpp</a>, and <a href="xform-example.html#x1248">xform/xform.cpp</a>.
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="xForm"></a>QPixmap::xForm ( const <a href="qwmatrix.html">QWMatrix</a> & matrix ) const
</h3>
Returns a copy of the pixmap that is transformed using <em>matrix</em>.
The original pixmap is not changed.
<p> The transformation <em>matrix</em> is internally adjusted to compensate
for unwanted translation, i.e. <a href="#xForm">xForm</a>() returns the smallest image
that contains all the transformed points of the original image.
<p> This function is slow because it involves transformation to a
<a href="qimage.html">QImage</a>, non-trivial computations and a transformation back to a
QPixmap.
<p> <p>See also <a href="#trueMatrix">trueMatrix</a>(), <a href="qwmatrix.html">QWMatrix</a>, <a href="qpainter.html#setWorldMatrix">QPainter::setWorldMatrix</a>(), and <a href="qimage.html#xForm">QImage::xForm</a>().
<p>Examples: <a href="desktop-example.html#x1747">desktop/desktop.cpp</a>, <a href="fileiconview-example.html#x863">fileiconview/qfileiconview.cpp</a>, <a href="movies-example.html#x514">movies/main.cpp</a>, and <a href="qmag-example.html#x1787">qmag/qmag.cpp</a>.
<hr><h2>Related Functions</h2>
<h3 class=fn>void <a name="copyBlt"></a>copyBlt ( <a href="qpixmap.html">QPixmap</a> * dst, int dx, int dy, const <a href="qpixmap.html">QPixmap</a> * src, int sx, int sy, int sw, int sh )
</h3>
<p> Copies a block of pixels from <em>src</em> to <em>dst</em>. The alpha channel
and mask data (if any) is also copied from <em>src</em>. NOTE: <em>src</em>
is <em>not</em> alpha blended or masked when copied to <em>dst</em>. Use
<a href="qpaintdevice.html#bitBlt">bitBlt</a>() or <a href="qpainter.html#drawPixmap">QPainter::drawPixmap</a>() to perform alpha blending or
masked drawing.
<p> <em>sx</em>, <em>sy</em> is the top-left pixel in <em>src</em> (0, 0 by default), <em>dx</em>, <em>dy</em> is the top-left position in <em>dst</em> and <em>sw</em>, \sh is the
size of the copied block (all of <em>src</em> by default).
<p> If <em>src</em>, <em>dst</em>, <em>sw</em> or <em>sh</em> is 0 (zero), <a href="#copyBlt">copyBlt</a>() does
nothing. If <em>sw</em> or <em>sh</em> is negative, copyBlt() copies starting
at <em>sx</em> (and respectively, <em>sy</em>) and ending at the right edge
(and respectively, the bottom edge) of <em>src</em>.
<p> copyBlt() does nothing if <em>src</em> and <em>dst</em> have different depths.
<h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qpixmap.html">QPixmap</a> & pixmap )
</h3>
<p> Writes the pixmap <em>pixmap</em> to the stream <em>s</em> as a PNG image.
<p> Note that writing the stream to a file will not produce a valid image file.
<p> <p>See also <a href="#save">QPixmap::save</a>() and <a href="datastreamformat.html">Format of the QDataStream operators</a>.
<h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qpixmap.html">QPixmap</a> & pixmap )
</h3>
<p> Reads a pixmap from the stream <em>s</em> into the pixmap <em>pixmap</em>.
<p> <p>See also <a href="#load">QPixmap::load</a>() and <a href="datastreamformat.html">Format of the QDataStream operators</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright © 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>
|