📄 qpixmap.3qt
字号:
See also hasAlpha() and mask()..SH "int QPixmap::height () const"Returns the height of the pixmap..PPSee also width(), size(), and rect()..PPExamples:.)l movies/main.cpp, scribble/scribble.cpp, scrollview/scrollview.cpp, t10/cannon.cpp, and xform/xform.cpp..SH "const char * QPixmap::imageFormat ( const QString & fileName )\fC [static]\fR"Returns a string that specifies the image format of the file \fIfileName\fR, or 0 if the file cannot be read or if the format cannot be recognized..PPThe QImageIO documentation lists the supported image formats..PPSee also load() and save()..SH "bool QPixmap::isNull () const"Returns TRUE if this is a null pixmap; otherwise returns FALSE..PPA null pixmap has zero width, zero height and no contents. You cannot draw in a null pixmap or bitBlt() anything to it..PPResizing an existing pixmap to (0, 0) makes a pixmap into a null pixmap..PPSee also resize()..PPExamples:.)l movies/main.cpp, qdir/qdir.cpp, qmag/qmag.cpp, and scrollview/scrollview.cpp..SH "bool QPixmap::isQBitmap () const"Returns TRUE if this is a QBitmap; otherwise returns FALSE..SH "bool QPixmap::load ( const QString & fileName, const char * format, int conversion_flags )"Loads a pixmap from the file \fIfileName\fR at runtime. Returns TRUE if successful; otherwise returns FALSE..PPIf \fIformat\fR is specified, the loader attempts to read the pixmap using the specified format. If \fIformat\fR is not specified (default), the loader reads a few bytes from the header to guess the file's format..PPSee the convertFromImage() documentation for a description of the \fIconversion_flags\fR argument..PPThe QImageIO documentation lists the supported image formats and explains how to add extra formats..PPSee also loadFromData(), save(), imageFormat(), QImage::load(), and QImageIO..PPExamples:.)l picture/picture.cpp, scrollview/scrollview.cpp, and xform/xform.cpp..SH "bool QPixmap::load ( const QString & fileName, const char * format = 0, ColorMode mode = Auto )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPLoads a pixmap from the file \fIfileName\fR at runtime..PPIf \fIformat\fR is specified, the loader attempts to read the pixmap using the specified format. If \fIformat\fR is not specified (default), the loader reads a few bytes from the header to guess the file's format..PPThe \fImode\fR is used to specify the color mode of the pixmap..PPSee also QPixmap::ColorMode..SH "bool QPixmap::loadFromData ( const uchar * buf, uint len, const char * format, int conversion_flags )"Loads a pixmap from the binary data in \fIbuf\fR (\fIlen\fR bytes). Returns TRUE if successful; otherwise returns FALSE..PPIf \fIformat\fR is specified, the loader attempts to read the pixmap using the specified format. If \fIformat\fR is not specified (default), the loader reads a few bytes from the header to guess the file's format..PPSee the convertFromImage() documentation for a description of the \fIconversion_flags\fR argument..PPThe QImageIO documentation lists the supported image formats and explains how to add extra formats..PPSee also load(), save(), imageFormat(), QImage::loadFromData(), and QImageIO..SH "bool QPixmap::loadFromData ( const uchar * buf, uint len, const char * format = 0, ColorMode mode = Auto )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPLoads a pixmap from the binary data in \fIbuf\fR (\fIlen\fR bytes) using color mode \fImode\fR. Returns TRUE if successful; otherwise returns FALSE..PPIf \fIformat\fR is specified, the loader attempts to read the pixmap using the specified format. If \fIformat\fR is not specified (default), the loader reads a few bytes from the header to guess the file's format..PPSee also QPixmap::ColorMode..SH "bool QPixmap::loadFromData ( const QByteArray & buf, const char * format = 0, int conversion_flags = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..SH "const QBitmap * QPixmap::mask () const"Returns the mask bitmap, or 0 if no mask has been set..PPSee also setMask(), QBitmap, and hasAlpha()..SH "int QPixmap::metric ( int m ) const\fC [virtual protected]\fR"Internal implementation of the virtual QPaintDevice::metric() function..PPUse the QPaintDeviceMetrics class instead..PP\fIm\fR is the metric to get..SH "QPixmap & QPixmap::operator= ( const QPixmap & pixmap )"Assigns the pixmap \fIpixmap\fR to this pixmap and returns a reference to this pixmap..SH "QPixmap & QPixmap::operator= ( const QImage & image )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPConverts the image \fIimage\fR to a pixmap that is assigned to this pixmap. Returns a reference to the pixmap..PPSee also convertFromImage()..SH "Optimization QPixmap::optimization () const"Returns the optimization setting for this pixmap..PPThe default optimization setting is QPixmap::NormalOptim. You can change this setting in two ways:.TPCall setDefaultOptimization() to set the default optimization for all new pixmaps..TPCall setOptimization() to set the optimization for individual pixmaps..PPSee also setOptimization(), setDefaultOptimization(), and defaultOptimization()..SH "QRect QPixmap::rect () const"Returns the enclosing rectangle (0,0,width(),height()) of the pixmap..PPSee also width(), height(), and size()..SH "void QPixmap::resize ( int w, int h )"Resizes the pixmap to \fIw\fR width and \fIh\fR height. If either \fIw\fR or \fIh\fR is 0, the pixmap becomes a null pixmap..PPIf both \fIw\fR and \fIh\fR are greater than 0, a valid pixmap is created. New pixels will be uninitialized (random) if the pixmap is expanded..PPExample: grapher/grapher.cpp..SH "void QPixmap::resize ( const QSize & size )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPResizes the pixmap to size \fIsize\fR..SH "bool QPixmap::save ( const QString & fileName, const char * format, int quality = -1 ) const"Saves the pixmap to the file \fIfileName\fR using the image file format \fIformat\fR and a quality factor \fIquality\fR. \fIquality\fR 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..PPSee also load(), loadFromData(), imageFormat(), QImage::save(), and QImageIO..PPExample: qmag/qmag.cpp..SH "bool QPixmap::save ( QIODevice * device, const char * format, int quality = -1 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function writes a QPixmap to the QIODevice, \fIdevice\fR. This can be used, for example, to save a pixmap directly into a QByteArray:.PP.nf.br QPixmap pixmap;.br QByteArray ba;.br QBuffer buffer( ba );.br buffer.open( IO_WriteOnly );.br pixmap.save( &buffer, "PNG" ); // writes pixmap into ba in PNG format.br.fi.SH "bool QPixmap::selfMask () const"Returns TRUE if the pixmap's mask is identical to the pixmap itself; otherwise returns FALSE..PPSee also mask()..SH "int QPixmap::serialNumber () const"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..PPAn example of where this is useful is for caching QPixmaps..PPSee also QPixmapCache..SH "void QPixmap::setDefaultOptimization ( Optimization optimization )\fC [static]\fR"Sets the default pixmap optimization..PPAll \fInew\fR pixmaps that are created will use this default optimization. You may also set optimization for individual pixmaps using the setOptimization() function..PPThe initial default \fIoptimization\fR setting is \fCQPixmap::Normal\fR..PPSee also defaultOptimization(), setOptimization(), and optimization()..SH "void QPixmap::setMask ( const QBitmap & newmask )"Sets a mask bitmap..PPThe \fInewmask\fR bitmap defines the clip mask for this pixmap. Every pixel in \fInewmask\fR 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..PP\fBWarning:\fR Setting the mask on a pixmap will cause any alpha channel data to be cleared. For example:.PP.nf.br QPixmap alpha( "image-with-alpha.png" );.br QPixmap alphacopy = alpha;.br alphacopy.setMask( *alphacopy.mask() );.br.fiNow, alpha and alphacopy are visually different..PPSetting a null mask resets the mask..PPSee also mask(), createHeuristicMask(), and QBitmap..SH "void QPixmap::setOptimization ( Optimization optimization )"Sets pixmap drawing optimization for this pixmap..PPThe \fIoptimization\fR setting affects pixmap operations, in particular drawing of transparent pixmaps (bitBlt() a pixmap with a mask set) and pixmap transformations (the xForm() function)..PPPixmap 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..PPUse the setDefaultOptimization() to change the default optimization for all new pixmaps..PPSee also optimization(), setDefaultOptimization(), and defaultOptimization()..SH "QSize QPixmap::size () const"Returns the size of the pixmap..PPSee also width(), height(), and rect()..PPExample: movies/main.cpp..SH "QWMatrix QPixmap::trueMatrix ( const QWMatrix & matrix, int w, int h )\fC [static]\fR"Returns the actual matrix used for transforming a pixmap with \fIw\fR width and \fIh\fR height and matrix \fImatrix\fR..PPWhen transforming a pixmap with xForm(), the transformation matrix is internally adjusted to compensate for unwanted translation, i.e. xForm() returns the smallest pixmap containing all transformed points of the original pixmap..PPThis function returns the modified matrix, which maps points correctly from the original pixmap into the new pixmap..PPSee also xForm() and QWMatrix..SH "int QPixmap::width () const"Returns the width of the pixmap..PPSee also height(), size(), and rect()..PPExamples:.)l movies/main.cpp, scribble/scribble.cpp, scrollview/scrollview.cpp, and xform/xform.cpp..SH "QPixmap QPixmap::xForm ( const QWMatrix & matrix ) const"Returns a copy of the pixmap that is transformed using \fImatrix\fR. The original pixmap is not changed..PPThe transformation \fImatrix\fR is internally adjusted to compensate for unwanted translation, i.e. xForm() returns the smallest image that contains all the transformed points of the original image..PPThis function is slow because it involves transformation to a QImage, non-trivial computations and a transformation back to a QPixmap..PPSee also trueMatrix(), QWMatrix, QPainter::setWorldMatrix(), and QImage::xForm()..PPExamples:.)l fileiconview/qfileiconview.cpp, movies/main.cpp, and qmag/qmag.cpp..SH RELATED FUNCTION DOCUMENTATION.SH "void copyBlt ( QPixmap * dst, int dx, int dy, const QPixmap * src, int sx, int sy, int sw, int sh )"Copies a block of pixels from \fIsrc\fR to \fIdst\fR. The alpha channel and mask data (if any) is also copied from \fIsrc\fR. NOTE: \fIsrc\fR is \fInot\fR alpha blended or masked when copied to \fIdst\fR. Use bitBlt() or QPainter::drawPixmap() to perform alpha blending or masked drawing..PP\fIsx\fR, \fIsy\fR is the top-left pixel in \fIsrc\fR (0, 0 by default), \fIdx\fR, \fIdy\fR is the top-left position in \fIdst\fR and \fIsw\fR, \\sh is the size of the copied block (all of \fIsrc\fR by default)..PPIf \fIsrc\fR, \fIdst\fR, \fIsw\fR or \fIsh\fR is 0 (zero), copyBlt() does nothing. If \fIsw\fR or \fIsh\fR is negative, copyBlt() copies starting at \fIsx\fR (and respectively, \fIsy\fR) and ending at the right edge (and respectively, the bottom edge) of \fIsrc\fR..PPcopyBlt() does nothing if \fIsrc\fR and \fIdst\fR have different depths..SH "QDataStream & operator<< ( QDataStream & s, const QPixmap & pixmap )"Writes the pixmap \fIpixmap\fR to the stream \fIs\fR as a PNG image..PPNote that writing the stream to a file will not produce a valid image file..PPSee also QPixmap::save() and Format of the QDataStream operators..SH "QDataStream & operator>> ( QDataStream & s, QPixmap & pixmap )"Reads a pixmap from the stream \fIs\fR into the pixmap \fIpixmap\fR..PPSee also QPixmap::load() and Format of the QDataStream operators..SH "SEE ALSO".BR http://doc.trolltech.com/qpixmap.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qpixmap.3qt) and the Qtversion (3.3.5).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -