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 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><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 QImage & image )</div></li><li><div class=fn><a href="#QPixmap-3"><b>QPixmap</b></a> ( int w, int h, int depth = -1, Optimization optimization = DefaultOptim )</div></li><li><div class=fn><a href="#QPixmap-4"><b>QPixmap</b></a> ( const QSize & size, int depth = -1, Optimization optimization = DefaultOptim )</div></li><li><div class=fn><a href="#QPixmap-5"><b>QPixmap</b></a> ( const QString & fileName, const char * format = 0, ColorMode mode = Auto )</div></li><li><div class=fn><a href="#QPixmap-6"><b>QPixmap</b></a> ( const QString & fileName, const char * format, int conversion_flags )</div></li><li><div class=fn><a href="#QPixmap-7"><b>QPixmap</b></a> ( const char * xpm[] )</div></li><li><div class=fn><a href="#QPixmap-8"><b>QPixmap</b></a> ( const QByteArray & img_data )</div></li><li><div class=fn><a href="#QPixmap-9"><b>QPixmap</b></a> ( const QPixmap & pixmap )</div></li><li><div class=fn><a href="#~QPixmap"><b>~QPixmap</b></a> ()</div></li><li><div class=fn>QPixmap & <a href="#operator-eq"><b>operator=</b></a> ( const QPixmap & pixmap )</div></li><li><div class=fn>QPixmap & <a href="#operator-eq-2"><b>operator=</b></a> ( const QImage & 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 QColor & fillColor = Qt::white )</div></li><li><div class=fn>void <a href="#fill-2"><b>fill</b></a> ( const QWidget * widget, int xofs, int yofs )</div></li><li><div class=fn>void <a href="#fill-3"><b>fill</b></a> ( const QWidget * widget, const QPoint & ofs )</div></li><li><div class=fn>void <a href="#resize"><b>resize</b></a> ( int w, int h )</div></li><li><div class=fn>void <a href="#resize-2"><b>resize</b></a> ( const QSize & 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 QBitmap & 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 clipTight = TRUE ) const</div></li><li><div class=fn>QPixmap <a href="#xForm"><b>xForm</b></a> ( const QWMatrix & 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 QImage & image, ColorMode mode = Auto )</div></li><li><div class=fn>bool <a href="#convertFromImage"><b>convertFromImage</b></a> ( const QImage & img, int conversion_flags )</div></li><li><div class=fn>bool <a href="#load-2"><b>load</b></a> ( const QString & fileName, const char * format = 0, ColorMode mode = Auto )</div></li><li><div class=fn>bool <a href="#load"><b>load</b></a> ( const QString & fileName, const char * format, int conversion_flags )</div></li><li><div class=fn>bool <a href="#loadFromData-2"><b>loadFromData</b></a> ( const uchar * buf, uint len, const char * format = 0, ColorMode mode = Auto )</div></li><li><div class=fn>bool <a href="#loadFromData"><b>loadFromData</b></a> ( const uchar * buf, uint len, const char * format, int conversion_flags )</div></li><li><div class=fn>bool <a href="#loadFromData-3"><b>loadFromData</b></a> ( const QByteArray & buf, const char * format = 0, int conversion_flags = 0 )</div></li><li><div class=fn>bool <a href="#save"><b>save</b></a> ( const QString & fileName, const char * format, int 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 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 window, int x = 0, int y = 0, int w = -1, int h = -1 )</div></li><li><div class=fn>QPixmap <a href="#grabWidget"><b>grabWidget</b></a> ( QWidget * widget, int x = 0, int y = 0, int w = -1, int h = -1 )</div></li><li><div class=fn>QWMatrix <a href="#trueMatrix"><b>trueMatrix</b></a> ( const QWMatrix & matrix, int w, int h )</div></li><li><div class=fn>const char * <a href="#imageFormat"><b>imageFormat</b></a> ( const QString & 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 optimization )</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn><a href="#QPixmap-a"><b>QPixmap</b></a> ( int w, int h, const uchar * bits, bool isXbitmap )</div></li><li><div class=fn>virtual int <a href="#metric"><b>metric</b></a> ( int m ) const</div></li></ul><h2>Related Functions</h2><ul><li><div class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QPixmap & pixmap )</div></li><li><div class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QPixmap & 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 + -
显示快捷键?