本页内容

QColormap Class

QColormap 类将与设备无关的 QColors 映射为与设备相关的像素值。更多内容...

头文件: #include <QColormap>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
状态: 自 6.11 起已弃用

该类自 6.11 起已弃用。我们强烈建议不要在新代码中使用它。

公共类型

enum Mode { Direct, Indexed, Gray }

公共函数

QColormap(const QColormap &colormap)
~QColormap()
const QColor colorAt(uint pixel) const
const QList<QColor> colormap() const
int depth() const
QColormap::Mode mode() const
uint pixel(const QColor &color) const
int size() const
QColormap &operator=(const QColormap &colormap)

静态公共成员

QColormap instance(int screen = -1)

详细说明

成员类型文档

enum QColormap::Mode

该枚举描述了QColormap 如何将设备无关的RGB值映射为设备相关的像素值。

常量值描述
QColormap::Direct0像素值直接源自 RGB 值,也称为“真彩色”。
QColormap::Indexed1像素值代表可用颜色列表中的索引,即QColormap 使用与 RGB 值最接近的颜色的索引。
QColormap::Gray2与Indexed 类似,像素值代表一个可用灰度色调列表。QColormap 使用与RGB值计算出的灰度色调最接近的灰度色调的索引。

成员函数文档

QColormap::QColormap(const QColormap &colormap)

创建另一个colormap 的副本。

[noexcept] QColormap::~QColormap()

销毁颜色映射表。

const QColor QColormap::colorAt(uint pixel) const

返回pixel 的QColor 。

另请参阅 pixel()。

const QList<QColor> QColormap::colormap() const

返回一个颜色列表,该列表表示设备在Indexed 和Gray 模式下的颜色映射。对于Direct 模式,该函数返回一个空列表。

另请参阅 size()。

int QColormap::depth() const

返回设备的深度。

另请参阅 size()。

[static] QColormap QColormap::instance(int screen = -1)

返回指定screen 对应的颜色映射表。如果screen 为-1,则该函数返回默认屏幕的颜色映射表。

QColormap::Mode QColormap::mode() const

返回此色图的模式。

另请参阅 QColormap::Mode 。

uint QColormap::pixel(const QColor &color) const

返回color 的设备相关像素值。

另请参阅 colorAt()。

int QColormap::size() const

返回Indexed 和Gray 模式下色图的大小;在Direct 模式下返回-1。

另请参阅 colormap()。

QColormap &QColormap::operator=(const QColormap &colormap)

将给定的colormap 分配给此颜色映射,并返回对此颜色映射的引用。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.