<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/opengl/qglcolormap.cpp --> <head> <title>Qt 4.2: QGLColormap Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td> <td width="1"> </td><td class="postheader" 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="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QGLColormap Class Reference<br /><sup><sup>[<a href="qtopengl.html">QtOpenGL</a> module]</sup></sup></h1> <p>The QGLColormap class is used for installing custom colormaps into QGLWidgets. <a href="#details">More...</a></p> <pre> #include <QGLColormap></pre><ul> <li><a href="qglcolormap-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h3>Public Functions</h3> <ul> <li><div class="fn"/><b><a href="qglcolormap.html#QGLColormap">QGLColormap</a></b> ()</li> <li><div class="fn"/><b><a href="qglcolormap.html#QGLColormap-2">QGLColormap</a></b> ( const QGLColormap & <i>map</i> )</li> <li><div class="fn"/><b><a href="qglcolormap.html#dtor.QGLColormap">~QGLColormap</a></b> ()</li> <li><div class="fn"/>QColor <b><a href="qglcolormap.html#entryColor">entryColor</a></b> ( int <i>idx</i> ) const</li> <li><div class="fn"/>QRgb <b><a href="qglcolormap.html#entryRgb">entryRgb</a></b> ( int <i>idx</i> ) const</li> <li><div class="fn"/>int <b><a href="qglcolormap.html#find">find</a></b> ( QRgb <i>color</i> ) const</li> <li><div class="fn"/>int <b><a href="qglcolormap.html#findNearest">findNearest</a></b> ( QRgb <i>color</i> ) const</li> <li><div class="fn"/>bool <b><a href="qglcolormap.html#isEmpty">isEmpty</a></b> () const</li> <li><div class="fn"/>void <b><a href="qglcolormap.html#setEntries">setEntries</a></b> ( int <i>count</i>, const QRgb * <i>colors</i>, int <i>base</i> = 0 )</li> <li><div class="fn"/>void <b><a href="qglcolormap.html#setEntry">setEntry</a></b> ( int <i>idx</i>, QRgb <i>color</i> )</li> <li><div class="fn"/>void <b><a href="qglcolormap.html#setEntry-2">setEntry</a></b> ( int <i>idx</i>, const QColor & <i>color</i> )</li> <li><div class="fn"/>int <b><a href="qglcolormap.html#size">size</a></b> () const</li> <li><div class="fn"/>QGLColormap & <b><a href="qglcolormap.html#operator-eq">operator=</a></b> ( const QGLColormap & <i>map</i> )</li> </ul> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QGLColormap class is used for installing custom colormaps into QGLWidgets.</p> <p>QGLColormap provides a platform independent way of specifying and installing indexed colormaps into QGLWidgets. QGLColormap is especially useful when using the OpenGL color-index mode.</p> <p>Under X11 you must use an X server that supports either a <tt>PseudoColor</tt> or <tt>DirectColor</tt> visual class. If your X server currently only provides a <tt>GrayScale</tt>, <tt>TrueColor</tt>, <tt>StaticColor</tt> or <tt>StaticGray</tt> visual, you will not be able to allocate colorcells for writing. If this is the case, try setting your X server to 8 bit mode. It should then provide you with at least a <tt>PseudoColor</tt> visual. Note that you may experience colormap flashing if your X server is running in 8 bit mode.</p> <p>Under Windows the size of the colormap is always set to 256 colors. Note that under Windows you can also install colormaps in child widgets.</p> <p>This class uses <a href="shared.html#implicit-sharing">implicit sharing</a> as a memory and speed optimization.</p> <p>Example of use:</p> <pre> #include <QApplication> #include <QGLColormap> int main() { QApplication app(argc, argv); MySuperGLWidget widget; <span class="comment">// a QGLWidget in color-index mode</span> QGLColormap colormap; <span class="comment">// This will fill the colormap with colors ranging from</span> <span class="comment">// black to white.</span> for (int i = 0; i < colormap.size(); i++) colormap.setEntry(i, qRgb(i, i, i)); widget.setColormap(colormap); widget.show(); return app.exec(); }</pre> <p>See also <a href="qglwidget.html#setColormap">QGLWidget::setColormap</a>() and <a href="qglwidget.html#colormap">QGLWidget::colormap</a>().</p> <hr /> <h2>Member Function Documentation</h2> <h3 class="fn"><a name="QGLColormap"></a>QGLColormap::QGLColormap ()</h3> <p>Construct a <a href="qglcolormap.html">QGLColormap</a>.</p> <h3 class="fn"><a name="QGLColormap-2"></a>QGLColormap::QGLColormap ( const QGLColormap & <i>map</i> )</h3> <p>Construct a shallow copy of <i>map</i>.</p> <h3 class="fn"><a name="dtor.QGLColormap"></a>QGLColormap::~QGLColormap ()</h3> <p>Dereferences the <a href="qglcolormap.html">QGLColormap</a> and deletes it if this was the last reference to it.</p> <h3 class="fn"><a name="entryColor"></a><a href="qcolor.html">QColor</a> QGLColormap::entryColor ( int <i>idx</i> ) const</h3> <p>Returns the <a href="qcolor.html#QRgb-typedef">QRgb</a> value in the colorcell with index <i>idx</i>.</p> <h3 class="fn"><a name="entryRgb"></a><a href="qcolor.html#QRgb-typedef">QRgb</a> QGLColormap::entryRgb ( int <i>idx</i> ) const</h3> <p>Returns the <a href="qcolor.html#QRgb-typedef">QRgb</a> value in the colorcell with index <i>idx</i>.</p> <h3 class="fn"><a name="find"></a>int QGLColormap::find ( <a href="qcolor.html#QRgb-typedef">QRgb</a> <i>color</i> ) const</h3> <p>Returns the index of the color <i>color</i>. If <i>color</i> is not in the map, -1 is returned.</p> <h3 class="fn"><a name="findNearest"></a>int QGLColormap::findNearest ( <a href="qcolor.html#QRgb-typedef">QRgb</a> <i>color</i> ) const</h3> <p>Returns the index of the color that is the closest match to color <i>color</i>.</p> <h3 class="fn"><a name="isEmpty"></a>bool QGLColormap::isEmpty () const</h3> <p>Returns true if the colormap is empty; otherwise returns false. A colormap with no color values set is considered to be empty.</p> <h3 class="fn"><a name="setEntries"></a>void QGLColormap::setEntries ( int <i>count</i>, const <a href="qcolor.html#QRgb-typedef">QRgb</a> * <i>colors</i>, int <i>base</i> = 0 )</h3> <p>Set an array of cells in this colormap. <i>count</i> is the number of colors that should be set, <i>colors</i> is the array of colors, and <i>base</i> is the starting index.</p> <h3 class="fn"><a name="setEntry"></a>void QGLColormap::setEntry ( int <i>idx</i>, <a href="qcolor.html#QRgb-typedef">QRgb</a> <i>color</i> )</h3> <p>Set cell at index <i>idx</i> in the colormap to color <i>color</i>.</p> <h3 class="fn"><a name="setEntry-2"></a>void QGLColormap::setEntry ( int <i>idx</i>, const <a href="qcolor.html">QColor</a> & <i>color</i> )</h3> <p>This is an overloaded member function, provided for convenience.</p> <p>Set the cell with index <i>idx</i> in the colormap to color <i>color</i>.</p> <h3 class="fn"><a name="size"></a>int QGLColormap::size () const</h3> <p>Returns the number of colorcells in the colormap.</p> <h3 class="fn"><a name="operator-eq"></a>QGLColormap & QGLColormap::operator= ( const QGLColormap & <i>map</i> )</h3> <p>Assign a shallow copy of <i>map</i> to this <a href="qglcolormap.html">QGLColormap</a>.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="30%">Copyright © 2006 <a href="trolltech.html">Trolltech</a></td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt 4.2.1</div></td> </tr></table></div></address></body> </html>