本页内容

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 ”进行混合的对象。

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

mode : string

此属性定义了将“foregroundSource ”与源素材进行混合时所使用的模式。属性值不区分大小写。

mode描述
normal通过使用 Alpha 混合,将foregroundSource 的像素分量值写入源图像上。
addition将源图像和foregroundSource 的像素分量值相加后写入。
平均将源图像和foregroundSource 的像素分量值求平均值后写入。
颜色将源图像的明度值与foregroundSource 的色相和饱和度相结合,并写入。
colorBurn源图像中较暗的像素会被进一步加深;如果源图像和foregroundSource 中的像素都是浅色的,则结果为浅色。
colorDodge源图像中较亮的像素会变得更亮;如果源图像和foregroundSource 中的像素都是暗的,则结果为暗色。
darken将源图像和foregroundSource 中较暗的像素分量值写入。
darkerColor将源图像和foregroundSource 中亮度较低的像素RGB值写入。
difference写入源图像与foregroundSource 之间的像素分量值的绝对差值。
divide将源图像的像素分量值除以foregroundSource 中的值,并将结果写入。
exclusion写入源图像与foregroundSource 之间对比度降低后的像素分量值差。
hardLight源图像的像素分量值会根据“foregroundSource ”的值进行变亮或变暗处理,然后写入。
色相将foregroundSource 的色相值与源图像的饱和度和明度相结合,并写入结果。
lighten将源图像和foregroundSource 中的最亮像素分量值写入。
lighterColor将源图像和foregroundSource 中亮度较高的像素的RGB值写入。
lightness将foregroundSource 中的明度值与源图像和 中的色相及饱和度相结合后写入。
multiply将源和foregroundSource 的像素分量值相乘后写入。
取反写入源图像与foregroundSource 之间像素分量值的绝对差值的反相结果。
饱和度将foregroundSource 的饱和度值与源图像的色相和明度值相结合,并写入结果。
屏幕将源图像和foregroundSource 的像素值取反,然后相乘,再次取反,并写入。
subtract将foregroundSource 的像素值从源图像中减去,然后写入。
softLight源图像的像素分量值会根据foregroundSource 的值略微变亮或变暗,然后写入。
源图像示例示例foregroundSource

叶子上的黑甲虫

色彩斑斓的蝴蝶图案

具有不同模式值的输出示例

“混合”效果与“正常”模式

混合效果与加法模式

使用“平均”模式的混合效果

模式:normal 模式:加法 模式:平均

混合效果与颜色模式

使用“颜色加深”模式混合效果

使用“加亮”模式混合效果

模式:色彩 模式:加深 模式:颜色提亮

使用“变暗”混合模式的混合效果

使用“更深色”模式的混合效果

“混合”效果与“差异”模式

模式:变暗 模式:加深颜色 模式:差值

混合效果与“除法”混合模式

混合效果与排除模式

“混合”效果与“硬光”模式

模式:除法 模式:排除 模式:强光

“色相”模式下的混合效果

使用“变亮”模式的混合效果

使用“浅色”模式的混合效果

模式:色相 模式:变亮 模式:更浅的颜色

使用“亮度”混合模式应用混合效果

混合效果与否定模式

“混合”效果与“正片叠底”混合模式

模式:亮度 模式:反相 模式:正片叠底

混合效果与饱和度模式

“混合”效果与“屏幕”模式

使用“减法”模式的混合效果

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

使用“柔光”模式混合效果

模式:柔光

source : variant

此属性定义了将在“foregroundSource ”效果叠加时作为基准的源对象。

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

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