EffectGaussianBlur.qml Example File
multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml
import QtQuick 2.0
Item {
id: root
property bool divider: true
property real dividerValue: 0.5
property ListModel parameters: ListModel {
ListElement {
name: "Radius"
value: 0.5
}
onDataChanged: updateBlurSize()
}
function updateBlurSize()
{
if ((targetHeight > 0) && (targetWidth > 0))
{
verticalBlurSize = 4.0 * parameters.get(0).value / targetHeight;
horizontalBlurSize = 4.0 * parameters.get(0).value / targetWidth;
}
}
property alias targetWidth: verticalShader.targetWidth
property alias targetHeight: verticalShader.targetHeight
property alias source: verticalShader.source
property alias horizontalBlurSize: horizontalShader.blurSize
property alias verticalBlurSize: verticalShader.blurSize
Effect {
id: verticalShader
anchors.fill: parent
dividerValue: parent.dividerValue
property real blurSize: 0.0
onTargetHeightChanged: {
updateBlurSize()
}
onTargetWidthChanged: {
updateBlurSize()
}
fragmentShaderFilename: "gaussianblur_v.fsh"
}
Effect {
id: horizontalShader
anchors.fill: parent
dividerValue: parent.dividerValue
property real blurSize: 0.0
fragmentShaderFilename: "gaussianblur_h.fsh"
source: horizontalShaderSource
ShaderEffectSource {
id: horizontalShaderSource
sourceItem: verticalShader
smooth: true
hideSource: true
}
}
}