Blend QML Type

使用混合模式合并两个源项。更多

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

Item

属性

详细说明

可通过mode 属性选择混合模式。

来源foregroundSource应用的效果

注: 此效果在使用 OpenGL 运行时可用。

示例

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

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
    }

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

    Blend {
        anchors.fill: bug
        source: bug
        foregroundSource: butterfly
        mode: "subtract"
    }
}

属性文档

cached : bool

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

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

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

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


foregroundSource : variant

该属性定义了要在source 上混合的项目。

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


mode : string

该属性定义了foregroundSource 与源混合时使用的模式。数值不区分大小写。

模式描述
正常通过使用 alpha 混合,将foregroundSource 中的像素分量值写入源。
加法将源值和foregroundSource 中的像素分量值相加并写入。
平均值对来源和foregroundSource 的像素分量值进行平均并写入。
颜色将数据源中的亮度值与foregroundSource 中的色调和饱和度值相加后写入。
颜色灼烧将源图像中颜色较深的像素加深,如果源图像和foregroundSource 中的像素都是浅色,则结果为浅色。
颜色减淡将源图像中的浅色像素调亮,如果源图像和foregroundSource 像素都是深色,结果就是深色。
变暗写入源像素和foregroundSource 中较暗的像素分量值。
更暗的颜色写入源文件和foregroundSource 中亮度较低的像素 rgb 值。
差值写入源和foregroundSource 之间像素分量绝对值的差值。
除法将源文件中的像素分量值除以foregroundSource 中的值后写入。
排除写入源和foregroundSource 之间对比度降低的像素分量值差异。
硬光根据foregroundSource 的值对来源的像素分量值进行变亮或变暗处理并写入。
色调foregroundSource 中的色调值与来源中的饱和度和亮度值相结合并写入。
变亮写入来自源和foregroundSource 的最亮像素分量值。
更亮的颜色写入来源于foregroundSource 的亮度较高的像素 rgb 值。
亮度foregroundSource 中的亮度值与源文件中的色调和饱和度相结合并写入。
相乘将数据源和foregroundSource 中的像素分量值相乘并写入。
否定写入源和foregroundSource 之间的像素分量绝对值的反转差值。
饱和度foregroundSource 中的饱和度值与来源中的色调和亮度值合并后写入。
屏幕将源值和foregroundSource 中的像素值相减,然后相乘,再相减,最后写入。
减去foregroundSource 中的像素值从源值中减去,然后写入。
软光根据foregroundSource 的值,将源值的像素分量值稍微变亮或变暗,然后写入。
源示例示例foregroundSource

不同模式值的输出示例

模式:正常 模式:加法 模式:平均值

模式:颜色 模式:烧色 模式:滤色

模式:变暗 模式:变暗颜色 模式:差异

模式:分割 模式:排除 模式:硬光

模式:色调 模式: 调亮 模式:浅色

模式:亮度 模式:否定 模式:乘法

模式:饱和度 模式: 屏幕 模式:减

模式:柔光

source : variant

该属性定义了在foregroundSource 上混合时作为基底的源项。

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


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