qimage.html
来自「QT 下载资料仅供参考」· HTML 代码 · 共 1,041 行 · 第 1/5 页
HTML
1,041 行
<!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/qimage.cpp:67 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QImage 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>QImage Class Reference</h1><p>The QImage class provides a hardware-independent pixmaprepresentation with direct access to the pixel data.<a href="#details">More...</a><p><tt>#include <<a href="qimage-h.html">qimage.h</a>></tt><p><a href="qimage-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn>enum <a href="#Endian-enum"><b>Endian</b></a> { IgnoreEndian, BigEndian, LittleEndian }</div></li><li><div class=fn><a href="#QImage"><b>QImage</b></a> ()</div></li><li><div class=fn><a href="#QImage-2"><b>QImage</b></a> ( int w, int h, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )</div></li><li><div class=fn><a href="#QImage-3"><b>QImage</b></a> ( const QSize & size, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )</div></li><li><div class=fn><a href="#QImage-4"><b>QImage</b></a> ( const QString & fileName, const char * format = 0 )</div></li><li><div class=fn><a href="#QImage-5"><b>QImage</b></a> ( const char * const xpm[] )</div></li><li><div class=fn><a href="#QImage-6"><b>QImage</b></a> ( const QByteArray & array )</div></li><li><div class=fn><a href="#QImage-7"><b>QImage</b></a> ( uchar * yourdata, int w, int h, int depth, QRgb * colortable, int numColors, Endian bitOrder )</div></li><li><div class=fn><a href="#QImage-8"><b>QImage</b></a> ( uchar * yourdata, int w, int h, int depth, int bpl, QRgb * colortable, int numColors, Endian bitOrder )</div></li><li><div class=fn><a href="#QImage-9"><b>QImage</b></a> ( const QImage & image )</div></li><li><div class=fn><a href="#~QImage"><b>~QImage</b></a> ()</div></li><li><div class=fn>QImage & <a href="#operator-eq"><b>operator=</b></a> ( const QImage & image )</div></li><li><div class=fn>QImage & <a href="#operator-eq-2"><b>operator=</b></a> ( const QPixmap & pixmap )</div></li><li><div class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QImage & i ) const</div></li><li><div class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QImage & i ) const</div></li><li><div class=fn>void <a href="#detach"><b>detach</b></a> ()</div></li><li><div class=fn>QImage <a href="#copy"><b>copy</b></a> () const</div></li><li><div class=fn>QImage <a href="#copy-2"><b>copy</b></a> ( int x, int y, int w, int h, int conversion_flags = 0 ) const</div></li><li><div class=fn>QImage <a href="#copy-3"><b>copy</b></a> ( const QRect & r ) const</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>int <a href="#numColors"><b>numColors</b></a> () const</div></li><li><div class=fn>Endian <a href="#bitOrder"><b>bitOrder</b></a> () const</div></li><li><div class=fn>QRgb <a href="#color"><b>color</b></a> ( int i ) const</div></li><li><div class=fn>void <a href="#setColor"><b>setColor</b></a> ( int i, QRgb c )</div></li><li><div class=fn>void <a href="#setNumColors"><b>setNumColors</b></a> ( int numColors )</div></li><li><div class=fn>bool <a href="#hasAlphaBuffer"><b>hasAlphaBuffer</b></a> () const</div></li><li><div class=fn>void <a href="#setAlphaBuffer"><b>setAlphaBuffer</b></a> ( bool enable )</div></li><li><div class=fn>bool <a href="#allGray"><b>allGray</b></a> () const</div></li><li><div class=fn>bool <a href="#isGrayscale"><b>isGrayscale</b></a> () const</div></li><li><div class=fn>uchar * <a href="#bits"><b>bits</b></a> () const</div></li><li><div class=fn>uchar * <a href="#scanLine"><b>scanLine</b></a> ( int i ) const</div></li><li><div class=fn>uchar ** <a href="#jumpTable"><b>jumpTable</b></a> () const</div></li><li><div class=fn>QRgb * <a href="#colorTable"><b>colorTable</b></a> () const</div></li><li><div class=fn>int <a href="#numBytes"><b>numBytes</b></a> () const</div></li><li><div class=fn>int <a href="#bytesPerLine"><b>bytesPerLine</b></a> () const</div></li><li><div class=fn>bool <a href="#create"><b>create</b></a> ( int width, int height, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )</div></li><li><div class=fn>bool <a href="#create-2"><b>create</b></a> ( const QSize &, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )</div></li><li><div class=fn>void <a href="#reset"><b>reset</b></a> ()</div></li><li><div class=fn>void <a href="#fill"><b>fill</b></a> ( uint pixel )</div></li><li><div class=fn>void <a href="#invertPixels"><b>invertPixels</b></a> ( bool invertAlpha = TRUE )</div></li><li><div class=fn>QImage <a href="#convertDepth-2"><b>convertDepth</b></a> ( int depth ) const</div></li><li><div class=fn>QImage <a href="#convertDepthWithPalette"><b>convertDepthWithPalette</b></a> ( int d, QRgb * palette, int palette_count, int conversion_flags = 0 ) const</div></li><li><div class=fn>QImage <a href="#convertDepth"><b>convertDepth</b></a> ( int depth, int conversion_flags ) const</div></li><li><div class=fn>QImage <a href="#convertBitOrder"><b>convertBitOrder</b></a> ( Endian bitOrder ) const</div></li><li><div class=fn>enum <a href="#ScaleMode-enum"><b>ScaleMode</b></a> { ScaleFree, ScaleMin, ScaleMax }</div></li><li><div class=fn>QImage <a href="#smoothScale"><b>smoothScale</b></a> ( int w, int h, ScaleMode mode = ScaleFree ) const</div></li><li><div class=fn>QImage <a href="#smoothScale-2"><b>smoothScale</b></a> ( const QSize & s, ScaleMode mode = ScaleFree ) const</div></li><li><div class=fn>QImage <a href="#scale"><b>scale</b></a> ( int w, int h, ScaleMode mode = ScaleFree ) const</div></li><li><div class=fn>QImage <a href="#scale-2"><b>scale</b></a> ( const QSize & s, ScaleMode mode = ScaleFree ) const</div></li><li><div class=fn>QImage <a href="#scaleWidth"><b>scaleWidth</b></a> ( int w ) const</div></li><li><div class=fn>QImage <a href="#scaleHeight"><b>scaleHeight</b></a> ( int h ) const</div></li><li><div class=fn>QImage <a href="#xForm"><b>xForm</b></a> ( const QWMatrix & matrix ) const</div></li><li><div class=fn>QImage <a href="#createAlphaMask"><b>createAlphaMask</b></a> ( int conversion_flags = 0 ) const</div></li><li><div class=fn>QImage <a href="#createHeuristicMask"><b>createHeuristicMask</b></a> ( bool clipTight = TRUE ) const</div></li><li><div class=fn>QImage <a href="#mirror"><b>mirror</b></a> () const</div></li><li><div class=fn>QImage <a href="#mirror-2"><b>mirror</b></a> ( bool horizontal, bool vertical ) const</div></li><li><div class=fn>QImage <a href="#swapRGB"><b>swapRGB</b></a> () const</div></li><li><div class=fn>bool <a href="#load"><b>load</b></a> ( const QString & fileName, const char * format = 0 )</div></li><li><div class=fn>bool <a href="#loadFromData"><b>loadFromData</b></a> ( const uchar * buf, uint len, const char * format = 0 )</div></li><li><div class=fn>bool <a href="#loadFromData-2"><b>loadFromData</b></a> ( QByteArray buf, const char * format = 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>bool <a href="#valid"><b>valid</b></a> ( int x, int y ) const</div></li><li><div class=fn>int <a href="#pixelIndex"><b>pixelIndex</b></a> ( int x, int y ) const</div></li><li><div class=fn>QRgb <a href="#pixel"><b>pixel</b></a> ( int x, int y ) const</div></li><li><div class=fn>void <a href="#setPixel"><b>setPixel</b></a> ( int x, int y, uint index_or_rgb )</div></li><li><div class=fn>int <a href="#dotsPerMeterX"><b>dotsPerMeterX</b></a> () const</div></li><li><div class=fn>int <a href="#dotsPerMeterY"><b>dotsPerMeterY</b></a> () const</div></li><li><div class=fn>void <a href="#setDotsPerMeterX"><b>setDotsPerMeterX</b></a> ( int x )</div></li><li><div class=fn>void <a href="#setDotsPerMeterY"><b>setDotsPerMeterY</b></a> ( int y )</div></li><li><div class=fn>QPoint <a href="#offset"><b>offset</b></a> () const</div></li><li><div class=fn>void <a href="#setOffset"><b>setOffset</b></a> ( const QPoint & p )</div></li><li><div class=fn>QValueList<QImageTextKeyLang> <a href="#textList"><b>textList</b></a> () const</div></li><li><div class=fn>QStringList <a href="#textLanguages"><b>textLanguages</b></a> () const</div></li><li><div class=fn>QStringList <a href="#textKeys"><b>textKeys</b></a> () const</div></li><li><div class=fn>QString <a href="#text"><b>text</b></a> ( const char * key, const char * lang = 0 ) const</div></li><li><div class=fn>QString <a href="#text-2"><b>text</b></a> ( const QImageTextKeyLang & kl ) const</div></li><li><div class=fn>void <a href="#setText"><b>setText</b></a> ( const char * key, const char * lang, const QString & s )</div></li></ul><h2>Static Public Members</h2><ul><li><div class=fn>Endian <a href="#systemBitOrder"><b>systemBitOrder</b></a> ()</div></li><li><div class=fn>Endian <a href="#systemByteOrder"><b>systemByteOrder</b></a> ()</div></li><li><div class=fn>const char * <a href="#imageFormat"><b>imageFormat</b></a> ( const QString & fileName )</div></li><li><div class=fn>QStrList <a href="#inputFormats"><b>inputFormats</b></a> ()</div></li><li><div class=fn>QStrList <a href="#outputFormats"><b>outputFormats</b></a> ()</div></li><li><div class=fn>QStringList <a href="#inputFormatList"><b>inputFormatList</b></a> ()</div></li><li><div class=fn>QStringList <a href="#outputFormatList"><b>outputFormatList</b></a> ()</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 QImage & image )</div></li><li><div class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QImage & image )</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QImage class provides a hardware-independent pixmaprepresentation with direct access to the pixel data.<p> <p> It is one of the two classes Qt provides for dealing with images,the other being <a href="qpixmap.html">QPixmap</a>. QImage is designed and optimized for I/Oand for direct pixel access/manipulation. QPixmap is designed andoptimized for drawing. There are (slow) functions to convertbetween QImage and QPixmap: <a href="qpixmap.html#convertToImage">QPixmap::convertToImage</a>() and<a href="qpixmap.html#convertFromImage">QPixmap::convertFromImage</a>().<p> An image has the parameters <a href="#width">width</a>, <a href="#height">height</a> and <a href="#depth">depth</a> (bits perpixel, bpp), a color table and the actual <a href="#bits">pixels</a>. QImage supports 1-bpp, 8-bpp and 32-bpp imagedata. 1-bpp and 8-bpp images use a color lookup table; the pixelvalue is a color table index.<p> 32-bpp images encode an RGB value in 24 bits and ignore the colortable. The most significant byte is used for the <a href="#setAlphaBuffer">alpha buffer</a>.<p> An entry in the color table is an RGB triplet encoded as a <tt>uint</tt>. Use the <a href="qcolor.html#qRed">qRed()</a>, <a href="qcolor.html#qGreen">qGreen()</a> and <a href="qcolor.html#qBlue">qBlue()</a> functions (<a href="qcolor-h.html">qcolor.h</a>) to access the components, and <a href="qcolor.html#qRgb">qRgb</a> to make an RGB triplet (see the <a href="qcolor.html">QColor</a> classdocumentation).<p> 1-bpp (monochrome) images have a color table with a most twocolors. There are two different formats: big endian (MSB first) orlittle endian (LSB first) bit order. To access a single bit youwill must do some bit shifts:<p> <pre> QImage image; // sets bit at (x,y) to 1 if ( image.<a href="#bitOrder">bitOrder</a>() == QImage::<a href="#Endian-enum">LittleEndian</a> ) *(image.<a href="#scanLine">scanLine</a>(y) + (x >> 3)) |= 1 << (x & 7); else *(image.<a href="#scanLine">scanLine</a>(y) + (x >> 3)) |= 1 << (7 -(x & 7)); </pre> <p> If this looks complicated, it might be a good idea to convert the1-bpp image to an 8-bpp image using <a href="#convertDepth">convertDepth</a>().<p> 8-bpp images are much easier to work with than 1-bpp imagesbecause they have a single byte per pixel:<p> <pre> QImage image; // set entry 19 in the color table to yellow image.<a href="#setColor">setColor</a>( 19, qRgb(255,255,0) ); // set 8 bit pixel at (x,y) to value yellow (in color table) *(image.<a href="#scanLine">scanLine</a>(y) + x) = 19; </pre> <p> 32-bpp images ignore the color table; instead, each pixel containsthe RGB triplet. 24 bits contain the RGB value; the mostsignificant byte is reserved for the alpha buffer.<p> <pre> QImage image; // sets 32 bit pixel at (x,y) to yellow. uint *p = (uint *)image.<a href="#scanLine">scanLine</a>(y) + x; *p = <a href="qcolor.html#qRgb">qRgb</a>(255,255,0); </pre> <p> On Qt/Embedded, scanlines are aligned to the pixel depth and maybe padded to any degree, while on all other platforms, thescanlines are 32-bit aligned for all depths. The constructortaking a <tt>uchar*</tt> argument always expects 32-bit aligned data.On Qt/Embedded, an additional constructor allows the number ofbytes-per-line to be specified.<p> QImage supports a variety of methods for getting information aboutthe image, for example, <a href="#colorTable">colorTable</a>(), <a href="#allGray">allGray</a>(), <a href="#isGrayscale">isGrayscale</a>(),<a href="#bitOrder">bitOrder</a>(), <a href="#bytesPerLine">bytesPerLine</a>(), <a href="#depth">depth</a>(), <a href="#dotsPerMeterX">dotsPerMeterX</a>() and<a href="#dotsPerMeterY">dotsPerMeterY</a>(), <a href="#hasAlphaBuffer">hasAlphaBuffer</a>(), <a href="#numBytes">numBytes</a>(), <a href="#numColors">numColors</a>(), and<a href="#width">width</a>() and <a href="#height">height</a>().<p> Pixel colors are retrieved with <a href="#pixel">pixel</a>() and set with <a href="#setPixel">setPixel</a>().<p> QImage also supports a number of functions for creating a new
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?