Blend QML Type
使用混合模式合并两个源对象。更多...
| Import Statement: | import Qt5Compat.GraphicalEffects |
| Since: | QtGraphicalEffects 1.0 |
| Inherits: |
属性
- cached : bool
- foregroundSource : variant
- mode : string
- source : variant
详细说明
可通过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.
























