QColormap Class

QColormap 类可将独立于设备的 QColors 映射到与设备相关的像素值。更多

Header: #include <QColormap>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets

公共类型

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::Gray2Indexed 相似,像素值代表可用灰度色调列表。QColormap 使用与 RGB 值计算出的灰度色调最匹配的灰度色调索引。

成员函数文档

QColormap::QColormap(const QColormap &colormap)

构建另一个colormap 的副本。

[noexcept] QColormap::~QColormap()

破坏色谱图。

const QColor QColormap::colorAt(uint pixel) const

返回pixelQColor

另请参阅 pixel() 。

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

返回代表IndexedGray 模式下设备颜色映射的颜色列表。对于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

IndexedGray 模式下,返回颜色映射表的大小;在Direct 模式下,返回-1。

另请参见 colormap().

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

将给定的colormap 分配给颜色贴图,并返回颜色贴图的引用。

© 2025 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.