MaskedBlur QML Type
应用不同密度的模糊效果。更多
Import Statement: | import Qt5Compat.GraphicalEffects |
Since: | QtGraphicalEffects 1.0 |
Inherits: |
属性
- cached : alias
- maskSource : alias
- radius : alias
- samples : alias
- source : alias
详细说明
MaskedBlur 效果通过模糊图像来柔化图像。可以使用maskSource 来控制每个像素的模糊强度,这样信号源的某些部分就会比其他部分更加模糊。
实时模糊是一项成本较高的操作。即使采样数量适中的全屏高斯模糊,在高端图形硬件上也只能以 60 fps 的速度运行。
来源 | 遮罩源 | 应用的效果 |
---|---|---|
注: 此效果在使用 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 } LinearGradient { id: mask anchors.fill: bug gradient: Gradient { GradientStop { position: 0.2; color: "#ffffffff" } GradientStop { position: 0.5; color: "#00ffffff" } } start: Qt.point(0, 0) end: Qt.point(300, 0) visible: false } MaskedBlur { anchors.fill: bug source: bug maskSource: mask radius: 16 samples: 24 } }
属性文档
cached : alias |
此属性允许缓存效果输出像素,以提高渲染性能。每次更改源或特效属性时,都必须更新缓存中的像素。由于需要额外的内存缓冲区来存储效果输出,因此会增加内存消耗。
建议在动画源或特效属性时禁用缓存。
默认情况下,该属性设置为false
。
maskSource : alias |
该属性定义了控制模糊最终强度的项目。来自 maskSource 的像素 alpha 通道值定义了用于模糊相应源像素的实际模糊半径。
不透明的 maskSource 像素会产生指定的模糊效果radius ,而透明像素则会完全抑制模糊效果。半透明的 maskSource 像素产生的模糊半径是根据像素的透明度级别内插的。
radius : alias |
samples : alias |
该属性定义了在进行模糊计算时,每个像素取样的数量。数值越大,质量越好,但渲染速度越慢。
理想情况下,该值应是所需最高半径值的两倍再加 1,例如,如果半径在 0.0 和 4.0 之间,样本数应设置为 9。
默认情况下,该属性设置为9
。
该属性不用于动画。更改此属性可能会导致重新编译底层 OpenGL 着色器。
source : alias |
该属性定义了将被模糊的源项。
注意: 不支持让效果包含自身,例如将源设置为效果的父级。
© 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.