返回介绍

QGLColormap Class

发布于 2019-10-04 15:00:32 字数 4713 浏览 1070 评论 0 收藏 0

The QGLColormap class is used for installing custom colormaps into QGLWidgets. More...

#include <qglcolormap.h>

List of all member functions.

Public Members

  • QGLColormap ()
  • QGLColormap ( constQGLColormap&map )
  • ~QGLColormap ()
  • QGLColormap & operator= ( constQGLColormap&map )
  • bool isEmpty () const
  • int size () const
  • void detach ()
  • void setEntries ( intcount, constQRgb*colors, intbase = 0 )
  • void setEntry ( intidx, QRgbcolor )
  • void setEntry ( intidx, constQColor&color )
  • QRgb entryRgb ( intidx ) const
  • QColor entryColor ( intidx ) const
  • int find ( QRgbcolor ) const
  • int findNearest ( QRgbcolor ) const

Detailed Description

The QGLColormap class is used for installing custom colormaps into QGLWidgets.

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.

Under X11 you will have to use an X server that supports either a PseudoColor or DirectColor visual class. If your X server currently only provides a GrayScale, TrueColor, StaticColor or StaticGray visual, you will not be able to allocate colorcells for writing. If this is the case, try setting your X server in 8 bit mode. It should then provide you with at least a PseudoColor visual. Note that you may experience colormap flashing if your X server is running in 8 bit mode.

Under Windows the size of the colormap is always set to 256 colors. Note that under Windows you are allowed to install colormaps into child widgets.

This class uses explicit sharing (see Shared Classes).

Example of use:

  #include <qapplication.h>
  #include <qglcolormap.h>

  int main()
  {
      QApplication a( argc, argv );

      MySuperGLWidget widget( 0 ); // A QGLWidget in color-index mode
      QGLColormap colormap;

      // This will fill the colormap with colors ranging from
      // black to white.
      for ( int i = 0; i < colormap.size(); i++ )
          colormap.setEntry( i, qRgb( i, i, i ) );

      widget.setColormap( colormap );
      widget.show();
      return a.exec();
  }
  

See also QGLWidget::setColormap(), QGLWidget::colormap(), Graphics Classes and Image Processing Classes.


Member Function Documentation

QGLColormap::QGLColormap ()

Construct a QGLColormap.

QGLColormap::QGLColormap ( constQGLColormap&map )

Construct a shallow copy of map.

QGLColormap::~QGLColormap ()

Dereferences the QGLColormap and deletes it if this was the last reference to it.

void QGLColormap::detach ()

Detaches this QGLColormap from the shared block.

QColor QGLColormap::entryColor ( intidx ) const

Returns the QRgb value in the colorcell with index idx.

QRgb QGLColormap::entryRgb ( intidx ) const

Returns the QRgb value in the colorcell with index idx.

int QGLColormap::find ( QRgbcolor ) const

Returns the index of the color color. If color is not in the map, -1 is returned.

int QGLColormap::findNearest ( QRgbcolor ) const

Returns the index of the color that is the closest match to color color.

bool QGLColormap::isEmpty () const

Returns TRUE if the colormap is empty; otherwise returns FALSE. A colormap with no color values set is considered to be empty.

QGLColormap& QGLColormap::operator= ( constQGLColormap&map )

Assign a shallow copy of map to this QGLColormap.

void QGLColormap::setEntries ( intcount, constQRgb*colors, intbase = 0 )

Set an array of cells in this colormap. count is the number of colors that should be set, colors is the array of colors, and base is the starting index.

void QGLColormap::setEntry ( intidx, QRgbcolor )

Set cell idx in the colormap to color color.

void QGLColormap::setEntry ( intidx, constQColor&color )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Set cell with index idx in the colormap to color color.

int QGLColormap::size () const

Returns the number of colorcells in the colormap.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文