📄 qimage.3qt
字号:
.PPReturns TRUE if the image was successfully saved; otherwise returns FALSE..PPSee also load(), loadFromData(), imageFormat(), QPixmap::save(), and QImageIO..SH "bool QImage::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 QImage to the QIODevice, \fIdevice\fR. This can be used, for example, to save an image directly into a QByteArray:.PP.nf.br QImage image;.br QByteArray ba;.br QBuffer buffer( ba );.br buffer.open( IO_WriteOnly );.br image.save( &buffer, "PNG" ); // writes image into ba in PNG format.br.fi.SH "QImage QImage::scale ( int w, int h, ScaleMode mode = ScaleFree ) const"Returns a copy of the image scaled to a rectangle of width \fIw\fR and height \fIh\fR according to the ScaleMode \fImode\fR..TPIf \fImode\fR is ScaleFree, the image is scaled to (\fIw\fR, \fIh\fR)..TPIf \fImode\fR is ScaleMin, the image is scaled to a rectangle as large as possible inside (\fIw\fR, \fIh\fR), preserving the aspect ratio..TPIf \fImode\fR is ScaleMax, the image is scaled to a rectangle as small as possible outside (\fIw\fR, \fIh\fR), preserving the aspect ratio..PPIf either the width \fIw\fR or the height \fIh\fR is 0 or negative, this function returns a null image..PPThis function uses a simple, fast algorithm. If you need better quality, use smoothScale() instead..PPSee also scaleWidth(), scaleHeight(), smoothScale(), and xForm()..SH "QImage QImage::scale ( const QSize & s, ScaleMode mode = ScaleFree ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThe requested size of the image is \fIs\fR..SH "QImage QImage::scaleHeight ( int h ) const"Returns a scaled copy of the image. The returned image has a height of \fIh\fR pixels. This function automatically calculates the width of the image so that the ratio of the image is preserved..PPIf \fIh\fR is 0 or negative a null image is returned..PPSee also scale(), scaleWidth(), smoothScale(), and xForm()..PPExample: table/small-table-demo/main.cpp..SH "QImage QImage::scaleWidth ( int w ) const"Returns a scaled copy of the image. The returned image has a width of \fIw\fR pixels. This function automatically calculates the height of the image so that the ratio of the image is preserved..PPIf \fIw\fR is 0 or negative a null image is returned..PPSee also scale(), scaleHeight(), smoothScale(), and xForm()..SH "uchar * QImage::scanLine ( int i ) const"Returns a pointer to the pixel data at the scanline with index \fIi\fR. The first scanline is at index 0..PPThe scanline data is aligned on a 32-bit boundary..PP\fBWarning:\fR If you are accessing 32-bpp image data, cast the returned pointer to \fCQRgb*\fR (QRgb has a 32-bit size) and use it to read/write the pixel value. You cannot use the \fCuchar*\fR pointer directly, because the pixel format depends on the byte order on the underlying platform. Hint: use qRed(), qGreen() and qBlue(), etc. (qcolor.h) to access the pixels..PP\fBWarning:\fR If you are accessing 16-bpp image data, you must handle endianness yourself..PPSee also bytesPerLine(), bits(), and jumpTable()..PPExample: desktop/desktop.cpp..SH "void QImage::setAlphaBuffer ( bool enable )"Enables alpha buffer mode if \fIenable\fR is TRUE, otherwise disables it. The default setting is disabled..PPAn 8-bpp image has 8-bit pixels. A pixel is an index into the color table, which contains 32-bit color values. In a 32-bpp image, the 32-bit pixels are the color values..PPThis 32-bit value is encoded as follows: The lower 24 bits are used for the red, green, and blue components. The upper 8 bits contain the alpha component..PPThe alpha component specifies the transparency of a pixel. 0 means completely transparent and 255 means opaque. The alpha component is ignored if you do not enable alpha buffer mode..PPThe alpha buffer is used to set a mask when a QImage is translated to a QPixmap..PPSee also hasAlphaBuffer() and createAlphaMask()..SH "void QImage::setColor ( int i, QRgb c )"Sets a color in the color table at index \fIi\fR to \fIc\fR..PPA color value is an RGB triplet. Use the qRgb() function (defined in qcolor.h) to make RGB triplets..PPSee also color(), setNumColors(), and numColors()..PPExamples:.)l desktop/desktop.cpp and themes/wood.cpp..SH "void QImage::setDotsPerMeterX ( int x )"Sets the value returned by dotsPerMeterX() to \fIx\fR..SH "void QImage::setDotsPerMeterY ( int y )"Sets the value returned by dotsPerMeterY() to \fIy\fR..SH "void QImage::setNumColors ( int numColors )"Resizes the color table to \fInumColors\fR colors..PPIf the color table is expanded all the extra colors will be set to black (RGB 0,0,0)..PPSee also numColors(), color(), setColor(), and colorTable()..SH "void QImage::setOffset ( const QPoint & p )"Sets the value returned by offset() to \fIp\fR..SH "void QImage::setPixel ( int x, int y, uint index_or_rgb )"Sets the pixel index or color at the coordinates (\fIx\fR, \fIy\fR) to \fIindex_or_rgb\fR..PPIf (\fIx\fR, \fIy\fR) is not valid, the result is undefined..PPIf the image is a paletted image (depth() <= 8) and \fIindex_or_rgb\fR >= numColors(), the result is undefined..PPSee also pixelIndex(), pixel(), qRgb(), qRgba(), and valid()..SH "void QImage::setText ( const char * key, const char * lang, const QString & s )"Records string \fIs\fR for the keyword \fIkey\fR. The \fIkey\fR should be a portable keyword recognizable by other software - some suggested values can be found in the PNG specification. \fIs\fR can be any text. \fIlang\fR should specify the language code (see RFC 1766) or 0..SH "QSize QImage::size () const"Returns the size of the image, i.e. its width and height..PPSee also width(), height(), and rect()..SH "QImage QImage::smoothScale ( int w, int h, ScaleMode mode = ScaleFree ) const"Returns a smoothly scaled copy of the image. The returned image has a size of width \fIw\fR by height \fIh\fR pixels if \fImode\fR is ScaleFree. The modes ScaleMin and ScaleMax may be used to preserve the ratio of the image: if \fImode\fR is ScaleMin, the returned image is guaranteed to fit into the rectangle specified by \fIw\fR and \fIh\fR (it is as large as possible within the constraints); if \fImode\fR is ScaleMax, the returned image fits at least into the specified rectangle (it is a small as possible within the constraints)..PPFor 32-bpp images and 1-bpp/8-bpp color images the result will be 32-bpp, whereas all-gray images (including black-and-white 1-bpp) will produce 8-bit grayscale images with the palette spanning 256 grays from black to white..PPThis function uses code based on pnmscale.c by Jef Poskanzer..PPpnmscale.c - read a portable anymap and scale it.PPCopyright (C) 1989, 1991 by Jef Poskanzer..PPPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty..PPSee also scale() and mirror()..SH "QImage QImage::smoothScale ( const QSize & s, ScaleMode mode = ScaleFree ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThe requested size of the image is \fIs\fR..SH "QImage QImage::swapRGB () const"Returns a QImage in which the values of the red and blue components of all pixels have been swapped, effectively converting an RGB image to a BGR image. The original QImage is not changed..SH "Endian QImage::systemBitOrder ()\fC [static]\fR"Determines the bit order of the display hardware. Returns QImage::LittleEndian (LSB first) or QImage::BigEndian (MSB first)..PPSee also systemByteOrder()..SH "Endian QImage::systemByteOrder ()\fC [static]\fR"Determines the host computer byte order. Returns QImage::LittleEndian (LSB first) or QImage::BigEndian (MSB first)..PPSee also systemBitOrder()..SH "QString QImage::text ( const char * key, const char * lang = 0 ) const"Returns the string recorded for the keyword \fIkey\fR in language \fIlang\fR, or in a default language if \fIlang\fR is 0..SH "QString QImage::text ( const QImageTextKeyLang & kl ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the string recorded for the keyword and language \fIkl\fR..SH "QStringList QImage::textKeys () const"Returns the keywords for which some texts are recorded..PPNote that if you want to iterate over the list, you should iterate over a copy, e.g..PP.nf.br QStringList list = myImage.textKeys();.br QStringList::Iterator it = list.begin();.br while( it != list.end() ) {.br myProcessing( *it );.br ++it;.br }.br.fi.PPSee also textList(), text(), setText(), and textLanguages()..SH "QStringList QImage::textLanguages () const"Returns the language identifiers for which some texts are recorded..PPNote that if you want to iterate over the list, you should iterate over a copy, e.g..PP.nf.br QStringList list = myImage.textLanguages();.br QStringList::Iterator it = list.begin();.br while( it != list.end() ) {.br myProcessing( *it );.br ++it;.br }.br.fi.PPSee also textList(), text(), setText(), and textKeys()..SH "QValueList<QImageTextKeyLang> QImage::textList () const"Returns a list of QImageTextKeyLang objects that enumerate all the texts key/language pairs set by setText() for this image..PPNote that if you want to iterate over the list, you should iterate over a copy, e.g..PP.nf.br QValueList<QImageTextKeyLang> list = myImage.textList();.br QValueList<QImageTextKeyLang>::Iterator it = list.begin();.br while( it != list.end() ) {.br myProcessing( *it );.br ++it;.br }.br.fi.SH "bool QImage::valid ( int x, int y ) const"Returns TRUE if ( \fIx\fR, \fIy\fR ) is a valid coordinate in the image; otherwise returns FALSE..PPSee also width(), height(), and pixelIndex()..PPExamples:.)l canvas/canvas.cpp and qmag/qmag.cpp..SH "int QImage::width () const"Returns the width of the image..PPSee also height(), size(), and rect()..PPExamples:.)l canvas/canvas.cpp and opengl/texture/gltexobj.cpp..SH "QImage QImage::xForm ( const QWMatrix & matrix ) const"Returns a copy of the image that is transformed using the transformation matrix, \fImatrix\fR..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..PPSee also scale(), QPixmap::xForm(), QPixmap::trueMatrix(), and QWMatrix..SH RELATED FUNCTION DOCUMENTATION.SH "QDataStream & operator<< ( QDataStream & s, const QImage & image )"Writes the image \fIimage\fR to the stream \fIs\fR as a PNG image, or as a BMP image if the stream's version is 1..PPNote that writing the stream to a file will not produce a valid image file..PPSee also QImage::save() and Format of the QDataStream operators..SH "QDataStream & operator>> ( QDataStream & s, QImage & image )"Reads an image from the stream \fIs\fR and stores it in \fIimage\fR..PPSee also QImage::load() and Format of the QDataStream operators..SH "SEE ALSO".BR http://doc.trolltech.com/qimage.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 (qimage.3qt) and the Qtversion (3.2.3).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -