GammaAdjust QML Type

改变源项的亮度。更多

Import Statement: import Qt5Compat.GraphicalEffects
Since: QtGraphicalEffects 1.0
Inherits:

Item

属性

详细说明

GammaAdjust 根据预先定义为幂律表达式的曲线应用于每个像素,其中属性 gamma 用作倒数缩放指数。详情请参考gamma 的属性文档。

来源应用效果

示例

下面的示例展示了如何应用该效果。

import QtQuick
import Qt5Compat.GraphicalEffects

Item {
    width: 300
    height: 300

    Image {
        id: bug
        source: "images/bug.jpg"
        sourceSize: Qt.size(parent.width, parent.height)
        smooth: true
        visible: false
    }

    GammaAdjust {
        anchors.fill: bug
        source: bug
        gamma: 0.45
    }
}

属性文档

cached : bool

此属性允许缓存效果输出像素,以提高渲染性能。

每次更改源或效果属性时,都必须更新缓存中的像素。由于需要额外的内存缓冲区来存储效果输出,因此会增加内存消耗。

建议在动画源或特效属性时禁用缓存。

默认情况下,该属性设置为false


gamma : real

该属性定义了根据等式改变每个像素亮度的变化系数:

luminance = pow(original_luminance, 1.0 / gamma); // The luminance is assumed to be between 0.0 and 1.0

将伽玛值设为 1.0 以下会使图像变暗,设为 1.0 以上会使图像变亮。

数值范围从 0.0(最暗)到 inf(最亮)。默认情况下,该属性设置为1.0 (无变化)。

不同伽玛值的输出示例

gamma: 0.5 gamma: 1.0 伽玛值:2.0
上述图像的像素亮度曲线。

红色曲线:默认伽玛值(1.0)
黄色曲线:应用的效果
X 轴:像素原始亮度
Y轴:应用效果后的像素亮度

source : variant

该属性定义了要调整亮度的源项。

注意: 不支持让效果包含自身,例如将源设置为效果的父项。


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