qpixmap.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 753 行 · 第 1/4 页

HTML
753
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/kernel/qpixmap.cpp:50 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QPixmap Class</title><style type="text/css"><!--h3.fn,span.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&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;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 &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;</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><div class=fn>enum <a href="#ColorMode-enum"><b>ColorMode</b></a> { Auto, Color, Mono }</div></li><li><div class=fn>enum <a href="#Optimization-enum"><b>Optimization</b></a> { DefaultOptim, NoOptim, MemoryOptim = NoOptim, NormalOptim, BestOptim }</div></li><li><div class=fn><a href="#QPixmap"><b>QPixmap</b></a> ()</div></li><li><div class=fn><a href="#QPixmap-2"><b>QPixmap</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;image )</div></li><li><div class=fn><a href="#QPixmap-3"><b>QPixmap</b></a> ( int&nbsp;w, int&nbsp;h, int&nbsp;depth = -1, Optimization&nbsp;optimization = DefaultOptim )</div></li><li><div class=fn><a href="#QPixmap-4"><b>QPixmap</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;size, int&nbsp;depth = -1, Optimization&nbsp;optimization = DefaultOptim )</div></li><li><div class=fn><a href="#QPixmap-5"><b>QPixmap</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0, ColorMode&nbsp;mode = Auto )</div></li><li><div class=fn><a href="#QPixmap-6"><b>QPixmap</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )</div></li><li><div class=fn><a href="#QPixmap-7"><b>QPixmap</b></a> ( const&nbsp;char&nbsp;*&nbsp;xpm[] )</div></li><li><div class=fn><a href="#QPixmap-8"><b>QPixmap</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;img_data )</div></li><li><div class=fn><a href="#QPixmap-9"><b>QPixmap</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</div></li><li><div class=fn><a href="#~QPixmap"><b>~QPixmap</b></a> ()</div></li><li><div class=fn>QPixmap &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</div></li><li><div class=fn>QPixmap &amp; <a href="#operator-eq-2"><b>operator=</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;image )</div></li><li><div class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</div></li><li><div class=fn>int <a href="#width"><b>width</b></a> () const</div></li><li><div class=fn>int <a href="#height"><b>height</b></a> () const</div></li><li><div class=fn>QSize <a href="#size"><b>size</b></a> () const</div></li><li><div class=fn>QRect <a href="#rect"><b>rect</b></a> () const</div></li><li><div class=fn>int <a href="#depth"><b>depth</b></a> () const</div></li><li><div class=fn>void <a href="#fill"><b>fill</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;fillColor = Qt::white )</div></li><li><div class=fn>void <a href="#fill-2"><b>fill</b></a> ( const&nbsp;QWidget&nbsp;*&nbsp;widget, int&nbsp;xofs, int&nbsp;yofs )</div></li><li><div class=fn>void <a href="#fill-3"><b>fill</b></a> ( const&nbsp;QWidget&nbsp;*&nbsp;widget, const&nbsp;QPoint&nbsp;&amp;&nbsp;ofs )</div></li><li><div class=fn>void <a href="#resize"><b>resize</b></a> ( int&nbsp;w, int&nbsp;h )</div></li><li><div class=fn>void <a href="#resize-2"><b>resize</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;size )</div></li><li><div class=fn>const QBitmap * <a href="#mask"><b>mask</b></a> () const</div></li><li><div class=fn>void <a href="#setMask"><b>setMask</b></a> ( const&nbsp;QBitmap&nbsp;&amp;&nbsp;newmask )</div></li><li><div class=fn>bool <a href="#selfMask"><b>selfMask</b></a> () const</div></li><li><div class=fn>QBitmap <a href="#createHeuristicMask"><b>createHeuristicMask</b></a> ( bool&nbsp;clipTight = TRUE ) const</div></li><li><div class=fn>QPixmap <a href="#xForm"><b>xForm</b></a> ( const&nbsp;QWMatrix&nbsp;&amp;&nbsp;matrix ) const</div></li><li><div class=fn>QImage <a href="#convertToImage"><b>convertToImage</b></a> () const</div></li><li><div class=fn>bool <a href="#convertFromImage-2"><b>convertFromImage</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;image, ColorMode&nbsp;mode = Auto )</div></li><li><div class=fn>bool <a href="#convertFromImage"><b>convertFromImage</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;img, int&nbsp;conversion_flags )</div></li><li><div class=fn>bool <a href="#load-2"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0, ColorMode&nbsp;mode = Auto )</div></li><li><div class=fn>bool <a href="#load"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )</div></li><li><div class=fn>bool <a href="#loadFromData-2"><b>loadFromData</b></a> ( const&nbsp;uchar&nbsp;*&nbsp;buf, uint&nbsp;len, const&nbsp;char&nbsp;*&nbsp;format = 0, ColorMode&nbsp;mode = Auto )</div></li><li><div class=fn>bool <a href="#loadFromData"><b>loadFromData</b></a> ( const&nbsp;uchar&nbsp;*&nbsp;buf, uint&nbsp;len, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )</div></li><li><div class=fn>bool <a href="#loadFromData-3"><b>loadFromData</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;buf, const&nbsp;char&nbsp;*&nbsp;format = 0, int&nbsp;conversion_flags = 0 )</div></li><li><div class=fn>bool <a href="#save"><b>save</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;quality = -1 ) const</div></li><li><div class=fn>int <a href="#serialNumber"><b>serialNumber</b></a> () const</div></li><li><div class=fn>Optimization <a href="#optimization"><b>optimization</b></a> () const</div></li><li><div class=fn>void <a href="#setOptimization"><b>setOptimization</b></a> ( Optimization&nbsp;optimization )</div></li><li><div class=fn>virtual void <a href="#detach"><b>detach</b></a> ()</div></li><li><div class=fn>bool <a href="#isQBitmap"><b>isQBitmap</b></a> () const</div></li></ul><h2>Static Public Members</h2><ul><li><div class=fn>int <a href="#defaultDepth"><b>defaultDepth</b></a> ()</div></li><li><div class=fn>QPixmap <a href="#grabWindow"><b>grabWindow</b></a> ( WId&nbsp;window, int&nbsp;x = 0, int&nbsp;y = 0, int&nbsp;w = -1, int&nbsp;h = -1 )</div></li><li><div class=fn>QPixmap <a href="#grabWidget"><b>grabWidget</b></a> ( QWidget&nbsp;*&nbsp;widget, int&nbsp;x = 0, int&nbsp;y = 0, int&nbsp;w = -1, int&nbsp;h = -1 )</div></li><li><div class=fn>QWMatrix <a href="#trueMatrix"><b>trueMatrix</b></a> ( const&nbsp;QWMatrix&nbsp;&amp;&nbsp;matrix, int&nbsp;w, int&nbsp;h )</div></li><li><div class=fn>const char * <a href="#imageFormat"><b>imageFormat</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</div></li><li><div class=fn>Optimization <a href="#defaultOptimization"><b>defaultOptimization</b></a> ()</div></li><li><div class=fn>void <a href="#setDefaultOptimization"><b>setDefaultOptimization</b></a> ( Optimization&nbsp;optimization )</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn><a href="#QPixmap-a"><b>QPixmap</b></a> ( int&nbsp;w, int&nbsp;h, const&nbsp;uchar&nbsp;*&nbsp;bits, bool&nbsp;isXbitmap )</div></li><li><div class=fn>virtual int <a href="#metric"><b>metric</b></a> ( int&nbsp;m ) const</div></li></ul><h2>Related Functions</h2><ul><li><div class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</div></li><li><div class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QPixmap&nbsp;&amp;&nbsp;pixmap )</div></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 withimages; the other is <a href="qimage.html">QImage</a>. QPixmap is designed and optimizedfor drawing; QImage is designed and optimized for I/O and fordirect pixel access/manipulation. There are (slow) functions toconvert 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 updatingof widgets. Whenever something complex needs to be drawn, you canuse 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 theunderlying window system. Pixels can be accessed only through<a href="qpainter.html">QPainter</a> functions, through bitBlt(), and by converting theQPixmap 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> subclassessupport 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 apixmap. The enclosing rectangle is given by <a href="#rect">rect</a>(). Pixmaps can befilled with <a href="#fill">fill</a>() and resized with <a href="#resize">resize</a>(). You can create andset 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 canalso <a href="#loadFromData">loadFromData</a>(). You can control optimization with<a href="#setOptimization">setOptimization</a>() and obtain a transformed version of the pixmapusing <a href="#xForm">xForm</a>()<p> Note regarding Windows 95 and 98: on Windows 9x the system crashesif you create more than about 1000 pixmaps, independent of thesize of the pixmaps or installed RAM. Windows NT and 2000 do nothave this limitation.<p> Qt tries to work around the resource limitation. If you set thepixmap optimization to <a href="#Optimization-enum">QPixmap::MemoryOptim</a> and the width ofyour pixmap is less than or equal to 128 pixels, Qt stores thepixmap in a way that is very memory-efficient when there are manypixmaps.<p> If your application uses dozens or hundreds of pixmaps (forexample on tool bar buttons and in popup menus), and you plan torun it on Windows 95 or Windows 98, we recommend using code likethis:<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> <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 fewplaces; the best choice varies from pixmap to pixmap but cangenerally be derived heuristically. This enum type defines anumber of optimization modes that you can set for any pixmap totweak the speed/memory tradeoffs:<ul>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?